forked from qt-creator/qt-creator
QmlProfiler: Drop static accessors from QmlProfilerTool
It wasn't really a singleton even before. For testing purposes make the client/state/model managers accessible. Change-Id: Ie5efbc47a6b9119495f999e4e05877d4789da407 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -28,8 +28,6 @@
|
||||
#include "qmlprofilerclientmanager.h"
|
||||
#include "qmlprofilertool.h"
|
||||
|
||||
#include <app/app_version.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/helpmanager.h>
|
||||
|
||||
@@ -57,6 +55,7 @@ using namespace ProjectExplorer;
|
||||
using namespace QmlProfiler::Internal;
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
static QString QmlServerUrl = "QmlServerUrl";
|
||||
|
||||
@@ -92,46 +91,8 @@ QmlProfilerRunner::~QmlProfilerRunner()
|
||||
|
||||
void QmlProfilerRunner::start()
|
||||
{
|
||||
Internal::QmlProfilerTool::instance()->finalizeRunControl(this);
|
||||
emit starting(this);
|
||||
QTC_ASSERT(d->m_profilerState, return);
|
||||
|
||||
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(Core::Constants::IDE_DISPLAY_NAME);
|
||||
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();
|
||||
}, Qt::QueuedConnection); // Queue any connection failures after reportStarted()
|
||||
|
||||
clientManager->connectToServer(serverUrl);
|
||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning);
|
||||
reportStarted();
|
||||
}
|
||||
|
||||
@@ -261,18 +222,22 @@ static QUrl localServerUrl(RunControl *runControl)
|
||||
return serverUrl;
|
||||
}
|
||||
|
||||
LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl)
|
||||
: LocalQmlProfilerSupport(runControl, localServerUrl(runControl))
|
||||
LocalQmlProfilerSupport::LocalQmlProfilerSupport(QmlProfilerTool *profilerTool,
|
||||
RunControl *runControl)
|
||||
: LocalQmlProfilerSupport(profilerTool, runControl, localServerUrl(runControl))
|
||||
{
|
||||
}
|
||||
|
||||
LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const QUrl &serverUrl)
|
||||
LocalQmlProfilerSupport::LocalQmlProfilerSupport(QmlProfilerTool *profilerTool,
|
||||
RunControl *runControl, const QUrl &serverUrl)
|
||||
: SimpleTargetRunner(runControl)
|
||||
{
|
||||
setDisplayName("LocalQmlProfilerSupport");
|
||||
|
||||
m_profiler = new QmlProfilerRunner(runControl);
|
||||
m_profiler->setServerUrl(serverUrl);
|
||||
connect(m_profiler, &QmlProfilerRunner::starting,
|
||||
profilerTool, &QmlProfilerTool::finalizeRunControl);
|
||||
|
||||
addStopDependency(m_profiler);
|
||||
// We need to open the local server before the application tries to connect.
|
||||
@@ -301,4 +266,5 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const Q
|
||||
setRunnable(debuggee);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
|
||||
Reference in New Issue
Block a user