qt5: fixed crash with hints. issue #36773

git-svn-id: trunk@62726 -
This commit is contained in:
zeljko 2020-03-09 08:41:41 +00:00
parent 8b04de8ad2
commit c98da657b9
5 changed files with 45 additions and 3 deletions

View File

@ -177,6 +177,7 @@ type
// qt hints handles map (needed on X11 only)
procedure AddHintHandle(AHandle: TObject);
procedure RemoveHintHandle(AHandle: TObject);
procedure RemoveAllHintsHandles;
function IsValidHintHandle(AHandle: TObject): Boolean;
procedure HideAllHints;
procedure RestoreAllHints;

View File

@ -1435,6 +1435,37 @@ begin
System.LeaveCriticalsection(CriticalSection);
end;
procedure TQtWidgetSet.RemoveAllHintsHandles;
var
i: Integer;
AWidget: TQtHintWindow;
begin
System.EnterCriticalsection(CriticalSection);
try
if not Assigned(SavedHintHandlesList) then
exit;
for i := SavedHintHandlesList.Count - 1 downto 0 do
begin
if IsValidHintHandle(TObject(SavedHintHandlesList.Items[i])) then
begin
AWidget := TQtHintWindow(SavedHintHandlesList.Items[i]);
if Assigned(AWidget.LCLObject) and (AWidget.LCLObject.Parent = nil) and
(AWidget.LCLObject is THintWindow) then
begin
AWidget.BeginUpdate;
AWidget.LCLObject.Visible := False;
AWidget.Hide;
AWidget.EndUpdate;
AWidget.setParent(nil);
THintWindow(AWidget.LCLObject).ReleaseHandle;
end;
end;
end;
finally
System.LeaveCriticalsection(CriticalSection);
end;
end;
function TQtWidgetSet.IsValidHintHandle(AHandle: TObject): Boolean;
begin
if (AHandle = nil) then

View File

@ -18312,10 +18312,9 @@ begin
if AParams.WndParent <> 0 then
Parent := TQtWidget(AParams.WndParent).GetContainerWidget
else
{issue #36773
if QApplication_activeModalWidget <> nil then
Parent := QApplication_activeModalWidget
else}
else
Parent := nil;
Result := QWidget_create(Parent, QtToolTip);
FDeleteLater := True;

View File

@ -282,7 +282,8 @@ end;
class procedure TQtWSWinControl.GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean);
begin
Assert(AWinControl.HandleAllocated, 'GetPreferredSize: Handle not allocated');
if not WSCheckHandleAllocated(AWinControl, 'GetPreferredSize') then
Exit;
TQtWidget(AWinControl.Handle).PreferredSize(PreferredWidth, PreferredHeight, WithThemeSpace);
end;

View File

@ -265,6 +265,11 @@ end;
------------------------------------------------------------------------------}
class procedure TQtWSCustomForm.CloseModal(const ACustomForm: TCustomForm);
begin
{issue #36773}
{$IFDEF HASX11}
Application.CancelHint;
QtWidgetSet.RemoveAllHintsHandles;
{$ENDIF}
inherited CloseModal(ACustomForm);
end;
@ -662,6 +667,11 @@ end;
------------------------------------------------------------------------------}
class procedure TQtWSCustomForm.ShowModal(const ACustomForm: TCustomForm);
begin
{issue #36773}
{$IFDEF HASX11}
Application.CancelHint;
QtWidgetSet.RemoveAllHintsHandles;
{$ENDIF}
{
Setting modal flags is done in TQtWSCustomControl.ShowHide
Since that flags has effect only when Widget is not visible