diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 1e41f08c0bc1d81f83ac0f02b37bcc3cfcb358b9..884ca96b600f402ad4f6a12dbe8dc39db5b022a9 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -59,6 +59,7 @@ #include <QtGui/QMainWindow> #include <QtGui/QMessageBox> #include <QtGui/QToolTip> +#include <QtGui/QTextDocument> #include <QtNetwork/QTcpSocket> #include <QtNetwork/QHostAddress> @@ -75,6 +76,7 @@ # define XSDEBUG(s) qDebug() << s + namespace Debugger { namespace Internal { @@ -656,6 +658,16 @@ void QmlEngine::messageReceived(const QByteArray &message) Debugger::DebuggerUISwitcher *uiSwitcher = Debugger::DebuggerUISwitcher::instance(); uiSwitcher->setActiveLanguage("C++"); + bool becauseOfexception; + stream >> becauseOfexception; + if (becauseOfexception) { + QString error; + stream >> error; + + QString msg = tr("<p>An Uncaught Exception occured in <i>%1</i>:</p><p>%2</p>").arg(stackFrames.value(0).file, Qt::escape(error)); + showMessageBox(QMessageBox::Information, tr("Uncaught Exception"), msg); + } + } else if (command == "RESULT") { WatchData data; diff --git a/src/tools/qml/qmlobserver/jsdebuggeragent.cpp b/src/tools/qml/qmlobserver/jsdebuggeragent.cpp index e6007676e990f1b1be57fec4eb8d15c166fe957c..8681624a0571f1b6acb0d670fc272aeddda42ad5 100644 --- a/src/tools/qml/qmlobserver/jsdebuggeragent.cpp +++ b/src/tools/qml/qmlobserver/jsdebuggeragent.cpp @@ -303,9 +303,9 @@ void JSDebuggerAgent::exceptionThrow(qint64 scriptId, bool hasHandler) { Q_UNUSED(scriptId); - Q_UNUSED(exception); - Q_UNUSED(hasHandler); -/* ... */ +// qDebug() << Q_FUNC_INFO << exception.toString() << hasHandler; + if (!hasHandler && state != Stopped) + stopped(true, exception); } /*! @@ -427,7 +427,7 @@ void JSDebuggerAgent::messageReceived(const QByteArray& message) QDeclarativeDebugService::messageReceived(message); } -void JSDebuggerAgent::stopped() +void JSDebuggerAgent::stopped(bool becauseOfException, const QScriptValue& exception) { knownObjectIds.clear(); state = Stopped; @@ -464,12 +464,14 @@ void JSDebuggerAgent::stopped() QList<JSAgentWatchData> locals = getLocals(engine()->currentContext()); - // Clear any exceptions occurred during locals evaluation. - engine()->clearExceptions(); + if (!becauseOfException) { + // Clear any exceptions occurred during locals evaluation. + engine()->clearExceptions(); + } QByteArray reply; QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("STOPPED") << backtrace << watches << locals; + rs << QByteArray("STOPPED") << backtrace << watches << locals << becauseOfException << exception.toString(); sendMessage(reply); loop.exec(QEventLoop::ExcludeUserInputEvents); diff --git a/src/tools/qml/qmlobserver/jsdebuggeragent.h b/src/tools/qml/qmlobserver/jsdebuggeragent.h index 93d4b75095c0d51004ca22adf2821601fb6a6f94..acd7b18c92f793e6013b52bd6c46090eae522560 100644 --- a/src/tools/qml/qmlobserver/jsdebuggeragent.h +++ b/src/tools/qml/qmlobserver/jsdebuggeragent.h @@ -54,6 +54,7 @@ // #include <QtScript/qscriptengineagent.h> +#include <QtScript/QScriptValue> #include <QtCore/QEventLoop> #include <QtCore/QSet> #include <private/qdeclarativedebugservice_p.h> @@ -118,7 +119,7 @@ private: int stepCount; void continueExec(); - void stopped(); + void stopped(bool becauseOfException = false, const QScriptValue &exception = QScriptValue()); void recordKnownObjects(const QList<JSAgentWatchData> &);