diff options
author | Joel Nordell <joel.nordell@chloridepower.com> | 2009-06-17 13:26:41 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-06-17 13:44:46 (GMT) |
commit | 5af2e06cb543bd27450c29a1fca8686413f1cceb (patch) | |
tree | cb0a085c640d30813f58b3e43acfdf81396ac0f7 /src | |
parent | 30d6ac5feeb43b32eccc72595fe9a2c89d0f5c1e (diff) | |
download | Qt-5af2e06cb543bd27450c29a1fca8686413f1cceb.zip Qt-5af2e06cb543bd27450c29a1fca8686413f1cceb.tar.gz Qt-5af2e06cb543bd27450c29a1fca8686413f1cceb.tar.bz2 |
fix crash when detach()ing a debugger and then evaluating script print() function
Merge-request: 554
Reviewed-by: Kent Hansen <khansen@trolltech.com>
Diffstat (limited to 'src')
-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 |