diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2011-09-14 13:12:25 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2011-09-15 13:35:34 +0200 |
commit | 6b1f96bf7b25a72806fbdf3454a6dfe4c3c48fb0 (patch) | |
tree | 51386ffcafde69eb6c91417522cf829ed275b9af | |
parent | 26f163570bbcde6b808d4c41f6fe3f8904f6e384 (diff) | |
download | qt-creator-6b1f96bf7b25a72806fbdf3454a6dfe4c3c48fb0.tar.gz |
QmlProfiler: Re-enable attaching to a (remote) port
Change-Id: Iff5f8cf26e580ede4f82aba5a36acd785521da8d
Reviewed-on: http://codereview.qt-project.org/4890
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerattachdialog.ui | 6 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerengine.cpp | 24 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerengine.h | 3 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerplugin.cpp | 3 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertool.cpp | 112 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertool.h | 1 |
6 files changed, 83 insertions, 66 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerattachdialog.ui b/src/plugins/qmlprofiler/qmlprofilerattachdialog.ui index 5bae9fee4c..7619903627 100644 --- a/src/plugins/qmlprofiler/qmlprofilerattachdialog.ui +++ b/src/plugins/qmlprofiler/qmlprofilerattachdialog.ui @@ -6,12 +6,12 @@ <rect> <x>0</x> <y>0</y> - <width>164</width> - <height>96</height> + <width>184</width> + <height>124</height> </rect> </property> <property name="windowTitle"> - <string>Dialog</string> + <string>QML Profiler</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.cpp b/src/plugins/qmlprofiler/qmlprofilerengine.cpp index c5b6bfeed7..91e40c0900 100644 --- a/src/plugins/qmlprofiler/qmlprofilerengine.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerengine.cpp @@ -92,6 +92,8 @@ QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(ProjectExplorer::RunCo QObject *parent) { AbstractQmlProfilerRunner *runner = 0; + if (!runConfiguration) // attaching + return 0; if (QmlProjectManager::QmlProjectRunConfiguration *rc1 = qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration)) { // This is a "plain" .qmlproject. @@ -129,8 +131,9 @@ QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(ProjectExplorer::RunCo // QmlProfilerEngine::QmlProfilerEngine(IAnalyzerTool *tool, - ProjectExplorer::RunConfiguration *runConfiguration) - : IAnalyzerEngine(tool, runConfiguration) + const Analyzer::AnalyzerStartParameters &sp, + ProjectExplorer::RunConfiguration *runConfiguration) + : IAnalyzerEngine(tool, sp, runConfiguration) , d(new QmlProfilerEnginePrivate(this)) { d->m_running = false; @@ -178,12 +181,16 @@ bool QmlProfilerEngine::start() } } - connect(d->m_runner, SIGNAL(stopped()), this, SLOT(stopped())); - connect(d->m_runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)), - this, SLOT(logApplicationMessage(QString,Utils::OutputFormat))); + if (d->m_runner) { + connect(d->m_runner, SIGNAL(stopped()), this, SLOT(stopped())); + connect(d->m_runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)), + this, SLOT(logApplicationMessage(QString,Utils::OutputFormat))); + d->m_runner->start(); + d->m_noDebugOutputTimer.start(); + } else { + emit processRunning(startParameters().connParams.port); + } - d->m_noDebugOutputTimer.start(); - d->m_runner->start(); d->m_running = true; d->m_delayedDelete = false; @@ -246,7 +253,8 @@ void QmlProfilerEngine::finishProcess() // user stop? if (d->m_running) { d->m_running = false; - d->m_runner->stop(); + if (d->m_runner) + d->m_runner->stop(); emit finished(); } } diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.h b/src/plugins/qmlprofiler/qmlprofilerengine.h index 359ba8ebe8..21567c5f73 100644 --- a/src/plugins/qmlprofiler/qmlprofilerengine.h +++ b/src/plugins/qmlprofiler/qmlprofilerengine.h @@ -45,7 +45,8 @@ class QmlProfilerEngine : public Analyzer::IAnalyzerEngine public: QmlProfilerEngine(Analyzer::IAnalyzerTool *tool, - ProjectExplorer::RunConfiguration *runConfiguration); + const Analyzer::AnalyzerStartParameters &sp, + ProjectExplorer::RunConfiguration *runConfiguration); ~QmlProfilerEngine(); static void showNonmodalWarning(const QString &warningMsg); diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index 995a13cb5d..e43cdb8cae 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -50,9 +50,8 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS Q_UNUSED(errorString) addAutoReleasedObject(new QmlProfilerRunControlFactory()); StartModes modes; - // They are handled the same actually. - //modes.append(StartMode(StartRemote)); modes.append(StartMode(StartLocal)); + modes.append(StartMode(StartRemote)); AnalyzerManager::addTool(new QmlProfilerTool(this), modes); return true; } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index a3f2a91efc..8c03213464 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -45,6 +45,7 @@ #include <analyzerbase/analyzermanager.h> #include <analyzerbase/analyzerconstants.h> +#include <analyzerbase/analyzerruncontrol.h> #include "canvas/qdeclarativecanvas_p.h" #include "canvas/qdeclarativecontext2d_p.h" @@ -83,6 +84,7 @@ using namespace Analyzer; using namespace QmlProfiler::Internal; using namespace QmlJsDebugClient; +using namespace ProjectExplorer; class QmlProfilerTool::QmlProfilerToolPrivate { @@ -99,9 +101,9 @@ public: QmlProfilerEventsView *m_eventsView; QmlProfilerEventsView *m_calleeView; QmlProfilerEventsView *m_callerView; - ProjectExplorer::Project *m_project; + Project *m_project; Utils::FileInProjectFinder m_projectFinder; - ProjectExplorer::RunConfiguration *m_runConfiguration; + RunConfiguration *m_runConfiguration; bool m_isAttached; QToolButton *m_recordButton; QToolButton *m_clearButton; @@ -196,35 +198,38 @@ void QmlProfilerTool::showContextMenu(const QPoint &position) } IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp, - ProjectExplorer::RunConfiguration *runConfiguration) -{ - QmlProfilerEngine *engine = new QmlProfilerEngine(this, runConfiguration); - - // Check minimum Qt Version. We cannot really be sure what the Qt version - // at runtime is, but guess that the active build configuraiton has been used. - QtSupport::QtVersionNumber minimumVersion(4, 7, 4); - if (Qt4ProjectManager::Qt4BuildConfiguration *qt4Config - = qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration*>( - runConfiguration->target()->activeBuildConfiguration())) { - if (qt4Config->qtVersion()->isValid() && qt4Config->qtVersion()->qtVersion() < minimumVersion) { - int result = QMessageBox::warning(QApplication::activeWindow(), tr("QML Profiler"), - tr("The QML profiler requires Qt 4.7.4 or newer.\n" - "The Qt version configured in your active build configuration is too old.\n" - "Do you want to continue?"), QMessageBox::Yes, QMessageBox::No); - if (result == QMessageBox::No) - return 0; - } - } + RunConfiguration *runConfiguration) +{ + QmlProfilerEngine *engine = new QmlProfilerEngine(this, sp, runConfiguration); d->m_connectMode = QmlProfilerToolPrivate::TcpConnection; - if (Qt4ProjectManager::S60DeployConfiguration *deployConfig - = qobject_cast<Qt4ProjectManager::S60DeployConfiguration*>( - runConfiguration->target()->activeDeployConfiguration())) { - if (deployConfig->communicationChannel() - == Qt4ProjectManager::S60DeployConfiguration::CommunicationCodaSerialConnection) { - d->m_connectMode = QmlProfilerToolPrivate::OstConnection; - d->m_ostDevice = deployConfig->serialPortName(); + if (runConfiguration) { + // Check minimum Qt Version. We cannot really be sure what the Qt version + // at runtime is, but guess that the active build configuraiton has been used. + QtSupport::QtVersionNumber minimumVersion(4, 7, 4); + if (Qt4ProjectManager::Qt4BuildConfiguration *qt4Config + = qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration*>( + runConfiguration->target()->activeBuildConfiguration())) { + if (qt4Config->qtVersion()->isValid() && qt4Config->qtVersion()->qtVersion() < minimumVersion) { + int result = QMessageBox::warning(QApplication::activeWindow(), tr("QML Profiler"), + tr("The QML profiler requires Qt 4.7.4 or newer.\n" + "The Qt version configured in your active build configuration is too old.\n" + "Do you want to continue?"), QMessageBox::Yes, QMessageBox::No); + if (result == QMessageBox::No) + return 0; + } + } + + // Check whether we should use OST instead of TCP + if (Qt4ProjectManager::S60DeployConfiguration *deployConfig + = qobject_cast<Qt4ProjectManager::S60DeployConfiguration*>( + runConfiguration->target()->activeDeployConfiguration())) { + if (deployConfig->communicationChannel() + == Qt4ProjectManager::S60DeployConfiguration::CommunicationCodaSerialConnection) { + d->m_connectMode = QmlProfilerToolPrivate::OstConnection; + d->m_ostDevice = deployConfig->serialPortName(); + } } } @@ -235,7 +240,12 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp } d->m_runConfiguration = runConfiguration; - d->m_project = runConfiguration->target()->project(); + + if (runConfiguration) + d->m_project = runConfiguration->target()->project(); + else + d->m_project = ProjectExplorerPlugin::instance()->currentProject(); + if (d->m_project) { d->m_projectFinder.setProjectDirectory(d->m_project->projectDirectory()); updateProjectFileList(); @@ -464,7 +474,7 @@ void QmlProfilerTool::updateTimer(qreal elapsedSeconds) void QmlProfilerTool::updateProjectFileList() { d->m_projectFinder.setProjectFiles( - d->m_project->files(ProjectExplorer::Project::ExcludeGeneratedFiles)); + d->m_project->files(Project::ExcludeGeneratedFiles)); } void QmlProfilerTool::clearDisplay() @@ -475,25 +485,23 @@ void QmlProfilerTool::clearDisplay() d->m_callerView->clear(); } -void QmlProfilerTool::attach() +static void startRemoteTool(IAnalyzerTool *tool, StartMode mode) { - if (!d->m_isAttached) { - QmlProfilerAttachDialog dialog; - int result = dialog.exec(); + Q_UNUSED(tool); + QmlProfilerAttachDialog dialog; + if (dialog.exec() != QDialog::Accepted) + return; - if (result == QDialog::Rejected) - return; + AnalyzerStartParameters sp; + sp.toolId = tool->id(); + sp.startMode = mode; + sp.connParams.host = dialog.address(); + sp.connParams.port = dialog.port(); - d->m_tcpPort = dialog.port(); - d->m_tcpHost = dialog.address(); + AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0); + QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt())); - connectClient(d->m_tcpPort); - AnalyzerManager::showMode(); - } else { - stopRecording(); - } - - d->m_isAttached = !d->m_isAttached; + ProjectExplorerPlugin::instance()->startRunControl(rc, tool->id()); } void QmlProfilerTool::tryToConnect() @@ -567,17 +575,19 @@ void QmlProfilerTool::updateRecordingState() void QmlProfilerTool::startTool(StartMode mode) { - Q_UNUSED(mode); - using namespace ProjectExplorer; // Make sure mode is shown. AnalyzerManager::showMode(); - ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); - // ### not sure if we're supposed to check if the RunConFiguration isEnabled - Project *pro = pe->startupProject(); - pe->runProject(pro, id()); + if (mode == StartLocal) { + ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); + // ### not sure if we're supposed to check if the RunConFiguration isEnabled + Project *pro = pe->startupProject(); + pe->runProject(pro, id()); + } else if (mode == StartRemote) { + startRemoteTool(this, mode); + } } void QmlProfilerTool::logStatus(const QString &msg) diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index 36f5f64e8c..7ade2fffa6 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -91,7 +91,6 @@ signals: private slots: void updateProjectFileList(); - void attach(); void tryToConnect(); void connectionStateChanged(); void showSaveDialog(); |