diff --git a/extras/juce demo/src/binarydata/ThreadingDemo.cpp b/extras/juce demo/src/binarydata/ThreadingDemo.cpp index 232c317dbd..9135c67e60 100644 --- a/extras/juce demo/src/binarydata/ThreadingDemo.cpp +++ b/extras/juce demo/src/binarydata/ThreadingDemo.cpp @@ -33,13 +33,11 @@ //============================================================================== -class BouncingBallComp : public Component, - public AsyncUpdater +class BouncingBallComp : public Component { float x, y, size, dx, dy, w, h, parentWidth, parentHeight; float innerX, innerY; Colour colour; - CriticalSection lock; Thread::ThreadID threadId; public: @@ -88,25 +86,8 @@ public: parentHeight = getParentHeight() - size; } - void handleAsyncUpdate() - { - const ScopedLock sl (lock); - - setBounds (((int) x) - 2, - ((int) y) - 2, - ((int) size) + 4, - ((int) size) + 4); - - innerX = x - getX(); - innerY = y - getY(); - - repaint(); - } - void moveBall() { - const ScopedLock sl (lock); - threadId = Thread::getCurrentThreadId(); // this is so the component can print the thread ID inside the ball x += dx; @@ -124,10 +105,15 @@ public: if (y > parentHeight) dy = -fabsf (dy); - // this is called on a background thread, so we don't want to call - // any UI code from here - instead we'll trigger an event that will update - // the component's position later. This is a safe way to avoid deadlocks - triggerAsyncUpdate(); + setBounds (((int) x) - 2, + ((int) y) - 2, + ((int) size) + 4, + ((int) size) + 4); + + innerX = x - getX(); + innerY = y - getY(); + + repaint(); } juce_UseDebuggingNewOperator @@ -166,10 +152,18 @@ public: // called, so we should check it often, and exit as soon as it gets flagged. while (! threadShouldExit()) { - moveBall(); - // sleep a bit so the threads don't all grind the CPU to a halt.. wait (interval); + + // because this is a background thread, we mustn't do any UI work without + // first grabbing a MessageManagerLock.. + const MessageManagerLock mml (Thread::getCurrentThread()); + + if (! mml.lockWasGained()) // if something is trying to kill this job, the lock + return; // will fail, in which case we'd better return.. + + // now we've got the UI thread locked, we can mess about with the components + moveBall(); } } @@ -196,9 +190,18 @@ public: // this is the code that runs this job. It'll be repeatedly called until we return // jobHasFinished instead of jobNeedsRunningAgain. - moveBall(); Thread::sleep (30); + + // because this is a background thread, we mustn't do any UI work without + // first grabbing a MessageManagerLock.. + const MessageManagerLock mml (this); + + // before moving the ball, we need to check whether the lock was actually gained, because + // if something is trying to stop this job, it will have failed.. + if (mml.lockWasGained()) + moveBall(); + return jobNeedsRunningAgain; } diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index bb1fba66c7..e509341c0c 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -37088,7 +37088,6 @@ MessageManagerLock::~MessageManagerLock() throw() } END_JUCE_NAMESPACE - /********* End of inlined file: juce_MessageManager.cpp *********/ /********* Start of inlined file: juce_MultiTimer.cpp *********/ @@ -45353,6 +45352,9 @@ void Slider::lookAndFeelChanged() decButton->setRepeatSpeed (300, 100, 20); decButton->addMouseListener (incButton, false); } + + incButton->setTooltip (getTooltip()); + decButton->setTooltip (getTooltip()); } setComponentEffect (lf.getSliderEffect()); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 165f2888cf..2ee1f4b116 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -36131,13 +36131,11 @@ private: /********* End of inlined file: juce_PluginListComponent.h *********/ #endif -#ifndef __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ - -/********* Start of inlined file: juce_FlacAudioFormat.h *********/ -#ifndef __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ -#define __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ +#ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ -#if JUCE_USE_FLAC || defined (DOXYGEN) +/********* Start of inlined file: juce_WavAudioFormat.h *********/ +#ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ +#define __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ /********* Start of inlined file: juce_AudioFormat.h *********/ #ifndef __JUCE_AUDIOFORMAT_JUCEHEADER__ @@ -36413,52 +36411,6 @@ private: #endif // __JUCE_AUDIOFORMAT_JUCEHEADER__ /********* End of inlined file: juce_AudioFormat.h *********/ -/** - Reads and writes the lossless-compression FLAC audio format. - - To compile this, you'll need to set the JUCE_USE_FLAC flag in juce_Config.h, - and make sure your include search path and library search path are set up to find - the FLAC header files and static libraries. - - @see AudioFormat -*/ -class JUCE_API FlacAudioFormat : public AudioFormat -{ -public: - - FlacAudioFormat(); - ~FlacAudioFormat(); - - const Array getPossibleSampleRates(); - const Array getPossibleBitDepths(); - bool canDoStereo(); - bool canDoMono(); - bool isCompressed(); - - AudioFormatReader* createReaderFor (InputStream* sourceStream, - const bool deleteStreamIfOpeningFails); - - AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo, - double sampleRateToUse, - unsigned int numberOfChannels, - int bitsPerSample, - const StringPairArray& metadataValues, - int qualityOptionIndex); - - juce_UseDebuggingNewOperator -}; - -#endif -#endif // __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ -/********* End of inlined file: juce_FlacAudioFormat.h *********/ - -#endif -#ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ - -/********* Start of inlined file: juce_WavAudioFormat.h *********/ -#ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ -#define __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ - /** Reads and Writes WAV format audio files. @@ -36574,6 +36526,52 @@ public: #endif // __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ /********* End of inlined file: juce_WavAudioFormat.h *********/ +#endif +#ifndef __JUCE_AIFFAUDIOFORMAT_JUCEHEADER__ + +/********* Start of inlined file: juce_AiffAudioFormat.h *********/ +#ifndef __JUCE_AIFFAUDIOFORMAT_JUCEHEADER__ +#define __JUCE_AIFFAUDIOFORMAT_JUCEHEADER__ + +/** + Reads and Writes AIFF format audio files. + + @see AudioFormat +*/ +class JUCE_API AiffAudioFormat : public AudioFormat +{ +public: + + /** Creates an format object. */ + AiffAudioFormat(); + + /** Destructor. */ + ~AiffAudioFormat(); + + const Array getPossibleSampleRates(); + const Array getPossibleBitDepths(); + bool canDoStereo(); + bool canDoMono(); +#if JUCE_MAC + bool canHandleFile (const File& fileToTest); +#endif + + AudioFormatReader* createReaderFor (InputStream* sourceStream, + const bool deleteStreamIfOpeningFails); + + AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo, + double sampleRateToUse, + unsigned int numberOfChannels, + int bitsPerSample, + const StringPairArray& metadataValues, + int qualityOptionIndex); + + juce_UseDebuggingNewOperator +}; + +#endif // __JUCE_AIFFAUDIOFORMAT_JUCEHEADER__ +/********* End of inlined file: juce_AiffAudioFormat.h *********/ + #endif #ifndef __JUCE_OGGVORBISAUDIOFORMAT_JUCEHEADER__ @@ -36682,52 +36680,6 @@ public: #endif // __JUCE_QUICKTIMEAUDIOFORMAT_JUCEHEADER__ /********* End of inlined file: juce_QuickTimeAudioFormat.h *********/ -#endif -#ifndef __JUCE_AIFFAUDIOFORMAT_JUCEHEADER__ - -/********* Start of inlined file: juce_AiffAudioFormat.h *********/ -#ifndef __JUCE_AIFFAUDIOFORMAT_JUCEHEADER__ -#define __JUCE_AIFFAUDIOFORMAT_JUCEHEADER__ - -/** - Reads and Writes AIFF format audio files. - - @see AudioFormat -*/ -class JUCE_API AiffAudioFormat : public AudioFormat -{ -public: - - /** Creates an format object. */ - AiffAudioFormat(); - - /** Destructor. */ - ~AiffAudioFormat(); - - const Array getPossibleSampleRates(); - const Array getPossibleBitDepths(); - bool canDoStereo(); - bool canDoMono(); -#if JUCE_MAC - bool canHandleFile (const File& fileToTest); -#endif - - AudioFormatReader* createReaderFor (InputStream* sourceStream, - const bool deleteStreamIfOpeningFails); - - AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo, - double sampleRateToUse, - unsigned int numberOfChannels, - int bitsPerSample, - const StringPairArray& metadataValues, - int qualityOptionIndex); - - juce_UseDebuggingNewOperator -}; - -#endif // __JUCE_AIFFAUDIOFORMAT_JUCEHEADER__ -/********* End of inlined file: juce_AiffAudioFormat.h *********/ - #endif #ifndef __JUCE_AUDIOCDBURNER_JUCEHEADER__ @@ -37377,6 +37329,54 @@ private: #endif // __JUCE_AUDIOTHUMBNAILCACHE_JUCEHEADER__ /********* End of inlined file: juce_AudioThumbnailCache.h *********/ +#endif +#ifndef __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ + +/********* Start of inlined file: juce_FlacAudioFormat.h *********/ +#ifndef __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ +#define __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ + +#if JUCE_USE_FLAC || defined (DOXYGEN) + +/** + Reads and writes the lossless-compression FLAC audio format. + + To compile this, you'll need to set the JUCE_USE_FLAC flag in juce_Config.h, + and make sure your include search path and library search path are set up to find + the FLAC header files and static libraries. + + @see AudioFormat +*/ +class JUCE_API FlacAudioFormat : public AudioFormat +{ +public: + + FlacAudioFormat(); + ~FlacAudioFormat(); + + const Array getPossibleSampleRates(); + const Array getPossibleBitDepths(); + bool canDoStereo(); + bool canDoMono(); + bool isCompressed(); + + AudioFormatReader* createReaderFor (InputStream* sourceStream, + const bool deleteStreamIfOpeningFails); + + AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo, + double sampleRateToUse, + unsigned int numberOfChannels, + int bitsPerSample, + const StringPairArray& metadataValues, + int qualityOptionIndex); + + juce_UseDebuggingNewOperator +}; + +#endif +#endif // __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ +/********* End of inlined file: juce_FlacAudioFormat.h *********/ + #endif #ifndef __JUCE_INTERPROCESSCONNECTIONSERVER_JUCEHEADER__ @@ -38212,9 +38212,6 @@ private: #endif #ifndef __JUCE_INTERPROCESSCONNECTION_JUCEHEADER__ -#endif -#ifndef __JUCE_SOLIDCOLOURBRUSH_JUCEHEADER__ - #endif #ifndef __JUCE_BRUSH_JUCEHEADER__ @@ -38740,6 +38737,9 @@ private: #endif // __JUCE_IMAGEBRUSH_JUCEHEADER__ /********* End of inlined file: juce_ImageBrush.h *********/ +#endif +#ifndef __JUCE_SOLIDCOLOURBRUSH_JUCEHEADER__ + #endif #ifndef __JUCE_COLOUR_JUCEHEADER__ diff --git a/src/juce_app_includes.h b/src/juce_app_includes.h index d9d18f94f0..dcd56c6bb1 100644 --- a/src/juce_app_includes.h +++ b/src/juce_app_includes.h @@ -197,21 +197,18 @@ #ifndef __JUCE_PLUGINLISTCOMPONENT_JUCEHEADER__ #include "juce_appframework/audio/plugins/juce_PluginListComponent.h" #endif -#ifndef __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ - #include "juce_appframework/audio/audio_file_formats/juce_FlacAudioFormat.h" -#endif #ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_WavAudioFormat.h" #endif +#ifndef __JUCE_AIFFAUDIOFORMAT_JUCEHEADER__ + #include "juce_appframework/audio/audio_file_formats/juce_AiffAudioFormat.h" +#endif #ifndef __JUCE_OGGVORBISAUDIOFORMAT_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_OggVorbisAudioFormat.h" #endif #ifndef __JUCE_QUICKTIMEAUDIOFORMAT_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_QuickTimeAudioFormat.h" #endif -#ifndef __JUCE_AIFFAUDIOFORMAT_JUCEHEADER__ - #include "juce_appframework/audio/audio_file_formats/juce_AiffAudioFormat.h" -#endif #ifndef __JUCE_AUDIOCDBURNER_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_AudioCDBurner.h" #endif @@ -239,6 +236,9 @@ #ifndef __JUCE_AUDIOTHUMBNAILCACHE_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_AudioThumbnailCache.h" #endif +#ifndef __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ + #include "juce_appframework/audio/audio_file_formats/juce_FlacAudioFormat.h" +#endif #ifndef __JUCE_INTERPROCESSCONNECTIONSERVER_JUCEHEADER__ #include "juce_appframework/events/juce_InterprocessConnectionServer.h" #endif @@ -284,9 +284,6 @@ #ifndef __JUCE_INTERPROCESSCONNECTION_JUCEHEADER__ #include "juce_appframework/events/juce_InterprocessConnection.h" #endif -#ifndef __JUCE_SOLIDCOLOURBRUSH_JUCEHEADER__ - #include "juce_appframework/gui/graphics/brushes/juce_SolidColourBrush.h" -#endif #ifndef __JUCE_BRUSH_JUCEHEADER__ #include "juce_appframework/gui/graphics/brushes/juce_Brush.h" #endif @@ -296,6 +293,9 @@ #ifndef __JUCE_IMAGEBRUSH_JUCEHEADER__ #include "juce_appframework/gui/graphics/brushes/juce_ImageBrush.h" #endif +#ifndef __JUCE_SOLIDCOLOURBRUSH_JUCEHEADER__ + #include "juce_appframework/gui/graphics/brushes/juce_SolidColourBrush.h" +#endif #ifndef __JUCE_COLOUR_JUCEHEADER__ #include "juce_appframework/gui/graphics/colour/juce_Colour.h" #endif diff --git a/src/juce_appframework/audio/audio_file_formats/juce_FlacAudioFormat.h b/src/juce_appframework/audio/audio_file_formats/juce_FlacAudioFormat.h index 31a1745419..a379d999d5 100644 --- a/src/juce_appframework/audio/audio_file_formats/juce_FlacAudioFormat.h +++ b/src/juce_appframework/audio/audio_file_formats/juce_FlacAudioFormat.h @@ -32,9 +32,9 @@ #ifndef __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ #define __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ -#if JUCE_USE_FLAC || defined (DOXYGEN) +#include "juce_AudioFormat.h" // (must keep this outside the conditional define) -#include "juce_AudioFormat.h" +#if JUCE_USE_FLAC || defined (DOXYGEN) //============================================================================== diff --git a/src/juce_appframework/audio/audio_file_formats/juce_OggVorbisAudioFormat.h b/src/juce_appframework/audio/audio_file_formats/juce_OggVorbisAudioFormat.h index 42faf98d6f..c28c195187 100644 --- a/src/juce_appframework/audio/audio_file_formats/juce_OggVorbisAudioFormat.h +++ b/src/juce_appframework/audio/audio_file_formats/juce_OggVorbisAudioFormat.h @@ -32,9 +32,9 @@ #ifndef __JUCE_OGGVORBISAUDIOFORMAT_JUCEHEADER__ #define __JUCE_OGGVORBISAUDIOFORMAT_JUCEHEADER__ -#if JUCE_USE_OGGVORBIS || defined (DOXYGEN) +#include "juce_AudioFormat.h" // (must keep this outside the conditional define) -#include "juce_AudioFormat.h" +#if JUCE_USE_OGGVORBIS || defined (DOXYGEN) //============================================================================== diff --git a/src/juce_appframework/gui/components/controls/juce_Slider.cpp b/src/juce_appframework/gui/components/controls/juce_Slider.cpp index 19f0eabc16..e6dce1228b 100644 --- a/src/juce_appframework/gui/components/controls/juce_Slider.cpp +++ b/src/juce_appframework/gui/components/controls/juce_Slider.cpp @@ -384,6 +384,9 @@ void Slider::lookAndFeelChanged() decButton->setRepeatSpeed (300, 100, 20); decButton->addMouseListener (incButton, false); } + + incButton->setTooltip (getTooltip()); + decButton->setTooltip (getTooltip()); } setComponentEffect (lf.getSliderEffect());