On Android an application can be closed by first being backgrounded and then cleared, in which case Qt.application.state will transition to Qt.ApplicationInactive and then Qt.ApplicationSuspended, whereafter it will just get killed. No destructors called.
In that case, the QML Settings component doesn't properly persist its properties.
In the attached out.log can be seen the debug output of three separate launches of the minimal app also attached.
- The value of foo is the default value of . The app is closed via the Android back button, resulting in a proper close. A new value of is written to foo before close.
- The value of foo is , as set in the previous launch. The app is closed by first backgrounding it and then clearing it. A new value of 0. is written to foo, before the app is killed.
- The value of foo is still , as it was before the second launch. The Settings component failed to persist the new value of to foo.
Expected behaviour would be for the new value of to be persisted.
One possible solution would be to expose the sync() method of the inner QSettings pointer to the outside QML component.
That way it would be possible to explicitly trigger a save from within QML to make sure properties are persisted as soon as the app is backgrounded.