fixed mem leak

git-svn-id: trunk@7282 -
This commit is contained in:
mattias 2005-06-25 14:36:02 +00:00
parent fd711c2600
commit 7335ee16f1

View File

@ -451,13 +451,22 @@ var
Procedure LoadBitmap; Procedure LoadBitmap;
var var
ext : String; ext : String;
TempBitmap: TBitmap;
begin begin
Ext := ExtractFileExt(TheDialog.FileName); Ext := ExtractFileExt(TheDialog.FileName);
ABitmap := TBitmap.Create; if (CompareText(Ext, '.xpm') = 0)
if (AnsiCompareText(Ext, '.xpm') = 0) or (CompareText(Ext, '.bmp') = 0) then begin
or (AnsiCompareText(Ext, '.bmp') = 0) then begin If FileExists(TheDialog.FileName) then begin
If FileExists(TheDialog.FileName) then TempBitmap := TBitmap.Create;
ABitmap.LoadFromFile(TheDialog.FileName); try
// try to load
TempBitmap.LoadFromFile(TheDialog.FileName);
// no exception -> loading ok
ABitmap.Assign(TempBitmap);
finally
TempBitmap.Free;
end;
end;
end end
else begin else begin
ABitmap.Assign(TheDialog.Preview.Picture.Graphic); ABitmap.Assign(TheDialog.Preview.Picture.Graphic);
@ -472,7 +481,7 @@ var
end; end;
begin begin
debugln('TButtonGlyphPropEditor.Edit'); //debugln('TButtonGlyphPropEditor.Edit');
ABitmap := TBitmap(GetObjectValue(TBitmap)); ABitmap := TBitmap(GetObjectValue(TBitmap));
TheDialog := TGraphicPropertyEditorForm.Create(nil); TheDialog := TGraphicPropertyEditorForm.Create(nil);
try try
@ -490,7 +499,6 @@ begin
If TheDialog.Preview.Picture.Graphic <> nil then begin If TheDialog.Preview.Picture.Graphic <> nil then begin
if TheDialog.Modified then begin if TheDialog.Modified then begin
LoadBitmap; LoadBitmap;
SetPtrValue(ABitmap);
end; end;
end end
else begin else begin