From 0d50639d708942216a19fcb6636e8eeae0bfb56f Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 2 Feb 2008 14:52:23 +0100 Subject: [PATCH] Fix problem with static initialisation order --- src/common/singletonsubclass.hpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/common/singletonsubclass.hpp b/src/common/singletonsubclass.hpp index 8877ba6bf..e779b820e 100644 --- a/src/common/singletonsubclass.hpp +++ b/src/common/singletonsubclass.hpp @@ -73,13 +73,20 @@ namespace cinelerra virtual S* create () { return POL::create (); } // covariance checked! virtual void destroy (I* pSi) { POL::destroy (static_cast (pSi)); } }; - + + + struct My_scoped_ptr : scoped_ptr ///< implementation detail: defeat static initialisation + { + using scoped_ptr::get; + My_scoped_ptr() : scoped_ptr (get()? get() : 0) {} ///< bypass if already configured + }; + /** we configure this link \i later, when the singleton factory * is actually created, to point at the desired implementation subclass. */ - static scoped_ptr link; + static My_scoped_ptr link; - /** Forwarding Template to configure the basic SingletonFactory */ + /** Forwarding Template used to configure the basic SingletonFactory */ template struct Adapted { @@ -89,7 +96,7 @@ namespace cinelerra }; template class A, class I> - scoped_ptr::Link> Adapter::link (0); + typename Adapter::My_scoped_ptr Adapter::link; // note: use special ctor (due to stati init order!) /** type-information used to configure the factory instance