From 790648b9154ae7b67d41d8fb564944bc275737b1 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 23 Nov 2010 13:28:18 +0100 Subject: [PATCH] debugger: make freshly inserted watchers immediately visble Even if no engine is running. --- src/plugins/debugger/debuggercore.h | 1 + src/plugins/debugger/debuggerplugin.cpp | 40 ++++++++++++++----------- src/plugins/debugger/watchhandler.cpp | 17 +++++++---- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/plugins/debugger/debuggercore.h b/src/plugins/debugger/debuggercore.h index 3b8bc2eeb95..f306f73f779 100644 --- a/src/plugins/debugger/debuggercore.h +++ b/src/plugins/debugger/debuggercore.h @@ -77,6 +77,7 @@ public: virtual QVariant configValue(const QString &name) const = 0; virtual void setConfigValue(const QString &name, const QVariant &value) = 0; virtual void updateState(DebuggerEngine *engine) = 0; + virtual void updateWatchersWindow() = 0; virtual void showQtDumperLibraryWarning(const QString &details) = 0; virtual QIcon locationMarkIcon() const = 0; virtual const CPlusPlus::Snapshot &cppCodeModelSnapshot() const = 0; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index f2aeef41c19..cab0f62cc63 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1030,6 +1030,7 @@ public slots: DebuggerState state() const { return m_state; } void updateState(DebuggerEngine *engine); + void updateWatchersWindow(); void onCurrentProjectChanged(ProjectExplorer::Project *project); void gotoLocation(const QString &file, int line, bool setMarker); @@ -1919,8 +1920,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, SLOT(aboutToSaveSession())); connect(sessionManager(), SIGNAL(aboutToUnloadSession()), SLOT(aboutToUnloadSession())); - connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(updateRunActions()), - this, SLOT(updateDebugActions())); + connect(ProjectExplorerPlugin::instance(), SIGNAL(updateRunActions()), + SLOT(updateDebugActions())); // EditorManager QObject *editorManager = core->editorManager(); @@ -2039,12 +2040,10 @@ void DebuggerPluginPrivate::languagesChanged(const DebuggerLanguages &languages) void DebuggerPluginPrivate::debugProject() { - Project *pro = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject(); - if (!pro) - return; - - ProjectExplorer::ProjectExplorerPlugin::instance()->runProject(pro, Constants::DEBUGMODE); - } + ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); + if (Project *pro = pe->startupProject()) + pe->runProject(pro, Constants::DEBUGMODE); +} void DebuggerPluginPrivate::startExternalApplication() { @@ -2073,7 +2072,7 @@ void DebuggerPluginPrivate::startExternalApplication() sp.processArgs = dlg.executableArguments(); // Fixme: 1 of 3 testing hacks. if (sp.processArgs.startsWith(__("@tcf@ ")) || sp.processArgs.startsWith(__("@sym@ "))) - sp.toolChainType = ProjectExplorer::ToolChain_RVCT_ARMV5; + sp.toolChainType = ToolChain_RVCT_ARMV5; if (RunControl *rc = m_debuggerRunControlFactory->create(sp)) @@ -2145,7 +2144,7 @@ void DebuggerPluginPrivate::startRemoteCdbSession() { const QString connectionKey = _("CdbRemoteConnection"); DebuggerStartParameters sp; - sp.toolChainType = ProjectExplorer::ToolChain_MSVC; + sp.toolChainType = ToolChain_MSVC; sp.startMode = AttachToRemote; StartRemoteCdbDialog dlg(mainWindow()); QString previousConnection = configValue(connectionKey).toString(); @@ -2211,7 +2210,7 @@ void DebuggerPluginPrivate::startRemoteApplication() sp.displayName = dlg.localExecutable(); sp.debuggerCommand = dlg.debugger(); // Override toolchain-detection. if (!sp.debuggerCommand.isEmpty()) - sp.toolChainType = ProjectExplorer::ToolChain_INVALID; + sp.toolChainType = ToolChain_INVALID; sp.startMode = AttachToRemote; sp.useServerStartScript = dlg.useServerStartScript(); sp.serverStartScript = dlg.serverStartScript(); @@ -2678,6 +2677,14 @@ void DebuggerPluginPrivate::setInitialState() //emit m_plugin->stateChanged(m_state); } +void DebuggerPluginPrivate::updateWatchersWindow() +{ + m_watchersWindow->setVisible( + m_watchersWindow->model()->rowCount(QModelIndex()) > 0); + m_returnWindow->setVisible( + m_returnWindow->model()->rowCount(QModelIndex()) > 0); +} + void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) { QTC_ASSERT(engine, return); @@ -2687,10 +2694,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) m_threadBox->setCurrentIndex(engine->threadsHandler()->currentThread()); - m_watchersWindow->setVisible( - m_watchersWindow->model()->rowCount(QModelIndex()) > 0); - m_returnWindow->setVisible( - m_returnWindow->model()->rowCount(QModelIndex()) > 0); + updateWatchersWindow(); //m_plugin->showMessage(QString("PLUGIN SET STATE: ") // + DebuggerEngine::stateName(engine->state()), LogStatus); @@ -2820,9 +2824,9 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) void DebuggerPluginPrivate::updateDebugActions() { - ProjectExplorer::ProjectExplorerPlugin *peplugin = ProjectExplorer::ProjectExplorerPlugin::instance(); - Project *project = peplugin->startupProject(); - m_debugAction->setEnabled(peplugin->canRun(project, Constants::DEBUGMODE)); + ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); + Project *project = pe->startupProject(); + m_debugAction->setEnabled(pe->canRun(project, Constants::DEBUGMODE)); } void DebuggerPluginPrivate::gotoLocation(const QString &file, int line, bool setMarker) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 47979e03c8a..d88296c864a 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -56,7 +56,7 @@ #include #include -// creates debug output for accesses to the model +// Creates debug output for accesses to the model. //#define DEBUG_MODEL 1 #if DEBUG_MODEL @@ -1333,7 +1333,6 @@ QByteArray WatchHandler::watcherName(const QByteArray &exp) void WatchHandler::watchExpression(const QString &exp) { QTC_ASSERT(m_engine, return); - QTC_ASSERT(m_engine->debuggerCapabilities() & AddWatcherCapability, return); // Do not insert multiple placeholders. if (exp.isEmpty() && m_watcherNames.contains(QByteArray())) return; @@ -1346,10 +1345,16 @@ void WatchHandler::watchExpression(const QString &exp) if (exp.isEmpty()) data.setAllUnneeded(); data.iname = watcherName(data.exp); - if (m_engine->isSynchronous()) - m_engine->updateWatchData(data); - else + if (m_engine->state() == DebuggerNotReady) { + data.setAllUnneeded(); + data.setValue(" "); + data.setHasChildren(false); insertData(data); + } else if (m_engine->isSynchronous()) { + m_engine->updateWatchData(data); + } else { + insertData(data); + } updateWatchersWindow(); saveWatchers(); emitAllChanged(); @@ -1468,7 +1473,7 @@ void WatchHandler::removeWatchExpression(const QString &exp0) void WatchHandler::updateWatchersWindow() { // Force show/hide of watchers and return view. - debuggerCore()->updateState(m_engine); + debuggerCore()->updateWatchersWindow(); } void WatchHandler::updateWatchers()