LCL-QT5: Better debugging for Invalid handle in TQtWSWinControl.SetText.

git-svn-id: trunk@62716 -
This commit is contained in:
juha 2020-03-08 15:58:24 +00:00
parent 45ba784bd8
commit 2b84e231a5
2 changed files with 23 additions and 9 deletions

View File

@ -309,10 +309,19 @@ begin
Exit;
Wdgt := TQtWidget(AWinControl.Handle);
Assert(Assigned(Wdgt), 'TQtWSWinControl.SetText: AWinControl.Handle=Nil');
DebugLn(['TQtWSWinControl.SetText: Widget.ClassName=', Wdgt.ClassName]);
Wdgt.BeginUpdate;
Wdgt.setText(GetUtf8String(AText));
Wdgt.EndUpdate;
try
DebugLn(['TQtWSWinControl.SetText: Widget.ClassName=', Wdgt.ClassName]);
if not QtWidgetSet.IsValidHandle(AWinControl.Handle) then
DebugLn(['TQtWSWinControl.SetText: "', Wdgt.ClassName,
'" has invalid handle=$', IntToHex(AWinControl.Handle,SizeOf(HWND)*2)]);
Wdgt.BeginUpdate;
Wdgt.setText(GetUtf8String(AText));
Wdgt.EndUpdate;
except
on E: Exception do
DebugLn(['TQtWSWinControl.SetText: "', E.Message, '" with "',
Wdgt.ClassName, '", handle=$', IntToHex(AWinControl.Handle,SizeOf(HWND)*2)]);
end;
end;
class procedure TQtWSWinControl.SetChildZPosition(const AWinControl,

View File

@ -27,6 +27,8 @@ uses
qtobjects, qtwidgets, qtproc,
// LCL
SysUtils, Classes, types, Controls, LCLType, Forms,
// LazUtils
LazLoggerBase,
// Widgetset
InterfaceBase, WSForms, WSProc, WSLCLClasses;
@ -1041,8 +1043,7 @@ begin
end;
end;
class function TQtWSCustomForm.CanFocus(const AWinControl: TWinControl
): Boolean;
class function TQtWSCustomForm.CanFocus(const AWinControl: TWinControl): Boolean;
var
Widget: TQtWidget;
begin
@ -1069,15 +1070,19 @@ end;
class procedure TQtWSHintWindow.ShowHide(const AWinControl: TWinControl);
var
AWidget: TQtHintWindow;
ToBeVisible: Boolean;
begin
DebugLn(['TQtWSHintWindow.ShowHide: Enter.']);
if not WSCheckHandleAllocated(AWinControl, 'ShowHide') then
Exit;
AWidget := TQtHintWindow(AWinControl.Handle);
ToBeVisible := AWinControl.HandleObjectShouldBeVisible;
DebugLn([' TQtWSHintWindow.ShowHide: Handle is ', AWidget.ClassName,
', Visible=', ToBeVisible]);
AWidget.BeginUpdate;
AWidget.setVisible(AWinControl.HandleObjectShouldBeVisible);
AWidget.setVisible(ToBeVisible);
AWidget.EndUpdate;
DebugLn([' TQtWSHintWindow.ShowHide: End.']);
end;
end.