diff --git a/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp b/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp index 51b5d5d651..06c4726564 100644 --- a/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp +++ b/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp @@ -111,7 +111,7 @@ void AppearanceSettings::refreshPresetSchemeList() if (newSchemes != presetSchemeFiles) { - presetSchemeFiles.swapWithArray (newSchemes); + presetSchemeFiles.swapWith (newSchemes); commandManager->commandStatusChanged(); } } diff --git a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp index e9af705966..e319a00fa6 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp @@ -43,7 +43,7 @@ MidiMessageSequence& MidiMessageSequence::operator= (const MidiMessageSequence& void MidiMessageSequence::swapWith (MidiMessageSequence& other) noexcept { - list.swapWithArray (other.list); + list.swapWith (other.list); } MidiMessageSequence::~MidiMessageSequence() diff --git a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp index 80d0d352bf..1de35f9383 100644 --- a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp +++ b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp @@ -387,7 +387,7 @@ public: if (sampleRates != newRates) { - sampleRates.swapWithArray (newRates); + sampleRates.swapWith (newRates); #if JUCE_ASIO_DEBUGGING StringArray s; diff --git a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp index 2463257c4e..1c2f9bad6c 100644 --- a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp @@ -162,7 +162,7 @@ bool BufferingAudioReader::readNextBufferChunk() { const ScopedLock sl (lock); - newBlocks.swapWithArray (blocks); + newBlocks.swapWith (blocks); } for (int i = blocks.size(); --i >= 0;) diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index a36386d194..e965b22254 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -1180,7 +1180,7 @@ void AudioProcessorGraph::clearRenderingSequence() { const ScopedLock sl (getCallbackLock()); - renderingOps.swapWithArray (oldOps); + renderingOps.swapWith (oldOps); } deleteRenderOpArray (oldOps); @@ -1254,7 +1254,7 @@ void AudioProcessorGraph::buildRenderingSequence() while (midiBuffers.size() < numMidiBuffersNeeded) midiBuffers.add (new MidiBuffer()); - renderingOps.swapWithArray (newRenderingOps); + renderingOps.swapWith (newRenderingOps); } // delete the old ones.. diff --git a/modules/juce_core/containers/juce_Array.h b/modules/juce_core/containers/juce_Array.h index fe6af14b45..38490a2fad 100644 --- a/modules/juce_core/containers/juce_Array.h +++ b/modules/juce_core/containers/juce_Array.h @@ -137,7 +137,7 @@ public: if (this != &other) { Array otherCopy (other); - swapWithArray (otherCopy); + swapWith (otherCopy); } return *this; @@ -576,11 +576,11 @@ public: If you need to exchange two arrays, this is vastly quicker than using copy-by-value because it just swaps their internal pointers. */ - void swapWithArray (Array& otherArray) noexcept + template + void swapWith (OtherArrayType& otherArray) noexcept { const ScopedLockType lock1 (getLock()); - const ScopedLockType lock2 (otherArray.getLock()); - + const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock()); data.swapWith (otherArray.data); std::swap (numUsed, otherArray.numUsed); } @@ -1025,6 +1025,11 @@ public: typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType; + //============================================================================== + // Note that the swapWithArray method has been replaced by a more flexible templated version, + // and renamed "swapWith" to be more consistent with the names used in other classes. + JUCE_DEPRECATED_WITH_BODY (void swapWithArray (Array& other) noexcept, { swapWith (other); }) + private: //============================================================================== ArrayAllocationBase data; diff --git a/modules/juce_core/containers/juce_HashMap.h b/modules/juce_core/containers/juce_HashMap.h index 4e66f8abec..40ad386c19 100644 --- a/modules/juce_core/containers/juce_HashMap.h +++ b/modules/juce_core/containers/juce_HashMap.h @@ -317,12 +317,13 @@ public: //============================================================================== /** Efficiently swaps the contents of two hash-maps. */ - void swapWith (HashMap& otherHashMap) noexcept + template + void swapWith (OtherHashMapType& otherHashMap) noexcept { const ScopedLockType lock1 (getLock()); - const ScopedLockType lock2 (otherHashMap.getLock()); + const typename OtherHashMapType::ScopedLockType lock2 (otherHashMap.getLock()); - slots.swapWithArray (otherHashMap.slots); + slots.swapWith (otherHashMap.slots); std::swap (totalNumItems, otherHashMap.totalNumItems); } diff --git a/modules/juce_core/containers/juce_OwnedArray.h b/modules/juce_core/containers/juce_OwnedArray.h index 83355680ee..b59e25d23d 100644 --- a/modules/juce_core/containers/juce_OwnedArray.h +++ b/modules/juce_core/containers/juce_OwnedArray.h @@ -792,11 +792,11 @@ public: If you need to exchange two arrays, this is vastly quicker than using copy-by-value because it just swaps their internal pointers. */ - void swapWithArray (OwnedArray& otherArray) noexcept + template + void swapWith (OtherArrayType& otherArray) noexcept { const ScopedLockType lock1 (getLock()); - const ScopedLockType lock2 (otherArray.getLock()); - + const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock()); data.swapWith (otherArray.data); std::swap (numUsed, otherArray.numUsed); } @@ -874,6 +874,11 @@ public: typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType; + //============================================================================== + // Note that the swapWithArray method has been replaced by a more flexible templated version, + // and renamed "swapWith" to be more consistent with the names used in other classes. + JUCE_DEPRECATED_WITH_BODY (void swapWithArray (OwnedArray& other) noexcept, { swapWith (other); }) + private: //============================================================================== ArrayAllocationBase data; diff --git a/modules/juce_core/containers/juce_ReferenceCountedArray.h b/modules/juce_core/containers/juce_ReferenceCountedArray.h index 3f2a34b970..0e0e5cd4d4 100644 --- a/modules/juce_core/containers/juce_ReferenceCountedArray.h +++ b/modules/juce_core/containers/juce_ReferenceCountedArray.h @@ -96,7 +96,7 @@ public: ReferenceCountedArray& operator= (const ReferenceCountedArray& other) noexcept { ReferenceCountedArray otherCopy (other); - swapWithArray (otherCopy); + swapWith (otherCopy); return *this; } @@ -107,7 +107,7 @@ public: ReferenceCountedArray& operator= (const ReferenceCountedArray& other) noexcept { ReferenceCountedArray otherCopy (other); - swapWithArray (otherCopy); + swapWith (otherCopy); return *this; } @@ -745,11 +745,11 @@ public: If you need to exchange two arrays, this is vastly quicker than using copy-by-value because it just swaps their internal pointers. */ - void swapWithArray (ReferenceCountedArray& otherArray) noexcept + template + void swapWith (OtherArrayType& otherArray) noexcept { const ScopedLockType lock1 (getLock()); - const ScopedLockType lock2 (otherArray.getLock()); - + const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock()); data.swapWith (otherArray.data); std::swap (numUsed, otherArray.numUsed); } @@ -857,6 +857,11 @@ public: typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType; + //============================================================================== + // Note that the swapWithArray method has been replaced by a more flexible templated version, + // and renamed "swapWith" to be more consistent with the names used in other classes. + JUCE_DEPRECATED_WITH_BODY (void swapWithArray (ReferenceCountedArray& other) noexcept, { swapWith (other); }) + private: //============================================================================== ArrayAllocationBase data; diff --git a/modules/juce_core/containers/juce_SortedSet.h b/modules/juce_core/containers/juce_SortedSet.h index 5836ed1965..91cf0bb202 100644 --- a/modules/juce_core/containers/juce_SortedSet.h +++ b/modules/juce_core/containers/juce_SortedSet.h @@ -450,7 +450,7 @@ public: */ void swapWith (SortedSet& otherSet) noexcept { - data.swapWithArray (otherSet.data); + data.swapWith (otherSet.data); } //============================================================================== diff --git a/modules/juce_core/text/juce_StringArray.cpp b/modules/juce_core/text/juce_StringArray.cpp index 859110bec8..166b5b0cd0 100644 --- a/modules/juce_core/text/juce_StringArray.cpp +++ b/modules/juce_core/text/juce_StringArray.cpp @@ -127,7 +127,7 @@ bool StringArray::operator!= (const StringArray& other) const noexcept void StringArray::swapWith (StringArray& other) noexcept { - strings.swapWithArray (other.strings); + strings.swapWith (other.strings); } void StringArray::clear() diff --git a/modules/juce_graphics/geometry/juce_RectangleList.cpp b/modules/juce_graphics/geometry/juce_RectangleList.cpp index 80fd0a7e26..f9b99b60ed 100644 --- a/modules/juce_graphics/geometry/juce_RectangleList.cpp +++ b/modules/juce_graphics/geometry/juce_RectangleList.cpp @@ -332,7 +332,7 @@ bool RectangleList::getIntersectionWith (const Rectangle& rect, RectangleLi void RectangleList::swapWith (RectangleList& otherList) noexcept { - rects.swapWithArray (otherList.rects); + rects.swapWith (otherList.rects); } diff --git a/modules/juce_gui_basics/components/juce_Desktop.cpp b/modules/juce_gui_basics/components/juce_Desktop.cpp index d70702ca44..d9160cbac9 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -420,7 +420,7 @@ void Desktop::Displays::init (Desktop& desktop) void Desktop::Displays::refresh() { Array oldDisplays; - oldDisplays.swapWithArray (displays); + oldDisplays.swapWith (displays); init (Desktop::getInstance()); diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index d365606192..74c0bed85c 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -1150,14 +1150,14 @@ PopupMenu& PopupMenu::operator= (const PopupMenu& other) PopupMenu::PopupMenu (PopupMenu&& other) noexcept : lookAndFeel (other.lookAndFeel) { - items.swapWithArray (other.items); + items.swapWith (other.items); } PopupMenu& PopupMenu::operator= (PopupMenu&& other) noexcept { jassert (this != &other); // hopefully the compiler should make this situation impossible! - items.swapWithArray (other.items); + items.swapWith (other.items); lookAndFeel = other.lookAndFeel; return *this; } diff --git a/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp b/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp index 87e6ca4cfa..29f6816005 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp @@ -94,7 +94,7 @@ bool RelativePointPath::operator!= (const RelativePointPath& other) const noexce void RelativePointPath::swapWith (RelativePointPath& other) noexcept { - elements.swapWithArray (other.elements); + elements.swapWith (other.elements); std::swap (usesNonZeroWinding, other.usesNonZeroWinding); std::swap (containsDynamicPoints, other.containsDynamicPoints); } diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index 13d585e5a7..5eb3db8a36 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -22,7 +22,7 @@ ============================================================================== */ -static uint32 lastUniqueID = 1; +static uint32 lastUniquePeerID = 1; //============================================================================== ComponentPeer::ComponentPeer (Component& comp, const int flags) @@ -30,7 +30,7 @@ ComponentPeer::ComponentPeer (Component& comp, const int flags) styleFlags (flags), constrainer (nullptr), lastDragAndDropCompUnderMouse (nullptr), - uniqueID (lastUniqueID += 2), // increment by 2 so that this can never hit 0 + uniqueID (lastUniquePeerID += 2), // increment by 2 so that this can never hit 0 isWindowMinimised (false) { Desktop::getInstance().peers.add (this); diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index 9bb5e46b75..8cb91b1194 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -76,7 +76,7 @@ public: return false; } - tokens.swapWithArray (newTokens); + tokens.swapWith (newTokens); return true; }