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 a22e79f38c
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 <jaroslaw.kobus@qt.io>
This commit is contained in:
Eike Ziller
2025-04-03 14:22:17 +02:00
parent 39ef6244ba
commit 21661db604
2 changed files with 4 additions and 2 deletions

View File

@@ -38,7 +38,6 @@ QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl)
: RunWorker(runControl) : RunWorker(runControl)
{ {
setId("QmlProfilerRunner"); setId("QmlProfilerRunner");
runControl->requestQmlChannel();
runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR); runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR);
} }
@@ -152,6 +151,7 @@ RunWorker *createLocalQmlProfilerWorker(RunControl *runControl)
worker->setId("LocalQmlProfilerSupport"); worker->setId("LocalQmlProfilerSupport");
auto profiler = new QmlProfilerRunner(runControl); auto profiler = new QmlProfilerRunner(runControl);
runControl->requestQmlChannel();
worker->addStopDependency(profiler); worker->addStopDependency(profiler);
// We need to open the local server before the application tries to connect. // We need to open the local server before the application tries to connect.

View File

@@ -555,7 +555,9 @@ ProjectExplorer::RunControl *QmlProfilerTool::attachToWaitingApplication()
d->m_viewContainer->perspective()->select(); d->m_viewContainer->perspective()->select();
auto runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); 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, // 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 // similar to how QObject children are owned by their parents
[[maybe_unused]] auto profiler = new QmlProfilerRunner(runControl); [[maybe_unused]] auto profiler = new QmlProfilerRunner(runControl);