debugger: closer dependency plugin<->manager, less signal/slot connections

This commit is contained in:
hjk
2010-03-10 13:46:05 +01:00
parent 944b6dad7d
commit 6321e4ebfe
4 changed files with 90 additions and 121 deletions

View File

@@ -29,6 +29,7 @@
#include "debuggermanager.h" #include "debuggermanager.h"
#include "debuggerplugin.h"
#include "debuggeractions.h" #include "debuggeractions.h"
#include "debuggeragents.h" #include "debuggeragents.h"
#include "debuggerrunner.h" #include "debuggerrunner.h"
@@ -305,6 +306,7 @@ struct DebuggerManagerPrivate
DebuggerState m_state; DebuggerState m_state;
CPlusPlus::Snapshot m_codeModelSnapshot; CPlusPlus::Snapshot m_codeModelSnapshot;
DebuggerPlugin *m_plugin;
}; };
DebuggerManager *DebuggerManagerPrivate::instance = 0; DebuggerManager *DebuggerManagerPrivate::instance = 0;
@@ -322,10 +324,11 @@ DebuggerManagerPrivate::DebuggerManagerPrivate(DebuggerManager *manager) :
m_stopIcon.addFile(":/debugger/images/debugger_stop.png"); m_stopIcon.addFile(":/debugger/images/debugger_stop.png");
} }
DebuggerManager::DebuggerManager() DebuggerManager::DebuggerManager(DebuggerPlugin *plugin)
: d(new DebuggerManagerPrivate(this)) : d(new DebuggerManagerPrivate(this))
{ {
DebuggerManagerPrivate::instance = this; DebuggerManagerPrivate::instance = this;
d->m_plugin = plugin;
init(); init();
} }
@@ -573,8 +576,8 @@ void DebuggerManager::init()
d->m_snapshotDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_snapshotWindow); d->m_snapshotDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_snapshotWindow);
d->m_stackDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_stackWindow); d->m_stackDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_stackWindow);
d->m_sourceFilesDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_sourceFilesWindow, d->m_sourceFilesDock = uiSwitcher->createDockWidget(LANG_CPP,
Qt::TopDockWidgetArea, false); d->m_sourceFilesWindow, Qt::TopDockWidgetArea, false);
connect(d->m_sourceFilesDock->toggleViewAction(), SIGNAL(toggled(bool)), connect(d->m_sourceFilesDock->toggleViewAction(), SIGNAL(toggled(bool)),
this, SLOT(reloadSourceFiles()), Qt::QueuedConnection); this, SLOT(reloadSourceFiles()), Qt::QueuedConnection);
@@ -588,7 +591,8 @@ void DebuggerManager::init()
localsAndWatchers->setStretchFactor(0, 3); localsAndWatchers->setStretchFactor(0, 3);
localsAndWatchers->setStretchFactor(1, 1); localsAndWatchers->setStretchFactor(1, 1);
localsAndWatchers->setStretchFactor(2, 1); localsAndWatchers->setStretchFactor(2, 1);
d->m_watchDock = DebuggerUISwitcher::instance()->createDockWidget(LANG_CPP, localsAndWatchers); d->m_watchDock = DebuggerUISwitcher::instance()->createDockWidget(LANG_CPP,
localsAndWatchers);
d->m_dockWidgets << d->m_breakDock << d->m_modulesDock << d->m_registerDock d->m_dockWidgets << d->m_breakDock << d->m_modulesDock << d->m_registerDock
<< d->m_outputDock << d->m_stackDock << d->m_sourceFilesDock << d->m_outputDock << d->m_stackDock << d->m_sourceFilesDock
<< d->m_threadsDock << d->m_watchDock; << d->m_threadsDock << d->m_watchDock;
@@ -691,7 +695,8 @@ QWidget *DebuggerManager::threadsWindow() const
void DebuggerManager::createNewDock(QWidget *widget) void DebuggerManager::createNewDock(QWidget *widget)
{ {
QDockWidget *dockWidget = DebuggerUISwitcher::instance()->createDockWidget(LANG_CPP, widget); QDockWidget *dockWidget =
DebuggerUISwitcher::instance()->createDockWidget(LANG_CPP, widget);
dockWidget->setWindowTitle(widget->windowTitle()); dockWidget->setWindowTitle(widget->windowTitle());
dockWidget->setObjectName(widget->windowTitle()); dockWidget->setObjectName(widget->windowTitle());
dockWidget->setFeatures(QDockWidget::DockWidgetClosable); dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
@@ -860,7 +865,7 @@ void DebuggerManager::toggleBreakpoint()
{ {
QString fileName; QString fileName;
int lineNumber = -1; int lineNumber = -1;
queryCurrentTextEditor(&fileName, &lineNumber, 0); d->m_plugin->currentTextEditor(&fileName, &lineNumber);
if (lineNumber == -1) if (lineNumber == -1)
return; return;
toggleBreakpoint(fileName, lineNumber); toggleBreakpoint(fileName, lineNumber);
@@ -1047,9 +1052,10 @@ void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp)
d->m_startParameters = sp; d->m_startParameters = sp;
d->m_inferiorPid = d->m_startParameters->attachPID > 0 d->m_inferiorPid = d->m_startParameters->attachPID > 0
? d->m_startParameters->attachPID : 0; ? d->m_startParameters->attachPID : 0;
const QString toolChainName = ProjectExplorer::ToolChain::toolChainName(static_cast<ProjectExplorer::ToolChain::ToolChainType>(d->m_startParameters->toolChainType)); const QString toolChainName = ProjectExplorer::ToolChain::toolChainName(
ProjectExplorer::ToolChain::ToolChainType(d->m_startParameters->toolChainType));
emit debugModeRequested(); d->m_plugin->activateDebugMode();
showDebuggerOutput(LogStatus, showDebuggerOutput(LogStatus,
tr("Starting debugger for tool chain '%1'...").arg(toolChainName)); tr("Starting debugger for tool chain '%1'...").arg(toolChainName));
showDebuggerOutput(LogDebug, DebuggerSettings::instance()->dump()); showDebuggerOutput(LogDebug, DebuggerSettings::instance()->dump());
@@ -1347,12 +1353,6 @@ void DebuggerManager::setBusyCursor(bool busy)
d->m_watchersWindow->setCursor(cursor); d->m_watchersWindow->setCursor(cursor);
} }
void DebuggerManager::queryCurrentTextEditor(QString *fileName, int *lineNumber,
QObject **object)
{
emit currentTextEditorRequested(fileName, lineNumber, object);
}
void DebuggerManager::continueExec() void DebuggerManager::continueExec()
{ {
if (d->m_engine) if (d->m_engine)
@@ -1382,7 +1382,7 @@ void DebuggerManager::runToLineExec()
{ {
QString fileName; QString fileName;
int lineNumber = -1; int lineNumber = -1;
emit currentTextEditorRequested(&fileName, &lineNumber, 0); d->m_plugin->currentTextEditor(&fileName, &lineNumber);
if (d->m_engine && !fileName.isEmpty()) { if (d->m_engine && !fileName.isEmpty()) {
STATE_DEBUG(fileName << lineNumber); STATE_DEBUG(fileName << lineNumber);
d->m_engine->runToLineExec(fileName, lineNumber); d->m_engine->runToLineExec(fileName, lineNumber);
@@ -1393,8 +1393,7 @@ void DebuggerManager::runToFunctionExec()
{ {
QString fileName; QString fileName;
int lineNumber = -1; int lineNumber = -1;
QObject *object = 0; QObject *object = d->m_plugin->currentTextEditor(&fileName, &lineNumber);
emit currentTextEditorRequested(&fileName, &lineNumber, &object);
QPlainTextEdit *ed = qobject_cast<QPlainTextEdit*>(object); QPlainTextEdit *ed = qobject_cast<QPlainTextEdit*>(object);
if (!ed) if (!ed)
return; return;
@@ -1426,7 +1425,7 @@ void DebuggerManager::jumpToLineExec()
{ {
QString fileName; QString fileName;
int lineNumber = -1; int lineNumber = -1;
emit currentTextEditorRequested(&fileName, &lineNumber, 0); d->m_plugin->currentTextEditor(&fileName, &lineNumber);
if (d->m_engine && !fileName.isEmpty()) { if (d->m_engine && !fileName.isEmpty()) {
STATE_DEBUG(fileName << lineNumber); STATE_DEBUG(fileName << lineNumber);
d->m_engine->jumpToLineExec(fileName, lineNumber); d->m_engine->jumpToLineExec(fileName, lineNumber);
@@ -1438,18 +1437,18 @@ void DebuggerManager::resetLocation()
d->m_disassemblerViewAgent.resetLocation(); d->m_disassemblerViewAgent.resetLocation();
d->m_stackHandler->setCurrentIndex(-1); d->m_stackHandler->setCurrentIndex(-1);
// Connected to the plugin. // Connected to the plugin.
emit resetLocationRequested(); d->m_plugin->resetLocation();
} }
void DebuggerManager::gotoLocation(const Debugger::Internal::StackFrame &frame, bool setMarker) void DebuggerManager::gotoLocation(const StackFrame &frame, bool setMarker)
{ {
if (theDebuggerBoolSetting(OperateByInstruction) || !frame.isUsable()) { if (theDebuggerBoolSetting(OperateByInstruction) || !frame.isUsable()) {
if (setMarker) if (setMarker)
emit resetLocationRequested(); d->m_plugin->resetLocation();
d->m_disassemblerViewAgent.setFrame(frame); d->m_disassemblerViewAgent.setFrame(frame);
} else { } else {
// Connected to the plugin. // Connected to the plugin.
emit gotoLocationRequested(frame.file, frame.line, setMarker); d->m_plugin->gotoLocation(frame.file, frame.line, setMarker);
} }
} }
@@ -1633,15 +1632,12 @@ bool DebuggerManager::isReverseDebugging() const
QVariant DebuggerManager::sessionValue(const QString &name) QVariant DebuggerManager::sessionValue(const QString &name)
{ {
// this is answered by the plugin return d->m_plugin->sessionValue(name);
QVariant value;
emit sessionValueRequested(name, &value);
return value;
} }
void DebuggerManager::setSessionValue(const QString &name, const QVariant &value) void DebuggerManager::setSessionValue(const QString &name, const QVariant &value)
{ {
emit setSessionValueRequested(name, value); d->m_plugin->setSessionValue(name, value);
} }
QMessageBox *DebuggerManager::showMessageBox(int icon, const QString &title, QMessageBox *DebuggerManager::showMessageBox(int icon, const QString &title,
@@ -1803,7 +1799,7 @@ void DebuggerManager::setState(DebuggerState state, bool forced)
theDebuggerAction(ExpandStack)->setEnabled(actionsEnabled); theDebuggerAction(ExpandStack)->setEnabled(actionsEnabled);
theDebuggerAction(ExecuteCommand)->setEnabled(d->m_state != DebuggerNotReady); theDebuggerAction(ExecuteCommand)->setEnabled(d->m_state != DebuggerNotReady);
emit stateChanged(d->m_state); d->m_plugin->handleStateChanged(d->m_state);
const bool notbusy = state == InferiorStopped const bool notbusy = state == InferiorStopped
|| state == DebuggerNotReady || state == DebuggerNotReady
|| state == InferiorUnrunnable; || state == InferiorUnrunnable;

View File

@@ -87,7 +87,6 @@ class ScriptEngine;
class CdbDebugEngine; class CdbDebugEngine;
class CdbDebugEnginePrivate; class CdbDebugEnginePrivate;
struct DebuggerManagerActions; struct DebuggerManagerActions;
class DebuggerPlugin;
class CdbDebugEventCallback; class CdbDebugEventCallback;
class CdbDumperHelper; class CdbDumperHelper;
class CdbDumperInitThread; class CdbDumperInitThread;
@@ -158,7 +157,7 @@ class DEBUGGER_EXPORT DebuggerManager : public QObject
Q_OBJECT Q_OBJECT
public: public:
DebuggerManager(); explicit DebuggerManager(Internal::DebuggerPlugin *plugin);
~DebuggerManager(); ~DebuggerManager();
friend class Internal::IDebuggerEngine; friend class Internal::IDebuggerEngine;
@@ -207,7 +206,6 @@ public slots:
void setSimpleDockWidgetArrangement(const QString &activeLanguage); void setSimpleDockWidgetArrangement(const QString &activeLanguage);
void setBusyCursor(bool on); void setBusyCursor(bool on);
void queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **ed);
void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setLocationMarker); void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setLocationMarker);
void fileOpen(const QString &file); void fileOpen(const QString &file);
@@ -330,16 +328,7 @@ signals:
void debuggingFinished(); void debuggingFinished();
void inferiorPidChanged(qint64 pid); void inferiorPidChanged(qint64 pid);
void stateChanged(int newstatus); void stateChanged(int newstatus);
void debugModeRequested();
void previousModeRequested();
void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever' void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
void gotoLocationRequested(const QString &file, int line, bool setLocationMarker);
void resetLocationRequested();
void currentTextEditorRequested(QString *fileName, int *lineNumber, QObject **ob);
void sessionValueRequested(const QString &name, QVariant *value);
void setSessionValueRequested(const QString &name, const QVariant &value);
void configValueRequested(const QString &name, QVariant *value);
void setConfigValueRequested(const QString &name, const QVariant &value);
void applicationOutputAvailable(const QString &output); void applicationOutputAvailable(const QString &output);
void emitShowOutput(int channel, const QString &output); void emitShowOutput(int channel, const QString &output);
void emitShowInput(int channel, const QString &input); void emitShowInput(int channel, const QString &input);

View File

@@ -86,6 +86,7 @@
#include <QtCore/QtPlugin> #include <QtCore/QtPlugin>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QTimer> #include <QtCore/QTimer>
#include <QtCore/QVariant>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QDockWidget> #include <QtGui/QDockWidget>
@@ -674,11 +675,6 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
ExtensionSystem::PluginManager::instance()->addObject(m_uiSwitcher); ExtensionSystem::PluginManager::instance()->addObject(m_uiSwitcher);
m_uiSwitcher->addLanguage(LANG_CPP); m_uiSwitcher->addLanguage(LANG_CPP);
m_manager = new DebuggerManager;
ExtensionSystem::PluginManager::instance()->addObject(m_manager);
const QList<Core::IOptionsPage *> engineOptionPages =
m_manager->initializeEngines(m_cmdLineEnabledEngines);
ICore *core = ICore::instance(); ICore *core = ICore::instance();
QTC_ASSERT(core, return false); QTC_ASSERT(core, return false);
@@ -705,8 +701,13 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
m_gdbRunningContext = uidm->uniqueIdentifier(Constants::GDBRUNNING); m_gdbRunningContext = uidm->uniqueIdentifier(Constants::GDBRUNNING);
DebuggerManager *manager = new DebuggerManager(this);
ExtensionSystem::PluginManager::instance()->addObject(manager);
const QList<Core::IOptionsPage *> engineOptionPages =
manager->initializeEngines(m_cmdLineEnabledEngines);
// register factory of DebuggerRunControl // register factory of DebuggerRunControl
m_debuggerRunControlFactory = new DebuggerRunControlFactory(m_manager); m_debuggerRunControlFactory = new DebuggerRunControlFactory(manager);
addAutoReleasedObject(m_debuggerRunControlFactory); addAutoReleasedObject(m_debuggerRunControlFactory);
QList<int> context; QList<int> context;
@@ -741,13 +742,13 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
m_detachAction = new QAction(this); m_detachAction = new QAction(this);
m_detachAction->setText(tr("Detach Debugger")); m_detachAction->setText(tr("Detach Debugger"));
connect(m_detachAction, SIGNAL(triggered()), connect(m_detachAction, SIGNAL(triggered()),
m_manager, SLOT(detachDebugger())); manager, SLOT(detachDebugger()));
// Core::ActionContainer *mdebug = // Core::ActionContainer *mdebug =
// am->actionContainer(ProjectExplorer::Constants::M_DEBUG); // am->actionContainer(ProjectExplorer::Constants::M_DEBUG);
Core::Command *cmd = 0; Core::Command *cmd = 0;
const DebuggerManagerActions actions = m_manager->debuggerManagerActions(); const DebuggerManagerActions actions = manager->debuggerManagerActions();
Core::ActionContainer *mstart = Core::ActionContainer *mstart =
@@ -902,34 +903,33 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
addAutoReleasedObject(new DebuggerListener); addAutoReleasedObject(new DebuggerListener);
m_locationMark = 0; m_locationMark = 0;
m_manager->setSimpleDockWidgetArrangement(LANG_CPP); manager->setSimpleDockWidgetArrangement(LANG_CPP);
readSettings(); readSettings();
m_uiSwitcher->setToolbar(LANG_CPP, createToolbar());
connect(m_uiSwitcher, SIGNAL(dockArranged(QString)), m_manager,
SLOT(setSimpleDockWidgetArrangement(QString)));
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
this, SLOT(onModeChanged(Core::IMode*))); this, SLOT(onModeChanged(Core::IMode*)));
m_debugMode->widget()->setFocusProxy(EditorManager::instance()); m_debugMode->widget()->setFocusProxy(EditorManager::instance());
addObject(m_debugMode); addObject(m_debugMode);
m_manager = manager;
// //
// Connections // Connections
// //
// TextEditor // TextEditor
connect(TextEditor::TextEditorPlugin::instance(), connect(TextEditorPlugin::instance(),
SIGNAL(fontSettingsChanged(TextEditor::FontSettings)), SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
m_manager, SLOT(fontSettingsChanged(TextEditor::FontSettings))); manager, SLOT(fontSettingsChanged(TextEditor::FontSettings)));
// ProjectExplorer // ProjectExplorer
connect(sessionManager(), SIGNAL(sessionLoaded()), connect(sessionManager(), SIGNAL(sessionLoaded()),
m_manager, SLOT(sessionLoaded())); manager, SLOT(sessionLoaded()));
connect(sessionManager(), SIGNAL(aboutToSaveSession()), connect(sessionManager(), SIGNAL(aboutToSaveSession()),
m_manager, SLOT(aboutToSaveSession())); manager, SLOT(aboutToSaveSession()));
connect(sessionManager(), SIGNAL(aboutToUnloadSession()), connect(sessionManager(), SIGNAL(aboutToUnloadSession()),
m_manager, SLOT(aboutToUnloadSession())); manager, SLOT(aboutToUnloadSession()));
// EditorManager // EditorManager
QObject *editorManager = core->editorManager(); QObject *editorManager = core->editorManager();
@@ -939,60 +939,46 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
this, SLOT(editorOpened(Core::IEditor*))); this, SLOT(editorOpened(Core::IEditor*)));
// Application interaction // Application interaction
connect(m_manager, SIGNAL(currentTextEditorRequested(QString*,int*,QObject**)),
this, SLOT(queryCurrentTextEditor(QString*,int*,QObject**)));
connect(m_manager, SIGNAL(setSessionValueRequested(QString,QVariant)),
this, SLOT(setSessionValue(QString,QVariant)));
connect(m_manager, SIGNAL(sessionValueRequested(QString,QVariant*)),
this, SLOT(querySessionValue(QString,QVariant*)));
connect(m_manager, SIGNAL(resetLocationRequested()),
this, SLOT(resetLocation()));
connect(m_manager, SIGNAL(gotoLocationRequested(QString,int,bool)),
this, SLOT(gotoLocation(QString,int,bool)));
connect(m_manager, SIGNAL(stateChanged(int)),
this, SLOT(handleStateChanged(int)));
connect(m_manager, SIGNAL(previousModeRequested()),
this, SLOT(activatePreviousMode()));
connect(m_manager, SIGNAL(debugModeRequested()),
this, SLOT(activateDebugMode()));
connect(theDebuggerAction(SettingsDialog), SIGNAL(triggered()), connect(theDebuggerAction(SettingsDialog), SIGNAL(triggered()),
this, SLOT(showSettingsDialog())); this, SLOT(showSettingsDialog()));
handleStateChanged(DebuggerNotReady); handleStateChanged(DebuggerNotReady);
m_uiSwitcher->setToolbar(LANG_CPP, createToolbar());
connect(m_uiSwitcher, SIGNAL(dockArranged(QString)), manager,
SLOT(setSimpleDockWidgetArrangement(QString)));
return true; return true;
} }
QWidget *DebuggerPlugin::createToolbar() const QWidget *DebuggerPlugin::createToolbar() const
{ {
Core::ActionManager *am = ICore::instance()->actionManager(); Core::ActionManager *am = ICore::instance()->actionManager();
QWidget *toolbarContainer = new QWidget; QWidget *toolbarContainer = new QWidget;
QHBoxLayout *debugToolBarLayout = new QHBoxLayout(toolbarContainer);
debugToolBarLayout->setMargin(0); QHBoxLayout *hbox = new QHBoxLayout(toolbarContainer);
debugToolBarLayout->setSpacing(0); hbox->setMargin(0);
debugToolBarLayout->addWidget(toolButton(am->command(ProjectExplorer::Constants::DEBUG)->action())); hbox->setSpacing(0);
debugToolBarLayout->addWidget(toolButton(am->command(Constants::INTERRUPT)->action())); hbox->addWidget(toolButton(am->command(ProjectExplorer::Constants::DEBUG)->action()));
debugToolBarLayout->addWidget(toolButton(am->command(Constants::NEXT)->action())); hbox->addWidget(toolButton(am->command(Constants::INTERRUPT)->action()));
debugToolBarLayout->addWidget(toolButton(am->command(Constants::STEP)->action())); hbox->addWidget(toolButton(am->command(Constants::NEXT)->action()));
debugToolBarLayout->addWidget(toolButton(am->command(Constants::STEPOUT)->action())); hbox->addWidget(toolButton(am->command(Constants::STEP)->action()));
debugToolBarLayout->addWidget(toolButton(am->command(Constants::OPERATE_BY_INSTRUCTION)->action())); hbox->addWidget(toolButton(am->command(Constants::STEPOUT)->action()));
hbox->addWidget(toolButton(am->command(Constants::OPERATE_BY_INSTRUCTION)->action()));
#ifdef USE_REVERSE_DEBUGGING #ifdef USE_REVERSE_DEBUGGING
debugToolBarLayout->addWidget(new Utils::StyledSeparator); hbox->addWidget(new Utils::StyledSeparator);
debugToolBarLayout->addWidget(toolButton(am->command(Constants::REVERSE)->action())); hbox->addWidget(toolButton(am->command(Constants::REVERSE)->action()));
#endif #endif
debugToolBarLayout->addWidget(new Utils::StyledSeparator); hbox->addWidget(new Utils::StyledSeparator);
debugToolBarLayout->addWidget(new QLabel(tr("Threads:"))); hbox->addWidget(new QLabel(tr("Threads:")));
QComboBox *threadBox = new QComboBox; QComboBox *threadBox = new QComboBox;
threadBox->setModel(m_manager->threadsModel()); threadBox->setModel(m_manager->threadsModel());
connect(threadBox, SIGNAL(activated(int)), connect(threadBox, SIGNAL(activated(int)),
m_manager->threadsWindow(), SIGNAL(threadSelected(int))); m_manager->threadsWindow(), SIGNAL(threadSelected(int)));
debugToolBarLayout->addWidget(threadBox);
debugToolBarLayout->addWidget(m_manager->statusLabel(), 10); hbox->addWidget(threadBox);
hbox->addWidget(m_manager->statusLabel(), 10);
return toolbarContainer; return toolbarContainer;
} }
@@ -1047,21 +1033,20 @@ void DebuggerPlugin::activateDebugMode()
modeManager->activateMode(QLatin1String(MODE_DEBUG)); modeManager->activateMode(QLatin1String(MODE_DEBUG));
} }
void DebuggerPlugin::queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **object) QWidget *DebuggerPlugin::currentTextEditor(QString *fileName, int *lineNumber)
{ {
EditorManager *editorManager = EditorManager::instance(); EditorManager *editorManager = EditorManager::instance();
if (!editorManager) if (!editorManager)
return; return 0;
Core::IEditor *editor = editorManager->currentEditor(); Core::IEditor *editor = editorManager->currentEditor();
ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor); ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor);
if (!textEditor) if (!textEditor)
return; return 0;
if (fileName) if (fileName)
*fileName = textEditor->file()->fileName(); *fileName = textEditor->file()->fileName();
if (lineNumber) if (lineNumber)
*lineNumber = textEditor->currentLine(); *lineNumber = textEditor->currentLine();
if (object) return textEditor->widget();
*object = textEditor->widget();
} }
void DebuggerPlugin::editorOpened(Core::IEditor *editor) void DebuggerPlugin::editorOpened(Core::IEditor *editor)
@@ -1140,13 +1125,12 @@ void DebuggerPlugin::breakpointEnableDisableMarginActionTriggered()
} }
} }
void DebuggerPlugin::requestMark(TextEditor::ITextEditor *editor, int lineNumber) void DebuggerPlugin::requestMark(ITextEditor *editor, int lineNumber)
{ {
m_manager->toggleBreakpoint(editor->file()->fileName(), lineNumber); m_manager->toggleBreakpoint(editor->file()->fileName(), lineNumber);
} }
void DebuggerPlugin::showToolTip(TextEditor::ITextEditor *editor, void DebuggerPlugin::showToolTip(ITextEditor *editor, const QPoint &point, int pos)
const QPoint &point, int pos)
{ {
if (!theDebuggerBoolSetting(UseToolTipsInMainEditor) if (!theDebuggerBoolSetting(UseToolTipsInMainEditor)
|| m_manager->state() == DebuggerNotReady) || m_manager->state() == DebuggerNotReady)
@@ -1157,19 +1141,16 @@ void DebuggerPlugin::showToolTip(TextEditor::ITextEditor *editor,
void DebuggerPlugin::setSessionValue(const QString &name, const QVariant &value) void DebuggerPlugin::setSessionValue(const QString &name, const QVariant &value)
{ {
//qDebug() << "SET SESSION VALUE" << name << value;
QTC_ASSERT(sessionManager(), return); QTC_ASSERT(sessionManager(), return);
sessionManager()->setValue(name, value); sessionManager()->setValue(name, value);
} }
void DebuggerPlugin::querySessionValue(const QString &name, QVariant *value) QVariant DebuggerPlugin::sessionValue(const QString &name)
{ {
QTC_ASSERT(sessionManager(), return); QTC_ASSERT(sessionManager(), return QVariant());
*value = sessionManager()->value(name); return sessionManager()->value(name);
//qDebug() << "GET SESSION VALUE: " << name << value;
} }
void DebuggerPlugin::setConfigValue(const QString &name, const QVariant &value) void DebuggerPlugin::setConfigValue(const QString &name, const QVariant &value)
{ {
QTC_ASSERT(m_debugMode, return); QTC_ASSERT(m_debugMode, return);
@@ -1182,12 +1163,6 @@ QVariant DebuggerPlugin::configValue(const QString &name) const
return settings()->value(name); return settings()->value(name);
} }
void DebuggerPlugin::queryConfigValue(const QString &name, QVariant *value)
{
QTC_ASSERT(m_debugMode, return);
*value = settings()->value(name);
}
void DebuggerPlugin::resetLocation() void DebuggerPlugin::resetLocation()
{ {
//qDebug() << "RESET_LOCATION: current:" << currentTextEditor(); //qDebug() << "RESET_LOCATION: current:" << currentTextEditor();
@@ -1200,7 +1175,12 @@ void DebuggerPlugin::resetLocation()
void DebuggerPlugin::gotoLocation(const QString &file, int line, bool setMarker) void DebuggerPlugin::gotoLocation(const QString &file, int line, bool setMarker)
{ {
bool newEditor = false; bool newEditor = false;
TextEditor::BaseTextEditor::openEditorAt(file, line, 0, QString(), &newEditor); ITextEditor *editor =
BaseTextEditor::openEditorAt(file, line, 0, QString(), &newEditor);
if (!editor)
return;
if (newEditor)
editor->setProperty("OpenedByDebugger", true);
if (setMarker) { if (setMarker) {
resetLocation(); resetLocation();
m_locationMark = new LocationMark(file, line); m_locationMark = new LocationMark(file, line);
@@ -1209,6 +1189,10 @@ void DebuggerPlugin::gotoLocation(const QString &file, int line, bool setMarker)
void DebuggerPlugin::handleStateChanged(int state) void DebuggerPlugin::handleStateChanged(int state)
{ {
// Prevent it from beeing triggered on setup.
if (!m_manager)
return;
const bool startIsContinue = (state == InferiorStopped); const bool startIsContinue = (state == InferiorStopped);
ICore *core = ICore::instance(); ICore *core = ICore::instance();
if (startIsContinue) { if (startIsContinue) {

View File

@@ -89,20 +89,20 @@ private:
virtual void remoteCommand(const QStringList &options, const QStringList &arguments); virtual void remoteCommand(const QStringList &options, const QStringList &arguments);
QVariant configValue(const QString &name) const; QVariant configValue(const QString &name) const;
QWidget *currentTextEditor(QString *fileName, int *line);
QVariant sessionValue(const QString &name);
void setSessionValue(const QString &name, const QVariant &value);
QVariant configValue(const QString &name);
void setConfigValue(const QString &name, const QVariant &value);
private slots: private slots:
void activatePreviousMode(); void activatePreviousMode();
void activateDebugMode(); void activateDebugMode();
void queryCurrentTextEditor(QString *fileName, int *line, QObject **object);
void editorOpened(Core::IEditor *); void editorOpened(Core::IEditor *);
void editorAboutToClose(Core::IEditor *); void editorAboutToClose(Core::IEditor *);
void handleStateChanged(int state); void handleStateChanged(int state);
void requestMark(TextEditor::ITextEditor *editor, int lineNumber); void requestMark(TextEditor::ITextEditor *editor, int lineNumber);
void showToolTip(TextEditor::ITextEditor *editor, const QPoint &pnt, int pos); void showToolTip(TextEditor::ITextEditor *editor, const QPoint &pnt, int pos);
void querySessionValue(const QString &name, QVariant *value);
void setSessionValue(const QString &name, const QVariant &value);
void queryConfigValue(const QString &name, QVariant *value);
void setConfigValue(const QString &name, const QVariant &value);
void requestContextMenu(TextEditor::ITextEditor *editor, void requestContextMenu(TextEditor::ITextEditor *editor,
int lineNumber, QMenu *menu); int lineNumber, QMenu *menu);