forked from qt-creator/qt-creator
QmlProfiler: qmlproject support
Reviewed-by: Kai Koehne
This commit is contained in:
@@ -255,9 +255,8 @@ AnalyzerManager::AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager
|
||||
{
|
||||
m_toolBox->setObjectName(QLatin1String("AnalyzerManagerToolBox"));
|
||||
m_runControlFactory = new AnalyzerRunControlFactory();
|
||||
AnalyzerPlugin::instance()->addAutoReleasedObject(m_runControlFactory);
|
||||
connect(m_runControlFactory, SIGNAL(runControlCreated(Analyzer::AnalyzerRunControl *)),
|
||||
q, SLOT(runControlCreated(Analyzer::AnalyzerRunControl *)));
|
||||
|
||||
q->registerRunControlFactory(m_runControlFactory);
|
||||
|
||||
connect(m_toolBox, SIGNAL(currentIndexChanged(int)),
|
||||
q, SLOT(toolSelected(int)));
|
||||
@@ -275,6 +274,13 @@ AnalyzerManager::AnalyzerManagerPrivate::~AnalyzerManagerPrivate()
|
||||
}
|
||||
}
|
||||
|
||||
void AnalyzerManager::registerRunControlFactory(ProjectExplorer::IRunControlFactory *factory)
|
||||
{
|
||||
AnalyzerPlugin::instance()->addAutoReleasedObject(factory);
|
||||
connect(factory, SIGNAL(runControlCreated(Analyzer::AnalyzerRunControl *)),
|
||||
this, SLOT(runControlCreated(Analyzer::AnalyzerRunControl *)));
|
||||
}
|
||||
|
||||
void AnalyzerManager::AnalyzerManagerPrivate::setupActions()
|
||||
{
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#define ANALYZERMANAGER_H
|
||||
|
||||
#include "analyzerbase_global.h"
|
||||
#include "projectexplorer/runconfiguration.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
@@ -75,6 +76,7 @@ public:
|
||||
~AnalyzerManager();
|
||||
|
||||
static AnalyzerManager *instance();
|
||||
void registerRunControlFactory(ProjectExplorer::IRunControlFactory *factory);
|
||||
|
||||
bool isInitialized() const;
|
||||
void shutdown();
|
||||
|
@@ -45,7 +45,6 @@
|
||||
#include <QtGui/QVBoxLayout>
|
||||
|
||||
using namespace Analyzer;
|
||||
using namespace Analyzer::Internal;
|
||||
|
||||
AnalyzerRunConfigWidget::AnalyzerRunConfigWidget()
|
||||
: m_detailsWidget(new Utils::DetailsWidget(this))
|
||||
|
@@ -38,6 +38,7 @@
|
||||
#define ANALYZER_INTERNAL_ANALYZERRUNCONFIGWIDGET_H
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <analyzerbase/analyzerbase_global.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QStandardItemModel;
|
||||
@@ -51,9 +52,7 @@ namespace Analyzer {
|
||||
|
||||
class AnalyzerSettings;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class AnalyzerRunConfigWidget : public ProjectExplorer::RunConfigWidget
|
||||
class ANALYZER_EXPORT AnalyzerRunConfigWidget : public ProjectExplorer::RunConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -68,7 +67,6 @@ private:
|
||||
Utils::DetailsWidget *m_detailsWidget;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ANALYZER_INTERNAL_ANALYZERRUNCONFIGWIDGET_H
|
||||
|
@@ -272,7 +272,8 @@ plugin_analyzerbase.depends += plugin_projectexplorer
|
||||
|
||||
plugin_qmlprofiler.subdir = qmlprofiler
|
||||
plugin_qmlprofiler.depends = plugin_coreplugin
|
||||
plugin_qmlprofiler.depends = plugin_analyzerbase
|
||||
plugin_qmlprofiler.depends += plugin_analyzerbase
|
||||
plugin_qmlprofiler.depends += plugin_qmlprojectmanager
|
||||
}
|
||||
|
||||
plugin_qmljstools.subdir = qmljstools
|
||||
|
@@ -6,6 +6,7 @@ DEFINES += PROFILER_LIBRARY
|
||||
include(../../qtcreatorplugin.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(../../plugins/analyzerbase/analyzerbase.pri)
|
||||
include(../../plugins/qmlprojectmanager/qmlprojectmanager.pri)
|
||||
|
||||
|
||||
QT += network script declarative
|
||||
@@ -20,7 +21,8 @@ SOURCES += \
|
||||
tracewindow.cpp \
|
||||
timelineview.cpp \
|
||||
qmlprofilerattachdialog.cpp \
|
||||
qmlprofilersummaryview.cpp
|
||||
qmlprofilersummaryview.cpp \
|
||||
qmlprojectanalyzerruncontrolfactory.cpp
|
||||
|
||||
HEADERS += \
|
||||
qmlprofilerconstants.h \
|
||||
@@ -31,7 +33,8 @@ HEADERS += \
|
||||
tracewindow.h \
|
||||
timelineview.h \
|
||||
qmlprofilerattachdialog.h \
|
||||
qmlprofilersummaryview.h
|
||||
qmlprofilersummaryview.h \
|
||||
qmlprojectanalyzerruncontrolfactory.h
|
||||
|
||||
RESOURCES += \
|
||||
qml/qml.qrc
|
||||
|
@@ -39,8 +39,6 @@
|
||||
#include <analyzerbase/analyzermanager.h>
|
||||
#include <analyzerbase/analyzerconstants.h>
|
||||
|
||||
#include <projectexplorer/applicationrunconfiguration.h>
|
||||
|
||||
#include <private/qdeclarativedebugclient_p.h>
|
||||
|
||||
#include "timelineview.h"
|
||||
@@ -52,9 +50,7 @@
|
||||
#include "canvas/qdeclarativecontext2d_p.h"
|
||||
#include "canvas/qdeclarativetiledcanvas_p.h"
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <QProcess>
|
||||
#include "tracewindow.h"
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
#include <unistd.h> // sleep
|
||||
@@ -73,11 +69,7 @@ public:
|
||||
|
||||
QmlProfilerEngine *q;
|
||||
|
||||
QString m_workingDirectory;
|
||||
QString m_executable;
|
||||
QString m_commandLineArguments;
|
||||
Utils::Environment m_environment;
|
||||
|
||||
Analyzer::AnalyzerStartParameters m_params;
|
||||
QProcess *m_process;
|
||||
bool m_running;
|
||||
bool m_fetchingData;
|
||||
@@ -87,16 +79,7 @@ QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp
|
||||
: IAnalyzerEngine(sp, runConfiguration)
|
||||
, d(new QmlProfilerEnginePrivate(this))
|
||||
{
|
||||
ProjectExplorer::LocalApplicationRunConfiguration *localAppConfig =
|
||||
qobject_cast<ProjectExplorer::LocalApplicationRunConfiguration *>(runConfiguration);
|
||||
|
||||
if (!localAppConfig)
|
||||
return;
|
||||
|
||||
d->m_workingDirectory = localAppConfig->workingDirectory();
|
||||
d->m_executable = localAppConfig->executable();
|
||||
d->m_commandLineArguments = localAppConfig->commandLineArguments();
|
||||
d->m_environment = localAppConfig->environment();
|
||||
d->m_params = sp;
|
||||
d->m_process = 0;
|
||||
d->m_running = false;
|
||||
d->m_fetchingData = false;
|
||||
@@ -165,8 +148,10 @@ bool QmlProfilerEngine::QmlProfilerEnginePrivate::launchperfmonitor()
|
||||
m_process = new QProcess();
|
||||
|
||||
QStringList arguments("-qmljsdebugger=port:" + QString::number(QmlProfilerTool::port) + ",block");
|
||||
arguments.append(m_params.debuggeeArgs.split(" "));
|
||||
|
||||
if (QmlProfilerPlugin::debugOutput)
|
||||
qWarning("QmlProfiler: Launching %s", qPrintable(m_executable));
|
||||
qWarning("QmlProfiler: Launching %s", qPrintable(m_params.displayName));
|
||||
|
||||
if (qtquick1) {
|
||||
QProcessEnvironment env;
|
||||
@@ -175,16 +160,16 @@ bool QmlProfilerEngine::QmlProfilerEnginePrivate::launchperfmonitor()
|
||||
}
|
||||
|
||||
m_process->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
m_process->setWorkingDirectory(m_workingDirectory);
|
||||
m_process->setWorkingDirectory(m_params.workingDirectory);
|
||||
connect(m_process,SIGNAL(finished(int)),q,SLOT(spontaneousStop()));
|
||||
m_process->start(m_executable, arguments);
|
||||
m_process->start(m_params.debuggee, arguments);
|
||||
|
||||
// give the process time to start
|
||||
sleep(1);
|
||||
|
||||
if (!m_process->waitForStarted()) {
|
||||
if (QmlProfilerPlugin::debugOutput)
|
||||
qWarning("QmlProfiler: %s failed to start", qPrintable(m_executable));
|
||||
qWarning("QmlProfiler: %s failed to start", qPrintable(m_params.displayName));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "qmlprofilerplugin.h"
|
||||
#include "qmlprofilerconstants.h"
|
||||
#include "qmlprojectanalyzerruncontrolfactory.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
@@ -68,6 +69,7 @@ public:
|
||||
|
||||
void initialize(const QStringList &arguments, QString *errorString);
|
||||
|
||||
QmlProjectAnalyzerRunControlFactory *m_runControlFactory;
|
||||
QmlProfilerPlugin *q;
|
||||
};
|
||||
|
||||
@@ -76,7 +78,8 @@ void QmlProfilerPlugin::QmlProfilerPluginPrivate::initialize(const QStringList &
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorString)
|
||||
|
||||
// AnalyzerManager::instance()->addTool(new MemcheckTool(this));
|
||||
m_runControlFactory = new QmlProjectAnalyzerRunControlFactory();
|
||||
Analyzer::AnalyzerManager::instance()->registerRunControlFactory(m_runControlFactory);
|
||||
}
|
||||
|
||||
|
||||
|
123
src/plugins/qmlprofiler/qmlprojectanalyzerruncontrolfactory.cpp
Normal file
123
src/plugins/qmlprofiler/qmlprojectanalyzerruncontrolfactory.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** No Commercial Usage
|
||||
**
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "qmlprojectanalyzerruncontrolfactory.h"
|
||||
#include "qmlprojectmanager/qmlprojectrunconfiguration.h"
|
||||
#include <analyzerbase/analyzerstartparameters.h>
|
||||
#include <analyzerbase/analyzersettings.h>
|
||||
#include <analyzerbase/analyzerrunconfigwidget.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace Analyzer;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace QmlProfiler::Internal;
|
||||
|
||||
AnalyzerStartParameters localStartParameters(ProjectExplorer::RunConfiguration *runConfiguration)
|
||||
{
|
||||
AnalyzerStartParameters sp;
|
||||
QTC_ASSERT(runConfiguration, return sp);
|
||||
QmlProjectManager::QmlProjectRunConfiguration *rc =
|
||||
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration);
|
||||
QTC_ASSERT(rc, return sp);
|
||||
|
||||
sp.startMode = StartLocal;
|
||||
sp.environment = rc->environment();
|
||||
sp.workingDirectory = rc->workingDirectory();
|
||||
sp.debuggee = rc->observerPath();
|
||||
sp.debuggeeArgs = rc->viewerArguments();
|
||||
sp.displayName = rc->displayName();
|
||||
return sp;
|
||||
}
|
||||
|
||||
QmlProjectAnalyzerRunControlFactory::QmlProjectAnalyzerRunControlFactory(QObject *parent)
|
||||
: IRunControlFactory(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QmlProjectAnalyzerRunControlFactory::~QmlProjectAnalyzerRunControlFactory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool QmlProjectAnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
|
||||
{
|
||||
if (!qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration))
|
||||
return false;
|
||||
return mode == Constants::MODE_ANALYZE;
|
||||
}
|
||||
|
||||
RunControl *QmlProjectAnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, const QString &mode)
|
||||
{
|
||||
if (!qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration) ||
|
||||
mode != Constants::MODE_ANALYZE) {
|
||||
return 0;
|
||||
}
|
||||
const AnalyzerStartParameters sp = localStartParameters(runConfiguration);
|
||||
return create(sp, runConfiguration);
|
||||
}
|
||||
|
||||
AnalyzerRunControl *QmlProjectAnalyzerRunControlFactory::create(const Analyzer::AnalyzerStartParameters &sp, RunConfiguration *runConfiguration)
|
||||
{
|
||||
AnalyzerRunControl *rc = new AnalyzerRunControl(sp, runConfiguration);
|
||||
emit runControlCreated(rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
QString QmlProjectAnalyzerRunControlFactory::displayName() const
|
||||
{
|
||||
return tr("QmlAnalyzer");
|
||||
}
|
||||
|
||||
IRunConfigurationAspect *QmlProjectAnalyzerRunControlFactory::createRunConfigurationAspect()
|
||||
{
|
||||
return new AnalyzerProjectSettings;
|
||||
}
|
||||
|
||||
RunConfigWidget *QmlProjectAnalyzerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
|
||||
{
|
||||
QmlProjectManager::QmlProjectRunConfiguration *localRc =
|
||||
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration);
|
||||
if (!localRc)
|
||||
return 0;
|
||||
|
||||
AnalyzerProjectSettings *settings = runConfiguration->extraAspect<AnalyzerProjectSettings>();
|
||||
if (!settings)
|
||||
return 0;
|
||||
|
||||
Analyzer::AnalyzerRunConfigWidget *ret = new Analyzer::AnalyzerRunConfigWidget;
|
||||
ret->setRunConfiguration(runConfiguration);
|
||||
return ret;
|
||||
// return 0;
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** No Commercial Usage
|
||||
**
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QMLPROJECTANALYZERRUNCONTROLFACTORY_H
|
||||
#define QMLPROJECTANALYZERRUNCONTROLFACTORY_H
|
||||
|
||||
#include <analyzerbase/analyzerruncontrol.h>
|
||||
//#include <analyzerbase/analyzerruncontrolfactory.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
class QmlProjectAnalyzerRunControlFactory : public ProjectExplorer::IRunControlFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef ProjectExplorer::RunConfiguration RunConfiguration;
|
||||
|
||||
QmlProjectAnalyzerRunControlFactory(QObject *parent = 0);
|
||||
~QmlProjectAnalyzerRunControlFactory();
|
||||
|
||||
// virtuals from IRunControlFactory
|
||||
bool canRun(RunConfiguration *runConfiguration, const QString &mode) const;
|
||||
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, const QString &mode);
|
||||
Analyzer::AnalyzerRunControl *create(const Analyzer::AnalyzerStartParameters &sp, RunConfiguration *runConfiguration = 0);
|
||||
QString displayName() const;
|
||||
|
||||
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect();
|
||||
ProjectExplorer::RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
|
||||
|
||||
signals:
|
||||
void runControlCreated(Analyzer::AnalyzerRunControl *);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // QMLPROJECTANALYZERRUNCONTROLFACTORY_H
|
@@ -152,6 +152,8 @@ bool QmlRunControlFactory::canRun(RunConfiguration *runConfiguration,
|
||||
qobject_cast<QmlProjectRunConfiguration*>(runConfiguration);
|
||||
if (mode == ProjectExplorer::Constants::RUNMODE)
|
||||
return config != 0 && !config->viewerPath().isEmpty();
|
||||
else if (mode != Debugger::Constants::DEBUGMODE)
|
||||
return false;
|
||||
|
||||
bool qmlDebugSupportInstalled =
|
||||
Debugger::DebuggerPlugin::isActiveDebugLanguage(Debugger::QmlLanguage);
|
||||
|
Reference in New Issue
Block a user