forked from qt-creator/qt-creator
Debugger: Have main window handle mode change separately
On shutdown the DebuggerMainWindow might not be alive anymore. By connecting the signal handler to the window, rather than the plugin we avoid dereferencing null pointers in that case. Change-Id: I6421eebc6b1b76f176b31eafeb039d91edd3f0b3 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -126,6 +126,22 @@ QDockWidget *DebuggerMainWindow::dockWidget(const QByteArray &dockId) const
|
|||||||
return m_dockForDockId.value(dockId);
|
return m_dockForDockId.value(dockId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebuggerMainWindow::onModeChanged(Core::Id mode)
|
||||||
|
{
|
||||||
|
if (mode == Debugger::Constants::MODE_DEBUG) {
|
||||||
|
setDockActionsVisible(true);
|
||||||
|
restorePerspective({});
|
||||||
|
} else {
|
||||||
|
setDockActionsVisible(false);
|
||||||
|
|
||||||
|
// Hide dock widgets manually in case they are floating.
|
||||||
|
foreach (QDockWidget *dockWidget, dockWidgets()) {
|
||||||
|
if (dockWidget->isFloating())
|
||||||
|
dockWidget->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DebuggerMainWindow::resetCurrentPerspective()
|
void DebuggerMainWindow::resetCurrentPerspective()
|
||||||
{
|
{
|
||||||
loadPerspectiveHelper(m_currentPerspectiveId, false);
|
loadPerspectiveHelper(m_currentPerspectiveId, false);
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ public:
|
|||||||
QByteArray currentPerspective() const { return m_currentPerspectiveId; }
|
QByteArray currentPerspective() const { return m_currentPerspectiveId; }
|
||||||
QStackedWidget *centralWidgetStack() const { return m_centralWidgetStack; }
|
QStackedWidget *centralWidgetStack() const { return m_centralWidgetStack; }
|
||||||
|
|
||||||
|
void onModeChanged(Core::Id mode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDockWidget *registerDockWidget(const QByteArray &dockId, QWidget *widget);
|
QDockWidget *registerDockWidget(const QByteArray &dockId, QWidget *widget);
|
||||||
void loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings = true);
|
void loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings = true);
|
||||||
|
|||||||
@@ -1770,6 +1770,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
|
|
||||||
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
|
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
|
||||||
this, &DebuggerPluginPrivate::onModeChanged);
|
this, &DebuggerPluginPrivate::onModeChanged);
|
||||||
|
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
|
||||||
|
m_mainWindow.data(), &DebuggerMainWindow::onModeChanged);
|
||||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||||
this, &DebuggerPluginPrivate::updateDebugWithoutDeployMenu);
|
this, &DebuggerPluginPrivate::updateDebugWithoutDeployMenu);
|
||||||
|
|
||||||
@@ -3386,8 +3388,6 @@ void DebuggerPluginPrivate::onModeChanged(Id mode)
|
|||||||
editor->widget()->setFocus();
|
editor->widget()->setFocus();
|
||||||
|
|
||||||
m_toolTipManager.debugModeEntered();
|
m_toolTipManager.debugModeEntered();
|
||||||
m_mainWindow->setDockActionsVisible(true);
|
|
||||||
m_mainWindow->restorePerspective({});
|
|
||||||
|
|
||||||
// static bool firstTime = true;
|
// static bool firstTime = true;
|
||||||
// if (firstTime) {
|
// if (firstTime) {
|
||||||
@@ -3405,13 +3405,6 @@ void DebuggerPluginPrivate::onModeChanged(Id mode)
|
|||||||
updateActiveLanguages();
|
updateActiveLanguages();
|
||||||
} else {
|
} else {
|
||||||
m_toolTipManager.leavingDebugMode();
|
m_toolTipManager.leavingDebugMode();
|
||||||
m_mainWindow->setDockActionsVisible(false);
|
|
||||||
|
|
||||||
// Hide dock widgets manually in case they are floating.
|
|
||||||
foreach (QDockWidget *dockWidget, m_mainWindow->dockWidgets()) {
|
|
||||||
if (dockWidget->isFloating())
|
|
||||||
dockWidget->hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user