From f5a3fb0fb31a8dfc59cdc3b09776e6e351924215 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 19 Aug 2009 12:04:35 +0000 Subject: [PATCH] removed a memory leak in mac messaging; tweaked mac VSTs to avoid a shutdown bug in Reaper; added a clear() method to DynamicObject. --- .../juce_mac_MessageManager.mm | 8 +- .../wrapper/VST/juce_VST_Wrapper.mm | 357 ++++++------ juce.h | 26 +- juce_Config.h | 508 +++++++++--------- juce_amalgamated.cpp | 40 +- juce_amalgamated.h | 29 +- src/juce_core/containers/juce_Variant.cpp | 6 + src/juce_core/containers/juce_Variant.h | 4 + 8 files changed, 493 insertions(+), 485 deletions(-) diff --git a/build/macosx/platform_specific_code/juce_mac_MessageManager.mm b/build/macosx/platform_specific_code/juce_mac_MessageManager.mm index cd2c110c73..4cac62e29f 100644 --- a/build/macosx/platform_specific_code/juce_mac_MessageManager.mm +++ b/build/macosx/platform_specific_code/juce_mac_MessageManager.mm @@ -217,6 +217,7 @@ static int numPendingMessages = 0; NSData* data = (NSData*) n; void* message = 0; [data getBytes: &message length: sizeof (message)]; + [data release]; if (message != 0 && ! flushingMessages) redirector->deliverMessage (message); @@ -354,7 +355,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) uint32 endTime = Time::getMillisecondCounter() + millisecondsToRunFor; NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001]; - while (Time::getMillisecondCounter() < endTime && ! quitMessagePosted) + while (! quitMessagePosted) { const ScopedAutoReleasePool pool; @@ -368,6 +369,9 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) if (e != 0 && ! isEventBlockedByModalComps (e)) [NSApp sendEvent: e]; + + if (Time::getMillisecondCounter() >= endTime) + break; } return ! quitMessagePosted; @@ -417,7 +421,7 @@ bool juce_postMessageToSystemQueue (void* message) atomicIncrement (numPendingMessages); [juceAppDelegate performSelectorOnMainThread: @selector (customEvent:) - withObject: (id) [NSData dataWithBytes: &message length: (int) sizeof (message)] + withObject: (id) [[NSData alloc] initWithBytes: &message length: (int) sizeof (message)] waitUntilDone: NO]; return true; } diff --git a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm index c664fa2d4a..53fa3c4655 100644 --- a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm +++ b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm @@ -1,176 +1,181 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-9 by Raw Material Software Ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the GNU General - Public License (Version 2), as published by the Free Software Foundation. - A copy of the license is included in the JUCE distribution, or can be found - online at www.gnu.org/licenses. - - JUCE is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - ------------------------------------------------------------------------------ - - To release a closed-source product which uses JUCE, commercial licenses are - available: visit www.rawmaterialsoftware.com/juce for more information. - - ============================================================================== -*/ - -//============================================================================== -#include "../juce_IncludeCharacteristics.h" - -#if JucePlugin_Build_VST - -#include - -#define ADD_CARBON_BODGE 1 // see note below.. - -#include - -#include "../juce_PluginHeaders.h" - -//============================================================================== -BEGIN_JUCE_NAMESPACE - -#if ADD_CARBON_BODGE -/* When you wrap a WindowRef as an NSWindow, it seems to bugger up the HideWindow - function, so when the host tries (and fails) to hide the window, this catches - the event and does the job properly. -*/ - -static pascal OSStatus windowVisibilityBodge (EventHandlerCallRef, EventRef e, void* user) -{ - NSWindow* hostWindow = (NSWindow*) user; - - switch (GetEventKind (e)) - { - case kEventWindowShown: - [hostWindow orderFront: nil]; - break; - case kEventWindowHidden: - [hostWindow orderOut: nil]; - break; - } - - return eventNotHandledErr; -} -#endif - -//============================================================================== -void initialiseMac() -{ - NSApplicationLoad(); -} - -void* attachComponentToWindowRef (Component* comp, void* windowRef) -{ - const ScopedAutoReleasePool pool; - - NSWindow* hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef]; - [hostWindow retain]; - [hostWindow setCanHide: YES]; - [hostWindow setReleasedWhenClosed: YES]; - - NSView* content = [hostWindow contentView]; - NSRect f = [content frame]; - NSPoint windowPos = [hostWindow convertBaseToScreen: f.origin]; - windowPos.y = [[NSScreen mainScreen] frame].size.height - (windowPos.y + f.size.height); - comp->setTopLeftPosition ((int) windowPos.x, (int) windowPos.y); - -#if ! JucePlugin_EditorRequiresKeyboardFocus - comp->addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses); -#else - comp->addToDesktop (ComponentPeer::windowIsTemporary); -#endif - - comp->setVisible (true); - comp->toFront (false); - - NSView* pluginView = (NSView*) comp->getWindowHandle(); - NSWindow* pluginWindow = [pluginView window]; - [pluginWindow setExcludedFromWindowsMenu: YES]; - [pluginWindow setCanHide: YES]; - - [hostWindow addChildWindow: pluginWindow - ordered: NSWindowAbove]; - [hostWindow orderFront: nil]; - [pluginWindow orderFront: nil]; - -#if ADD_CARBON_BODGE - // Adds a callback bodge to work around some problems with wrapped - // carbon windows.. - const EventTypeSpec eventsToCatch[] = { - { kEventClassWindow, kEventWindowShown }, - { kEventClassWindow, kEventWindowHidden } - }; - - EventHandlerRef ref; - InstallWindowEventHandler ((WindowRef) windowRef, - NewEventHandlerUPP (windowVisibilityBodge), - GetEventTypeCount (eventsToCatch), eventsToCatch, - (void*) hostWindow, &ref); - comp->setComponentProperty ("carbonEventRef", String::toHexString ((pointer_sized_int) (void*) ref)); -#endif - - return hostWindow; -} - -void detachComponentFromWindowRef (Component* comp, void* nsWindow) -{ - const ScopedAutoReleasePool pool; - -#if ADD_CARBON_BODGE - EventHandlerRef ref = (EventHandlerRef) (void*) (pointer_sized_int) - comp->getComponentProperty ("carbonEventRef", false, String::empty).getHexValue64(); - RemoveEventHandler (ref); -#endif - - NSWindow* hostWindow = (NSWindow*) nsWindow; - NSView* pluginView = (NSView*) comp->getWindowHandle(); - NSWindow* pluginWindow = [pluginView window]; - - [hostWindow removeChildWindow: pluginWindow]; - comp->removeFromDesktop(); - - [hostWindow release]; - - // The event loop needs to be run between closing the window and deleting the plugin, - // presumably to let the cocoa objects get tidied up. Leaving out this line causes crashes - // in Live when you delete the plugin with its window open. - MessageManager::getInstance()->runDispatchLoopUntil (10); -} - -void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight) -{ - NSWindow* hostWindow = (NSWindow*) nsWindow; - if (hostWindow != 0) - { - ScopedAutoReleasePool pool; - - // Can't use the cocoa NSWindow resizing code, or it messes up in Live. - Rect r; - GetWindowBounds ((WindowRef) [hostWindow windowRef], kWindowContentRgn, &r); - r.right += newWidth - component->getWidth(); - r.bottom += newHeight - component->getHeight(); - SetWindowBounds ((WindowRef) [hostWindow windowRef], kWindowContentRgn, &r); - - [[hostWindow contentView] setNeedsDisplay: YES]; - } -} - -void checkWindowVisibility (void* nsWindow, Component* comp) -{ - NSWindow* hostWindow = (NSWindow*) nsWindow; - comp->setVisible ([hostWindow isVisible]); -} - -END_JUCE_NAMESPACE - -#endif +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 by Raw Material Software Ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. + + ============================================================================== +*/ + +//============================================================================== +#include "../juce_IncludeCharacteristics.h" + +#if JucePlugin_Build_VST + +#include + +#define ADD_CARBON_BODGE 1 // see note below.. + +#include + +#include "../juce_PluginHeaders.h" + +//============================================================================== +BEGIN_JUCE_NAMESPACE + +#if ADD_CARBON_BODGE +/* When you wrap a WindowRef as an NSWindow, it seems to bugger up the HideWindow + function, so when the host tries (and fails) to hide the window, this catches + the event and does the job properly. +*/ + +static pascal OSStatus windowVisibilityBodge (EventHandlerCallRef, EventRef e, void* user) +{ + NSWindow* hostWindow = (NSWindow*) user; + + switch (GetEventKind (e)) + { + case kEventWindowShown: + [hostWindow orderFront: nil]; + break; + case kEventWindowHidden: + [hostWindow orderOut: nil]; + break; + } + + return eventNotHandledErr; +} +#endif + +//============================================================================== +void initialiseMac() +{ + NSApplicationLoad(); +} + +void* attachComponentToWindowRef (Component* comp, void* windowRef) +{ + const ScopedAutoReleasePool pool; + + NSWindow* hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef]; + [hostWindow retain]; + [hostWindow setCanHide: YES]; + [hostWindow setReleasedWhenClosed: YES]; + + NSView* content = [hostWindow contentView]; + NSRect f = [content frame]; + NSPoint windowPos = [hostWindow convertBaseToScreen: f.origin]; + windowPos.y = [[NSScreen mainScreen] frame].size.height - (windowPos.y + f.size.height); + comp->setTopLeftPosition ((int) windowPos.x, (int) windowPos.y); + +#if ! JucePlugin_EditorRequiresKeyboardFocus + comp->addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses); +#else + comp->addToDesktop (ComponentPeer::windowIsTemporary); +#endif + + comp->setVisible (true); + comp->toFront (false); + + NSView* pluginView = (NSView*) comp->getWindowHandle(); + NSWindow* pluginWindow = [pluginView window]; + [pluginWindow setExcludedFromWindowsMenu: YES]; + [pluginWindow setCanHide: YES]; + + [hostWindow addChildWindow: pluginWindow + ordered: NSWindowAbove]; + [hostWindow orderFront: nil]; + [pluginWindow orderFront: nil]; + +#if ADD_CARBON_BODGE + // Adds a callback bodge to work around some problems with wrapped + // carbon windows.. + const EventTypeSpec eventsToCatch[] = { + { kEventClassWindow, kEventWindowShown }, + { kEventClassWindow, kEventWindowHidden } + }; + + EventHandlerRef ref; + InstallWindowEventHandler ((WindowRef) windowRef, + NewEventHandlerUPP (windowVisibilityBodge), + GetEventTypeCount (eventsToCatch), eventsToCatch, + (void*) hostWindow, &ref); + comp->setComponentProperty ("carbonEventRef", String::toHexString ((pointer_sized_int) (void*) ref)); +#endif + + return hostWindow; +} + +void detachComponentFromWindowRef (Component* comp, void* nsWindow) +{ + { + const ScopedAutoReleasePool pool; + +#if ADD_CARBON_BODGE + EventHandlerRef ref = (EventHandlerRef) (void*) (pointer_sized_int) + comp->getComponentProperty ("carbonEventRef", false, String::empty).getHexValue64(); + RemoveEventHandler (ref); +#endif + + NSWindow* hostWindow = (NSWindow*) nsWindow; + NSView* pluginView = (NSView*) comp->getWindowHandle(); + NSWindow* pluginWindow = [pluginView window]; + + [hostWindow removeChildWindow: pluginWindow]; + comp->removeFromDesktop(); + + [hostWindow release]; + } + + // The event loop needs to be run between closing the window and deleting the plugin, + // presumably to let the cocoa objects get tidied up. Leaving out this line causes crashes + // in Live and Reaper when you delete the plugin with its window open. + // (Doing it this way rather than using a single longer timout means that w can guarantee + // how many messages will be dispatched, which seems to be vital in Reaper) + for (int i = 20; --i >= 0;) + MessageManager::getInstance()->runDispatchLoopUntil (1); +} + +void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight) +{ + NSWindow* hostWindow = (NSWindow*) nsWindow; + if (hostWindow != 0) + { + ScopedAutoReleasePool pool; + + // Can't use the cocoa NSWindow resizing code, or it messes up in Live. + Rect r; + GetWindowBounds ((WindowRef) [hostWindow windowRef], kWindowContentRgn, &r); + r.right += newWidth - component->getWidth(); + r.bottom += newHeight - component->getHeight(); + SetWindowBounds ((WindowRef) [hostWindow windowRef], kWindowContentRgn, &r); + + [[hostWindow contentView] setNeedsDisplay: YES]; + } +} + +void checkWindowVisibility (void* nsWindow, Component* comp) +{ + NSWindow* hostWindow = (NSWindow*) nsWindow; + comp->setVisible ([hostWindow isVisible]); +} + +END_JUCE_NAMESPACE + +#endif diff --git a/juce.h b/juce.h index 06b79ff6bc..638e101558 100644 --- a/juce.h +++ b/juce.h @@ -2,29 +2,23 @@ ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. + Copyright 2004-9 by Raw Material Software Ltd. ------------------------------------------------------------------------------ - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. - JUCE is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. ------------------------------------------------------------------------------ - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ diff --git a/juce_Config.h b/juce_Config.h index dec4999a98..ec09a72e4d 100644 --- a/juce_Config.h +++ b/juce_Config.h @@ -1,257 +1,251 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#ifndef __JUCE_CONFIG_JUCEHEADER__ -#define __JUCE_CONFIG_JUCEHEADER__ - -//============================================================================== -/* - This file contains macros that enable/disable various JUCE features. -*/ - -//============================================================================= -/** The name of the namespace that all Juce classes and functions will be - put inside. If this is not defined, no namespace will be used. -*/ -#ifndef JUCE_NAMESPACE - #define JUCE_NAMESPACE juce -#endif - -//============================================================================= -/** Normally, JUCE_DEBUG is set to 1 or 0 based on compiler and project settings, - but if you define this value, you can override this can force it to be true or - false. -*/ -#ifndef JUCE_FORCE_DEBUG - //#define JUCE_FORCE_DEBUG 1 -#endif - -//============================================================================= -/** If this flag is enabled, the the jassert and jassertfalse macros will - always use Logger::writeToLog() to write a message when an assertion happens. - - Enabling it will also leave this turned on in release builds. When it's disabled, - however, the jassert and jassertfalse macros will not be compiled in a - release build. - - @see jassert, jassertfalse, Logger -*/ -#ifndef JUCE_LOG_ASSERTIONS -// #define JUCE_LOG_ASSERTIONS 1 -#endif - -//============================================================================= -/** Comment out this macro if you haven't got the Steinberg ASIO SDK, without - which the ASIOAudioIODevice class can't be built. See the comments in the - ASIOAudioIODevice class's header file for more info about this. - - (This only affects a Win32 build) -*/ -#ifndef JUCE_ASIO - #define JUCE_ASIO 1 -#endif - -/** Comment out this macro to disable building of ALSA device support on Linux. -*/ -#ifndef JUCE_ALSA - #define JUCE_ALSA 1 -#endif - -//============================================================================= -/** Comment out this macro if you don't want to enable QuickTime or if you don't - have the SDK installed. - - If this flag is not enabled, the QuickTimeMovieComponent and QuickTimeAudioFormat - classes will be unavailable. - - On Windows, if you enable this, you'll need to have the QuickTime SDK - installed, and its header files will need to be on your include path. -*/ -#if ! (defined (JUCE_QUICKTIME) || defined (LINUX) || (defined (_WIN32) && ! defined (_MSC_VER))) - #define JUCE_QUICKTIME 1 -#endif - - -//============================================================================= -/** Comment out this macro if you don't want to enable OpenGL or if you don't - have the appropriate headers and libraries available. If it's not enabled, the - OpenGLComponent class will be unavailable. -*/ -#ifndef JUCE_OPENGL - #define JUCE_OPENGL 1 -#endif - -//============================================================================= -/** These flags enable the Ogg-Vorbis and Flac audio formats. - - If you're not going to need either of these formats, turn off the flags to - avoid bloating your codebase with them. -*/ -#ifndef JUCE_USE_FLAC - #define JUCE_USE_FLAC 1 -#endif - -#ifndef JUCE_USE_OGGVORBIS - #define JUCE_USE_OGGVORBIS 1 -#endif - -//============================================================================= -/** This flag lets you enable support for CD-burning. You might want to disable - it to build without the MS SDK under windows. -*/ -#if (! defined (JUCE_USE_CDBURNER)) && ! (defined (_WIN32) && ! defined (_MSC_VER)) - #define JUCE_USE_CDBURNER 1 -#endif - -//============================================================================= -/** Enabling this provides support for cameras, using the CameraDevice class -*/ -#if JUCE_QUICKTIME && ! defined (JUCE_USE_CAMERA) -// #define JUCE_USE_CAMERA 1 -#endif - -//============================================================================= -/** Enabling this macro means that all regions that get repainted will have a coloured - line drawn around them. - - This is handy if you're trying to optimise drawing, because it lets you easily see - when anything is being repainted unnecessarily. -*/ -#ifndef JUCE_ENABLE_REPAINT_DEBUGGING -// #define JUCE_ENABLE_REPAINT_DEBUGGING 1 -#endif - -//============================================================================= -/** Enable this under Linux to use Xinerama for multi-monitor support. -*/ -#ifndef JUCE_USE_XINERAMA - #define JUCE_USE_XINERAMA 1 -#endif - -/** Enable this under Linux to use XShm for faster shared-memory rendering. -*/ -#ifndef JUCE_USE_XSHM - #define JUCE_USE_XSHM 1 -#endif - -//============================================================================= -/** Enabling this builds support for VST audio plugins. - @see VSTPluginFormat, AudioPluginFormat, AudioPluginFormatManager, JUCE_PLUGINHOST_AU -*/ -#ifndef JUCE_PLUGINHOST_VST -// #define JUCE_PLUGINHOST_VST 1 -#endif - -/** Enabling this builds support for AudioUnit audio plugins. - @see AudioUnitPluginFormat, AudioPluginFormat, AudioPluginFormatManager, JUCE_PLUGINHOST_VST -*/ -#ifndef JUCE_PLUGINHOST_AU -// #define JUCE_PLUGINHOST_AU 1 -#endif - -//============================================================================= -/** Enabling this will avoid including any UI code in the build. This is handy for - writing command-line utilities, e.g. on linux boxes which don't have some - of the UI libraries installed. -*/ -#ifndef JUCE_ONLY_BUILD_CORE_LIBRARY - //#define JUCE_ONLY_BUILD_CORE_LIBRARY 1 -#endif - -/** This lets you disable building of the WebBrowserComponent, if it's not required. -*/ -#ifndef JUCE_WEB_BROWSER - #define JUCE_WEB_BROWSER 1 -#endif - - -//============================================================================= -/** Setting this allows the build to use old Carbon libraries that will be - deprecated in newer versions of OSX. This is handy for some backwards-compatibility - reasons. -*/ -#ifndef JUCE_SUPPORT_CARBON - #define JUCE_SUPPORT_CARBON 1 -#endif - -//============================================================================= -/* These flags let you avoid the direct inclusion of some 3rd-party libs in the - codebase - you might need to use this if you're linking to some of these libraries - yourself. -*/ -#ifndef JUCE_INCLUDE_ZLIB_CODE - #define JUCE_INCLUDE_ZLIB_CODE 1 -#endif - -#ifndef JUCE_INCLUDE_FLAC_CODE - #define JUCE_INCLUDE_FLAC_CODE 1 -#endif - -#ifndef JUCE_INCLUDE_OGGVORBIS_CODE - #define JUCE_INCLUDE_OGGVORBIS_CODE 1 -#endif - -#ifndef JUCE_INCLUDE_PNGLIB_CODE - #define JUCE_INCLUDE_PNGLIB_CODE 1 -#endif - -#ifndef JUCE_INCLUDE_JPEGLIB_CODE - #define JUCE_INCLUDE_JPEGLIB_CODE 1 -#endif - -//============================================================================= -/** Enable this to add extra memory-leak info to the new and delete operators. - - (Currently, this only affects Windows builds in debug mode). -*/ -#ifndef JUCE_CHECK_MEMORY_LEAKS - #define JUCE_CHECK_MEMORY_LEAKS 1 -#endif - -/** Enable this to turn on juce's internal catching of exceptions. - - Turning it off will avoid any exception catching. With it on, all exceptions - are passed to the JUCEApplication::unhandledException() callback for logging. -*/ -#ifndef JUCE_CATCH_UNHANDLED_EXCEPTIONS - #define JUCE_CATCH_UNHANDLED_EXCEPTIONS 1 -#endif - -/** If this macro is set, the Juce String class will use unicode as its - internal representation. If it isn't set, it'll use ANSI. -*/ -#ifndef JUCE_STRINGS_ARE_UNICODE - #define JUCE_STRINGS_ARE_UNICODE 1 -#endif - -//============================================================================= - -#endif +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 by Raw Material Software Ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. + + ============================================================================== +*/ + +#ifndef __JUCE_CONFIG_JUCEHEADER__ +#define __JUCE_CONFIG_JUCEHEADER__ + +//============================================================================== +/* + This file contains macros that enable/disable various JUCE features. +*/ + +//============================================================================= +/** The name of the namespace that all Juce classes and functions will be + put inside. If this is not defined, no namespace will be used. +*/ +#ifndef JUCE_NAMESPACE + #define JUCE_NAMESPACE juce +#endif + +//============================================================================= +/** Normally, JUCE_DEBUG is set to 1 or 0 based on compiler and project settings, + but if you define this value, you can override this can force it to be true or + false. +*/ +#ifndef JUCE_FORCE_DEBUG + //#define JUCE_FORCE_DEBUG 1 +#endif + +//============================================================================= +/** If this flag is enabled, the the jassert and jassertfalse macros will + always use Logger::writeToLog() to write a message when an assertion happens. + + Enabling it will also leave this turned on in release builds. When it's disabled, + however, the jassert and jassertfalse macros will not be compiled in a + release build. + + @see jassert, jassertfalse, Logger +*/ +#ifndef JUCE_LOG_ASSERTIONS +// #define JUCE_LOG_ASSERTIONS 1 +#endif + +//============================================================================= +/** Comment out this macro if you haven't got the Steinberg ASIO SDK, without + which the ASIOAudioIODevice class can't be built. See the comments in the + ASIOAudioIODevice class's header file for more info about this. + + (This only affects a Win32 build) +*/ +#ifndef JUCE_ASIO + #define JUCE_ASIO 1 +#endif + +/** Comment out this macro to disable building of ALSA device support on Linux. +*/ +#ifndef JUCE_ALSA + #define JUCE_ALSA 1 +#endif + +//============================================================================= +/** Comment out this macro if you don't want to enable QuickTime or if you don't + have the SDK installed. + + If this flag is not enabled, the QuickTimeMovieComponent and QuickTimeAudioFormat + classes will be unavailable. + + On Windows, if you enable this, you'll need to have the QuickTime SDK + installed, and its header files will need to be on your include path. +*/ +#if ! (defined (JUCE_QUICKTIME) || defined (LINUX) || (defined (_WIN32) && ! defined (_MSC_VER))) + #define JUCE_QUICKTIME 1 +#endif + + +//============================================================================= +/** Comment out this macro if you don't want to enable OpenGL or if you don't + have the appropriate headers and libraries available. If it's not enabled, the + OpenGLComponent class will be unavailable. +*/ +#ifndef JUCE_OPENGL + #define JUCE_OPENGL 1 +#endif + +//============================================================================= +/** These flags enable the Ogg-Vorbis and Flac audio formats. + + If you're not going to need either of these formats, turn off the flags to + avoid bloating your codebase with them. +*/ +#ifndef JUCE_USE_FLAC + #define JUCE_USE_FLAC 1 +#endif + +#ifndef JUCE_USE_OGGVORBIS + #define JUCE_USE_OGGVORBIS 1 +#endif + +//============================================================================= +/** This flag lets you enable support for CD-burning. You might want to disable + it to build without the MS SDK under windows. +*/ +#if (! defined (JUCE_USE_CDBURNER)) && ! (defined (_WIN32) && ! defined (_MSC_VER)) + #define JUCE_USE_CDBURNER 1 +#endif + +//============================================================================= +/** Enabling this provides support for cameras, using the CameraDevice class +*/ +#if JUCE_QUICKTIME && ! defined (JUCE_USE_CAMERA) +// #define JUCE_USE_CAMERA 1 +#endif + +//============================================================================= +/** Enabling this macro means that all regions that get repainted will have a coloured + line drawn around them. + + This is handy if you're trying to optimise drawing, because it lets you easily see + when anything is being repainted unnecessarily. +*/ +#ifndef JUCE_ENABLE_REPAINT_DEBUGGING +// #define JUCE_ENABLE_REPAINT_DEBUGGING 1 +#endif + +//============================================================================= +/** Enable this under Linux to use Xinerama for multi-monitor support. +*/ +#ifndef JUCE_USE_XINERAMA + #define JUCE_USE_XINERAMA 1 +#endif + +/** Enable this under Linux to use XShm for faster shared-memory rendering. +*/ +#ifndef JUCE_USE_XSHM + #define JUCE_USE_XSHM 1 +#endif + +//============================================================================= +/** Enabling this builds support for VST audio plugins. + @see VSTPluginFormat, AudioPluginFormat, AudioPluginFormatManager, JUCE_PLUGINHOST_AU +*/ +#ifndef JUCE_PLUGINHOST_VST +// #define JUCE_PLUGINHOST_VST 1 +#endif + +/** Enabling this builds support for AudioUnit audio plugins. + @see AudioUnitPluginFormat, AudioPluginFormat, AudioPluginFormatManager, JUCE_PLUGINHOST_VST +*/ +#ifndef JUCE_PLUGINHOST_AU +// #define JUCE_PLUGINHOST_AU 1 +#endif + +//============================================================================= +/** Enabling this will avoid including any UI code in the build. This is handy for + writing command-line utilities, e.g. on linux boxes which don't have some + of the UI libraries installed. +*/ +#ifndef JUCE_ONLY_BUILD_CORE_LIBRARY + //#define JUCE_ONLY_BUILD_CORE_LIBRARY 1 +#endif + +/** This lets you disable building of the WebBrowserComponent, if it's not required. +*/ +#ifndef JUCE_WEB_BROWSER + #define JUCE_WEB_BROWSER 1 +#endif + + +//============================================================================= +/** Setting this allows the build to use old Carbon libraries that will be + deprecated in newer versions of OSX. This is handy for some backwards-compatibility + reasons. +*/ +#ifndef JUCE_SUPPORT_CARBON + #define JUCE_SUPPORT_CARBON 1 +#endif + +//============================================================================= +/* These flags let you avoid the direct inclusion of some 3rd-party libs in the + codebase - you might need to use this if you're linking to some of these libraries + yourself. +*/ +#ifndef JUCE_INCLUDE_ZLIB_CODE + #define JUCE_INCLUDE_ZLIB_CODE 1 +#endif + +#ifndef JUCE_INCLUDE_FLAC_CODE + #define JUCE_INCLUDE_FLAC_CODE 1 +#endif + +#ifndef JUCE_INCLUDE_OGGVORBIS_CODE + #define JUCE_INCLUDE_OGGVORBIS_CODE 1 +#endif + +#ifndef JUCE_INCLUDE_PNGLIB_CODE + #define JUCE_INCLUDE_PNGLIB_CODE 1 +#endif + +#ifndef JUCE_INCLUDE_JPEGLIB_CODE + #define JUCE_INCLUDE_JPEGLIB_CODE 1 +#endif + +//============================================================================= +/** Enable this to add extra memory-leak info to the new and delete operators. + + (Currently, this only affects Windows builds in debug mode). +*/ +#ifndef JUCE_CHECK_MEMORY_LEAKS + #define JUCE_CHECK_MEMORY_LEAKS 1 +#endif + +/** Enable this to turn on juce's internal catching of exceptions. + + Turning it off will avoid any exception catching. With it on, all exceptions + are passed to the JUCEApplication::unhandledException() callback for logging. +*/ +#ifndef JUCE_CATCH_UNHANDLED_EXCEPTIONS + #define JUCE_CATCH_UNHANDLED_EXCEPTIONS 1 +#endif + +/** If this macro is set, the Juce String class will use unicode as its + internal representation. If it isn't set, it'll use ANSI. +*/ +#ifndef JUCE_STRINGS_ARE_UNICODE + #define JUCE_STRINGS_ARE_UNICODE 1 +#endif + +//============================================================================= + +#endif diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index d219481b94..a1b5aeec5e 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -2,29 +2,23 @@ ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. + Copyright 2004-9 by Raw Material Software Ltd. ------------------------------------------------------------------------------ - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. - JUCE is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. ------------------------------------------------------------------------------ - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ @@ -3836,6 +3830,12 @@ void DynamicObject::setMethod (const var::identifier& name, setProperty (name, methodFunction); } +void DynamicObject::clear() +{ + propertyIds.clear(); + propertyValues.clear(); +} + END_JUCE_NAMESPACE /********* End of inlined file: juce_Variant.cpp *********/ @@ -260866,6 +260866,7 @@ static int numPendingMessages = 0; NSData* data = (NSData*) n; void* message = 0; [data getBytes: &message length: sizeof (message)]; + [data release]; if (message != 0 && ! flushingMessages) redirector->deliverMessage (message); @@ -261003,7 +261004,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) uint32 endTime = Time::getMillisecondCounter() + millisecondsToRunFor; NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001]; - while (Time::getMillisecondCounter() < endTime && ! quitMessagePosted) + while (! quitMessagePosted) { const ScopedAutoReleasePool pool; @@ -261017,6 +261018,9 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) if (e != 0 && ! isEventBlockedByModalComps (e)) [NSApp sendEvent: e]; + + if (Time::getMillisecondCounter() >= endTime) + break; } return ! quitMessagePosted; @@ -261065,7 +261069,7 @@ bool juce_postMessageToSystemQueue (void* message) atomicIncrement (numPendingMessages); [juceAppDelegate performSelectorOnMainThread: @selector (customEvent:) - withObject: (id) [NSData dataWithBytes: &message length: (int) sizeof (message)] + withObject: (id) [[NSData alloc] initWithBytes: &message length: (int) sizeof (message)] waitUntilDone: NO]; return true; } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 0615874acd..bfed6919f4 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -2,29 +2,23 @@ ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. + Copyright 2004-9 by Raw Material Software Ltd. ------------------------------------------------------------------------------ - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. - JUCE is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. ------------------------------------------------------------------------------ - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ @@ -11599,6 +11593,9 @@ public: void setMethod (const var::identifier& methodName, var::MethodFunction methodFunction); + /** Removes all properties and methods from the object. */ + void clear(); + juce_UseDebuggingNewOperator private: diff --git a/src/juce_core/containers/juce_Variant.cpp b/src/juce_core/containers/juce_Variant.cpp index c876bd87ac..049424911c 100644 --- a/src/juce_core/containers/juce_Variant.cpp +++ b/src/juce_core/containers/juce_Variant.cpp @@ -429,4 +429,10 @@ void DynamicObject::setMethod (const var::identifier& name, setProperty (name, methodFunction); } +void DynamicObject::clear() +{ + propertyIds.clear(); + propertyValues.clear(); +} + END_JUCE_NAMESPACE diff --git a/src/juce_core/containers/juce_Variant.h b/src/juce_core/containers/juce_Variant.h index a147c9b3e8..f6d98bf657 100644 --- a/src/juce_core/containers/juce_Variant.h +++ b/src/juce_core/containers/juce_Variant.h @@ -231,6 +231,10 @@ public: void setMethod (const var::identifier& methodName, var::MethodFunction methodFunction); + //============================================================================== + /** Removes all properties and methods from the object. */ + void clear(); + //============================================================================== juce_UseDebuggingNewOperator