]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/persist.cpp
wxDialogBase only has one ctor, so just do initialization in ctor instead of Init()
[wxWidgets.git] / src / common / persist.cpp
index 76ab2698bdcde2c7d133df5071b5953b8686da92..f1e951957ff4bdafeba4dbde1c5f735142226d17 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     common persistence support classes
 // Author:      Vadim Zeitlin
 // Created:     2009-01-20
-// RCS-ID:      $Id$
 // Copyright:   (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
     #pragma hdrstop
 #endif
 
+#if wxUSE_CONFIG
+
 #ifndef WX_PRECOMP
 #endif // WX_PRECOMP
 
 #include "wx/persist.h"
 
+namespace
+{
+
+wxPersistenceManager* gs_manager = NULL;
+
+} // anonymous namespace
+
 // ============================================================================
 // wxPersistenceManager implementation
 // ============================================================================
 
+/* static */
+void wxPersistenceManager::Set(wxPersistenceManager& manager)
+{
+    gs_manager = &manager;
+}
+
 /* static */
 wxPersistenceManager& wxPersistenceManager::Get()
 {
-    static wxPersistenceManager s_manager;
+    if ( !gs_manager )
+    {
+        static wxPersistenceManager s_manager;
 
-    return s_manager;
+        gs_manager = &s_manager;
+    }
+
+    return *gs_manager;
 }
 
 wxPersistenceManager::~wxPersistenceManager()
@@ -150,4 +169,6 @@ wxPERSIST_DEFINE_SAVE_RESTORE_FOR(int)
 wxPERSIST_DEFINE_SAVE_RESTORE_FOR(long)
 wxPERSIST_DEFINE_SAVE_RESTORE_FOR(wxString)
 
-#undef wxPERSIST_DEFINE_SAVE_RESTORE_FOR  
+#undef wxPERSIST_DEFINE_SAVE_RESTORE_FOR
+
+#endif // wxUSE_CONFIG