From: Vadim Zeitlin Date: Sat, 7 Feb 2009 23:10:56 +0000 (+0000) Subject: fix wxList::erase(it, end()) in non-STL build (see #10103) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1416fc5ff62141ff5d27790f513de59233ab5746 fix wxList::erase(it, end()) in non-STL build (see #10103) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58734 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/list.h b/include/wx/list.h index 4a55c64134..c917e02a2f 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -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; \ } \ diff --git a/tests/lists/lists.cpp b/tests/lists/lists.cpp index f634eb5231..ef259ba552 100644 --- a/tests/lists/lists.cpp +++ b/tests/lists/lists.cpp @@ -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()