]> git.saurik.com Git - wxWidgets.git/commitdiff
Redundant wxPropertyGrid validation failure message boxes should no longer be shown
authorJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 4 Jul 2010 09:46:43 +0000 (09:46 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 4 Jul 2010 09:46:43 +0000 (09:46 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64810 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/propgrid.h
src/propgrid/propgrid.cpp

index 7d37883174aff3d09e784209bb5d7b89427d444f..62d43e27458367cbfd091d239048ed3b1ead0315 100644 (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
index d27df9c92d716f921bf165e537b63d9f850b88e2..1774f76d099fb33458ee39ce1d45f063d18e790a 100644 (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);