Commit ed2862ac authored by hjk's avatar hjk

debugger: remove special mechanism to update watcher and return window

parent e7088e9c
......@@ -696,9 +696,10 @@ void DebuggerEngine::addToWatchWindow()
int line, column;
exp = cppExpressionAt(textEditor, tc.position(), &line, &column);
}
if (!exp.isEmpty())
watchHandler()->watchExpression(exp);
if (exp.isEmpty())
return;
watchHandler()->watchExpression(exp);
plugin()->updateState(this);
}
// Called from RunControl.
......@@ -860,24 +861,18 @@ void DebuggerEngine::setState(DebuggerState state, bool forced)
//qDebug() << "STATUS CHANGE: FROM " << stateName(d->m_state)
// << " TO " << stateName(state);
DebuggerState oldState = d->m_state;
d->m_state = state;
QString msg = _("State changed from %1(%2) to %3(%4).")
.arg(stateName(d->m_state)).arg(d->m_state).arg(stateName(state)).arg(state);
//if (!((d->m_state == -1 && state == 0) || (d->m_state == 0 && state == 0)))
// qDebug() << msg;
if (!forced && !isAllowedTransition(d->m_state, state))
.arg(stateName(oldState)).arg(oldState).arg(stateName(state)).arg(state);
if (!forced && !isAllowedTransition(oldState, state))
qDebug() << "UNEXPECTED STATE TRANSITION: " << msg;
showMessage(msg, LogDebug);
//resetLocation();
if (state == d->m_state)
return;
d->m_state = state;
plugin()->updateState(this);
if (d->m_state == DebuggerNotReady)
if (state != oldState && state == DebuggerNotReady)
d->m_runControl->debuggingFinished();
}
......
......@@ -253,6 +253,7 @@ public slots:
void quitDebugger() { exitDebugger(); }
protected:
friend class WatchHandler;
void setState(DebuggerState state, bool forced = false);
private:
......
......@@ -52,7 +52,7 @@
#include "watchwindow.h"
#include "watchutils.h"
#include "breakhandler.h"
#include "breakhandler.h"
#include "stackhandler.h"
#include "watchhandler.h"
......@@ -2072,7 +2072,15 @@ void DebuggerPluginPrivate::setSimpleDockWidgetArrangement(const QString &active
void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
{
m_watchersWindow->setVisible(
m_watchersWindow->model()->rowCount(QModelIndex()) > 0);
m_returnWindow->setVisible(
m_returnWindow->model()->rowCount(QModelIndex()) > 0);
QTC_ASSERT(engine, return);
if (m_state == engine->state())
return;
m_state = engine->state();
bool actionsEnabled = DebuggerEngine::debuggerActionsEnabled(m_state);
......@@ -2171,9 +2179,6 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
theDebuggerAction(ExpandStack)->setEnabled(actionsEnabled);
theDebuggerAction(ExecuteCommand)->setEnabled(m_state == InferiorStopped);
m_watchersWindow->setVisible(false);
m_returnWindow->setVisible(false);
const bool notbusy = m_state == InferiorStopped
|| m_state == DebuggerNotReady
|| m_state == InferiorUnrunnable;
......@@ -2565,12 +2570,6 @@ void DebuggerPlugin::extensionsInitialized()
//d->m_uiSwitcher->initialize();
}
void DebuggerPlugin::updateWatchersWindow(bool showWatchers, bool showReturn)
{
d->m_watchersWindow->setVisible(showWatchers);
d->m_returnWindow->setVisible(showReturn);
}
QWidget *DebuggerPlugin::mainWindow() const
{
return d->m_uiSwitcher->mainWindow();
......
......@@ -101,12 +101,12 @@ public:
// This contains per-session data like breakpoints and watched
// expression. It serves as a template for new engine instantiations.
Internal::DebuggerEngine *sessionTemplate();
void updateState(Internal::DebuggerEngine *engine);
public slots:
void exitDebugger(); // FIXME: remove
void clearCppCodeModelSnapshot();
void ensureLogVisible();
void updateWatchersWindow(bool showWatchers, bool showReturn);
// void runTest(const QString &fileName);
void showMessage(const QString &msg, int channel, int timeout = -1);
......@@ -123,8 +123,6 @@ private:
void extensionsInitialized();
void remoteCommand(const QStringList &options, const QStringList &arguments);
void updateState(Internal::DebuggerEngine *engine);
QWidget *mainWindow() const;
private:
......
......@@ -1226,6 +1226,7 @@ void WatchHandler::watchExpression(const QString &exp)
m_engine->updateWatchData(data);
updateWatchersWindow();
saveWatchers();
emitAllChanged();
}
static void swapEndian(char *d, int nchar)
......@@ -1340,13 +1341,14 @@ void WatchHandler::removeWatchExpression(const QString &exp0)
break;
}
}
updateWatchersWindow();
emitAllChanged();
}
void WatchHandler::updateWatchersWindow()
{
const bool showWatchers = m_watchers->rowCount(QModelIndex()) > 0;
const bool showReturn = m_return->rowCount(QModelIndex()) > 0;
plugin()->updateWatchersWindow(showWatchers, showReturn);
// Force show/hide of watchers and return view.
plugin()->updateState(m_engine);
}
void WatchHandler::updateWatchers()
......@@ -1370,7 +1372,6 @@ void WatchHandler::loadWatchers()
m_watcherNames[exp.toLatin1()] = watcherCounter++;
//qDebug() << "LOAD WATCHERS: " << m_watchers;
//reinitializeWatchersHelper();
}
QStringList WatchHandler::watchedExpressions() const
......
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