1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-04 03:40:07 +00:00

Modified app startup code so that JUCEApplication::shutdown() will still get called even if the app is aborted during the initialise() method.

This commit is contained in:
jules 2015-04-14 11:30:25 +01:00
parent e0556acccc
commit 4af50da9f7
4 changed files with 29 additions and 17 deletions

View file

@ -232,7 +232,7 @@ int JUCEApplicationBase::main()
jassert (app != nullptr);
if (! app->initialiseApp())
return app->getApplicationReturnValue();
return app->shutdownApp();
JUCE_TRY
{

View file

@ -259,6 +259,7 @@ public:
static CreateInstanceFunction createInstance;
virtual bool initialiseApp();
int shutdownApp();
static void JUCE_CALLTYPE sendUnhandledException (const std::exception*, const char* sourceFile, int lineNumber);
bool sendCommandLineToPreexistingInstance();
#endif
@ -274,8 +275,6 @@ private:
friend struct ContainerDeletePolicy<MultipleInstanceHandler>;
ScopedPointer<MultipleInstanceHandler> multipleInstanceHandler;
int shutdownApp();
JUCE_DECLARE_NON_COPYABLE (JUCEApplicationBase)
};

View file

@ -41,9 +41,15 @@ JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, launchApp, void, (JNIEnv* en
initialiseJuce_GUI();
JUCEApplicationBase* app = JUCEApplicationBase::createInstance();
if (! app->initialiseApp())
exit (app->getApplicationReturnValue());
if (JUCEApplicationBase* app = JUCEApplicationBase::createInstance())
{
if (! app->initialiseApp())
exit (app->shutdownApp());
}
else
{
jassertfalse; // you must supply an application object for an android app!
}
jassert (MessageManager::getInstance()->isThisTheMessageThread());
}

View file

@ -43,44 +43,51 @@ extern bool isIOSAppActive;
- (void) applicationDidFinishLaunching: (UIApplication*) application
{
(void) application;
ignoreUnused (application);
initialiseJuce_GUI();
JUCEApplicationBase* app = JUCEApplicationBase::createInstance();
if (! app->initialiseApp())
exit (0);
if (JUCEApplicationBase* app = JUCEApplicationBase::createInstance())
{
if (! app->initialiseApp())
exit (app->shutdownApp());
}
else
{
jassertfalse; // you must supply an application object for an iOS app!
}
}
- (void) applicationWillTerminate: (UIApplication*) application
{
(void) application;
ignoreUnused (application);
JUCEApplicationBase::appWillTerminateByForce();
}
- (void) applicationDidEnterBackground: (UIApplication*) application
{
(void) application;
ignoreUnused (application);
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
app->suspended();
}
- (void) applicationWillEnterForeground: (UIApplication*) application
{
(void) application;
ignoreUnused (application);
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
app->resumed();
}
- (void) applicationDidBecomeActive: (UIApplication*) application
{
(void) application;
ignoreUnused (application);
isIOSAppActive = true;
}
- (void) applicationWillResignActive: (UIApplication*) application
{
(void) application;
ignoreUnused (application);
isIOSAppActive = false;
}
@ -207,7 +214,7 @@ void JUCE_CALLTYPE NativeMessageBox::showMessageBox (AlertWindow::AlertIconType
JUCE_AUTORELEASEPOOL
{
iOSMessageBox mb (title, message, @"OK", nil, nil, nullptr, false);
(void) mb.getResult();
ignoreUnused (mb.getResult());
}
}
#endif