aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/qmlpreview/qmlpreviewruncontrol.cpp')
-rw-r--r--src/plugins/qmlpreview/qmlpreviewruncontrol.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp b/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp
index 9f22796689..c513a580f3 100644
--- a/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp
+++ b/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp
@@ -134,21 +134,22 @@ LocalQmlPreviewSupport::LocalQmlPreviewSupport(ProjectExplorer::RunControl *runC
const auto currentTarget = runControl->target();
const auto *qmlBuildSystem = qobject_cast<QmlProjectManager::QmlBuildSystem *>(currentTarget->buildSystem());
- const auto aspect = runControl->aspect<QmlProjectManager::QmlMainFileAspect>();
- const QString mainScript = aspect->mainScript();
- const QString currentFile = aspect->currentFile();
-
- const QString mainScriptFromProject = qmlBuildSystem->targetFile(
- Utils::FilePath::fromString(mainScript)).toString();
-
- const QString currentFileFromProject = qmlBuildSystem->targetFile(
- Utils::FilePath::fromString(currentFile)).toString();
-
- if (!currentFile.isEmpty() && qmlProjectRunConfigurationArguments.last().contains(mainScriptFromProject)) {
- qmlProjectRunConfigurationArguments.removeLast();
- auto commandLine = Utils::CommandLine(runnable.commandLine().executable(), qmlProjectRunConfigurationArguments);
- commandLine.addArg(currentFile);
- runnable.setCommandLine(commandLine);
+ if (const auto aspect = runControl->aspect<QmlProjectManager::QmlMainFileAspect>()) {
+ const QString mainScript = aspect->mainScript();
+ const QString currentFile = aspect->currentFile();
+
+ const QString mainScriptFromProject = qmlBuildSystem->targetFile(
+ Utils::FilePath::fromString(mainScript)).toString();
+
+ const QString currentFileFromProject = qmlBuildSystem->targetFile(
+ Utils::FilePath::fromString(currentFile)).toString();
+
+ if (!currentFile.isEmpty() && qmlProjectRunConfigurationArguments.last().contains(mainScriptFromProject)) {
+ qmlProjectRunConfigurationArguments.removeLast();
+ auto commandLine = Utils::CommandLine(runnable.commandLine().executable(), qmlProjectRunConfigurationArguments);
+ commandLine.addArg(currentFile);
+ runnable.setCommandLine(commandLine);
+ }
}
Utils::QtcProcess::addArg(&runnable.commandLineArguments,