From 3050cfd7f3de5486b9e1af3a32481d0b0d9d4ced Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 10 Dec 2008 11:51:16 +0000 Subject: [PATCH] minor fixes to callFunctionOnMessageThread, menu positioning on windows, and audio thumbnails --- juce_amalgamated.cpp | 29 ++++++++++++++----- .../juce_AudioThumbnail.cpp | 5 ++-- .../gui/components/menus/juce_PopupMenu.cpp | 4 +++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 95b2017942..0bb12db69c 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -18237,8 +18237,9 @@ void AudioThumbnail::setSource (InputSource* const newSource) clear(); - if (! (cache.loadThumb (*this, newSource->hashCode()) - && isFullyLoaded())) + if (newSource != 0 + && ! (cache.loadThumb (*this, newSource->hashCode()) + && isFullyLoaded())) { { const ScopedLock sl (readerLock); @@ -63966,7 +63967,11 @@ private: const Rectangle mon (Desktop::getInstance() .getMonitorAreaContaining ((minX + maxX) / 2, (minY + maxY) / 2, +#if JUCE_MAC true)); +#else + false)); // on windows, don't stop the menu overlapping the taskbar +#endif int x, y, widthToUse, heightToUse; layoutMenuItems (mon.getWidth() - 24, widthToUse, heightToUse); @@ -268621,12 +268626,19 @@ using namespace JUCE_NAMESPACE; - (void) performCallback: (id) info { - CallbackMessagePayload* pl = (CallbackMessagePayload*) info; + if ([info isKindOfClass: [NSData class]]) + { + CallbackMessagePayload* pl = (CallbackMessagePayload*) [((NSData*) info) bytes]; - if (pl != 0) + if (pl != 0) + { + pl->result = (*pl->function) (pl->parameter); + pl->hasBeenExecuted = true; + } + } + else { - pl->result = (*pl->function) (pl->parameter); - pl->hasBeenExecuted = true; + jassertfalse // should never get here! } } @@ -268725,6 +268737,8 @@ void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* call } else { + const ScopedAutoReleasePool pool; + CallbackMessagePayload cmp; cmp.function = callback; cmp.parameter = data; @@ -268732,7 +268746,8 @@ void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* call cmp.hasBeenExecuted = false; [juceAppDelegate performSelectorOnMainThread: @selector (performCallback:) - withObject: (id) &cmp + withObject: [NSData dataWithBytesNoCopy: &cmp + length: sizeof (cmp)] waitUntilDone: YES]; return cmp.result; diff --git a/src/juce_appframework/audio/audio_file_formats/juce_AudioThumbnail.cpp b/src/juce_appframework/audio/audio_file_formats/juce_AudioThumbnail.cpp index eb464f1ba8..28d9bf5137 100644 --- a/src/juce_appframework/audio/audio_file_formats/juce_AudioThumbnail.cpp +++ b/src/juce_appframework/audio/audio_file_formats/juce_AudioThumbnail.cpp @@ -105,8 +105,9 @@ void AudioThumbnail::setSource (InputSource* const newSource) clear(); - if (! (cache.loadThumb (*this, newSource->hashCode()) - && isFullyLoaded())) + if (newSource != 0 + && ! (cache.loadThumb (*this, newSource->hashCode()) + && isFullyLoaded())) { { const ScopedLock sl (readerLock); diff --git a/src/juce_appframework/gui/components/menus/juce_PopupMenu.cpp b/src/juce_appframework/gui/components/menus/juce_PopupMenu.cpp index f702a77701..8b66ae57b2 100644 --- a/src/juce_appframework/gui/components/menus/juce_PopupMenu.cpp +++ b/src/juce_appframework/gui/components/menus/juce_PopupMenu.cpp @@ -848,7 +848,11 @@ private: const Rectangle mon (Desktop::getInstance() .getMonitorAreaContaining ((minX + maxX) / 2, (minY + maxY) / 2, +#if JUCE_MAC true)); +#else + false)); // on windows, don't stop the menu overlapping the taskbar +#endif int x, y, widthToUse, heightToUse; layoutMenuItems (mon.getWidth() - 24, widthToUse, heightToUse);