Removed property editor validation failure assertions when implicitly clearing selection. Added relevant notes into documentation of member functions that previously asserted.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56690 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -252,14 +252,6 @@
|
|||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// wxPG_CHECK_FOO_DBG - debug check with message that does not
|
|
||||||
// interrupt program flow.
|
|
||||||
#define wxPG_CHECK_RET_DBG(A,B) \
|
|
||||||
if ( !(A) ) { wxLogWarning(B); return; }
|
|
||||||
#define wxPG_CHECK_MSG_DBG(A,B,C) \
|
|
||||||
if ( !(A) ) { wxLogWarning(C); return B; }
|
|
||||||
|
|
||||||
|
|
||||||
class wxPGEditor;
|
class wxPGEditor;
|
||||||
class wxPGProperty;
|
class wxPGProperty;
|
||||||
class wxPropertyCategory;
|
class wxPropertyCategory;
|
||||||
|
@@ -200,9 +200,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void Clear() = 0;
|
virtual void Clear() = 0;
|
||||||
|
|
||||||
/** Deselect current selection, if any. Returns true if success
|
/**
|
||||||
(ie. validator did not intercept). */
|
Clears current selection, if any.
|
||||||
bool ClearSelection();
|
|
||||||
|
@param validation
|
||||||
|
If set to @false, deselecting the property will always work,
|
||||||
|
even if its editor had invalid value in it.
|
||||||
|
|
||||||
|
@return Returns @true if successful or if there was no selection. May
|
||||||
|
fail if validation was enabled and active editor had invalid
|
||||||
|
value.
|
||||||
|
*/
|
||||||
|
bool ClearSelection( bool validation = false);
|
||||||
|
|
||||||
/** Resets modified status of all properties.
|
/** Resets modified status of all properties.
|
||||||
*/
|
*/
|
||||||
|
@@ -451,6 +451,10 @@ public:
|
|||||||
/**
|
/**
|
||||||
Enables or disables (shows/hides) categories according to parameter
|
Enables or disables (shows/hides) categories according to parameter
|
||||||
enable.
|
enable.
|
||||||
|
|
||||||
|
@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.
|
||||||
*/
|
*/
|
||||||
bool EnableCategories( bool enable );
|
bool EnableCategories( bool enable );
|
||||||
|
|
||||||
@@ -811,11 +815,19 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Sorts all items at all levels (except private children).
|
Sorts all items at all levels (except private 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.
|
||||||
*/
|
*/
|
||||||
void Sort();
|
void Sort();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sorts children of a property.
|
Sorts children of a property.
|
||||||
|
|
||||||
|
@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.
|
||||||
*/
|
*/
|
||||||
void SortChildren( wxPGPropArg id );
|
void SortChildren( wxPGPropArg id );
|
||||||
};
|
};
|
||||||
|
@@ -46,6 +46,9 @@ public:
|
|||||||
- Does not automatically redraw the control, so you may need to call
|
- Does not automatically redraw the control, so you may need to call
|
||||||
Refresh() when calling this function after control has been shown for
|
Refresh() when calling this function after control has been shown for
|
||||||
the first time.
|
the first time.
|
||||||
|
- 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.
|
||||||
*/
|
*/
|
||||||
wxPGProperty* Append( wxPGProperty* property );
|
wxPGProperty* Append( wxPGProperty* property );
|
||||||
|
|
||||||
@@ -71,15 +74,25 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Deletes all properties.
|
Deletes all properties.
|
||||||
|
|
||||||
|
@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.
|
||||||
*/
|
*/
|
||||||
virtual void Clear() = 0;
|
virtual void Clear() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Deselect current selection, if any.
|
Clears current selection, if any.
|
||||||
|
|
||||||
@return Returns @true if success (ie. validator did not intercept).
|
@param validation
|
||||||
|
If set to @false, deselecting the property will always work,
|
||||||
|
even if its editor had invalid value in it.
|
||||||
|
|
||||||
|
@return Returns @true if successful or if there was no selection. May
|
||||||
|
fail if validation was enabled and active editor had invalid
|
||||||
|
value.
|
||||||
*/
|
*/
|
||||||
bool ClearSelection();
|
bool ClearSelection( bool validation = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Resets modified status of all properties.
|
Resets modified status of all properties.
|
||||||
@@ -90,14 +103,19 @@ public:
|
|||||||
Collapses given category or property with children.
|
Collapses given category or property with children.
|
||||||
|
|
||||||
@return Returns @true if actually collapsed.
|
@return Returns @true if actually collapsed.
|
||||||
|
|
||||||
|
@remarks This function may deselect 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.
|
||||||
*/
|
*/
|
||||||
bool Collapse( wxPGPropArg id );
|
bool Collapse( wxPGPropArg id );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Collapses all items that can be collapsed.
|
Collapses all items that can be collapsed.
|
||||||
|
|
||||||
@return Returns @false if failed (may fail if value in active
|
@remarks This functions clears selection. Validation failure option
|
||||||
editor cannot be validated).
|
wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. selection
|
||||||
|
is cleared even if editor had invalid value.
|
||||||
*/
|
*/
|
||||||
bool CollapseAll();
|
bool CollapseAll();
|
||||||
|
|
||||||
@@ -112,6 +130,10 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Deletes a property.
|
Deletes a property.
|
||||||
|
|
||||||
|
@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.
|
||||||
*/
|
*/
|
||||||
void DeleteProperty( wxPGPropArg id );
|
void DeleteProperty( wxPGPropArg id );
|
||||||
|
|
||||||
@@ -148,11 +170,19 @@ public:
|
|||||||
Expands given category or property with children.
|
Expands given category or property with children.
|
||||||
|
|
||||||
@return Returns @true if actually expanded.
|
@return Returns @true if actually expanded.
|
||||||
|
|
||||||
|
@remarks This function may deselect 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.
|
||||||
*/
|
*/
|
||||||
bool Expand( wxPGPropArg id );
|
bool Expand( wxPGPropArg id );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Expands all items that can be expanded.
|
Expands all items that can be expanded.
|
||||||
|
|
||||||
|
@remarks This functions clears selection. Validation failure option
|
||||||
|
wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. selection
|
||||||
|
is cleared even if editor had invalid value.
|
||||||
*/
|
*/
|
||||||
bool ExpandAll( bool expand = true );
|
bool ExpandAll( bool expand = true );
|
||||||
|
|
||||||
@@ -431,6 +461,10 @@ public:
|
|||||||
non-categoric) are active, Insert becomes even more slow. This is
|
non-categoric) are active, Insert becomes even more slow. This is
|
||||||
especially true if current mode is non-categoric.
|
especially true if current mode is non-categoric.
|
||||||
|
|
||||||
|
- 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.
|
||||||
|
|
||||||
Example of use:
|
Example of use:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
@@ -1038,13 +1038,7 @@ void wxPropertyGrid::ResetColours()
|
|||||||
bool wxPropertyGrid::SetFont( const wxFont& font )
|
bool wxPropertyGrid::SetFont( const wxFont& font )
|
||||||
{
|
{
|
||||||
// Must disable active editor.
|
// Must disable active editor.
|
||||||
if ( m_selected )
|
ClearSelection(false);
|
||||||
{
|
|
||||||
bool selRes = ClearSelection();
|
|
||||||
wxPG_CHECK_MSG_DBG( selRes,
|
|
||||||
false,
|
|
||||||
wxT("failed to deselect a property (editor probably had invalid value)") );
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Following code is disabled with wxMac because
|
// TODO: Following code is disabled with wxMac because
|
||||||
// it is reported to fail. I (JMS) cannot debug it
|
// it is reported to fail. I (JMS) cannot debug it
|
||||||
@@ -2177,12 +2171,7 @@ void wxPropertyGrid::Refresh( bool WXUNUSED(eraseBackground),
|
|||||||
|
|
||||||
void wxPropertyGrid::Clear()
|
void wxPropertyGrid::Clear()
|
||||||
{
|
{
|
||||||
if ( m_selected )
|
ClearSelection(false);
|
||||||
{
|
|
||||||
bool selRes = DoSelectProperty(NULL, wxPG_SEL_DELETING); // This must be before state clear
|
|
||||||
wxPG_CHECK_RET_DBG( selRes,
|
|
||||||
wxT("failed to deselect a property (editor probably had invalid value)") );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pState->DoClear();
|
m_pState->DoClear();
|
||||||
|
|
||||||
@@ -2201,8 +2190,7 @@ void wxPropertyGrid::Clear()
|
|||||||
|
|
||||||
bool wxPropertyGrid::EnableCategories( bool enable )
|
bool wxPropertyGrid::EnableCategories( bool enable )
|
||||||
{
|
{
|
||||||
if ( !ClearSelection() )
|
ClearSelection(false);
|
||||||
return false;
|
|
||||||
|
|
||||||
if ( enable )
|
if ( enable )
|
||||||
{
|
{
|
||||||
@@ -2254,13 +2242,7 @@ void wxPropertyGrid::SwitchState( wxPropertyGridPageState* pNewState )
|
|||||||
|
|
||||||
wxPGProperty* oldSelection = m_selected;
|
wxPGProperty* oldSelection = m_selected;
|
||||||
|
|
||||||
// Deselect
|
ClearSelection(false);
|
||||||
if ( m_selected )
|
|
||||||
{
|
|
||||||
bool selRes = ClearSelection();
|
|
||||||
wxPG_CHECK_RET_DBG( selRes,
|
|
||||||
wxT("failed to deselect a property (editor probably had invalid value)") );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pState->m_selected = oldSelection;
|
m_pState->m_selected = oldSelection;
|
||||||
|
|
||||||
@@ -2328,9 +2310,7 @@ void wxPropertyGrid::SortChildren( wxPGPropArg id )
|
|||||||
|
|
||||||
void wxPropertyGrid::Sort()
|
void wxPropertyGrid::Sort()
|
||||||
{
|
{
|
||||||
bool selRes = ClearSelection(); // This must be before state clear
|
ClearSelection(false); // This must be before state clear
|
||||||
wxPG_CHECK_RET_DBG( selRes,
|
|
||||||
wxT("failed to deselect a property (editor probably had invalid value)") );
|
|
||||||
|
|
||||||
m_pState->Sort();
|
m_pState->Sort();
|
||||||
}
|
}
|
||||||
@@ -3666,10 +3646,9 @@ bool wxPropertyGrid::DoCollapse( wxPGProperty* p, bool sendEvents )
|
|||||||
wxPGProperty* pwc = wxStaticCast(p, wxPGProperty);
|
wxPGProperty* pwc = wxStaticCast(p, wxPGProperty);
|
||||||
|
|
||||||
// If active editor was inside collapsed section, then disable it
|
// If active editor was inside collapsed section, then disable it
|
||||||
if ( m_selected && m_selected->IsSomeParent (p) )
|
if ( m_selected && m_selected->IsSomeParent(p) )
|
||||||
{
|
{
|
||||||
if ( !ClearSelection() )
|
ClearSelection(false);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store dont-center-splitter flag 'cause we need to temporarily set it
|
// Store dont-center-splitter flag 'cause we need to temporarily set it
|
||||||
@@ -3754,8 +3733,7 @@ bool wxPropertyGrid::DoHideProperty( wxPGProperty* p, bool hide, int flags )
|
|||||||
( m_selected == p || m_selected->IsSomeParent(p) )
|
( m_selected == p || m_selected->IsSomeParent(p) )
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ( !ClearSelection() )
|
ClearSelection(false);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pState->DoHideProperty(p, hide, flags);
|
m_pState->DoHideProperty(p, hide, flags);
|
||||||
|
@@ -315,11 +315,7 @@ void wxPropertyGridInterface::DeleteProperty( wxPGPropArg id )
|
|||||||
wxPropertyGrid* grid = state->GetGrid();
|
wxPropertyGrid* grid = state->GetGrid();
|
||||||
|
|
||||||
if ( grid->GetState() == state )
|
if ( grid->GetState() == state )
|
||||||
{
|
grid->DoSelectProperty(NULL, wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE);
|
||||||
bool selRes = grid->DoSelectProperty(NULL, wxPG_SEL_DELETING);
|
|
||||||
wxPG_CHECK_RET_DBG( selRes,
|
|
||||||
wxT("failed to deselect a property (editor probably had invalid value)") );
|
|
||||||
}
|
|
||||||
|
|
||||||
state->DoDelete( p );
|
state->DoDelete( p );
|
||||||
|
|
||||||
@@ -358,12 +354,16 @@ wxPGProperty* wxPropertyGridInterface::ReplaceProperty( wxPGPropArg id, wxPGProp
|
|||||||
// wxPropertyGridInterface property operations
|
// wxPropertyGridInterface property operations
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxPropertyGridInterface::ClearSelection()
|
bool wxPropertyGridInterface::ClearSelection( bool validation )
|
||||||
{
|
{
|
||||||
|
int flags = 0;
|
||||||
|
if ( !validation )
|
||||||
|
flags |= wxPG_SEL_NOVALIDATE;
|
||||||
|
|
||||||
wxPropertyGridPageState* state = m_pState;
|
wxPropertyGridPageState* state = m_pState;
|
||||||
wxPropertyGrid* pg = state->GetGrid();
|
wxPropertyGrid* pg = state->GetGrid();
|
||||||
if ( pg->GetState() == state )
|
if ( pg->GetState() == state )
|
||||||
return pg->DoClearSelection();
|
return pg->DoSelectProperty(NULL, flags);
|
||||||
else
|
else
|
||||||
state->SetSelection(NULL);
|
state->SetSelection(NULL);
|
||||||
return true;
|
return true;
|
||||||
@@ -428,8 +428,7 @@ bool wxPropertyGridInterface::ExpandAll( bool doExpand )
|
|||||||
if ( GetSelection() && GetSelection() != state->DoGetRoot() &&
|
if ( GetSelection() && GetSelection() != state->DoGetRoot() &&
|
||||||
!doExpand )
|
!doExpand )
|
||||||
{
|
{
|
||||||
if ( !pg->ClearSelection() )
|
pg->ClearSelection(false);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPGVIterator it;
|
wxPGVIterator it;
|
||||||
|
@@ -1565,13 +1565,8 @@ bool wxPropertyGridPageState::PrepareToAddItem( wxPGProperty* property,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Make sure nothing is selected.
|
// Make sure nothing is selected.
|
||||||
if ( propGrid && propGrid->m_selected )
|
if ( propGrid )
|
||||||
{
|
propGrid->ClearSelection(false);
|
||||||
bool selRes = propGrid->ClearSelection();
|
|
||||||
wxPG_CHECK_MSG_DBG( selRes,
|
|
||||||
true,
|
|
||||||
wxT("failed to deselect a property (editor probably had invalid value)") );
|
|
||||||
}
|
|
||||||
|
|
||||||
// NULL parent == root parent
|
// NULL parent == root parent
|
||||||
if ( !scheduledParent )
|
if ( !scheduledParent )
|
||||||
|
Reference in New Issue
Block a user