QmlProfiler: Enable on Windows

Replace use of sleep() call with a timer.
This commit is contained in:
Kai Koehne
2011-04-12 17:24:56 +02:00
parent 233f65da57
commit e6620167fc
5 changed files with 37 additions and 15 deletions

View File

@@ -64,7 +64,7 @@ contains(QT_CONFIG, declarative) {
minQtVersion(4, 7, 1) { minQtVersion(4, 7, 1) {
SUBDIRS += plugin_qmldesigner SUBDIRS += plugin_qmldesigner
!win32:SUBDIRS += plugin_qmlprofiler SUBDIRS += plugin_qmlprofiler
} else { } else {
warning() warning()
warning("QmlDesigner plugin has been disabled.") warning("QmlDesigner plugin has been disabled.")
@@ -269,13 +269,13 @@ plugin_analyzerbase.depends += plugin_projectexplorer
plugin_callgrind.depends = plugin_coreplugin plugin_callgrind.depends = plugin_coreplugin
plugin_callgrind.depends += plugin_analyzerbase plugin_callgrind.depends += plugin_analyzerbase
plugin_callgrind.depends += plugin_valgrindtoolbase plugin_callgrind.depends += plugin_valgrindtoolbase
plugin_qmlprofiler.subdir = qmlprofiler
plugin_qmlprofiler.depends = plugin_coreplugin
plugin_qmlprofiler.depends += plugin_analyzerbase
plugin_qmlprofiler.depends += plugin_qmlprojectmanager
} }
plugin_qmlprofiler.subdir = qmlprofiler
plugin_qmlprofiler.depends = plugin_coreplugin
plugin_qmlprofiler.depends += plugin_analyzerbase
plugin_qmlprofiler.depends += plugin_qmlprojectmanager
plugin_qmljstools.subdir = qmljstools plugin_qmljstools.subdir = qmljstools
plugin_qmljstools.depends = plugin_projectexplorer plugin_qmljstools.depends = plugin_projectexplorer
plugin_qmljstools.depends += plugin_coreplugin plugin_qmljstools.depends += plugin_coreplugin

View File

@@ -8,11 +8,9 @@ include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/analyzerbase/analyzerbase.pri) include(../../plugins/analyzerbase/analyzerbase.pri)
include(../../plugins/qmlprojectmanager/qmlprojectmanager.pri) include(../../plugins/qmlprojectmanager/qmlprojectmanager.pri)
QT += network script declarative QT += network script declarative
include(canvas/canvas.pri) include(canvas/canvas.pri)
#include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri)
SOURCES += \ SOURCES += \
qmlprofilerplugin.cpp \ qmlprofilerplugin.cpp \

View File

@@ -52,9 +52,6 @@
#include <QProcess> #include <QProcess>
#ifdef Q_OS_UNIX
#include <unistd.h> // sleep
#endif
using namespace QmlProfiler::Internal; using namespace QmlProfiler::Internal;
@@ -176,9 +173,6 @@ bool QmlProfilerEngine::QmlProfilerEnginePrivate::launchperfmonitor()
connect(m_process,SIGNAL(finished(int)),q,SLOT(spontaneousStop())); connect(m_process,SIGNAL(finished(int)),q,SLOT(spontaneousStop()));
m_process->start(m_params.debuggee, arguments); m_process->start(m_params.debuggee, arguments);
// give the process time to start
sleep(1);
if (!m_process->waitForStarted()) { if (!m_process->waitForStarted()) {
if (QmlProfilerPlugin::debugOutput) if (QmlProfilerPlugin::debugOutput)
qWarning("QmlProfiler: %s failed to start", qPrintable(m_params.displayName)); qWarning("QmlProfiler: %s failed to start", qPrintable(m_params.displayName));

View File

@@ -109,6 +109,8 @@ public:
QmlProfilerTool *q; QmlProfilerTool *q;
QDeclarativeDebugConnection *m_client; QDeclarativeDebugConnection *m_client;
QTimer m_connectionTimer;
int m_connectionAttempts;
TraceWindow *m_traceWindow; TraceWindow *m_traceWindow;
QTabWidget *m_tabbed; QTabWidget *m_tabbed;
QmlProfilerSummaryView *m_summary; QmlProfilerSummaryView *m_summary;
@@ -128,6 +130,7 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this)) : IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this))
{ {
d->m_client = 0; d->m_client = 0;
d->m_connectionAttempts = 0;
d->m_traceWindow = 0; d->m_traceWindow = 0;
d->m_outputPaneAdapter = 0; d->m_outputPaneAdapter = 0;
d->m_project = 0; d->m_project = 0;
@@ -135,6 +138,9 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
d->m_isAttached = false; d->m_isAttached = false;
d->m_attachAction = 0; d->m_attachAction = 0;
d->m_recordingEnabled = true; d->m_recordingEnabled = true;
d->m_connectionTimer.setInterval(200);
connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect()));
} }
QmlProfilerTool::~QmlProfilerTool() QmlProfilerTool::~QmlProfilerTool()
@@ -190,7 +196,7 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
return engine; return engine;
} }
void QmlProfilerTool::initialize(ExtensionSystem::IPlugin */*plugin*/) void QmlProfilerTool::initialize(ExtensionSystem::IPlugin * /*plugin*/)
{ {
qmlRegisterType<Canvas>("Monitor", 1, 0, "Canvas"); qmlRegisterType<Canvas>("Monitor", 1, 0, "Canvas");
qmlRegisterType<TiledCanvas>("Monitor", 1, 0, "TiledCanvas"); qmlRegisterType<TiledCanvas>("Monitor", 1, 0, "TiledCanvas");
@@ -286,6 +292,11 @@ QWidget *QmlProfilerTool::createTimeLineWidget()
} }
void QmlProfilerTool::connectClient() void QmlProfilerTool::connectClient()
{
d->m_connectionTimer.start();
}
void QmlProfilerTool::connectToClient()
{ {
QDeclarativeDebugConnection *newClient = new QDeclarativeDebugConnection; QDeclarativeDebugConnection *newClient = new QDeclarativeDebugConnection;
d->m_traceWindow->reset(newClient); d->m_traceWindow->reset(newClient);
@@ -419,3 +430,19 @@ void QmlProfilerTool::updateAttachAction()
d->m_attachAction->setEnabled(Analyzer::AnalyzerManager::instance()->currentTool() == this); d->m_attachAction->setEnabled(Analyzer::AnalyzerManager::instance()->currentTool() == this);
} }
void QmlProfilerTool::tryToConnect()
{
++d->m_connectionAttempts;
if (d->m_client->isConnected()) {
d->m_connectionTimer.stop();
d->m_connectionAttempts = 0;
} else if (d->m_connectionAttempts == 50) {
d->m_connectionTimer.stop();
d->m_connectionAttempts = 0;
// TODO: Warn user that connection failed
//emit connectionStartupFailed();
} else {
connectToClient();
}
}

View File

@@ -85,8 +85,11 @@ private slots:
void updateProjectFileList(); void updateProjectFileList();
void attach(); void attach();
void updateAttachAction(); void updateAttachAction();
void tryToConnect();
private: private:
void connectToClient();
class QmlProfilerToolPrivate; class QmlProfilerToolPrivate;
QmlProfilerToolPrivate *d; QmlProfilerToolPrivate *d;
}; };