diff --git a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp index d385b180de..dc0f4e04b6 100644 --- a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp +++ b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp @@ -690,31 +690,24 @@ public: JUCE_ASIO_LOG ("showing control panel"); bool done = false; + insideControlPanelModalLoop = true; - JUCE_TRY - { - // are there are devices that need to be closed before showing their control panel? - // close(); - insideControlPanelModalLoop = true; - - const uint32 started = Time::getMillisecondCounter(); + const uint32 started = Time::getMillisecondCounter(); - if (asioObject != nullptr) - { - asioObject->controlPanel(); + if (asioObject != nullptr) + { + asioObject->controlPanel(); - const int spent = (int) Time::getMillisecondCounter() - (int) started; + const int spent = (int) Time::getMillisecondCounter() - (int) started; - JUCE_ASIO_LOG ("spent: " + String (spent)); + JUCE_ASIO_LOG ("spent: " + String (spent)); - if (spent > 300) - { - shouldUsePreferredSize = true; - done = true; - } + if (spent > 300) + { + shouldUsePreferredSize = true; + done = true; } } - JUCE_CATCH_ALL insideControlPanelModalLoop = false; return done; diff --git a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp index 8fd118d3dd..75e007c61e 100644 --- a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp +++ b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp @@ -182,11 +182,9 @@ namespace DSoundLogging } } - #define CATCH JUCE_CATCH_EXCEPTION #define JUCE_DS_LOG(a) DSoundLogging::logMessage(a); #define JUCE_DS_LOG_ERROR(a) DSoundLogging::logError(a, __LINE__); #else - #define CATCH JUCE_CATCH_ALL #define JUCE_DS_LOG(a) #define JUCE_DS_LOG_ERROR(a) #endif diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 4ceb5b70ad..1cf35f8076 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -1754,19 +1754,15 @@ public: if (! isActive) return; // Avoids redundantly calling things like setActive - JUCE_TRY - { - isActive = false; + isActive = false; - setStateForAllBusses (false); + setStateForAllBusses (false); - if (processor != nullptr) - warnOnFailure (processor->setProcessing (false)); + if (processor != nullptr) + warnOnFailure (processor->setProcessing (false)); - if (component != nullptr) - warnOnFailure (component->setActive (false)); - } - JUCE_CATCH_ALL_ASSERT + if (component != nullptr) + warnOnFailure (component->setActive (false)); } bool supportsDoublePrecisionProcessing() const override diff --git a/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm b/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm index c8bbc15a8d..8cb317aafe 100644 --- a/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm +++ b/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm @@ -112,27 +112,26 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BluetoothMidiSelectorOverlay) }; -#endif // JUCE_MODULE_AVAILABLE_juce_gui_extra && ! TARGET_IPHONE_SIMULATOR - -//============================================================================== bool BluetoothMidiDevicePairingDialogue::open() { - #if JUCE_MODULE_AVAILABLE_juce_gui_extra && ! TARGET_IPHONE_SIMULATOR if (isAvailable()) { new BluetoothMidiSelectorOverlay(); return true; } - #endif return false; } bool BluetoothMidiDevicePairingDialogue::isAvailable() { - #if JUCE_MODULE_AVAILABLE_juce_gui_extra && ! TARGET_IPHONE_SIMULATOR return NSClassFromString ([NSString stringWithUTF8String: "CABTMIDICentralViewController"]) != nil; - #else - return false; - #endif } + +//============================================================================== +#else + +bool BluetoothMidiDevicePairingDialogue::open() { return false; } +bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } + +#endif diff --git a/modules/juce_core/native/juce_win32_Files.cpp b/modules/juce_core/native/juce_win32_Files.cpp index b4808a5d3a..ebf480f751 100644 --- a/modules/juce_core/native/juce_win32_Files.cpp +++ b/modules/juce_core/native/juce_win32_Files.cpp @@ -798,14 +798,8 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, //============================================================================== bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String& parameters) { - HINSTANCE hInstance = 0; - - JUCE_TRY - { - hInstance = ShellExecute (0, 0, fileName.toWideCharPointer(), - parameters.toWideCharPointer(), 0, SW_SHOWDEFAULT); - } - JUCE_CATCH_ALL + HINSTANCE hInstance = ShellExecute (0, 0, fileName.toWideCharPointer(), + parameters.toWideCharPointer(), 0, SW_SHOWDEFAULT); return hInstance > (HINSTANCE) 32; } diff --git a/modules/juce_core/native/juce_win32_Threads.cpp b/modules/juce_core/native/juce_win32_Threads.cpp index 7d2003fc39..71d697a328 100644 --- a/modules/juce_core/native/juce_win32_Threads.cpp +++ b/modules/juce_core/native/juce_win32_Threads.cpp @@ -314,27 +314,17 @@ bool juce_isRunningInWine() bool DynamicLibrary::open (const String& name) { close(); - - JUCE_TRY - { - handle = LoadLibrary (name.toWideCharPointer()); - } - JUCE_CATCH_ALL - + handle = LoadLibrary (name.toWideCharPointer()); return handle != nullptr; } void DynamicLibrary::close() { - JUCE_TRY + if (handle != nullptr) { - if (handle != nullptr) - { - FreeLibrary ((HMODULE) handle); - handle = nullptr; - } + FreeLibrary ((HMODULE) handle); + handle = nullptr; } - JUCE_CATCH_ALL } void* DynamicLibrary::getFunction (const String& functionName) noexcept diff --git a/modules/juce_core/system/juce_PlatformDefs.h b/modules/juce_core/system/juce_PlatformDefs.h index 54ab399a6b..98cbd7818b 100644 --- a/modules/juce_core/system/juce_PlatformDefs.h +++ b/modules/juce_core/system/juce_PlatformDefs.h @@ -251,40 +251,6 @@ #endif -//============================================================================== -#if JUCE_CATCH_UNHANDLED_EXCEPTIONS - - #define JUCE_TRY try - - #define JUCE_CATCH_ALL catch (...) {} - #define JUCE_CATCH_ALL_ASSERT catch (...) { jassertfalse; } - - #if ! JUCE_MODULE_AVAILABLE_juce_gui_basics - #define JUCE_CATCH_EXCEPTION JUCE_CATCH_ALL - #else - /** Used in try-catch blocks, this macro will send exceptions to the JUCEApplicationBase - object so they can be logged by the application if it wants to. - */ - #define JUCE_CATCH_EXCEPTION \ - catch (const std::exception& e) \ - { \ - juce::JUCEApplicationBase::sendUnhandledException (&e, __FILE__, __LINE__); \ - } \ - catch (...) \ - { \ - juce::JUCEApplicationBase::sendUnhandledException (nullptr, __FILE__, __LINE__); \ - } - #endif - -#else - - #define JUCE_TRY - #define JUCE_CATCH_EXCEPTION - #define JUCE_CATCH_ALL - #define JUCE_CATCH_ALL_ASSERT - -#endif - //============================================================================== #if JUCE_DEBUG || DOXYGEN /** A platform-independent way of forcing an inline function. diff --git a/modules/juce_core/threads/juce_Thread.cpp b/modules/juce_core/threads/juce_Thread.cpp index d5b7110b97..d195b66d10 100644 --- a/modules/juce_core/threads/juce_Thread.cpp +++ b/modules/juce_core/threads/juce_Thread.cpp @@ -86,22 +86,25 @@ void Thread::threadEntryPoint() const CurrentThreadHolder::Ptr currentThreadHolder (getCurrentThreadHolder()); currentThreadHolder->value = this; - JUCE_TRY - { - if (threadName.isNotEmpty()) - setCurrentThreadName (threadName); + if (threadName.isNotEmpty()) + setCurrentThreadName (threadName); - if (startSuspensionEvent.wait (10000)) - { - jassert (getCurrentThreadId() == threadId); + if (startSuspensionEvent.wait (10000)) + { + jassert (getCurrentThreadId() == threadId); - if (affinityMask != 0) - setCurrentThreadAffinityMask (affinityMask); + if (affinityMask != 0) + setCurrentThreadAffinityMask (affinityMask); + try + { run(); } + catch (...) + { + jassertfalse; // Your run() method mustn't throw any exceptions! + } } - JUCE_CATCH_ALL_ASSERT currentThreadHolder->value.releaseCurrentThreadStorage(); closeThreadHandle(); diff --git a/modules/juce_core/threads/juce_ThreadPool.cpp b/modules/juce_core/threads/juce_ThreadPool.cpp index b50c9de455..f57359c629 100644 --- a/modules/juce_core/threads/juce_ThreadPool.cpp +++ b/modules/juce_core/threads/juce_ThreadPool.cpp @@ -336,11 +336,14 @@ bool ThreadPool::runNextJob (ThreadPoolThread& thread) ThreadPoolJob::JobStatus result = ThreadPoolJob::jobHasFinished; thread.currentJob = job; - JUCE_TRY + try { result = job->runJob(); } - JUCE_CATCH_ALL_ASSERT + catch (...) + { + jassertfalse; // Your runJob() method mustn't throw any exceptions! + } thread.currentJob = nullptr; diff --git a/modules/juce_events/juce_events.cpp b/modules/juce_events/juce_events.cpp index 53069c472b..13c84c9b6e 100644 --- a/modules/juce_events/juce_events.cpp +++ b/modules/juce_events/juce_events.cpp @@ -38,10 +38,6 @@ #include "../juce_core/native/juce_BasicNativeHeaders.h" #include "juce_events.h" -#if JUCE_CATCH_UNHANDLED_EXCEPTIONS && JUCE_MODULE_AVAILABLE_juce_gui_basics - #include "../juce_gui_basics/juce_gui_basics.h" -#endif - //============================================================================== #if JUCE_MAC #import diff --git a/modules/juce_events/messages/juce_ApplicationBase.h b/modules/juce_events/messages/juce_ApplicationBase.h index bde123bf8c..35bc65ff71 100644 --- a/modules/juce_events/messages/juce_ApplicationBase.h +++ b/modules/juce_events/messages/juce_ApplicationBase.h @@ -279,4 +279,27 @@ private: }; +//============================================================================== +#if JUCE_CATCH_UNHANDLED_EXCEPTIONS || defined (DOXYGEN) + + /** The JUCE_TRY/JUCE_CATCH_EXCEPTION wrappers can be used to pass any uncaught exceptions to + the JUCEApplicationBase::sendUnhandledException() method. + This functionality can be enabled with the JUCE_CATCH_UNHANDLED_EXCEPTIONS macro. + */ + #define JUCE_TRY try + + /** The JUCE_TRY/JUCE_CATCH_EXCEPTION wrappers can be used to pass any uncaught exceptions to + the JUCEApplicationBase::sendUnhandledException() method. + This functionality can be enabled with the JUCE_CATCH_UNHANDLED_EXCEPTIONS macro. + */ + #define JUCE_CATCH_EXCEPTION \ + catch (const std::exception& e) { juce::JUCEApplicationBase::sendUnhandledException (&e, __FILE__, __LINE__); } \ + catch (...) { juce::JUCEApplicationBase::sendUnhandledException (nullptr, __FILE__, __LINE__); } + +#else + #define JUCE_TRY + #define JUCE_CATCH_EXCEPTION +#endif + + #endif // JUCE_APPLICATIONBASE_H_INCLUDED diff --git a/modules/juce_events/messages/juce_MessageManager.h b/modules/juce_events/messages/juce_MessageManager.h index 9373205850..676ced4092 100644 --- a/modules/juce_events/messages/juce_MessageManager.h +++ b/modules/juce_events/messages/juce_MessageManager.h @@ -32,8 +32,7 @@ class ActionBroadcaster; //============================================================================== -/** See MessageManager::callFunctionOnMessageThread() for use of this function type -*/ +/** See MessageManager::callFunctionOnMessageThread() for use of this function type. */ typedef void* (MessageCallbackFunction) (void* userData); diff --git a/modules/juce_graphics/fonts/juce_Font.cpp b/modules/juce_graphics/fonts/juce_Font.cpp index f47e182cdc..7b7632fb8e 100644 --- a/modules/juce_graphics/fonts/juce_Font.cpp +++ b/modules/juce_graphics/fonts/juce_Font.cpp @@ -159,9 +159,7 @@ void Typeface::setTypefaceCacheSize (int numFontsToCache) TypefaceCache::getInstance()->setSize (numFontsToCache); } -#if JUCE_MODULE_AVAILABLE_juce_opengl -extern void clearOpenGLGlyphCache(); -#endif +void (*clearOpenGLGlyphCache)() = nullptr; void Typeface::clearTypefaceCache() { @@ -169,9 +167,8 @@ void Typeface::clearTypefaceCache() RenderingHelpers::SoftwareRendererSavedState::clearGlyphCache(); - #if JUCE_MODULE_AVAILABLE_juce_opengl - clearOpenGLGlyphCache(); - #endif + if (clearOpenGLGlyphCache != nullptr) + clearOpenGLGlyphCache(); } //============================================================================== diff --git a/modules/juce_gui_basics/juce_gui_basics.cpp b/modules/juce_gui_basics/juce_gui_basics.cpp index 8f240494e8..0af3e64f02 100644 --- a/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/modules/juce_gui_basics/juce_gui_basics.cpp @@ -40,10 +40,6 @@ #include "../juce_core/native/juce_BasicNativeHeaders.h" #include "juce_gui_basics.h" -#if JUCE_MODULE_AVAILABLE_juce_opengl - #include "../juce_opengl/juce_opengl.h" -#endif - //============================================================================== #if JUCE_MAC #import diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 084153fae6..fad1fefa0a 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -1129,19 +1129,16 @@ public: JUCE_DECLARE_NON_COPYABLE (JuceDropTarget) }; - #if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client static bool offerKeyMessageToJUCEWindow (MSG& m) { if (m.message == WM_KEYDOWN || m.message == WM_KEYUP) if (Component::getCurrentlyFocusedComponent() != nullptr) if (HWNDComponentPeer* h = getOwnerOfWindow (m.hwnd)) - if (m.message == WM_KEYDOWN ? h->doKeyDown (m.wParam) - : h->doKeyUp (m.wParam)) - return true; + return m.message == WM_KEYDOWN ? h->doKeyDown (m.wParam) + : h->doKeyUp (m.wParam); return false; } - #endif private: HWND hwnd, parentToAddTo; @@ -3021,9 +3018,8 @@ bool KeyPress::isKeyCurrentlyDown (const int keyCode) return HWNDComponentPeer::isKeyDown (k); } -#if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client +// (This internal function is used by the plugin client module) bool offerKeyMessageToJUCEWindow (MSG& m) { return HWNDComponentPeer::offerKeyMessageToJUCEWindow (m); } -#endif //============================================================================== bool JUCE_CALLTYPE Process::isForegroundProcess() diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 319e25b2b1..90dcf2417d 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -22,6 +22,8 @@ ============================================================================== */ +extern void (*clearOpenGLGlyphCache)(); // declared in juce_graphics + namespace OpenGLRendering { @@ -1589,7 +1591,7 @@ public: } } - typedef RenderingHelpers::GlyphCache , SavedState> GlyphCacheType; + typedef RenderingHelpers::GlyphCache, SavedState> GlyphCacheType; void drawGlyph (int glyphNumber, const AffineTransform& trans) { @@ -1770,9 +1772,15 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NonShaderContext) }; -LowLevelGraphicsContext* createOpenGLContext (const Target&); -LowLevelGraphicsContext* createOpenGLContext (const Target& target) +static void clearOpenGLGlyphCacheCallback() { + SavedState::GlyphCacheType::getInstance().reset(); +} + +static LowLevelGraphicsContext* createOpenGLContext (const Target& target) +{ + clearOpenGLGlyphCache = clearOpenGLGlyphCacheCallback; + if (target.context.areShadersAvailable()) return new ShaderContext (target); @@ -1795,17 +1803,9 @@ LowLevelGraphicsContext* createOpenGLGraphicsContext (OpenGLContext& context, Op LowLevelGraphicsContext* createOpenGLGraphicsContext (OpenGLContext& context, unsigned int frameBufferID, int width, int height) { - using namespace OpenGLRendering; return OpenGLRendering::createOpenGLContext (OpenGLRendering::Target (context, frameBufferID, width, height)); } -void clearOpenGLGlyphCache(); -void clearOpenGLGlyphCache() -{ - OpenGLRendering::SavedState::GlyphCacheType::getInstance().reset(); -} - - //============================================================================== struct CustomProgram : public ReferenceCountedObject, public OpenGLRendering::ShaderPrograms::ShaderBase