]> git.saurik.com Git - wxWidgets.git/commitdiff
Reset static flag on cleanup.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 5 Aug 2009 17:24:57 +0000 (17:24 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 5 Aug 2009 17:24:57 +0000 (17:24 +0000)
s_stdIDsAdded was not reset and so the standard IDs were not added again if
the library was initialized, shut down and initialized again.

Closes #11075.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61613 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/xrc/xmlres.cpp

index 82c3f10a891a1c1ef57336f94d8aee505f9681fc..c4b2ae9a2e24c4fefe16570efb16f390e74bd23a 100644 (file)
@@ -2021,58 +2021,13 @@ static int XRCID_Lookup(const char *str_id, int value_if_not_found = wxID_NONE)
     return (*rec_var)->id;
 }
 
-static void AddStdXRCID_Records();
-
-/*static*/
-int wxXmlResource::DoGetXRCID(const char *str_id, int value_if_not_found)
-{
-    static bool s_stdIDsAdded = false;
-
-    if ( !s_stdIDsAdded )
-    {
-        s_stdIDsAdded = true;
-        AddStdXRCID_Records();
-    }
-
-    return XRCID_Lookup(str_id, value_if_not_found);
-}
-
-/* static */
-wxString wxXmlResource::FindXRCIDById(int numId)
-{
-    for ( int i = 0; i < XRCID_TABLE_SIZE; i++ )
-    {
-        for ( XRCID_record *rec = XRCID_Records[i]; rec; rec = rec->next )
-        {
-            if ( rec->id == numId )
-                return wxString(rec->key);
-        }
-    }
-
-    return wxString();
-}
-
-static void CleanXRCID_Record(XRCID_record *rec)
+namespace
 {
-    if (rec)
-    {
-        CleanXRCID_Record(rec->next);
 
-        free(rec->key);
-        delete rec;
-    }
-}
+// flag indicating whether standard XRC ids were already initialized
+static bool gs_stdIDsAdded = false;
 
-static void CleanXRCID_Records()
-{
-    for (int i = 0; i < XRCID_TABLE_SIZE; i++)
-    {
-        CleanXRCID_Record(XRCID_Records[i]);
-        XRCID_Records[i] = NULL;
-    }
-}
-
-static void AddStdXRCID_Records()
+void AddStdXRCID_Records()
 {
 #define stdID(id) XRCID_Lookup(#id, id)
     stdID(-1);
@@ -2200,8 +2155,57 @@ static void AddStdXRCID_Records()
 #undef stdID
 }
 
+} // anonymous namespace
 
 
+/*static*/
+int wxXmlResource::DoGetXRCID(const char *str_id, int value_if_not_found)
+{
+    if ( !gs_stdIDsAdded )
+    {
+        gs_stdIDsAdded = true;
+        AddStdXRCID_Records();
+    }
+
+    return XRCID_Lookup(str_id, value_if_not_found);
+}
+
+/* static */
+wxString wxXmlResource::FindXRCIDById(int numId)
+{
+    for ( int i = 0; i < XRCID_TABLE_SIZE; i++ )
+    {
+        for ( XRCID_record *rec = XRCID_Records[i]; rec; rec = rec->next )
+        {
+            if ( rec->id == numId )
+                return wxString(rec->key);
+        }
+    }
+
+    return wxString();
+}
+
+static void CleanXRCID_Record(XRCID_record *rec)
+{
+    if (rec)
+    {
+        CleanXRCID_Record(rec->next);
+
+        free(rec->key);
+        delete rec;
+    }
+}
+
+static void CleanXRCID_Records()
+{
+    for (int i = 0; i < XRCID_TABLE_SIZE; i++)
+    {
+        CleanXRCID_Record(XRCID_Records[i]);
+        XRCID_Records[i] = NULL;
+    }
+
+    gs_stdIDsAdded = false;
+}
 
 
 //-----------------------------------------------------------------------------