Android: Do not start Qt app if it has already been started

Call startQtApplication() in QtView even if the Qt libs
have already been loaded, to make sure the app gets started
also when the Activity is recreated. Check whether Qt app
is already running inside the method itself to avoid hanging up
because of trying to start it twice.

Task-number: QTBUG-123711
Change-Id: I3b009e4c2f40af9f258ce32b7e181c3faa21c194
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit be33f2d3233fb787d5251ba7d0876962efe49075)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit fbc78ff287586349600e508d55fde332def55b6d)
bb10
Tinja Paavoseppä 2024-11-26 14:17:38 +02:00 committed by Qt Cherry-pick Bot
parent dca4361b99
commit 4dbdb57358
2 changed files with 8 additions and 5 deletions

View File

@ -340,6 +340,9 @@ public class QtNative
static void startApplication(String params, String mainLib)
{
if (m_stateDetails.isStarted)
return;
QtThread thread = getQtThread();
thread.run(() -> {
final String qtParams = mainLib + " " + params;

View File

@ -155,14 +155,14 @@ abstract class QtView extends ViewGroup {
loader.setMainLibraryName(appLibName);
QtLoader.LoadingResult result = loader.loadQtLibraries();
if (result == QtLoader.LoadingResult.Succeeded) {
// Start Native Qt application
m_viewInterface.startQtApplication(loader.getApplicationParameters(),
loader.getMainLibraryPath());
} else if (result == QtLoader.LoadingResult.Failed) {
if (result == QtLoader.LoadingResult.Failed) {
// If we weren't able to load the libraries, remove the delegate from the factory
// as it's holding a reference to the Context, and we don't want it leaked
QtEmbeddedViewInterfaceFactory.remove(getContext());
} else {
// Start Native Qt application
m_viewInterface.startQtApplication(loader.getApplicationParameters(),
loader.getMainLibraryPath());
}
}