LCL: Fix errors when using TMainMenu.Images and Bitmap. Issue , 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
lcl
include
interfaces/win32

View File

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

View File

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