Commit a9d2e645 authored by hjk's avatar hjk

QmlProfiler: Move TCP connection initialization to runworker's start()

That makes the high level sequence of operation the same as for the
local socket case.

Change-Id: Ib8af2a7826a482e98b75fe00f3c0e672b98886c5
Reviewed-by: Ulf Hermann's avatarUlf Hermann <ulf.hermann@qt.io>
parent 51dd89fc
......@@ -103,10 +103,44 @@ void QmlProfilerRunner::start()
QUrl serverUrl = this->serverUrl();
QmlProfilerClientManager *clientManager = Internal::QmlProfilerTool::clientManager();
connect(clientManager, &QmlProfilerClientManager::connectionFailed,
this, [this, clientManager] {
QMessageBox *infoBox = new QMessageBox(ICore::mainWindow());
infoBox->setIcon(QMessageBox::Critical);
infoBox->setWindowTitle(QmlProfilerTool::tr("Qt Creator"));
infoBox->setText(QmlProfilerTool::tr("Could not connect to the in-process QML profiler.\n"
"Do you want to retry?"));
infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel | QMessageBox::Help);
infoBox->setDefaultButton(QMessageBox::Retry);
infoBox->setModal(true);
connect(infoBox, &QDialog::finished, this, [clientManager, this](int result) {
switch (result) {
case QMessageBox::Retry:
clientManager->retryConnect();
break;
case QMessageBox::Help:
HelpManager::handleHelpRequest(
"qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html");
Q_FALLTHROUGH();
case QMessageBox::Cancel:
// The actual error message has already been logged.
QmlProfilerTool::logState(QmlProfilerTool::tr("Failed to connect."));
cancelProcess();
break;
}
});
infoBox->show();
});
clientManager->setServerUrl(serverUrl);
if (serverUrl.port() != -1) {
QmlProfilerClientManager *clientManager = Internal::QmlProfilerTool::clientManager();
clientManager->setServerUrl(serverUrl);
clientManager->connectToTcpServer();
} else {
clientManager->startLocalServer();
}
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning);
......
......@@ -352,16 +352,6 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker)
updateRunActions();
runWorker->registerProfilerStateManager(d->m_profilerState);
QmlProfilerClientManager *clientManager = d->m_profilerConnections;
// FIXME: Check that there's something sensible in sp.connParams
auto serverUrl = runWorker->serverUrl();
clientManager->setServerUrl(serverUrl);
if (!serverUrl.path().isEmpty()) {
// That's the local socket case.
// We open the server and the application connects to it, so let's do that right away.
clientManager->startLocalServer();
}
//
// Initialize m_projectFinder
......@@ -370,37 +360,6 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker)
if (runConfiguration) {
d->m_profilerModelManager->populateFileFinder(runConfiguration);
}
connect(clientManager, &QmlProfilerClientManager::connectionFailed,
runWorker, [this, clientManager, runWorker]() {
QMessageBox *infoBox = new QMessageBox(ICore::mainWindow());
infoBox->setIcon(QMessageBox::Critical);
infoBox->setWindowTitle(tr("Qt Creator"));
infoBox->setText(tr("Could not connect to the in-process QML profiler.\n"
"Do you want to retry?"));
infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel | QMessageBox::Help);
infoBox->setDefaultButton(QMessageBox::Retry);
infoBox->setModal(true);
connect(infoBox, &QDialog::finished, runWorker, [clientManager, runWorker](int result) {
switch (result) {
case QMessageBox::Retry:
clientManager->retryConnect();
break;
case QMessageBox::Help:
HelpManager::handleHelpRequest(
"qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html");
Q_FALLTHROUGH();
case QMessageBox::Cancel:
// The actual error message has already been logged.
logState(tr("Failed to connect."));
runWorker->cancelProcess();
break;
}
});
infoBox->show();
});
}
void QmlProfilerTool::recordingButtonChanged(bool recording)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment