Rework our plugin loading code
commitc93bc4e8ebc5369f83852893de8cbcd0b7b34d85
authorJan Kundrát <jkt@kde.org>
Mon, 1 Feb 2016 17:52:50 +0000 (1 18:52 +0100)
committerJan Kundrát <jkt@kde.org>
Tue, 2 Feb 2016 00:19:30 +0000 (2 01:19 +0100)
tree039e46be7f46a8986ac9d235761d1057c0da37ce
parent1bc33c46ced6b7823318b8b8d030d79344a5a18d
Rework our plugin loading code

In Qt5, one should essentially never ever unload a plugin which happens
to use Qt classes. This is very visible when one uses a QStringLiteral.
According to Thiago, unloading C++ plugins is very dangerous because
some class instances might have vtables which point to the code that
we're just unloading. We could probably handle this (by ensuring that
all plugin jobs are destroyed, and I mean C++-like destroyed with no
references held), but the QStringLiteral and any caches are a problem on
their own. For more context, please see [1] and [2].

Let's change the plugin loading code so that it stops unloading the
detected plugins no matter if they are used or unused. Note that we are
*not* actually *creating* the plugin implementations themselves (for
example, we aren't instantiating any actual address book implementation,
just the relatively small wrapper, the factory class.

I also took the liberty to refactor the code a bit. It now explicitly
uses class types for specifying if it's a password or address book
plugin, and bits of QLibrary for testing if it's indeed a plugin in the
first place (so that it skips irrelevant stuff in the build dir).

Change-Id: I7f8da24ac37ec52ba056da486a43ea3fbe7d5222
12 files changed:
src/Gui/SettingsDialog.cpp
src/Plugins/AbookAddressbook/AbookAddressbook.cpp
src/Plugins/AbookAddressbook/AbookAddressbook.h
src/Plugins/AddressbookPlugin.h
src/Plugins/ClearTextPassword/ClearTextPassword.cpp
src/Plugins/ClearTextPassword/ClearTextPassword.h
src/Plugins/PasswordPlugin.h
src/Plugins/PluginInterface.h
src/Plugins/PluginManager.cpp
src/Plugins/PluginManager.h
src/Plugins/QtKeyChain/QtKeyChainPassword.cpp
src/Plugins/QtKeyChain/QtKeyChainPassword.h