mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:59:20 +02:00
fixed missing try..finally for unit dependencies update
git-svn-id: trunk@8131 -
This commit is contained in:
parent
5b55b57a08
commit
8b5ea3ffa8
@ -5809,9 +5809,11 @@ begin
|
|||||||
|
|
||||||
if not UnitDependenciesView.RootValid then begin
|
if not UnitDependenciesView.RootValid then begin
|
||||||
if Project1.MainUnitID>=0 then begin
|
if Project1.MainUnitID>=0 then begin
|
||||||
|
UnitDependenciesView.BeginUpdate;
|
||||||
UnitDependenciesView.RootFilename:=Project1.MainUnitInfo.Filename;
|
UnitDependenciesView.RootFilename:=Project1.MainUnitInfo.Filename;
|
||||||
UnitDependenciesView.RootShortFilename:=
|
UnitDependenciesView.RootShortFilename:=
|
||||||
ExtractFilename(Project1.MainUnitInfo.Filename);
|
ExtractFilename(Project1.MainUnitInfo.Filename);
|
||||||
|
UnitDependenciesView.EndUpdate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -171,10 +171,8 @@ type
|
|||||||
procedure ShowProjectButtonClick(Sender: TObject);
|
procedure ShowProjectButtonClick(Sender: TObject);
|
||||||
procedure UnitDependenciesViewClose(Sender: TObject;
|
procedure UnitDependenciesViewClose(Sender: TObject;
|
||||||
var CloseAction: TCloseAction);
|
var CloseAction: TCloseAction);
|
||||||
|
procedure UnitHistoryListEditingDone(Sender: TObject);
|
||||||
procedure UnitDependenciesViewResize(Sender: TObject);
|
procedure UnitDependenciesViewResize(Sender: TObject);
|
||||||
procedure UnitHistoryListChange(Sender: TObject);
|
|
||||||
procedure UnitHistoryListKeyUp(Sender: TObject; var Key: Word;
|
|
||||||
Shift: TShiftState);
|
|
||||||
procedure UnitTreeViewAdvancedCustomDrawItem(Sender: TCustomTreeView;
|
procedure UnitTreeViewAdvancedCustomDrawItem(Sender: TCustomTreeView;
|
||||||
Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage;
|
Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage;
|
||||||
var PaintImages, DefaultDraw: Boolean);
|
var PaintImages, DefaultDraw: Boolean);
|
||||||
@ -185,9 +183,13 @@ type
|
|||||||
procedure UnitTreeViewMouseDown(Sender: TOBject; Button: TMouseButton;
|
procedure UnitTreeViewMouseDown(Sender: TOBject; Button: TMouseButton;
|
||||||
Shift: TShiftState; X, Y: Integer);
|
Shift: TShiftState; X, Y: Integer);
|
||||||
private
|
private
|
||||||
|
FCommitUnitHistoryListSelectionNeeded: boolean;
|
||||||
FOnAccessingSources: TNotifyEvent;
|
FOnAccessingSources: TNotifyEvent;
|
||||||
FOnGetProjectMainFilename: TOnGetProjectMainFilename;
|
FOnGetProjectMainFilename: TOnGetProjectMainFilename;
|
||||||
FOnOpenFile: TOnOpenFile;
|
FOnOpenFile: TOnOpenFile;
|
||||||
|
FRefreshNeeded: boolean;
|
||||||
|
FRebuildTreeNeeded: boolean;
|
||||||
|
FRefreshHistoryListNeeded: boolean;
|
||||||
FRootCodeBuffer: TCodeBuffer;
|
FRootCodeBuffer: TCodeBuffer;
|
||||||
FRootFilename: string;
|
FRootFilename: string;
|
||||||
FRootNode: TUnitNode;
|
FRootNode: TUnitNode;
|
||||||
@ -199,6 +201,7 @@ type
|
|||||||
procedure RebuildTree;
|
procedure RebuildTree;
|
||||||
procedure SetRootFilename(const AValue: string);
|
procedure SetRootFilename(const AValue: string);
|
||||||
procedure SetRootShortFilename(const AValue: string);
|
procedure SetRootShortFilename(const AValue: string);
|
||||||
|
procedure CommitUnitHistoryListSelection;
|
||||||
protected
|
protected
|
||||||
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
||||||
public
|
public
|
||||||
@ -216,6 +219,7 @@ type
|
|||||||
property OnOpenFile: TOnOpenFile read FOnOpenFile write FOnOpenFile;
|
property OnOpenFile: TOnOpenFile read FOnOpenFile write FOnOpenFile;
|
||||||
property RootFilename: string read FRootFilename write SetRootFilename;
|
property RootFilename: string read FRootFilename write SetRootFilename;
|
||||||
property RootShortFilename: string read FRootShortFilename write SetRootShortFilename;
|
property RootShortFilename: string read FRootShortFilename write SetRootShortFilename;
|
||||||
|
property RefreshNeeded: boolean read FRefreshNeeded write FRefreshNeeded;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -271,21 +275,11 @@ begin
|
|||||||
DoResize;
|
DoResize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitDependenciesView.UnitHistoryListChange(Sender: TObject);
|
procedure TUnitDependenciesView.UnitHistoryListEditingDone(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
//DebugLn('TUnitDependenciesView.UnitHistoryListEditingDone ',UnitHistoryList.Text,' ',dbgs(UnitHistoryList.Items.IndexOf(UnitHistoryList.Text)));
|
||||||
if UnitHistoryList.Items.IndexOf(UnitHistoryList.Text)<0 then exit;
|
if UnitHistoryList.Items.IndexOf(UnitHistoryList.Text)<0 then exit;
|
||||||
//RootFilename:=ExpandFilename(UnitHistoryList.Text);
|
CommitUnitHistoryListSelection;
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TUnitDependenciesView.UnitHistoryListKeyUp(Sender: TObject;
|
|
||||||
var Key: Word; Shift: TShiftState);
|
|
||||||
var
|
|
||||||
NewFilename: string;
|
|
||||||
begin
|
|
||||||
if (Key=VK_RETURN) and (Shift=[]) then begin
|
|
||||||
NewFilename:=ExpandFilename(UnitHistoryList.Text);
|
|
||||||
RootFilename:=NewFilename;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitDependenciesView.UnitTreeViewAdvancedCustomDrawItem(
|
procedure TUnitDependenciesView.UnitTreeViewAdvancedCustomDrawItem(
|
||||||
@ -380,25 +374,36 @@ end;
|
|||||||
|
|
||||||
procedure TUnitDependenciesView.RebuildTree;
|
procedure TUnitDependenciesView.RebuildTree;
|
||||||
begin
|
begin
|
||||||
|
if FUpdateCount>0 then begin
|
||||||
|
FRebuildTreeNeeded:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
FRebuildTreeNeeded:=false;
|
||||||
|
|
||||||
CodeToolBoss.ActivateWriteLock;
|
CodeToolBoss.ActivateWriteLock;
|
||||||
BeginUpdate;
|
BeginUpdate;
|
||||||
|
try
|
||||||
ClearTree;
|
ClearTree;
|
||||||
if RootFilename='' then exit;
|
if RootFilename='' then exit;
|
||||||
FRootNode:=TUnitNode.Create;
|
FRootNode:=TUnitNode.Create;
|
||||||
FRootNode.CodeBuffer:=FRootCodeBuffer;
|
FRootNode.CodeBuffer:=FRootCodeBuffer;
|
||||||
FRootNode.Filename:=RootFilename;
|
FRootNode.Filename:=RootFilename;
|
||||||
|
//debugln('TUnitDependenciesView.RebuildTree RootFilename=',RootFilename);
|
||||||
FRootNode.ShortFilename:=FRootShortFilename;
|
FRootNode.ShortFilename:=FRootShortFilename;
|
||||||
UnitTreeView.Items.Clear;
|
UnitTreeView.Items.Clear;
|
||||||
FRootNode.TreeNode:=UnitTreeView.Items.Add(nil,'');
|
FRootNode.TreeNode:=UnitTreeView.Items.Add(nil,'');
|
||||||
FRootNode.CreateChilds;
|
FRootNode.CreateChilds;
|
||||||
|
|
||||||
|
finally
|
||||||
|
FRebuildTreeNeeded:=false;
|
||||||
EndUpdate;
|
EndUpdate;
|
||||||
CodeToolBoss.DeActivateWriteLock;
|
CodeToolBoss.DeActivateWriteLock;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitDependenciesView.SetRootFilename(const AValue: string);
|
procedure TUnitDependenciesView.SetRootFilename(const AValue: string);
|
||||||
begin
|
begin
|
||||||
|
//DebugLn('TUnitDependenciesView.SetRootFilename Old=',FRootFilename,' New',AValue);
|
||||||
if FRootFilename=AValue then exit;
|
if FRootFilename=AValue then exit;
|
||||||
FRootFilename:=AValue;
|
FRootFilename:=AValue;
|
||||||
FRootCodeBuffer:=CodeToolBoss.LoadFile(FRootFilename,false,false);
|
FRootCodeBuffer:=CodeToolBoss.LoadFile(FRootFilename,false,false);
|
||||||
@ -416,6 +421,18 @@ begin
|
|||||||
FRootNode.ShortFilename:=AValue;
|
FRootNode.ShortFilename:=AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TUnitDependenciesView.CommitUnitHistoryListSelection;
|
||||||
|
begin
|
||||||
|
//DebugLn('TUnitDependenciesView.CommitUnitHistoryListSelection Old=',FRootFilename,' New=',UnitHistoryList.Text,' FUpdateCount=',dbgs(FUpdateCount));
|
||||||
|
if FUpdateCount>0 then begin
|
||||||
|
FCommitUnitHistoryListSelectionNeeded:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
FCommitUnitHistoryListSelectionNeeded:=false;
|
||||||
|
if UnitHistoryList.Items.IndexOf(UnitHistoryList.Text)<0 then exit;
|
||||||
|
RootFilename:=ExpandFilename(UnitHistoryList.Text);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TUnitDependenciesView.KeyUp(var Key: Word; Shift: TShiftState);
|
procedure TUnitDependenciesView.KeyUp(var Key: Word; Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
inherited KeyUp(Key, Shift);
|
inherited KeyUp(Key, Shift);
|
||||||
@ -476,9 +493,7 @@ begin
|
|||||||
Top:=0;
|
Top:=0;
|
||||||
Width:=Parent.ClientWidth-Left;
|
Width:=Parent.ClientWidth-Left;
|
||||||
RefreshHistoryList;
|
RefreshHistoryList;
|
||||||
OnKeyUp:=@UnitHistoryListKeyUp;
|
OnEditingDone:=@UnitHistoryListEditingDone;
|
||||||
OnChange:=@UnitHistoryListChange;
|
|
||||||
Visible:=true;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
W:=90; //Used foro simplified the update
|
W:=90; //Used foro simplified the update
|
||||||
@ -492,7 +507,6 @@ begin
|
|||||||
Width:=W;
|
Width:=W;
|
||||||
Caption:=dlgUnitDepBrowse;
|
Caption:=dlgUnitDepBrowse;
|
||||||
OnClick:=@SelectUnitButtonClick;
|
OnClick:=@SelectUnitButtonClick;
|
||||||
Visible:=true;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
RefreshButton:=TBitBtn.Create(Self);
|
RefreshButton:=TBitBtn.Create(Self);
|
||||||
@ -506,7 +520,6 @@ begin
|
|||||||
Height:=SelectUnitButton.Height;
|
Height:=SelectUnitButton.Height;
|
||||||
Caption:=dlgUnitDepRefresh;
|
Caption:=dlgUnitDepRefresh;
|
||||||
OnClick:=@RefreshButtonClick;
|
OnClick:=@RefreshButtonClick;
|
||||||
Visible:=true;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ShowProjectButton:=TBitBtn.Create(Self);
|
ShowProjectButton:=TBitBtn.Create(Self);
|
||||||
@ -520,7 +533,6 @@ begin
|
|||||||
Height:=RefreshButton.Height;
|
Height:=RefreshButton.Height;
|
||||||
Caption:=dlgEnvProject;
|
Caption:=dlgEnvProject;
|
||||||
OnClick:=@ShowProjectButtonClick;
|
OnClick:=@ShowProjectButtonClick;
|
||||||
Visible:=true;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
UnitTreeView:=TTreeView.Create(Self);
|
UnitTreeView:=TTreeView.Create(Self);
|
||||||
@ -537,7 +549,6 @@ begin
|
|||||||
//StateImages:=SrcTypeImageList;
|
//StateImages:=SrcTypeImageList;
|
||||||
OnAdvancedCustomDrawItem:=@UnitTreeViewAdvancedCustomDrawItem;
|
OnAdvancedCustomDrawItem:=@UnitTreeViewAdvancedCustomDrawItem;
|
||||||
OnMouseDown:=@UnitTreeViewMouseDown;
|
OnMouseDown:=@UnitTreeViewMouseDown;
|
||||||
Visible:=true;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
OnResize:=@UnitDependenciesViewResize;
|
OnResize:=@UnitDependenciesViewResize;
|
||||||
@ -557,15 +568,31 @@ end;
|
|||||||
|
|
||||||
procedure TUnitDependenciesView.EndUpdate;
|
procedure TUnitDependenciesView.EndUpdate;
|
||||||
begin
|
begin
|
||||||
|
if FUpdateCount<0 then RaiseGDBException('TUnitDependenciesView.EndUpdate');
|
||||||
dec(FUpdateCount);
|
dec(FUpdateCount);
|
||||||
|
if FUpdateCount=0 then begin
|
||||||
|
if FCommitUnitHistoryListSelectionNeeded then
|
||||||
|
CommitUnitHistoryListSelection;
|
||||||
|
if FRefreshNeeded then
|
||||||
|
Refresh;
|
||||||
|
if FRebuildTreeNeeded then
|
||||||
|
RebuildTree;
|
||||||
|
if FRefreshHistoryListNeeded then
|
||||||
|
RefreshHistoryList;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitDependenciesView.Refresh;
|
procedure TUnitDependenciesView.Refresh;
|
||||||
var
|
var
|
||||||
ExpandState: TExpandedUnitNodeState;
|
ExpandState: TExpandedUnitNodeState;
|
||||||
begin
|
begin
|
||||||
if FUpdateCount>0 then exit;
|
if FUpdateCount>0 then begin
|
||||||
|
FRefreshNeeded:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
FRefreshNeeded:=false;
|
||||||
BeginUpdate;
|
BeginUpdate;
|
||||||
|
try
|
||||||
if Assigned(OnAccessingSources) then OnAccessingSources(Self);
|
if Assigned(OnAccessingSources) then OnAccessingSources(Self);
|
||||||
// save old expanded nodes
|
// save old expanded nodes
|
||||||
ExpandState:=TExpandedUnitNodeState.Create;
|
ExpandState:=TExpandedUnitNodeState.Create;
|
||||||
@ -575,11 +602,21 @@ begin
|
|||||||
// restore expanded state
|
// restore expanded state
|
||||||
ExpandState.AssignTo(FRootNode);
|
ExpandState.AssignTo(FRootNode);
|
||||||
ExpandState.Free;
|
ExpandState.Free;
|
||||||
|
finally
|
||||||
|
FRefreshNeeded:=false;
|
||||||
EndUpdate;
|
EndUpdate;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitDependenciesView.RefreshHistoryList;
|
procedure TUnitDependenciesView.RefreshHistoryList;
|
||||||
begin
|
begin
|
||||||
|
if FUpdateCount>0 then begin
|
||||||
|
FRefreshHistoryListNeeded:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
FRefreshHistoryListNeeded:=false;
|
||||||
|
BeginUpdate;
|
||||||
|
try
|
||||||
if RootFilename<>'' then
|
if RootFilename<>'' then
|
||||||
if not InputHistories.AddToUnitDependenciesHistory(RootFilename) then
|
if not InputHistories.AddToUnitDependenciesHistory(RootFilename) then
|
||||||
exit;
|
exit;
|
||||||
@ -588,6 +625,10 @@ begin
|
|||||||
UnitHistoryList.Text:=UnitHistoryList.Items[0]
|
UnitHistoryList.Text:=UnitHistoryList.Items[0]
|
||||||
else
|
else
|
||||||
UnitHistoryList.Text:=RootFilename;
|
UnitHistoryList.Text:=RootFilename;
|
||||||
|
finally
|
||||||
|
FRefreshHistoryListNeeded:=false;
|
||||||
|
EndUpdate;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TUnitNode }
|
{ TUnitNode }
|
||||||
|
Loading…
Reference in New Issue
Block a user