QtQuick for Android: Do not terminate Qt during configuration change
In Android the default behavior is that when a configuration change, e.g. an orientation change, happens, the Activity is destroyed and a new one is created with the new configuration. In regular Qt for Android, this is not a problem as the QtActivity overrides this behavior and swicthes the configuration without recreating the Activity. However in QtQuick for Android i.e. when adding a QtQuickView to an otherwise regular Android app, we cannot rely on that being the case. Currently, if for example the orientation is changed with an Activity that has a QtQuickView in it and the default behavior is used, it will crash, as the destruction of the Activity will terminate the Qt runtime, and whne creating it anew the runtime is not properly restarted. This patch does not fix the underlying issue of not restaring the Qt runtime properly, but it adds a check so we don't terminate it when the reason for the Activity destruction is a configuration change, as in those cases it will anyway be recreated immediately, meaning a full termination is too heavyhanded anyway. Task-number: QTBUG-123711 Pick-to: 6.8 Change-Id: Ia44ab8f55855aa5d54c5fb25e3cca90a9c0feaaa Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
846b84ff30
commit
aef9fff1d7
@ -75,7 +75,10 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
if (m_activity == activity && m_stateDetails.isStarted) {
|
||||
// If the Activity was destroyed due to a configuration change, it will be recreated
|
||||
// instantly, so don't terminate Qt if that's the case
|
||||
if (m_activity == activity && m_stateDetails.isStarted &&
|
||||
!activity.isChangingConfigurations()) {
|
||||
m_activity.getApplication().unregisterActivityLifecycleCallbacks(this);
|
||||
QtNative.unregisterAppStateListener(QtEmbeddedDelegate.this);
|
||||
QtEmbeddedViewInterfaceFactory.remove(m_activity);
|
||||
|
Loading…
x
Reference in New Issue
Block a user