[Kde-pim] Extracting some code from KMail into a lib

Kevin Krammer kevin.krammer at gmx.at
Sun Sep 26 11:41:25 BST 2010


On Sunday, 2010-09-26, Andras Mantia wrote:
> Kevin Krammer wrote:
> > One important thing to consider when doing singletons is to never make a
> > QObject singleton unless you are 110% sure it is never going to be used
> > in a thread.
> 
>  KMKernel is already a QObject based singleton, so as long as it works now,
> it should work once I have a singleton in the lib as well. :)

A difference between application and lib is that usage of a lib is not always 
fully predeterminable.
So it is extremely important to document any such restrictions properly, 
especially if the singleton is used internally somewhere.
Singletons have tendency to sneak into other classes and users of those might 
not be aware of it and the restrictions it carries.

> Good point neverthless.
> Nitpick: it can be used, just be careful where the event loop is running,
> eg. calling a regular method of the singleton should be safe, while using
> signals/slots might not be.

Probably true. Again a matter of documentation. Anyone working on the class 
needs to be aware of that they can't emit signals from methods that did not 
emit one before in order to keep those methods "safe".

Cheers,
Kevin
-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20100926/c94dc24b/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list