diff options
-rw-r--r-- | src/scripttools/debugging/qscriptdebuggerbackend.cpp | 15 | ||||
-rw-r--r-- | src/scripttools/debugging/qscriptdebuggerbackend_p_p.h | 6 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/scripttools/debugging/qscriptdebuggerbackend.cpp b/src/scripttools/debugging/qscriptdebuggerbackend.cpp index da9d50e..c7577d6 100644 --- a/src/scripttools/debugging/qscriptdebuggerbackend.cpp +++ b/src/scripttools/debugging/qscriptdebuggerbackend.cpp @@ -412,11 +412,14 @@ void QScriptDebuggerBackend::attachTo(QScriptEngine *engine) detach(); d->agent = new QScriptDebuggerAgent(d, engine); QScriptValue global = engine->globalObject(); + d->origTraceFunction = global.property(QString::fromLatin1("print")); global.setProperty(QString::fromLatin1("print"), traceFunction()); // global.setProperty(QString::fromLatin1("qAssert"), assertFunction()); + d->origFileNameFunction = global.property(QString::fromLatin1("__FILE__")); global.setProperty(QString::fromLatin1("__FILE__"), fileNameFunction(), QScriptValue::PropertyGetter | QScriptValue::PropertySetter | QScriptValue::ReadOnly); + d->origLineNumberFunction = global.property(QString::fromLatin1("__LINE__")); global.setProperty(QString::fromLatin1("__LINE__"), lineNumberFunction(), QScriptValue::PropertyGetter | QScriptValue::PropertySetter | QScriptValue::ReadOnly); @@ -438,13 +441,13 @@ void QScriptDebuggerBackend::detach() if (eng && eng->agent() == d->agent) { eng->setAgent(0); QScriptValue global = eng->globalObject(); - if (global.property(QString::fromLatin1("print")).strictlyEquals(traceFunction())) - global.setProperty(QString::fromLatin1("print"), QScriptValue()); + global.setProperty(QString::fromLatin1("print"), d->origTraceFunction); + d->origTraceFunction = QScriptValue(); // global.setProperty(QString::fromLatin1("qAssert"), QScriptValue()); - if (global.property(QString::fromLatin1("__FILE__")).strictlyEquals(fileNameFunction())) - global.setProperty(QString::fromLatin1("__FILE__"), QScriptValue()); - if (global.property(QString::fromLatin1("__LINE__")).strictlyEquals(lineNumberFunction())) - global.setProperty(QString::fromLatin1("__LINE__"), QScriptValue()); + global.setProperty(QString::fromLatin1("__FILE__"), d->origFileNameFunction); + d->origFileNameFunction = QScriptValue(); + global.setProperty(QString::fromLatin1("__LINE__"), d->origLineNumberFunction); + d->origLineNumberFunction = QScriptValue(); d->agent->nullifyBackendPointer(); d->agent = 0; // agent is owned by engine } diff --git a/src/scripttools/debugging/qscriptdebuggerbackend_p_p.h b/src/scripttools/debugging/qscriptdebuggerbackend_p_p.h index de18304..a356762 100644 --- a/src/scripttools/debugging/qscriptdebuggerbackend_p_p.h +++ b/src/scripttools/debugging/qscriptdebuggerbackend_p_p.h @@ -57,6 +57,7 @@ #include <QtCore/qhash.h> #include <QtCore/qlist.h> +#include <QtScript/qscriptvalue.h> #include "qscriptdebuggerbackend_p.h" @@ -66,7 +67,6 @@ class QEvent; class QString; class QScriptContext; class QScriptEngine; -class QScriptValue; class QScriptValueIterator; class QScriptObjectSnapshot; class QScriptDebuggerAgent; @@ -126,6 +126,10 @@ public: QObject *eventReceiver; QScriptDebuggerBackend *q_ptr; + + QScriptValue origTraceFunction; + QScriptValue origFileNameFunction; + QScriptValue origLineNumberFunction; }; QT_END_NAMESPACE |