forked from qt-creator/qt-creator
QmlProfiler: Enable on Windows
Replace use of sleep() call with a timer.
This commit is contained in:
@@ -64,7 +64,7 @@ contains(QT_CONFIG, declarative) {
|
||||
|
||||
minQtVersion(4, 7, 1) {
|
||||
SUBDIRS += plugin_qmldesigner
|
||||
!win32:SUBDIRS += plugin_qmlprofiler
|
||||
SUBDIRS += plugin_qmlprofiler
|
||||
} else {
|
||||
warning()
|
||||
warning("QmlDesigner plugin has been disabled.")
|
||||
@@ -269,12 +269,12 @@ plugin_analyzerbase.depends += plugin_projectexplorer
|
||||
plugin_callgrind.depends = plugin_coreplugin
|
||||
plugin_callgrind.depends += plugin_analyzerbase
|
||||
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_qmljstools.subdir = qmljstools
|
||||
plugin_qmljstools.depends = plugin_projectexplorer
|
||||
|
@@ -8,11 +8,9 @@ include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(../../plugins/analyzerbase/analyzerbase.pri)
|
||||
include(../../plugins/qmlprojectmanager/qmlprojectmanager.pri)
|
||||
|
||||
|
||||
QT += network script declarative
|
||||
|
||||
include(canvas/canvas.pri)
|
||||
#include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri)
|
||||
|
||||
SOURCES += \
|
||||
qmlprofilerplugin.cpp \
|
||||
|
@@ -52,9 +52,6 @@
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
#include <unistd.h> // sleep
|
||||
#endif
|
||||
|
||||
using namespace QmlProfiler::Internal;
|
||||
|
||||
@@ -176,9 +173,6 @@ bool QmlProfilerEngine::QmlProfilerEnginePrivate::launchperfmonitor()
|
||||
connect(m_process,SIGNAL(finished(int)),q,SLOT(spontaneousStop()));
|
||||
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_params.displayName));
|
||||
|
@@ -109,6 +109,8 @@ public:
|
||||
QmlProfilerTool *q;
|
||||
|
||||
QDeclarativeDebugConnection *m_client;
|
||||
QTimer m_connectionTimer;
|
||||
int m_connectionAttempts;
|
||||
TraceWindow *m_traceWindow;
|
||||
QTabWidget *m_tabbed;
|
||||
QmlProfilerSummaryView *m_summary;
|
||||
@@ -128,6 +130,7 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this))
|
||||
{
|
||||
d->m_client = 0;
|
||||
d->m_connectionAttempts = 0;
|
||||
d->m_traceWindow = 0;
|
||||
d->m_outputPaneAdapter = 0;
|
||||
d->m_project = 0;
|
||||
@@ -135,6 +138,9 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
d->m_isAttached = false;
|
||||
d->m_attachAction = 0;
|
||||
d->m_recordingEnabled = true;
|
||||
|
||||
d->m_connectionTimer.setInterval(200);
|
||||
connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect()));
|
||||
}
|
||||
|
||||
QmlProfilerTool::~QmlProfilerTool()
|
||||
@@ -286,6 +292,11 @@ QWidget *QmlProfilerTool::createTimeLineWidget()
|
||||
}
|
||||
|
||||
void QmlProfilerTool::connectClient()
|
||||
{
|
||||
d->m_connectionTimer.start();
|
||||
}
|
||||
|
||||
void QmlProfilerTool::connectToClient()
|
||||
{
|
||||
QDeclarativeDebugConnection *newClient = new QDeclarativeDebugConnection;
|
||||
d->m_traceWindow->reset(newClient);
|
||||
@@ -419,3 +430,19 @@ void QmlProfilerTool::updateAttachAction()
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@@ -85,8 +85,11 @@ private slots:
|
||||
void updateProjectFileList();
|
||||
void attach();
|
||||
void updateAttachAction();
|
||||
void tryToConnect();
|
||||
|
||||
private:
|
||||
void connectToClient();
|
||||
|
||||
class QmlProfilerToolPrivate;
|
||||
QmlProfilerToolPrivate *d;
|
||||
};
|
||||
|
Reference in New Issue
Block a user