Property removal and deletion done from wxPropertyGrid event handler is now postponed to idle event
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63534 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1808,6 +1808,10 @@ protected:
|
|||||||
/** Appearance of a unspecified value cell. */
|
/** Appearance of a unspecified value cell. */
|
||||||
wxPGCell m_unspecifiedAppearance;
|
wxPGCell m_unspecifiedAppearance;
|
||||||
|
|
||||||
|
/** List of properties to be deleted/removed in idle event handler. */
|
||||||
|
wxArrayPGProperty m_deletedProperties;
|
||||||
|
wxArrayPGProperty m_removedProperties;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Temporary values
|
// Temporary values
|
||||||
//
|
//
|
||||||
|
@@ -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
|
Removes and deletes a property and any children.
|
||||||
automatically deleted as well.
|
|
||||||
*/
|
@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
|
@param id
|
||||||
Pointer or name of a property.
|
Pointer or name of a property.
|
||||||
|
|
||||||
@remarks Removed property cannot have any children.
|
@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 );
|
||||||
|
|
||||||
|
@@ -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
|
@param id
|
||||||
failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie.
|
Pointer or name of a property.
|
||||||
selection is cleared even if editor had invalid value.
|
|
||||||
|
@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
|
@param id
|
||||||
Pointer or name of a property.
|
Pointer or name of a property.
|
||||||
|
|
||||||
@remarks Removed property cannot have any children.
|
@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 );
|
||||||
|
|
||||||
|
@@ -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_processedEvent = &evt;
|
||||||
m_eventObject->HandleWindowEvent(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 )
|
if ( tlp != m_tlp )
|
||||||
OnTLPChanging(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
|
||||||
|
@@ -1857,6 +1857,18 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
|||||||
wxCHECK_RET( item != &m_regularArray && item != m_abcArray,
|
wxCHECK_RET( item != &m_regularArray && item != m_abcArray,
|
||||||
wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
|
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();
|
unsigned int indinparent = item->GetIndexInParent();
|
||||||
|
|
||||||
wxPGProperty* pwc = (wxPGProperty*)item;
|
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 ( DoIsPropertySelected(item) )
|
||||||
{
|
{
|
||||||
if ( pg && pg->GetState() == this )
|
if ( pg && pg->GetState() == this )
|
||||||
|
Reference in New Issue
Block a user