Redundant wxPropertyGrid validation failure message boxes should no longer be shown

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64810 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli 2010-07-04 09:46:43 +00:00
parent 4fb5dadb13
commit 03d47fcf07
2 changed files with 29 additions and 2 deletions

View File

@ -1940,6 +1940,8 @@ protected:
/** 1 if in DoSelectProperty() */
unsigned char m_inDoSelectProperty;
bool m_inOnValidationFailure;
wxPGVFBFlags m_permanentValidationFailureBehavior; // Set by app
// DoEditorValidate() recursion guard

View File

@ -344,6 +344,7 @@ void wxPropertyGrid::Init1()
m_inDoPropertyChanged = 0;
m_inCommitChangesFromEditor = 0;
m_inDoSelectProperty = 0;
m_inOnValidationFailure = false;
m_permanentValidationFailureBehavior = wxPG_VFB_DEFAULT;
m_dragStatus = 0;
m_mouseSide = 16;
@ -3185,7 +3186,27 @@ void wxPropertyGrid::DoHidePropertyError( wxPGProperty* WXUNUSED(property) )
bool wxPropertyGrid::OnValidationFailure( wxPGProperty* property,
wxVariant& invalidValue )
{
if ( m_inOnValidationFailure )
return true;
m_inOnValidationFailure = true;
wxON_BLOCK_EXIT_SET(m_inOnValidationFailure, false);
wxWindow* editor = GetEditorControl();
int vfb = m_validationInfo.m_failureBehavior;
if ( m_inDoSelectProperty )
{
// When property selection is being changed, do not display any
// messages, if some were already shown for this property.
if ( property->HasFlag(wxPG_PROP_INVALID_VALUE) )
{
m_validationInfo.m_failureBehavior =
vfb & ~(wxPG_VFB_SHOW_MESSAGE |
wxPG_VFB_SHOW_MESSAGEBOX |
wxPG_VFB_SHOW_MESSAGE_ON_STATUSBAR);
}
}
// First call property's handler
property->OnValidationFailure(invalidValue);
@ -3529,6 +3550,7 @@ void wxPropertyGrid::HandleCustomEditorEvent( wxEvent &event )
// Possibly, but very rare.
if ( !selected ||
selected->HasFlag(wxPG_PROP_BEING_DELETED) ||
m_inOnValidationFailure ||
// Also don't handle editor event if wxEVT_PG_CHANGED or
// similar is currently doing something (showing a
// message box, for instance).
@ -4058,8 +4080,6 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
// First, deactivate previous
if ( prevFirstSel )
{
OnValidationFailureReset(prevFirstSel);
// Must double-check if this is an selected in case of forceswitch
if ( p != prevFirstSel )
{
@ -4073,6 +4093,11 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
}
}
// This should be called after CommitChangesFromEditor(), so that
// OnValidationFailure() still has information on property's
// validation state.
OnValidationFailureReset(prevFirstSel);
FreeEditors();
m_iFlags &= ~(wxPG_FL_ABNORMAL_EDITOR);