prevent calling the Libman getter unless in the ctor

This commit is contained in:
Basile Burg 2019-02-03 15:05:28 +01:00
parent 13d7309439
commit 511bf285aa
1 changed files with 18 additions and 19 deletions

View File

@ -66,6 +66,7 @@ type
private private
fProj: ICommonProject; fProj: ICommonProject;
fFreeProj: ICommonProject; fFreeProj: ICommonProject;
fLibman: TLibraryManager;
procedure updateButtonsState; procedure updateButtonsState;
procedure projNew(project: ICommonProject); procedure projNew(project: ICommonProject);
procedure projChanged(project: ICommonProject); procedure projChanged(project: ICommonProject);
@ -104,6 +105,7 @@ constructor TLibManEditorWidget.Create(aOwner: TComponent);
begin begin
inherited; inherited;
TListViewCopyMenu.create(List); TListViewCopyMenu.create(List);
fLibman := LibMan;
end; end;
procedure TLibManEditorWidget.updateButtonsState; procedure TLibManEditorWidget.updateButtonsState;
@ -205,7 +207,7 @@ var
itm: TListItem; itm: TListItem;
begin begin
itm := List.Items.Add; itm := List.Items.Add;
itm.Data := LibMan.libraries.Add; itm.Data := fLibman.libraries.Add;
itm.Caption := notav; itm.Caption := notav;
itm.SubItems.Add(notav); itm.SubItems.Add(notav);
itm.SubItems.Add(notav); itm.SubItems.Add(notav);
@ -575,7 +577,7 @@ begin
if (ovw and not List.items.findCaption(nme, row)) or not ovw then if (ovw and not List.items.findCaption(nme, row)) or not ovw then
row := List.Items.Add; row := List.Items.Add;
if row.Data.isNil then if row.Data.isNil then
row.Data := LibMan.libraries.Add; row.Data := fLibman.libraries.Add;
row.Caption:= nme; row.Caption:= nme;
row.SubItems.Clear; row.SubItems.Clear;
nme := projectSourcePath(prj as ICommonProject); nme := projectSourcePath(prj as ICommonProject);
@ -608,7 +610,7 @@ begin
if (ovw and not List.items.findCaption(nme, row)) or not ovw then if (ovw and not List.items.findCaption(nme, row)) or not ovw then
row := List.Items.Add; row := List.Items.Add;
if row.Data.isNil then if row.Data.isNil then
row.Data := LibMan.libraries.Add; row.Data := fLibman.libraries.Add;
row.Caption := nme; row.Caption := nme;
row.SubItems.Clear; row.SubItems.Clear;
if prj.binaryKind = staticlib then if prj.binaryKind = staticlib then
@ -647,15 +649,15 @@ begin
al := List.Selected.Caption; al := List.Selected.Caption;
if inputQuery('library alias', '', al) then if inputQuery('library alias', '', al) then
begin begin
for i := 0 to LibMan.librariesCount-1 do for i := 0 to fLibman.librariesCount-1 do
if (LibMan.libraryByIndex[i].libAlias = al) and if (fLibman.libraryByIndex[i].libAlias = al) and
(LibMan.libraryByIndex[i] <> itemForRow(List.Selected)) then (fLibman.libraryByIndex[i] <> itemForRow(List.Selected)) then
begin begin
dlgOkError('This alias is already used by another library, the renaming is canceled'); dlgOkError('This alias is already used by another library, the renaming is canceled');
exit; exit;
end; end;
List.Selected.Caption := al; List.Selected.Caption := al;
LibMan.updateItemsByAlias; fLibman.updateItemsByAlias;
RowToLibrary(List.Selected); RowToLibrary(List.Selected);
end; end;
@ -737,7 +739,7 @@ begin
end; end;
row := List.Items.Add; row := List.Items.Add;
row.Data := LibMan.libraries.Add; row.Data := fLibman.libraries.Add;
row.Caption := lalias; row.Caption := lalias;
if (fname.extractFileExt <> libExt) then if (fname.extractFileExt <> libExt) then
begin begin
@ -775,7 +777,7 @@ begin
if List.Selected.isNil then if List.Selected.isNil then
exit; exit;
LibMan.libraries.Delete(List.Selected.Index); flibman.libraries.Delete(List.Selected.Index);
List.Items.Delete(List.Selected.Index); List.Items.Delete(List.Selected.Index);
updateButtonsState; updateButtonsState;
end; end;
@ -873,7 +875,7 @@ begin
i := list.Selected.Index; i := list.Selected.Index;
list.Items.Exchange(i, i - 1); list.Items.Exchange(i, i - 1);
LibMan.libraries.Exchange(i, i - 1); fLibman.libraries.Exchange(i, i - 1);
end; end;
procedure TLibManEditorWidget.btnMoveDownClick(Sender: TObject); procedure TLibManEditorWidget.btnMoveDownClick(Sender: TObject);
@ -885,7 +887,7 @@ begin
i := list.Selected.Index; i := list.Selected.Index;
list.Items.Exchange(i, i + 1); list.Items.Exchange(i, i + 1);
LibMan.libraries.Exchange(i, i + 1); fLibman.libraries.Exchange(i, i + 1);
end; end;
procedure TLibManEditorWidget.DoShow; procedure TLibManEditorWidget.DoShow;
@ -900,14 +902,11 @@ var
row: TListItem; row: TListItem;
i: Integer; i: Integer;
begin begin
if LibMan.isNil then
exit;
List.BeginUpdate; List.BeginUpdate;
List.Clear; List.Clear;
for i := 0 to LibMan.libraries.Count - 1 do for i := 0 to fLibman.libraries.Count - 1 do
begin begin
itm := TLibraryItem(LibMan.libraries.Items[i]); itm := TLibraryItem(flibman.libraries.Items[i]);
row := List.Items.Add; row := List.Items.Add;
row.Data:= itm; row.Data:= itm;
row.Caption := itm.libAlias; row.Caption := itm.libAlias;
@ -934,11 +933,11 @@ begin
itm.enabled := row.SubItems[3] = enableStr[true]; itm.enabled := row.SubItems[3] = enableStr[true];
itm.updateModulesInfo; itm.updateModulesInfo;
LibMan.updateDCD; fLibman.updateDCD;
if added then if added then
LibMan.updateCrossDependencies fLibman.updateCrossDependencies
else else
Libman.updateAfterAddition(itm); fLibman.updateAfterAddition(itm);
end; end;
end. end.