Commit 7657dd3a authored by Daniel Teske's avatar Daniel Teske Committed by Friedemann Kleint

Add error string to IRunControlFactory::createRunControl

And add a few helpful error messages

Task-number: QTCREATORBUG-7826

Change-Id: Ia9f9fa476cecf2cff198bc460408bc062e119338
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@nokia.com>
parent c5097ed1
......@@ -68,11 +68,14 @@ bool AnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMo
return false;
}
RunControl *AnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode)
RunControl *AnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
{
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool)
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected"); // never happens
return 0;
}
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
......
......@@ -51,7 +51,8 @@ public:
QString displayName() const;
bool canRun(RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const;
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode);
ProjectExplorer::RunMode mode,
QString *errorMessage);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect();
ProjectExplorer::RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
......
......@@ -81,7 +81,7 @@ static QStringList qtSoPaths(QtSupport::BaseQtVersion *qtVersion)
return paths.toList();
}
RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *runConfig)
RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *runConfig, QString *errorMessage)
{
Target *target = runConfig->target();
Qt4Project *project = static_cast<Qt4Project *>(target->project());
......@@ -119,7 +119,7 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
}
DebuggerRunControl * const debuggerRunControl
= DebuggerPlugin::createDebugger(params, runConfig);
= DebuggerPlugin::createDebugger(params, runConfig, errorMessage);
new AndroidDebugSupport(runConfig, debuggerRunControl);
return debuggerRunControl;
}
......
......@@ -47,7 +47,8 @@ class AndroidDebugSupport : public QObject
Q_OBJECT
public:
static ProjectExplorer::RunControl *createDebugRunControl(AndroidRunConfiguration *runConfig);
static ProjectExplorer::RunControl *createDebugRunControl(AndroidRunConfiguration *runConfig,
QString *errorMessage);
AndroidDebugSupport(AndroidRunConfiguration *runConfig,
Debugger::DebuggerRunControl *runControl);
......
......@@ -171,7 +171,7 @@ bool AndroidRunControlFactory::canRun(RunConfiguration *runConfiguration,
}
RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig,
ProjectExplorer::RunMode mode)
ProjectExplorer::RunMode mode, QString *errorMessage)
{
Q_ASSERT(canRun(runConfig, mode));
AndroidRunConfiguration *rc = qobject_cast<AndroidRunConfiguration *>(runConfig);
......@@ -179,7 +179,7 @@ RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig,
if (mode == NormalRunMode)
return new AndroidRunControl(rc);
else
return AndroidDebugSupport::createDebugRunControl(rc);
return AndroidDebugSupport::createDebugRunControl(rc, errorMessage);
}
QString AndroidRunControlFactory::displayName() const
......
......@@ -80,7 +80,8 @@ public:
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode);
ProjectExplorer::RunMode mode,
QString *errorMessage);
};
} // namespace Internal
......
......@@ -3387,9 +3387,9 @@ void DebuggerPlugin::remoteCommand(const QStringList &options,
}
DebuggerRunControl *DebuggerPlugin::createDebugger
(const DebuggerStartParameters &sp, RunConfiguration *rc)
(const DebuggerStartParameters &sp, RunConfiguration *rc, QString *errorMessage)
{
return DebuggerRunControlFactory::doCreate(sp, rc);
return DebuggerRunControlFactory::doCreate(sp, rc, errorMessage);
}
void DebuggerPlugin::extensionsInitialized()
......
......@@ -66,7 +66,8 @@ public:
static QAction *visibleDebugAction();
static DebuggerRunControl *createDebugger(const DebuggerStartParameters &sp,
ProjectExplorer::RunConfiguration *rc);
ProjectExplorer::RunConfiguration *rc,
QString *errorMessage);
private:
// IPlugin implementation.
......
......@@ -50,7 +50,8 @@ public:
// FIXME: Used by qmljsinspector.cpp:469
ProjectExplorer::RunControl *create(
ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode);
ProjectExplorer::RunMode mode,
QString *errorMessage);
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const;
......@@ -64,7 +65,7 @@ public:
ProjectExplorer::RunConfiguration *runConfiguration = 0);
static DebuggerRunControl *doCreate(const DebuggerStartParameters &sp,
ProjectExplorer::RunConfiguration *rc);
ProjectExplorer::RunConfiguration *rc, QString *errorMessage);
private:
QString displayName() const;
......
......@@ -543,8 +543,9 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
}
RunControl *DebuggerRunControlFactory::create
(RunConfiguration *runConfiguration, RunMode mode)
(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
{
Q_UNUSED(errorMessage)
QTC_ASSERT(mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain, return 0);
DebuggerStartParameters sp = localStartParameters(runConfiguration);
if (sp.startMode == NoStartMode)
......@@ -552,7 +553,7 @@ RunControl *DebuggerRunControlFactory::create
if (mode == DebugRunModeWithBreakOnMain)
sp.breakOnMain = true;
return doCreate(sp, runConfiguration);
return doCreate(sp, runConfiguration, errorMessage);
}
static DebuggerEngineType guessUnixCppEngineType(const DebuggerStartParameters &sp)
......@@ -644,8 +645,9 @@ static void fixupEngineTypes(DebuggerStartParameters &sp, RunConfiguration *rc)
}
DebuggerRunControl *DebuggerRunControlFactory::doCreate
(const DebuggerStartParameters &sp0, RunConfiguration *rc)
(const DebuggerStartParameters &sp0, RunConfiguration *rc, QString *errorMessage)
{
Q_UNUSED(errorMessage);
DebuggerStartParameters sp = sp0;
if (!debuggerCore()->boolSetting(AutoEnrichParameters)) {
const QString sysroot = sp.sysRoot;
......@@ -663,8 +665,9 @@ DebuggerRunControl *DebuggerRunControlFactory::doCreate
}
fixupEngineTypes(sp, rc);
if (!sp.masterEngineType)
if (!sp.masterEngineType) {
return 0;
}
return new DebuggerRunControl(rc, sp);
}
......@@ -672,9 +675,12 @@ DebuggerRunControl *DebuggerRunControlFactory::doCreate
DebuggerRunControl *DebuggerRunControlFactory::createAndScheduleRun
(const DebuggerStartParameters &sp, RunConfiguration *runConfiguration)
{
DebuggerRunControl *rc = doCreate(sp, runConfiguration);
if (!rc)
QString errorMessage;
DebuggerRunControl *rc = doCreate(sp, runConfiguration, &errorMessage);
if (!rc) {
ProjectExplorer::ProjectExplorerPlugin::showRunErrorMessage(errorMessage);
return 0;
}
debuggerCore()->showMessage(sp.startMessage, 0);
ProjectExplorerPlugin::instance()->startRunControl(rc, DebugRunMode);
return rc;
......
......@@ -202,7 +202,7 @@ bool MaemoRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode
return maemoRunConfig->hasEnoughFreePorts(mode);
}
RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig, RunMode mode)
RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig, RunMode mode, QString *errorMessage)
{
Q_ASSERT(canRun(runConfig, mode));
......@@ -216,7 +216,7 @@ RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig, RunMode
}
const DebuggerStartParameters params = LinuxDeviceDebugSupport::startParameters(rc);
DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc);
DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc, errorMessage);
if (!runControl)
return 0;
LinuxDeviceDebugSupport * const debugSupport
......
......@@ -82,7 +82,9 @@ public:
QString displayName() const;
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const;
RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode);
RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode,
QString *errorMessage);
};
} // namespace Internal
......
......@@ -61,13 +61,16 @@ QString LocalApplicationRunControlFactory::displayName() const
return tr("Run");
}
RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode)
RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
{
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
LocalApplicationRunConfiguration *localRunConfiguration = qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
// Force the dialog about executables at this point and fail if there is none
if (localRunConfiguration->executable().isEmpty())
if (localRunConfiguration->executable().isEmpty()) {
if (errorMessage)
*errorMessage = tr("No executable");
return 0;
}
return new LocalApplicationRunControl(localRunConfiguration, mode);
}
......
......@@ -48,7 +48,7 @@ public:
virtual ~LocalApplicationRunControlFactory();
virtual bool canRun(RunConfiguration *runConfiguration, RunMode mode) const;
virtual QString displayName() const;
virtual RunControl* create(RunConfiguration *runConfiguration, RunMode mode);
virtual RunControl* create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage);
};
class LocalApplicationRunControl : public RunControl
......
......@@ -1576,13 +1576,29 @@ void ProjectExplorerPlugin::executeRunConfiguration(RunConfiguration *runConfigu
if (IRunControlFactory *runControlFactory = findRunControlFactory(runConfiguration, runMode)) {
emit aboutToExecuteProject(runConfiguration->target()->project(), runMode);
RunControl *control = runControlFactory->create(runConfiguration, runMode);
if (!control)
QString errorMessage;
RunControl *control = runControlFactory->create(runConfiguration, runMode, &errorMessage);
if (!control) {
showRunErrorMessage(errorMessage);
return;
}
startRunControl(control, runMode);
}
}
void ProjectExplorerPlugin::showRunErrorMessage(const QString &errorMessage)
{
if (errorMessage.isNull()) {
// a error occured, but message was not set
QMessageBox::critical(Core::ICore::mainWindow(), tr("Unknown error"), errorMessage);
} else if (errorMessage.isEmpty()) {
// a error, but the message was set to empty
// hack for qml observer warning, show nothing at all
} else {
QMessageBox::critical(Core::ICore::mainWindow(), tr("Could Not Run"), errorMessage);
}
}
void ProjectExplorerPlugin::startRunControl(RunControl *runControl, RunMode runMode)
{
d->m_outputPane->createNewOutputWindow(runControl);
......
......@@ -109,6 +109,7 @@ public:
Internal::ProjectExplorerSettings projectExplorerSettings() const;
void startRunControl(RunControl *runControl, RunMode runMode);
static void showRunErrorMessage(const QString &errorMessage);
// internal public for FlatModel
void renameFile(Node *node, const QString &to);
......
......@@ -228,7 +228,7 @@ public:
virtual ~IRunControlFactory();
virtual bool canRun(RunConfiguration *runConfiguration, RunMode mode) const = 0;
virtual RunControl *create(RunConfiguration *runConfiguration, RunMode mode) = 0;
virtual RunControl *create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) = 0;
virtual QString displayName() const = 0;
......
......@@ -167,7 +167,7 @@ bool QmlProjectRunControlFactory::canRun(RunConfiguration *runConfiguration,
}
RunControl *QmlProjectRunControlFactory::create(RunConfiguration *runConfiguration,
RunMode mode)
RunMode mode, QString *errorMessage)
{
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
QmlProjectRunConfiguration *config = qobject_cast<QmlProjectRunConfiguration *>(runConfiguration);
......@@ -187,7 +187,7 @@ RunControl *QmlProjectRunControlFactory::create(RunConfiguration *runConfigurati
if (mode == NormalRunMode)
runControl = new QmlProjectRunControl(config, mode);
else if (mode == DebugRunMode)
runControl = createDebugRunControl(config);
runControl = createDebugRunControl(config, errorMessage);
return runControl;
}
......@@ -196,7 +196,7 @@ QString QmlProjectRunControlFactory::displayName() const
return tr("Run");
}
RunControl *QmlProjectRunControlFactory::createDebugRunControl(QmlProjectRunConfiguration *runConfig)
RunControl *QmlProjectRunControlFactory::createDebugRunControl(QmlProjectRunConfiguration *runConfig, QString *errorMessage)
{
Debugger::DebuggerStartParameters params;
params.startMode = Debugger::StartInternal;
......@@ -224,10 +224,11 @@ RunControl *QmlProjectRunControlFactory::createDebugRunControl(QmlProjectRunConf
if (params.executable.isEmpty()) {
QmlProjectPlugin::showQmlObserverToolWarning();
*errorMessage = QString(""); // hack, we already showed a error message
return 0;
}
return Debugger::DebuggerPlugin::createDebugger(params, runConfig);
return Debugger::DebuggerPlugin::createDebugger(params, runConfig, errorMessage);
}
} // namespace Internal
......
......@@ -77,11 +77,12 @@ public:
// IRunControlFactory
virtual bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const;
virtual ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode);
virtual ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode, QString *errorMessage);
virtual QString displayName() const;
private:
ProjectExplorer::RunControl *createDebugRunControl(QmlProjectRunConfiguration *runConfig);
ProjectExplorer::RunControl *createDebugRunControl(QmlProjectRunConfiguration *runConfig, QString *errorMessage);
};
} // namespace Internal
......
......@@ -82,9 +82,8 @@ bool BlackBerryRunControlFactory::canRun(ProjectExplorer::RunConfiguration *runC
return activeDeployConf != 0;
}
ProjectExplorer::RunControl *BlackBerryRunControlFactory::create(
ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode)
ProjectExplorer::RunControl *BlackBerryRunControlFactory::create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode, QString *errorMessage)
{
BlackBerryRunConfiguration *rc = qobject_cast<BlackBerryRunConfiguration *>(runConfiguration);
if (!rc)
......@@ -92,8 +91,11 @@ ProjectExplorer::RunControl *BlackBerryRunControlFactory::create(
BlackBerryDeployConfiguration *activeDeployConf = qobject_cast<BlackBerryDeployConfiguration *>(
rc->target()->activeDeployConfiguration());
if (!activeDeployConf)
if (!activeDeployConf) {
if (errorMessage)
*errorMessage = tr("No active deploy configuration");
return 0;
}
if (mode == ProjectExplorer::NormalRunMode) {
BlackBerryRunControl *runControl = new BlackBerryRunControl(rc);
......@@ -102,7 +104,7 @@ ProjectExplorer::RunControl *BlackBerryRunControlFactory::create(
}
Debugger::DebuggerRunControl * const runControl =
Debugger::DebuggerPlugin::createDebugger(startParameters(rc), runConfiguration);
Debugger::DebuggerPlugin::createDebugger(startParameters(rc), runConfiguration, errorMessage);
if (!runControl)
return 0;
......
......@@ -57,7 +57,8 @@ public:
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode);
ProjectExplorer::RunMode mode,
QString *errorMessage);
QString displayName() const;
......
......@@ -116,7 +116,7 @@ bool QnxRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mo
return true;
}
RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mode)
RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mode, QString *errorMessage)
{
Q_ASSERT(canRun(runConfig, mode));
......@@ -126,7 +126,7 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mo
return new QnxRunControl(rc);
const DebuggerStartParameters params = createStartParameters(rc);
DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc);
DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc, errorMessage);
if (!runControl)
return 0;
......
......@@ -52,7 +52,7 @@ public:
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode);
ProjectExplorer::RunMode mode, QString *errorMessage);
};
} // namespace Internal
......
......@@ -80,7 +80,7 @@ bool RemoteLinuxRunControlFactory::canRun(RunConfiguration *runConfiguration, Ru
return true;
}
RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, RunMode mode)
RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, RunMode mode, QString *errorMessage)
{
Q_ASSERT(canRun(runConfig, mode));
......@@ -92,7 +92,7 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Ru
DebuggerStartParameters params = LinuxDeviceDebugSupport::startParameters(rc);
if (mode == ProjectExplorer::DebugRunModeWithBreakOnMain)
params.breakOnMain = true;
DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc);
DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc, errorMessage);
if (!runControl)
return 0;
LinuxDeviceDebugSupport * const debugSupport =
......
......@@ -46,7 +46,7 @@ public:
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode);
ProjectExplorer::RunMode mode, QString *errorMessage);
};
} // namespace Internal
......
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