]> git.saurik.com Git - wxWidgets.git/commitdiff
Property removal and deletion done from wxPropertyGrid event handler is now postponed...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Mon, 22 Feb 2010 16:44:56 +0000 (16:44 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Mon, 22 Feb 2010 16:44:56 +0000 (16:44 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63534 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/propgrid.h
include/wx/propgrid/propgridiface.h
interface/wx/propgrid/propgridiface.h
src/propgrid/propgrid.cpp
src/propgrid/propgridpagestate.cpp

index 2d744fe7c9bad5b14345c6780ea0ee408d2999ab..cda343f9f3539f66301cca47ebfeba976b2d1feb 100644 (file)
@@ -1808,6 +1808,10 @@ protected:
     /** Appearance of a unspecified value cell. */
     wxPGCell            m_unspecifiedAppearance;
 
     /** Appearance of a unspecified value cell. */
     wxPGCell            m_unspecifiedAppearance;
 
+    /** List of properties to be deleted/removed in idle event handler. */
+    wxArrayPGProperty   m_deletedProperties;
+    wxArrayPGProperty   m_removedProperties;
+
     //
     // Temporary values
     //
     //
     // Temporary values
     //
index a79f2a93b28b2ba3bae1789a6b192ea5e099408e..7b4041b4caa6d1188a8a3c4f40880e95ecf4b336 100644 (file)
@@ -240,18 +240,34 @@ public:
     bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
 
     /**
     bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
 
     /**
-        Deletes a property by id. If category is deleted, all children are
-        automatically deleted as well.
-     */
+        Removes and deletes a property and any children.
+
+        @param id
+            Pointer or name of a property.
+
+        @remarks If you delete a property in a wxPropertyGrid event
+                 handler, the actual deletion is postponed until the next
+                 idle event.
+
+                 This functions deselects selected property, if any.
+                 Validation failure option wxPG_VFB_STAY_IN_PROPERTY is not
+                 respected, ie. selection is cleared even if editor had
+                 invalid value.
+    */
     void DeleteProperty( wxPGPropArg id );
 
     /**
     void DeleteProperty( wxPGPropArg id );
 
     /**
-        Removes and returns a property.
+        Removes a property. Does not delete the property object, but
+        instead returns it.
 
         @param id
             Pointer or name of a property.
 
         @remarks Removed property cannot have any children.
 
         @param id
             Pointer or name of a property.
 
         @remarks Removed property cannot have any children.
+
+                 Also, if you remove property in a wxPropertyGrid event
+                 handler, the actual removal is postponed until the next
+                 idle event.
     */
     wxPGProperty* RemoveProperty( wxPGPropArg id );
 
     */
     wxPGProperty* RemoveProperty( wxPGPropArg id );
 
index c8bdd55707a6c07b7625e483238c110e26a9b24d..efd9067b68acab54edf699e733e0bb3acddd0666 100644 (file)
@@ -135,11 +135,19 @@ public:
     bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
 
     /**
     bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
 
     /**
-        Deletes a property.
+        Removes and deletes a property and any children.
 
 
-        @remarks This functions deselects selected property, if any. Validation
-                failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie.
-                selection is cleared even if editor had invalid value.
+        @param id
+            Pointer or name of a property.
+
+        @remarks If you delete a property in a wxPropertyGrid event
+                 handler, the actual deletion is postponed until the next
+                 idle event.
+
+                 This functions deselects selected property, if any.
+                 Validation failure option wxPG_VFB_STAY_IN_PROPERTY is not
+                 respected, ie. selection is cleared even if editor had
+                 invalid value.
     */
     void DeleteProperty( wxPGPropArg id );
 
     */
     void DeleteProperty( wxPGPropArg id );
 
@@ -589,12 +597,17 @@ public:
     static void RegisterAdditionalEditors();
 
     /**
     static void RegisterAdditionalEditors();
 
     /**
-        Removes and returns a property.
+        Removes a property. Does not delete the property object, but
+        instead returns it.
 
         @param id
             Pointer or name of a property.
 
         @remarks Removed property cannot have any children.
 
         @param id
             Pointer or name of a property.
 
         @remarks Removed property cannot have any children.
+
+                 Also, if you remove property in a wxPropertyGrid event
+                 handler, the actual removal is postponed until the next
+                 idle event.
     */
     wxPGProperty* RemoveProperty( wxPGPropArg id );
 
     */
     wxPGProperty* RemoveProperty( wxPGPropArg id );
 
index ee5e0e92e3d7ed0e9eb7f5aa4d0b74c0f30fe389..389e7a88f2259b95b10e5d768ae44e60b29c9ba3 100644 (file)
@@ -4535,9 +4535,10 @@ bool wxPropertyGrid::SendEvent( int eventType, wxPGProperty* p,
             evt.SetCanVeto(true);
     }
 
             evt.SetCanVeto(true);
     }
 
+    wxPropertyGridEvent* prevProcessedEvent = m_processedEvent;
     m_processedEvent = &evt;
     m_eventObject->HandleWindowEvent(evt);
     m_processedEvent = &evt;
     m_eventObject->HandleWindowEvent(evt);
-    m_processedEvent = NULL;
+    m_processedEvent = prevProcessedEvent;
 
     return evt.WasVetoed();
 }
 
     return evt.WasVetoed();
 }
