View Issue Details

IDProjectCategoryView StatusLast Update
0004468JEDI VCL00 JVCL Componentspublic2008-10-05 15:38
ReportergcornuAssigned Tojfudickar 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.30 
Target VersionFixed in Version 
Summary0004468: TjvDBGrid,
DescriptionIn TjvDBGrid, using BooleanEditor and CheckIfBooleanField on an integer field to
get a checkbox editor.
When I first click on the checkbox, a value of 10 (ten) is written in the field instead of 1 (one).
Digging into the code I found the origin of the flaw in ChangeBoolean procedure.
with an initial null value in the field and a FieldValueChange=9 (toggle flag)
you enter in
"if FBooleanFieldToEdit.IsNull or (FieldValueChange <> JvGridBool_INVERT) then" and end in
"FBooleanFieldToEdit.Value := FieldValueChange + 1"
where the value 9 (FieldValueChange) + 1 is written ending with a 10 value !!
see additional information for suggested corrected code.
Additional Informationprocedure TJvDBGrid.ChangeBoolean(const FieldValueChange: Shortint);
// FieldValueChange = 9 -> invert, 0 -> check (true), -1 -> uncheck (false)
begin
  if Assigned(FBooleanFieldToEdit) and BooleanEditor then
  begin
    DataLink.Edit;
    if DataLink.Editing then
    begin
      if FBooleanFieldToEdit.IsNull or (FieldValueChange <> JvGridBool_INVERT) then
      begin
        case FBooleanFieldToEdit.DataType of
          ftBoolean:
            FBooleanFieldToEdit.Value := (FieldValueChange = JvGridBool_CHECK);
          ftString, ftWideString:
            begin
              if FieldValueChange = JvGridBool_CHECK then
                FBooleanFieldToEdit.Value := FStringForTrue
              else
                FBooleanFieldToEdit.Value := FStringForFalse;
            end;
        else
          // ******* START OF CORRECTION ******
          if FieldValueChange <> JvGridBool_INVERT then
            FBooleanFieldToEdit.Value := FieldValueChange + 1
          else
            FBooleanFieldToEdit.Value := 1;
          // ******* END **********************
        end;
      end
      else
        case FBooleanFieldToEdit.DataType of
          ftBoolean:
            FBooleanFieldToEdit.Value := not FBooleanFieldToEdit.AsBoolean;
          ftString, ftWideString:
            begin
              if AnsiSameText(FBooleanFieldToEdit.AsString, FStringForTrue) then
                FBooleanFieldToEdit.Value := FStringForFalse
              else
                FBooleanFieldToEdit.Value := FStringForTrue;
            end;
        else
          FBooleanFieldToEdit.Value := 1 - Abs(FBooleanFieldToEdit.AsInteger);
        end;
      InvalidateCell(Col, Row);
    end;
  end;
  FBooleanFieldToEdit := nil;
end;
TagsNo tags attached.

Activities

jfudickar

2008-09-24 14:57

developer   ~0014671

Could you please create a small sample which shows this behaviour.

It would help debugging the problem and your solution.

Greetings and thanks
Jens

2008-09-25 01:47

 

[JEDI VCL 0004468].zip (4,439 bytes)

gcornu

2008-09-25 01:50

reporter   ~0014686

Hello, I've just uploaded a sample demonstrating the bug.
It uses standard components from Delphi and of course JVCL.
You'll find also a screenshot showing the bug

Thanks for your good work on JVCL
Guillaume

jfudickar

2008-10-05 15:36

developer   ~0014757

Commited to svn.

Thanks for your analysis.

Issue History

Date Modified Username Field Change
2008-09-22 04:57 gcornu New Issue
2008-09-24 14:57 jfudickar Note Added: 0014671
2008-09-24 14:58 jfudickar Status new => feedback
2008-09-25 01:47 gcornu File Added: [JEDI VCL 0004468].zip
2008-09-25 01:50 gcornu Note Added: 0014686
2008-10-05 15:36 jfudickar Status feedback => resolved
2008-10-05 15:36 jfudickar Resolution open => fixed
2008-10-05 15:36 jfudickar Assigned To => jfudickar
2008-10-05 15:36 jfudickar Note Added: 0014757