From 8915141c1e7fdfd5df93b17f0c9bf07d1f171343 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Sat, 3 Jul 2010 11:43:49 +0000 Subject: [PATCH] wxPropertyGrid validation failure was not (always) reset when a valid value was entered after an invalid one. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64795 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/propgrid.h | 13 +++++++++++++ src/propgrid/propgrid.cpp | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 973b9e2..1594894 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -420,6 +420,16 @@ class WXDLLIMPEXP_PROPGRID wxPGValidationInfo { friend class wxPropertyGrid; public: + wxPGValidationInfo() + { + m_failureBehavior = 0; + m_isFailing = false; + } + + ~wxPGValidationInfo() + { + } + /** @return Returns failure behavior which is a combination of @ref propgrid_vfbflags. @@ -468,6 +478,9 @@ private: /** Validation failure behavior. Use wxPG_VFB_XXX flags. */ wxPGVFBFlags m_failureBehavior; + + // True when validation is currently failing. + bool m_isFailing; }; // ----------------------------------------------------------------------- diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 9be3b2a..937ada1 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -2987,6 +2987,7 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue // m_validationInfo.m_failureBehavior = m_permanentValidationFailureBehavior; + m_validationInfo.m_isFailing = true; // // Variant list a special value that cannot be validated @@ -3119,6 +3120,8 @@ bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue pendingValue = value; } + m_validationInfo.m_isFailing = false; + return true; } @@ -3255,6 +3258,8 @@ void wxPropertyGrid::DoOnValidationFailureReset( wxPGProperty* property ) DrawItemAndChildren(property); } } + + m_validationInfo.m_isFailing = false; } // ----------------------------------------------------------------------- @@ -3271,6 +3276,9 @@ bool wxPropertyGrid::DoPropertyChanged( wxPGProperty* p, unsigned int selFlags ) m_inDoPropertyChanged = 1; + // If property's value is being changed, assume it is valid + OnValidationFailureReset(selected); + // Maybe need to update control wxASSERT( m_chgInfo_changedProperty != NULL ); @@ -3544,6 +3552,13 @@ void wxPropertyGrid::HandleCustomEditorEvent( wxEvent &event ) selected, wnd ) ) valueIsPending = true; + + // Mark value always as pending if validation is currently + // failing and value was not unspecified + if ( !valueIsPending && + !pendingValue.IsNull() && + m_validationInfo.m_isFailing ) + valueIsPending = true; } else { -- 2.7.4