View Issue Details

IDProjectCategoryView StatusLast Update
0002472JEDI VCL00 JVCL Componentspublic2005-01-04 15:33
ReporterSimesAssigned To 
PrioritynormalSeveritytweakReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 BETA 2 
Target VersionFixed in Version3.00 RC 1 
Summary0002472: TJvEditor doesn't invoke OnChange event for final undo
DescriptionWhen 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 InformationSuggested 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;
TagsNo tags attached.

Activities

AHUser

2005-01-04 15:33

developer   ~0006090

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 =>