summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2018-03-07 10:35:08 +0100
committerTobias Hunger <tobias.hunger@qt.io>2018-03-07 14:35:15 +0000
commit6e419d642a2c1e9d6f5cc334bdd58305fd01b3e5 (patch)
treea04eb067a58183327c728ad1cc58a39718cd1a92 /src/plugins
parent23e48fe207d62b16ca5cef701536ce34f3c9681d (diff)
downloadqt-creator-6e419d642a2c1e9d6f5cc334bdd58305fd01b3e5.tar.gz
RunConfigurationFactories: Fix crash opening non-qmake based projects
Make sure the Qnx RCs only get triggered for qmake-based projects and defend against broken set-ups using QTC_ASSERT. Task-number: QTCREATORBUG-19755 Change-Id: If64b73de49b0199308f767151d68909dc8b1bc53 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp3
-rw-r--r--src/plugins/ios/iosrunfactories.cpp3
-rw-r--r--src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp2
-rw-r--r--src/plugins/qmakeandroidsupport/qmakeandroidrunfactories.cpp3
-rw-r--r--src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp6
-rw-r--r--src/plugins/qnx/qnxrunconfigurationfactory.cpp9
-rw-r--r--src/plugins/winrt/winrtrunfactories.cpp3
7 files changed, 20 insertions, 9 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp
index e59daaa0fe..6b68d47868 100644
--- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp
@@ -241,7 +241,8 @@ CMakeRunConfigurationFactory::CMakeRunConfigurationFactory(QObject *parent) :
QList<BuildTargetInfo>
CMakeRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode) const
{
- CMakeProject *project = static_cast<CMakeProject *>(parent->project());
+ CMakeProject *project = qobject_cast<CMakeProject *>(parent->project());
+ QTC_ASSERT(project, return {});
const QStringList titles = project->buildTargetTitles(true);
return Utils::transform(titles, [project](const QString &title) {
BuildTargetInfo bti;
diff --git a/src/plugins/ios/iosrunfactories.cpp b/src/plugins/ios/iosrunfactories.cpp
index dccf82e952..854cf45c75 100644
--- a/src/plugins/ios/iosrunfactories.cpp
+++ b/src/plugins/ios/iosrunfactories.cpp
@@ -62,7 +62,8 @@ bool IosRunConfigurationFactory::canCreateHelper(Target *parent, const QString &
QList<BuildTargetInfo>
IosRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode mode) const
{
- auto project = static_cast<QmakeProject *>(parent->project());
+ auto project = qobject_cast<QmakeProject *>(parent->project());
+ QTC_ASSERT(project, return {});
return project->buildTargets(mode, {ProjectType::ApplicationTemplate,
ProjectType::SharedLibraryTemplate,
ProjectType::AuxTemplate});
diff --git a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
index e2324f39f9..ca0ed33f0c 100644
--- a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
+++ b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
@@ -388,7 +388,7 @@ QList<BuildTargetInfo> QbsRunConfigurationFactory::availableBuildTargets(Target
{
QList<qbs::ProductData> products;
- QbsProject *project = static_cast<QbsProject *>(parent->project());
+ QbsProject *project = qobject_cast<QbsProject *>(parent->project());
if (!project || !project->qbsProject().isValid())
return {};
diff --git a/src/plugins/qmakeandroidsupport/qmakeandroidrunfactories.cpp b/src/plugins/qmakeandroidsupport/qmakeandroidrunfactories.cpp
index e5c62c52dc..dfb0084c61 100644
--- a/src/plugins/qmakeandroidsupport/qmakeandroidrunfactories.cpp
+++ b/src/plugins/qmakeandroidsupport/qmakeandroidrunfactories.cpp
@@ -59,7 +59,8 @@ QmakeAndroidRunConfigurationFactory::QmakeAndroidRunConfigurationFactory(QObject
QList<BuildTargetInfo>
QmakeAndroidRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode mode) const
{
- auto project = static_cast<QmakeProject *>(parent->project());
+ auto project = qobject_cast<QmakeProject *>(parent->project());
+ QTC_ASSERT(project, return {});
return project->buildTargets(mode, {ProjectType::ApplicationTemplate, ProjectType::SharedLibraryTemplate});
}
diff --git a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp
index 549db31d2f..6ead3531d9 100644
--- a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp
+++ b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp
@@ -439,14 +439,16 @@ DesktopQmakeRunConfigurationFactory::DesktopQmakeRunConfigurationFactory(QObject
bool DesktopQmakeRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
{
- QmakeProject *project = static_cast<QmakeProject *>(parent->project());
+ QmakeProject *project = qobject_cast<QmakeProject *>(parent->project());
+ QTC_ASSERT(project, return {});
return project->hasApplicationProFile(Utils::FileName::fromString(buildTarget));
}
QList<BuildTargetInfo>
DesktopQmakeRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode mode) const
{
- QmakeProject *project = static_cast<QmakeProject *>(parent->project());
+ QmakeProject *project = qobject_cast<QmakeProject *>(parent->project());
+ QTC_ASSERT(project, return {});
return project->buildTargets(mode);
}
diff --git a/src/plugins/qnx/qnxrunconfigurationfactory.cpp b/src/plugins/qnx/qnxrunconfigurationfactory.cpp
index 05112b36bb..5e2e2c8e46 100644
--- a/src/plugins/qnx/qnxrunconfigurationfactory.cpp
+++ b/src/plugins/qnx/qnxrunconfigurationfactory.cpp
@@ -32,6 +32,7 @@
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <qmakeprojectmanager/qmakeproject.h>
+#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
using namespace ProjectExplorer;
@@ -41,14 +42,17 @@ namespace Internal {
QnxRunConfigurationFactory::QnxRunConfigurationFactory(QObject *parent) :
ProjectExplorer::IRunConfigurationFactory(parent)
{
- registerRunConfiguration<QnxRunConfiguration>(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX);
- setSupportedTargetDeviceTypes({Constants::QNX_QNX_OS_TYPE});
+ registerRunConfiguration<QnxRunConfiguration>(Qnx::Constants::QNX_QNX_RUNCONFIGURATION_PREFIX);
+ setSupportedTargetDeviceTypes({Qnx::Constants::QNX_QNX_OS_TYPE});
+ addSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
}
QList<ProjectExplorer::BuildTargetInfo>
QnxRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode mode) const
{
auto project = qobject_cast<QmakeProjectManager::QmakeProject *>(parent->project());
+ QTC_ASSERT(project, return {});
+
const QList<BuildTargetInfo> buildTargets = project->buildTargets(mode);
return Utils::transform(buildTargets, [](BuildTargetInfo bti) {
bti.displayName = tr("%1 on QNX Device").arg(QFileInfo(bti.targetName).completeBaseName());
@@ -60,6 +64,7 @@ bool QnxRunConfigurationFactory::canCreateHelper(ProjectExplorer::Target *parent
const QString &buildTarget) const
{
auto project = qobject_cast<QmakeProjectManager::QmakeProject *>(parent->project());
+ QTC_ASSERT(project, return false);
return project->hasApplicationProFile(Utils::FileName::fromString(buildTarget));
}
diff --git a/src/plugins/winrt/winrtrunfactories.cpp b/src/plugins/winrt/winrtrunfactories.cpp
index 55e098db0c..f8bc558cfa 100644
--- a/src/plugins/winrt/winrtrunfactories.cpp
+++ b/src/plugins/winrt/winrtrunfactories.cpp
@@ -53,7 +53,8 @@ WinRtRunConfigurationFactory::WinRtRunConfigurationFactory()
QList<BuildTargetInfo>
WinRtRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode mode) const
{
- QmakeProject *project = static_cast<QmakeProject *>(parent->project());
+ QmakeProject *project = qobject_cast<QmakeProject *>(parent->project());
+ QTC_ASSERT(project, return {});
const QList<BuildTargetInfo> buildTargets = project->buildTargets(mode);
return Utils::transform(buildTargets, [](BuildTargetInfo bti) {
bti.displayName = tr("Run App Package");