IDEIntf: fixed creation/freeing in TGraphicPropertyEditor.Edit

git-svn-id: trunk@15534 -
This commit is contained in:
mattias 2008-06-23 11:35:26 +00:00
parent ea148e0664
commit 3beabb68e9

View File

@ -175,9 +175,11 @@ procedure TGraphicPropertyEditor.Edit;
var var
TheDialog: TGraphicPropertyEditorForm; TheDialog: TGraphicPropertyEditorForm;
AGraphic: TGraphic; AGraphic: TGraphic;
FreeGraphic: Boolean;
begin begin
AGraphic := TGraphic(GetObjectValue(TGraphic)); AGraphic := TGraphic(GetObjectValue(TGraphic));
TheDialog := TGraphicPropertyEditorForm.Create(nil); TheDialog := TGraphicPropertyEditorForm.Create(nil);
FreeGraphic:=false;
try try
if (AGraphic <> nil) then if (AGraphic <> nil) then
TheDialog.Preview.Picture.Assign(AGraphic) TheDialog.Preview.Picture.Assign(AGraphic)
@ -192,11 +194,14 @@ begin
begin begin
{$Warnings off} {$Warnings off}
// TGraphic itself is an abstract class, so the compiler will warn // TGraphic itself is an abstract class, so the compiler will warn
if AGraphic = nil then if AGraphic = nil then begin
AGraphic := TGraphic(GetTypeData(GetPropType)^.ClassType).Create; AGraphic := TGraphic(GetTypeData(GetPropType)^.ClassType.Create).Create;
FreeGraphic:=true;
end;
{$Warnings on} {$Warnings on}
AGraphic.LoadFromFile(TheDialog.FileName); AGraphic.LoadFromFile(TheDialog.FileName);
FreeGraphic:=false;
SetPtrValue(AGraphic); SetPtrValue(AGraphic);
Modified; Modified;
end; end;
@ -209,6 +214,8 @@ begin
end; end;
end; end;
finally finally
if FreeGraphic then
AGraphic.Free;
TheDialog.Free; TheDialog.Free;
end; end;
end; end;