Commit 72cca485 authored by Ulf Hermann's avatar Ulf Hermann

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: default avatarhjk <hjk@qt.io>
parent 56a09859
......@@ -126,6 +126,22 @@ QDockWidget *DebuggerMainWindow::dockWidget(const QByteArray &dockId) const
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()
{
loadPerspectiveHelper(m_currentPerspectiveId, false);
......
......@@ -129,6 +129,8 @@ public:
QByteArray currentPerspective() const { return m_currentPerspectiveId; }
QStackedWidget *centralWidgetStack() const { return m_centralWidgetStack; }
void onModeChanged(Core::Id mode);
private:
QDockWidget *registerDockWidget(const QByteArray &dockId, QWidget *widget);
void loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings = true);
......
......@@ -1770,6 +1770,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
this, &DebuggerPluginPrivate::onModeChanged);
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
m_mainWindow.data(), &DebuggerMainWindow::onModeChanged);
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
this, &DebuggerPluginPrivate::updateDebugWithoutDeployMenu);
......@@ -3386,8 +3388,6 @@ void DebuggerPluginPrivate::onModeChanged(Id mode)
editor->widget()->setFocus();
m_toolTipManager.debugModeEntered();
m_mainWindow->setDockActionsVisible(true);
m_mainWindow->restorePerspective({});
// static bool firstTime = true;
// if (firstTime) {
......@@ -3405,13 +3405,6 @@ void DebuggerPluginPrivate::onModeChanged(Id mode)
updateActiveLanguages();
} else {
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();
}
}
}
......
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