diff --git a/lcl/interfaces/qt/qtwsmenus.pp b/lcl/interfaces/qt/qtwsmenus.pp index 548816e539..62c46829dc 100644 --- a/lcl/interfaces/qt/qtwsmenus.pp +++ b/lcl/interfaces/qt/qtwsmenus.pp @@ -136,8 +136,13 @@ begin if (ImgList <> nil) and (AMenuItem.ImageIndex >= 0) and (AMenuItem.ImageIndex < ImgList.Count) then begin - ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, AMenuItem.Bitmap); // Qt bindings support only 16px icons for menu items - Result.setImage(TQtImage(AMenuItem.Bitmap.Handle)); + Bmp := TBitmap.Create; + try + ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, Bmp); // Qt bindings support only 16px icons for menu items + Result.setImage(TQtImage(Bmp.Handle)); + finally + Bmp.Free; + end; end else if Assigned(AMenuItem.Bitmap) then begin diff --git a/lcl/interfaces/qt5/qtwsmenus.pp b/lcl/interfaces/qt5/qtwsmenus.pp index 1e2f53d70f..2a3a83d87b 100644 --- a/lcl/interfaces/qt5/qtwsmenus.pp +++ b/lcl/interfaces/qt5/qtwsmenus.pp @@ -135,8 +135,13 @@ begin if (ImgList <> nil) and (AMenuItem.ImageIndex >= 0) and (AMenuItem.ImageIndex < ImgList.Count) then begin - ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, AMenuItem.Bitmap); // Qt bindings support only 16px icons for menu items - Result.setImage(TQtImage(AMenuItem.Bitmap.Handle)); + Bmp := TBitmap.Create; + try + ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, Bmp); // Qt bindings support only 16px icons for menu items + Result.setImage(TQtImage(Bmp.Handle)); + finally + Bmp.Free; + end; end else if Assigned(AMenuItem.Bitmap) then begin diff --git a/lcl/interfaces/qt6/qtwsmenus.pp b/lcl/interfaces/qt6/qtwsmenus.pp index ec54144d37..47d50dd9b3 100644 --- a/lcl/interfaces/qt6/qtwsmenus.pp +++ b/lcl/interfaces/qt6/qtwsmenus.pp @@ -135,8 +135,13 @@ begin if (ImgList <> nil) and (AMenuItem.ImageIndex >= 0) and (AMenuItem.ImageIndex < ImgList.Count) then begin - ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, AMenuItem.Bitmap); // Qt bindings support only 16px icons for menu items - Result.setImage(TQtImage(AMenuItem.Bitmap.Handle)); + Bmp := TBitmap.Create; + try + ImgList.ResolutionForPPI[16, ScreenInfo.PixelsPerInchX, 1].GetBitmap(AMenuItem.ImageIndex, Bmp); // Qt bindings support only 16px icons for menu items + Result.setImage(TQtImage(Bmp.Handle)); + finally + Bmp.Free; + end; end else if Assigned(AMenuItem.Bitmap) then begin