From 9ae2ce76297ef899e9c4444f736ede4706c7ece4 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 25 Jan 2016 15:00:20 +0100 Subject: ProjectExplorer: Drop LocalApplicationRunConfiguration The functionality can be provided by producing a suitable Runnable in the derived classes directly. Change-Id: I7b8e8fe33fffd2b00176b6cf6633eca4e152e466 Reviewed-by: Tobias Hunger --- src/plugins/debugger/unstartedappwatcherdialog.cpp | 48 +++++++++++++--------- 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'src/plugins/debugger/unstartedappwatcherdialog.cpp') diff --git a/src/plugins/debugger/unstartedappwatcherdialog.cpp b/src/plugins/debugger/unstartedappwatcherdialog.cpp index 7e5e323517..763fba865f 100644 --- a/src/plugins/debugger/unstartedappwatcherdialog.cpp +++ b/src/plugins/debugger/unstartedappwatcherdialog.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include @@ -56,6 +56,13 @@ using namespace ProjectExplorer; namespace Debugger { namespace Internal { +static bool isLocal(RunConfiguration *runConfiguration) +{ + Target *target = runConfiguration ? runConfiguration->target() : 0; + Kit *kit = target ? target->kit() : 0; + return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; +} + /*! \class Debugger::Internal::UnstartedAppWatcherDialog @@ -88,8 +95,11 @@ UnstartedAppWatcherDialog::UnstartedAppWatcherDialog(QWidget *parent) m_kitChooser->setVisible(true); Project *project = ProjectTree::currentProject(); - if (project && project->activeTarget() && project->activeTarget()->kit()) - m_kitChooser->setCurrentKitId(project->activeTarget()->kit()->id()); + Target *activeTarget = project ? project->activeTarget() : 0; + Kit *kit = activeTarget ? activeTarget->kit() : 0; + + if (kit) + m_kitChooser->setCurrentKitId(kit->id()); else if (KitManager::defaultKit()) m_kitChooser->setCurrentKitId(KitManager::defaultKit()->id()); @@ -97,13 +107,12 @@ UnstartedAppWatcherDialog::UnstartedAppWatcherDialog(QWidget *parent) m_pathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); m_pathChooser->setHistoryCompleter(QLatin1String("LocalExecutable")); - if (project && project->activeTarget() && project->activeTarget()->activeRunConfiguration()) { - LocalApplicationRunConfiguration *localAppRC = - qobject_cast - (project->activeTarget()->activeRunConfiguration()); - - if (localAppRC) - m_pathChooser->setPath(localAppRC->executable()); + if (activeTarget) { + if (RunConfiguration *runConfig = activeTarget->activeRunConfiguration()) { + const Runnable runnable = runConfig->runnable(); + if (runnable.is() && isLocal(runConfig)) + m_pathChooser->setPath(runnable.as().executable); + } } m_hideOnAttachCheckBox = new QCheckBox(tr("Reopen dialog when application finishes"), this); @@ -171,20 +180,19 @@ void UnstartedAppWatcherDialog::selectExecutable() QString path; Project *project = ProjectTree::currentProject(); + Target *activeTarget = project ? project->activeTarget() : 0; - if (project && project->activeTarget() && project->activeTarget()->activeRunConfiguration()) { - - LocalApplicationRunConfiguration *localAppRC = - qobject_cast - (project->activeTarget()->activeRunConfiguration()); - if (localAppRC) - path = QFileInfo(localAppRC->executable()).path(); + if (activeTarget) { + if (RunConfiguration *runConfig = activeTarget->activeRunConfiguration()) { + const Runnable runnable = runConfig->runnable(); + if (runnable.is() && isLocal(runConfig)) + path = QFileInfo(runnable.as().executable).path(); + } } if (path.isEmpty()) { - if (project && project->activeTarget() && - project->activeTarget()->activeBuildConfiguration()) { - path = project->activeTarget()->activeBuildConfiguration()->buildDirectory().toString(); + if (activeTarget && activeTarget->activeBuildConfiguration()) { + path = activeTarget->activeBuildConfiguration()->buildDirectory().toString(); } else if (project) { path = project->projectDirectory().toString(); } -- cgit v1.2.1