Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002472 [JEDI VCL] 00 JVCL Components tweak always 2005-01-04 11:49 2005-01-04 15:33
Reporter Simes View Status public  
Assigned To
Priority normal Resolution fixed  
Status resolved   Product Version 3.00 BETA 2
Summary 0002472: TJvEditor doesn't invoke OnChange event for final undo
Description When undoing changes made to an instance of TJvEditor, undoing the final (or only) change doesn't invoke the OnChange or OnStatusChange events. This means, for example, that an editor caption may still have the "*" signifying the buffer has been changed, after all changes have been removed.
Additional Information Suggested change to file JvEditorCommon.pas (changes marked with //sda):

procedure TJvUndoBuffer.Undo;
var
  UndoClass: TClass;
  Compound: Integer;
  IsOnlyCaret: Boolean;
  Selection: TJvSelectionRec;

   function IsIntf(AInstance: TObject; IID: TGUID): Boolean; overload;
   begin
     Result := (AInstance <> nil) and (AInstance.GetInterfaceEntry(IID) <> nil);
   end;

   function IsIntf(AClass: TClass; IID: TGUID): Boolean; overload;
   begin
     Result := (AClass <> nil) and (AClass.GetInterfaceEntry(IID) <> nil);
   end;

var //sda
  WasModified: boolean; //sda
begin
  if InUndo then
    Exit;

  Selection := FJvEditor.FSelection;
  WasModified := FJvEditor.Modified; //sda

  IsOnlyCaret := True;
  InUndo := True;
  try
    if LastUndo <> nil then
    begin
      Compound := 0;
      UndoClass := LastUndo.ClassType;
      while (LastUndo <> nil) and
        ((UndoClass = LastUndo.ClassType) or
        {(LastUndo is TJvDeleteTrailUndo) or
        (LastUndo is TJvReLineUndo) or}
        IsIntf(LastUndo, IJvUndoCompound) or
        (Compound > 0)) or
        {((UndoClass = TJvBackspaceUndo) and
        (LastUndo is TJvBackspaceUnindentUndo)) do}
        IsIntf(UndoClass, IJvBackspaceUndo) and
        IsIntf(LastUndo, IJvBackspaceUnindentUndo) do
      begin
        if LastUndo.ClassType = TJvBeginCompoundUndo then
        begin
          Dec(Compound);
          UndoClass := nil;
        end
        else
        if LastUndo.ClassType = TJvEndCompoundUndo then
          Inc(Compound);
        LastUndo.Undo;
        if LastUndo <> nil then
        begin
          LastUndo.RestoreSelection;
          FJvEditor.Modified := LastUndo.FModified;
        end;
        Dec(FPtr);
        {if (UndoClass = TJvDeleteTrailUndo) or
          (UndoClass = TJvReLineUndo) then}
        if IsIntf(UndoClass, IJvUndoCompound) then
          UndoClass := LastUndo.ClassType;
        if (UndoClass <> TJvCaretUndo) and
          (UndoClass <> TJvSelectUndo) and
          (UndoClass <> TJvUnselectUndo) then
          IsOnlyCaret := False;
        if not FJvEditor.GroupUndo then
          Break;
      end;
      if not FJvEditor.Modified then
        IsOnlyCaret := True;

      // paint selection
      if not CompareMem(@Selection, @FJvEditor.FSelection, SizeOf(TJvSelectionRec)) then
        FJvEditor.PaintSelection;

      FJvEditor.UpdateEditorView;
      if FJvEditor.FUpdateLock = 0 then
        if not IsOnlyCaret then
          FJvEditor.Changed
        else if WasModified then //sda
          FJvEditor.StatusChanged; //sda
    end;
  finally
    InUndo := False;
  end;
end;
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0006090)
AHUser (developer)
2005-01-04 15:33

Thanks.

Fixed in CVS.

- Issue History
Date Modified Username Field Change
2005-01-04 11:49 Simes New Issue
2005-01-04 15:33 AHUser Status new => resolved
2005-01-04 15:33 AHUser Resolution open => fixed
2005-01-04 15:33 AHUser Assigned To => AHUser
2005-01-04 15:33 AHUser Note Added: 0006090
2005-01-04 15:33 AHUser Assigned To AHUser =>


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker