How to use a webview in a dynamic lib or a plugin
-
We use QWebView for display Some Url in our applications. The QWebView is used in the dynamic lib inherate from QtPlugin, it is works fine for mac& Linux ,but on windows when we try to close the application ,the App crash, Accroding to the VC's debugging hint, we found that the delete of a Qobject WebCore::SharedTimerQt make the crash when the Qapplication object is deleted.
Our App's strucure like this:
App load A.DLL
and A.DLL use the Qwebview just like
QWebView * pView = new QWebView;
pView->load(Url("Http://xxx.com"));I found that the default parent of the WebCore::SharedTimerQt is QCoreApplication, So when the A.dll is unloaded so the QWebKit4.dll is also unloaded by the application. So when the
WebCore::SharedTimerQt is deleted when the application is closed, it is crash.Is there any way to use QWebView as a Plugin or a dynamic lib without make the depandece between the Main Application and the QWebKit4.dll?
-
Do you do a proper tear down of the objects when the dll is unloaded? I would have thought the timer would be removed when the QWebPage is deleted.
I am affraid this use case of running QtWebKit as plugin has never been tested. There are code path depending on delete later for example, so you would need to remove all the objects, wait a few event loop and unload the plugin.
If you are willing to support WebKit as a plugin, I think you should start hacking and adding tests for that on webkit.org.
-
I have checked the code , and with debug information, that the QWebPage is delete (the destructor is called when debug). there is no other object based in QWebKit is used in the code. Is there any way to check all the object even created by qt self is deleted properly before the dll unloaded?
Can someone told me the relationship between the QWebView-Load() and the Timer Object thanks a lot. -
WebKit uses plenty of timers. It could be as simple as delayed layout in the page.