我使用Qt/MFC迁移框架工具下面这个例子: http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-qt-dll-example.htmlQt/MFC迁移框架工具:正确退出DLL?
我生成DLL由基于MFC的第三方应用程序加载。第三方应用程序基本上调用我的导出的DLL函数之一来启动我的插件和另一个函数来关闭我的应用程序。目前我在关机功能中什么也没做。
当我在第三方应用程序中加载我的DLL时,启动函数被调用,我的DLL启动成功,我可以看到我的消息框。但是,如果关闭我的插件,然后尝试再次启动它,我得到以下错误:
Debug Error!
Program: <my 3rd party app>
Module: 4.7.1
File: global\qglobal.cpp
Line: 2262
ASSERT failure in QWidget: "Widgets must be created in the GUI
thread.", file kernel\qwidget.cpp line 1233
(Press Retry to debug the application)
Abort Retry Ignore
这让我觉得我没有做一些正确的关闭我的插件。我需要做些什么才能正确关闭它?
UPDATE: http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-walkthrough.html说:
The DLL also has to make sure that it can be loaded together with other Qt based DLLs in the same process (in which case a QApplication object will probably exist already), and that the DLL that creates the QApplication object remains loaded in memory to avoid other DLLs using memory that is no longer available to the process.
所以我想如果有一些问题,我需要以某种方式保留原来的DLL加载无论什么?
我认为你是对的,一个DLL永久拥有QApplication实例。当你启动一个新的DLL(或者同一个DLL)时,你如何连接到现有的QApplication实例,以便创建GUI对象? – User 2011-03-01 17:32:54