Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
58c4cd8b
Commit
58c4cd8b
authored
Mar 04, 2009
by
Friedemann Kleint
Browse files
Fixes: Make Attach External Dialog play nicely (exclude self)
Details: MinGW compilation
parent
86b6c44e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/plugins/debugger/debuggerdialogs.cpp
View file @
58c4cd8b
...
...
@@ -41,6 +41,7 @@
#include
<QtCore/QDebug>
#include
<QtCore/QDir>
#include
<QtCore/QFile>
#include
<QtCore/QCoreApplication>
#include
<QtGui/QStandardItemModel>
#include
<QtGui/QHeaderView>
#include
<QtGui/QFileDialog>
...
...
@@ -115,7 +116,7 @@ static QStandardItemModel *createProcessModel(QObject *parent)
return
rc
;
}
static
bool
isProcess
Name
(
const
QString
&
procname
)
static
bool
is
Unix
Process
Id
(
const
QString
&
procname
)
{
for
(
int
i
=
0
;
i
!=
procname
.
size
();
++
i
)
if
(
!
procname
.
at
(
i
).
isDigit
())
...
...
@@ -132,31 +133,45 @@ bool operator<(const ProcData &p1, const ProcData &p2)
static
QList
<
ProcData
>
unixProcessList
()
{
QList
<
ProcData
>
rc
;
const
QStringList
proc
name
s
=
QDir
(
QLatin1String
(
"/proc/"
)).
entryList
();
if
(
proc
name
s
.
isEmpty
())
const
QStringList
proc
Id
s
=
QDir
(
QLatin1String
(
"/proc/"
)).
entryList
();
if
(
proc
Id
s
.
isEmpty
())
return
rc
;
foreach
(
const
QString
&
proc
name
,
proc
name
s
)
{
if
(
!
isProcess
Name
(
proc
name
))
foreach
(
const
QString
&
proc
Id
,
proc
Id
s
)
{
if
(
!
is
Unix
Process
Id
(
proc
Id
))
continue
;
QString
filename
=
QLatin1String
(
"/proc/"
);
filename
+=
proc
name
;
filename
+=
proc
Id
;
filename
+=
QLatin1String
(
"/stat"
);
QFile
file
(
filename
);
file
.
open
(
QIODevice
::
ReadOnly
);
const
QStringList
data
=
QString
::
fromLocal8Bit
(
file
.
readAll
()).
split
(
' '
);
ProcData
proc
;
proc
.
ppid
=
procId
;
proc
.
name
=
data
.
at
(
1
);
if
(
proc
.
name
.
startsWith
(
QLatin1Char
(
'('
))
&&
proc
.
name
.
endsWith
(
QLatin1Char
(
')'
)))
proc
.
name
=
proc
.
name
.
mid
(
1
,
proc
.
name
.
size
()
-
2
);
if
(
proc
.
name
.
startsWith
(
QLatin1Char
(
'('
))
&&
proc
.
name
.
endsWith
(
QLatin1Char
(
')'
)))
{
proc
.
name
.
truncate
(
proc
.
name
.
size
()
-
1
);
proc
.
name
.
remove
(
0
,
1
);
}
proc
.
state
=
data
.
at
(
2
);
proc
.
ppid
=
data
.
at
(
3
);
// PPID is element 3
rc
.
push_back
(
proc
);
}
return
rc
;
}
static
void
populateProcessModel
(
QStandardItemModel
*
model
)
static
inline
QStandardItem
*
createStandardItem
(
const
QString
&
text
,
bool
enabled
)
{
QStandardItem
*
rc
=
new
QStandardItem
(
text
);
rc
->
setEnabled
(
enabled
);
return
rc
;
}
// Populate a standard item model with a list
// of processes and gray out the excludePid.
static
void
populateProcessModel
(
QStandardItemModel
*
model
,
const
QString
&
excludePid
=
QString
())
{
#ifdef Q_OS_WIN
QList
<
ProcData
>
processes
=
winProcessList
();
...
...
@@ -167,15 +182,16 @@ static void populateProcessModel(QStandardItemModel *model)
if
(
const
int
rowCount
=
model
->
rowCount
())
model
->
removeRows
(
0
,
rowCount
);
QStandardItem
*
root
=
model
->
invisibleRootItem
();
foreach
(
const
ProcData
&
proc
,
processes
)
{
const
bool
enabled
=
proc
.
ppid
!=
excludePid
;
QList
<
QStandardItem
*>
row
;
row
.
append
(
new
Q
StandardItem
(
proc
.
ppid
));
row
.
append
(
new
Q
StandardItem
(
proc
.
name
));
row
.
append
(
create
StandardItem
(
proc
.
ppid
,
enabled
));
row
.
append
(
create
StandardItem
(
proc
.
name
,
enabled
));
if
(
!
proc
.
image
.
isEmpty
())
row
.
back
()
->
setToolTip
(
proc
.
image
);
row
.
append
(
new
Q
StandardItem
(
proc
.
state
));
row
.
append
(
create
StandardItem
(
proc
.
state
,
enabled
));
root
->
appendRow
(
row
);
}
}
...
...
@@ -188,12 +204,14 @@ static void populateProcessModel(QStandardItemModel *model)
AttachExternalDialog
::
AttachExternalDialog
(
QWidget
*
parent
)
:
QDialog
(
parent
),
m_selfPid
(
QString
::
number
(
QCoreApplication
::
applicationPid
())),
m_ui
(
new
Ui
::
AttachExternalDialog
),
m_model
(
createProcessModel
(
this
)),
m_proxyModel
(
new
QSortFilterProxyModel
(
this
))
{
m_ui
->
setupUi
(
this
);
m_ui
->
buttonBox
->
button
(
QDialogButtonBox
::
Ok
)
->
setDefault
(
true
);
okButton
()
->
setDefault
(
true
);
okButton
()
->
setEnabled
(
false
);
m_proxyModel
->
setSourceModel
(
m_model
);
m_proxyModel
->
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
...
...
@@ -209,6 +227,9 @@ AttachExternalDialog::AttachExternalDialog(QWidget *parent) :
connect
(
m_ui
->
procView
,
SIGNAL
(
activated
(
QModelIndex
)),
this
,
SLOT
(
procSelected
(
QModelIndex
)));
connect
(
m_ui
->
pidLineEdit
,
SIGNAL
(
textChanged
(
QString
)),
this
,
SLOT
(
pidChanged
(
QString
)));
connect
(
m_ui
->
filterClearToolButton
,
SIGNAL
(
clicked
()),
m_ui
->
filterLineEdit
,
SLOT
(
clear
()));
connect
(
m_ui
->
filterLineEdit
,
SIGNAL
(
textChanged
(
QString
)),
...
...
@@ -222,13 +243,17 @@ AttachExternalDialog::~AttachExternalDialog()
delete
m_ui
;
}
QPushButton
*
AttachExternalDialog
::
okButton
()
const
{
return
m_ui
->
buttonBox
->
button
(
QDialogButtonBox
::
Ok
);
}
void
AttachExternalDialog
::
rebuildProcessList
()
{
populateProcessModel
(
m_model
);
populateProcessModel
(
m_model
,
m_selfPid
);
m_ui
->
procView
->
expandAll
();
m_ui
->
procView
->
resizeColumnToContents
(
0
);
m_ui
->
procView
->
resizeColumnToContents
(
1
);
m_ui
->
procView
->
sortByColumn
(
1
,
Qt
::
AscendingOrder
);
}
void
AttachExternalDialog
::
procSelected
(
const
QModelIndex
&
proxyIndex
)
...
...
@@ -237,7 +262,8 @@ void AttachExternalDialog::procSelected(const QModelIndex &proxyIndex)
QModelIndex
index
=
index0
.
sibling
(
index0
.
row
(),
0
);
if
(
const
QStandardItem
*
item
=
m_model
->
itemFromIndex
(
index
))
{
m_ui
->
pidLineEdit
->
setText
(
item
->
text
());
m_ui
->
buttonBox
->
button
(
QDialogButtonBox
::
Ok
)
->
animateClick
();
if
(
okButton
()
->
isEnabled
())
okButton
()
->
animateClick
();
}
}
...
...
@@ -246,6 +272,11 @@ int AttachExternalDialog::attachPID() const
return
m_ui
->
pidLineEdit
->
text
().
toInt
();
}
void
AttachExternalDialog
::
pidChanged
(
const
QString
&
pid
)
{
okButton
()
->
setEnabled
(
!
pid
.
isEmpty
()
&&
pid
!=
m_selfPid
);
}
///////////////////////////////////////////////////////////////////////
//
// AttachRemoteDialog
...
...
src/plugins/debugger/debuggerdialogs.h
View file @
58c4cd8b
...
...
@@ -37,6 +37,7 @@ QT_BEGIN_NAMESPACE
class
QModelIndex
;
class
QStandardItemModel
;
class
QSortFilterProxyModel
;
class
QPushButton
;
namespace
Ui
{
class
AttachCoreDialog
;
...
...
@@ -90,11 +91,15 @@ public:
private
slots
:
void
rebuildProcessList
();
void
procSelected
(
const
QModelIndex
&
);
void
pidChanged
(
const
QString
&
);
private:
inline
QPushButton
*
okButton
()
const
;
const
QString
m_selfPid
;
Ui
::
AttachExternalDialog
*
m_ui
;
QSortFilterProxyModel
*
m_proxyModel
;
QStandardItemModel
*
m_model
;
QSortFilterProxyModel
*
m_proxyModel
;
};
...
...
src/plugins/debugger/debuggermanager.cpp
View file @
58c4cd8b
...
...
@@ -798,8 +798,9 @@ static bool determineDebuggerType(const QString &executable,
*
dt
=
DebuggerManager
::
ScriptDebugger
;
return
true
;
}
#ifndef Q_
W
S_WIN
#ifndef Q_
O
S_WIN
*
dt
=
DebuggerManager
::
GdbDebugger
;
Q_UNUSED
(
errorMessage
)
return
true
;
#else
// If a file has PDB files, it has been compiled by VS.
...
...
src/plugins/debugger/win/dbgwinutils.cpp
View file @
58c4cd8b
...
...
@@ -65,7 +65,7 @@ QList<ProcData> winProcessList()
for
(
bool
hasNext
=
Process32First
(
snapshot
,
&
pe
);
hasNext
;
hasNext
=
Process32Next
(
snapshot
,
&
pe
))
{
ProcData
procData
;
procData
.
ppid
=
QString
::
number
(
pe
.
th32ProcessID
);
procData
.
name
=
QString
::
fromUtf16
(
pe
.
szExeFile
);
procData
.
name
=
QString
::
fromUtf16
(
reinterpret_cast
<
ushort
*>
(
pe
.
szExeFile
)
)
;
#ifdef USE_PSAPI
procData
.
image
=
imageName
(
pe
.
th32ProcessID
);
#endif
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment