26JUCEApplicationBase::CreateInstanceFunction JUCEApplicationBase::createInstance =
nullptr;
27JUCEApplicationBase* JUCEApplicationBase::appInstance =
nullptr;
30void* JUCEApplicationBase::iOSCustomDelegate =
nullptr;
39void JUCEApplicationBase::appWillTerminateByForce()
60void JUCEApplicationBase::sendUnhandledException (
const std::exception*
const e,
77#if ! (JUCE_IOS || JUCE_ANDROID)
81#if JUCE_HANDLE_MULTIPLE_INSTANCES
82struct JUCEApplicationBase::MultipleInstanceHandler
final :
public ActionListener
84 MultipleInstanceHandler (
const String&
appName)
104 void actionListenerCallback (
const String& message)
override
110 if (message.startsWith (
appName +
"/"))
111 app->anotherInstanceStarted (message.substring (
appName.length() + 1));
121bool JUCEApplicationBase::sendCommandLineToPreexistingInstance()
123 jassert (multipleInstanceHandler ==
nullptr);
126 return multipleInstanceHandler->sendCommandLineToPreexistingInstance();
133JUCEApplicationBase::JUCEApplicationBase()
142 appInstance =
nullptr;
153#if JUCE_WINDOWS && ! defined (_CONSOLE)
158 CharPointer_UTF16 (
L" "),
159 CharPointer_UTF16 (
L"\"")).findEndOfWhitespace();
169 s = StringArray (
argv + 1,
argc - 1);
178#if JUCE_IOS && JUCE_MODULE_AVAILABLE_juce_gui_basics
186#if (JUCE_LINUX || JUCE_BSD) && JUCE_MODULE_AVAILABLE_juce_gui_extra && (! defined (JUCE_WEB_BROWSER) || JUCE_WEB_BROWSER)
191 const char*
const* juce_argv =
nullptr;
194 extern const char*
const* juce_argv;
195 extern int juce_argc;
217 for (
int i = 1; i < juce_argc; ++i)
223int JUCEApplicationBase::main (
int argc,
const char*
argv[])
234 #if (JUCE_LINUX || JUCE_BSD) && JUCE_MODULE_AVAILABLE_juce_gui_extra && (! defined (JUCE_WEB_BROWSER) || JUCE_WEB_BROWSER)
235 if (
argc >= 2 &&
String (
argv[1]) ==
"--juce-gtkwebkitfork-child")
239 #if JUCE_IOS && JUCE_MODULE_AVAILABLE_juce_gui_basics
243 return JUCEApplicationBase::main();
251int JUCEApplicationBase::main()
254 jassert (createInstance !=
nullptr);
259 if (!
app->initialiseApp())
260 return app->shutdownApp();
269 return app->shutdownApp();
275bool JUCEApplicationBase::initialiseApp()
277 #if JUCE_HANDLE_MULTIPLE_INSTANCES
280 DBG (
"Another instance is running - quitting...");
285 #if JUCE_WINDOWS && (! defined (_CONSOLE)) && (! JUCE_MINGW)
302 stillInitialising =
false;
307 #if JUCE_HANDLE_MULTIPLE_INSTANCES
308 if (
auto*
mih = multipleInstanceHandler.get())
315int JUCEApplicationBase::shutdownApp()
319 #if JUCE_HANDLE_MULTIPLE_INSTANCES
320 if (
auto*
mih = multipleInstanceHandler.get())
331 multipleInstanceHandler.reset();
Wraps a pointer to a null-terminated UTF-8 character string, and provides various methods to operate ...
static Type findEndOfToken(Type text, BreakType breakCharacters, Type quoteCharacters)
Returns a pointer to the first character in the string which is found in the breakCharacters string.
static void deleteAll()
Deletes all extant objects.
static bool isAbsolutePath(StringRef path)
Returns true if the string seems to be a fully-specified absolute path.
virtual ~JUCEApplicationBase()
Destructor.
virtual void initialise(const String &commandLineParameters)=0
Called when the application starts.
virtual const String getApplicationName()=0
Returns the application's name.
static String JUCE_CALLTYPE getCommandLineParameters()
Returns the application's command line parameters as a single string.
static void quit()
Signals that the main message loop should stop and the application should terminate.
static StringArray JUCE_CALLTYPE getCommandLineParameterArray()
Returns the application's command line parameters as a set of strings.
void setApplicationReturnValue(int newReturnValue) noexcept
Sets the value that should be returned as the application's exit code when the app quits.
static JUCEApplicationBase * getInstance() noexcept
Returns the global instance of the application object that's running.
static bool isStandaloneApp() noexcept
Returns true if this executable is running as an app (as opposed to being a plugin or other kind of s...
virtual bool moreThanOneInstanceAllowed()=0
Checks whether multiple instances of the app are allowed.
int getApplicationReturnValue() const noexcept
Returns the value that has been set as the application's exit code.
void runDispatchLoop()
Runs the event dispatch loop until a stop message is posted.
void stopDispatchLoop()
Sends a signal that the dispatch loop should terminate.
void deregisterBroadcastListener(ActionListener *listener)
Deregisters a broadcast listener.
static void broadcastMessage(const String &messageText)
Sends a message to all other JUCE applications that are running.
void registerBroadcastListener(ActionListener *listener)
Registers a listener to get told about broadcast messages.
static void deleteInstance()
Deletes the global MessageManager instance.
static MessageManager * getInstance()
Returns the global instance of the MessageManager.
A special array for holding a list of strings.
void add(String stringToAdd)
Appends a string at the end of the array.
bool containsChar(juce_wchar character) const noexcept
Tests whether the string contains a particular character.
#define JUCE_TRY
The JUCE_TRY/JUCE_CATCH_EXCEPTION wrappers can be used to pass any uncaught exceptions to the JUCEApp...
#define JUCE_CATCH_EXCEPTION
The JUCE_TRY/JUCE_CATCH_EXCEPTION wrappers can be used to pass any uncaught exceptions to the JUCEApp...
#define JUCE_AUTORELEASEPOOL
A macro that can be used to easily declare a local ScopedAutoReleasePool object for RAII-based obj-C ...
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...