From 54e76a72d81e7246e60fe5714ee78951bd4c24d0 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Thu, 6 Mar 2014 11:28:39 +0100 Subject: [PATCH] ProjectExplorer: Do not crash when the user deletes a RC Do not crash when the user deletes the RC that was active when clicking the run button before Creator gets to start it. This can when somebody starts to clean up his configuration while being bored waiting for the build/deployment to finish. This is the critical part of QTCREATORBUG-11594. A smaller issue in that bug is that the custom RC should not get removed in the first place. Task-number: QTCREATORBUG-11594 Change-Id: I9fca542994db8877dffc4d92872f94fdf6bda3d1 Reviewed-by: Daniel Teske --- .../projectexplorer/projectexplorer.cpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 4f57ad3850a..32fe1642c1e 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -233,7 +233,8 @@ struct ProjectExplorerPluginPrivate { static const int m_maxRecentProjects = 25; QString m_lastOpenDirectory; - RunConfiguration *m_delayedRunConfiguration; + QPointer m_delayedRunConfiguration; + bool m_shouldHaveRunConfiguration; RunMode m_runMode; QString m_projectFilterString; Internal::MiniProjectTargetSelector * m_targetSelector; @@ -256,7 +257,7 @@ struct ProjectExplorerPluginPrivate { ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() : m_currentProject(0), m_currentNode(0), - m_delayedRunConfiguration(0), + m_shouldHaveRunConfiguration(false), m_runMode(NoRunMode), m_projectsMode(0), m_kitManager(0), @@ -1747,7 +1748,7 @@ void ProjectExplorerPlugin::buildQueueFinished(bool success) updateActions(); bool ignoreErrors = true; - if (d->m_delayedRunConfiguration && success && BuildManager::getErrorTaskCount() > 0) { + if (!d->m_delayedRunConfiguration.isNull() && success && BuildManager::getErrorTaskCount() > 0) { ignoreErrors = QMessageBox::question(ICore::mainWindow(), tr("Ignore all errors?"), tr("Found some build errors in current task.\n" @@ -1755,14 +1756,21 @@ void ProjectExplorerPlugin::buildQueueFinished(bool success) QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes; } + if (d->m_delayedRunConfiguration.isNull() && d->m_shouldHaveRunConfiguration) { + QMessageBox::warning(ICore::mainWindow(), + tr("Run Configuration removed!"), + tr("The Configuration that was supposed to run is no longer " + "available.\n"), QMessageBox::Ok); + } - if (success && ignoreErrors && d->m_delayedRunConfiguration) { - executeRunConfiguration(d->m_delayedRunConfiguration, d->m_runMode); + if (success && ignoreErrors && !d->m_delayedRunConfiguration.isNull()) { + executeRunConfiguration(d->m_delayedRunConfiguration.data(), d->m_runMode); } else { if (BuildManager::tasksAvailable()) BuildManager::showTaskWindow(); } - d->m_delayedRunConfiguration = 0; + d->m_delayedRunConfiguration.clear(); + d->m_shouldHaveRunConfiguration = false; d->m_runMode = NoRunMode; } @@ -2326,6 +2334,7 @@ void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc, // delay running till after our queued steps were processed d->m_runMode = runMode; d->m_delayedRunConfiguration = rc; + d->m_shouldHaveRunConfiguration = true; } else { executeRunConfiguration(rc, runMode); }