make KLibrary's kde3Factory behave like kde4Factory

Thiago Macieira thiago at kde.org
Thu Oct 11 11:44:22 BST 2007


Em Thursday 11 October 2007 11:28:09 Matthias Kretz escreveu:
> #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?

Yes.

The above code is not possible. QPointer is not POD, so it won't be 
initialised and you can't use it like that above.

You can use a K_GLOBAL_STATIC though, but the code becomes very, very ugly.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- 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/b54b4def/attachment.sig>


More information about the kde-core-devel mailing list