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

Simplified some inter-module dependencies and exception-catching fallbacks

This commit is contained in:
jules 2015-12-23 11:47:18 +00:00
parent 9b167ca5e1
commit 2a1234b6ac
16 changed files with 90 additions and 141 deletions

View file

@ -690,31 +690,24 @@ public:
JUCE_ASIO_LOG ("showing control panel");
bool done = false;
insideControlPanelModalLoop = true;
JUCE_TRY
const uint32 started = Time::getMillisecondCounter();
if (asioObject != nullptr)
{
// are there are devices that need to be closed before showing their control panel?
// close();
insideControlPanelModalLoop = true;
asioObject->controlPanel();
const uint32 started = Time::getMillisecondCounter();
const int spent = (int) Time::getMillisecondCounter() - (int) started;
if (asioObject != nullptr)
JUCE_ASIO_LOG ("spent: " + String (spent));
if (spent > 300)
{
asioObject->controlPanel();
const int spent = (int) Time::getMillisecondCounter() - (int) started;
JUCE_ASIO_LOG ("spent: " + String (spent));
if (spent > 300)
{
shouldUsePreferredSize = true;
done = true;
}
shouldUsePreferredSize = true;
done = true;
}
}
JUCE_CATCH_ALL
insideControlPanelModalLoop = false;
return done;

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

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

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

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

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

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.

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 (startSuspensionEvent.wait (10000))
{
if (threadName.isNotEmpty())
setCurrentThreadName (threadName);
jassert (getCurrentThreadId() == threadId);
if (startSuspensionEvent.wait (10000))
if (affinityMask != 0)
setCurrentThreadAffinityMask (affinityMask);
try
{
jassert (getCurrentThreadId() == threadId);
if (affinityMask != 0)
setCurrentThreadAffinityMask (affinityMask);
run();
}
catch (...)
{
jassertfalse; // Your run() method mustn't throw any exceptions!
}
}
JUCE_CATCH_ALL_ASSERT
currentThreadHolder->value.releaseCurrentThreadStorage();
closeThreadHandle();

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;

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>

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

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

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

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>

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

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