[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: [patch] koffice/libs/: port K3StaticDeleter to K_GLOBAL_STATIC
From:       Thomas Zander <zander () kde ! org>
Date:       2008-08-27 6:09:15
Message-ID: 200808270809.17817.zander () kde ! org
[Download RAW message or body]

On Wednesday 27. August 2008 00:56:48 Jaroslaw Staniek wrote:
> Hi,
> Being bored with the warnings, I've finally ported K3StaticDeleters to
> K_GLOBAL_STATICs. Since K_GLOBAL_STATIC overloads 'operator type*', I've
> merged ctors with private ::init() method if there's any, to make the
> code even simpler.
> All the statics like s_instance are no put within the private (but still
> static) usage of K_GLOBAL_STATIC within the blocks of instance() static
> methods. This is the way how K_GLOBAL_STATIC is used in kdelibs too (and,
> what's good, in our apps like KSpread).

The reason I never did this is because as far as I understand it can't work 
with K_GLOBAL_STATIC; hopefully I'm wrong.

The init and the constructor are separate for a good reason. The init 
fetches all the plugins and constructs them. So calling init can take quite 
some time.
All the plugins do thing too, including calling another singleton. Which 
will then create lots of plugins there. And those plugins may use our 
singleton.  And you have a loop.

Now, as far as I know a global-static only has a real pointer to it when the 
constructor finishes (basic OO, you can't use an object until its 
constructor finishes).  So if I call instance() *from* the constructor, 
I've got a problem.

And we do call instance() from the constructor in our 3rd party plugins, so 
we do need an init() method.

If we can do that using K_GLOBAL_STATIC; great.  But I've been told by the 
author that its not possible. (though I'm not sure he understood what I 
asked)

>
> OK?

No ;)
-- 
Thomas Zander
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic