1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Quick tidy-up of some messaging classes

This commit is contained in:
jules 2017-12-04 11:30:15 +00:00
parent f4963a27d7
commit f3cde9763a
9 changed files with 31 additions and 33 deletions

View file

@ -31,8 +31,6 @@ void* JUCEApplicationBase::iOSCustomDelegate = nullptr;
#endif
JUCEApplicationBase::JUCEApplicationBase()
: appReturnValue (0),
stillInitialising (true)
{
jassert (isStandaloneApp() && appInstance == nullptr);
appInstance = this;
@ -75,7 +73,7 @@ void JUCEApplicationBase::sendUnhandledException (const std::exception* const e,
const char* const sourceFile,
const int lineNumber)
{
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
if (auto* app = JUCEApplicationBase::getInstance())
{
// If you hit this assertion then the __FILE__ macro is providing a
// relative path instead of an absolute path. On Windows this will be
@ -95,7 +93,6 @@ void JUCEApplicationBase::sendUnhandledException (const std::exception* const e,
#if JUCE_HANDLE_MULTIPLE_INSTANCES
struct JUCEApplicationBase::MultipleInstanceHandler : public ActionListener
{
public:
MultipleInstanceHandler (const String& appName)
: appLock ("juceAppLock_" + appName)
{
@ -106,19 +103,21 @@ public:
if (appLock.enter (0))
return false;
JUCEApplicationBase* const app = JUCEApplicationBase::getInstance();
jassert (app != nullptr);
if (auto* app = JUCEApplicationBase::getInstance())
{
MessageManager::broadcastMessage (app->getApplicationName() + "/" + app->getCommandLineParameters());
return true;
}
MessageManager::broadcastMessage (app->getApplicationName()
+ "/" + app->getCommandLineParameters());
return true;
jassertfalse;
return false;
}
void actionListenerCallback (const String& message) override
{
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
if (auto* app = JUCEApplicationBase::getInstance())
{
const String appName (app->getApplicationName());
auto appName = app->getApplicationName();
if (message.startsWith (appName + "/"))
app->anotherInstanceStarted (message.substring (appName.length() + 1));
@ -163,9 +162,9 @@ String JUCE_CALLTYPE JUCEApplicationBase::getCommandLineParameters()
StringArray JUCE_CALLTYPE JUCEApplicationBase::getCommandLineParameterArray()
{
StringArray s;
int argc = 0;
if (LPWSTR* const argv = CommandLineToArgvW (GetCommandLineW(), &argc))
if (auto argv = CommandLineToArgvW (GetCommandLineW(), &argc))
{
s = StringArray (argv + 1, argc - 1);
LocalFree (argv);
@ -303,8 +302,8 @@ bool JUCEApplicationBase::initialiseApp()
return false;
#if JUCE_HANDLE_MULTIPLE_INSTANCES
if (multipleInstanceHandler != nullptr)
MessageManager::getInstance()->registerBroadcastListener (multipleInstanceHandler.get());
if (auto* mih = multipleInstanceHandler.get())
MessageManager::getInstance()->registerBroadcastListener (mih);
#endif
return true;
@ -315,8 +314,8 @@ int JUCEApplicationBase::shutdownApp()
jassert (JUCEApplicationBase::getInstance() == this);
#if JUCE_HANDLE_MULTIPLE_INSTANCES
if (multipleInstanceHandler != nullptr)
MessageManager::getInstance()->deregisterBroadcastListener (multipleInstanceHandler.get());
if (auto* mih = multipleInstanceHandler.get())
MessageManager::getInstance()->deregisterBroadcastListener (mih);
#endif
JUCE_TRY