From 9ef0b97716e4ed73187470bc574a9c2a550d8901 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 11 Mar 2019 15:42:43 +0100 Subject: Avoid some visible uses of RunControl::runConfiguration() For a long time, probably from the very beginning, a RunControl was meant to hold (a copy of) data needed for its operation, that was valid at the time of its construction, to be resilient in cases where RunConfiguration setting were changed while the RunControl was running, or to properly re-run with the original settings. Unfortunately, the task was repetitive, as RunConfiguration classes had no generic access to properties / "aspects" and there was was the runConfiguration() accessor (probably for mostly unrelated reasons in the output pane handling) which made the idea of just casting that to the original runConfiguration and access the data directly there appealing, with all the expected consequences. This patch here partially addresses the issue by copying some more of the related data at RunControl construction time and adjust the using code, avoiding most uses of the runConfiguration() accessor in a mostly mechanical matter. Complete removal appears possible, but will be less mechanical in "difficult" plugins like ios, so this is left for later. The new accessors in RunControl are very much ad-hoc, leaving room for improvement, e.g. by consolidating the access to the run config settings aspects with the other runconfig aspects or similar. For now the goal is to remove the runConfiguration() accessor, and to as much as possible fixed data after RunControl setup is finished. Next step would be to officially allow construction of RunControls without a specific RunConfiguration by setting the necessary data independently, removing the need for the various workarounds that are currently used for the purpose of faking (parts of) the effect of the non-existing RunConfiguration or refusing to operate at all, even if it would be possible. Change-Id: If8e5596da8422c70e90f97270389adbe6d0b46f2 Reviewed-by: Christian Kandeler --- src/plugins/winrt/winrtdebugsupport.cpp | 2 +- src/plugins/winrt/winrtrunnerhelper.cpp | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'src/plugins/winrt') diff --git a/src/plugins/winrt/winrtdebugsupport.cpp b/src/plugins/winrt/winrtdebugsupport.cpp index f7962c4ef05..d7f3e9a59bb 100644 --- a/src/plugins/winrt/winrtdebugsupport.cpp +++ b/src/plugins/winrt/winrtdebugsupport.cpp @@ -75,7 +75,7 @@ WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl) setQmlServer(qmlServer); } - setSymbolFile(runControl->runConfiguration()->buildTargetInfo().targetFilePath.toString()); + setSymbolFile(runControl->buildTargetInfo().targetFilePath.toString()); QString errorMessage; m_runner = new WinRtRunnerHelper(this, &errorMessage); if (!errorMessage.isEmpty()) { diff --git a/src/plugins/winrt/winrtrunnerhelper.cpp b/src/plugins/winrt/winrtrunnerhelper.cpp index 491abfc57fb..b5b10b06000 100644 --- a/src/plugins/winrt/winrtrunnerhelper.cpp +++ b/src/plugins/winrt/winrtrunnerhelper.cpp @@ -50,12 +50,11 @@ WinRtRunnerHelper::WinRtRunnerHelper(ProjectExplorer::RunWorker *runWorker, QStr : QObject(runWorker) , m_worker(runWorker) { - auto runConfiguration = runWorker->runControl()->runConfiguration(); + auto runControl = runWorker->runControl(); - ProjectExplorer::Target *target = runConfiguration->target(); m_device = runWorker->device().dynamicCast(); - const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(target->kit()); + const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(runControl->kit()); if (!qt) { *errorMessage = tr("The current kit has no Qt version."); return; @@ -68,7 +67,7 @@ WinRtRunnerHelper::WinRtRunnerHelper(ProjectExplorer::RunWorker *runWorker, QStr return; } - const BuildTargetInfo bti = runConfiguration->buildTargetInfo(); + const BuildTargetInfo bti = runControl->buildTargetInfo(); m_executableFilePath = bti.targetFilePath.toString(); if (m_executableFilePath.isEmpty()) { @@ -84,13 +83,13 @@ WinRtRunnerHelper::WinRtRunnerHelper(ProjectExplorer::RunWorker *runWorker, QStr bool loopbackExemptClient = false; bool loopbackExemptServer = false; - if (auto aspect = runConfiguration->aspect()) - m_arguments = aspect->arguments(runConfiguration->macroExpander()); - if (auto aspect = runConfiguration->aspect()) + if (auto aspect = runControl->aspect()) + m_arguments = aspect->arguments(runControl->runConfiguration()->macroExpander()); + if (auto aspect = runControl->aspect()) m_uninstallAfterStop = aspect->value(); - if (auto aspect = runConfiguration->aspect()) + if (auto aspect = runControl->aspect()) loopbackExemptClient = aspect->value(); - if (auto aspect = runConfiguration->aspect()) + if (auto aspect = runControl->aspect()) loopbackExemptServer = aspect->value(); if (loopbackExemptClient && loopbackExemptServer) m_loopbackArguments = "--loopbackexempt clientserver"; @@ -99,7 +98,7 @@ WinRtRunnerHelper::WinRtRunnerHelper(ProjectExplorer::RunWorker *runWorker, QStr else if (loopbackExemptServer) m_loopbackArguments = "--loopbackexempt server"; - if (ProjectExplorer::BuildConfiguration *bc = target->activeBuildConfiguration()) + if (BuildConfiguration *bc = runControl->target()->activeBuildConfiguration()) m_environment = bc->environment(); } -- cgit v1.2.3