IDE: added a sanity check about if ListView.Selected is assigned. Issue #19819

git-svn-id: trunk@33595 -
This commit is contained in:
juha 2011-11-17 20:16:25 +00:00
parent a002250d2b
commit e597ae1306

View File

@ -203,26 +203,27 @@ begin
NewFile:=TNewItemProjectFile(FNewItem);
if (NewFile.Descriptor is TFileDescInheritedItem) then
begin
AInheritedNode := nil;
// If we are inheriting from a form
if (NewFile.Descriptor is TFileDescInheritedComponent) then begin
InhCompItem:=TFileDescInheritedComponent(NewFile.Descriptor);
AInheritedNode := InheritableComponentsListView.Selected;
// load the ancestor component
AnUnitInfo:=TUnitInfo(AInheritedNode.Data);
if LazarusIDE.DoOpenComponent(AnUnitInfo.Filename,
[ofOnlyIfExists,ofQuiet,ofLoadHiddenResource,ofUseCache],[],
AncestorComponent)<>mrOk then
begin
MessageDlg(lisErrorOpeningComponent,
lisUnableToOpenAncestorComponent, mtError, [mbCancel], 0);
exit;
if Assigned(AInheritedNode) then begin
// load the ancestor component
AnUnitInfo:=TUnitInfo(AInheritedNode.Data);
if LazarusIDE.DoOpenComponent(AnUnitInfo.Filename,
[ofOnlyIfExists,ofQuiet,ofLoadHiddenResource,ofUseCache],[],
AncestorComponent)<>mrOk then
begin
MessageDlg(lisErrorOpeningComponent,
lisUnableToOpenAncestorComponent, mtError, [mbCancel], 0);
exit;
end;
// Set the resource class of the file descriptor
InhCompItem.ResourceClass := TPersistentClass(AncestorComponent.ClassType);
InhCompItem.InheritedUnit := AnUnitInfo;
InhCompItem.DeclareClassVariable := not AncestorComponent.ClassType.InheritsFrom(TFrame);
//DebugLn(['TNewOtherDialog.OKButtonClick ',InhCompItem.InheritedUnit.Filename,' ',dbgsname(InhCompItem.ResourceClass)]);
end;
// Set the resource class of the file descriptor
InhCompItem.ResourceClass := TPersistentClass(AncestorComponent.ClassType);
InhCompItem.InheritedUnit := AnUnitInfo;
InhCompItem.DeclareClassVariable := not AncestorComponent.ClassType.InheritsFrom(TFrame);
//DebugLn(['TNewOtherDialog.OKButtonClick ',InhCompItem.InheritedUnit.Filename,' ',dbgsname(InhCompItem.ResourceClass)]);
end
else
begin