From 238a99caf858e9800ac51dde4ccece465337435d Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 27 Feb 2024 16:06:47 +0000 Subject: [PATCH] Android: Allow multiple instances of ScopedJuceInitialiser_GUI Previously, the UnitTestRunner example in the DemoRunner would fail on any tests that included ScopedJuceInitialiser_GUI, as DeletedAtShutdown objects would be destroyed too early. --- modules/juce_events/native/juce_Messaging_android.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/juce_events/native/juce_Messaging_android.cpp b/modules/juce_events/native/juce_Messaging_android.cpp index 95c535c592..85f46384c6 100644 --- a/modules/juce_events/native/juce_Messaging_android.cpp +++ b/modules/juce_events/native/juce_Messaging_android.cpp @@ -267,7 +267,7 @@ private: JUCEApplicationBase::createInstance = createApplicationSymbol; - initialiseJuce_GUI(); + initialiser.emplace(); if (! JUCEApplicationBase::createInstance()) jassertfalse; // you must supply an application object for an android app! @@ -292,6 +292,7 @@ private: } } + std::optional initialiser; GlobalRef myself; juce::JUCEApplicationBase* (*createApplicationSymbol)(); bool hasBeenInitialised = false;