Skip to content
Snippets Groups Projects
Commit af6e06df authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Do not start LocalRunConfiguration when the executable is empty.


When accidentally pressing 'Debug' on a library project,
the dialog asking for the executable pops up and debugging still
starts although cancel is pressed.

Add dialog title, set flags, and check its return values.

Change-Id: I8518b8af70b12a7059f9ee0e20a9d0b325db1e98
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 68990316
No related branches found
No related tags found
No related merge requests found
...@@ -717,7 +717,6 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu ...@@ -717,7 +717,6 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration); qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
QTC_ASSERT(rc, return sp); QTC_ASSERT(rc, return sp);
sp.startMode = StartInternal;
sp.environment = rc->environment(); sp.environment = rc->environment();
sp.workingDirectory = rc->workingDirectory(); sp.workingDirectory = rc->workingDirectory();
...@@ -727,6 +726,9 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu ...@@ -727,6 +726,9 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
#endif #endif
sp.executable = rc->executable(); sp.executable = rc->executable();
if (sp.executable.isEmpty())
return sp;
sp.startMode = StartInternal;
sp.processArgs = rc->commandLineArguments(); sp.processArgs = rc->commandLineArguments();
sp.toolChainAbi = rc->abi(); sp.toolChainAbi = rc->abi();
if (!sp.toolChainAbi.isValid()) { if (!sp.toolChainAbi.isValid()) {
...@@ -784,6 +786,8 @@ RunControl *DebuggerRunControlFactory::create ...@@ -784,6 +786,8 @@ RunControl *DebuggerRunControlFactory::create
{ {
QTC_ASSERT(mode == Constants::DEBUGMODE || mode == Constants::DEBUGMODE2, return 0); QTC_ASSERT(mode == Constants::DEBUGMODE || mode == Constants::DEBUGMODE2, return 0);
DebuggerStartParameters sp = localStartParameters(runConfiguration); DebuggerStartParameters sp = localStartParameters(runConfiguration);
if (sp.startMode == NoStartMode)
return 0;
if (mode == Constants::DEBUGMODE2) if (mode == Constants::DEBUGMODE2)
sp.breakOnMain = true; sp.breakOnMain = true;
return create(sp, runConfiguration); return create(sp, runConfiguration);
......
...@@ -128,9 +128,12 @@ QString CustomExecutableRunConfiguration::executable() const ...@@ -128,9 +128,12 @@ QString CustomExecutableRunConfiguration::executable() const
if (exec.isEmpty() || !QFileInfo(exec).exists()) { if (exec.isEmpty() || !QFileInfo(exec).exists()) {
// Oh the executable doesn't exists, ask the user. // Oh the executable doesn't exists, ask the user.
QWidget *confWidget = const_cast<CustomExecutableRunConfiguration *>(this)->createConfigurationWidget(); CustomExecutableRunConfiguration *that = const_cast<CustomExecutableRunConfiguration *>(this);
QWidget *confWidget = that->createConfigurationWidget();
confWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); confWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
QDialog dialog(Core::ICore::instance()->mainWindow()); QDialog dialog(Core::ICore::instance()->mainWindow());
dialog.setWindowTitle(displayName());
dialog.setWindowFlags(dialog.windowFlags() & ~Qt::WindowContextHelpButtonHint);
dialog.setLayout(new QVBoxLayout()); dialog.setLayout(new QVBoxLayout());
QLabel *label = new QLabel(tr("Could not find the executable, please specify one.")); QLabel *label = new QLabel(tr("Could not find the executable, please specify one."));
label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
...@@ -146,14 +149,18 @@ QString CustomExecutableRunConfiguration::executable() const ...@@ -146,14 +149,18 @@ QString CustomExecutableRunConfiguration::executable() const
QString oldWorkingDirectory = m_workingDirectory; QString oldWorkingDirectory = m_workingDirectory;
QString oldCmdArguments = m_cmdArguments; QString oldCmdArguments = m_cmdArguments;
if (dialog.exec()) { if (dialog.exec() == QDialog::Accepted) {
return executable(); return executable();
} else { } else {
CustomExecutableRunConfiguration *that = const_cast<CustomExecutableRunConfiguration *>(this); // Restore values changed by the configuration widget.
that->m_executable = oldExecutable; if (that->m_executable != oldExecutable
that->m_workingDirectory = oldWorkingDirectory; || that->m_workingDirectory != oldWorkingDirectory
that->m_cmdArguments = oldCmdArguments; || that->m_cmdArguments != oldCmdArguments) {
emit that->changed(); that->m_executable = oldExecutable;
that->m_workingDirectory = oldWorkingDirectory;
that->m_cmdArguments = oldCmdArguments;
emit that->changed();
}
return QString(); return QString();
} }
} }
......
...@@ -67,7 +67,11 @@ QString LocalApplicationRunControlFactory::displayName() const ...@@ -67,7 +67,11 @@ QString LocalApplicationRunControlFactory::displayName() const
RunControl *LocalApplicationRunControlFactory::create(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode) RunControl *LocalApplicationRunControlFactory::create(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode)
{ {
QTC_ASSERT(canRun(runConfiguration, mode), return 0); QTC_ASSERT(canRun(runConfiguration, mode), return 0);
return new LocalApplicationRunControl(qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration), mode); LocalApplicationRunConfiguration *localRunConfiguration = qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
// Force the dialog about executables at this point and fail if there is none
if (localRunConfiguration->executable().isEmpty())
return 0;
return new LocalApplicationRunControl(localRunConfiguration, mode);
} }
RunConfigWidget *LocalApplicationRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration) RunConfigWidget *LocalApplicationRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment