Gtk3: fixed crash if handle vanish during input event.issue #41449

This commit is contained in:
zeljan1 2025-02-21 17:52:46 +01:00
parent 5710c5537a
commit d8cd947b55

View File

@ -2299,6 +2299,7 @@ var
MsgPopup : TLMMouse;
MousePos: TPoint;
MButton: guint;
SavedHandle: PtrUInt;
begin
Result := False;
{$IF DEFINED(GTK3DEBUGEVENTS) OR DEFINED(GTK3DEBUGMOUSE)}
@ -2309,6 +2310,8 @@ begin
if Event^.button.send_event = NO_PROPAGATION_TO_PARENT then
exit;
SavedHandle := PtrUInt(Self);
FillChar(Msg{%H-}, SizeOf(Msg), #0);
MousePos.x := Round(Event^.button.x);
@ -2395,6 +2398,9 @@ begin
Event^.button.send_event := NO_PROPAGATION_TO_PARENT;
Result := False;
if SavedHandle <> PtrUInt(Self) then
exit;
if Msg.Msg = LM_RBUTTONDOWN then
begin
MsgPopup := Msg;
@ -2402,9 +2408,17 @@ begin
MsgPopup.XPos := SmallInt(Round(Event^.button.x_root));
MsgPopup.YPos := SmallInt(Round(Event^.button.y_root));
DeliverMessage(MsgPopup, True);
if SavedHandle <> PtrUInt(Self) then
exit;
end;
if not Result then
begin
Result := DeliverMessage(Msg, True) <> 0;
if SavedHandle <> PtrUInt(Self) then
exit;
end;
if Event^.type_ = GDK_BUTTON_RELEASE then
begin
Msg.Msg := LM_CLICKED;