From 1f184bf2adb72d32d79fa8c710863e2a95b979ca Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 9 Jun 2011 14:30:15 +0200 Subject: [PATCH] QmlProfiler: Track status of app through application output We do that already in the debugger too. Change-Id: I31828a01aaec041ac38102b9bd034728d02486e2 Reviewed-on: http://codereview.qt.nokia.com/427 Reviewed-by: Kai Koehne --- src/plugins/qmlprofiler/qmlprofilerengine.cpp | 60 +++++++++++++++++++ src/plugins/qmlprofiler/qmlprofilerengine.h | 1 + 2 files changed, 61 insertions(+) diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.cpp b/src/plugins/qmlprofiler/qmlprofilerengine.cpp index 693e21fefea..aa631a7df1f 100644 --- a/src/plugins/qmlprofiler/qmlprofilerengine.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerengine.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -49,6 +50,8 @@ #include "tracewindow.h" #include +#include +#include #include "canvas/qdeclarativecanvas_p.h" #include "canvas/qdeclarativecontext2d_p.h" @@ -180,9 +183,66 @@ void QmlProfilerEngine::finishProcess() } } +void QmlProfilerEngine::filterApplicationMessage(const QString &msg) +{ + static const QString qddserver = QLatin1String("QDeclarativeDebugServer: "); + static const QString cannotRetrieveDebuggingOutput = ProjectExplorer::ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput(); + + const int index = msg.indexOf(qddserver); + if (index != -1) { + QString status = msg; + status.remove(0, index + qddserver.length()); // chop of 'QDeclarativeDebugServer: ' + + static QString waitingForConnection = QLatin1String("Waiting for connection "); + static QString unableToListen = QLatin1String("Unable to listen "); + static QString debuggingNotEnabled = QLatin1String("Ignoring \"-qmljsdebugger="); + static QString debuggingNotEnabled2 = QLatin1String("Ignoring\"-qmljsdebugger="); // There is (was?) a bug in one of the error strings - safest to handle both + static QString connectionEstablished = QLatin1String("Connection established"); + + QString errorMessage; + if (status.startsWith(waitingForConnection)) { + emit processRunning(); + } else if (status.startsWith(unableToListen)) { + //: Error message shown after 'Could not connect ... debugger:" + errorMessage = tr("The port seems to be in use."); + } else if (status.startsWith(debuggingNotEnabled) || status.startsWith(debuggingNotEnabled2)) { + //: Error message shown after 'Could not connect ... debugger:" + errorMessage = tr("The application is not set up for QML/JS debugging."); + } else if (status.startsWith(connectionEstablished)) { + // nothing to do + } else { + qWarning() << "Unknown QDeclarativeDebugServer status message: " << status; + } + + if (!errorMessage.isEmpty()) { + Core::ICore * const core = Core::ICore::instance(); + QMessageBox *infoBox = new QMessageBox(core->mainWindow()); + infoBox->setIcon(QMessageBox::Critical); + infoBox->setWindowTitle(tr("Qt Creator")); + //: %1 is detailed error message + infoBox->setText(tr("Could not connect to the in-process QML debugger:\n%1") + .arg(errorMessage)); + infoBox->setStandardButtons(QMessageBox::Ok | QMessageBox::Help); + infoBox->setDefaultButton(QMessageBox::Ok); + infoBox->setModal(true); + + connect(infoBox, SIGNAL(finished(int)), + this, SLOT(wrongSetupMessageBoxFinished(int))); + + infoBox->show(); + } + } else if (msg.contains(cannotRetrieveDebuggingOutput)) { + // we won't get debugging output, so just try to connect ... + emit processRunning(); + } +} + + void QmlProfilerEngine::logApplicationMessage(const QString &msg, Utils::OutputFormat /*format*/) { qDebug() << "app: " << msg; + + filterApplicationMessage(msg); } } // namespace Internal diff --git a/src/plugins/qmlprofiler/qmlprofilerengine.h b/src/plugins/qmlprofiler/qmlprofilerengine.h index 0ef61947bb9..88586d1cce0 100644 --- a/src/plugins/qmlprofiler/qmlprofilerengine.h +++ b/src/plugins/qmlprofiler/qmlprofilerengine.h @@ -63,6 +63,7 @@ private slots: void dataReceived(); void finishProcess(); void logApplicationMessage(const QString &msg, Utils::OutputFormat format); + void filterApplicationMessage(const QString &msg); private: class QmlProfilerEnginePrivate;