我使用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