Re: [PATCH] Setting variables in PD_DocumentRDF

From: Ingo Brückl <ib_at_wupperonline.de>
Date: Sat Apr 14 2012 - 21:48:28 CEST

Hubert Figuière wrote on Sat, 14 Apr 2012 11:34:32 -0700:

> On 13/04/12 07:06 AM, Ingo Brückl wrote:
>> I don't know whether it is a compiler issue, but the static variables get
>> their "new PD_...Null" value *after* being PD_DocumentRDF::set, resulting
>> in calling the PD_...Null functions rather than the GTK ones.

> Where is ::set called from?

From ap_RDFSemanticItemGTKInjected.cpp's PD_RDFDialogsGTK() constructor.

> The only safe way for static global object is to use a function to get
> them as there is no guarantee of initialization order.

Initialization order seems the problem. It seems set first and initialized
afterwards.

> Something like that:

> static PD_SemanticItemFactory* getSemanticItemFactory()
> {
> static PD_SemanticItemFactory* s_SemanticItemFactory = new
> PD_SemanticItemFactoryNull;
> return s_SemanticItemFactory;
> }

> This guarantee the proper initialization.

Yes, but things are more complicated here (due to sloppy programming). These
static variables are used in PD_DocumentRDF class member functions as well as
in ordinary global (non-member) functions (although only with file scope).

Ingo
Received on Sat, 14 Apr 2012 21:48:28 +0200

This archive was generated by hypermail 2.1.8 : Sat Apr 14 2012 - 21:54:43 CEST