From 78e9c178aec42a69cc8c8ce93abc024bb20c33d3 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 17 Mar 2016 10:59:48 +0100 Subject: [PATCH] Debugger: Avoid switching to debug when the inferior started (or failed) We already switch to debug mode when starting the run control. Since loading of projects from the command line is delayed by the project explorer plugin, and that switches to edit or projects mode, we must delay the startup of the debugger when started from the command line until the project explorer plugin really finished all initialization. Change-Id: Icfae2b39878084b024c40fa30a2e35f6a0b94a89 Reviewed-by: hjk Reviewed-by: Orgad Shaneh --- src/plugins/debugger/debuggerplugin.cpp | 4 +--- src/plugins/projectexplorer/projectexplorer.cpp | 12 +++++------- src/plugins/projectexplorer/projectexplorer.h | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 531b2c09912..72a9be069a6 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1199,7 +1199,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, m_arguments = arguments; if (!m_arguments.isEmpty()) - connect(KitManager::instance(), &KitManager::kitsLoaded, + connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::finishedInitialization, this, &DebuggerPluginPrivate::parseCommandLineArguments); m_mainWindow = new DebuggerMainWindow; @@ -2523,7 +2523,6 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) setProxyAction(m_visibleStartAction, Id(Constants::INTERRUPT)); m_hiddenStopAction->setAction(m_interruptAction); m_localsAndExpressionsWindow->setShowLocals(false); - activateDebugMode(); } else if (state == DebuggerFinished) { const bool canRun = ProjectExplorerPlugin::canRunStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE); // We don't want to do anything anymore. @@ -2548,7 +2547,6 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) m_hiddenStopAction->setAction(m_exitAction); // show locals in core dumps m_localsAndExpressionsWindow->setShowLocals(true); - activateDebugMode(); } else { // Everything else is "undisturbable". m_interruptAction->setEnabled(false); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index fec7d9938ce..2c399e9955a 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1889,7 +1889,11 @@ void ProjectExplorerPluginPrivate::restoreSession() connect(dd->m_welcomePage, &ProjectWelcomePage::requestProject, m_instance, &ProjectExplorerPlugin::openProjectWelcomePage); dd->m_arguments = arguments; - QTimer::singleShot(0, m_instance, &ProjectExplorerPlugin::restoreSession2); + // delay opening projects from the command line even more + QTimer::singleShot(0, m_instance, []() { + ICore::openFiles(dd->m_arguments, ICore::OpenFilesFlags(ICore::CanContainLineAndColumnNumbers | ICore::SwitchMode)); + m_instance->finishedInitialization(); + }); updateActions(); } @@ -1898,12 +1902,6 @@ void ProjectExplorerPluginPrivate::loadSession(const QString &session) SessionManager::loadSession(session); } -void ProjectExplorerPlugin::restoreSession2() -{ - QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - ICore::openFiles(dd->m_arguments, ICore::OpenFilesFlags(ICore::CanContainLineAndColumnNumbers | ICore::SwitchMode)); -} - void ProjectExplorerPluginPrivate::buildStateChanged(Project * pro) { Q_UNUSED(pro) diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index aee6d28f738..64e8882e887 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -161,6 +161,7 @@ public: static void openOpenProjectDialog(); signals: + void finishedInitialization(); void runControlStarted(ProjectExplorer::RunControl *rc); void runControlFinished(ProjectExplorer::RunControl *rc); @@ -177,7 +178,6 @@ signals: private: static bool coreAboutToClose(); - static void restoreSession2(); #ifdef WITH_TESTS private slots: