LCL: Fix errors when using TMainMenu.Images and Bitmap. Issue #27069, patch from Denis Kozlov.

git-svn-id: trunk@46977 -
This commit is contained in:
juha 2014-11-23 21:31:58 +00:00
parent 45eab13451
commit 469cfdbb40
2 changed files with 5 additions and 5 deletions

View File

@ -937,14 +937,14 @@ begin
if HasIcon then if HasIcon then
begin begin
AImageList := GetImageList; AImageList := GetImageList;
if AImageList <> nil then if (AImageList <> nil) and (FImageIndex >= 0) then // using size of ImageList
begin begin
if (FImageIndex < 0) or (FImageIndex >= AImageList.Count) then if (FImageIndex >= AImageList.Count) then
Exit; Exit;
Result.x := AImageList.Width; Result.x := AImageList.Width;
Result.y := AImageList.Height; Result.y := AImageList.Height;
end end
else else // using size of Bitmap
begin begin
Result.x := Bitmap.Width; Result.x := Bitmap.Width;
Result.y := Bitmap.Height; Result.y := Bitmap.Height;

View File

@ -1098,7 +1098,7 @@ var
AImageIndex: Integer; AImageIndex: Integer;
begin begin
AImageList := AMenuItem.GetImageList; AImageList := AMenuItem.GetImageList;
if AImageList = nil then if (AImageList = nil) or (AMenuItem.ImageIndex < 0) then // using icon from Bitmap
begin begin
AImageList := TImageList.Create(nil); AImageList := TImageList.Create(nil);
AImageList.Width := AMenuItem.Bitmap.Width; // maybe height to prevent too wide bitmaps? AImageList.Width := AMenuItem.Bitmap.Width; // maybe height to prevent too wide bitmaps?
@ -1106,7 +1106,7 @@ begin
AImageIndex := AImageList.Add(AMenuItem.Bitmap, nil); AImageIndex := AImageList.Add(AMenuItem.Bitmap, nil);
FreeImageList := True; FreeImageList := True;
end end
else else // using icon from ImageList
begin begin
FreeImageList := False; FreeImageList := False;
AImageIndex := AMenuItem.ImageIndex; AImageIndex := AMenuItem.ImageIndex;