[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: singleton::exists() addition for K_GLOBAL_STATIC
From: Olivier Goffart <ogoffart () kde ! org>
Date: 2008-05-04 20:40:26
Message-ID: 200805042240.32258.ogoffart () kde ! org
[Download RAW message or body]
Le dimanche 4 mai 2008, David Faure a écrit :
> I'm porting code like this
> void KonqFMSettings::reparseConfiguration()
> {
> if (globalEmbedSettings) {
> globalEmbedSettings->init();
> }
> }
> to K_GLOBAL_STATIC.
> It used to do nothing if the singleton hadn't been constructed yet, but now
> it would create it just to reparse configuration, which is useless in this
> case.
>
> How about this addition?
Looks ok.
Maybe it should be documented anyway.
>
> Index: kglobal.h
> ===================================================================
> --- kglobal.h (revision 802526)
> +++ kglobal.h (working copy)
> @@ -266,6 +266,10 @@ static struct K_GLOBAL_STATIC_STRUCT_NAM
> {
> \ return _k_static_##NAME##_destroyed;
> \ }
> \ + bool exists()
> \ + {
> \ + return _k_static_##NAME != 0;
> \ + }
> \ inline operator TYPE*()
> \ {
> \ return operator->();
> \
>
> Then I could write
> if (globalEmbedSettings.exists()) {
> globalEmbedSettings->init();
> }
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic