2012-03-21 64 views
1

我有一些Lua的绑定Qt的是找工作在Mac OS X(QT 4.8.0),但坠毁在Ubuntu Linux(QT 4.7.4)。 Qt的代码加载有dlopen的,然后执行被传递与APP-> exec来QT()。如何在作为共享库加载时正确关闭Qt?

Lua代码:

require 'mimas' -- Load shared library mimas.so linked to Qt libs 
app = mimas.Application() -- Just a wrapper around QApplication 
app:exec() 
-- In some callback: app:quit() 

当Lua退出(后应用程式:EXEC()返回时),它在其上一个SIGSEGV结束的 '土卫' 共享库dlclose。回溯:

Program received signal SIGSEGV, Segmentation fault. 
QList<QFactoryLoader*>::removeAll (this=0x0, [email protected]) 
    at ../../include/QtCore/../../src/corelib/tools/qlist.h:760 
760 ../../include/QtCore/../../src/corelib/tools/qlist.h: No such file or directory. 
    in ../../include/QtCore/../../src/corelib/tools/qlist.h 
(gdb) bt 
#0 QList<QFactoryLoader*>::removeAll (this=0x0, [email protected]) 
    at ../../include/QtCore/../../src/corelib/tools/qlist.h:760 
#1 0x0131126c in QFactoryLoader::~QFactoryLoader (this=0x8104a48, 
    __in_chrg=<optimized out>) at plugin/qfactoryloader.cpp:208 
#2 0x01311302 in QFactoryLoader::~QFactoryLoader (this=0x8104a48, 
    __in_chrg=<optimized out>) at plugin/qfactoryloader.cpp:209 
#3 0x009143a8 in QGlobalStaticDeleter<QFactoryLoader>::~QGlobalStaticDeleter (
    this=0x11c3200, __in_chrg=<optimized out>) 
    at ../../include/QtCore/../../src/corelib/global/qglobal.h:1825 
#4 0x001e7d2b in __cxa_finalize() from /lib/i386-linux-gnu/libc.so.6 
#5 0x00842a94 in __do_global_dtors_aux() 
    from /usr/lib/i386-linux-gnu/libQtGui.so.4 
[snip] 
#13 0x0016bd28 in dlclose() from /lib/i386-linux-gnu/libdl.so.2 

如何关闭Qt的正确,这样它不会在此内存错误结束?

这个问题似乎是qt_factory_loaders()返回null。我将尝试使用Qt 4.8.0来查看事情是否发生了变化。

[编辑]我可以缩小问题(这是不相关的LUA)和填充bug report QT间期。

回答

0

不能完全确定你的问题是什么,但可以明确的告诉Qt应用程序中app:quit()

+0

应用程式:退出()是Qt是如何停止和应用程式:EXEC()返回。在这一步之后发生崩溃。 – gaspard 2012-03-21 13:50:36

0

退出是dlclose()也许你想要什么?

http://www.kernel.org/doc/man-pages/online/pages/man3/dlsym.3.html

The function dlclose() decrements the reference count on the dynamic library 
    handle handle. If the reference count drops to zero and no other loaded 
    libraries use symbols in it, then the dynamic library is unloaded. 

    The function dlclose() returns 0 on success, and nonzero on error. 

例如:

#ifdef MAC_OS 
    // unload library for MAC 
#else //if linux 
    dlclose(lib_handle); 
#endif 
+0

正如可以从回溯看到,“dlclose”由Lua中称为其lua_close操作(框13)的一部分。崩溃发生在'dlclose'期间。 – gaspard 2012-03-21 13:51:57