From 59a2506864861396156b82d75e7e192ce84b9f89 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Sun, 3 Jan 2010 16:17:42 +0000 Subject: [PATCH] Minor code clean-ups --- .../wrapper/RTAS/juce_RTAS_MacUtilities.mm | 2 +- juce_amalgamated.cpp | 441 ++++++++---------- juce_amalgamated.h | 75 +-- .../juce_AudioFormatManager.cpp | 14 +- src/audio/devices/juce_AudioDeviceManager.cpp | 9 +- src/core/juce_PlatformUtilities.h | 12 +- .../components/controls/juce_TextEditor.cpp | 8 +- src/gui/components/controls/juce_TextEditor.h | 2 +- src/gui/components/controls/juce_TreeView.cpp | 3 +- src/gui/components/menus/juce_MenuBarModel.h | 4 +- src/gui/components/mouse/juce_MouseCursor.cpp | 78 +--- src/gui/components/mouse/juce_MouseCursor.h | 9 +- src/gui/graphics/imaging/juce_ImageCache.cpp | 40 +- src/gui/graphics/imaging/juce_ImageCache.h | 3 +- src/io/files/juce_ZipFile.cpp | 20 +- src/io/files/juce_ZipFile.h | 2 +- src/io/streams/juce_BufferedInputStream.cpp | 6 +- src/io/streams/juce_BufferedInputStream.h | 3 +- .../juce_GZIPCompressorOutputStream.cpp | 29 +- .../streams/juce_GZIPCompressorOutputStream.h | 6 +- .../juce_GZIPDecompressorInputStream.cpp | 30 +- .../juce_GZIPDecompressorInputStream.h | 7 +- src/io/streams/juce_MemoryOutputStream.cpp | 16 +- src/io/streams/juce_MemoryOutputStream.h | 3 +- src/io/streams/juce_SubregionStream.cpp | 8 +- src/io/streams/juce_SubregionStream.h | 3 +- src/native/mac/juce_iphone_Audio.cpp | 6 +- .../mac/juce_iphone_UIViewComponentPeer.mm | 4 +- src/native/mac/juce_mac_AppleRemote.mm | 12 +- .../mac/juce_mac_CarbonViewWrapperComponent.h | 2 +- .../mac/juce_mac_CoreGraphicsContext.mm | 28 +- src/native/mac/juce_mac_CoreMidi.cpp | 4 +- src/native/mac/juce_mac_Files.mm | 4 +- src/native/mac/juce_mac_Fonts.mm | 12 +- src/native/mac/juce_mac_MainMenu.mm | 10 +- src/native/mac/juce_mac_MessageManager.mm | 4 +- src/native/mac/juce_mac_MiscUtilities.mm | 2 +- .../mac/juce_mac_NSViewComponentPeer.mm | 4 +- src/native/mac/juce_mac_SystemStats.mm | 2 +- src/native/mac/juce_mac_Threads.mm | 2 +- .../windows/juce_win32_PlatformUtils.cpp | 4 +- src/text/juce_LocalisedStrings.cpp | 24 +- src/text/juce_LocalisedStrings.h | 24 +- src/utilities/juce_DeletedAtShutdown.cpp | 13 +- 44 files changed, 428 insertions(+), 566 deletions(-) diff --git a/extras/audio plugins/wrapper/RTAS/juce_RTAS_MacUtilities.mm b/extras/audio plugins/wrapper/RTAS/juce_RTAS_MacUtilities.mm index bce67cd120..fb5b4d9c73 100644 --- a/extras/audio plugins/wrapper/RTAS/juce_RTAS_MacUtilities.mm +++ b/extras/audio plugins/wrapper/RTAS/juce_RTAS_MacUtilities.mm @@ -115,7 +115,7 @@ void removeSubWindow (void* nsWindow, Component* comp) MessageManager::getInstance()->runDispatchLoopUntil (1); } -static bool isJuceWindow (WindowRef w) throw() +static bool isJuceWindow (WindowRef w) { for (int i = ComponentPeer::getNumPeers(); --i >= 0;) { diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 0d0cb81044..888d40b173 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -982,7 +982,7 @@ public: setEmbeddedWindowToOurSize(); } - static void recursiveHIViewRepaint (HIViewRef view) throw() + static void recursiveHIViewRepaint (HIViewRef view) { HIViewSetNeedsDisplay (view, true); HIViewRef child = HIViewGetFirstSubview (view); @@ -8606,9 +8606,9 @@ BEGIN_JUCE_NAMESPACE BufferedInputStream::BufferedInputStream (InputStream* const source_, const int bufferSize_, - const bool deleteSourceWhenDestroyed_) throw() + const bool deleteSourceWhenDestroyed) throw() : source (source_), - deleteSourceWhenDestroyed (deleteSourceWhenDestroyed_), + sourceToDelete (deleteSourceWhenDestroyed ? source_ : 0), bufferSize (jmax (256, bufferSize_)), position (source_->getPosition()), lastReadPos (0), @@ -8624,8 +8624,6 @@ BufferedInputStream::BufferedInputStream (InputStream* const source_, BufferedInputStream::~BufferedInputStream() throw() { - if (deleteSourceWhenDestroyed) - delete source; } int64 BufferedInputStream::getTotalLength() @@ -8852,26 +8850,22 @@ MemoryOutputStream::MemoryOutputStream (const int initialSize, : data (memoryBlockToWriteTo), position (0), size (0), - blockSize (jmax (16, blockSizeToIncreaseBy)), - ownsMemoryBlock (memoryBlockToWriteTo == 0) + blockSize (jmax (16, blockSizeToIncreaseBy)) { - if (memoryBlockToWriteTo == 0) - data = new MemoryBlock (initialSize); + if (data == 0) + dataToDelete = data = new MemoryBlock (initialSize); else - memoryBlockToWriteTo->setSize (initialSize, false); + data->setSize (initialSize, false); } MemoryOutputStream::~MemoryOutputStream() throw() { - if (ownsMemoryBlock) - delete data; - else - flush(); + flush(); } void MemoryOutputStream::flush() { - if (! ownsMemoryBlock) + if (dataToDelete == 0) data->setSize (size, false); } @@ -8947,19 +8941,19 @@ BEGIN_JUCE_NAMESPACE SubregionStream::SubregionStream (InputStream* const sourceStream, const int64 startPositionInSourceStream_, const int64 lengthOfSourceStream_, - const bool deleteSourceWhenDestroyed_) throw() + const bool deleteSourceWhenDestroyed) throw() : source (sourceStream), - deleteSourceWhenDestroyed (deleteSourceWhenDestroyed_), startPositionInSourceStream (startPositionInSourceStream_), lengthOfSourceStream (lengthOfSourceStream_) { + if (deleteSourceWhenDestroyed) + sourceToDelete = source; + setPosition (0); } SubregionStream::~SubregionStream() throw() { - if (deleteSourceWhenDestroyed) - delete source; } int64 SubregionStream::getTotalLength() @@ -9240,8 +9234,7 @@ class ZipInputStream : public InputStream { public: - ZipInputStream (ZipFile& file_, - ZipEntryInfo& zei) throw() + ZipInputStream (ZipFile& file_, ZipEntryInfo& zei) : file (file_), zipEntryInfo (zei), pos (0), @@ -9346,19 +9339,20 @@ private: }; ZipFile::ZipFile (InputStream* const source_, - const bool deleteStreamWhenDestroyed_) throw() - : inputStream (source_), - deleteStreamWhenDestroyed (deleteStreamWhenDestroyed_) + const bool deleteStreamWhenDestroyed) throw() + : inputStream (source_) #ifdef JUCE_DEBUG , numOpenStreams (0) #endif { + if (deleteStreamWhenDestroyed) + streamToDelete = inputStream; + init(); } ZipFile::ZipFile (const File& file) - : inputStream (0), - deleteStreamWhenDestroyed (false) + : inputStream (0) #ifdef JUCE_DEBUG , numOpenStreams (0) #endif @@ -9369,8 +9363,7 @@ ZipFile::ZipFile (const File& file) ZipFile::ZipFile (InputSource* const inputSource_) : inputStream (0), - inputSource (inputSource_), - deleteStreamWhenDestroyed (false) + inputSource (inputSource_) #ifdef JUCE_DEBUG , numOpenStreams (0) #endif @@ -9383,9 +9376,6 @@ ZipFile::~ZipFile() throw() for (int i = entries.size(); --i >= 0;) delete (ZipEntryInfo*) entries.getUnchecked(i); - if (deleteStreamWhenDestroyed) - delete inputStream; - #ifdef JUCE_DEBUG // If you hit this assertion, it means you've created a stream to read // one of the items in the zipfile, but you've forgotten to delete that @@ -10367,26 +10357,26 @@ END_JUCE_NAMESPACE BEGIN_JUCE_NAMESPACE -LocalisedStrings::LocalisedStrings (const String& fileContents) throw() +LocalisedStrings::LocalisedStrings (const String& fileContents) { loadFromText (fileContents); } -LocalisedStrings::LocalisedStrings (const File& fileToLoad) throw() +LocalisedStrings::LocalisedStrings (const File& fileToLoad) { loadFromText (fileToLoad.loadFileAsString()); } -LocalisedStrings::~LocalisedStrings() throw() +LocalisedStrings::~LocalisedStrings() { } -const String LocalisedStrings::translate (const String& text) const throw() +const String LocalisedStrings::translate (const String& text) const { return translations.getValue (text, text); } -static int findCloseQuote (const String& text, int startPos) throw() +static int findCloseQuote (const String& text, int startPos) { tchar lastChar = 0; @@ -10404,7 +10394,7 @@ static int findCloseQuote (const String& text, int startPos) throw() return startPos; } -static const String unescapeString (const String& s) throw() +static const String unescapeString (const String& s) { return s.replace (T("\\\""), T("\"")) .replace (T("\\\'"), T("\'")) @@ -10413,7 +10403,7 @@ static const String unescapeString (const String& s) throw() .replace (T("\\n"), T("\n")); } -void LocalisedStrings::loadFromText (const String& fileContents) throw() +void LocalisedStrings::loadFromText (const String& fileContents) { StringArray lines; lines.addLines (fileContents); @@ -10452,7 +10442,7 @@ void LocalisedStrings::loadFromText (const String& fileContents) throw() } } -void LocalisedStrings::setIgnoresCase (const bool shouldIgnoreCase) throw() +void LocalisedStrings::setIgnoresCase (const bool shouldIgnoreCase) { translations.setIgnoresCase (shouldIgnoreCase); } @@ -10460,7 +10450,7 @@ void LocalisedStrings::setIgnoresCase (const bool shouldIgnoreCase) throw() static CriticalSection currentMappingsLock; static LocalisedStrings* currentMappings = 0; -void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations) throw() +void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations) { const ScopedLock sl (currentMappingsLock); @@ -10468,12 +10458,12 @@ void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations) th currentMappings = newTranslations; } -LocalisedStrings* LocalisedStrings::getCurrentMappings() throw() +LocalisedStrings* LocalisedStrings::getCurrentMappings() { return currentMappings; } -const String LocalisedStrings::translateWithCurrentMappings (const String& text) throw() +const String LocalisedStrings::translateWithCurrentMappings (const String& text) { const ScopedLock sl (currentMappingsLock); @@ -10483,7 +10473,7 @@ const String LocalisedStrings::translateWithCurrentMappings (const String& text) return text; } -const String LocalisedStrings::translateWithCurrentMappings (const char* text) throw() +const String LocalisedStrings::translateWithCurrentMappings (const char* text) { return translateWithCurrentMappings (String (text)); } @@ -17923,15 +17913,16 @@ void DeletedAtShutdown::deleteAll() { JUCE_TRY { - DeletedAtShutdown* const deletee = (DeletedAtShutdown*) localCopy.getUnchecked(i); + DeletedAtShutdown* deletee = (DeletedAtShutdown*) localCopy.getUnchecked(i); // double-check that it's not already been deleted during another object's destructor. - lock.enter(); - const bool okToDelete = objectsToDelete.contains (deletee); - lock.exit(); + { + const ScopedLock sl (lock); + if (! objectsToDelete.contains (deletee)) + deletee = 0; + } - if (okToDelete) - delete deletee; + delete deletee; } JUCE_CATCH_EXCEPTION } @@ -20428,10 +20419,7 @@ void AudioFormatManager::registerBasicFormats() void AudioFormatManager::clearFormats() { for (int i = getNumKnownFormats(); --i >= 0;) - { - AudioFormat* const af = getKnownFormat(i); - delete af; - } + delete getKnownFormat(i); knownFormats.clear(); defaultFormatIndex = 0; @@ -20520,12 +20508,14 @@ AudioFormatReader* AudioFormatManager::createReaderFor (const File& file) return 0; } -AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* in) +AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* audioFileStream) { // you need to actually register some formats before the manager can // use them to open a file! jassert (knownFormats.size() > 0); + ScopedPointer in (audioFileStream); + if (in != 0) { const int64 originalStreamPos = in->getPosition(); @@ -20535,7 +20525,10 @@ AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* in) AudioFormatReader* const r = getKnownFormat(i)->createReaderFor (in, false); if (r != 0) + { + in.release(); return r; + } in->setPosition (originalStreamPos); @@ -20543,8 +20536,6 @@ AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* in) // that all the formats can have a go at opening it. jassert (in->getPosition() == originalStreamPos); } - - delete in; } return 0; @@ -24835,10 +24826,11 @@ void AudioDeviceManager::CallbackHandler::handleIncomingMidiMessage (MidiInput* void AudioDeviceManager::playTestSound() { - audioCallbackLock.enter(); - AudioSampleBuffer* oldSound = testSound.release(); - audioCallbackLock.exit(); - delete oldSound; + { + audioCallbackLock.enter(); + ScopedPointer oldSound (testSound); + audioCallbackLock.exit(); + } testSoundPosition = 0; @@ -52336,7 +52328,7 @@ TextEditor::TextEditor (const String& name, TextEditor::~TextEditor() { clearInternal (0); - delete viewport; + viewport = 0; } void TextEditor::newTransaction() throw() @@ -53885,15 +53877,15 @@ void TextEditor::splitSection (const int sectionIndex, sections.insert (sectionIndex + 1, ((UniformTextSection*) sections.getUnchecked (sectionIndex)) - ->split (charToSplitAt, passwordCharacter)); + ->split (charToSplitAt, passwordCharacter)); } void TextEditor::coalesceSimilarSections() throw() { for (int i = 0; i < sections.size() - 1; ++i) { - UniformTextSection* const s1 = (UniformTextSection*) (sections.getUnchecked (i)); - UniformTextSection* const s2 = (UniformTextSection*) (sections.getUnchecked (i + 1)); + UniformTextSection* const s1 = (UniformTextSection*) sections.getUnchecked (i); + UniformTextSection* const s2 = (UniformTextSection*) sections.getUnchecked (i + 1); if (s1->font == s2->font && s1->colour == s2->colour) @@ -55286,7 +55278,7 @@ public: for (int i = rowComponentItems.size(); --i >= 0;) { - Component* const comp = (Component*) (rowComponents.getUnchecked(i)); + Component* const comp = (Component*) rowComponents.getUnchecked(i); bool keep = false; @@ -70370,46 +70362,31 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro // isStandard set depending on which interface was used to create the cursor void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw(); -static CriticalSection mouseCursorLock; -static VoidArray standardCursors (2); +static CriticalSection activeCursorListLock; +static VoidArray activeCursors (2); -class RefCountedMouseCursor +class SharedMouseCursorInternal : public ReferenceCountedObject { public: - RefCountedMouseCursor (const MouseCursor::StandardCursorType t) throw() - : refCount (1), - standardType (t), + SharedMouseCursorInternal (const MouseCursor::StandardCursorType type) throw() + : standardType (type), isStandard (true) { handle = juce_createStandardMouseCursor (standardType); - standardCursors.add (this); + activeCursors.add (this); } - RefCountedMouseCursor (Image& image, - const int hotSpotX, - const int hotSpotY) throw() - : refCount (1), - standardType (MouseCursor::NormalCursor), + SharedMouseCursorInternal (const Image& image, const int hotSpotX, const int hotSpotY) throw() + : standardType (MouseCursor::NormalCursor), isStandard (false) { handle = juce_createMouseCursorFromImage (image, hotSpotX, hotSpotY); } - ~RefCountedMouseCursor() throw() + ~SharedMouseCursorInternal() throw() { juce_deleteMouseCursor (handle, isStandard); - standardCursors.removeValue (this); - } - - void decRef() throw() - { - if (--refCount == 0) - delete this; - } - - void incRef() throw() - { - ++refCount; + activeCursors.removeValue (this); } void* getHandle() const throw() @@ -70417,76 +70394,59 @@ public: return handle; } - static RefCountedMouseCursor* findInstance (MouseCursor::StandardCursorType type) throw() + static SharedMouseCursorInternal* findInstance (MouseCursor::StandardCursorType type) throw() { - const ScopedLock sl (mouseCursorLock); - - for (int i = 0; i < standardCursors.size(); i++) + for (int i = activeCursors.size(); --i >= 0;) { - RefCountedMouseCursor* const r = (RefCountedMouseCursor*) standardCursors.getUnchecked(i); + SharedMouseCursorInternal* const r = (SharedMouseCursorInternal*) activeCursors.getUnchecked(i); if (r->standardType == type) - { - r->incRef(); return r; - } } - return new RefCountedMouseCursor (type); + return new SharedMouseCursorInternal (type); } juce_UseDebuggingNewOperator private: void* handle; - int refCount; const MouseCursor::StandardCursorType standardType; const bool isStandard; - const RefCountedMouseCursor& operator= (const RefCountedMouseCursor&); + const SharedMouseCursorInternal& operator= (const SharedMouseCursorInternal&); }; MouseCursor::MouseCursor() throw() { - cursorHandle = RefCountedMouseCursor::findInstance (NormalCursor); + const ScopedLock sl (activeCursorListLock); + cursorHandle = SharedMouseCursorInternal::findInstance (NormalCursor); } MouseCursor::MouseCursor (const StandardCursorType type) throw() { - cursorHandle = RefCountedMouseCursor::findInstance (type); + const ScopedLock sl (activeCursorListLock); + cursorHandle = SharedMouseCursorInternal::findInstance (type); } -MouseCursor::MouseCursor (Image& image, - const int hotSpotX, - const int hotSpotY) throw() +MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY) throw() { - cursorHandle = new RefCountedMouseCursor (image, hotSpotX, hotSpotY); + const ScopedLock sl (activeCursorListLock); + cursorHandle = new SharedMouseCursorInternal (image, hotSpotX, hotSpotY); } MouseCursor::MouseCursor (const MouseCursor& other) throw() : cursorHandle (other.cursorHandle) { - const ScopedLock sl (mouseCursorLock); - cursorHandle->incRef(); } MouseCursor::~MouseCursor() throw() { - const ScopedLock sl (mouseCursorLock); - cursorHandle->decRef(); } const MouseCursor& MouseCursor::operator= (const MouseCursor& other) throw() { - if (this != &other) - { - const ScopedLock sl (mouseCursorLock); - - cursorHandle->decRef(); - cursorHandle = other.cursorHandle; - cursorHandle->incRef(); - } - + cursorHandle = other.cursorHandle; return *this; } @@ -92149,12 +92109,12 @@ END_JUCE_NAMESPACE BEGIN_JUCE_NAMESPACE -struct CachedImageInfo +struct ImageCacheItem { - Image* image; + ScopedPointer image; int64 hashCode; int refCount; - unsigned int releaseTime; + uint32 releaseTime; juce_UseDebuggingNewOperator }; @@ -92169,17 +92129,6 @@ ImageCache::ImageCache() throw() ImageCache::~ImageCache() { - const ScopedLock sl (lock); - - for (int i = images.size(); --i >= 0;) - { - CachedImageInfo* const ci = (CachedImageInfo*) images.getUnchecked(i); - delete ci->image; - delete ci; - } - - images.clear(); - jassert (instance == this); instance = 0; } @@ -92192,11 +92141,11 @@ Image* ImageCache::getFromHashCode (const int64 hashCode) for (int i = instance->images.size(); --i >= 0;) { - CachedImageInfo* const ci = (CachedImageInfo*) instance->images.getUnchecked(i); + ImageCacheItem* const ci = instance->images.getUnchecked(i); if (ci->hashCode == hashCode) { - atomicIncrement (ci->refCount); + ci->refCount++; return ci->image; } } @@ -92213,7 +92162,7 @@ void ImageCache::addImageToCache (Image* const image, if (instance == 0) instance = new ImageCache(); - CachedImageInfo* const newC = new CachedImageInfo(); + ImageCacheItem* const newC = new ImageCacheItem(); newC->hashCode = hashCode; newC->image = image; newC->refCount = 1; @@ -92232,9 +92181,9 @@ void ImageCache::release (Image* const imageToRelease) for (int i = instance->images.size(); --i >= 0;) { - CachedImageInfo* const ci = (CachedImageInfo*) instance->images.getUnchecked(i); + ImageCacheItem* const ci = instance->images.getUnchecked(i); - if (ci->image == imageToRelease) + if ((Image*) ci->image == imageToRelease) { if (--(ci->refCount) == 0) ci->releaseTime = Time::getApproximateMillisecondCounter(); @@ -92263,7 +92212,7 @@ bool ImageCache::isImageInCache (Image* const imageToLookFor) const ScopedLock sl (instance->lock); for (int i = instance->images.size(); --i >= 0;) - if (((const CachedImageInfo*) instance->images.getUnchecked(i))->image == imageToLookFor) + if ((Image*) instance->images.getUnchecked(i)->image == imageToLookFor) return true; } @@ -92278,9 +92227,9 @@ void ImageCache::incReferenceCount (Image* const image) for (int i = instance->images.size(); --i >= 0;) { - CachedImageInfo* const ci = (CachedImageInfo*) instance->images.getUnchecked(i); + ImageCacheItem* const ci = (ImageCacheItem*) instance->images.getUnchecked(i); - if (ci->image == image) + if ((Image*) ci->image == image) { ci->refCount++; return; @@ -92300,7 +92249,7 @@ void ImageCache::timerCallback() for (int i = images.size(); --i >= 0;) { - CachedImageInfo* const ci = (CachedImageInfo*) images.getUnchecked(i); + ImageCacheItem* const ci = images.getUnchecked(i); if (ci->refCount <= 0) { @@ -92308,8 +92257,6 @@ void ImageCache::timerCallback() || now < ci->releaseTime - 1000) { images.remove (i); - delete ci->image; - delete ci; } else { @@ -92324,8 +92271,7 @@ void ImageCache::timerCallback() Image* ImageCache::getFromFile (const File& file) { - const int64 hashCode = file.getFullPathName().hashCode64(); - + const int64 hashCode = file.hashCode64(); Image* image = getFromHashCode (hashCode); if (image == 0) @@ -95043,38 +94989,30 @@ const int gzipCompBufferSize = 32768; GZIPCompressorOutputStream::GZIPCompressorOutputStream (OutputStream* const destStream_, int compressionLevel, - const bool deleteDestStream_, + const bool deleteDestStream, const bool noWrap) : destStream (destStream_), - deleteDestStream (deleteDestStream_), + streamToDelete (deleteDestStream ? destStream_ : 0), buffer (gzipCompBufferSize) { if (compressionLevel < 1 || compressionLevel > 9) compressionLevel = -1; helper = new GZIPCompressorHelper (compressionLevel, noWrap); - } GZIPCompressorOutputStream::~GZIPCompressorOutputStream() { flush(); - - delete (GZIPCompressorHelper*) helper; - - if (deleteDestStream) - delete destStream; } void GZIPCompressorOutputStream::flush() { - GZIPCompressorHelper* const h = (GZIPCompressorHelper*) helper; - - if (! h->finished) + if (! helper->finished) { - h->shouldFinish = true; + helper->shouldFinish = true; - while (! h->finished) + while (! helper->finished) doNextBlock(); } @@ -95083,13 +95021,11 @@ void GZIPCompressorOutputStream::flush() bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany) { - GZIPCompressorHelper* const h = (GZIPCompressorHelper*) helper; - - if (! h->finished) + if (! helper->finished) { - h->setInput ((uint8*) destBuffer, howMany); + helper->setInput ((uint8*) destBuffer, howMany); - while (! h->needsInput()) + while (! helper->needsInput()) { if (! doNextBlock()) return false; @@ -95101,8 +95037,7 @@ bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany) bool GZIPCompressorOutputStream::doNextBlock() { - GZIPCompressorHelper* const h = (GZIPCompressorHelper*) helper; - const int len = h->doNextBlock (buffer, gzipCompBufferSize); + const int len = helper->doNextBlock (buffer, gzipCompBufferSize); if (len > 0) return destStream->write (buffer, len); @@ -102436,28 +102371,24 @@ public: const int gzipDecompBufferSize = 32768; GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream* const sourceStream_, - const bool deleteSourceWhenDestroyed_, + const bool deleteSourceWhenDestroyed, const bool noWrap_, const int64 uncompressedStreamLength_) : sourceStream (sourceStream_), + streamToDelete (deleteSourceWhenDestroyed ? sourceStream_ : 0), uncompressedStreamLength (uncompressedStreamLength_), - deleteSourceWhenDestroyed (deleteSourceWhenDestroyed_), noWrap (noWrap_), isEof (false), activeBufferSize (0), originalSourcePos (sourceStream_->getPosition()), currentPos (0), - buffer (gzipDecompBufferSize) + buffer (gzipDecompBufferSize), + helper (new GZIPDecompressHelper (noWrap_)) { - helper = new GZIPDecompressHelper (noWrap_); } GZIPDecompressorInputStream::~GZIPDecompressorInputStream() { - if (deleteSourceWhenDestroyed) - delete sourceStream; - - delete (GZIPDecompressHelper*) helper; } int64 GZIPDecompressorInputStream::getTotalLength() @@ -102467,8 +102398,6 @@ int64 GZIPDecompressorInputStream::getTotalLength() int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) { - GZIPDecompressHelper* const h = (GZIPDecompressHelper*) helper; - if ((howMany > 0) && ! isEof) { jassert (destBuffer != 0); @@ -102478,26 +102407,26 @@ int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) int numRead = 0; uint8* d = (uint8*) destBuffer; - while (! h->error) + while (! helper->error) { - const int n = h->doNextBlock (d, howMany); + const int n = helper->doNextBlock (d, howMany); currentPos += n; if (n == 0) { - if (h->finished || h->needsDictionary) + if (helper->finished || helper->needsDictionary) { isEof = true; return numRead; } - if (h->needsInput()) + if (helper->needsInput()) { activeBufferSize = sourceStream->read (buffer, gzipDecompBufferSize); if (activeBufferSize > 0) { - h->setInput ((uint8*) buffer, activeBufferSize); + helper->setInput ((uint8*) buffer, activeBufferSize); } else { @@ -102524,9 +102453,7 @@ int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) bool GZIPDecompressorInputStream::isExhausted() { - const GZIPDecompressHelper* const h = (GZIPDecompressHelper*) helper; - - return h->error || isEof; + return helper->error || isEof; } int64 GZIPDecompressorInputStream::getPosition() @@ -102545,8 +102472,6 @@ bool GZIPDecompressorInputStream::setPosition (int64 newPos) else { // reset the stream and start again.. - delete (GZIPDecompressHelper*) helper; - isEof = false; activeBufferSize = 0; currentPos = 0; @@ -236111,7 +236036,7 @@ bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAdd static HKEY findKeyForPath (String name, const bool createForWriting, - String& valueName) throw() + String& valueName) { HKEY rootKey = 0; @@ -236253,7 +236178,7 @@ void PlatformUtilities::registerFileAssociation (const String& fileExtension, targetExecutable.getFullPathName() + " %1"); } -bool juce_IsRunningInWine() throw() +bool juce_IsRunningInWine() { HKEY key; if (RegOpenKeyEx (HKEY_CURRENT_USER, _T("Software\\Wine"), 0, KEY_READ, &key) == ERROR_SUCCESS) @@ -259085,7 +259010,7 @@ static void juce_getCpuVendor (char* const v) throw() memcpy (v, vendor, 16); } -static unsigned int getCPUIDWord (unsigned int& familyModel, unsigned int& extFeatures) throw() +static unsigned int getCPUIDWord (unsigned int& familyModel, unsigned int& extFeatures) { unsigned int cpu = 0; unsigned int ext = 0; @@ -259895,7 +259820,7 @@ int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOut void JUCE_API juce_threadEntryPoint (void*); -void* threadEntryProc (void* userData) throw() +void* threadEntryProc (void* userData) { const ScopedAutoReleasePool pool; juce_threadEntryPoint (userData); @@ -260539,7 +260464,7 @@ const StringArray juce_getFileSystemRoots() throw() return s; } -static bool isFileOnDriveType (const File* const f, const char** types) throw() +static bool isFileOnDriveType (const File* const f, const char** types) { struct statfs buf; @@ -260589,7 +260514,7 @@ bool File::isOnRemovableDrive() const throw() #endif } -static bool juce_isHiddenFile (const String& path) throw() +static bool juce_isHiddenFile (const String& path) { #if JUCE_IPHONE return File (path).getFileName().startsWithChar (T('.')); @@ -261182,7 +261107,7 @@ void PlatformUtilities::addItemToDock (const File& file) } } -int PlatformUtilities::getOSXMinorVersionNumber() throw() +int PlatformUtilities::getOSXMinorVersionNumber() { SInt32 versionMinor = 0; OSErr err = Gestalt (gestaltSystemVersionMinor, &versionMinor); @@ -261758,7 +261683,7 @@ private: AffineTransform pathTransform; #endif - void createGlyphsForString (const juce_wchar* const text, const int length, HeapBlock & glyphs) throw() + void createGlyphsForString (const juce_wchar* const text, const int length, HeapBlock & glyphs) { #if SUPPORT_10_4_FONTS #if ! SUPPORT_ONLY_10_4_FONTS @@ -261791,7 +261716,7 @@ private: class CharToGlyphMapper { public: - CharToGlyphMapper (CGFontRef fontRef) throw() + CharToGlyphMapper (CGFontRef fontRef) : segCount (0), endCode (0), startCode (0), idDelta (0), idRangeOffset (0), glyphIndexes (0) { @@ -261833,7 +261758,7 @@ private: } } - ~CharToGlyphMapper() throw() + ~CharToGlyphMapper() { if (endCode != 0) { @@ -261845,7 +261770,7 @@ private: } } - int getGlyphForCharacter (const juce_wchar c) const throw() + int getGlyphForCharacter (const juce_wchar c) const { for (int i = 0; i < segCount; ++i) { @@ -261873,12 +261798,12 @@ private: int segCount; CFDataRef endCode, startCode, idDelta, idRangeOffset, glyphIndexes; - static uint16 getValue16 (CFDataRef data, const int index) throw() + static uint16 getValue16 (CFDataRef data, const int index) { return CFSwapInt16BigToHost (*(UInt16*) (CFDataGetBytePtr (data) + index)); } - static uint32 getValue32 (CFDataRef data, const int index) throw() + static uint32 getValue32 (CFDataRef data, const int index) { return CFSwapInt32BigToHost (*(UInt32*) (CFDataGetBytePtr (data) + index)); } @@ -261959,7 +261884,7 @@ public: LowLevelGraphicsContext* createLowLevelContext(); - static CGImageRef createImage (const Image& juceImage, const bool forAlpha, CGColorSpaceRef colourSpace) throw() + static CGImageRef createImage (const Image& juceImage, const bool forAlpha, CGColorSpaceRef colourSpace) { const CoreGraphicsImage* nativeImage = dynamic_cast (&juceImage); @@ -262009,7 +261934,7 @@ public: CGContextRef context; private: - static CGBitmapInfo getCGImageFlags (const Image& image) throw() + static CGBitmapInfo getCGImageFlags (const Image& image) { #if JUCE_BIG_ENDIAN return image.getFormat() == Image::ARGB ? (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Big) : kCGBitmapByteOrderDefault; @@ -262433,18 +262358,18 @@ private: struct SavedState { - SavedState() throw() + SavedState() : font (1.0f), fontRef (0), fontTransform (CGAffineTransformIdentity) { } - SavedState (const SavedState& other) throw() + SavedState (const SavedState& other) : fillType (other.fillType), font (other.font), fontRef (other.fontRef), fontTransform (other.fontTransform) { } - ~SavedState() throw() + ~SavedState() { } @@ -262473,7 +262398,7 @@ private: outData[3] = colour.getAlpha() / 255.0f; } - CGShadingRef createGradient (const AffineTransform& transform, ColourGradient gradient) throw() + CGShadingRef createGradient (const AffineTransform& transform, ColourGradient gradient) { numGradientLookupEntries = gradient.createLookupTable (transform, gradientLookupTable); --numGradientLookupEntries; @@ -262499,7 +262424,7 @@ private: return result; } - void drawGradient() throw() + void drawGradient() { flip(); applyTransform (state->fillType.transform); @@ -262512,7 +262437,7 @@ private: CGShadingRelease (shading); } - void createPath (const Path& path) const throw() + void createPath (const Path& path) const { CGContextBeginPath (context); Path::Iterator i (path); @@ -262542,7 +262467,7 @@ private: } } - void createPath (const Path& path, const AffineTransform& transform) const throw() + void createPath (const Path& path, const AffineTransform& transform) const { CGContextBeginPath (context); Path::Iterator i (path); @@ -262579,7 +262504,7 @@ private: } } - static Image* createAlphaChannelImage (const Image& im) throw() + static Image* createAlphaChannelImage (const Image& im) { if (im.getFormat() == Image::SingleChannel) return const_cast (&im); @@ -262587,18 +262512,18 @@ private: return im.createCopyOfAlphaChannel(); } - static void deleteAlphaChannelImage (const Image& im, Image* const alphaIm) throw() + static void deleteAlphaChannelImage (const Image& im, Image* const alphaIm) { if (im.getFormat() != Image::SingleChannel) delete alphaIm; } - void flip() const throw() + void flip() const { CGContextConcatCTM (context, CGAffineTransformMake (1, 0, 0, -1, 0, flipHeight)); } - void applyTransform (const AffineTransform& transform) const throw() + void applyTransform (const AffineTransform& transform) const { CGAffineTransform t; t.a = transform.mat00; @@ -262610,7 +262535,7 @@ private: CGContextConcatCTM (context, t); } - float flipY (float y) const throw() + float flipY (float y) const { return flipHeight - y; } @@ -262771,14 +262696,14 @@ void ModifierKeys::updateCurrentModifiers() throw() currentModifierFlags = currentModifiers; } -static int getModifierForButtonNumber (const int num) throw() +static int getModifierForButtonNumber (const int num) { return num == 0 ? ModifierKeys::leftButtonModifier : (num == 1 ? ModifierKeys::rightButtonModifier : (num == 2 ? ModifierKeys::middleButtonModifier : 0)); } -static int64 getMouseTime (UIEvent* e) throw() +static int64 getMouseTime (UIEvent* e) { return (Time::currentTimeMillis() - Time::getMillisecondCounter()) + (int64) ([e timestamp] * 1000.0); @@ -264877,7 +264802,7 @@ private: } OSStatus process (AudioUnitRenderActionFlags* ioActionFlags, const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList* ioData) throw() + UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList* ioData) { OSStatus err = noErr; @@ -264955,7 +264880,7 @@ private: return err; } - void updateDeviceInfo() throw() + void updateDeviceInfo() { UInt32 size = sizeof (sampleRate); AudioSessionGetProperty (kAudioSessionProperty_CurrentHardwareSampleRate, &size, &sampleRate); @@ -265100,7 +265025,7 @@ private: // If the routing is set to go through the receiver (i.e. the speaker, but quiet), this re-routes it // to make it loud. Needed because by default when using an input + output, the output is kept quiet. - static void fixAudioRouteIfSetToReceiver() throw() + static void fixAudioRouteIfSetToReceiver() { CFStringRef audioRoute = 0; UInt32 propertySize = sizeof (audioRoute); @@ -265397,12 +265322,12 @@ static bool makeSureClientExists() class MidiPortAndEndpoint { public: - MidiPortAndEndpoint (MIDIPortRef port_, MIDIEndpointRef endPoint_) throw() + MidiPortAndEndpoint (MIDIPortRef port_, MIDIEndpointRef endPoint_) : port (port_), endPoint (endPoint_) { } - ~MidiPortAndEndpoint() throw() + ~MidiPortAndEndpoint() { if (port != 0) MIDIPortDispose (port); @@ -266185,7 +266110,7 @@ private: AffineTransform pathTransform; #endif - void createGlyphsForString (const juce_wchar* const text, const int length, HeapBlock & glyphs) throw() + void createGlyphsForString (const juce_wchar* const text, const int length, HeapBlock & glyphs) { #if SUPPORT_10_4_FONTS #if ! SUPPORT_ONLY_10_4_FONTS @@ -266218,7 +266143,7 @@ private: class CharToGlyphMapper { public: - CharToGlyphMapper (CGFontRef fontRef) throw() + CharToGlyphMapper (CGFontRef fontRef) : segCount (0), endCode (0), startCode (0), idDelta (0), idRangeOffset (0), glyphIndexes (0) { @@ -266260,7 +266185,7 @@ private: } } - ~CharToGlyphMapper() throw() + ~CharToGlyphMapper() { if (endCode != 0) { @@ -266272,7 +266197,7 @@ private: } } - int getGlyphForCharacter (const juce_wchar c) const throw() + int getGlyphForCharacter (const juce_wchar c) const { for (int i = 0; i < segCount; ++i) { @@ -266300,12 +266225,12 @@ private: int segCount; CFDataRef endCode, startCode, idDelta, idRangeOffset, glyphIndexes; - static uint16 getValue16 (CFDataRef data, const int index) throw() + static uint16 getValue16 (CFDataRef data, const int index) { return CFSwapInt16BigToHost (*(UInt16*) (CFDataGetBytePtr (data) + index)); } - static uint32 getValue32 (CFDataRef data, const int index) throw() + static uint32 getValue32 (CFDataRef data, const int index) { return CFSwapInt32BigToHost (*(UInt32*) (CFDataGetBytePtr (data) + index)); } @@ -266388,7 +266313,7 @@ public: LowLevelGraphicsContext* createLowLevelContext(); - static CGImageRef createImage (const Image& juceImage, const bool forAlpha, CGColorSpaceRef colourSpace) throw() + static CGImageRef createImage (const Image& juceImage, const bool forAlpha, CGColorSpaceRef colourSpace) { const CoreGraphicsImage* nativeImage = dynamic_cast (&juceImage); @@ -266438,7 +266363,7 @@ public: CGContextRef context; private: - static CGBitmapInfo getCGImageFlags (const Image& image) throw() + static CGBitmapInfo getCGImageFlags (const Image& image) { #if JUCE_BIG_ENDIAN return image.getFormat() == Image::ARGB ? (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Big) : kCGBitmapByteOrderDefault; @@ -266862,18 +266787,18 @@ private: struct SavedState { - SavedState() throw() + SavedState() : font (1.0f), fontRef (0), fontTransform (CGAffineTransformIdentity) { } - SavedState (const SavedState& other) throw() + SavedState (const SavedState& other) : fillType (other.fillType), font (other.font), fontRef (other.fontRef), fontTransform (other.fontTransform) { } - ~SavedState() throw() + ~SavedState() { } @@ -266902,7 +266827,7 @@ private: outData[3] = colour.getAlpha() / 255.0f; } - CGShadingRef createGradient (const AffineTransform& transform, ColourGradient gradient) throw() + CGShadingRef createGradient (const AffineTransform& transform, ColourGradient gradient) { numGradientLookupEntries = gradient.createLookupTable (transform, gradientLookupTable); --numGradientLookupEntries; @@ -266928,7 +266853,7 @@ private: return result; } - void drawGradient() throw() + void drawGradient() { flip(); applyTransform (state->fillType.transform); @@ -266941,7 +266866,7 @@ private: CGShadingRelease (shading); } - void createPath (const Path& path) const throw() + void createPath (const Path& path) const { CGContextBeginPath (context); Path::Iterator i (path); @@ -266971,7 +266896,7 @@ private: } } - void createPath (const Path& path, const AffineTransform& transform) const throw() + void createPath (const Path& path, const AffineTransform& transform) const { CGContextBeginPath (context); Path::Iterator i (path); @@ -267008,7 +266933,7 @@ private: } } - static Image* createAlphaChannelImage (const Image& im) throw() + static Image* createAlphaChannelImage (const Image& im) { if (im.getFormat() == Image::SingleChannel) return const_cast (&im); @@ -267016,18 +266941,18 @@ private: return im.createCopyOfAlphaChannel(); } - static void deleteAlphaChannelImage (const Image& im, Image* const alphaIm) throw() + static void deleteAlphaChannelImage (const Image& im, Image* const alphaIm) { if (im.getFormat() != Image::SingleChannel) delete alphaIm; } - void flip() const throw() + void flip() const { CGContextConcatCTM (context, CGAffineTransformMake (1, 0, 0, -1, 0, flipHeight)); } - void applyTransform (const AffineTransform& transform) const throw() + void applyTransform (const AffineTransform& transform) const { CGAffineTransform t; t.a = transform.mat00; @@ -267039,7 +266964,7 @@ private: CGContextConcatCTM (context, t); } - float flipY (float y) const throw() + float flipY (float y) const { return flipHeight - y; } @@ -267652,7 +267577,7 @@ void ModifierKeys::updateCurrentModifiers() throw() currentModifierFlags = currentModifiers; } -static int64 getMouseTime (NSEvent* e) throw() +static int64 getMouseTime (NSEvent* e) { return (Time::currentTimeMillis() - Time::getMillisecondCounter()) + (int64) ([e timestamp] * 1000.0); @@ -267665,7 +267590,7 @@ static void getMousePos (NSEvent* e, NSView* view, int& x, int& y) y = roundFloatToInt ([view frame].size.height - p.y); } -static int getModifierForButtonNumber (const int num) throw() +static int getModifierForButtonNumber (const int num) { return num == 0 ? ModifierKeys::leftButtonModifier : (num == 1 ? ModifierKeys::rightButtonModifier @@ -268871,7 +268796,7 @@ AppleRemoteDevice::~AppleRemoteDevice() stop(); } -static io_object_t getAppleRemoteDevice() throw() +static io_object_t getAppleRemoteDevice() { CFMutableDictionaryRef dict = IOServiceMatching ("AppleIRController"); @@ -268888,7 +268813,7 @@ static io_object_t getAppleRemoteDevice() throw() return iod; } -static bool createAppleRemoteInterface (io_object_t iod, void** device) throw() +static bool createAppleRemoteInterface (io_object_t iod, void** device) { jassert (*device == 0); io_name_t classname; @@ -268917,7 +268842,7 @@ static bool createAppleRemoteInterface (io_object_t iod, void** device) throw() return *device != 0; } -bool AppleRemoteDevice::start (const bool inExclusiveMode) throw() +bool AppleRemoteDevice::start (const bool inExclusiveMode) { if (queue != 0) return true; @@ -268940,7 +268865,7 @@ bool AppleRemoteDevice::start (const bool inExclusiveMode) throw() return result; } -void AppleRemoteDevice::stop() throw() +void AppleRemoteDevice::stop() { if (queue != 0) { @@ -268958,7 +268883,7 @@ void AppleRemoteDevice::stop() throw() } } -bool AppleRemoteDevice::isActive() const throw() +bool AppleRemoteDevice::isActive() const { return queue != 0; } @@ -268969,7 +268894,7 @@ static void appleRemoteQueueCallback (void* const target, const IOReturn result, ((AppleRemoteDevice*) target)->handleCallbackInternal(); } -bool AppleRemoteDevice::open (const bool openInExclusiveMode) throw() +bool AppleRemoteDevice::open (const bool openInExclusiveMode) { Array cookies; @@ -269442,14 +269367,14 @@ class JuceMainMenuHandler : private MenuBarModelListener, public: static JuceMainMenuHandler* instance; - JuceMainMenuHandler() throw() + JuceMainMenuHandler() : currentModel (0), lastUpdateTime (0) { callback = [[JuceMenuCallback alloc] initWithOwner: this]; } - ~JuceMainMenuHandler() throw() + ~JuceMainMenuHandler() { setMenu (0); @@ -269459,7 +269384,7 @@ public: [callback release]; } - void setMenu (MenuBarModel* const newMenuBarModel) throw() + void setMenu (MenuBarModel* const newMenuBarModel) { if (currentModel != newMenuBarModel) { @@ -269870,7 +269795,7 @@ static void rebuildMainMenu (const PopupMenu* extraItems) } void MenuBarModel::setMacMainMenu (MenuBarModel* newMenuBarModel, - const PopupMenu* extraAppleMenuItems) throw() + const PopupMenu* extraAppleMenuItems) { if (getMacMainMenu() != newMenuBarModel) { @@ -269899,7 +269824,7 @@ void MenuBarModel::setMacMainMenu (MenuBarModel* newMenuBarModel, newMenuBarModel->menuItemsChanged(); } -MenuBarModel* MenuBarModel::getMacMainMenu() throw() +MenuBarModel* MenuBarModel::getMacMainMenu() { return JuceMainMenuHandler::instance != 0 ? JuceMainMenuHandler::instance->currentModel : 0; @@ -270871,7 +270796,7 @@ public: delete this; } - void postMessage (void* m) throw() + void postMessage (void* m) { messages.add (m); CFRunLoopSourceSignal (runLoopSource); @@ -270883,7 +270808,7 @@ private: CFRunLoopSourceRef runLoopSource; Array messages; - void runLoopCallback() throw() + void runLoopCallback() { int numDispatched = 0; @@ -273047,12 +272972,12 @@ static bool makeSureClientExists() class MidiPortAndEndpoint { public: - MidiPortAndEndpoint (MIDIPortRef port_, MIDIEndpointRef endPoint_) throw() + MidiPortAndEndpoint (MIDIPortRef port_, MIDIEndpointRef endPoint_) : port (port_), endPoint (endPoint_) { } - ~MidiPortAndEndpoint() throw() + ~MidiPortAndEndpoint() { if (port != 0) MIDIPortDispose (port); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 631b7d37b2..b06af5764b 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -12659,7 +12659,7 @@ public: /** MAC ONLY - Returns the current OS version number. E.g. if it's running on 10.4, this will be 4, 10.5 will return 5, etc. */ - static int getOSXMinorVersionNumber() throw(); + static int getOSXMinorVersionNumber(); #endif #if JUCE_WINDOWS || DOXYGEN @@ -12846,20 +12846,20 @@ public: false, it will be shared with other apps. @see stop */ - bool start (const bool inExclusiveMode) throw(); + bool start (const bool inExclusiveMode); /** Stops the device running. @see start */ - void stop() throw(); + void stop(); /** Returns true if the device has been started successfully. */ - bool isActive() const throw(); + bool isActive() const; /** Returns the ID number of the remote, if it has sent one. */ - int getRemoteId() const throw() { return remoteId; } + int getRemoteId() const { return remoteId; } juce_UseDebuggingNewOperator @@ -12871,7 +12871,7 @@ private: void* queue; int remoteId; - bool open (const bool openInExclusiveMode) throw(); + bool open (const bool openInExclusiveMode); AppleRemoteDevice (const AppleRemoteDevice&); const AppleRemoteDevice& operator= (const AppleRemoteDevice&); @@ -14348,9 +14348,9 @@ private: friend class ZipInputStream; CriticalSection lock; InputStream* inputStream; + ScopedPointer streamToDelete; ScopedPointer inputSource; - bool deleteStreamWhenDestroyed; int numEntries, centralRecStart; #ifdef JUCE_DEBUG @@ -14940,7 +14940,7 @@ public: private: InputStream* const source; - const bool deleteSourceWhenDestroyed; + ScopedPointer sourceToDelete; int bufferSize; int64 position, lastReadPos, bufferStart, bufferOverlap; HeapBlock buffer; @@ -14995,6 +14995,8 @@ private: #ifndef __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__ #define __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__ +class GZIPCompressorHelper; + /** A stream which uses zlib to compress the data written into it. @@ -15034,9 +15036,9 @@ public: private: OutputStream* const destStream; - const bool deleteDestStream; + ScopedPointer streamToDelete; HeapBlock buffer; - void* helper; + ScopedPointer helper; bool doNextBlock(); GZIPCompressorOutputStream (const GZIPCompressorOutputStream&); @@ -15053,6 +15055,8 @@ private: #ifndef __JUCE_GZIPDECOMPRESSORINPUTSTREAM_JUCEHEADER__ #define __JUCE_GZIPDECOMPRESSORINPUTSTREAM_JUCEHEADER__ +class GZIPDecompressHelper; + /** This stream will decompress a source-stream using zlib. @@ -15095,13 +15099,14 @@ public: private: InputStream* const sourceStream; + ScopedPointer streamToDelete; const int64 uncompressedStreamLength; - const bool deleteSourceWhenDestroyed, noWrap; + const bool noWrap; bool isEof; int activeBufferSize; int64 originalSourcePos, currentPos; HeapBlock buffer; - void* helper; + ScopedPointer helper; GZIPDecompressorInputStream (const GZIPDecompressorInputStream&); const GZIPDecompressorInputStream& operator= (const GZIPDecompressorInputStream&); @@ -15226,8 +15231,8 @@ public: private: MemoryBlock* data; + ScopedPointer dataToDelete; int position, size, blockSize; - bool ownsMemoryBlock; }; #endif // __JUCE_MEMORYOUTPUTSTREAM_JUCEHEADER__ @@ -15291,7 +15296,7 @@ public: private: InputStream* const source; - const bool deleteSourceWhenDestroyed; + ScopedPointer sourceToDelete; const int64 startPositionInSourceStream, lengthOfSourceStream; SubregionStream (const SubregionStream&); @@ -15370,17 +15375,17 @@ public: When you create one of these, you can call setCurrentMappings() to make it the set of mappings that the system's using. */ - LocalisedStrings (const String& fileContents) throw(); + LocalisedStrings (const String& fileContents); /** Creates a set of translations from a file. When you create one of these, you can call setCurrentMappings() to make it the set of mappings that the system's using. */ - LocalisedStrings (const File& fileToLoad) throw(); + LocalisedStrings (const File& fileToLoad); /** Destructor. */ - ~LocalisedStrings() throw(); + ~LocalisedStrings(); /** Selects the current set of mappings to be used by the system. @@ -15392,14 +15397,14 @@ public: @see translateWithCurrentMappings */ - static void setCurrentMappings (LocalisedStrings* newTranslations) throw(); + static void setCurrentMappings (LocalisedStrings* newTranslations); /** Returns the currently selected set of mappings. This is the object that was last passed to setCurrentMappings(). It may be 0 if none has been created. */ - static LocalisedStrings* getCurrentMappings() throw(); + static LocalisedStrings* getCurrentMappings(); /** Tries to translate a string using the currently selected set of mappings. @@ -15410,7 +15415,7 @@ public: @see setCurrentMappings, getCurrentMappings */ - static const String translateWithCurrentMappings (const String& text) throw(); + static const String translateWithCurrentMappings (const String& text); /** Tries to translate a string using the currently selected set of mappings. @@ -15421,13 +15426,13 @@ public: @see setCurrentMappings, getCurrentMappings */ - static const String translateWithCurrentMappings (const char* text) throw(); + static const String translateWithCurrentMappings (const char* text); /** Attempts to look up a string and return its localised version. If the string isn't found in the list, the original string will be returned. */ - const String translate (const String& text) const throw(); + const String translate (const String& text) const; /** Returns the name of the language specified in the translation file. @@ -15436,7 +15441,7 @@ public: language: german @endcode */ - const String getLanguageName() const throw() { return languageName; } + const String getLanguageName() const { return languageName; } /** Returns the list of suitable country codes listed in the translation file. @@ -15447,12 +15452,12 @@ public: The country codes are supposed to be 2-character ISO complient codes. */ - const StringArray getCountryCodes() const throw() { return countryCodes; } + const StringArray getCountryCodes() const { return countryCodes; } /** Indicates whether to use a case-insensitive search when looking up a string. This defaults to true. */ - void setIgnoresCase (const bool shouldIgnoreCase) throw(); + void setIgnoresCase (const bool shouldIgnoreCase); juce_UseDebuggingNewOperator @@ -15461,7 +15466,7 @@ private: StringArray countryCodes; StringPairArray translations; - void loadFromText (const String& fileContents) throw(); + void loadFromText (const String& fileContents); }; #endif // __JUCE_LOCALISEDSTRINGS_JUCEHEADER__ @@ -16809,7 +16814,7 @@ private: #define __JUCE_MOUSECURSOR_JUCEHEADER__ class Image; -class RefCountedMouseCursor; +class SharedMouseCursorInternal; class ComponentPeer; class Component; @@ -16867,7 +16872,7 @@ public: @param hotSpotX the x position of the cursor's hotspot within the image @param hotSpotY the y position of the cursor's hotspot within the image */ - MouseCursor (Image& image, + MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY) throw(); @@ -16921,13 +16926,11 @@ public: juce_UseDebuggingNewOperator private: - RefCountedMouseCursor* cursorHandle; + ReferenceCountedObjectPtr cursorHandle; friend class Component; - void showInWindow (ComponentPeer* window) const throw(); void showInAllWindows() const throw(); - void* getHandle() const throw(); }; @@ -33540,7 +33543,7 @@ protected: private: - Viewport* viewport; + ScopedPointer viewport; TextHolderComponent* textHolder; BorderSize borderSize; @@ -48976,12 +48979,12 @@ public: object then newMenuBarModel must be non-null. */ static void setMacMainMenu (MenuBarModel* newMenuBarModel, - const PopupMenu* extraAppleMenuItems = 0) throw(); + const PopupMenu* extraAppleMenuItems = 0); /** MAC ONLY - Returns the menu model that is currently being shown as the main menu bar. */ - static MenuBarModel* getMacMainMenu() throw(); + static MenuBarModel* getMacMainMenu(); #endif @@ -55816,6 +55819,8 @@ private: #ifndef __JUCE_IMAGECACHE_JUCEHEADER__ #define __JUCE_IMAGECACHE_JUCEHEADER__ +struct ImageCacheItem; + /** A global cache of images that have been loaded from files or memory. @@ -55942,7 +55947,7 @@ public: private: CriticalSection lock; - VoidArray images; + OwnedArray images; ImageCache() throw(); ImageCache (const ImageCache&); diff --git a/src/audio/audio_file_formats/juce_AudioFormatManager.cpp b/src/audio/audio_file_formats/juce_AudioFormatManager.cpp index e4a266ea15..fba221ba00 100644 --- a/src/audio/audio_file_formats/juce_AudioFormatManager.cpp +++ b/src/audio/audio_file_formats/juce_AudioFormatManager.cpp @@ -98,10 +98,7 @@ void AudioFormatManager::registerBasicFormats() void AudioFormatManager::clearFormats() { for (int i = getNumKnownFormats(); --i >= 0;) - { - AudioFormat* const af = getKnownFormat(i); - delete af; - } + delete getKnownFormat(i); knownFormats.clear(); defaultFormatIndex = 0; @@ -191,12 +188,14 @@ AudioFormatReader* AudioFormatManager::createReaderFor (const File& file) return 0; } -AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* in) +AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* audioFileStream) { // you need to actually register some formats before the manager can // use them to open a file! jassert (knownFormats.size() > 0); + ScopedPointer in (audioFileStream); + if (in != 0) { const int64 originalStreamPos = in->getPosition(); @@ -206,7 +205,10 @@ AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* in) AudioFormatReader* const r = getKnownFormat(i)->createReaderFor (in, false); if (r != 0) + { + in.release(); return r; + } in->setPosition (originalStreamPos); @@ -214,8 +216,6 @@ AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* in) // that all the formats can have a go at opening it. jassert (in->getPosition() == originalStreamPos); } - - delete in; } return 0; diff --git a/src/audio/devices/juce_AudioDeviceManager.cpp b/src/audio/devices/juce_AudioDeviceManager.cpp index bb103b8ad2..d05a04d660 100644 --- a/src/audio/devices/juce_AudioDeviceManager.cpp +++ b/src/audio/devices/juce_AudioDeviceManager.cpp @@ -926,10 +926,11 @@ void AudioDeviceManager::CallbackHandler::handleIncomingMidiMessage (MidiInput* //============================================================================== void AudioDeviceManager::playTestSound() { - audioCallbackLock.enter(); - AudioSampleBuffer* oldSound = testSound.release(); - audioCallbackLock.exit(); - delete oldSound; + { + audioCallbackLock.enter(); + ScopedPointer oldSound (testSound); + audioCallbackLock.exit(); + } testSoundPosition = 0; diff --git a/src/core/juce_PlatformUtilities.h b/src/core/juce_PlatformUtilities.h index 77fa32af20..40f2ac2764 100644 --- a/src/core/juce_PlatformUtilities.h +++ b/src/core/juce_PlatformUtilities.h @@ -77,7 +77,7 @@ public: /** MAC ONLY - Returns the current OS version number. E.g. if it's running on 10.4, this will be 4, 10.5 will return 5, etc. */ - static int getOSXMinorVersionNumber() throw(); + static int getOSXMinorVersionNumber(); #endif @@ -273,20 +273,20 @@ public: false, it will be shared with other apps. @see stop */ - bool start (const bool inExclusiveMode) throw(); + bool start (const bool inExclusiveMode); /** Stops the device running. @see start */ - void stop() throw(); + void stop(); /** Returns true if the device has been started successfully. */ - bool isActive() const throw(); + bool isActive() const; /** Returns the ID number of the remote, if it has sent one. */ - int getRemoteId() const throw() { return remoteId; } + int getRemoteId() const { return remoteId; } //============================================================================== juce_UseDebuggingNewOperator @@ -299,7 +299,7 @@ private: void* queue; int remoteId; - bool open (const bool openInExclusiveMode) throw(); + bool open (const bool openInExclusiveMode); AppleRemoteDevice (const AppleRemoteDevice&); const AppleRemoteDevice& operator= (const AppleRemoteDevice&); diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index 5ae6b104dd..02815476f7 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -1045,7 +1045,7 @@ TextEditor::TextEditor (const String& name, TextEditor::~TextEditor() { clearInternal (0); - delete viewport; + viewport = 0; } //============================================================================== @@ -2614,15 +2614,15 @@ void TextEditor::splitSection (const int sectionIndex, sections.insert (sectionIndex + 1, ((UniformTextSection*) sections.getUnchecked (sectionIndex)) - ->split (charToSplitAt, passwordCharacter)); + ->split (charToSplitAt, passwordCharacter)); } void TextEditor::coalesceSimilarSections() throw() { for (int i = 0; i < sections.size() - 1; ++i) { - UniformTextSection* const s1 = (UniformTextSection*) (sections.getUnchecked (i)); - UniformTextSection* const s2 = (UniformTextSection*) (sections.getUnchecked (i + 1)); + UniformTextSection* const s1 = (UniformTextSection*) sections.getUnchecked (i); + UniformTextSection* const s2 = (UniformTextSection*) sections.getUnchecked (i + 1); if (s1->font == s2->font && s1->colour == s2->colour) diff --git a/src/gui/components/controls/juce_TextEditor.h b/src/gui/components/controls/juce_TextEditor.h index 50c0165617..1508d3f465 100644 --- a/src/gui/components/controls/juce_TextEditor.h +++ b/src/gui/components/controls/juce_TextEditor.h @@ -609,7 +609,7 @@ protected: private: //============================================================================== - Viewport* viewport; + ScopedPointer viewport; TextHolderComponent* textHolder; BorderSize borderSize; diff --git a/src/gui/components/controls/juce_TreeView.cpp b/src/gui/components/controls/juce_TreeView.cpp index 6c8a4ae6a7..49354691a8 100644 --- a/src/gui/components/controls/juce_TreeView.cpp +++ b/src/gui/components/controls/juce_TreeView.cpp @@ -218,7 +218,7 @@ public: for (int i = rowComponentItems.size(); --i >= 0;) { - Component* const comp = (Component*) (rowComponents.getUnchecked(i)); + Component* const comp = (Component*) rowComponents.getUnchecked(i); bool keep = false; @@ -467,7 +467,6 @@ void TreeView::deleteRootItem() setRootItem (0); } - void TreeView::setRootItemVisible (const bool shouldBeVisible) { rootItemVisible = shouldBeVisible; diff --git a/src/gui/components/menus/juce_MenuBarModel.h b/src/gui/components/menus/juce_MenuBarModel.h index 3b420f3a40..dd9cfeb7ae 100644 --- a/src/gui/components/menus/juce_MenuBarModel.h +++ b/src/gui/components/menus/juce_MenuBarModel.h @@ -151,12 +151,12 @@ public: object then newMenuBarModel must be non-null. */ static void setMacMainMenu (MenuBarModel* newMenuBarModel, - const PopupMenu* extraAppleMenuItems = 0) throw(); + const PopupMenu* extraAppleMenuItems = 0); /** MAC ONLY - Returns the menu model that is currently being shown as the main menu bar. */ - static MenuBarModel* getMacMainMenu() throw(); + static MenuBarModel* getMacMainMenu(); #endif diff --git a/src/gui/components/mouse/juce_MouseCursor.cpp b/src/gui/components/mouse/juce_MouseCursor.cpp index aad8229b01..897ddf0404 100644 --- a/src/gui/components/mouse/juce_MouseCursor.cpp +++ b/src/gui/components/mouse/juce_MouseCursor.cpp @@ -39,47 +39,32 @@ void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) th //============================================================================== -static CriticalSection mouseCursorLock; -static VoidArray standardCursors (2); +static CriticalSection activeCursorListLock; +static VoidArray activeCursors (2); //============================================================================== -class RefCountedMouseCursor +class SharedMouseCursorInternal : public ReferenceCountedObject { public: - RefCountedMouseCursor (const MouseCursor::StandardCursorType t) throw() - : refCount (1), - standardType (t), + SharedMouseCursorInternal (const MouseCursor::StandardCursorType type) throw() + : standardType (type), isStandard (true) { handle = juce_createStandardMouseCursor (standardType); - standardCursors.add (this); + activeCursors.add (this); } - RefCountedMouseCursor (Image& image, - const int hotSpotX, - const int hotSpotY) throw() - : refCount (1), - standardType (MouseCursor::NormalCursor), + SharedMouseCursorInternal (const Image& image, const int hotSpotX, const int hotSpotY) throw() + : standardType (MouseCursor::NormalCursor), isStandard (false) { handle = juce_createMouseCursorFromImage (image, hotSpotX, hotSpotY); } - ~RefCountedMouseCursor() throw() + ~SharedMouseCursorInternal() throw() { juce_deleteMouseCursor (handle, isStandard); - standardCursors.removeValue (this); - } - - void decRef() throw() - { - if (--refCount == 0) - delete this; - } - - void incRef() throw() - { - ++refCount; + activeCursors.removeValue (this); } void* getHandle() const throw() @@ -87,22 +72,17 @@ public: return handle; } - static RefCountedMouseCursor* findInstance (MouseCursor::StandardCursorType type) throw() + static SharedMouseCursorInternal* findInstance (MouseCursor::StandardCursorType type) throw() { - const ScopedLock sl (mouseCursorLock); - - for (int i = 0; i < standardCursors.size(); i++) + for (int i = activeCursors.size(); --i >= 0;) { - RefCountedMouseCursor* const r = (RefCountedMouseCursor*) standardCursors.getUnchecked(i); + SharedMouseCursorInternal* const r = (SharedMouseCursorInternal*) activeCursors.getUnchecked(i); if (r->standardType == type) - { - r->incRef(); return r; - } } - return new RefCountedMouseCursor (type); + return new SharedMouseCursorInternal (type); } //============================================================================== @@ -110,56 +90,44 @@ public: private: void* handle; - int refCount; const MouseCursor::StandardCursorType standardType; const bool isStandard; - const RefCountedMouseCursor& operator= (const RefCountedMouseCursor&); + const SharedMouseCursorInternal& operator= (const SharedMouseCursorInternal&); }; //============================================================================== MouseCursor::MouseCursor() throw() { - cursorHandle = RefCountedMouseCursor::findInstance (NormalCursor); + const ScopedLock sl (activeCursorListLock); + cursorHandle = SharedMouseCursorInternal::findInstance (NormalCursor); } MouseCursor::MouseCursor (const StandardCursorType type) throw() { - cursorHandle = RefCountedMouseCursor::findInstance (type); + const ScopedLock sl (activeCursorListLock); + cursorHandle = SharedMouseCursorInternal::findInstance (type); } -MouseCursor::MouseCursor (Image& image, - const int hotSpotX, - const int hotSpotY) throw() +MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY) throw() { - cursorHandle = new RefCountedMouseCursor (image, hotSpotX, hotSpotY); + const ScopedLock sl (activeCursorListLock); + cursorHandle = new SharedMouseCursorInternal (image, hotSpotX, hotSpotY); } MouseCursor::MouseCursor (const MouseCursor& other) throw() : cursorHandle (other.cursorHandle) { - const ScopedLock sl (mouseCursorLock); - cursorHandle->incRef(); } MouseCursor::~MouseCursor() throw() { - const ScopedLock sl (mouseCursorLock); - cursorHandle->decRef(); } const MouseCursor& MouseCursor::operator= (const MouseCursor& other) throw() { - if (this != &other) - { - const ScopedLock sl (mouseCursorLock); - - cursorHandle->decRef(); - cursorHandle = other.cursorHandle; - cursorHandle->incRef(); - } - + cursorHandle = other.cursorHandle; return *this; } diff --git a/src/gui/components/mouse/juce_MouseCursor.h b/src/gui/components/mouse/juce_MouseCursor.h index 2aa5e598f8..5813af3727 100644 --- a/src/gui/components/mouse/juce_MouseCursor.h +++ b/src/gui/components/mouse/juce_MouseCursor.h @@ -26,8 +26,9 @@ #ifndef __JUCE_MOUSECURSOR_JUCEHEADER__ #define __JUCE_MOUSECURSOR_JUCEHEADER__ +#include "../../../containers/juce_ReferenceCountedObject.h" class Image; -class RefCountedMouseCursor; +class SharedMouseCursorInternal; class ComponentPeer; class Component; @@ -88,7 +89,7 @@ public: @param hotSpotX the x position of the cursor's hotspot within the image @param hotSpotY the y position of the cursor's hotspot within the image */ - MouseCursor (Image& image, + MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY) throw(); @@ -146,13 +147,11 @@ public: juce_UseDebuggingNewOperator private: - RefCountedMouseCursor* cursorHandle; + ReferenceCountedObjectPtr cursorHandle; friend class Component; - void showInWindow (ComponentPeer* window) const throw(); void showInAllWindows() const throw(); - void* getHandle() const throw(); }; diff --git a/src/gui/graphics/imaging/juce_ImageCache.cpp b/src/gui/graphics/imaging/juce_ImageCache.cpp index 00d8c3845d..59647e9466 100644 --- a/src/gui/graphics/imaging/juce_ImageCache.cpp +++ b/src/gui/graphics/imaging/juce_ImageCache.cpp @@ -33,12 +33,12 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -struct CachedImageInfo +struct ImageCacheItem { - Image* image; + ScopedPointer image; int64 hashCode; int refCount; - unsigned int releaseTime; + uint32 releaseTime; juce_UseDebuggingNewOperator }; @@ -55,17 +55,6 @@ ImageCache::ImageCache() throw() ImageCache::~ImageCache() { - const ScopedLock sl (lock); - - for (int i = images.size(); --i >= 0;) - { - CachedImageInfo* const ci = (CachedImageInfo*) images.getUnchecked(i); - delete ci->image; - delete ci; - } - - images.clear(); - jassert (instance == this); instance = 0; } @@ -78,11 +67,11 @@ Image* ImageCache::getFromHashCode (const int64 hashCode) for (int i = instance->images.size(); --i >= 0;) { - CachedImageInfo* const ci = (CachedImageInfo*) instance->images.getUnchecked(i); + ImageCacheItem* const ci = instance->images.getUnchecked(i); if (ci->hashCode == hashCode) { - atomicIncrement (ci->refCount); + ci->refCount++; return ci->image; } } @@ -99,7 +88,7 @@ void ImageCache::addImageToCache (Image* const image, if (instance == 0) instance = new ImageCache(); - CachedImageInfo* const newC = new CachedImageInfo(); + ImageCacheItem* const newC = new ImageCacheItem(); newC->hashCode = hashCode; newC->image = image; newC->refCount = 1; @@ -118,9 +107,9 @@ void ImageCache::release (Image* const imageToRelease) for (int i = instance->images.size(); --i >= 0;) { - CachedImageInfo* const ci = (CachedImageInfo*) instance->images.getUnchecked(i); + ImageCacheItem* const ci = instance->images.getUnchecked(i); - if (ci->image == imageToRelease) + if ((Image*) ci->image == imageToRelease) { if (--(ci->refCount) == 0) ci->releaseTime = Time::getApproximateMillisecondCounter(); @@ -149,7 +138,7 @@ bool ImageCache::isImageInCache (Image* const imageToLookFor) const ScopedLock sl (instance->lock); for (int i = instance->images.size(); --i >= 0;) - if (((const CachedImageInfo*) instance->images.getUnchecked(i))->image == imageToLookFor) + if ((Image*) instance->images.getUnchecked(i)->image == imageToLookFor) return true; } @@ -164,9 +153,9 @@ void ImageCache::incReferenceCount (Image* const image) for (int i = instance->images.size(); --i >= 0;) { - CachedImageInfo* const ci = (CachedImageInfo*) instance->images.getUnchecked(i); + ImageCacheItem* const ci = (ImageCacheItem*) instance->images.getUnchecked(i); - if (ci->image == image) + if ((Image*) ci->image == image) { ci->refCount++; return; @@ -186,7 +175,7 @@ void ImageCache::timerCallback() for (int i = images.size(); --i >= 0;) { - CachedImageInfo* const ci = (CachedImageInfo*) images.getUnchecked(i); + ImageCacheItem* const ci = images.getUnchecked(i); if (ci->refCount <= 0) { @@ -194,8 +183,6 @@ void ImageCache::timerCallback() || now < ci->releaseTime - 1000) { images.remove (i); - delete ci->image; - delete ci; } else { @@ -210,8 +197,7 @@ void ImageCache::timerCallback() Image* ImageCache::getFromFile (const File& file) { - const int64 hashCode = file.getFullPathName().hashCode64(); - + const int64 hashCode = file.hashCode64(); Image* image = getFromHashCode (hashCode); if (image == 0) diff --git a/src/gui/graphics/imaging/juce_ImageCache.h b/src/gui/graphics/imaging/juce_ImageCache.h index 3a0e2a91bb..9a3a6aa925 100644 --- a/src/gui/graphics/imaging/juce_ImageCache.h +++ b/src/gui/graphics/imaging/juce_ImageCache.h @@ -31,6 +31,7 @@ #include "../../../events/juce_Timer.h" #include "../../../utilities/juce_DeletedAtShutdown.h" #include "../../../containers/juce_VoidArray.h" +struct ImageCacheItem; //============================================================================== @@ -162,7 +163,7 @@ public: private: //============================================================================== CriticalSection lock; - VoidArray images; + OwnedArray images; ImageCache() throw(); ImageCache (const ImageCache&); diff --git a/src/io/files/juce_ZipFile.cpp b/src/io/files/juce_ZipFile.cpp index dd31a80569..0e47d5bdbb 100644 --- a/src/io/files/juce_ZipFile.cpp +++ b/src/io/files/juce_ZipFile.cpp @@ -52,8 +52,7 @@ class ZipInputStream : public InputStream { public: //============================================================================== - ZipInputStream (ZipFile& file_, - ZipEntryInfo& zei) throw() + ZipInputStream (ZipFile& file_, ZipEntryInfo& zei) : file (file_), zipEntryInfo (zei), pos (0), @@ -161,19 +160,20 @@ private: //============================================================================== ZipFile::ZipFile (InputStream* const source_, - const bool deleteStreamWhenDestroyed_) throw() - : inputStream (source_), - deleteStreamWhenDestroyed (deleteStreamWhenDestroyed_) + const bool deleteStreamWhenDestroyed) throw() + : inputStream (source_) #ifdef JUCE_DEBUG , numOpenStreams (0) #endif { + if (deleteStreamWhenDestroyed) + streamToDelete = inputStream; + init(); } ZipFile::ZipFile (const File& file) - : inputStream (0), - deleteStreamWhenDestroyed (false) + : inputStream (0) #ifdef JUCE_DEBUG , numOpenStreams (0) #endif @@ -184,8 +184,7 @@ ZipFile::ZipFile (const File& file) ZipFile::ZipFile (InputSource* const inputSource_) : inputStream (0), - inputSource (inputSource_), - deleteStreamWhenDestroyed (false) + inputSource (inputSource_) #ifdef JUCE_DEBUG , numOpenStreams (0) #endif @@ -198,9 +197,6 @@ ZipFile::~ZipFile() throw() for (int i = entries.size(); --i >= 0;) delete (ZipEntryInfo*) entries.getUnchecked(i); - if (deleteStreamWhenDestroyed) - delete inputStream; - #ifdef JUCE_DEBUG // If you hit this assertion, it means you've created a stream to read // one of the items in the zipfile, but you've forgotten to delete that diff --git a/src/io/files/juce_ZipFile.h b/src/io/files/juce_ZipFile.h index 9924932e0c..b33ac37a59 100644 --- a/src/io/files/juce_ZipFile.h +++ b/src/io/files/juce_ZipFile.h @@ -150,9 +150,9 @@ private: friend class ZipInputStream; CriticalSection lock; InputStream* inputStream; + ScopedPointer streamToDelete; ScopedPointer inputSource; - bool deleteStreamWhenDestroyed; int numEntries, centralRecStart; #ifdef JUCE_DEBUG diff --git a/src/io/streams/juce_BufferedInputStream.cpp b/src/io/streams/juce_BufferedInputStream.cpp index 6563611731..3d78276385 100644 --- a/src/io/streams/juce_BufferedInputStream.cpp +++ b/src/io/streams/juce_BufferedInputStream.cpp @@ -34,9 +34,9 @@ BEGIN_JUCE_NAMESPACE //============================================================================== BufferedInputStream::BufferedInputStream (InputStream* const source_, const int bufferSize_, - const bool deleteSourceWhenDestroyed_) throw() + const bool deleteSourceWhenDestroyed) throw() : source (source_), - deleteSourceWhenDestroyed (deleteSourceWhenDestroyed_), + sourceToDelete (deleteSourceWhenDestroyed ? source_ : 0), bufferSize (jmax (256, bufferSize_)), position (source_->getPosition()), lastReadPos (0), @@ -52,8 +52,6 @@ BufferedInputStream::BufferedInputStream (InputStream* const source_, BufferedInputStream::~BufferedInputStream() throw() { - if (deleteSourceWhenDestroyed) - delete source; } //============================================================================== diff --git a/src/io/streams/juce_BufferedInputStream.h b/src/io/streams/juce_BufferedInputStream.h index 64dc8c22af..6a08cc5783 100644 --- a/src/io/streams/juce_BufferedInputStream.h +++ b/src/io/streams/juce_BufferedInputStream.h @@ -27,6 +27,7 @@ #define __JUCE_BUFFEREDINPUTSTREAM_JUCEHEADER__ #include "juce_InputStream.h" +#include "../../containers/juce_ScopedPointer.h" //============================================================================== @@ -74,7 +75,7 @@ public: private: InputStream* const source; - const bool deleteSourceWhenDestroyed; + ScopedPointer sourceToDelete; int bufferSize; int64 position, lastReadPos, bufferStart, bufferOverlap; HeapBlock buffer; diff --git a/src/io/streams/juce_GZIPCompressorOutputStream.cpp b/src/io/streams/juce_GZIPCompressorOutputStream.cpp index 0c1c19585d..fe593e6302 100644 --- a/src/io/streams/juce_GZIPCompressorOutputStream.cpp +++ b/src/io/streams/juce_GZIPCompressorOutputStream.cpp @@ -136,39 +136,31 @@ const int gzipCompBufferSize = 32768; GZIPCompressorOutputStream::GZIPCompressorOutputStream (OutputStream* const destStream_, int compressionLevel, - const bool deleteDestStream_, + const bool deleteDestStream, const bool noWrap) : destStream (destStream_), - deleteDestStream (deleteDestStream_), + streamToDelete (deleteDestStream ? destStream_ : 0), buffer (gzipCompBufferSize) { if (compressionLevel < 1 || compressionLevel > 9) compressionLevel = -1; helper = new GZIPCompressorHelper (compressionLevel, noWrap); - } GZIPCompressorOutputStream::~GZIPCompressorOutputStream() { flush(); - - delete (GZIPCompressorHelper*) helper; - - if (deleteDestStream) - delete destStream; } //============================================================================== void GZIPCompressorOutputStream::flush() { - GZIPCompressorHelper* const h = (GZIPCompressorHelper*) helper; - - if (! h->finished) + if (! helper->finished) { - h->shouldFinish = true; + helper->shouldFinish = true; - while (! h->finished) + while (! helper->finished) doNextBlock(); } @@ -177,13 +169,11 @@ void GZIPCompressorOutputStream::flush() bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany) { - GZIPCompressorHelper* const h = (GZIPCompressorHelper*) helper; - - if (! h->finished) + if (! helper->finished) { - h->setInput ((uint8*) destBuffer, howMany); + helper->setInput ((uint8*) destBuffer, howMany); - while (! h->needsInput()) + while (! helper->needsInput()) { if (! doNextBlock()) return false; @@ -195,8 +185,7 @@ bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany) bool GZIPCompressorOutputStream::doNextBlock() { - GZIPCompressorHelper* const h = (GZIPCompressorHelper*) helper; - const int len = h->doNextBlock (buffer, gzipCompBufferSize); + const int len = helper->doNextBlock (buffer, gzipCompBufferSize); if (len > 0) return destStream->write (buffer, len); diff --git a/src/io/streams/juce_GZIPCompressorOutputStream.h b/src/io/streams/juce_GZIPCompressorOutputStream.h index dad214ba61..278907eac7 100644 --- a/src/io/streams/juce_GZIPCompressorOutputStream.h +++ b/src/io/streams/juce_GZIPCompressorOutputStream.h @@ -27,6 +27,8 @@ #define __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__ #include "juce_OutputStream.h" +#include "../../containers/juce_ScopedPointer.h" +class GZIPCompressorHelper; //============================================================================== @@ -72,9 +74,9 @@ public: private: OutputStream* const destStream; - const bool deleteDestStream; + ScopedPointer streamToDelete; HeapBlock buffer; - void* helper; + ScopedPointer helper; bool doNextBlock(); GZIPCompressorOutputStream (const GZIPCompressorOutputStream&); diff --git a/src/io/streams/juce_GZIPDecompressorInputStream.cpp b/src/io/streams/juce_GZIPDecompressorInputStream.cpp index f1b30cb5c3..9d2ccadc22 100644 --- a/src/io/streams/juce_GZIPDecompressorInputStream.cpp +++ b/src/io/streams/juce_GZIPDecompressorInputStream.cpp @@ -163,28 +163,24 @@ public: const int gzipDecompBufferSize = 32768; GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream* const sourceStream_, - const bool deleteSourceWhenDestroyed_, + const bool deleteSourceWhenDestroyed, const bool noWrap_, const int64 uncompressedStreamLength_) : sourceStream (sourceStream_), + streamToDelete (deleteSourceWhenDestroyed ? sourceStream_ : 0), uncompressedStreamLength (uncompressedStreamLength_), - deleteSourceWhenDestroyed (deleteSourceWhenDestroyed_), noWrap (noWrap_), isEof (false), activeBufferSize (0), originalSourcePos (sourceStream_->getPosition()), currentPos (0), - buffer (gzipDecompBufferSize) + buffer (gzipDecompBufferSize), + helper (new GZIPDecompressHelper (noWrap_)) { - helper = new GZIPDecompressHelper (noWrap_); } GZIPDecompressorInputStream::~GZIPDecompressorInputStream() { - if (deleteSourceWhenDestroyed) - delete sourceStream; - - delete (GZIPDecompressHelper*) helper; } int64 GZIPDecompressorInputStream::getTotalLength() @@ -194,8 +190,6 @@ int64 GZIPDecompressorInputStream::getTotalLength() int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) { - GZIPDecompressHelper* const h = (GZIPDecompressHelper*) helper; - if ((howMany > 0) && ! isEof) { jassert (destBuffer != 0); @@ -205,26 +199,26 @@ int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) int numRead = 0; uint8* d = (uint8*) destBuffer; - while (! h->error) + while (! helper->error) { - const int n = h->doNextBlock (d, howMany); + const int n = helper->doNextBlock (d, howMany); currentPos += n; if (n == 0) { - if (h->finished || h->needsDictionary) + if (helper->finished || helper->needsDictionary) { isEof = true; return numRead; } - if (h->needsInput()) + if (helper->needsInput()) { activeBufferSize = sourceStream->read (buffer, gzipDecompBufferSize); if (activeBufferSize > 0) { - h->setInput ((uint8*) buffer, activeBufferSize); + helper->setInput ((uint8*) buffer, activeBufferSize); } else { @@ -251,9 +245,7 @@ int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) bool GZIPDecompressorInputStream::isExhausted() { - const GZIPDecompressHelper* const h = (GZIPDecompressHelper*) helper; - - return h->error || isEof; + return helper->error || isEof; } int64 GZIPDecompressorInputStream::getPosition() @@ -272,8 +264,6 @@ bool GZIPDecompressorInputStream::setPosition (int64 newPos) else { // reset the stream and start again.. - delete (GZIPDecompressHelper*) helper; - isEof = false; activeBufferSize = 0; currentPos = 0; diff --git a/src/io/streams/juce_GZIPDecompressorInputStream.h b/src/io/streams/juce_GZIPDecompressorInputStream.h index 9d16637cdd..61658c5a9d 100644 --- a/src/io/streams/juce_GZIPDecompressorInputStream.h +++ b/src/io/streams/juce_GZIPDecompressorInputStream.h @@ -27,6 +27,8 @@ #define __JUCE_GZIPDECOMPRESSORINPUTSTREAM_JUCEHEADER__ #include "juce_InputStream.h" +#include "../../containers/juce_ScopedPointer.h" +class GZIPDecompressHelper; //============================================================================== @@ -75,13 +77,14 @@ public: private: InputStream* const sourceStream; + ScopedPointer streamToDelete; const int64 uncompressedStreamLength; - const bool deleteSourceWhenDestroyed, noWrap; + const bool noWrap; bool isEof; int activeBufferSize; int64 originalSourcePos, currentPos; HeapBlock buffer; - void* helper; + ScopedPointer helper; GZIPDecompressorInputStream (const GZIPDecompressorInputStream&); const GZIPDecompressorInputStream& operator= (const GZIPDecompressorInputStream&); diff --git a/src/io/streams/juce_MemoryOutputStream.cpp b/src/io/streams/juce_MemoryOutputStream.cpp index 60920d305c..8105006b54 100644 --- a/src/io/streams/juce_MemoryOutputStream.cpp +++ b/src/io/streams/juce_MemoryOutputStream.cpp @@ -38,26 +38,22 @@ MemoryOutputStream::MemoryOutputStream (const int initialSize, : data (memoryBlockToWriteTo), position (0), size (0), - blockSize (jmax (16, blockSizeToIncreaseBy)), - ownsMemoryBlock (memoryBlockToWriteTo == 0) + blockSize (jmax (16, blockSizeToIncreaseBy)) { - if (memoryBlockToWriteTo == 0) - data = new MemoryBlock (initialSize); + if (data == 0) + dataToDelete = data = new MemoryBlock (initialSize); else - memoryBlockToWriteTo->setSize (initialSize, false); + data->setSize (initialSize, false); } MemoryOutputStream::~MemoryOutputStream() throw() { - if (ownsMemoryBlock) - delete data; - else - flush(); + flush(); } void MemoryOutputStream::flush() { - if (! ownsMemoryBlock) + if (dataToDelete == 0) data->setSize (size, false); } diff --git a/src/io/streams/juce_MemoryOutputStream.h b/src/io/streams/juce_MemoryOutputStream.h index 2f94f747a7..b7c57cd4a9 100644 --- a/src/io/streams/juce_MemoryOutputStream.h +++ b/src/io/streams/juce_MemoryOutputStream.h @@ -28,6 +28,7 @@ #include "juce_OutputStream.h" #include "../../containers/juce_MemoryBlock.h" +#include "../../containers/juce_ScopedPointer.h" //============================================================================== @@ -87,8 +88,8 @@ public: private: MemoryBlock* data; + ScopedPointer dataToDelete; int position, size, blockSize; - bool ownsMemoryBlock; }; #endif // __JUCE_MEMORYOUTPUTSTREAM_JUCEHEADER__ diff --git a/src/io/streams/juce_SubregionStream.cpp b/src/io/streams/juce_SubregionStream.cpp index 8900c8491e..2158a6256d 100644 --- a/src/io/streams/juce_SubregionStream.cpp +++ b/src/io/streams/juce_SubregionStream.cpp @@ -35,19 +35,19 @@ BEGIN_JUCE_NAMESPACE SubregionStream::SubregionStream (InputStream* const sourceStream, const int64 startPositionInSourceStream_, const int64 lengthOfSourceStream_, - const bool deleteSourceWhenDestroyed_) throw() + const bool deleteSourceWhenDestroyed) throw() : source (sourceStream), - deleteSourceWhenDestroyed (deleteSourceWhenDestroyed_), startPositionInSourceStream (startPositionInSourceStream_), lengthOfSourceStream (lengthOfSourceStream_) { + if (deleteSourceWhenDestroyed) + sourceToDelete = source; + setPosition (0); } SubregionStream::~SubregionStream() throw() { - if (deleteSourceWhenDestroyed) - delete source; } int64 SubregionStream::getTotalLength() diff --git a/src/io/streams/juce_SubregionStream.h b/src/io/streams/juce_SubregionStream.h index cc3e6a7a95..680ad65d36 100644 --- a/src/io/streams/juce_SubregionStream.h +++ b/src/io/streams/juce_SubregionStream.h @@ -27,6 +27,7 @@ #define __JUCE_SUBREGIONSTREAM_JUCEHEADER__ #include "juce_InputStream.h" +#include "../../containers/juce_ScopedPointer.h" //============================================================================== @@ -82,7 +83,7 @@ public: private: InputStream* const source; - const bool deleteSourceWhenDestroyed; + ScopedPointer sourceToDelete; const int64 startPositionInSourceStream, lengthOfSourceStream; SubregionStream (const SubregionStream&); diff --git a/src/native/mac/juce_iphone_Audio.cpp b/src/native/mac/juce_iphone_Audio.cpp index cee26c2256..c8c010fd82 100644 --- a/src/native/mac/juce_iphone_Audio.cpp +++ b/src/native/mac/juce_iphone_Audio.cpp @@ -271,7 +271,7 @@ private: //================================================================================================== OSStatus process (AudioUnitRenderActionFlags* ioActionFlags, const AudioTimeStamp* inTimeStamp, - UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList* ioData) throw() + UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList* ioData) { OSStatus err = noErr; @@ -349,7 +349,7 @@ private: return err; } - void updateDeviceInfo() throw() + void updateDeviceInfo() { UInt32 size = sizeof (sampleRate); AudioSessionGetProperty (kAudioSessionProperty_CurrentHardwareSampleRate, &size, &sampleRate); @@ -496,7 +496,7 @@ private: // If the routing is set to go through the receiver (i.e. the speaker, but quiet), this re-routes it // to make it loud. Needed because by default when using an input + output, the output is kept quiet. - static void fixAudioRouteIfSetToReceiver() throw() + static void fixAudioRouteIfSetToReceiver() { CFStringRef audioRoute = 0; UInt32 propertySize = sizeof (audioRoute); diff --git a/src/native/mac/juce_iphone_UIViewComponentPeer.mm b/src/native/mac/juce_iphone_UIViewComponentPeer.mm index d7aa7d3749..e815fad256 100644 --- a/src/native/mac/juce_iphone_UIViewComponentPeer.mm +++ b/src/native/mac/juce_iphone_UIViewComponentPeer.mm @@ -179,14 +179,14 @@ void ModifierKeys::updateCurrentModifiers() throw() currentModifierFlags = currentModifiers; } -static int getModifierForButtonNumber (const int num) throw() +static int getModifierForButtonNumber (const int num) { return num == 0 ? ModifierKeys::leftButtonModifier : (num == 1 ? ModifierKeys::rightButtonModifier : (num == 2 ? ModifierKeys::middleButtonModifier : 0)); } -static int64 getMouseTime (UIEvent* e) throw() +static int64 getMouseTime (UIEvent* e) { return (Time::currentTimeMillis() - Time::getMillisecondCounter()) + (int64) ([e timestamp] * 1000.0); diff --git a/src/native/mac/juce_mac_AppleRemote.mm b/src/native/mac/juce_mac_AppleRemote.mm index 7cdf587efc..f8eeae4285 100644 --- a/src/native/mac/juce_mac_AppleRemote.mm +++ b/src/native/mac/juce_mac_AppleRemote.mm @@ -40,7 +40,7 @@ AppleRemoteDevice::~AppleRemoteDevice() stop(); } -static io_object_t getAppleRemoteDevice() throw() +static io_object_t getAppleRemoteDevice() { CFMutableDictionaryRef dict = IOServiceMatching ("AppleIRController"); @@ -57,7 +57,7 @@ static io_object_t getAppleRemoteDevice() throw() return iod; } -static bool createAppleRemoteInterface (io_object_t iod, void** device) throw() +static bool createAppleRemoteInterface (io_object_t iod, void** device) { jassert (*device == 0); io_name_t classname; @@ -86,7 +86,7 @@ static bool createAppleRemoteInterface (io_object_t iod, void** device) throw() return *device != 0; } -bool AppleRemoteDevice::start (const bool inExclusiveMode) throw() +bool AppleRemoteDevice::start (const bool inExclusiveMode) { if (queue != 0) return true; @@ -109,7 +109,7 @@ bool AppleRemoteDevice::start (const bool inExclusiveMode) throw() return result; } -void AppleRemoteDevice::stop() throw() +void AppleRemoteDevice::stop() { if (queue != 0) { @@ -127,7 +127,7 @@ void AppleRemoteDevice::stop() throw() } } -bool AppleRemoteDevice::isActive() const throw() +bool AppleRemoteDevice::isActive() const { return queue != 0; } @@ -138,7 +138,7 @@ static void appleRemoteQueueCallback (void* const target, const IOReturn result, ((AppleRemoteDevice*) target)->handleCallbackInternal(); } -bool AppleRemoteDevice::open (const bool openInExclusiveMode) throw() +bool AppleRemoteDevice::open (const bool openInExclusiveMode) { Array cookies; diff --git a/src/native/mac/juce_mac_CarbonViewWrapperComponent.h b/src/native/mac/juce_mac_CarbonViewWrapperComponent.h index dcabbc24c2..7299b667c2 100644 --- a/src/native/mac/juce_mac_CarbonViewWrapperComponent.h +++ b/src/native/mac/juce_mac_CarbonViewWrapperComponent.h @@ -202,7 +202,7 @@ public: setEmbeddedWindowToOurSize(); } - static void recursiveHIViewRepaint (HIViewRef view) throw() + static void recursiveHIViewRepaint (HIViewRef view) { HIViewSetNeedsDisplay (view, true); HIViewRef child = HIViewGetFirstSubview (view); diff --git a/src/native/mac/juce_mac_CoreGraphicsContext.mm b/src/native/mac/juce_mac_CoreGraphicsContext.mm index 9f6845caea..b305f44413 100644 --- a/src/native/mac/juce_mac_CoreGraphicsContext.mm +++ b/src/native/mac/juce_mac_CoreGraphicsContext.mm @@ -55,7 +55,7 @@ public: LowLevelGraphicsContext* createLowLevelContext(); //============================================================================== - static CGImageRef createImage (const Image& juceImage, const bool forAlpha, CGColorSpaceRef colourSpace) throw() + static CGImageRef createImage (const Image& juceImage, const bool forAlpha, CGColorSpaceRef colourSpace) { const CoreGraphicsImage* nativeImage = dynamic_cast (&juceImage); @@ -106,7 +106,7 @@ public: CGContextRef context; private: - static CGBitmapInfo getCGImageFlags (const Image& image) throw() + static CGBitmapInfo getCGImageFlags (const Image& image) { #if JUCE_BIG_ENDIAN return image.getFormat() == Image::ARGB ? (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Big) : kCGBitmapByteOrderDefault; @@ -536,18 +536,18 @@ private: struct SavedState { - SavedState() throw() + SavedState() : font (1.0f), fontRef (0), fontTransform (CGAffineTransformIdentity) { } - SavedState (const SavedState& other) throw() + SavedState (const SavedState& other) : fillType (other.fillType), font (other.font), fontRef (other.fontRef), fontTransform (other.fontTransform) { } - ~SavedState() throw() + ~SavedState() { } @@ -576,7 +576,7 @@ private: outData[3] = colour.getAlpha() / 255.0f; } - CGShadingRef createGradient (const AffineTransform& transform, ColourGradient gradient) throw() + CGShadingRef createGradient (const AffineTransform& transform, ColourGradient gradient) { numGradientLookupEntries = gradient.createLookupTable (transform, gradientLookupTable); --numGradientLookupEntries; @@ -602,7 +602,7 @@ private: return result; } - void drawGradient() throw() + void drawGradient() { flip(); applyTransform (state->fillType.transform); @@ -615,7 +615,7 @@ private: CGShadingRelease (shading); } - void createPath (const Path& path) const throw() + void createPath (const Path& path) const { CGContextBeginPath (context); Path::Iterator i (path); @@ -645,7 +645,7 @@ private: } } - void createPath (const Path& path, const AffineTransform& transform) const throw() + void createPath (const Path& path, const AffineTransform& transform) const { CGContextBeginPath (context); Path::Iterator i (path); @@ -682,7 +682,7 @@ private: } } - static Image* createAlphaChannelImage (const Image& im) throw() + static Image* createAlphaChannelImage (const Image& im) { if (im.getFormat() == Image::SingleChannel) return const_cast (&im); @@ -690,18 +690,18 @@ private: return im.createCopyOfAlphaChannel(); } - static void deleteAlphaChannelImage (const Image& im, Image* const alphaIm) throw() + static void deleteAlphaChannelImage (const Image& im, Image* const alphaIm) { if (im.getFormat() != Image::SingleChannel) delete alphaIm; } - void flip() const throw() + void flip() const { CGContextConcatCTM (context, CGAffineTransformMake (1, 0, 0, -1, 0, flipHeight)); } - void applyTransform (const AffineTransform& transform) const throw() + void applyTransform (const AffineTransform& transform) const { CGAffineTransform t; t.a = transform.mat00; @@ -713,7 +713,7 @@ private: CGContextConcatCTM (context, t); } - float flipY (float y) const throw() + float flipY (float y) const { return flipHeight - y; } diff --git a/src/native/mac/juce_mac_CoreMidi.cpp b/src/native/mac/juce_mac_CoreMidi.cpp index 268328e25e..bb744b5ef6 100644 --- a/src/native/mac/juce_mac_CoreMidi.cpp +++ b/src/native/mac/juce_mac_CoreMidi.cpp @@ -236,12 +236,12 @@ static bool makeSureClientExists() class MidiPortAndEndpoint { public: - MidiPortAndEndpoint (MIDIPortRef port_, MIDIEndpointRef endPoint_) throw() + MidiPortAndEndpoint (MIDIPortRef port_, MIDIEndpointRef endPoint_) : port (port_), endPoint (endPoint_) { } - ~MidiPortAndEndpoint() throw() + ~MidiPortAndEndpoint() { if (port != 0) MIDIPortDispose (port); diff --git a/src/native/mac/juce_mac_Files.mm b/src/native/mac/juce_mac_Files.mm index 2ec7b7bf5c..64c93c6ac0 100644 --- a/src/native/mac/juce_mac_Files.mm +++ b/src/native/mac/juce_mac_Files.mm @@ -107,7 +107,7 @@ const StringArray juce_getFileSystemRoots() throw() } //============================================================================== -static bool isFileOnDriveType (const File* const f, const char** types) throw() +static bool isFileOnDriveType (const File* const f, const char** types) { struct statfs buf; @@ -157,7 +157,7 @@ bool File::isOnRemovableDrive() const throw() #endif } -static bool juce_isHiddenFile (const String& path) throw() +static bool juce_isHiddenFile (const String& path) { #if JUCE_IPHONE return File (path).getFileName().startsWithChar (T('.')); diff --git a/src/native/mac/juce_mac_Fonts.mm b/src/native/mac/juce_mac_Fonts.mm index 09f2594853..4ef1befd3c 100644 --- a/src/native/mac/juce_mac_Fonts.mm +++ b/src/native/mac/juce_mac_Fonts.mm @@ -349,7 +349,7 @@ private: AffineTransform pathTransform; #endif - void createGlyphsForString (const juce_wchar* const text, const int length, HeapBlock & glyphs) throw() + void createGlyphsForString (const juce_wchar* const text, const int length, HeapBlock & glyphs) { #if SUPPORT_10_4_FONTS #if ! SUPPORT_ONLY_10_4_FONTS @@ -382,7 +382,7 @@ private: class CharToGlyphMapper { public: - CharToGlyphMapper (CGFontRef fontRef) throw() + CharToGlyphMapper (CGFontRef fontRef) : segCount (0), endCode (0), startCode (0), idDelta (0), idRangeOffset (0), glyphIndexes (0) { @@ -424,7 +424,7 @@ private: } } - ~CharToGlyphMapper() throw() + ~CharToGlyphMapper() { if (endCode != 0) { @@ -436,7 +436,7 @@ private: } } - int getGlyphForCharacter (const juce_wchar c) const throw() + int getGlyphForCharacter (const juce_wchar c) const { for (int i = 0; i < segCount; ++i) { @@ -464,12 +464,12 @@ private: int segCount; CFDataRef endCode, startCode, idDelta, idRangeOffset, glyphIndexes; - static uint16 getValue16 (CFDataRef data, const int index) throw() + static uint16 getValue16 (CFDataRef data, const int index) { return CFSwapInt16BigToHost (*(UInt16*) (CFDataGetBytePtr (data) + index)); } - static uint32 getValue32 (CFDataRef data, const int index) throw() + static uint32 getValue32 (CFDataRef data, const int index) { return CFSwapInt32BigToHost (*(UInt32*) (CFDataGetBytePtr (data) + index)); } diff --git a/src/native/mac/juce_mac_MainMenu.mm b/src/native/mac/juce_mac_MainMenu.mm index c339a5a1ba..b060bf66ff 100644 --- a/src/native/mac/juce_mac_MainMenu.mm +++ b/src/native/mac/juce_mac_MainMenu.mm @@ -60,14 +60,14 @@ public: static JuceMainMenuHandler* instance; //============================================================================== - JuceMainMenuHandler() throw() + JuceMainMenuHandler() : currentModel (0), lastUpdateTime (0) { callback = [[JuceMenuCallback alloc] initWithOwner: this]; } - ~JuceMainMenuHandler() throw() + ~JuceMainMenuHandler() { setMenu (0); @@ -77,7 +77,7 @@ public: [callback release]; } - void setMenu (MenuBarModel* const newMenuBarModel) throw() + void setMenu (MenuBarModel* const newMenuBarModel) { if (currentModel != newMenuBarModel) { @@ -489,7 +489,7 @@ static void rebuildMainMenu (const PopupMenu* extraItems) } void MenuBarModel::setMacMainMenu (MenuBarModel* newMenuBarModel, - const PopupMenu* extraAppleMenuItems) throw() + const PopupMenu* extraAppleMenuItems) { if (getMacMainMenu() != newMenuBarModel) { @@ -518,7 +518,7 @@ void MenuBarModel::setMacMainMenu (MenuBarModel* newMenuBarModel, newMenuBarModel->menuItemsChanged(); } -MenuBarModel* MenuBarModel::getMacMainMenu() throw() +MenuBarModel* MenuBarModel::getMacMainMenu() { return JuceMainMenuHandler::instance != 0 ? JuceMainMenuHandler::instance->currentModel : 0; diff --git a/src/native/mac/juce_mac_MessageManager.mm b/src/native/mac/juce_mac_MessageManager.mm index 9792a61e37..acad5a411e 100644 --- a/src/native/mac/juce_mac_MessageManager.mm +++ b/src/native/mac/juce_mac_MessageManager.mm @@ -129,7 +129,7 @@ public: delete this; } - void postMessage (void* m) throw() + void postMessage (void* m) { messages.add (m); CFRunLoopSourceSignal (runLoopSource); @@ -141,7 +141,7 @@ private: CFRunLoopSourceRef runLoopSource; Array messages; - void runLoopCallback() throw() + void runLoopCallback() { int numDispatched = 0; diff --git a/src/native/mac/juce_mac_MiscUtilities.mm b/src/native/mac/juce_mac_MiscUtilities.mm index d1797512f3..82296bcb4d 100644 --- a/src/native/mac/juce_mac_MiscUtilities.mm +++ b/src/native/mac/juce_mac_MiscUtilities.mm @@ -59,7 +59,7 @@ void PlatformUtilities::addItemToDock (const File& file) } } -int PlatformUtilities::getOSXMinorVersionNumber() throw() +int PlatformUtilities::getOSXMinorVersionNumber() { SInt32 versionMinor = 0; OSErr err = Gestalt (gestaltSystemVersionMinor, &versionMinor); diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 976d0f9bde..05815e5afe 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -637,7 +637,7 @@ void ModifierKeys::updateCurrentModifiers() throw() currentModifierFlags = currentModifiers; } -static int64 getMouseTime (NSEvent* e) throw() +static int64 getMouseTime (NSEvent* e) { return (Time::currentTimeMillis() - Time::getMillisecondCounter()) + (int64) ([e timestamp] * 1000.0); @@ -650,7 +650,7 @@ static void getMousePos (NSEvent* e, NSView* view, int& x, int& y) y = roundFloatToInt ([view frame].size.height - p.y); } -static int getModifierForButtonNumber (const int num) throw() +static int getModifierForButtonNumber (const int num) { return num == 0 ? ModifierKeys::leftButtonModifier : (num == 1 ? ModifierKeys::rightButtonModifier diff --git a/src/native/mac/juce_mac_SystemStats.mm b/src/native/mac/juce_mac_SystemStats.mm index 4eed48a1e5..69791278b3 100644 --- a/src/native/mac/juce_mac_SystemStats.mm +++ b/src/native/mac/juce_mac_SystemStats.mm @@ -46,7 +46,7 @@ static void juce_getCpuVendor (char* const v) throw() memcpy (v, vendor, 16); } -static unsigned int getCPUIDWord (unsigned int& familyModel, unsigned int& extFeatures) throw() +static unsigned int getCPUIDWord (unsigned int& familyModel, unsigned int& extFeatures) { unsigned int cpu = 0; unsigned int ext = 0; diff --git a/src/native/mac/juce_mac_Threads.mm b/src/native/mac/juce_mac_Threads.mm index a57fdcb73c..145609a9af 100644 --- a/src/native/mac/juce_mac_Threads.mm +++ b/src/native/mac/juce_mac_Threads.mm @@ -36,7 +36,7 @@ //============================================================================== void JUCE_API juce_threadEntryPoint (void*); -void* threadEntryProc (void* userData) throw() +void* threadEntryProc (void* userData) { const ScopedAutoReleasePool pool; juce_threadEntryPoint (userData); diff --git a/src/native/windows/juce_win32_PlatformUtils.cpp b/src/native/windows/juce_win32_PlatformUtils.cpp index 104b2c53fd..fa0021f9b5 100644 --- a/src/native/windows/juce_win32_PlatformUtils.cpp +++ b/src/native/windows/juce_win32_PlatformUtils.cpp @@ -31,7 +31,7 @@ //============================================================================== static HKEY findKeyForPath (String name, const bool createForWriting, - String& valueName) throw() + String& valueName) { HKEY rootKey = 0; @@ -175,7 +175,7 @@ void PlatformUtilities::registerFileAssociation (const String& fileExtension, //============================================================================== -bool juce_IsRunningInWine() throw() +bool juce_IsRunningInWine() { HKEY key; if (RegOpenKeyEx (HKEY_CURRENT_USER, _T("Software\\Wine"), 0, KEY_READ, &key) == ERROR_SUCCESS) diff --git a/src/text/juce_LocalisedStrings.cpp b/src/text/juce_LocalisedStrings.cpp index 4145ff8639..827df334fd 100644 --- a/src/text/juce_LocalisedStrings.cpp +++ b/src/text/juce_LocalisedStrings.cpp @@ -32,27 +32,27 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -LocalisedStrings::LocalisedStrings (const String& fileContents) throw() +LocalisedStrings::LocalisedStrings (const String& fileContents) { loadFromText (fileContents); } -LocalisedStrings::LocalisedStrings (const File& fileToLoad) throw() +LocalisedStrings::LocalisedStrings (const File& fileToLoad) { loadFromText (fileToLoad.loadFileAsString()); } -LocalisedStrings::~LocalisedStrings() throw() +LocalisedStrings::~LocalisedStrings() { } //============================================================================== -const String LocalisedStrings::translate (const String& text) const throw() +const String LocalisedStrings::translate (const String& text) const { return translations.getValue (text, text); } -static int findCloseQuote (const String& text, int startPos) throw() +static int findCloseQuote (const String& text, int startPos) { tchar lastChar = 0; @@ -70,7 +70,7 @@ static int findCloseQuote (const String& text, int startPos) throw() return startPos; } -static const String unescapeString (const String& s) throw() +static const String unescapeString (const String& s) { return s.replace (T("\\\""), T("\"")) .replace (T("\\\'"), T("\'")) @@ -79,7 +79,7 @@ static const String unescapeString (const String& s) throw() .replace (T("\\n"), T("\n")); } -void LocalisedStrings::loadFromText (const String& fileContents) throw() +void LocalisedStrings::loadFromText (const String& fileContents) { StringArray lines; lines.addLines (fileContents); @@ -118,7 +118,7 @@ void LocalisedStrings::loadFromText (const String& fileContents) throw() } } -void LocalisedStrings::setIgnoresCase (const bool shouldIgnoreCase) throw() +void LocalisedStrings::setIgnoresCase (const bool shouldIgnoreCase) { translations.setIgnoresCase (shouldIgnoreCase); } @@ -127,7 +127,7 @@ void LocalisedStrings::setIgnoresCase (const bool shouldIgnoreCase) throw() static CriticalSection currentMappingsLock; static LocalisedStrings* currentMappings = 0; -void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations) throw() +void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations) { const ScopedLock sl (currentMappingsLock); @@ -135,12 +135,12 @@ void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations) th currentMappings = newTranslations; } -LocalisedStrings* LocalisedStrings::getCurrentMappings() throw() +LocalisedStrings* LocalisedStrings::getCurrentMappings() { return currentMappings; } -const String LocalisedStrings::translateWithCurrentMappings (const String& text) throw() +const String LocalisedStrings::translateWithCurrentMappings (const String& text) { const ScopedLock sl (currentMappingsLock); @@ -150,7 +150,7 @@ const String LocalisedStrings::translateWithCurrentMappings (const String& text) return text; } -const String LocalisedStrings::translateWithCurrentMappings (const char* text) throw() +const String LocalisedStrings::translateWithCurrentMappings (const char* text) { return translateWithCurrentMappings (String (text)); } diff --git a/src/text/juce_LocalisedStrings.h b/src/text/juce_LocalisedStrings.h index 1cdcabb905..ae7555cada 100644 --- a/src/text/juce_LocalisedStrings.h +++ b/src/text/juce_LocalisedStrings.h @@ -94,17 +94,17 @@ public: When you create one of these, you can call setCurrentMappings() to make it the set of mappings that the system's using. */ - LocalisedStrings (const String& fileContents) throw(); + LocalisedStrings (const String& fileContents); /** Creates a set of translations from a file. When you create one of these, you can call setCurrentMappings() to make it the set of mappings that the system's using. */ - LocalisedStrings (const File& fileToLoad) throw(); + LocalisedStrings (const File& fileToLoad); /** Destructor. */ - ~LocalisedStrings() throw(); + ~LocalisedStrings(); //============================================================================== /** Selects the current set of mappings to be used by the system. @@ -117,14 +117,14 @@ public: @see translateWithCurrentMappings */ - static void setCurrentMappings (LocalisedStrings* newTranslations) throw(); + static void setCurrentMappings (LocalisedStrings* newTranslations); /** Returns the currently selected set of mappings. This is the object that was last passed to setCurrentMappings(). It may be 0 if none has been created. */ - static LocalisedStrings* getCurrentMappings() throw(); + static LocalisedStrings* getCurrentMappings(); /** Tries to translate a string using the currently selected set of mappings. @@ -135,7 +135,7 @@ public: @see setCurrentMappings, getCurrentMappings */ - static const String translateWithCurrentMappings (const String& text) throw(); + static const String translateWithCurrentMappings (const String& text); /** Tries to translate a string using the currently selected set of mappings. @@ -146,14 +146,14 @@ public: @see setCurrentMappings, getCurrentMappings */ - static const String translateWithCurrentMappings (const char* text) throw(); + static const String translateWithCurrentMappings (const char* text); //============================================================================== /** Attempts to look up a string and return its localised version. If the string isn't found in the list, the original string will be returned. */ - const String translate (const String& text) const throw(); + const String translate (const String& text) const; /** Returns the name of the language specified in the translation file. @@ -162,7 +162,7 @@ public: language: german @endcode */ - const String getLanguageName() const throw() { return languageName; } + const String getLanguageName() const { return languageName; } /** Returns the list of suitable country codes listed in the translation file. @@ -173,14 +173,14 @@ public: The country codes are supposed to be 2-character ISO complient codes. */ - const StringArray getCountryCodes() const throw() { return countryCodes; } + const StringArray getCountryCodes() const { return countryCodes; } //============================================================================== /** Indicates whether to use a case-insensitive search when looking up a string. This defaults to true. */ - void setIgnoresCase (const bool shouldIgnoreCase) throw(); + void setIgnoresCase (const bool shouldIgnoreCase); //============================================================================== juce_UseDebuggingNewOperator @@ -190,7 +190,7 @@ private: StringArray countryCodes; StringPairArray translations; - void loadFromText (const String& fileContents) throw(); + void loadFromText (const String& fileContents); }; diff --git a/src/utilities/juce_DeletedAtShutdown.cpp b/src/utilities/juce_DeletedAtShutdown.cpp index d48162ae97..370640be48 100644 --- a/src/utilities/juce_DeletedAtShutdown.cpp +++ b/src/utilities/juce_DeletedAtShutdown.cpp @@ -62,15 +62,16 @@ void DeletedAtShutdown::deleteAll() { JUCE_TRY { - DeletedAtShutdown* const deletee = (DeletedAtShutdown*) localCopy.getUnchecked(i); + DeletedAtShutdown* deletee = (DeletedAtShutdown*) localCopy.getUnchecked(i); // double-check that it's not already been deleted during another object's destructor. - lock.enter(); - const bool okToDelete = objectsToDelete.contains (deletee); - lock.exit(); + { + const ScopedLock sl (lock); + if (! objectsToDelete.contains (deletee)) + deletee = 0; + } - if (okToDelete) - delete deletee; + delete deletee; } JUCE_CATCH_EXCEPTION }