From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Mon, 4 Dec 2006 17:07:57 +0000 (+0000)
Subject: fix a problem with (sometimes) editing an invalid item in EditLabel() (Tim Kosse)
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a502b2841d622c17453ca2c6fc6d25fc0c978fa0

fix a problem with (sometimes) editing an invalid item in EditLabel() (Tim Kosse)


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

diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp
index 9646986295..a7485c2a2e 100644
--- a/src/generic/listctrl.cpp
+++ b/src/generic/listctrl.cpp
@@ -2910,8 +2910,15 @@ wxTextCtrl *wxListMainWindow::EditLabel(long item, wxClassInfo* textControlClass
     // We have to call this here because the label in question might just have
     // been added and no screen update taken place.
     if ( m_dirty )
+    {
         wxSafeYield();
 
+        // Pending events dispatched by wxSafeYield might have changed the item
+        // count
+        if ( (size_t)item >= GetItemCount() )
+            return NULL;
+    }
+
     wxTextCtrl * const text = (wxTextCtrl *)textControlClass->CreateObject();
     m_textctrlWrapper = new wxListTextCtrlWrapper(this, text, item);
     return m_textctrlWrapper->GetText();