Qt6: fixed rare crash when QMainWindow is destroyed, removed unneeded FMenuBar.Widget destructor, it will be freed by it's parent.

This commit is contained in:
zeljan1 2025-06-03 18:44:28 +02:00
parent 5ca9daf80f
commit 72db9f09ff

View File

@ -6007,9 +6007,14 @@ var
begin
if (Widget <> nil) and FOwnWidget then
begin
ALCLEvent := QLCLMessageEvent_create(LCLQt_DestroyWidget, 0,
if QObject_inherits(Widget, 'QMainWindow') then
QMainWindow_Destroy(QMainWindowH(Widget))
else
begin
ALCLEvent := QLCLMessageEvent_create(LCLQt_DestroyWidget, 0,
0, 0, 0);
QCoreApplication_postEvent(Widget, ALCLEvent, Ord(QtHighEventPriority));
QCoreApplication_postEvent(Widget, ALCLEvent, Ord(QtHighEventPriority));
end;
end;
Widget := nil;
end;
@ -7403,11 +7408,6 @@ begin
if QtWidgetSet.IsValidHandle(HWND(FMenuBar)) then
begin
FMenuBar.DetachEvents;
if FOwnWidget and (FMenuBar.Widget <> nil) then
begin
QObject_deleteLater(FMenuBar.Widget);
FMenuBar.Widget := nil;
end;
FMenuBar.Widget := nil;
FreeThenNil(FMenuBar);
end;