IDE: open loaded package dlg: do not keep package references

git-svn-id: trunk@41822 -
This commit is contained in:
mattias 2013-06-23 13:25:14 +00:00
parent db3fc39cbd
commit 9774750058

View File

@ -55,6 +55,7 @@ type
private private
function PkgStateToString(APackage: TLazPackage): string; function PkgStateToString(APackage: TLazPackage): string;
public public
Package: TLazPackage;
procedure UpdateSelection; procedure UpdateSelection;
procedure UpdatePackageList; procedure UpdatePackageList;
end; end;
@ -72,10 +73,8 @@ begin
UpdatePackageList; UpdatePackageList;
UpdateSelection; UpdateSelection;
Result:=ShowModal; Result:=ShowModal;
if Result=mrOK then begin if Result=mrOK then
Assert(Assigned(PkgListView.Selected), 'ShowOpenLoadedPkgDlg: Nothing selected'); OpenPackage:=Package
OpenPackage:=TLazPackage(PkgListView.Selected.Data);
end
else else
OpenPackage:=nil; OpenPackage:=nil;
finally finally
@ -105,22 +104,33 @@ begin
LI:=PkgListView.Selected; LI:=PkgListView.Selected;
ButtonPanel1.OKButton.Enabled:=Assigned(LI); ButtonPanel1.OKButton.Enabled:=Assigned(LI);
if Assigned(LI) then begin if Assigned(LI) then begin
CurPkg:=TLazPackage(LI.Data); CurPkg:=PackageGraph.FindPackageWithName(LI.Caption,nil);
HintStr:=Format(lisOIPFilename, [CurPkg.Filename]); if CurPkg=nil then
if CurPkg.Missing then HintMemo.Text:='Package "'+LI.Caption+'" was already closed'
HintStr:=Format(lisOIPThisPackageIsInstalledButTheLpkFileWasNotFound,[HintStr+LineEnding]); else begin
HintStr:=Format(lisOIPDescriptionDescription, [HintStr+LineEnding, HintStr:=Format(lisOIPFilename, [CurPkg.Filename]);
BreakString(CurPkg.Description, 60, length(lisOIPDescription))]); if CurPkg.Missing then
HintMemo.Text:=HintStr; HintStr:=Format(lisOIPThisPackageIsInstalledButTheLpkFileWasNotFound,[HintStr+LineEnding]);
HintStr:=Format(lisOIPDescriptionDescription, [HintStr+LineEnding,
BreakString(CurPkg.Description, 60, length(lisOIPDescription))]);
HintMemo.Text:=HintStr;
end;
end else begin end else begin
HintMemo.Text:=lisOIPPleaseSelectAPackage; HintMemo.Text:=lisOIPPleaseSelectAPackage;
end; end;
end; end;
procedure TOpenLoadedPackagesDlg.OpenButtonClick(Sender: TObject); procedure TOpenLoadedPackagesDlg.OpenButtonClick(Sender: TObject);
var
PkgName: String;
begin begin
Assert(Assigned(PkgListView.Selected), 'TOpenLoadedPackagesDlg.OpenButtonClick: Nothing selected'); if PkgListView.Selected=nil then exit;
ModalResult:=mrOk; PkgName:=PkgListView.Selected.Caption;
Package:=PackageGraph.FindPackageWithName(PkgName,nil);
if Package=nil then
ModalResult:=mrCancel
else
ModalResult:=mrOk;
end; end;
procedure TOpenLoadedPackagesDlg.FormCreate(Sender: TObject); procedure TOpenLoadedPackagesDlg.FormCreate(Sender: TObject);
@ -202,7 +212,6 @@ begin
CurListItem.SubItems.Add(PkgStateToString(CurPkg)); CurListItem.SubItems.Add(PkgStateToString(CurPkg));
end; end;
CurListItem.Caption:=CurPkg.Name; CurListItem.Caption:=CurPkg.Name;
CurListItem.Data:=CurPkg;
end; end;
PkgListView.EndUpdate; PkgListView.EndUpdate;
end; end;