diff options
-rw-r--r-- | src/scripttools/debugging/qscriptdebuggerbackend.cpp | 30 | ||||
-rw-r--r-- | tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp | 8 |
2 files changed, 23 insertions, 15 deletions
diff --git a/src/scripttools/debugging/qscriptdebuggerbackend.cpp b/src/scripttools/debugging/qscriptdebuggerbackend.cpp index 9eaf571..da9d50e 100644 --- a/src/scripttools/debugging/qscriptdebuggerbackend.cpp +++ b/src/scripttools/debugging/qscriptdebuggerbackend.cpp @@ -433,21 +433,21 @@ void QScriptDebuggerBackend::attachTo(QScriptEngine *engine) void QScriptDebuggerBackend::detach() { Q_D(QScriptDebuggerBackend); - if (!d->agent) - return; - QScriptEngine *eng = d->agent->engine(); - 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("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()); - d->agent->nullifyBackendPointer(); - d->agent = 0; // agent is owned by engine + if (d->agent) { + QScriptEngine *eng = d->agent->engine(); + 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("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()); + d->agent->nullifyBackendPointer(); + d->agent = 0; // agent is owned by engine + } } d->pendingEvaluateLineNumber = -1; diff --git a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp index 7f3f9f3..5e5b701 100644 --- a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp +++ b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp @@ -163,6 +163,14 @@ void tst_QScriptEngineDebugger::attachAndDetach() debugger2.attachTo(&engine); } #endif + { + QScriptEngine *engine = new QScriptEngine; + QScriptEngineDebugger debugger; + debugger.attachTo(engine); + delete engine; + QScriptEngine engine2; + debugger.attachTo(&engine2); + } } void tst_QScriptEngineDebugger::action() |