make KLibrary's kde3Factory behave like kde4Factory
Matthias Kretz
kretz at kde.org
Thu Oct 11 10:28:09 BST 2007
On Tuesday 09 October 2007, Matthias Kretz wrote:
> attached you'll find a patch that makes kde3Factory (helper function of
> KLibrary) behave the same as kde4Factory does, i.e.:
> - create new KPluginFactory instance if called the first time
> - return a pointer to the old KPluginFactory object if called a second time
> - when the KPluginFactory object is deleted, create it anew
> This restores the old behaviour we had with KLibLoader/KLibrary.
>
> Please review and let me know whether I should commit.
Hi again,
I won't commit this without comments, but here's a different idea how to solve
it: instead of storing the QPointer with kde3Factory in a K_GLOBAL_STATIC
QHash we do it like Q_PLUGIN_INSTANCE in K_EXPORT_COMPONENT_FACTORY, i.e.
change
#define K_EXPORT_COMPONENT_FACTORY( libname, factory ) \
extern "C" { KDE_EXPORT KLibFactory *init_##libname() \
{ return new factory; } }
to
#define K_EXPORT_COMPONENT_FACTORY( libname, factory ) \
extern "C" { KDE_EXPORT KLibFactory *init_##libname() \
{ \
static QPointer<QObject> _instance; \
if (!_instance) _instance = new factory; \
return _instance; \
} }
then init_##libname would behave exactly as qt_plugin_instance and kde3Factory
would need no further changes...
Comments?
--
________________________________________________________
Matthias Kretz (Germany) <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071011/3314a76e/attachment.sig>
More information about the kde-core-devel
mailing list