Reverted r64007 #0c525d9222 from branches/fixes_2_0 (LCL win: detect wincontrol destroy during WindProc / fixes Issue #28404) because it caused crashes

git-svn-id: branches/fixes_2_0@64032 -
This commit is contained in:
maxim 2020-10-16 23:39:29 +00:00
parent 3bb8fe51b5
commit c3e8aa2edf

View File

@ -294,8 +294,6 @@ type
TAccessCustomEdit = class(TCustomEdit);
TWindowProcHelper = class
private
procedure SetlWinControl(AValue: TWinControl);
private
// WindowProc parameters
Window: HWnd; // DWord / QWord
@ -305,7 +303,7 @@ type
// Other variables
LMessage: TLMessage;
PLMsg: PLMessage;
FlWinControl: TWinControl;
lWinControl: TWinControl;
WinProcess: Boolean;
NotifyUserInput: Boolean;
WindowInfo: PWin32WindowInfo;
@ -372,16 +370,7 @@ type
procedure UpdateLMMovePos(X, Y: Smallint);
procedure UpdateUIState(CharCode: Word);
function DoWindowProc: LResult; // Called from the actual WindowProc.
property lWinControl: TWinControl read FlWinControl write SetlWinControl;
end;
PWindowProcHelper = ^TWindowProcHelper;
{ TWindProcNotificationReceiver }
TWindProcNotificationReceiver = class
procedure ReceiveDestroyNotify(Sender: TObject);
end;
// Implementation of TWindowProcHelper
@ -500,18 +489,6 @@ begin
{$endif}
end;
procedure TWindowProcHelper.SetlWinControl(AValue: TWinControl);
begin
if FlWinControl = AValue then Exit;
if FlWinControl <> nil then
FlWinControl.RemoveHandlerOnBeforeDestruction(@TWindProcNotificationReceiver(@Self).ReceiveDestroyNotify);
FlWinControl := AValue;
if FlWinControl <> nil then
FlWinControl.AddHandlerOnBeforeDestruction(@TWindProcNotificationReceiver(@Self).ReceiveDestroyNotify);
end;
procedure TWindowProcHelper.CalcClipRgn(PaintRegion: HRGN);
var
nSize: DWORD;
@ -1949,14 +1926,6 @@ begin
end;
end;
{ TWindProcNotificationReceiver }
procedure TWindProcNotificationReceiver.ReceiveDestroyNotify(Sender: TObject);
begin
assert(PWindowProcHelper(Self)^.FlWinControl = Sender, 'TWindProcNotificationReceiver.ReceiveDestroyNotify: PWindowProcHelper(Self)^.FlWinControl = Sender');
PWindowProcHelper(Self)^.lWinControl := nil;
end;
// This is called from the actual WindowProc.
function TWindowProcHelper.DoWindowProc: LResult;
@ -1976,7 +1945,6 @@ const
WM_DPICHANGED = $02E0;
{$ENDIF}
begin
try
FillChar(LMessage, SizeOf(LMessage), 0);
PLMsg := @LMessage;
WinProcess := True;
@ -1989,7 +1957,6 @@ begin
end else begin
lWinControl := WindowInfo^.WinControl;
end;
if (IgnoreNextCharWindow <> 0) and ((Msg = WM_CHAR) or (Msg = WM_SYSCHAR)) then
begin
if IgnoreNextCharWindow = Window then
@ -2676,10 +2643,6 @@ begin
else if PLMsg = @LMNotify then Result := LMNotify.Result
else if PLMsg = @LMMouseEvent then Result := LMMouseEvent.Result
else Result := PLMsg^.Result;
finally
lWinControl := nil;
end;
end;
{------------------------------------------------------------------------------
@ -2714,7 +2677,6 @@ begin
finally
Helper.Free;
end;
Helper.lWinControl := nil;
end;
{$ifdef MSG_DEBUG}