diff --git a/src/plugins/analyzerbase/ianalyzertool.cpp b/src/plugins/analyzerbase/ianalyzertool.cpp index eda784f5250..db72921079a 100644 --- a/src/plugins/analyzerbase/ianalyzertool.cpp +++ b/src/plugins/analyzerbase/ianalyzertool.cpp @@ -97,6 +97,9 @@ void AnalyzerAction::startTool() TaskHub::clearTasks(Constants::ANALYZERTASK_ID); + if (m_toolPreparer && !m_toolPreparer()) + return; + // Custom start. if (m_toolStarter) { m_toolStarter(); diff --git a/src/plugins/analyzerbase/ianalyzertool.h b/src/plugins/analyzerbase/ianalyzertool.h index d998e782b41..84b478ad0bb 100644 --- a/src/plugins/analyzerbase/ianalyzertool.h +++ b/src/plugins/analyzerbase/ianalyzertool.h @@ -110,6 +110,10 @@ public: void startTool(); void setToolStarter(const ToolStarter &toolStarter) { m_toolStarter = toolStarter; } + typedef std::function ToolPreparer; + ToolPreparer toolPreparer() const { return m_toolPreparer; } + void setToolPreparer(const ToolPreparer &toolPreparer) { m_toolPreparer = toolPreparer; } + protected: bool m_useStartupProject; Core::Id m_menuGroup; @@ -120,6 +124,7 @@ protected: WidgetCreator m_widgetCreator; RunControlCreator m_runControlCreator; ToolStarter m_toolStarter; + ToolPreparer m_toolPreparer; }; } // namespace Analyzer diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index 01c69b2b975..415c86e2dab 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -70,7 +70,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS action->setToolId(QmlProfilerToolId); action->setWidgetCreator(widgetCreator); action->setRunControlCreator(runControlCreator); - action->setToolStarter([tool] { tool->startLocalTool(); }); + action->setToolPreparer([tool] { return tool->prepareTool(); }); action->setRunMode(ProjectExplorer::QmlProfilerRunMode); action->setText(tr("QML Profiler")); action->setToolTip(description); @@ -83,6 +83,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS action->setWidgetCreator(widgetCreator); action->setRunControlCreator(runControlCreator); action->setToolStarter([tool] { tool->startRemoteTool(); }); + action->setToolPreparer([tool] { return tool->prepareTool(); }); action->setRunMode(ProjectExplorer::QmlProfilerRunMode); action->setText(tr("QML Profiler (External)")); action->setToolTip(description); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 0c0c5429f9f..27df8eea89d 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -433,29 +433,21 @@ void QmlProfilerTool::clearDisplay() updateTimeDisplay(); } -void QmlProfilerTool::startLocalTool() +bool QmlProfilerTool::prepareTool() { if (d->m_recordButton->isChecked()) { - if (!checkForUnsavedNotes()) - return; - clearData(); // clear right away to suppress second warning on server recording change + if (checkForUnsavedNotes()) { + clearData(); // clear right away to suppress second warning on server recording change + return true; + } else { + return false; + } } - - // Make sure mode is shown. - AnalyzerManager::showMode(); - - // ### not sure if we're supposed to check if the RunConFiguration isEnabled - ProjectExplorerPlugin::runStartupProject(QmlProfilerRunMode); + return true; } void QmlProfilerTool::startRemoteTool() { - if (d->m_recordButton->isChecked()) { - if (!checkForUnsavedNotes()) - return; - clearData(); // clear right away to suppress second warning on server recording change - } - AnalyzerManager::showMode(); Id kitId; diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index cc062075503..ce59a8fc794 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -58,7 +58,7 @@ public: ProjectExplorer::RunConfiguration *runConfiguration = 0); QWidget *createWidgets(); - void startLocalTool(); + bool prepareTool(); void startRemoteTool(); QList profilerContextMenuActions() const;