]> git.saurik.com Git - wxWidgets.git/commitdiff
fix wxList::erase(it, end()) in non-STL build (see #10103)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 7 Feb 2009 23:10:56 +0000 (23:10 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 7 Feb 2009 23:10:56 +0000 (23:10 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58734 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/list.h
tests/lists/lists.cpp

index 4a55c64134475d11e8d8aa1d6ef8d4b683d70626..c917e02a2f5af6500fb742b42798d5cdbcda9a4f 100644 (file)
@@ -1034,7 +1034,9 @@ private:
         }                                                                   \
         iterator erase(const iterator& first, const iterator& last)         \
         {                                                                   \
-            iterator next = last; ++next;                                   \
+            iterator next = last;                                           \
+            if ( next != end() )                                            \
+                ++next;                                                     \
             DeleteNodes(first.m_node, last.m_node);                         \
             return next;                                                    \
         }                                                                   \
index f634eb523145cd61d70ea61aa8a1deccc3525a6b..ef259ba552245cc94d311ec9e09e2508164d830a 100644 (file)
@@ -156,6 +156,11 @@ void ListsTestCase::wxStdListTest()
     list1.insert(list1.end(), (int *)2);
     CPPUNIT_ASSERT_EQUAL( (int *)1, list1.front() );
     CPPUNIT_ASSERT_EQUAL( (int *)2, list1.back() );
+
+    it = list1.begin();
+    it = list1.erase(++it, list1.end());
+    CPPUNIT_ASSERT_EQUAL( 1, list1.size() );
+    CPPUNIT_ASSERT( it == list1.end() );
 }
 
 void ListsTestCase::wxListCtorTest()