QPluginLoader
-
Hi Developer Network,
I'm working over plugin arquitecture aproach, but I have a question about plugin loader.
If I call QPluginLoader::unload(), the loader free reserved memory for loaded object? or have I call delete operator?.@QObject *pluginInstance = m_loader.instance();
if (!pluginInstance)
continue;
PluginFactory *pluginFactory = qobject_cast<PluginFactory *>(pluginInstance);if (!pluginFactory)
continue;Plugin *plugin = pluginFactory->plugin(); // PluginFactory::plugin() { return new Plugin(); }
if (!plugin)
continue;m_loader.unload();
// delete plugin;@
Thank you for your help ;)
-
This depends on whether "plugin" is a child (QObject) of pluginInstance/pluginFactory. on mloader.unload(), pluginFactory is deleted. if "plugin" is not associated with the other classes anymore, you're responsible for the memory.
//EDIT: And since you create it via "new Plugin();" and not "new Plugin(this);", it isn't a child of the factory and you'll need to delete it yourself.
-
;)
Ok DerManu,
Thank you for your explanation (about QPluginLoader). I'll check my memory management.
BR,