Commit 6b1f96bf authored by Kai Koehne's avatar Kai Koehne

QmlProfiler: Re-enable attaching to a (remote) port

Change-Id: Iff5f8cf26e580ede4f82aba5a36acd785521da8d
Reviewed-on: http://codereview.qt-project.org/4890Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarAurindam Jana <aurindam.jana@nokia.com>
Reviewed-by: default avatarChristiaan Janssen <christiaan.janssen@nokia.com>
parent 26f16357
......@@ -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>
......
......@@ -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();
}
}
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -91,7 +91,6 @@ signals:
private slots:
void updateProjectFileList();
void attach();
void tryToConnect();
void connectionStateChanged();
void showSaveDialog();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment