Debugger: Remove unused WatchItem::state flag

Lately it was only set and read for debugging purposes. A mechanism
similar to the ChildrenNeeded state is still needed and available
through WatchItem::wantsChildren.

Change-Id: I78c85d65bc35810be420bd0418db9675473697cd
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
hjk
2016-08-03 13:13:06 +02:00
committed by hjk
parent a6acd3e8d9
commit 7e73e9c48f
4 changed files with 4 additions and 45 deletions

View File

@@ -615,7 +615,6 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj,
objWatch->type = obj.className();
objWatch->value = "object";
objWatch->wantsChildren = true;
objWatch->setAllUnneeded();
m_qmlEngine->watchHandler()->insertItem(objWatch);
addObjectWatch(objWatch->id);
@@ -645,7 +644,6 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj,
propertiesWatch->id = objDebugId;
propertiesWatch->value = "list";
propertiesWatch->wantsChildren = true;
propertiesWatch->setAllUnneeded();
foreach (const PropertyReference &property, obj.properties()) {
const QString propertyName = property.name();
@@ -659,7 +657,6 @@ void QmlInspectorAgent::addWatchData(const ObjectReference &obj,
propertyWatch->type = property.valueTypeName();
propertyWatch->value = property.value().toString();
propertyWatch->wantsChildren = false;
propertyWatch->setAllUnneeded();
propertiesWatch->appendChild(propertyWatch);
}

View File

@@ -109,7 +109,6 @@ bool isIntOrFloatType(const QString &type)
WatchItem::WatchItem() :
id(WatchItem::InvalidId),
state(InitialState),
address(0),
origaddr(0),
size(0),
@@ -135,7 +134,6 @@ bool WatchItem::isVTablePointer() const
void WatchItem::setError(const QString &msg)
{
setAllUnneeded();
value = msg;
wantsChildren = false;
valueEnabled = false;
@@ -178,8 +176,6 @@ void WatchItem::setValue(const QString &value0)
// column. No need to duplicate it here.
if (value.startsWith('(' + type + ") 0x"))
value = value.section(QLatin1Char(' '), -1, -1);
setValueUnneeded();
}
enum GuessChildrenResult { HasChildren, HasNoChildren, HasPossiblyChildren };
@@ -257,8 +253,6 @@ QString WatchItem::toString() const
if (!exp.isEmpty())
str << "exp=\"" << exp << doubleQuoteComma;
if (isValueNeeded())
str << "value=<needed>,";
if (!value.isEmpty())
str << "value=\"" << value << doubleQuoteComma;
@@ -272,8 +266,6 @@ QString WatchItem::toString() const
str << "wantsChildren=\"" << (wantsChildren ? "true" : "false") << doubleQuoteComma;
if (isChildrenNeeded())
str << "children=<needed>,";
str.flush();
if (res.endsWith(QLatin1Char(',')))
res.truncate(res.size() - 1);
@@ -340,7 +332,6 @@ public:
child->type = childType;
child->address = addrbase + i * addrstep;
child->valueEditable = true;
child->setAllUnneeded();
item->appendChild(child);
}
}
@@ -404,8 +395,6 @@ static bool sortByName(const WatchItem *a, const WatchItem *b)
void WatchItem::parseHelper(const GdbMi &input, bool maySort)
{
setChildrenUnneeded();
GdbMi mi = input["type"];
if (mi.isValid())
setType(mi.data());
@@ -445,11 +434,8 @@ void WatchItem::parseHelper(const GdbMi &input, bool maySort)
mi = input["value"];
QString enc = input["valueencoded"].data();
if (mi.isValid() || !enc.isEmpty()) {
if (mi.isValid() || !enc.isEmpty())
setValue(decodeData(mi.data(), enc));
} else {
setValueNeeded();
}
mi = input["size"];
if (mi.isValid())

View File

@@ -60,26 +60,9 @@ public:
WatchItem *parentItem() const;
enum State
{
ValueNeeded = 2,
ChildrenNeeded = 8,
InitialState = ValueNeeded | ChildrenNeeded
};
static const qint64 InvalidId = -1;
void setAllUnneeded() { state = State(0); }
bool isValueNeeded() const { return state & ValueNeeded; }
void setValueNeeded() { state = State(state | ValueNeeded); }
void setValueUnneeded() { state = State(state & ~ValueNeeded); }
bool isChildrenNeeded() const { return state & ChildrenNeeded; }
void setChildrenNeeded() { state = State(state | ChildrenNeeded); }
void setChildrenUnneeded() { state = State(state & ~ChildrenNeeded); }
void setHasChildren(bool c) { wantsChildren = c; if (!c) setChildrenUnneeded(); }
void setHasChildren(bool c) { wantsChildren = c; }
bool isValid() const { return !iname.isEmpty(); }
bool isVTablePointer() const;
@@ -99,7 +82,6 @@ public:
public:
qint64 id; // Token for the engine for internal mapping
qint32 state; // 'needed' flags;
QString iname; // Internal name sth like 'local.baz.public.a'
QString exp; // The expression
QString name; // Displayed name

View File

@@ -1220,12 +1220,10 @@ void WatchModel::fetchMore(const QModelIndex &idx)
WatchItem *item = nonRootItemForIndex(idx);
if (item) {
m_expandedINames.insert(item->iname);
if (item->children().isEmpty()) {
item->setChildrenNeeded();
if (item->children().isEmpty())
m_engine->expandItem(item->iname);
}
}
}
bool WatchModel::hasChildren(const QModelIndex &idx) const
{
@@ -2088,7 +2086,6 @@ void WatchHandler::watchExpression(const QString &exp, const QString &name)
saveWatchers();
if (m_model->m_engine->state() == DebuggerNotReady) {
item->setAllUnneeded();
item->setValue(QString(QLatin1Char(' ')));
item->update();
} else {
@@ -2111,7 +2108,6 @@ void WatchHandler::updateWatchExpression(WatchItem *item, const QString &newExp)
saveWatchers();
if (m_model->m_engine->state() == DebuggerNotReady) {
item->setAllUnneeded();
item->setValue(QString(QLatin1Char(' ')));
item->update();
} else {
@@ -2290,12 +2286,10 @@ void WatchHandler::fetchMore(const QString &iname) const
{
if (WatchItem *item = m_model->findItem(iname)) {
m_model->m_expandedINames.insert(iname);
if (item->children().isEmpty()) {
item->setChildrenNeeded();
if (item->children().isEmpty())
m_model->m_engine->expandItem(iname);
}
}
}
WatchItem *WatchHandler::findItem(const QString &iname) const
{