Commit af6e06df authored by Friedemann Kleint's avatar Friedemann Kleint

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
......@@ -717,7 +717,6 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
QTC_ASSERT(rc, return sp);
sp.startMode = StartInternal;
sp.environment = rc->environment();
sp.workingDirectory = rc->workingDirectory();
......@@ -727,6 +726,9 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
#endif
sp.executable = rc->executable();
if (sp.executable.isEmpty())
return sp;
sp.startMode = StartInternal;
sp.processArgs = rc->commandLineArguments();
sp.toolChainAbi = rc->abi();
if (!sp.toolChainAbi.isValid()) {
......@@ -784,6 +786,8 @@ RunControl *DebuggerRunControlFactory::create
{
QTC_ASSERT(mode == Constants::DEBUGMODE || mode == Constants::DEBUGMODE2, return 0);
DebuggerStartParameters sp = localStartParameters(runConfiguration);
if (sp.startMode == NoStartMode)
return 0;
if (mode == Constants::DEBUGMODE2)
sp.breakOnMain = true;
return create(sp, runConfiguration);
......
......@@ -128,9 +128,12 @@ QString CustomExecutableRunConfiguration::executable() const
if (exec.isEmpty() || !QFileInfo(exec).exists()) {
// 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);
QDialog dialog(Core::ICore::instance()->mainWindow());
dialog.setWindowTitle(displayName());
dialog.setWindowFlags(dialog.windowFlags() & ~Qt::WindowContextHelpButtonHint);
dialog.setLayout(new QVBoxLayout());
QLabel *label = new QLabel(tr("Could not find the executable, please specify one."));
label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
......@@ -146,14 +149,18 @@ QString CustomExecutableRunConfiguration::executable() const
QString oldWorkingDirectory = m_workingDirectory;
QString oldCmdArguments = m_cmdArguments;
if (dialog.exec()) {
if (dialog.exec() == QDialog::Accepted) {
return executable();
} else {
CustomExecutableRunConfiguration *that = const_cast<CustomExecutableRunConfiguration *>(this);
that->m_executable = oldExecutable;
that->m_workingDirectory = oldWorkingDirectory;
that->m_cmdArguments = oldCmdArguments;
emit that->changed();
// Restore values changed by the configuration widget.
if (that->m_executable != oldExecutable
|| that->m_workingDirectory != oldWorkingDirectory
|| that->m_cmdArguments != oldCmdArguments) {
that->m_executable = oldExecutable;
that->m_workingDirectory = oldWorkingDirectory;
that->m_cmdArguments = oldCmdArguments;
emit that->changed();
}
return QString();
}
}
......
......@@ -67,7 +67,11 @@ QString LocalApplicationRunControlFactory::displayName() const
RunControl *LocalApplicationRunControlFactory::create(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode)
{
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)
......
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