[Qt-interest] QScriptEngineDebugger crash
Kent Hansen
khansen at trolltech.com
Thu Oct 22 15:22:51 CEST 2009
Hi Dave,
Dave Ceddia skrev:
> 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...
I believe this is fixed with
http://qt.gitorious.org/qt/qt/merge_requests/554. The change will be in 4.6.
Regards,
Kent
More information about the Qt-interest-old
mailing list