mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 09:40:27 +02:00
Qt5,Qt6: track dangling pointer inside mouse release event if LCLObject is freed.
(cherry picked from commit db0a10f032
)
This commit is contained in:
parent
a877f4fbec
commit
71cb35ad12
@ -3685,6 +3685,7 @@ var
|
||||
SaveWidget: QWidgetH;
|
||||
LazButton: Byte;
|
||||
LazPos: TPoint;
|
||||
SavedLCLControl: PtrUInt;
|
||||
begin
|
||||
{$ifdef VerboseQt}
|
||||
WriteLn('TQtWidget.SlotMouse ',DbgSName(Self));
|
||||
@ -3752,15 +3753,22 @@ begin
|
||||
Include(FOwner.FWidgetState, qtwsInsideMouseDoubleClickEvent);
|
||||
Include(FWidgetState, qtwsInsideMouseDoubleClickEvent);
|
||||
end;
|
||||
SavedLCLControl := PtrUInt(LCLObject);
|
||||
try
|
||||
|
||||
NotifyApplicationUserInput(LCLObject, Msg.Msg);
|
||||
|
||||
if (SavedLCLControl <> PtrUInt(LCLObject)) then
|
||||
exit(True);
|
||||
|
||||
if not CanSendLCLMessage or (Sender = nil) then
|
||||
exit(True);
|
||||
|
||||
DeliverMessage(Msg, True);
|
||||
|
||||
if (SavedLCLControl <> PtrUInt(LCLObject)) then
|
||||
exit(True);
|
||||
|
||||
finally
|
||||
if qtwsInsideMouseDoubleClickEvent in FWidgetState then
|
||||
begin
|
||||
@ -3789,6 +3797,7 @@ begin
|
||||
QEventMouseButtonRelease:
|
||||
begin
|
||||
SaveWidget := nil;
|
||||
SavedLCLControl := PtrUInt(LCLObject);
|
||||
if (FChildOfComplexWidget = ccwCustomControl) and (FOwner <> nil) then
|
||||
SaveWidget := Widget;
|
||||
|
||||
@ -3797,13 +3806,20 @@ begin
|
||||
if (SaveWidget <> nil) and (SaveWidget <> Widget) then
|
||||
exit(True);
|
||||
|
||||
if (SavedLCLControl <> PtrUInt(LCLObject)) then
|
||||
exit(True);
|
||||
|
||||
if not CanSendLCLMessage or (Sender = nil) then
|
||||
exit(True);
|
||||
|
||||
DeliverMessage(Msg, True);
|
||||
|
||||
if (SaveWidget <> nil) and (SaveWidget <> Widget) then
|
||||
exit(True);
|
||||
|
||||
if (SavedLCLControl <> PtrUInt(LCLObject)) then
|
||||
exit(True);
|
||||
|
||||
// Check if our objects exists since LCL can destroy object during
|
||||
// mouse events...
|
||||
if CanSendLCLMessage and (Sender <> nil) then
|
||||
|
@ -3684,6 +3684,7 @@ var
|
||||
SaveWidget: QWidgetH;
|
||||
LazButton: Byte;
|
||||
LazPos: TPoint;
|
||||
SavedLCLControl: PtrUInt;
|
||||
begin
|
||||
{$ifdef VerboseQt}
|
||||
WriteLn('TQtWidget.SlotMouse ',DbgSName(Self));
|
||||
@ -3751,15 +3752,22 @@ begin
|
||||
Include(FOwner.FWidgetState, qtwsInsideMouseDoubleClickEvent);
|
||||
Include(FWidgetState, qtwsInsideMouseDoubleClickEvent);
|
||||
end;
|
||||
SavedLCLControl := PtrUInt(LCLObject);
|
||||
try
|
||||
|
||||
NotifyApplicationUserInput(LCLObject, Msg.Msg);
|
||||
|
||||
if (SavedLCLControl <> PtrUInt(LCLObject)) then
|
||||
exit(True);
|
||||
|
||||
if not CanSendLCLMessage or (Sender = nil) then
|
||||
exit(True);
|
||||
|
||||
DeliverMessage(Msg, True);
|
||||
|
||||
if (SavedLCLControl <> PtrUInt(LCLObject)) then
|
||||
exit(True);
|
||||
|
||||
finally
|
||||
if qtwsInsideMouseDoubleClickEvent in FWidgetState then
|
||||
begin
|
||||
@ -3788,6 +3796,7 @@ begin
|
||||
QEventMouseButtonRelease:
|
||||
begin
|
||||
SaveWidget := nil;
|
||||
SavedLCLControl := PtrUInt(LCLObject);
|
||||
if (FChildOfComplexWidget = ccwCustomControl) and (FOwner <> nil) then
|
||||
SaveWidget := Widget;
|
||||
|
||||
@ -3796,13 +3805,20 @@ begin
|
||||
if (SaveWidget <> nil) and (SaveWidget <> Widget) then
|
||||
exit(True);
|
||||
|
||||
if (SavedLCLControl <> PtrUInt(LCLObject)) then
|
||||
exit(True);
|
||||
|
||||
if not CanSendLCLMessage or (Sender = nil) then
|
||||
exit(True);
|
||||
|
||||
DeliverMessage(Msg, True);
|
||||
|
||||
if (SaveWidget <> nil) and (SaveWidget <> Widget) then
|
||||
exit(True);
|
||||
|
||||
if (SavedLCLControl <> PtrUInt(LCLObject)) then
|
||||
exit(True);
|
||||
|
||||
// Check if our objects exists since LCL can destroy object during
|
||||
// mouse events...
|
||||
if CanSendLCLMessage and (Sender <> nil) then
|
||||
|
Loading…
Reference in New Issue
Block a user