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

Kevin Krammer kevin.krammer at gmx.at
Sat Sep 25 15:38:01 BST 2010


On Saturday, 2010-09-25, Ingo Klöcker wrote:
> On Saturday 25 September 2010, Kevin Krammer wrote:
> > On Saturday, 2010-09-25, Andras Mantia wrote:
> > > Ingo Klöcker wrote:
> > > > I agree with Thomas that it should be a proper singleton if it is
> > > > a singleton. I don't see the problem with two singletons if in
> > > > the desktop version MailCommon is just an interface to KMKernel.
> > > 
> > > Thanks for the opinion and your interface based solution. Meantime
> > > I chatted about this with Till as well, and decided to go on with
> > > the singleton solution (now either yours, or a singleton in the
> > > lib and KMKernel derives from it). Just that by following the
> > > refactoring in small steps, right now the lib has the MailCommon
> > > passing around, but I will change it next week to use a singleton
> > > there.
> > 
> > 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.
> 
> Hmm. What's problematic about a QObject-derived singleton (apart from
> QObject's methods probably not being thread-safe and/or re-entrant)?

Thread ownership.
I had "fun" problems with the singleton used internally in 
Akonadi::Control::start() when doing the kresource bridges client side.

Initially I wanted to call start in a worker thread, just like any other 
method that uses nested event loops, however that only worked for the first 
worker thread, all others complained about the objects "belonging" to someone 
else (can't remember the exact message anymore).

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/20100925/93350e58/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