I have been unable to find the bug. In the start, it worked for me, then
it suddenly started breaking at various unrelated places, then it
worked, then it started failing again. I have added a tracing option to
Lqt, and it seems that this problem is caused by the use of multiple
threads by Qt.
Lua is not ready to work with multiple threads accessing the same Lua
state. Unfortunately, the log shows that multiple thread are accessing
the same QApplication object (therefore accessing the same state),
leaving the possibility that they will crash the application.
I am trying various locking strategies, like locking the lqtL_* API and
objects using QMutex, but so far no luck. The only possibility seems to
be a GIL [1], but you have to modify Lua for that (it provides
lua_lock() and lua_unlock() macros). But this will mean that it will not
work with stock Lua if you use multiple threads (or use something that
uses multiple threads).
[1] http://en.wikipedia.org/wiki/Global_Interpreter_Lock
QFileSystemModel *works* for me right now, I can browse my computer on
Mac OSX, and it does not seem to use multiple threads from the logs.
However, I am getting this error for every program ran in Lqt:
lua(27567,0x7fff76dbe960) malloc: *** error for object 0x104cac380:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
I have no idea where this "bogus" object is coming from, since there
is only a single thread running, and it works fine during the run. I
suspect this is a problem of "double free". Unfortunately I am unable
to run a test in Valgrind, due to this:
vex amd64->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0xDF 0xD1
0x1 0xE8 0x6A
==27572== valgrind: Unrecognised instruction at address 0xb4c0b.
==27572== at 0xB4C0B: aes_encrypt_key_hw (in
/usr/lib/system/libcommonCrypto.dylib)
==27572== by 0xB29E0: aesedp_setup (in /usr/lib/system/libcommonCrypto.dylib)
==27572== by 0xACBE3: cbc_start (in /usr/lib/system/libcommonCrypto.dylib)
==27572== by 0xAF5BB: CCCryptorCreateFromDataWithMode (in
/usr/lib/system/libcommonCrypto.dylib)
==27572== by 0xAF78D: CCCryptorCreateFromData (in
/usr/lib/system/libcommonCrypto.dylib)
==27572== by 0xAEDFC: CCCryptorCreate (in
/usr/lib/system/libcommonCrypto.dylib)
==27572== by 0xAFDC6: CCCrypt (in /usr/lib/system/libcommonCrypto.dylib)
==27572== by 0x4276463: -[NSPersistentUIManager init] (in
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
==27572== by 0x4276350: __PersistentUIManager_block_invoke_1 (in
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
==27572== by 0x596736A: _NSFaultInObject (in
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation)
==27572== by 0x42B607E: -[NSWindow(NSPersistentUISupport)
_invalidateRestorableStateOfContents] (in
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
==27572== by 0x43C6066: -[NSWindow
_commonInitFrame:styleMask:backing:defer:] (in
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
==27572== by 0x43C553A: -[NSWindow
_initContent:styleMask:backing:defer:contentView:] (in
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
==27572== by 0x43C4F0A: -[NSWindow
initWithContentRect:styleMask:backing:defer:] (in
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit)
==27572== by 0x2A82175: -[QCocoaWindow
initWithContentRect:styleMask:backing:defer:] (in
/Library/Frameworks/QtGui.framework/Versions/4/QtGui)
==27572== by 0x2A82036: -[NSWindow(QWidgetIntegration)
qt_initWithQWidget:contentRect:styleMask:] (in
/Library/Frameworks/QtGui.framework/Versions/4/QtGui)
==27572== by 0x2A74088: qt_mac_create_window(QWidget*, unsigned
int, unsigned long, QRect const&) (in
/Library/Frameworks/QtGui.framework/Versions/4/QtGui)
==27572== by 0x2A73CB7: QWidgetPrivate::createWindow_sys() (in
/Library/Frameworks/QtGui.framework/Versions/4/QtGui)
==27572== by 0x2A7313E: qt_mac_window_for(QWidget const*) (in
/Library/Frameworks/QtGui.framework/Versions/4/QtGui)
==27572== by 0x2A79427: QWidgetPrivate::setModal_sys() (in
/Library/Frameworks/QtGui.framework/Versions/4/QtGui)
==27572== by 0x2B1F9BD: QWidget::create(long, bool, bool) (in
/Library/Frameworks/QtGui.framework/Versions/4/QtGui)
==27572== by 0x2B24695: QWidget::setVisible(bool) (in
/Library/Frameworks/QtGui.framework/Versions/4/QtGui)
It seems Lqt won't make it to upcoming Qt 5.0 if issues keep coming up... :(