forked from qt-creator/qt-creator
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 <ulf.hermann@qt.io>
This commit is contained in:
@@ -103,10 +103,44 @@ void QmlProfilerRunner::start()
|
|||||||
|
|
||||||
QUrl serverUrl = this->serverUrl();
|
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) {
|
if (serverUrl.port() != -1) {
|
||||||
QmlProfilerClientManager *clientManager = Internal::QmlProfilerTool::clientManager();
|
|
||||||
clientManager->setServerUrl(serverUrl);
|
|
||||||
clientManager->connectToTcpServer();
|
clientManager->connectToTcpServer();
|
||||||
|
} else {
|
||||||
|
clientManager->startLocalServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning);
|
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning);
|
||||||
|
@@ -352,16 +352,6 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker)
|
|||||||
|
|
||||||
updateRunActions();
|
updateRunActions();
|
||||||
runWorker->registerProfilerStateManager(d->m_profilerState);
|
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
|
// Initialize m_projectFinder
|
||||||
@@ -370,37 +360,6 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker)
|
|||||||
if (runConfiguration) {
|
if (runConfiguration) {
|
||||||
d->m_profilerModelManager->populateFileFinder(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)
|
void QmlProfilerTool::recordingButtonChanged(bool recording)
|
||||||
|
Reference in New Issue
Block a user