From 21661db604437e9188f09d419c4d14a1ad5b14bd Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 3 Apr 2025 14:22:17 +0200 Subject: [PATCH] Fix attaching QML Profiler to running application The QML channel to use (the port that the user specified in the dialog for attaching) was no longer set for the QmlProfilerRunner. That broke with a22e79f38c13b652ad9639ee810647fc0c0e96b0 Avoid the usage of the ports gatherer with QmlProfilerRunner for the attachToWaitingApplication case and set the qmlChannel manually. Also avoid soft assert if there is no active run configuration. Fixes: QTCREATORBUG-32617 Change-Id: I608cc736ed82284afbdd40277a54237f80f30306 Reviewed-by: Jarek Kobus --- src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp | 2 +- src/plugins/qmlprofiler/qmlprofilertool.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index c0cff2369cc..8139596fab7 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -38,7 +38,6 @@ QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl) : RunWorker(runControl) { setId("QmlProfilerRunner"); - runControl->requestQmlChannel(); runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR); } @@ -152,6 +151,7 @@ RunWorker *createLocalQmlProfilerWorker(RunControl *runControl) worker->setId("LocalQmlProfilerSupport"); auto profiler = new QmlProfilerRunner(runControl); + runControl->requestQmlChannel(); worker->addStopDependency(profiler); // We need to open the local server before the application tries to connect. diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index cc456bc448f..e576a0a18c2 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -555,7 +555,9 @@ ProjectExplorer::RunControl *QmlProfilerTool::attachToWaitingApplication() d->m_viewContainer->perspective()->select(); auto runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); - runControl->copyDataFromRunConfiguration(activeRunConfigForActiveProject()); + if (RunConfiguration *runConfig = activeRunConfigForActiveProject()) + runControl->copyDataFromRunConfiguration(runConfig); + runControl->setQmlChannel(serverUrl); // The object as such is needed, the RunWorker becomes part of the RunControl at construction time, // similar to how QObject children are owned by their parents [[maybe_unused]] auto profiler = new QmlProfilerRunner(runControl);