Qt,Qt5: fixed AppRun when called with Application.Terminated - eg. app terminated in mainform.OnShow when using QtUseNativeEventLoop. part of Issue #34982

git-svn-id: branches/fixes_2_0@60289 -
This commit is contained in:
mattias 2019-02-02 18:44:59 +00:00
parent 7e5b882e03
commit 2c9ab572d6
4 changed files with 33 additions and 22 deletions

View File

@ -297,6 +297,13 @@ var
{$ENDIF} {$ENDIF}
begin begin
{$IFDEF QtUseNativeEventLoop} {$IFDEF QtUseNativeEventLoop}
if Application.Terminated then
begin
// application can be terminated in show event of mainform (before AppRun is called - see TApplication.Run. related to #34982)
if Assigned(ALoop) then
ALoop;
end else
begin
ATimer := QTimer_create(QCoreApplication_instance()); ATimer := QTimer_create(QCoreApplication_instance());
if (StyleName = 'gtk') or (StyleName = 'gtk+') then if (StyleName = 'gtk') or (StyleName = 'gtk+') then
QTimer_setInterval(ATimer, 1) {issue #31191} QTimer_setInterval(ATimer, 1) {issue #31191}
@ -305,6 +312,7 @@ begin
QTimer_start(ATimer); QTimer_start(ATimer);
FMainTimerID := QTimer_timerId(ATimer); FMainTimerID := QTimer_timerId(ATimer);
QApplication_exec(); QApplication_exec();
end;
{$ELSE} {$ELSE}
// use LCL loop // use LCL loop
if Assigned(ALoop) then if Assigned(ALoop) then

View File

@ -474,11 +474,9 @@ begin
ACustomForm := TCustomForm(AWinControl); ACustomForm := TCustomForm(AWinControl);
Widget := TQtMainWindow(AWinControl.Handle); Widget := TQtMainWindow(AWinControl.Handle);
{$IFNDEF QtUseNativeEventLoop}
{issue #34982} {issue #34982}
if AWinControl.HandleObjectShouldBeVisible and Application.Terminated then if AWinControl.HandleObjectShouldBeVisible and Application.Terminated then
exit; exit;
{$ENDIF}
if AWinControl.HandleObjectShouldBeVisible then if AWinControl.HandleObjectShouldBeVisible then
begin begin

View File

@ -245,6 +245,13 @@ var
{$ENDIF} {$ENDIF}
begin begin
{$IFDEF QtUseNativeEventLoop} {$IFDEF QtUseNativeEventLoop}
if Application.Terminated then
begin
// application can be terminated in show event of mainform (before AppRun is called - see TApplication.Run. related to #34982)
if Assigned(ALoop) then
ALoop;
end else
begin
FMainTimerID := -1; FMainTimerID := -1;
ATimer := QTimer_Create(QCoreApplication_instance()); ATimer := QTimer_Create(QCoreApplication_instance());
if (StyleName = 'gtk') or (StyleName = 'gtk+') then if (StyleName = 'gtk') or (StyleName = 'gtk+') then
@ -254,6 +261,7 @@ begin
QTimer_start(ATimer); QTimer_start(ATimer);
FMainTimerID := QTimer_timerId(ATimer); FMainTimerID := QTimer_timerId(ATimer);
QApplication_exec(); QApplication_exec();
end;
{$ELSE} {$ELSE}
// use LCL loop // use LCL loop
if Assigned(ALoop) then if Assigned(ALoop) then

View File

@ -479,12 +479,9 @@ begin
Widget := TQtMainWindow(AWinControl.Handle); Widget := TQtMainWindow(AWinControl.Handle);
{$IFNDEF QtUseNativeEventLoop}
{issue #34982} {issue #34982}
if AWinControl.HandleObjectShouldBeVisible and Application.Terminated then if AWinControl.HandleObjectShouldBeVisible and Application.Terminated then
exit; exit;
{$ENDIF}
if AWinControl.HandleObjectShouldBeVisible then if AWinControl.HandleObjectShouldBeVisible then
begin begin