diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-05-20 18:44:45 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-05-22 09:28:29 +0000 |
commit | 20c387f63630b49d9383af9fadbf16c5aaadeaa6 (patch) | |
tree | 6142a83639397c309e2c8f1e03baf2f7707acecb | |
parent | 036e8611ebaeb20edd2ced713520a76d7cccba40 (diff) |
QmlPreview: Don't use MainFileAspect if it doesn't exist
We only need to choose the main file if we're dealing with a qmlproject.
Fixes: QTCREATORBUG-24056
Change-Id: I5b5dfa29a46fa07de7ee570fa033d978e72dfdb5
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: hjk <hjk@qt.io>
-rw-r--r-- | src/plugins/qmlpreview/qmlpreviewruncontrol.cpp | 31 |
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, |