[Qt-interest] QScriptEngineDebugger crash

Dave Ceddia dceddia at gmail.com
Wed Oct 21 17:16:39 CEST 2009


I've noticed a crash when using QScriptEngineDebugger. Maybe the way I'm
using it is odd, but I have a checkbox in my GUI that enables or disables
the debugger, and when running a script, a new debugger will be allocated
and attached to the script engine. When the script has completed, the
debugger will be detached and destroyed. This way, the state of the checkbox
does not directly affect the existence of a debugger object.

What I'm noticing is that if I create a debugger, attach it, run the script,
and detach it, the debugger will replace the engine's print() function with
its own trace function, and the engine's print() function will never return
to its normal state (see QScriptDebuggerBackend::attachTo and
QScriptDebuggerBackend::detach in Qt's
src/scripttools/debugging/qscriptdebuggerbackend.cpp). Because of this, if I
then run a script without a debugger attached, the program will segfault
when I try to print() from a script.

My workaround right now is to save the engine's print function right after I
create the engine:
     QScriptValue oldPrintFunction =
engine->globalObject().property("print");
Then, when I detach and delete the debugger, I set the engine's print
function back to normal:
     engine->globalObject().setProperty("print", oldPrintFunction);

This seems to work fine so far, but it seems more like a bug than expected
behavior...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091021/d7f5b9b4/attachment.html 


More information about the Qt-interest-old mailing list