View Issue Details

IDProjectCategoryView StatusLast Update
0005768JEDI VCL00 JVCL Componentspublic2012-09-10 14:15
ReporterjkelleyAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.45 
Target VersionFixed in Version3.46 
Summary0005768: JvValidators problems clearing error indicators
DescriptionAs far as I can tell, TJvValidators fails to clear error indicators under the following circumstances:
- A validator failed validation (Valid := False) then was disabled (Enabled := False).
- A validator's ControlToValidate does not equal its ErrorControl.

In both cases, the problem appears to be with how the Controls array is handled in TJvValidators.Validate. The Controls array is intended to list controls whose error indicators should be cleared, but it's never initialized with the ControlToValidate properties for disabled validators, and it's never initialized with the ErrorControl properties, and on successful validation, the ErrorControl isn't cleared from Controls, even though ErrorControl is used to show the error indicator on failed validation.
TagsNo tags attached.

Activities

jkelley

2012-01-23 20:04

reporter   ~0019349

Here's a patch which, from my limited testing, fixes these issues.

2012-01-23 20:04

 

jvvalidatorsclear.diff (1,321 bytes)
Index: JvValidators.pas
===================================================================
--- JvValidators.pas	(revision 6925)
+++ JvValidators.pas	(working copy)
@@ -787,9 +787,14 @@
       { Get all controls that should be validated }
       if FErrorIndicator <> nil then
         for I := 0 to Count - 1 do
-          if Items[I].Enabled and (Items[I].ControlToValidate <> nil) then
-            if Controls.IndexOf(Items[I].ControlToValidate) = -1 then
-              Controls.Add(Items[I].ControlToValidate);
+        begin
+          ErrCtrl := Items[i].ErrorControl;
+          if ErrCtrl = nil then
+            ErrCtrl := Items[i].ControlToValidate;
+          if ErrCtrl <> nil then
+            if Controls.IndexOf(ErrCtrl) = -1 then
+              Controls.Add(ErrCtrl);
+        end;
 
       for I := 0 to Count - 1 do
       begin
@@ -809,7 +814,7 @@
               if ErrorIndicator <> nil then
                 FErrorIndicator.SetError(ErrCtrl, Items[I].ErrorMessage);
               if FErrorIndicator <> nil then
-                Controls.Remove(Items[I].ControlToValidate); { control is not valid }
+                Controls.Remove(ErrCtrl); { control is not valid }
             end;
             Result := False;
             if not DoValidateFailed(Items[I]) then
jvvalidatorsclear.diff (1,321 bytes)

obones

2012-02-22 15:06

administrator   ~0019460

Thank you for the patch. Can you provide the zipped sources of a sample application showing this?

obones

2012-06-13 16:29

administrator   ~0019977

Any news?

2012-06-14 14:47

 

Project1.rar (1,977,428 bytes)

2012-06-14 14:47

 

JVCL-0005802.rar (1,488 bytes)

Arioch

2012-06-15 15:46

developer   ~0020004

test added

obones

2012-06-18 14:15

administrator   ~0020016

This is now fixed in SVN

Issue History

Date Modified Username Field Change
2012-01-19 21:50 jkelley New Issue
2012-01-23 20:04 jkelley Note Added: 0019349
2012-01-23 20:04 jkelley File Added: jvvalidatorsclear.diff
2012-02-22 15:06 obones Note Added: 0019460
2012-02-22 15:06 obones Status new => feedback
2012-06-13 16:29 obones Note Added: 0019977
2012-06-14 14:47 Arioch File Added: Project1.rar
2012-06-14 14:47 Arioch File Added: JVCL-0005802.rar
2012-06-15 15:46 Arioch Note Added: 0020004
2012-06-18 11:24 obones Status feedback => acknowledged
2012-06-18 14:15 obones Note Added: 0020016
2012-06-18 14:15 obones Status acknowledged => resolved
2012-06-18 14:15 obones Fixed in Version => Daily / SVN
2012-06-18 14:15 obones Resolution open => fixed
2012-06-18 14:15 obones Assigned To => obones
2012-09-10 14:15 obones Fixed in Version Daily / SVN => 3.46