(Qt): fix TPopupMenu mem leak

git-svn-id: trunk@11886 -
This commit is contained in:
paul 2007-08-30 16:28:13 +00:00
parent 184385e598
commit 45cafe9489
2 changed files with 6 additions and 13 deletions

View File

@ -240,6 +240,8 @@ end;
Dealocates a Menu Item
------------------------------------------------------------------------------}
class procedure TQtWSMenuItem.DestroyHandle(const AMenuItem: TMenuItem);
var
Obj: TObject;
begin
{$ifdef VerboseQt}
Write('[TQtWSMenuItem.DestroyHandle] Caption: ' + AMenuItem.Caption);
@ -249,18 +251,9 @@ begin
WriteLn('');
{$endif}
{ Apparently LCL tries to dealocate the handle of the menu item internal to TMenu,
but it doesn´t create a handle for it. Instead it just put´s the handle of the TMenu
on that item.
We can detect this menu item checking if HasParent is false }
if AMenuItem.HasParent then
begin
{ Here the menu item has a QMenuH handle
Obs: Commented because they cause access violations inside Qt
library on the Virtual Magnifying Glass
}
TQtMenu(AMenuItem.Handle).Free;
end;
Obj := TObject(AMenuItem.Handle);
if Obj is TQtMenu then
Obj.Free;
end;
{------------------------------------------------------------------------------

View File

@ -70,7 +70,7 @@ type
TWSMenuClass = class of TWSMenu;
TWSMenu = class(TWSLCLComponent)
class function CreateHandle(const AMenu: TMenu): HMENU; virtual;
class function CreateHandle(const AMenu: TMenu): HMENU; virtual;
class procedure BiDiModeChanged(const AMenu: TMenu); virtual;
end;