From 04b164fd2459af2f8ae46f7d5f826f2c1adffbc9 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 30 Jan 2019 15:22:13 -0800 Subject: [PATCH] Migrate shutdown hack applied to QtActivity to InterfaceActivity --- .../hifiinterface/InterfaceActivity.java | 21 ++++++++++++++++++- .../qt5/android/bindings/QtActivity.java | 20 +----------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java index b7d2157737..fce5c2553e 100644 --- a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java +++ b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java @@ -166,8 +166,27 @@ public class InterfaceActivity extends QtActivity implements WebViewFragment.OnW @Override protected void onDestroy() { - super.onDestroy(); nativeOnDestroy(); + /* + cduarte https://highfidelity.manuscript.com/f/cases/16712/App-freezes-on-opening-randomly + After Qt upgrade to 5.11 we had a black screen crash after closing the application with + the hardware button "Back" and trying to start the app again. It could only be fixed after + totally closing the app swiping it in the list of running apps. + This problem did not happen with the previous Qt version. + After analysing changes we came up with this case and change: + https://codereview.qt-project.org/#/c/218882/ + In summary they've moved libs loading to the same thread as main() and as a matter of correctness + in the onDestroy method in QtActivityDelegate, they exit that thread with `QtNative.m_qtThread.exit();` + That exit call is the main reason of this problem. + + In this fix we just replace the `QtApplication.invokeDelegate();` call that may end using the + entire onDestroy method including that thread exit line for other three lines that purposely + terminate qt (borrowed from QtActivityDelegate::onDestroy as well). + */ + QtNative.terminateQt(); + QtNative.setActivity(null, null); + System.exit(0); + super.onDestroy(); } @Override diff --git a/android/libraries/qt/src/main/java/org/qtproject/qt5/android/bindings/QtActivity.java b/android/libraries/qt/src/main/java/org/qtproject/qt5/android/bindings/QtActivity.java index 93ae2bc227..40e1863d69 100644 --- a/android/libraries/qt/src/main/java/org/qtproject/qt5/android/bindings/QtActivity.java +++ b/android/libraries/qt/src/main/java/org/qtproject/qt5/android/bindings/QtActivity.java @@ -364,25 +364,7 @@ public class QtActivity extends Activity { @Override protected void onDestroy() { super.onDestroy(); - /* - cduarte https://highfidelity.manuscript.com/f/cases/16712/App-freezes-on-opening-randomly - After Qt upgrade to 5.11 we had a black screen crash after closing the application with - the hardware button "Back" and trying to start the app again. It could only be fixed after - totally closing the app swiping it in the list of running apps. - This problem did not happen with the previous Qt version. - After analysing changes we came up with this case and change: - https://codereview.qt-project.org/#/c/218882/ - In summary they've moved libs loading to the same thread as main() and as a matter of correctness - in the onDestroy method in QtActivityDelegate, they exit that thread with `QtNative.m_qtThread.exit();` - That exit call is the main reason of this problem. - - In this fix we just replace the `QtApplication.invokeDelegate();` call that may end using the - entire onDestroy method including that thread exit line for other three lines that purposely - terminate qt (borrowed from QtActivityDelegate::onDestroy as well). - */ - QtNative.terminateQt(); - QtNative.setActivity(null, null); - System.exit(0); + QtApplication.invokeDelegate(); } //---------------------------------------------------------------------------