IDE: designer: undo: using beginupdate/endupdate to trigger less events

git-svn-id: trunk@57986 -
This commit is contained in:
mattias 2018-05-21 09:31:59 +00:00
parent 00ff76e8f7
commit 362d5edb4f
2 changed files with 32 additions and 24 deletions

View File

@ -6531,13 +6531,13 @@ begin
LookupRoot:=NewLookupRoot; LookupRoot:=NewLookupRoot;
// set selection // set selection
if ASelection=nil then exit; if ASelection=nil then exit;
//writeln('TPropertyEditorHook.SetSelection A ASelection.Count=',ASelection.Count); //debulgn(['TPropertyEditorHook.SetSelection A ASelection.Count=',ASelection.Count]);
i:=GetHandlerCount(htSetSelectedPersistents); i:=GetHandlerCount(htSetSelectedPersistents);
while GetNextHandlerIndex(htSetSelectedPersistents,i) do begin while GetNextHandlerIndex(htSetSelectedPersistents,i) do begin
Handler:=TPropHookSetSelection(FHandlers[htSetSelectedPersistents][i]); Handler:=TPropHookSetSelection(FHandlers[htSetSelectedPersistents][i]);
Handler(ASelection); Handler(ASelection);
end; end;
//writeln('TPropertyEditorHook.SetSelection END ASelection.Count=',ASelection.Count); //debugln(['TPropertyEditorHook.SetSelection END ASelection.Count=',ASelection.Count]);
end; end;
procedure TPropertyEditorHook.Unselect(const APersistent: TPersistent); procedure TPropertyEditorHook.Unselect(const APersistent: TPersistent);

View File

@ -1274,7 +1274,7 @@ end;
function TDesigner.DoInsertFromStream(s: TStream; function TDesigner.DoInsertFromStream(s: TStream;
PasteParent: TWinControl; PasteFlags: TComponentPasteSelectionFlags): Boolean; PasteParent: TWinControl; PasteFlags: TComponentPasteSelectionFlags): Boolean;
var var
NewSelection: TControlSelection; NewSelection: TPersistentSelectionList;
NewComponents: TFPList; NewComponents: TFPList;
procedure FindUniquePosition(AComponent: TComponent); procedure FindUniquePosition(AComponent: TComponent);
@ -1336,7 +1336,7 @@ begin
//debugln('TDesigner.DoInsertFromStream B s.Size=',dbgs(s.Size),' S.Position=',dbgs(S.Position)); //debugln('TDesigner.DoInsertFromStream B s.Size=',dbgs(s.Size),' S.Position=',dbgs(S.Position));
if PasteParent=nil then PasteParent:=GetPasteParent; if PasteParent=nil then PasteParent:=GetPasteParent;
NewSelection:=TControlSelection.Create; NewSelection:=TPersistentSelectionList.Create;
NewComponents:=TFPList.Create; NewComponents:=TFPList.Create;
try try
Form.DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TDesigner.DoInsertFromStream'){$ENDIF}; Form.DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TDesigner.DoInsertFromStream'){$ENDIF};
@ -1373,7 +1373,7 @@ begin
finally finally
NewComponents.Free; NewComponents.Free;
if NewSelection.Count>0 then if NewSelection.Count>0 then
Selection.Assign(NewSelection); Selection.AssignSelection(NewSelection);
NewSelection.Free; NewSelection.Free;
end; end;
Result:=true; Result:=true;
@ -1494,17 +1494,21 @@ begin
if (IsActUndo and (FUndoList[FUndoCurr].opType in [uopAdd])) or if (IsActUndo and (FUndoList[FUndoCurr].opType in [uopAdd])) or
(not IsActUndo and (FUndoList[FUndoCurr].opType in [uopDelete])) then (not IsActUndo and (FUndoList[FUndoCurr].opType in [uopDelete])) then
begin begin
SaveControlSelection := TControlSelection.Create; Selection.BeginUpdate;
try try
Inc(FUndoLock); SaveControlSelection := TControlSelection.Create;
SaveControlSelection.Assign(Selection); try
Selection.Clear; Inc(FUndoLock);
Selection.Add(FForm.FindComponent(FUndoList[FUndoCurr].compName)); SaveControlSelection.Assign(Selection);
DeleteSelection; Selection.AssignPersistent(FForm.FindComponent(FUndoList[FUndoCurr].compName));
DeleteSelection;
finally
Dec(FUndoLock);
Selection.Assign(SaveControlSelection);
SaveControlSelection.Free;
end;
finally finally
Dec(FUndoLock); Selection.EndUpdate;
Selection.Assign(SaveControlSelection);
SaveControlSelection.Free;
end; end;
end; end;
@ -1803,21 +1807,25 @@ begin
if (aOpType in [uopAdd, uopDelete]) and (FForm <> aPersistent) then if (aOpType in [uopAdd, uopDelete]) and (FForm <> aPersistent) then
begin begin
SaveControlSelection := TControlSelection.Create; Selection.BeginUpdate;
try try
SaveControlSelection.Assign(Selection); SaveControlSelection := TControlSelection.Create;
AStream := TStringStream.Create('');
try try
Selection.Clear; SaveControlSelection.Assign(Selection);
Selection.Add(aPersistent); AStream := TStringStream.Create('');
CopySelectionToStream(AStream); try
FUndoList[FUndoCurr].obj := AStream.DataString; Selection.AssignPersistent(aPersistent);
CopySelectionToStream(AStream);
FUndoList[FUndoCurr].obj := AStream.DataString;
finally
AStream.Free;
end;
finally finally
AStream.Free; Selection.Assign(SaveControlSelection);
SaveControlSelection.Free;
end; end;
finally finally
Selection.Assign(SaveControlSelection); Selection.EndUpdate;
SaveControlSelection.Free;
end; end;
end; end;