From dd2209352676d2eab176f43de212abb5dfd363b0 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Sat, 16 Apr 2011 22:09:19 +0100 Subject: [PATCH] Cleaned up some obj-C autorelease code. --- src/core/juce_PlatformUtilities.h | 30 +++++++------- src/native/mac/juce_ios_MessageManager.mm | 6 +-- src/native/mac/juce_ios_MiscUtilities.mm | 6 +-- .../mac/juce_ios_UIViewComponentPeer.mm | 2 +- src/native/mac/juce_mac_AudioCDBurner.mm | 2 +- src/native/mac/juce_mac_CameraDevice.mm | 14 +++---- .../mac/juce_mac_CoreGraphicsContext.mm | 2 +- src/native/mac/juce_mac_FileChooser.mm | 4 +- src/native/mac/juce_mac_Files.mm | 41 +++++++++---------- src/native/mac/juce_mac_Fonts.mm | 12 +++--- src/native/mac/juce_mac_MainMenu.mm | 4 +- src/native/mac/juce_mac_MessageManager.mm | 6 +-- src/native/mac/juce_mac_MiscUtilities.mm | 8 ++-- src/native/mac/juce_mac_MouseCursor.mm | 2 +- .../mac/juce_mac_NSViewComponentPeer.mm | 4 +- src/native/mac/juce_mac_NativeCode.mm | 2 +- src/native/mac/juce_mac_Network.mm | 13 +++--- src/native/mac/juce_mac_OpenGLComponent.mm | 2 +- src/native/mac/juce_mac_Strings.mm | 2 +- src/native/mac/juce_mac_Threads.mm | 6 +-- src/native/windows/juce_win32_SystemStats.cpp | 6 +-- 21 files changed, 83 insertions(+), 91 deletions(-) diff --git a/src/core/juce_PlatformUtilities.h b/src/core/juce_PlatformUtilities.h index c2b2e955ef..ebf2cb1a54 100644 --- a/src/core/juce_PlatformUtilities.h +++ b/src/core/juce_PlatformUtilities.h @@ -203,28 +203,26 @@ private: //============================================================================== -#if JUCE_MAC || JUCE_IOS +#if JUCE_MAC || JUCE_IOS || DOXYGEN -/** A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII. -*/ -class JUCE_API ScopedAutoReleasePool -{ -public: - ScopedAutoReleasePool(); - ~ScopedAutoReleasePool(); + /** A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII. */ + class JUCE_API ScopedAutoReleasePool + { + public: + ScopedAutoReleasePool(); + ~ScopedAutoReleasePool(); -private: - void* pool; + private: + void* pool; - JUCE_DECLARE_NON_COPYABLE (ScopedAutoReleasePool); -}; + JUCE_DECLARE_NON_COPYABLE (ScopedAutoReleasePool); + }; -#define JUCE_AUTORELEASEPOOL const JUCE_NAMESPACE::ScopedAutoReleasePool pool; + /** A macro that can be used to easily declare a local ScopedAutoReleasePool object for RAII-based obj-C autoreleasing. */ + #define JUCE_AUTORELEASEPOOL const JUCE_NAMESPACE::ScopedAutoReleasePool JUCE_JOIN_MACRO (autoReleasePool_, __LINE__); #else - -#define JUCE_AUTORELEASEPOOL - + #define JUCE_AUTORELEASEPOOL #endif diff --git a/src/native/mac/juce_ios_MessageManager.mm b/src/native/mac/juce_ios_MessageManager.mm index 6b36186840..4de7a0a01c 100644 --- a/src/native/mac/juce_ios_MessageManager.mm +++ b/src/native/mac/juce_ios_MessageManager.mm @@ -86,7 +86,7 @@ void MessageManager::stopDispatchLoop() bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL jassert (isThisTheMessageThread()); // must only be called by the message thread uint32 endTime = Time::getMillisecondCounter() + millisecondsToRunFor; @@ -94,7 +94,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) while (! quitMessagePosted) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate: endDate]; @@ -165,7 +165,7 @@ void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* call // call your function.. jassert (! MessageManager::getInstance()->currentThreadHasLockedMessageManager()); - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL CallbackMessagePayload cmp; cmp.function = callback; diff --git a/src/native/mac/juce_ios_MiscUtilities.mm b/src/native/mac/juce_ios_MiscUtilities.mm index fe078336eb..74bf012930 100644 --- a/src/native/mac/juce_ios_MiscUtilities.mm +++ b/src/native/mac/juce_ios_MiscUtilities.mm @@ -138,7 +138,7 @@ public: int getResult() { jassert (callback == nullptr); - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL while (! alert.hidden && alert.superview != nil) [[NSRunLoop mainRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.01]]; @@ -186,7 +186,7 @@ void JUCE_CALLTYPE NativeMessageBox::showMessageBox (AlertWindow::AlertIconType const String& title, const String& message, Component* associatedComponent) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL iOSMessageBox mb (title, message, @"OK", nil, nil, 0, false); (void) mb.getResult(); } @@ -195,7 +195,7 @@ void JUCE_CALLTYPE NativeMessageBox::showMessageBoxAsync (AlertWindow::AlertIcon const String& title, const String& message, Component* associatedComponent) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL new iOSMessageBox (title, message, @"OK", nil, nil, 0, true); } diff --git a/src/native/mac/juce_ios_UIViewComponentPeer.mm b/src/native/mac/juce_ios_UIViewComponentPeer.mm index e97552b520..66a4e3a503 100644 --- a/src/native/mac/juce_ios_UIViewComponentPeer.mm +++ b/src/native/mac/juce_ios_UIViewComponentPeer.mm @@ -996,7 +996,7 @@ Desktop::DisplayOrientation Desktop::getCurrentOrientation() const void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL monitorCoords.clear(); CGRect r = clipToWorkArea ? [[UIScreen mainScreen] applicationFrame] diff --git a/src/native/mac/juce_mac_AudioCDBurner.mm b/src/native/mac/juce_mac_AudioCDBurner.mm index d8b39dea78..5550aabc58 100644 --- a/src/native/mac/juce_mac_AudioCDBurner.mm +++ b/src/native/mac/juce_mac_AudioCDBurner.mm @@ -571,7 +571,7 @@ const String AudioCDBurner::burn (JUCE_NAMESPACE::AudioCDBurner::BurnProgressLis void AudioCDReader::ejectDisk() { - const ScopedAutoReleasePool p; + JUCE_AUTORELEASEPOOL [[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath: juceStringToNS (volumeDir.getFullPathName())]; } diff --git a/src/native/mac/juce_mac_CameraDevice.mm b/src/native/mac/juce_mac_CameraDevice.mm index e53e63aac5..3ee25ea1c0 100644 --- a/src/native/mac/juce_mac_CameraDevice.mm +++ b/src/native/mac/juce_mac_CameraDevice.mm @@ -68,7 +68,7 @@ class QTCameraDeviceInteral public: QTCameraDeviceInteral (CameraDevice* owner, int index) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL session = [[QTCaptureSession alloc] init]; @@ -239,7 +239,7 @@ END_JUCE_NAMESPACE { if (internal->listeners.size() > 0) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL internal->callListeners ([CIImage imageWithCVImageBuffer: videoFrame], CVPixelBufferGetWidth (videoFrame), @@ -253,11 +253,11 @@ END_JUCE_NAMESPACE { const Time now (Time::getCurrentTime()); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 NSNumber* hosttime = (NSNumber*) [sampleBuffer attributeForKey: QTSampleBufferHostTimeAttribute]; -#else + #else NSNumber* hosttime = (NSNumber*) [sampleBuffer attributeForKey: @"hostTime"]; -#endif + #endif int64 presentationTime = (hosttime != nil) ? ((int64) AudioConvertHostTimeToNanos ([hosttime unsignedLongLongValue]) / 1000000 + 40) @@ -285,7 +285,7 @@ class QTCaptureViewerComp : public NSViewComponent public: QTCaptureViewerComp (CameraDevice* const cameraDevice, QTCameraDeviceInteral* const internal) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL captureView = [[QTCaptureView alloc] init]; [captureView setCaptureSession: internal->session]; @@ -400,7 +400,7 @@ void CameraDevice::removeListener (Listener* listenerToRemove) //============================================================================== const StringArray CameraDevice::getAvailableDevices() { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL StringArray results; NSArray* devs = [QTCaptureDevice inputDevicesWithMediaType: QTMediaTypeVideo]; diff --git a/src/native/mac/juce_mac_CoreGraphicsContext.mm b/src/native/mac/juce_mac_CoreGraphicsContext.mm index ab45b97198..e1e7923e8e 100644 --- a/src/native/mac/juce_mac_CoreGraphicsContext.mm +++ b/src/native/mac/juce_mac_CoreGraphicsContext.mm @@ -111,7 +111,7 @@ public: #if JUCE_MAC static NSImage* createNSImage (const Image& image) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL NSImage* im = [[NSImage alloc] init]; [im setSize: NSMakeSize (image.getWidth(), image.getHeight())]; diff --git a/src/native/mac/juce_mac_FileChooser.mm b/src/native/mac/juce_mac_FileChooser.mm index a75ac532e0..7cb8db8e25 100644 --- a/src/native/mac/juce_mac_FileChooser.mm +++ b/src/native/mac/juce_mac_FileChooser.mm @@ -91,7 +91,7 @@ void FileChooser::showPlatformDialog (Array& results, bool selectMultipleFiles, FilePreviewComponent* /*extraInfoComponent*/) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL StringArray* filters = new StringArray(); filters->addTokens (filter.replaceCharacters (",:", ";;"), ";", String::empty); @@ -168,7 +168,7 @@ void FileChooser::showPlatformDialog (Array& results, bool selectMultipleFiles, FilePreviewComponent* extraInfoComponent) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL jassertfalse; //xxx to do } diff --git a/src/native/mac/juce_mac_Files.mm b/src/native/mac/juce_mac_Files.mm index d3a1fef06d..bc4c6fe98e 100644 --- a/src/native/mac/juce_mac_Files.mm +++ b/src/native/mac/juce_mac_Files.mm @@ -35,7 +35,7 @@ //============================================================================== bool File::copyInternal (const File& dest) const { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL NSFileManager* fm = [NSFileManager defaultManager]; return [fm fileExistsAtPath: juceStringToNS (fullPath)] @@ -78,7 +78,7 @@ namespace FileHelpers bool isHiddenFile (const String& path) { #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL NSNumber* hidden = nil; NSError* err = nil; @@ -143,10 +143,10 @@ bool File::isOnHardDisk() const bool File::isOnRemovableDrive() const { - #if JUCE_IOS + #if JUCE_IOS return false; // xxx is this possible? - #else - const ScopedAutoReleasePool pool; + #else + JUCE_AUTORELEASEPOOL BOOL removable = false; [[NSWorkspace sharedWorkspace] @@ -158,7 +158,7 @@ bool File::isOnRemovableDrive() const type: nil]; return removable; - #endif + #endif } bool File::isHidden() const @@ -171,8 +171,7 @@ const char* juce_Argv0 = nullptr; // referenced from juce_Application.cpp const File File::getSpecialLocation (const SpecialLocationType type) { - const ScopedAutoReleasePool pool; - + JUCE_AUTORELEASEPOOL String resultPath; switch (type) @@ -254,7 +253,7 @@ const File File::getSpecialLocation (const SpecialLocationType type) //============================================================================== const String File::getVersion() const { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL String result; NSBundle* bundle = [NSBundle bundleWithPath: juceStringToNS (getFullPathName())]; @@ -301,7 +300,7 @@ bool File::moveToTrash() const #if JUCE_IOS return deleteFile(); //xxx is there a trashcan on the iPhone? #else - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL NSString* p = juceStringToNS (getFullPathName()); @@ -323,7 +322,7 @@ public: wildCard (wildCard_), enumerator (nil) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL enumerator = [[[NSFileManager defaultManager] enumeratorAtPath: juceStringToNS (directory.getFullPathName())] retain]; } @@ -337,7 +336,7 @@ public: bool* const isDir, bool* const isHidden, int64* const fileSize, Time* const modTime, Time* const creationTime, bool* const isReadOnly) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL const char* wildcardUTF8 = nullptr; for (;;) @@ -395,7 +394,7 @@ bool PlatformUtilities::openDocument (const String& fileName, const String& para #if JUCE_IOS return [[UIApplication sharedApplication] openURL: [NSURL fileURLWithPath: juceStringToNS (fileName)]]; #else - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL if (parameters.isEmpty()) { @@ -460,26 +459,26 @@ const String PlatformUtilities::makePathFromFSRef (FSRef* file) //============================================================================== OSType PlatformUtilities::getTypeOfFile (const String& filename) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL - #if JUCE_IOS || (defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_ALLOWED >= MAC_OS_X_VERSION_10_5) + #if JUCE_IOS || (defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_ALLOWED >= MAC_OS_X_VERSION_10_5) NSDictionary* fileDict = [[NSFileManager defaultManager] attributesOfItemAtPath: juceStringToNS (filename) error: nil]; - #else + #else // (the cast here avoids a deprecation warning) NSDictionary* fileDict = [((id) [NSFileManager defaultManager]) fileAttributesAtPath: juceStringToNS (filename) traverseLink: NO]; - #endif + #endif return [fileDict fileHFSTypeCode]; } bool PlatformUtilities::isBundle (const String& filename) { - #if JUCE_IOS + #if JUCE_IOS return false; // xxx can't find a sensible way to do this without trying to open the bundle.. - #else - const ScopedAutoReleasePool pool; + #else + JUCE_AUTORELEASEPOOL return [[NSWorkspace sharedWorkspace] isFilePackageAtPath: juceStringToNS (filename)]; - #endif + #endif } #endif diff --git a/src/native/mac/juce_mac_Fonts.mm b/src/native/mac/juce_mac_Fonts.mm index e0dda0d573..e3089fd762 100644 --- a/src/native/mac/juce_mac_Fonts.mm +++ b/src/native/mac/juce_mac_Fonts.mm @@ -50,7 +50,7 @@ public: MacTypeface (const Font& font) : Typeface (font.getTypefaceName()) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL renderingTransform = CGAffineTransformIdentity; bool needsItalicTransform = false; @@ -129,7 +129,7 @@ public: renderingTransform.c = 0.15f; } -#if SUPPORT_ONLY_10_4_FONTS + #if SUPPORT_ONLY_10_4_FONTS ATSFontRef atsFont = ATSFontFindFromName ((CFStringRef) [nsFont fontName], kATSOptionFlagsDefault); if (atsFont == 0) @@ -140,7 +140,7 @@ public: const float totalHeight = std::abs ([nsFont ascender]) + std::abs ([nsFont descender]); unitsToHeightScaleFactor = 1.0f / totalHeight; fontHeightToCGSizeFactor = 1024.0f / totalHeight; -#else + #else #if SUPPORT_10_4_FONTS if (NEW_CGFONT_FUNCTIONS_UNAVAILABLE) { @@ -164,7 +164,7 @@ public: unitsToHeightScaleFactor = 1.0f / totalHeight; fontHeightToCGSizeFactor = CGFontGetUnitsPerEm (fontRef) / (float) totalHeight; } -#endif + #endif #endif } @@ -310,7 +310,7 @@ public: // we might need to apply a transform to the path, so it mustn't have anything else in it jassert (path.isEmpty()); - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL NSBezierPath* bez = [NSBezierPath bezierPath]; [bez moveToPoint: NSMakePoint (0, 0)]; @@ -492,7 +492,7 @@ const StringArray Font::findAllTypefaceNames() { StringArray names; - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL #if JUCE_IOS NSArray* fonts = [UIFont familyNames]; diff --git a/src/native/mac/juce_mac_MainMenu.mm b/src/native/mac/juce_mac_MainMenu.mm index f5d5d412d3..cc314a6464 100644 --- a/src/native/mac/juce_mac_MainMenu.mm +++ b/src/native/mac/juce_mac_MainMenu.mm @@ -498,7 +498,7 @@ namespace MainMenuHelpers if (JUCEApplication::getInstance() != nullptr) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL NSMenu* mainMenu = [[NSMenu alloc] initWithTitle: @"MainMenu"]; NSMenuItem* item = [mainMenu addItemWithTitle: @"Apple" action: nil keyEquivalent: @""]; @@ -522,7 +522,7 @@ void MenuBarModel::setMacMainMenu (MenuBarModel* newMenuBarModel, { if (getMacMainMenu() != newMenuBarModel) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL if (newMenuBarModel == nullptr) { diff --git a/src/native/mac/juce_mac_MessageManager.mm b/src/native/mac/juce_mac_MessageManager.mm index 6680bd9eea..7757ac17cf 100644 --- a/src/native/mac/juce_mac_MessageManager.mm +++ b/src/native/mac/juce_mac_MessageManager.mm @@ -295,7 +295,7 @@ void MessageManager::runDispatchLoop() { if (! quitMessagePosted) // check that the quit message wasn't already posted.. { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL // must only be called by the message thread! jassert (isThisTheMessageThread()); @@ -424,7 +424,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) while (! quitMessagePosted) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL CFRunLoopRunInMode (kCFRunLoopDefaultMode, 0.001, true); @@ -498,7 +498,7 @@ void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* call // call your function.. jassert (! MessageManager::getInstance()->currentThreadHasLockedMessageManager()); - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL AppDelegateRedirector::CallbackMessagePayload cmp; cmp.function = callback; diff --git a/src/native/mac/juce_mac_MiscUtilities.mm b/src/native/mac/juce_mac_MiscUtilities.mm index c321277f80..ab6986810e 100644 --- a/src/native/mac/juce_mac_MiscUtilities.mm +++ b/src/native/mac/juce_mac_MiscUtilities.mm @@ -91,7 +91,7 @@ public: int getResult() const { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL NSInteger r = getRawResult(); return r == NSAlertDefaultReturn ? 1 : (r == NSAlertOtherReturn ? 2 : 0); } @@ -195,7 +195,7 @@ bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& fi return false; } - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL NSView* view = (NSView*) sourceComp->getWindowHandle(); @@ -243,7 +243,7 @@ bool Desktop::canUseSemiTransparentWindows() noexcept const Point MouseInputSource::getCurrentMousePosition() { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL const NSPoint p ([NSEvent mouseLocation]); return Point (roundToInt (p.x), roundToInt ([[[NSScreen screens] objectAtIndex: 0] frame].size.height - p.y)); } @@ -364,7 +364,7 @@ juce_ImplementSingleton_SingleThreaded (DisplaySettingsChangeCallback); void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL DisplaySettingsChangeCallback::getInstance(); diff --git a/src/native/mac/juce_mac_MouseCursor.mm b/src/native/mac/juce_mac_MouseCursor.mm index 3264297725..370583590c 100644 --- a/src/native/mac/juce_mac_MouseCursor.mm +++ b/src/native/mac/juce_mac_MouseCursor.mm @@ -64,7 +64,7 @@ void* MouseCursor::createMouseCursorFromImage (const Image& image, int hotspotX, void* MouseCursor::createStandardMouseCursor (MouseCursor::StandardCursorType type) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL NSCursor* c = nil; switch (type) diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 50897a7574..5e4e849a8e 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -980,7 +980,7 @@ void NSViewComponentPeer::setVisible (bool shouldBeVisible) void NSViewComponentPeer::setTitle (const String& title) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL if (! isSharedWindow) [window setTitle: juceStringToNS (title)]; @@ -1774,7 +1774,7 @@ ComponentPeer* Component::createNewPeer (int styleFlags, void* windowToAttachTo) //============================================================================== const Image juce_createIconForFile (const File& file) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL NSImage* image = [[NSWorkspace sharedWorkspace] iconForFile: juceStringToNS (file.getFullPathName())]; diff --git a/src/native/mac/juce_mac_NativeCode.mm b/src/native/mac/juce_mac_NativeCode.mm index af7757b260..442c501273 100644 --- a/src/native/mac/juce_mac_NativeCode.mm +++ b/src/native/mac/juce_mac_NativeCode.mm @@ -165,7 +165,7 @@ private: if (nextMessage == nullptr) return false; - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL MessageManager::getInstance()->deliverMessage (nextMessage); return true; } diff --git a/src/native/mac/juce_mac_Network.mm b/src/native/mac/juce_mac_Network.mm index d421cfcdda..7667d4591e 100644 --- a/src/native/mac/juce_mac_Network.mm +++ b/src/native/mac/juce_mac_Network.mm @@ -60,12 +60,12 @@ bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAdd const String& bodyText, const StringArray& filesToAttach) { -#if JUCE_IOS + #if JUCE_IOS //xxx probably need to use MFMailComposeViewController jassertfalse; return false; -#else - const ScopedAutoReleasePool pool; + #else + JUCE_AUTORELEASEPOOL String script; script << "tell application \"Mail\"\r\n" @@ -93,14 +93,13 @@ bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAdd script << "end tell\r\n" "end tell\r\n"; - NSAppleScript* s = [[NSAppleScript alloc] - initWithSource: juceStringToNS (script)]; + NSAppleScript* s = [[NSAppleScript alloc] initWithSource: juceStringToNS (script)]; NSDictionary* error = nil; const bool ok = [s executeAndReturnError: &error] != nil; [s release]; return ok; -#endif + #endif } //============================================================================== @@ -160,7 +159,7 @@ public: while (! threadShouldExit()) { - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL [[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.01]]; } } diff --git a/src/native/mac/juce_mac_OpenGLComponent.mm b/src/native/mac/juce_mac_OpenGLComponent.mm index a717f3fd53..e0e8ec8879 100644 --- a/src/native/mac/juce_mac_OpenGLComponent.mm +++ b/src/native/mac/juce_mac_OpenGLComponent.mm @@ -525,7 +525,7 @@ private: OpenGLContext* OpenGLComponent::createContext() { - ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL UIViewComponentPeer* peer = dynamic_cast (getPeer()); if (peer != nullptr) diff --git a/src/native/mac/juce_mac_Strings.mm b/src/native/mac/juce_mac_Strings.mm index 71f5499963..1e5368707d 100644 --- a/src/native/mac/juce_mac_Strings.mm +++ b/src/native/mac/juce_mac_Strings.mm @@ -64,7 +64,7 @@ CFStringRef PlatformUtilities::juceStringToCFString (const String& s) const String PlatformUtilities::convertToPrecomposedUnicode (const String& s) { #if JUCE_IOS - const ScopedAutoReleasePool pool; + JUCE_AUTORELEASEPOOL return nsStringToJuce ([juceStringToNS (s) precomposedStringWithCanonicalMapping]); #else UnicodeMapping map; diff --git a/src/native/mac/juce_mac_Threads.mm b/src/native/mac/juce_mac_Threads.mm index bc3fc73d3b..5c27c266c5 100644 --- a/src/native/mac/juce_mac_Threads.mm +++ b/src/native/mac/juce_mac_Threads.mm @@ -36,11 +36,11 @@ //============================================================================== bool Process::isForegroundProcess() { -#if JUCE_MAC + #if JUCE_MAC return [NSApp isActive]; -#else + #else return true; // xxx change this if more than one app is ever possible on the iPhone! -#endif + #endif } void Process::raisePrivilege() diff --git a/src/native/windows/juce_win32_SystemStats.cpp b/src/native/windows/juce_win32_SystemStats.cpp index ffa29b6036..6a1eee5819 100644 --- a/src/native/windows/juce_win32_SystemStats.cpp +++ b/src/native/windows/juce_win32_SystemStats.cpp @@ -40,7 +40,7 @@ static double hiResTicksScaleFactor; //============================================================================== -#if JUCE_USE_INTRINSICS +#if JUCE_USE_INTRINSICS || JUCE_64BIT // CPU info functions using intrinsics... @@ -69,9 +69,6 @@ static void juce_getCpuVendor (char* const v) { int vendor[4] = { 0 }; - #if JUCE_64BIT - /// xxx todo - #else #ifndef __MINGW32__ __try #endif @@ -96,7 +93,6 @@ static void juce_getCpuVendor (char* const v) *v = 0; } #endif - #endif memcpy (v, vendor, 16); }