First, enable pluginLoad.unload by use Qt::QueuedConnection, for deal with the possibility that unload a plugin itself in stop function.
// This would unload the shared library and delete the activator if
// there are no dependencies. However, objects from the plug-in might
// have been created via C-function symbol lookups. Hence we cannot
// safely unload the DLL. Maybe implement a in-DLL counter later
// (http://stackoverflow.com/questions/460809/c-dll-unloading-issue and
// http://boost.2283326.n4.nabble.com/shared-ptr-A-smarter-smart-pointer-proposal-for-dynamic-libraries-td2649749.html).
// The activator itself will be delete during program termination
// (by the QPluginLoader instance).
//TODO: is this method to unload the dll are safe?
QMetaObject::invokeMethod((QObject*)&m_unloader, "stopPlugin", Qt::QueuedConnection);
//pluginLoader.unload();
Second, at the rutnime, load and unload plugin "org.commontk.eventadmin", then we load that plugin again then the program crash, that's must because of the plugin problems. QVariant didn't support for Q_DECLARE_METATYPE in the dynamic load and unload plugins.
DLL unloading is a tricky business. AFAIK Qt officially doesn't support DLL unloading if meta types are provided by that dll [1]. We could try to work around this, but I am not feeling too confident about that.
To re-show this issue.
First, enable pluginLoad.unload by use Qt::QueuedConnection, for deal with the possibility that unload a plugin itself in stop function.
// This would unload the shared library and delete the activator if // there are no dependencies. However, objects from the plug-in might // have been created via C-function symbol lookups. Hence we cannot // safely unload the DLL. Maybe implement a in-DLL counter later // (http://stackoverflow.com/questions/460809/c-dll-unloading-issue and // http://boost.2283326.n4.nabble.com/shared-ptr-A-smarter-smart-pointer-proposal-for-dynamic-libraries-td2649749.html). // The activator itself will be delete during program termination // (by the QPluginLoader instance). //TODO: is this method to unload the dll are safe? QMetaObject::invokeMethod((QObject*)&m_unloader, "stopPlugin", Qt::QueuedConnection); //pluginLoader.unload();
Second, at the rutnime, load and unload plugin "org.commontk.eventadmin", then we load that plugin again then the program crash, that's must because of the plugin problems. QVariant didn't support for Q_DECLARE_METATYPE in the dynamic load and unload plugins.