Browse Source

Simplified some inter-module dependencies and exception-catching fallbacks

tags/2021-05-28
jules 9 years ago
parent
commit
2a1234b6ac
16 changed files with 90 additions and 141 deletions
  1. +11
    -18
      modules/juce_audio_devices/native/juce_win32_ASIO.cpp
  2. +0
    -2
      modules/juce_audio_devices/native/juce_win32_DirectSound.cpp
  3. +6
    -10
      modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp
  4. +8
    -9
      modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm
  5. +2
    -8
      modules/juce_core/native/juce_win32_Files.cpp
  6. +4
    -14
      modules/juce_core/native/juce_win32_Threads.cpp
  7. +0
    -34
      modules/juce_core/system/juce_PlatformDefs.h
  8. +13
    -10
      modules/juce_core/threads/juce_Thread.cpp
  9. +5
    -2
      modules/juce_core/threads/juce_ThreadPool.cpp
  10. +0
    -4
      modules/juce_events/juce_events.cpp
  11. +23
    -0
      modules/juce_events/messages/juce_ApplicationBase.h
  12. +1
    -2
      modules/juce_events/messages/juce_MessageManager.h
  13. +3
    -6
      modules/juce_graphics/fonts/juce_Font.cpp
  14. +0
    -4
      modules/juce_gui_basics/juce_gui_basics.cpp
  15. +3
    -7
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp
  16. +11
    -11
      modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp

+ 11
- 18
modules/juce_audio_devices/native/juce_win32_ASIO.cpp View File

@@ -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;


+ 0
- 2
modules/juce_audio_devices/native/juce_win32_DirectSound.cpp View File

@@ -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


+ 6
- 10
modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp View File

@@ -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


+ 8
- 9
modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm View File

@@ -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

+ 2
- 8
modules/juce_core/native/juce_win32_Files.cpp View File

@@ -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;
}


+ 4
- 14
modules/juce_core/native/juce_win32_Threads.cpp View File

@@ -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


+ 0
- 34
modules/juce_core/system/juce_PlatformDefs.h View File

@@ -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.


+ 13
- 10
modules/juce_core/threads/juce_Thread.cpp View File

@@ -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();


+ 5
- 2
modules/juce_core/threads/juce_ThreadPool.cpp View File

@@ -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;


+ 0
- 4
modules/juce_events/juce_events.cpp View File

@@ -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 <IOKit/IOKitLib.h>


+ 23
- 0
modules/juce_events/messages/juce_ApplicationBase.h View File

@@ -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

+ 1
- 2
modules/juce_events/messages/juce_MessageManager.h View File

@@ -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);


+ 3
- 6
modules/juce_graphics/fonts/juce_Font.cpp View File

@@ -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();
}
//==============================================================================


+ 0
- 4
modules/juce_gui_basics/juce_gui_basics.cpp View File

@@ -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 <WebKit/WebKit.h>


+ 3
- 7
modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -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()


+ 11
- 11
modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp View File

@@ -22,6 +22,8 @@
==============================================================================
*/
extern void (*clearOpenGLGlyphCache)(); // declared in juce_graphics
namespace OpenGLRendering
{
@@ -1589,7 +1591,7 @@ public:
}
}
typedef RenderingHelpers::GlyphCache <RenderingHelpers::CachedGlyphEdgeTable <SavedState>, SavedState> GlyphCacheType;
typedef RenderingHelpers::GlyphCache<RenderingHelpers::CachedGlyphEdgeTable<SavedState>, 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


Loading…
Cancel
Save