Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
3f36dbd8
Commit
3f36dbd8
authored
Jul 23, 2010
by
hjk
Browse files
debugger: simplify code for inserting new watchitems
parent
e0c8bc6f
Changes
7
Hide whitespace changes
Inline
Side-by-side
share/qtcreator/gdbmacros/dumper.py
View file @
3f36dbd8
...
...
@@ -1169,7 +1169,7 @@ class Dumper:
self
.
put
(
'name="%s",'
%
escapedExp
)
self
.
put
(
'exp="%s",'
%
escapedExp
)
handled
=
False
if
exp
==
"<Edit>"
or
len
(
exp
)
==
0
:
if
len
(
exp
)
==
0
:
# The <Edit> case
self
.
putValue
(
" "
)
self
.
putType
(
" "
)
self
.
putNumChild
(
0
)
...
...
src/plugins/debugger/debuggerconstants.h
View file @
3f36dbd8
...
...
@@ -214,7 +214,6 @@ enum ModelRoles
LocalsPointerValueRole
,
// Pointer value (address) as quint64
LocalsIsWatchpointAtAddressRole
,
LocalsIsWatchpointAtPointerValueRole
,
WatcherEditPlaceHolderRole
,
RequestWatchPointRole
,
RequestToggleWatchRole
,
RequestToolTipByExpressionRole
,
...
...
src/plugins/debugger/gdb/pythongdbengine.cpp
View file @
3f36dbd8
...
...
@@ -72,10 +72,7 @@ void GdbEngine::updateLocalsPython(const QByteArray &varList)
it
.
next
();
if
(
!
watchers
.
isEmpty
())
watchers
+=
"##"
;
if
(
it
.
key
()
==
WatchHandler
::
watcherEditPlaceHolder
().
toLatin1
())
watchers
+=
"<Edit>#watch."
+
QByteArray
::
number
(
it
.
value
());
else
watchers
+=
it
.
key
()
+
"#watch."
+
QByteArray
::
number
(
it
.
value
());
watchers
+=
it
.
key
()
+
"#watch."
+
QByteArray
::
number
(
it
.
value
());
}
QByteArray
options
;
...
...
src/plugins/debugger/pdb/pdbengine.cpp
View file @
3f36dbd8
...
...
@@ -735,10 +735,7 @@ void PdbEngine::updateLocals()
it
.
next
();
if
(
!
watchers
.
isEmpty
())
watchers
+=
"##"
;
if
(
it
.
key
()
==
WatchHandler
::
watcherEditPlaceHolder
().
toLatin1
())
watchers
+=
"<Edit>#watch."
+
QByteArray
::
number
(
it
.
value
());
else
watchers
+=
it
.
key
()
+
"#watch."
+
QByteArray
::
number
(
it
.
value
());
watchers
+=
it
.
key
()
+
"#watch."
+
QByteArray
::
number
(
it
.
value
());
}
QByteArray
options
;
...
...
src/plugins/debugger/watchhandler.cpp
View file @
3f36dbd8
...
...
@@ -599,26 +599,18 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
case
EngineActionsEnabledRole
:
return
engine
()
->
debuggerActionsEnabled
();
case
WatcherEditPlaceHolderRole
:
return
m_handler
->
watcherEditPlaceHolder
();
}
const
WatchItem
*
item
=
watchItem
(
idx
);
const
WatchItem
&
data
=
*
item
;
if
(
data
.
name
==
m_handler
->
watcherEditPlaceHolder
())
{
if
(
idx
.
column
()
==
0
&&
(
role
==
Qt
::
EditRole
||
role
==
Qt
::
DisplayRole
))
return
data
.
name
;
return
QVariant
();
}
switch
(
role
)
{
case
Qt
::
EditRole
:
case
Qt
::
DisplayRole
:
{
switch
(
idx
.
column
())
{
case
0
:
if
(
data
.
name
.
isEmpty
()
&&
role
==
Qt
::
DisplayRole
)
return
tr
(
"<Edit>"
);
if
(
data
.
name
==
QLatin1String
(
"*"
)
&&
item
->
parent
)
return
QVariant
(
QLatin1Char
(
'*'
)
+
item
->
parent
->
name
);
return
data
.
name
;
...
...
@@ -836,7 +828,7 @@ Qt::ItemFlags WatchModel::flags(const QModelIndex &idx) const
return
editable
;
// Watcher names are editable.
if
(
data
.
isWatcher
())
{
if
(
data
.
name
!=
m_handler
->
watcherEditPlaceHolder
())
{
if
(
!
data
.
name
.
isEmpty
())
{
// FIXME: Forcing types is not implemented yet.
//if (idx.column() == 2)
// return editable; // Watcher types can be set by force.
...
...
@@ -1249,7 +1241,7 @@ QByteArray WatchHandler::watcherName(const QByteArray &exp)
void
WatchHandler
::
watchExpression
(
const
QString
&
exp
)
{
// Do not insert multiple placeholders.
if
(
exp
==
watcherEditPlaceHolder
()
&&
m_watcherNames
.
contains
(
exp
.
toLatin1
()))
if
(
exp
.
isEmpty
()
&&
m_watcherNames
.
contains
(
QByteArray
()))
return
;
// FIXME: 'exp' can contain illegal characters
...
...
@@ -1257,7 +1249,7 @@ void WatchHandler::watchExpression(const QString &exp)
data
.
exp
=
exp
.
toLatin1
();
data
.
name
=
exp
;
m_watcherNames
[
data
.
exp
]
=
watcherCounter
++
;
if
(
exp
.
isEmpty
()
||
exp
==
watcherEditPlaceHolder
()
)
if
(
exp
.
isEmpty
())
data
.
setAllUnneeded
();
data
.
iname
=
watcherName
(
data
.
exp
);
if
(
m_engine
->
isSynchroneous
()
&&
!
m_engine
->
isSessionEngine
())
...
...
@@ -1416,7 +1408,7 @@ QStringList WatchHandler::watchedExpressions() const
while
(
it
.
hasNext
())
{
it
.
next
();
const
QString
&
watcherName
=
it
.
key
();
if
(
!
watcherName
.
isEmpty
()
&&
watcherName
!=
watcherEditPlaceHolder
()
)
if
(
!
watcherName
.
isEmpty
())
watcherNames
.
push_back
(
watcherName
);
}
return
watcherNames
;
...
...
@@ -1528,12 +1520,6 @@ WatchData *WatchHandler::findItem(const QByteArray &iname) const
return
model
->
findItem
(
iname
,
model
->
m_root
);
}
QString
WatchHandler
::
watcherEditPlaceHolder
()
{
static
const
QString
rc
=
tr
(
"<Edit>"
);
return
rc
;
}
void
WatchHandler
::
setFormat
(
const
QString
&
type
,
int
format
)
{
if
(
format
==
-
1
)
...
...
src/plugins/debugger/watchhandler.h
View file @
3f36dbd8
...
...
@@ -171,7 +171,6 @@ public:
QByteArray
typeFormatRequests
()
const
;
QByteArray
individualFormatRequests
()
const
;
static
QString
watcherEditPlaceHolder
();
int
format
(
const
QByteArray
&
iname
)
const
;
void
addTypeFormats
(
const
QString
&
type
,
const
QStringList
&
formats
);
...
...
src/plugins/debugger/watchwindow.cpp
View file @
3f36dbd8
...
...
@@ -206,9 +206,8 @@ void WatchWindow::mouseDoubleClickEvent(QMouseEvent *ev)
{
const
QModelIndex
idx
=
indexAt
(
ev
->
pos
());
if
(
!
idx
.
isValid
())
{
// The "<Edit>" string.
QVariant
placeHolder
=
model
()
->
data
(
idx
,
WatcherEditPlaceHolderRole
);
setModelData
(
RequestWatchExpressionRole
,
placeHolder
);
// The "<Edit>" case.
watchExpression
(
QString
());
return
;
}
QTreeView
::
mouseDoubleClickEvent
(
ev
);
...
...
@@ -410,7 +409,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
}
else
if
(
act
==
actAlwaysAdjustColumnWidth
)
{
setAlwaysResizeColumnsToContents
(
!
m_alwaysResizeColumnsToContents
);
}
else
if
(
act
==
actInsertNewWatchItem
)
{
watchExpression
(
WatchHandler
::
watcherEditPlaceHolder
());
watchExpression
(
QString
());
}
else
if
(
act
==
actOpenMemoryEditAtVariableAddress
)
{
setModelData
(
RequestShowMemoryRole
,
address
);
}
else
if
(
act
==
actOpenMemoryEditAtPointerValue
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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