]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix wxListCtrl in-place editing (to not crash
authorRobert Roebling <robert@roebling.de>
Thu, 30 Mar 2006 15:25:59 +0000 (15:25 +0000)
committerRobert Roebling <robert@roebling.de>
Thu, 30 Mar 2006 15:25:59 +0000 (15:25 +0000)
    when editin is finished by clicking somewhere
    else and thus taking the focus away from the
    wxTextCtrl). Also, "delete this" in the middle
    of code isn't optimal.

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

src/generic/listctrl.cpp

index 043001015ce431a81df8eb6c6b6d49a67d71a6f2..6ba376db61b58ddfffbdd2b0873b8fcf035e8f6b 100644 (file)
@@ -2033,6 +2033,8 @@ wxListTextCtrlWrapper::wxListTextCtrlWrapper(wxListMainWindow *owner,
     m_text->Create(owner, wxID_ANY, m_startValue,
                    wxPoint(rectLabel.x-4,rectLabel.y-4),
                    wxSize(rectLabel.width+11,rectLabel.height+8));
+    m_text->SetFocus();
+    
     m_text->PushEventHandler(this);
 }
 
@@ -2045,7 +2047,7 @@ void wxListTextCtrlWrapper::Finish()
         m_text->RemoveEventHandler(this);
         m_owner->FinishEditing(m_text);
 
-        delete this;
+        wxPendingDelete.Append( this );
     }
 }
 
@@ -2087,8 +2089,8 @@ void wxListTextCtrlWrapper::OnChar( wxKeyEvent &event )
             break;
 
         case WXK_ESCAPE:
-            Finish();
             m_owner->OnRenameCancelled( m_itemEdited );
+            Finish();
             break;
 
         default:
@@ -2123,16 +2125,13 @@ void wxListTextCtrlWrapper::OnKillFocus( wxFocusEvent &event )
 {
     if ( !m_finished && !m_aboutToFinish )
     {
-        // We must finish regardless of success, otherwise we'll get
-        // focus problems:
-        Finish();
-
         if ( !AcceptChanges() )
             m_owner->OnRenameCancelled( m_itemEdited );
+            
+        Finish();
     }
 
-    // We must let the native text control handle focus, too, otherwise
-    // it could have problems with the cursor (e.g., in wxGTK).
+    // We must let the native text control handle focus
     event.Skip();
 }