summaryrefslogtreecommitdiff
path: root/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp140
1 files changed, 48 insertions, 92 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
index f009a99429..90608cbb1f 100644
--- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
@@ -23,20 +23,15 @@
**
****************************************************************************/
-#include "qmlprofilerclientmanager.h"
#include "qmlprofilerruncontrol.h"
-#include "qmlprofilertool.h"
-#include "qmlprofilerplugin.h"
-#include <debugger/analyzer/analyzermanager.h>
+#include "qmlprofilerclientmanager.h"
+#include "qmlprofilertool.h"
#include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
-#include <projectexplorer/devicesupport/idevice.h>
-#include <projectexplorer/environmentaspect.h>
#include <projectexplorer/kitinformation.h>
-#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorericons.h>
#include <projectexplorer/runconfiguration.h>
@@ -47,18 +42,13 @@
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtsupportconstants.h>
-#include <qmldebug/qmloutputparser.h>
#include <qmldebug/qmldebugcommandlinearguments.h>
#include <utils/qtcassert.h>
+#include <utils/qtcfallthrough.h>
-#include <QApplication>
-#include <QMainWindow>
#include <QMessageBox>
-#include <QPushButton>
-#include <QTimer>
-using namespace Debugger;
using namespace Core;
using namespace ProjectExplorer;
using namespace QmlProfiler::Internal;
@@ -75,7 +65,6 @@ class QmlProfilerRunner::QmlProfilerRunnerPrivate
{
public:
QmlProfilerStateManager *m_profilerState = 0;
- QTimer m_noDebugOutputTimer;
};
//
@@ -89,14 +78,6 @@ QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl)
setDisplayName("QmlProfilerRunner");
runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR);
setSupportsReRunning(false);
-
- // Only wait 4 seconds for the 'Waiting for connection' on application output, then just try to connect
- // (application output might be redirected / blocked)
- d->m_noDebugOutputTimer.setSingleShot(true);
- d->m_noDebugOutputTimer.setInterval(4000);
- connect(&d->m_noDebugOutputTimer, &QTimer::timeout, this, [this]() {
- notifyRemoteSetupDone(Utils::Port());
- });
}
QmlProfilerRunner::~QmlProfilerRunner()
@@ -113,13 +94,45 @@ 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();
}
- else if (serverUrl.path().isEmpty())
- d->m_noDebugOutputTimer.start();
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning);
@@ -137,6 +150,7 @@ void QmlProfilerRunner::stop()
case QmlProfilerStateManager::AppStopRequested:
// Pressed "stop" a second time. Kill the application without collecting data
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
+ reportStopped();
break;
case QmlProfilerStateManager::Idle:
case QmlProfilerStateManager::AppDying:
@@ -149,7 +163,6 @@ void QmlProfilerRunner::stop()
}
break;
}
- reportStopped();
}
void QmlProfilerRunner::notifyRemoteFinished()
@@ -190,53 +203,6 @@ void QmlProfilerRunner::cancelProcess()
runControl()->initiateStop();
}
-void QmlProfilerRunner::notifyRemoteSetupFailed(const QString &errorMessage)
-{
- QMessageBox *infoBox = new QMessageBox(ICore::mainWindow());
- infoBox->setIcon(QMessageBox::Critical);
- infoBox->setWindowTitle(tr("Qt Creator"));
- //: %1 is detailed error message
- infoBox->setText(tr("Could not connect to the in-process QML debugger:\n%1")
- .arg(errorMessage));
- infoBox->setStandardButtons(QMessageBox::Ok | QMessageBox::Help);
- infoBox->setDefaultButton(QMessageBox::Ok);
- infoBox->setModal(true);
-
- connect(infoBox, &QDialog::finished,
- this, &QmlProfilerRunner::wrongSetupMessageBoxFinished);
-
- infoBox->show();
-
- // KILL
- d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
- d->m_noDebugOutputTimer.stop();
-}
-
-void QmlProfilerRunner::wrongSetupMessageBoxFinished(int button)
-{
- if (button == QMessageBox::Help) {
- HelpManager::handleHelpRequest(QLatin1String("qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html"
- "#setting-up-qml-debugging"));
- }
-}
-
-void QmlProfilerRunner::notifyRemoteSetupDone(Utils::Port port)
-{
- d->m_noDebugOutputTimer.stop();
-
- QUrl serverUrl = this->serverUrl();
- if (!port.isValid())
- port = Utils::Port(serverUrl.port());
-
- if (port.isValid()) {
- serverUrl.setPort(port.number());
- auto clientManager = Internal::QmlProfilerTool::clientManager();
- clientManager->setServerUrl(serverUrl);
- clientManager->connectToTcpServer();
- reportStarted();
- }
-}
-
void QmlProfilerRunner::registerProfilerStateManager( QmlProfilerStateManager *profilerState )
{
// disconnect old
@@ -256,7 +222,7 @@ void QmlProfilerRunner::profilerStateChanged()
{
switch (d->m_profilerState->currentState()) {
case QmlProfilerStateManager::Idle:
- d->m_noDebugOutputTimer.stop();
+ reportStopped();
break;
default:
break;
@@ -302,13 +268,17 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl)
}
LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const QUrl &serverUrl)
- : RunWorker(runControl)
+ : SimpleTargetRunner(runControl)
{
setDisplayName("LocalQmlProfilerSupport");
m_profiler = new QmlProfilerRunner(runControl);
m_profiler->setServerUrl(serverUrl);
- m_profiler->addDependency(this);
+
+ addStopDependency(m_profiler);
+ // We need to open the local server before the application tries to connect.
+ // In the TCP case, it doesn't hurt either to start the profiler before.
+ addStartDependency(m_profiler);
StandardRunnable debuggee = runnable().as<StandardRunnable>();
QString arguments = QmlDebug::qmlDebugArguments(QmlDebug::QmlProfilerServices, serverUrl);
@@ -319,21 +289,7 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const Q
debuggee.commandLineArguments = arguments;
debuggee.runMode = ApplicationLauncher::Gui;
- m_profilee = new SimpleTargetRunner(runControl);
- m_profilee->setRunnable(debuggee);
- addDependency(m_profilee);
-}
-
-void LocalQmlProfilerSupport::start()
-{
- reportStarted();
- emit localRunnerStarted();
-}
-
-void LocalQmlProfilerSupport::stop()
-{
- reportStopped();
- emit localRunnerStopped();
+ setRunnable(debuggee);
}
} // namespace QmlProfiler