Commit 63c5fc03 authored by hjk's avatar hjk

Debugger: Split updateWatchData() paths

There are two cases that do not coincide in asynchronous
engines such as the QmlEngine: Inserting a new watch item,
and expanding the children of an existing item.

Change-Id: Ic98a5f1e89aca37146039a241de737c407606e83
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 66964ac9
......@@ -1976,13 +1976,18 @@ bool DebuggerEngine::canHandleToolTip(const DebuggerToolTipContext &context) con
return state() == InferiorStopOk && context.isCppEditor;
}
void DebuggerEngine::updateWatchData(const QByteArray &iname)
void DebuggerEngine::updateItem(const QByteArray &iname)
{
UpdateParameters params;
params.partialVariable = iname;
doUpdateLocals(params);
}
void DebuggerEngine::expandItem(const QByteArray &iname)
{
updateItem(iname);
}
} // namespace Internal
} // namespace Debugger
......
......@@ -191,7 +191,8 @@ public:
DebuggerRunParameters &runParameters();
virtual bool canHandleToolTip(const DebuggerToolTipContext &) const;
virtual void updateWatchData(const QByteArray &iname);
virtual void expandItem(const QByteArray &iname); // Called when item in tree gets expanded.
virtual void updateItem(const QByteArray &iname); // Called for fresh watch items.
virtual void selectWatchData(const QByteArray &iname);
virtual void startDebugger(DebuggerRunControl *runControl);
......
......@@ -1222,7 +1222,7 @@ static void slotTooltipOverrideRequested
m_tooltips.push_back(tooltip);
tooltip->setState(PendingUnshown);
if (engine->canHandleToolTip(context)) {
engine->updateWatchData(context.iname);
engine->updateItem(context.iname);
} else {
ToolTip::show(point, DebuggerToolTipManager::tr("Expression too complex"),
Internal::mainWindow());
......
......@@ -394,7 +394,7 @@ void PdbEngine::assignValueInDebugger(WatchItem *, const QString &expression, co
updateLocals();
}
void PdbEngine::updateWatchData(const QByteArray &iname)
void PdbEngine::updateItem(const QByteArray &iname)
{
Q_UNUSED(iname);
updateAll();
......
......@@ -96,7 +96,7 @@ private:
bool supportsThreads() const { return true; }
bool isSynchronous() const { return true; }
void updateWatchData(const QByteArray &iname);
void updateItem(const QByteArray &iname);
QString mainPythonFile() const;
QString pythonInterpreter() const;
......
......@@ -114,12 +114,12 @@ bool QmlCppEngine::canHandleToolTip(const DebuggerToolTipContext &ctx) const
return success;
}
void QmlCppEngine::updateWatchData(const QByteArray &iname)
void QmlCppEngine::updateItem(const QByteArray &iname)
{
if (iname.startsWith("inspect."))
m_qmlEngine->updateWatchData(iname);
m_qmlEngine->updateItem(iname);
else
m_activeEngine->updateWatchData(iname);
m_activeEngine->updateItem(iname);
}
void QmlCppEngine::selectWatchData(const QByteArray &iname)
......
......@@ -48,7 +48,7 @@ public:
bool canDisplayTooltip() const;
bool canHandleToolTip(const DebuggerToolTipContext &) const;
void updateWatchData(const QByteArray &iname);
void updateItem(const QByteArray &iname);
void selectWatchData(const QByteArray &iname);
void watchPoint(const QPoint &);
......
......@@ -969,26 +969,31 @@ void QmlEngine::assignValueInDebugger(WatchItem *item,
}
}
void QmlEngine::updateWatchData(const QByteArray &iname)
void QmlEngine::expandItem(const QByteArray &iname)
{
const WatchItem *item = watchHandler()->findItem(iname);
// invalid expressions or out of scope variables
if (!item)
return;
QTC_ASSERT(item, return);
if (item->isInspect()) {
d->inspectorAdapter.agent()->updateWatchData(*item);
} else {
if (!item->name.isEmpty()) {
if (item->isChildrenNeeded() && watchHandler()->isExpandedIName(item->iname)) {
LookupItems items;
items.insert(int(item->id), {item->iname, item->name});
d->lookup(items);
}
}
LookupItems items;
items.insert(int(item->id), {item->iname, item->name});
d->lookup(items);
}
}
void QmlEngine::updateItem(const QByteArray &iname)
{
const WatchItem *item = watchHandler()->findItem(iname);
QTC_ASSERT(item, return);
QString exp = QString::fromUtf8(item->exp);
d->evaluate(exp, [this, exp](const QVariantMap &response) {
d->handleEvaluateWatcher(response, exp);
});
}
void QmlEngine::selectWatchData(const QByteArray &iname)
{
const WatchItem *item = watchHandler()->findItem(iname);
......
......@@ -129,7 +129,8 @@ private:
void reloadSourceFiles();
void reloadFullStack() {}
void updateWatchData(const QByteArray &iname);
void updateItem(const QByteArray &iname);
void expandItem(const QByteArray &iname);
void selectWatchData(const QByteArray &iname);
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
bool evaluateScript(const QString &expression);
......
......@@ -683,7 +683,7 @@ void WatchItem::fetchMore()
model->m_fetchTriggered.insert(iname);
if (children().isEmpty()) {
setChildrenNeeded();
model->m_engine->updateWatchData(iname);
model->m_engine->expandItem(iname);
}
}
......@@ -940,12 +940,12 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role
case LocalsTypeFormatRole:
setTypeFormat(item->type, value.toInt());
m_engine->updateWatchData(item->iname);
m_engine->updateLocals();
break;
case LocalsIndividualFormatRole: {
setIndividualFormat(item->iname, value.toInt());
m_engine->updateWatchData(item->iname);
m_engine->updateLocals();
break;
}
}
......@@ -1304,14 +1304,14 @@ void WatchHandler::watchExpression(const QString &exp0, const QString &name)
item->exp = exp;
item->name = name.isEmpty() ? exp0 : name;
item->iname = watcherName(exp);
m_model->insertItem(item);
saveWatchers();
if (m_model->m_engine->state() == DebuggerNotReady) {
item->setAllUnneeded();
item->setValue(QString(QLatin1Char(' ')));
m_model->insertItem(item);
} else {
m_model->m_engine->updateWatchData(item->iname);
m_model->m_engine->updateItem(item->iname);
}
updateWatchersWindow();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment