forked from qt-creator/qt-creator
QmlProfilerRunner: Drop private data
Change-Id: I8f45174cec9de3c88056bbe364da1f7c40820b36 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -33,23 +33,8 @@ using namespace ProjectExplorer;
|
|||||||
|
|
||||||
namespace QmlProfiler::Internal {
|
namespace QmlProfiler::Internal {
|
||||||
|
|
||||||
//
|
|
||||||
// QmlProfilerRunControlPrivate
|
|
||||||
//
|
|
||||||
|
|
||||||
class QmlProfilerRunner::QmlProfilerRunnerPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QPointer<QmlProfilerStateManager> m_profilerState;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// QmlProfilerRunControl
|
|
||||||
//
|
|
||||||
|
|
||||||
QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl)
|
QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl)
|
||||||
: RunWorker(runControl)
|
: RunWorker(runControl)
|
||||||
, d(new QmlProfilerRunnerPrivate)
|
|
||||||
{
|
{
|
||||||
setId("QmlProfilerRunner");
|
setId("QmlProfilerRunner");
|
||||||
runControl->requestQmlChannel();
|
runControl->requestQmlChannel();
|
||||||
@@ -57,29 +42,21 @@ QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl)
|
|||||||
setSupportsReRunning(false);
|
setSupportsReRunning(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerRunner::~QmlProfilerRunner()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProfilerRunner::start()
|
void QmlProfilerRunner::start()
|
||||||
{
|
{
|
||||||
if (d->m_profilerState)
|
|
||||||
disconnect(d->m_profilerState, &QmlProfilerStateManager::stateChanged, this, nullptr);
|
|
||||||
|
|
||||||
QmlProfilerTool::instance()->finalizeRunControl(runControl());
|
QmlProfilerTool::instance()->finalizeRunControl(runControl());
|
||||||
connect(this, &QmlProfilerRunner::stopped,
|
connect(this, &QmlProfilerRunner::stopped,
|
||||||
QmlProfilerTool::instance(), &QmlProfilerTool::handleStop);
|
QmlProfilerTool::instance(), &QmlProfilerTool::handleStop);
|
||||||
d->m_profilerState = QmlProfilerTool::instance()->stateManager();
|
QmlProfilerStateManager *stateManager = QmlProfilerTool::instance()->stateManager();
|
||||||
QTC_ASSERT(d->m_profilerState, return);
|
QTC_ASSERT(stateManager, return);
|
||||||
|
|
||||||
connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged, this, [this] {
|
connect(stateManager, &QmlProfilerStateManager::stateChanged, this, [this, stateManager] {
|
||||||
if (d->m_profilerState->currentState() == QmlProfilerStateManager::Idle)
|
if (stateManager->currentState() == QmlProfilerStateManager::Idle)
|
||||||
reportStopped();
|
reportStopped();
|
||||||
});
|
});
|
||||||
|
|
||||||
QmlProfilerClientManager *clientManager = QmlProfilerTool::instance()->clientManager();
|
QmlProfilerClientManager *clientManager = QmlProfilerTool::instance()->clientManager();
|
||||||
connect(clientManager, &QmlProfilerClientManager::connectionFailed, this, [this, clientManager] {
|
connect(clientManager, &QmlProfilerClientManager::connectionFailed, this, [this, clientManager, stateManager] {
|
||||||
auto infoBox = new QMessageBox(ICore::dialogParent());
|
auto infoBox = new QMessageBox(ICore::dialogParent());
|
||||||
infoBox->setIcon(QMessageBox::Critical);
|
infoBox->setIcon(QMessageBox::Critical);
|
||||||
infoBox->setWindowTitle(QGuiApplication::applicationDisplayName());
|
infoBox->setWindowTitle(QGuiApplication::applicationDisplayName());
|
||||||
@@ -96,19 +73,17 @@ void QmlProfilerRunner::start()
|
|||||||
infoBox->setDefaultButton(QMessageBox::Retry);
|
infoBox->setDefaultButton(QMessageBox::Retry);
|
||||||
infoBox->setModal(true);
|
infoBox->setModal(true);
|
||||||
|
|
||||||
connect(infoBox, &QDialog::finished, this, [this, clientManager, interval](int result) {
|
connect(infoBox, &QDialog::finished, this, [this, clientManager, stateManager, interval](int result) {
|
||||||
const auto cancelProcess = [this] {
|
const auto cancelProcess = [this, stateManager] {
|
||||||
QTC_ASSERT(d->m_profilerState, return);
|
switch (stateManager->currentState()) {
|
||||||
|
|
||||||
switch (d->m_profilerState->currentState()) {
|
|
||||||
case QmlProfilerStateManager::Idle:
|
case QmlProfilerStateManager::Idle:
|
||||||
break;
|
break;
|
||||||
case QmlProfilerStateManager::AppRunning:
|
case QmlProfilerStateManager::AppRunning:
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
|
stateManager->setCurrentState(QmlProfilerStateManager::AppDying);
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
const QString message = QString::fromLatin1("Unexpected process termination requested with state %1 in %2:%3")
|
const QString message = QString::fromLatin1("Unexpected process termination requested with state %1 in %2:%3")
|
||||||
.arg(d->m_profilerState->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__));
|
.arg(stateManager->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__));
|
||||||
qWarning("%s", qPrintable(message));
|
qWarning("%s", qPrintable(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -142,18 +117,19 @@ void QmlProfilerRunner::start()
|
|||||||
|
|
||||||
void QmlProfilerRunner::stop()
|
void QmlProfilerRunner::stop()
|
||||||
{
|
{
|
||||||
if (!d->m_profilerState) {
|
QmlProfilerStateManager *stateManager = QmlProfilerTool::instance()->stateManager();
|
||||||
|
if (!stateManager) {
|
||||||
reportStopped();
|
reportStopped();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (d->m_profilerState->currentState()) {
|
switch (stateManager->currentState()) {
|
||||||
case QmlProfilerStateManager::AppRunning:
|
case QmlProfilerStateManager::AppRunning:
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopRequested);
|
stateManager->setCurrentState(QmlProfilerStateManager::AppStopRequested);
|
||||||
break;
|
break;
|
||||||
case QmlProfilerStateManager::AppStopRequested:
|
case QmlProfilerStateManager::AppStopRequested:
|
||||||
// Pressed "stop" a second time. Kill the application without collecting data
|
// Pressed "stop" a second time. Kill the application without collecting data
|
||||||
d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle);
|
stateManager->setCurrentState(QmlProfilerStateManager::Idle);
|
||||||
reportStopped();
|
reportStopped();
|
||||||
break;
|
break;
|
||||||
case QmlProfilerStateManager::Idle:
|
case QmlProfilerStateManager::Idle:
|
||||||
@@ -162,7 +138,7 @@ void QmlProfilerRunner::stop()
|
|||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
const QString message = QString::fromLatin1("Unexpected engine stop from state %1 in %2:%3")
|
const QString message = QString::fromLatin1("Unexpected engine stop from state %1 in %2:%3")
|
||||||
.arg(d->m_profilerState->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__));
|
.arg(stateManager->currentStateAsString(), QString::fromLatin1(__FILE__), QString::number(__LINE__));
|
||||||
qWarning("%s", qPrintable(message));
|
qWarning("%s", qPrintable(message));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -18,14 +18,10 @@ class QmlProfilerRunner : public ProjectExplorer::RunWorker
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlProfilerRunner(ProjectExplorer::RunControl *runControl);
|
QmlProfilerRunner(ProjectExplorer::RunControl *runControl);
|
||||||
~QmlProfilerRunner() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
|
||||||
class QmlProfilerRunnerPrivate;
|
|
||||||
QmlProfilerRunnerPrivate *d;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectExplorer::RunWorker *createLocalQmlProfilerWorker(ProjectExplorer::RunControl *runControl);
|
ProjectExplorer::RunWorker *createLocalQmlProfilerWorker(ProjectExplorer::RunControl *runControl);
|
||||||
|
Reference in New Issue
Block a user