@@ -5639,6 +5640,27 @@ void wxPropertyGrid::OnIdle( wxIdleEvent& WXUNUSED(event) )
         if ( tlp != m_tlp )
             OnTLPChanging(tlp);
     }
         if ( tlp != m_tlp )
             OnTLPChanging(tlp);
     }
+
+    //
+    // Resolve pending property removals
+    if ( m_deletedProperties.size() > 0 )
+    {
+        wxArrayPGProperty& arr = m_deletedProperties;
+        for ( unsigned int i=0; i<arr.size(); i++ )
+        {
+            DeleteProperty(arr[i]);
+        }
+        arr.clear();
+    }
+    if ( m_removedProperties.size() > 0 )
+    {
+        wxArrayPGProperty& arr = m_removedProperties;
+        for ( unsigned int i=0; i<arr.size(); i++ )
+        {
+            RemoveProperty(arr[i]);
+        }
+        arr.clear();
+    }
 }
 
 bool wxPropertyGrid::IsEditorFocused() const
 }
 
 bool wxPropertyGrid::IsEditorFocused() const
index cd965c51372360d3667df9b7a46665176abd5026..5571a46b5b0ce24c1d8be979800fdb3982242872 100644 (file)
@@ -1857,6 +1857,18 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
     wxCHECK_RET( item != &m_regularArray && item != m_abcArray,
         wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
 
     wxCHECK_RET( item != &m_regularArray && item != m_abcArray,
         wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
 
+    wxPropertyGrid* pg = GetGrid();
+
+    // Must defer deletion? Yes, if handling a wxPG event.
+    if ( pg && pg->m_processedEvent )
+    {
+        if ( doDelete )
+            pg->m_deletedProperties.push_back(item);
+        else
+            pg->m_removedProperties.push_back(item);
+        return;
+    }
+
     unsigned int indinparent = item->GetIndexInParent();
 
     wxPGProperty* pwc = (wxPGProperty*)item;
     unsigned int indinparent = item->GetIndexInParent();
 
     wxPGProperty* pwc = (wxPGProperty*)item;
@@ -1867,8 +1879,6 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
 
     wxASSERT( item->GetParentState() == this );
 
 
     wxASSERT( item->GetParentState() == this );
 
-    wxPropertyGrid* pg = GetGrid();
-
     if ( DoIsPropertySelected(item) )
     {
         if ( pg && pg->GetState() == this )
     if ( DoIsPropertySelected(item) )
     {
         if ( pg && pg->GetState() == this )