diff options
Diffstat (limited to 'src/plugins/debugger/qml/qmlengine.cpp')
-rw-r--r-- | src/plugins/debugger/qml/qmlengine.cpp | 113 |
1 files changed, 47 insertions, 66 deletions
diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index cafd726c77..826e4c81c5 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -52,6 +52,7 @@ #include <extensionsystem/pluginmanager.h> #include <projectexplorer/applicationlauncher.h> +#include <qmljsdebugclient/qdeclarativeoutputparser.h> #include <utils/environment.h> #include <utils/qtcassert.h> @@ -100,6 +101,7 @@ private: ApplicationLauncher m_applicationLauncher; Utils::FileInProjectFinder fileFinder; QTimer m_noDebugOutputTimer; + QmlJsDebugClient::QDeclarativeOutputParser m_outputParser; }; QmlEnginePrivate::QmlEnginePrivate(QmlEngine *q) @@ -144,6 +146,14 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters, &d->m_noDebugOutputTimer, SLOT(start())); + d->m_outputParser.setNoOutputText(ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput()); + connect(&d->m_outputParser, SIGNAL(waitingForConnectionMessage()), + this, SLOT(beginConnection())); + connect(&d->m_outputParser, SIGNAL(noOutputMessage()), + this, SLOT(beginConnection())); + connect(&d->m_outputParser, SIGNAL(errorMessage(QString)), + this, SLOT(wrongSetupMessageBox(QString))); + // Only wait 8 seconds for the 'Waiting for connection' on application ouput, then just try to connect // (application output might be redirected / blocked) d->m_noDebugOutputTimer.setSingleShot(true); @@ -258,6 +268,28 @@ void QmlEngine::retryMessageBoxFinished(int result) } } +void QmlEngine::wrongSetupMessageBox(const QString &errorMessage) +{ + d->m_noDebugOutputTimer.stop(); + notifyEngineRunFailed(); + + 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(); +} + void QmlEngine::connectionError(QAbstractSocket::SocketError socketError) { if (socketError == QAbstractSocket::RemoteHostClosedError) @@ -280,63 +312,9 @@ bool QmlEngine::canDisplayTooltip() const return state() == InferiorRunOk || state() == InferiorStopOk; } -void QmlEngine::filterApplicationMessage(const QString &msg, int /*channel*/) +void QmlEngine::filterApplicationMessage(const QString &output, int /*channel*/) { - static const QString qddserver = QLatin1String("QDeclarativeDebugServer: "); - static const QString cannotRetrieveDebuggingOutput = ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput(); - - const int index = msg.indexOf(qddserver); - if (index != -1) { - // we're actually getting debug output - d->m_noDebugOutputTimer.stop(); - - 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)) { - beginConnection(); - } 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()) { - notifyEngineRunFailed(); - - 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 ... - beginConnection(); - } + d->m_outputParser.processOutput(output); } void QmlEngine::showMessage(const QString &msg, int channel, int timeout) const @@ -638,10 +616,10 @@ void QmlEngine::attemptBreakpointSynchronization() DebuggerEngine::attemptBreakpointSynchronization(); if (d->m_adapter.activeDebuggerClient()) { - d->m_adapter.activeDebuggerClient()->updateBreakpoints(); + d->m_adapter.activeDebuggerClient()->synchronizeBreakpoints(); } else { foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) { - client->updateBreakpoints(); + client->synchronizeBreakpoints(); } } } @@ -689,7 +667,7 @@ void QmlEngine::requestModuleSymbols(const QString &moduleName) bool QmlEngine::setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, const DebuggerToolTipContext &ctx) { - // This is processed by QML inspector, which has dependencies to + // This is processed by QML inspector, which has dependencies to // the qml js editor. Makes life easier. emit tooltipRequested(mousePos, editor, ctx.position); return true; @@ -724,7 +702,7 @@ void QmlEngine::updateWatchData(const WatchData &data, if (data.isValueNeeded()) { logMessage(LogSend, QString("%1 %2 %3").arg(QString("EXEC"), QString(data.iname), QString(data.name))); - d->m_adapter.activeDebuggerClient()->updateWatchData(&data); + d->m_adapter.activeDebuggerClient()->updateWatchData(data); } if (data.isChildrenNeeded() && watchHandler()->isExpandedIName(data.iname)) { @@ -768,12 +746,10 @@ unsigned QmlEngine::debuggerCapabilities() const QString QmlEngine::toFileInProject(const QUrl &fileUrl) { - if (startParameters().startMode != AttachToQmlPort) { - if (d->fileFinder.projectDirectory().isEmpty()) { - d->fileFinder.setProjectDirectory(startParameters().projectSourceDirectory); - d->fileFinder.setProjectFiles(startParameters().projectSourceFiles); - } - } + // make sure file finder is properly initialized + d->fileFinder.setProjectDirectory(startParameters().projectSourceDirectory); + d->fileFinder.setProjectFiles(startParameters().projectSourceFiles); + d->fileFinder.setSysroot(startParameters().sysroot); return d->fileFinder.findFile(fileUrl); } @@ -826,6 +802,11 @@ void QmlEngine::logMessage(LogDirection direction, const QString &message) showMessage(msg, LogDebug); } +QmlAdapter *QmlEngine::adapter() const +{ + return &d->m_adapter; +} + QmlEngine *createQmlEngine(const DebuggerStartParameters &sp, DebuggerEngine *masterEngine) { |