Qt-interest Archive, March 2008
Unloading Qt's plugins
Message 1 in thread
Good day.
I've a strange task. I need to unload loaded plugins in mine
application. And then reload them. (in case new plugins appears to be)
Is it possible in Qt to unload plugins ?? How-to or any advise will be
great!
Thanks a lot.
Best regards,
Ilya Dyoshin.
--
[ signature omitted ]
Message 2 in thread
Check QPluginLoader::unload()
--
[ signature omitted ]
Message 3 in thread
On torsdag den 27. Marts 2008, Ilya Dyoshin wrote:
> Good day.
>
> I've a strange task. I need to unload loaded plugins in mine
> application. And then reload them. (in case new plugins appears to be)
>
> Is it possible in Qt to unload plugins ?? How-to or any advise will be
> great!
Acenes already told you about unload() on QPluginLoader.
I would like to add that this is going to be *very* hard to maintain later.
Before unloading a plugin, every single object that uses code in it must be
deleted. If you have even a single destructor run on an object from the
plugin, this will immediately crash your application.
You can most likely do this in the first release of the code. But maintaining
this for the next 10 years is going to be annoying, frustrating, manual, and
incredibly expensive.
If the plugins are all written by you, or at least contain classes you
control, you need to implement a reference counting scheme, so your
application can run checks for this automatically. But if you are using Qt
plugins, you're out of luck.
You should seriously reconsider this option. If at all possible, scrap it.
That's a recommendation from someone who has tried this on customer code. I
was ordered to do it by the customer, and told them exactly the same thing
I'm telling you now. And I know they have all the issues now that I warned
them about. Every new programmer added to the team forgets this, and they end
up in debugging nightmare (hint: you can't single step in code from a module
that you already unloaded).
However, there are some cases where it is mostly safe to do it. QStyle plugins
would mostly be safe to unload, for example. But the potential errors all sit
right there in the "mostly".
Bo.
--
[ signature omitted ]