diff --git a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp index a98e02a369..7c3cef2e25 100644 --- a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp @@ -99,7 +99,7 @@ private: owner.setParameter (index, newVal); } - const String getTextFromValue (double /*value*/) + String getTextFromValue (double /*value*/) { return owner.getParameterText (index); } diff --git a/modules/juce_events/native/juce_mac_MessageManager.mm b/modules/juce_events/native/juce_mac_MessageManager.mm index 6a882107b2..ec24ad1e13 100644 --- a/modules/juce_events/native/juce_mac_MessageManager.mm +++ b/modules/juce_events/native/juce_mac_MessageManager.mm @@ -125,7 +125,7 @@ private: CFRunLoopSourceRef runLoopSource; MessageQueue messageQueue; - static const String quotedIfContainsSpaces (NSString* file) + static String quotedIfContainsSpaces (NSString* file) { String s (nsStringToJuce (file)); if (s.containsChar (' ')) @@ -144,15 +144,13 @@ using namespace juce; //============================================================================== @interface JuceAppDelegate : NSObject { -@private - id oldDelegate; - @public AppDelegateRedirector* redirector; } - (JuceAppDelegate*) init; - (void) dealloc; +- (void) unregisterObservers; - (BOOL) application: (NSApplication*) theApplication openFile: (NSString*) filename; - (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames; - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app; @@ -173,11 +171,8 @@ using namespace juce; redirector = new AppDelegateRedirector(); - NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; - if (JUCEApplicationBase::isStandaloneApp()) { - oldDelegate = [NSApp delegate]; [NSApp setDelegate: self]; [[NSDistributedNotificationCenter defaultCenter] addObserver: self @@ -187,7 +182,8 @@ using namespace juce; } else { - oldDelegate = nil; + NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; + [center addObserver: self selector: @selector (applicationDidResignActive:) name: NSApplicationDidResignActiveNotification object: NSApp]; @@ -203,17 +199,25 @@ using namespace juce; - (void) dealloc { - if (oldDelegate != nil) - [NSApp setDelegate: oldDelegate]; - - [[NSDistributedNotificationCenter defaultCenter] removeObserver: self - name: AppDelegateRedirector::getBroacastEventName() - object: nil]; - redirector->deleteSelf(); [super dealloc]; } +- (void) unregisterObservers +{ + [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget: self]; + [[NSNotificationCenter defaultCenter] removeObserver: self]; + + if (JUCEApplicationBase::isStandaloneApp()) + { + [NSApp setDelegate: nil]; + + [[NSDistributedNotificationCenter defaultCenter] removeObserver: self + name: AppDelegateRedirector::getBroacastEventName() + object: nil]; + } +} + - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app { (void) app; @@ -357,10 +361,8 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) //============================================================================== void initialiseNSApplication() { - #if JUCE_MAC JUCE_AUTORELEASEPOOL [NSApplication sharedApplication]; - #endif } void MessageManager::doPlatformSpecificInitialisation() @@ -368,20 +370,20 @@ void MessageManager::doPlatformSpecificInitialisation() if (juceAppDelegate == nil) juceAppDelegate = [[JuceAppDelegate alloc] init]; - // This launches a dummy thread, which forces Cocoa to initialise NSThreads - // correctly (needed prior to 10.5) + #if ! (defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) + // This launches a dummy thread, which forces Cocoa to initialise NSThreads correctly (needed prior to 10.5) if (! [NSThread isMultiThreaded]) [NSThread detachNewThreadSelector: @selector (dummyMethod) toTarget: juceAppDelegate withObject: nil]; + #endif } void MessageManager::doPlatformSpecificShutdown() { if (juceAppDelegate != nil) { - [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget: juceAppDelegate]; - [[NSNotificationCenter defaultCenter] removeObserver: juceAppDelegate]; + [juceAppDelegate unregisterObservers]; [juceAppDelegate release]; juceAppDelegate = nil; } diff --git a/modules/juce_graphics/native/juce_mac_Fonts.mm b/modules/juce_graphics/native/juce_mac_Fonts.mm index 618158750e..a01d4d6307 100644 --- a/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -646,11 +646,11 @@ private: const int idRangeOffsetOffset = idDeltaOffset + segCountX2; const int glyphIndexesOffset = idRangeOffsetOffset + segCountX2; - endCode = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + endCodeOffset, segCountX2); - startCode = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + startCodeOffset, segCountX2); - idDelta = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + idDeltaOffset, segCountX2); + endCode = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + endCodeOffset, segCountX2); + startCode = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + startCodeOffset, segCountX2); + idDelta = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + idDeltaOffset, segCountX2); idRangeOffset = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + idRangeOffsetOffset, segCountX2); - glyphIndexes = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + glyphIndexesOffset, offset + length - glyphIndexesOffset); + glyphIndexes = CFDataCreate (kCFAllocatorDefault, CFDataGetBytePtr (cmapTable) + glyphIndexesOffset, offset + length - glyphIndexesOffset); } break; diff --git a/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp b/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp index c10306fb79..b3a9cf0355 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp +++ b/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp @@ -195,7 +195,7 @@ namespace KeyPressHelpers } //============================================================================== -const KeyPress KeyPress::createFromDescription (const String& desc) +KeyPress KeyPress::createFromDescription (const String& desc) { int modifiers = 0; diff --git a/modules/juce_gui_basics/keyboard/juce_KeyPress.h b/modules/juce_gui_basics/keyboard/juce_KeyPress.h index 28b3b85d0c..7599f377c7 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyPress.h +++ b/modules/juce_gui_basics/keyboard/juce_KeyPress.h @@ -105,7 +105,7 @@ public: @see ModifierKeys */ - const ModifierKeys getModifiers() const noexcept { return mods; } + ModifierKeys getModifiers() const noexcept { return mods; } /** Returns the character that is associated with this keypress. @@ -136,7 +136,7 @@ public: @see getTextDescription */ - static const KeyPress createFromDescription (const String& textVersion); + static KeyPress createFromDescription (const String& textVersion); /** Creates a textual description of the key combination. diff --git a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp index 7f2a989cd5..46a463b4fc 100644 --- a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp +++ b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp @@ -25,7 +25,7 @@ BEGIN_JUCE_NAMESPACE -//============================================================================== + ModifierKeys::ModifierKeys() noexcept : flags (0) { diff --git a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h index 2b35ceb722..5e2773d399 100644 --- a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h +++ b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h @@ -64,7 +64,7 @@ public: preferred command-key modifier - so on the Mac it tests for the Apple key, on Windows/Linux, it's actually checking for the CTRL key. */ - inline bool isCommandDown() const noexcept { return (flags & commandModifier) != 0; } + inline bool isCommandDown() const noexcept { return testFlags (commandModifier); } /** Checks whether the user is trying to launch a pop-up menu. @@ -74,28 +74,28 @@ public: So on Windows/Linux, this method is really testing for a right-click. On the Mac, it tests for either the CTRL key being down, or a right-click. */ - inline bool isPopupMenu() const noexcept { return (flags & popupMenuClickModifier) != 0; } + inline bool isPopupMenu() const noexcept { return testFlags (popupMenuClickModifier); } /** Checks whether the flag is set for the left mouse-button. */ - inline bool isLeftButtonDown() const noexcept { return (flags & leftButtonModifier) != 0; } + inline bool isLeftButtonDown() const noexcept { return testFlags (leftButtonModifier); } /** Checks whether the flag is set for the right mouse-button. Note that for detecting popup-menu clicks, you should be using isPopupMenu() instead, as this is platform-independent (and makes your code more explanatory too). */ - inline bool isRightButtonDown() const noexcept { return (flags & rightButtonModifier) != 0; } + inline bool isRightButtonDown() const noexcept { return testFlags (rightButtonModifier); } - inline bool isMiddleButtonDown() const noexcept { return (flags & middleButtonModifier) != 0; } + inline bool isMiddleButtonDown() const noexcept { return testFlags (middleButtonModifier); } /** Tests for any of the mouse-button flags. */ - inline bool isAnyMouseButtonDown() const noexcept { return (flags & allMouseButtonModifiers) != 0; } + inline bool isAnyMouseButtonDown() const noexcept { return testFlags (allMouseButtonModifiers); } /** Tests for any of the modifier key flags. */ - inline bool isAnyModifierKeyDown() const noexcept { return (flags & (shiftModifier | ctrlModifier | altModifier | commandModifier)) != 0; } + inline bool isAnyModifierKeyDown() const noexcept { return testFlags ((shiftModifier | ctrlModifier | altModifier | commandModifier)); } /** Checks whether the shift key's flag is set. */ - inline bool isShiftDown() const noexcept { return (flags & shiftModifier) != 0; } + inline bool isShiftDown() const noexcept { return testFlags (shiftModifier); } /** Checks whether the CTRL key's flag is set. @@ -104,10 +104,10 @@ public: @see isCommandDown, isPopupMenu */ - inline bool isCtrlDown() const noexcept { return (flags & ctrlModifier) != 0; } + inline bool isCtrlDown() const noexcept { return testFlags (ctrlModifier); } /** Checks whether the shift key's flag is set. */ - inline bool isAltDown() const noexcept { return (flags & altModifier) != 0; } + inline bool isAltDown() const noexcept { return testFlags (altModifier); } //============================================================================== /** Flags that represent the different keys. */ @@ -206,11 +206,11 @@ private: //============================================================================== int flags; - static ModifierKeys currentModifiers; - friend class ComponentPeer; friend class MouseInputSource; friend class MouseInputSourceInternal; + + static ModifierKeys currentModifiers; static void updateCurrentModifiers() noexcept; }; diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index cfbcac8a54..ac8baf268f 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -643,7 +643,7 @@ String Slider::getTextValueSuffix() const return textSuffix; } -const String Slider::getTextFromValue (double v) +String Slider::getTextFromValue (double v) { if (getNumDecimalPlacesToDisplay() > 0) return String (v, getNumDecimalPlacesToDisplay()) + getTextValueSuffix(); diff --git a/modules/juce_gui_basics/widgets/juce_Slider.h b/modules/juce_gui_basics/widgets/juce_Slider.h index 881a233dd4..4ce1b5fd31 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.h +++ b/modules/juce_gui_basics/widgets/juce_Slider.h @@ -671,7 +671,7 @@ public: @see getValueFromText */ - virtual const String getTextFromValue (double value); + virtual String getTextFromValue (double value); /** Sets a suffix to append to the end of the numeric value when it's displayed as a string. diff --git a/modules/juce_gui_extra/misc/juce_ColourSelector.cpp b/modules/juce_gui_extra/misc/juce_ColourSelector.cpp index 2145c4d3b5..b2ebc73c0d 100644 --- a/modules/juce_gui_extra/misc/juce_ColourSelector.cpp +++ b/modules/juce_gui_extra/misc/juce_ColourSelector.cpp @@ -35,7 +35,7 @@ public: setRange (0.0, 255.0, 1.0); } - const String getTextFromValue (double value) + String getTextFromValue (double value) { return String::toHexString ((int) value).toUpperCase().paddedLeft ('0', 2); }