]> git.saurik.com Git - wxWidgets.git/commitdiff
fix bug with not updating the last line correctly when a group was deleted and recrea...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 21 Apr 2007 15:04:52 +0000 (15:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 21 Apr 2007 15:04:52 +0000 (15:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45557 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/common/fileconf.cpp
tests/fileconf/fileconftest.cpp

index 3aec581896fa999b8442883368a66c70c3447866..5805088ffbef1d1b688b8db7e3f6fab3f8c99922 100644 (file)
@@ -142,6 +142,7 @@ wxX11:
 All (Unix):
 
 - Handle socket shutdown by the peer correctly in wxSocket (Tim Kosse)
+- Fix bug in wxFileConfig when recreating a group (Steven Van Ingelgem)
 
 wxMSW:
 
index 04d1af7d6d71ad23f292b1251d8efa844ecdbd12..0c3912dbdb76b96775c7191a3ff64d257974552d 100644 (file)
@@ -1730,7 +1730,7 @@ bool wxFileConfigGroup::DeleteSubgroup(wxFileConfigGroup *pGroup)
 
             m_pLastGroup = NULL;
             for ( wxFileConfigLineList *pl = pLine->Prev();
-                  pl && pl != m_pLine && !m_pLastGroup;
+                  pl && !m_pLastGroup;
                   pl = pl->Prev() )
             {
                 // does this line belong to our subgroup?
@@ -1744,6 +1744,9 @@ bool wxFileConfigGroup::DeleteSubgroup(wxFileConfigGroup *pGroup)
                         break;
                     }
                 }
+
+                if ( pl == m_pLine )
+                    break;
             }
         }
 
index fa10884e15adc5063f428c2ff12e0ab608cd5c69..6f4aa5ff5357d1d215a02f01a6f8ef62a4730e44 100644 (file)
@@ -76,6 +76,7 @@ private:
         CPPUNIT_TEST( CreateEntriesAndSubgroup );
         CPPUNIT_TEST( CreateSubgroupAndEntries );
         CPPUNIT_TEST( DeleteLastGroup );
+        CPPUNIT_TEST( DeleteAndRecreateGroup );
     CPPUNIT_TEST_SUITE_END();
 
     void Path();
@@ -93,6 +94,7 @@ private:
     void CreateEntriesAndSubgroup();
     void CreateSubgroupAndEntries();
     void DeleteLastGroup();
+    void DeleteAndRecreateGroup();
 
     static wxString ChangePath(wxFileConfig& fc, const wxChar *path)
     {
@@ -512,5 +514,29 @@ void FileConfigTestCase::DeleteLastGroup()
     (void) ::wxRemoveFile(wxFileConfig::GetLocalFileName(_T("deleteconftest")));
 }
 
+void FileConfigTestCase::DeleteAndRecreateGroup()
+{
+    static const wxChar *confInitial =
+        _T("[First]\n")
+        _T("Value1=Foo\n")
+        _T("[Second]\n")
+        _T("Value2=Bar\n");
+
+    wxStringInputStream sis(confInitial);
+    wxFileConfig fc(sis);
+
+    fc.DeleteGroup(_T("Second"));
+    wxVERIFY_FILECONFIG( _T("[First]\n")
+                         _T("Value1=Foo\n"),
+                         fc );
+
+    fc.Write(_T("Second/Value2"), _T("New"));
+    wxVERIFY_FILECONFIG( _T("[First]\n")
+                         _T("Value1=Foo\n")
+                         _T("[Second]\n")
+                         _T("Value2=New\n"),
+                         fc );
+}
+
 #endif // wxUSE_FILECONFIG