forked from qt-creator/qt-creator
Debugger: Move perspective saving to a time where mode is active
It should not make and I do not observe a difference, but it seems the better thing to do. Change-Id: I1f1f9fba72c2b20f24ebde04cf4ec3711d77d476 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -306,35 +306,36 @@ void DebuggerMainWindow::showStatusMessage(const QString &message, int timeoutMS
|
|||||||
theMainWindow->d->m_statusLabel->showStatusMessage(message, timeoutMS);
|
theMainWindow->d->m_statusLabel->showStatusMessage(message, timeoutMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerMainWindow::onModeChanged(Core::Id mode)
|
void DebuggerMainWindow::enterDebugMode()
|
||||||
{
|
{
|
||||||
if (mode == Debugger::Constants::MODE_DEBUG) {
|
theMainWindow->setDockActionsVisible(true);
|
||||||
theMainWindow->setDockActionsVisible(true);
|
Perspective *perspective = theMainWindow->d->m_currentPerspective;
|
||||||
Perspective *perspective = theMainWindow->d->m_currentPerspective;
|
if (!perspective) {
|
||||||
if (!perspective) {
|
const QSettings *settings = ICore::settings();
|
||||||
const QSettings *settings = ICore::settings();
|
const QString lastPerspectiveId = settings->value(LAST_PERSPECTIVE_KEY).toString();
|
||||||
const QString lastPerspectiveId = settings->value(LAST_PERSPECTIVE_KEY).toString();
|
perspective = Perspective::findPerspective(lastPerspectiveId);
|
||||||
perspective = Perspective::findPerspective(lastPerspectiveId);
|
// If we don't find a perspective with the stored name, pick any.
|
||||||
// If we don't find a perspective with the stored name, pick any.
|
// This can happen e.g. when a plugin was disabled that provided
|
||||||
// This can happen e.g. when a plugin was disabled that provided
|
// the stored perspective, or when the save file was modified externally.
|
||||||
// the stored perspective, or when the save file was modified externally.
|
if (!perspective && !theMainWindow->d->m_perspectives.isEmpty())
|
||||||
if (!perspective && !theMainWindow->d->m_perspectives.isEmpty())
|
perspective = theMainWindow->d->m_perspectives.first();
|
||||||
perspective = theMainWindow->d->m_perspectives.first();
|
}
|
||||||
}
|
// There's at least the debugger preset perspective that should be found above.
|
||||||
// There's at least the debugger preset perspective that should be found above.
|
QTC_ASSERT(perspective, return);
|
||||||
QTC_ASSERT(perspective, return);
|
perspective->select();
|
||||||
perspective->select();
|
}
|
||||||
} else {
|
|
||||||
if (Perspective *perspective = theMainWindow->d->m_currentPerspective)
|
|
||||||
perspective->d->saveLayout();
|
|
||||||
|
|
||||||
theMainWindow->setDockActionsVisible(false);
|
void DebuggerMainWindow::leaveDebugMode()
|
||||||
|
{
|
||||||
|
if (Perspective *perspective = theMainWindow->d->m_currentPerspective)
|
||||||
|
perspective->d->saveLayout();
|
||||||
|
|
||||||
// Hide dock widgets manually in case they are floating.
|
theMainWindow->setDockActionsVisible(false);
|
||||||
for (QDockWidget *dockWidget : theMainWindow->dockWidgets()) {
|
|
||||||
if (dockWidget->isFloating())
|
// Hide dock widgets manually in case they are floating.
|
||||||
dockWidget->hide();
|
for (QDockWidget *dockWidget : theMainWindow->dockWidgets()) {
|
||||||
}
|
if (dockWidget->isFloating())
|
||||||
|
dockWidget->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ public:
|
|||||||
static void doShutdown();
|
static void doShutdown();
|
||||||
|
|
||||||
static void showStatusMessage(const QString &message, int timeoutMS);
|
static void showStatusMessage(const QString &message, int timeoutMS);
|
||||||
static void onModeChanged(Core::Id mode);
|
static void enterDebugMode();
|
||||||
|
static void leaveDebugMode();
|
||||||
|
|
||||||
static QWidget *centralWidgetStack();
|
static QWidget *centralWidgetStack();
|
||||||
void addSubPerspectiveSwitcher(QWidget *widget);
|
void addSubPerspectiveSwitcher(QWidget *widget);
|
||||||
|
|||||||
@@ -696,7 +696,6 @@ public:
|
|||||||
int lineNumber, QMenu *menu);
|
int lineNumber, QMenu *menu);
|
||||||
|
|
||||||
void toggleBreakpointHelper();
|
void toggleBreakpointHelper();
|
||||||
void onModeChanged(Id mode);
|
|
||||||
void updateDebugWithoutDeployMenu();
|
void updateDebugWithoutDeployMenu();
|
||||||
|
|
||||||
void startRemoteCdbSession();
|
void startRemoteCdbSession();
|
||||||
@@ -1352,8 +1351,19 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
addCdbOptionPages(&m_optionPages);
|
addCdbOptionPages(&m_optionPages);
|
||||||
m_optionPages.append(new LocalsAndExpressionsOptionsPage);
|
m_optionPages.append(new LocalsAndExpressionsOptionsPage);
|
||||||
|
|
||||||
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
|
connect(ModeManager::instance(), &ModeManager::currentModeAboutToChange, this, [] {
|
||||||
this, &DebuggerPluginPrivate::onModeChanged);
|
if (ModeManager::currentModeId() == MODE_DEBUG)
|
||||||
|
DebuggerMainWindow::leaveDebugMode();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ModeManager::instance(), &ModeManager::currentModeChanged, this, [](Id mode) {
|
||||||
|
if (mode == MODE_DEBUG) {
|
||||||
|
DebuggerMainWindow::enterDebugMode();
|
||||||
|
if (IEditor *editor = EditorManager::currentEditor())
|
||||||
|
editor->widget()->setFocus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||||
this, &DebuggerPluginPrivate::updateDebugWithoutDeployMenu);
|
this, &DebuggerPluginPrivate::updateDebugWithoutDeployMenu);
|
||||||
|
|
||||||
@@ -2283,19 +2293,6 @@ void DebuggerPlugin::extensionsInitialized()
|
|||||||
dd->extensionsInitialized();
|
dd->extensionsInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::onModeChanged(Id mode)
|
|
||||||
{
|
|
||||||
DebuggerMainWindow::onModeChanged(mode);
|
|
||||||
// FIXME: This one gets always called, even if switching between modes
|
|
||||||
// different then the debugger mode. E.g. Welcome and Help mode and
|
|
||||||
// also on shutdown.
|
|
||||||
|
|
||||||
if (mode == MODE_DEBUG) {
|
|
||||||
if (IEditor *editor = EditorManager::currentEditor())
|
|
||||||
editor->widget()->setFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
static bool buildTypeAccepted(QFlags<ToolMode> toolMode, BuildConfiguration::BuildType buildType)
|
static bool buildTypeAccepted(QFlags<ToolMode> toolMode, BuildConfiguration::BuildType buildType)
|
||||||
|
|||||||
Reference in New Issue
Block a user