Browse Source

Quick tidy-up of some messaging classes

tags/2021-05-28
jules 8 years ago
parent
commit
f3cde9763a
9 changed files with 31 additions and 33 deletions
  1. +1
    -1
      extras/Projucer/Source/Application/jucer_Application.cpp
  2. +1
    -1
      modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp
  3. +16
    -17
      modules/juce_events/messages/juce_ApplicationBase.cpp
  4. +3
    -4
      modules/juce_events/messages/juce_ApplicationBase.h
  5. +1
    -1
      modules/juce_events/messages/juce_MessageListener.cpp
  6. +3
    -3
      modules/juce_events/messages/juce_MessageManager.cpp
  7. +1
    -1
      modules/juce_events/native/juce_win32_Messaging.cpp
  8. +3
    -3
      modules/juce_gui_basics/native/juce_android_Windowing.cpp
  9. +2
    -2
      modules/juce_gui_basics/native/juce_ios_Windowing.mm

+ 1
- 1
extras/Projucer/Source/Application/jucer_Application.cpp View File

@@ -268,7 +268,7 @@ struct AsyncQuitRetrier : private Timer
stopTimer();
delete this;
if (JUCEApplicationBase* app = JUCEApplicationBase::getInstance())
if (auto* app = JUCEApplicationBase::getInstance())
app->systemRequestedQuit();
}


+ 1
- 1
modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp View File

@@ -254,7 +254,7 @@ namespace CoreMidiHelpers
static String getGlobalMidiClientName()
{
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
if (auto* app = JUCEApplicationBase::getInstance())
return app->getApplicationName();
return "JUCE";


+ 16
- 17
modules/juce_events/messages/juce_ApplicationBase.cpp 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


+ 3
- 4
modules/juce_events/messages/juce_ApplicationBase.h View File

@@ -190,10 +190,9 @@ public:
//==============================================================================
/** Override this method to be informed when the back button is pressed on a device.
This is currently only implemented on Android devices.
*/
virtual void backButtonPressed() { }
virtual void backButtonPressed() {}
//==============================================================================
/** Signals that the main message loop should stop and the application should terminate.
@@ -275,8 +274,8 @@ public:
private:
//==============================================================================
static JUCEApplicationBase* appInstance;
int appReturnValue;
bool stillInitialising;
int appReturnValue = 0;
bool stillInitialising = true;
struct MultipleInstanceHandler;
friend struct MultipleInstanceHandler;


+ 1
- 1
modules/juce_events/messages/juce_MessageListener.cpp View File

@@ -28,7 +28,7 @@ Message::~Message() {}
void Message::messageCallback()
{
if (MessageListener* const r = recipient)
if (auto* r = recipient.get())
r->handleMessage (*this);
}


+ 3
- 3
modules/juce_events/messages/juce_MessageManager.cpp View File

@@ -83,7 +83,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor)
{
jassert (isThisTheMessageThread()); // must only be called by the message thread
const int64 endTime = Time::currentTimeMillis() + millisecondsToRunFor;
auto endTime = Time::currentTimeMillis() + millisecondsToRunFor;
while (! quitMessageReceived)
{
@@ -213,7 +213,7 @@ bool MessageManager::isThisTheMessageThread() const noexcept
void MessageManager::setCurrentThreadAsMessageThread()
{
const Thread::ThreadID thisThread = Thread::getCurrentThreadId();
auto thisThread = Thread::getCurrentThreadId();
if (messageThreadId != thisThread)
{
@@ -227,7 +227,7 @@ void MessageManager::setCurrentThreadAsMessageThread()
bool MessageManager::currentThreadHasLockedMessageManager() const noexcept
{
const Thread::ThreadID thisThread = Thread::getCurrentThreadId();
auto thisThread = Thread::getCurrentThreadId();
return thisThread == messageThreadId || thisThread == threadWithLock.get();
}


+ 1
- 1
modules/juce_events/native/juce_win32_Messaging.cpp View File

@@ -133,7 +133,7 @@ bool MessageManager::dispatchNextMessageOnSystemQueue (const bool returnIfNoPend
}
else if (m.message == WM_QUIT)
{
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
if (auto* app = JUCEApplicationBase::getInstance())
app->systemRequestedQuit();
}
else if (isEventBlockedByModalComps == nullptr || ! isEventBlockedByModalComps (m))


+ 3
- 3
modules/juce_gui_basics/native/juce_android_Windowing.cpp View File

@@ -79,7 +79,7 @@ JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, suspendApp, void, (JNIEnv* e
{
setEnv (env);
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
if (auto* app = JUCEApplicationBase::getInstance())
app->suspended();
}
@@ -87,7 +87,7 @@ JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, resumeApp, void, (JNIEnv* en
{
setEnv (env);
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
if (auto* app = JUCEApplicationBase::getInstance())
app->resumed();
}
@@ -537,7 +537,7 @@ public:
void handleBackButtonCallback()
{
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
if (auto* app = JUCEApplicationBase::getInstance())
app->backButtonPressed();
}


+ 2
- 2
modules/juce_gui_basics/native/juce_ios_Windowing.mm View File

@@ -123,7 +123,7 @@ namespace juce
- (void) applicationDidEnterBackground: (UIApplication*) application
{
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
if (auto* app = JUCEApplicationBase::getInstance())
{
#if JUCE_EXECUTE_APP_SUSPEND_ON_BACKGROUND_TASK
appSuspendTask = [application beginBackgroundTaskWithName:@"JUCE Suspend Task" expirationHandler:^{
@@ -146,7 +146,7 @@ namespace juce
{
ignoreUnused (application);
if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
if (auto* app = JUCEApplicationBase::getInstance())
app->resumed();
}


Loading…
Cancel
Save