diff --git a/extras/Introjucer/Source/Project/jucer_ProjectType.cpp b/extras/Introjucer/Source/Project/jucer_ProjectType.cpp index 37ab8387f0..32b128964f 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectType.cpp +++ b/extras/Introjucer/Source/Project/jucer_ProjectType.cpp @@ -38,7 +38,7 @@ ProjectType::ProjectType (const String& type_, const String& desc_) ProjectType::~ProjectType() { - getAllTypes().removeValue (this); + getAllTypes().removeFirstMatchingValue (this); } Array& ProjectType::getAllTypes() diff --git a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp index d3e371164c..bf69545cd8 100644 --- a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp @@ -180,5 +180,5 @@ void MidiKeyboardState::addListener (MidiKeyboardStateListener* const listener) void MidiKeyboardState::removeListener (MidiKeyboardStateListener* const listener) { const ScopedLock sl (lock); - listeners.removeValue (listener); + listeners.removeFirstMatchingValue (listener); } diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index c9f54ad4b6..a385ee2aad 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -601,7 +601,7 @@ void AudioDeviceManager::removeAudioCallback (AudioIODeviceCallback* callbackToR const ScopedLock sl (audioCallbackLock); needsDeinitialising = needsDeinitialising && callbacks.contains (callbackToRemove); - callbacks.removeValue (callbackToRemove); + callbacks.removeFirstMatchingValue (callbackToRemove); } if (needsDeinitialising) diff --git a/modules/juce_audio_devices/native/juce_ios_Audio.cpp b/modules/juce_audio_devices/native/juce_ios_Audio.cpp index 5ae360d612..72dcb9f593 100644 --- a/modules/juce_audio_devices/native/juce_ios_Audio.cpp +++ b/modules/juce_audio_devices/native/juce_ios_Audio.cpp @@ -45,7 +45,7 @@ public: ~IPhoneAudioIODevice() { - getSessionHolder().activeDevices.removeValue (this); + getSessionHolder().activeDevices.removeFirstMatchingValue (this); close(); } diff --git a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp index d13a8542b7..f3593aa007 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp @@ -257,7 +257,7 @@ namespace CoreMidiHelpers { const ScopedLock sl (callbackLock); - activeCallbacks.removeValue (this); + activeCallbacks.removeFirstMatchingValue (this); } if (portAndEndpoint != nullptr && portAndEndpoint->port != 0) diff --git a/modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp b/modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp index c32444d2aa..4f8a46af53 100644 --- a/modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp +++ b/modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp @@ -1297,7 +1297,7 @@ Array AudioCDReader::findIndexesInTrack (const int trackNumber) pos += samplesPerFrame * framesPerIndexRead; } - indexes.removeValue (trackStart); + indexes.removeFirstMatchingValue (trackStart); } return indexes; diff --git a/modules/juce_audio_devices/native/juce_win32_Midi.cpp b/modules/juce_audio_devices/native/juce_win32_Midi.cpp index 4284e91ae8..55c7fe7993 100644 --- a/modules/juce_audio_devices/native/juce_win32_Midi.cpp +++ b/modules/juce_audio_devices/native/juce_win32_Midi.cpp @@ -105,7 +105,7 @@ public: isStarted = false; midiInReset (deviceHandle); midiInStop (deviceHandle); - activeMidiCollectors.removeValue (this); + activeMidiCollectors.removeFirstMatchingValue (this); unprepareAllHeaders(); concatenator.reset(); } @@ -436,7 +436,7 @@ MidiOutput::~MidiOutput() if (MidiOutHandle::activeHandles.contains (h) && --(h->refCount) == 0) { midiOutClose (h->handle); - MidiOutHandle::activeHandles.removeValue (h); + MidiOutHandle::activeHandles.removeFirstMatchingValue (h); delete h; } } diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 77ea7490a2..782a366c82 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -394,7 +394,7 @@ public: ~ModuleHandle() { - getActiveModules().removeValue (this); + getActiveModules().removeFirstMatchingValue (this); close(); } @@ -1153,7 +1153,7 @@ public: closePluginWindow(); #endif - activeVSTWindows.removeValue (this); + activeVSTWindows.removeFirstMatchingValue (this); plugin.editorBeingDeleted (this); } @@ -1319,7 +1319,7 @@ public: void broughtToFront() { - activeVSTWindows.removeValue (this); + activeVSTWindows.removeFirstMatchingValue (this); activeVSTWindows.add (this); #if JUCE_MAC diff --git a/modules/juce_core/containers/juce_Array.h b/modules/juce_core/containers/juce_Array.h index 40159d9517..e432f74903 100644 --- a/modules/juce_core/containers/juce_Array.h +++ b/modules/juce_core/containers/juce_Array.h @@ -743,7 +743,7 @@ public: @param valueToRemove the object to try to remove @see remove, removeRange */ - void removeValue (ParameterType valueToRemove) + void removeFirstMatchingValue (ParameterType valueToRemove) { const ScopedLockType lock (getLock()); ElementType* const e = data.elements; @@ -758,6 +758,24 @@ public: } } + /** Removes an item from the array. + + This will remove the first occurrence of the given element from the array. + If the item isn't found, no action is taken. + + @param valueToRemove the object to try to remove + @see remove, removeRange + */ + void removeAllInstancesOf (ParameterType valueToRemove) + { + const ScopedLockType lock (getLock()); + ElementType* const e = data.elements; + + for (int i = numUsed; --i >= 0;) + if (valueToRemove == e[i]) + remove (i); + } + /** Removes a range of elements from the array. This will remove a set of elements, starting from the given index, diff --git a/modules/juce_core/native/juce_android_SystemStats.cpp b/modules/juce_core/native/juce_android_SystemStats.cpp index 5e9c41b03f..9ff86747f4 100644 --- a/modules/juce_core/native/juce_android_SystemStats.cpp +++ b/modules/juce_core/native/juce_android_SystemStats.cpp @@ -31,7 +31,7 @@ JNIClassBase::JNIClassBase (const char* classPath_) JNIClassBase::~JNIClassBase() { - getClasses().removeValue (this); + getClasses().removeFirstMatchingValue (this); } Array& JNIClassBase::getClasses() diff --git a/modules/juce_core/streams/juce_OutputStream.cpp b/modules/juce_core/streams/juce_OutputStream.cpp index add9a284a1..f6a4197e9c 100644 --- a/modules/juce_core/streams/juce_OutputStream.cpp +++ b/modules/juce_core/streams/juce_OutputStream.cpp @@ -58,7 +58,7 @@ OutputStream::OutputStream() OutputStream::~OutputStream() { #if JUCE_DEBUG - danglingStreamChecker.activeStreams.removeValue (this); + danglingStreamChecker.activeStreams.removeFirstMatchingValue (this); #endif } diff --git a/modules/juce_core/threads/juce_ThreadPool.cpp b/modules/juce_core/threads/juce_ThreadPool.cpp index 2c9bf4c167..f73c8846c9 100644 --- a/modules/juce_core/threads/juce_ThreadPool.cpp +++ b/modules/juce_core/threads/juce_ThreadPool.cpp @@ -202,7 +202,7 @@ bool ThreadPool::removeJob (ThreadPoolJob* const job, } else { - jobs.removeValue (job); + jobs.removeFirstMatchingValue (job); addToDeleteList (deletionList, job); } } @@ -351,7 +351,7 @@ bool ThreadPool::runNextJob() if (result != ThreadPoolJob::jobNeedsRunningAgain || job->shouldStop) { - jobs.removeValue (job); + jobs.removeFirstMatchingValue (job); addToDeleteList (deletionList, job); jobFinishedSignal.signal(); diff --git a/modules/juce_core/threads/juce_TimeSliceThread.cpp b/modules/juce_core/threads/juce_TimeSliceThread.cpp index c9ca6246ac..1f4f2d79e8 100644 --- a/modules/juce_core/threads/juce_TimeSliceThread.cpp +++ b/modules/juce_core/threads/juce_TimeSliceThread.cpp @@ -59,11 +59,11 @@ void TimeSliceThread::removeTimeSliceClient (TimeSliceClient* const client) const ScopedLock sl2 (callbackLock); const ScopedLock sl3 (listLock); - clients.removeValue (client); + clients.removeFirstMatchingValue (client); } else { - clients.removeValue (client); + clients.removeFirstMatchingValue (client); } } @@ -156,7 +156,7 @@ void TimeSliceThread::run() if (msUntilNextCall >= 0) clientBeingCalled->nextCallTime += RelativeTime::milliseconds (msUntilNextCall); else - clients.removeValue (clientBeingCalled); + clients.removeFirstMatchingValue (clientBeingCalled); clientBeingCalled = nullptr; } diff --git a/modules/juce_core/unit_tests/juce_UnitTest.cpp b/modules/juce_core/unit_tests/juce_UnitTest.cpp index d44467dae4..c637e94986 100644 --- a/modules/juce_core/unit_tests/juce_UnitTest.cpp +++ b/modules/juce_core/unit_tests/juce_UnitTest.cpp @@ -31,7 +31,7 @@ UnitTest::UnitTest (const String& name_) UnitTest::~UnitTest() { - getAllTests().removeValue (this); + getAllTests().removeFirstMatchingValue (this); } Array& UnitTest::getAllTests() diff --git a/modules/juce_events/broadcasters/juce_ListenerList.h b/modules/juce_events/broadcasters/juce_ListenerList.h index a290d83454..ca3ca7638c 100644 --- a/modules/juce_events/broadcasters/juce_ListenerList.h +++ b/modules/juce_events/broadcasters/juce_ListenerList.h @@ -115,7 +115,7 @@ public: // Listeners can't be null pointers! jassert (listenerToRemove != nullptr); - listeners.removeValue (listenerToRemove); + listeners.removeFirstMatchingValue (listenerToRemove); } /** Returns the number of registered listeners. */ diff --git a/modules/juce_events/messages/juce_DeletedAtShutdown.cpp b/modules/juce_events/messages/juce_DeletedAtShutdown.cpp index 2d0c42eb3b..0769c5f61e 100644 --- a/modules/juce_events/messages/juce_DeletedAtShutdown.cpp +++ b/modules/juce_events/messages/juce_DeletedAtShutdown.cpp @@ -34,7 +34,7 @@ DeletedAtShutdown::DeletedAtShutdown() DeletedAtShutdown::~DeletedAtShutdown() { const SpinLock::ScopedLockType sl (deletedAtShutdownLock); - getObjects().removeValue (this); + getObjects().removeFirstMatchingValue (this); } void DeletedAtShutdown::deleteAll() diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 57320561c1..ed07980759 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -2907,7 +2907,7 @@ void Component::addKeyListener (KeyListener* const newListener) void Component::removeKeyListener (KeyListener* const listenerToRemove) { if (keyListeners != nullptr) - keyListeners->removeValue (listenerToRemove); + keyListeners->removeFirstMatchingValue (listenerToRemove); } bool Component::keyPressed (const KeyPress&) { return false; } diff --git a/modules/juce_gui_basics/components/juce_Desktop.cpp b/modules/juce_gui_basics/components/juce_Desktop.cpp index 72088f3b91..fa9d1789cb 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -119,7 +119,7 @@ void Desktop::addDesktopComponent (Component* const c) void Desktop::removeDesktopComponent (Component* const c) { - desktopComponents.removeValue (c); + desktopComponents.removeFirstMatchingValue (c); } void Desktop::componentBroughtToFront (Component* const c) diff --git a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp index 4a5d86aa4c..901ae036ca 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp @@ -96,7 +96,7 @@ void ComponentMovementWatcher::componentMovedOrResized (Component&, bool wasMove void ComponentMovementWatcher::componentBeingDeleted (Component& comp) { - registeredParentComps.removeValue (&comp); + registeredParentComps.removeFirstMatchingValue (&comp); if (component == &comp) unregister(); diff --git a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp index c52efd3c29..c23b95c464 100644 --- a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp +++ b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp @@ -258,7 +258,7 @@ bool MultiDocumentPanel::closeDocument (Component* component, if (shouldDelete) delete component; - components.removeValue (component); + components.removeFirstMatchingValue (component); if (isFullscreenWhenOneDocument() && components.size() == 1) { @@ -294,7 +294,7 @@ bool MultiDocumentPanel::closeDocument (Component* component, if (tabComponent != nullptr && tabComponent->getNumTabs() <= numDocsBeforeTabsUsed) tabComponent = nullptr; - components.removeValue (component); + components.removeFirstMatchingValue (component); if (components.size() > 0 && tabComponent == nullptr) addAndMakeVisible (components.getFirst()); @@ -515,7 +515,7 @@ void MultiDocumentPanel::updateOrder() if (current != nullptr) { - components.removeValue (current); + components.removeFirstMatchingValue (current); components.add (current); } } diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 5ed1bce3dc..f427bab1f1 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -287,7 +287,7 @@ public: ~Window() { - getActiveWindows().removeValue (this); + getActiveWindows().removeFirstMatchingValue (this); Desktop::getInstance().removeGlobalMouseListener (this); activeSubMenu = nullptr; items.clear(); diff --git a/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp b/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp index b19e30f0b2..123dfa1d71 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp @@ -77,7 +77,7 @@ public: if (isStandard) { const SpinLock::ScopedLockType sl (lock); - getCursors().removeValue (this); + getCursors().removeFirstMatchingValue (this); } delete this; diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index a71409a32e..c3de800c3b 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -836,7 +836,7 @@ public: if (isKeyDown) keysCurrentlyDown.addIfNotAlreadyThere (keyCode); else - keysCurrentlyDown.removeValue (keyCode); + keysCurrentlyDown.removeFirstMatchingValue (keyCode); } } diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp index cddbbe7b74..9e04dc79d8 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp @@ -265,7 +265,7 @@ void RelativeCoordinatePositionerBase::componentChildrenChanged (Component& chan void RelativeCoordinatePositionerBase::componentBeingDeleted (Component& comp) { jassert (sourceComponents.contains (&comp)); - sourceComponents.removeValue (&comp); + sourceComponents.removeFirstMatchingValue (&comp); registeredOk = false; } @@ -277,7 +277,7 @@ void RelativeCoordinatePositionerBase::markersChanged (MarkerList*) void RelativeCoordinatePositionerBase::markerListBeingDeleted (MarkerList* markerList) { jassert (sourceMarkerLists.contains (markerList)); - sourceMarkerLists.removeValue (markerList); + sourceMarkerLists.removeFirstMatchingValue (markerList); } void RelativeCoordinatePositionerBase::apply() diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index c3274751ba..df8f8c5279 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp @@ -480,7 +480,7 @@ void TableHeaderComponent::addListener (Listener* const newListener) void TableHeaderComponent::removeListener (Listener* const listenerToRemove) { - listeners.removeValue (listenerToRemove); + listeners.removeFirstMatchingValue (listenerToRemove); } //============================================================================== diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index 598a7c884b..421d7c9a6e 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp @@ -325,8 +325,8 @@ Component* AlertWindow::removeCustomComponent (const int index) if (c != nullptr) { - customComps.removeValue (c); - allComps.removeValue (c); + customComps.removeFirstMatchingValue (c); + allComps.removeFirstMatchingValue (c); removeChildComponent (c); updateLayout (false); diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index 2e0b745c6e..caffac5502 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -45,7 +45,7 @@ ComponentPeer::ComponentPeer (Component* const component_, const int styleFlags_ ComponentPeer::~ComponentPeer() { - heavyweightPeers.removeValue (this); + heavyweightPeers.removeFirstMatchingValue (this); Desktop::getInstance().triggerFocusCallback(); } diff --git a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp index cfacbd8553..1b7e4012a2 100644 --- a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp @@ -92,7 +92,7 @@ public: if (currentActive == w) currentActive = nullptr; - windows.removeValue (w); + windows.removeFirstMatchingValue (w); if (windows.size() == 0) deleteInstance(); diff --git a/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp b/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp index 64ea9cca2b..575ac8191a 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp @@ -458,7 +458,7 @@ void CodeDocument::Position::setPositionMaintained (const bool isMaintained) { // If this happens, you may have deleted the document while there are Position objects that are still using it... jassert (owner->positionsToMaintain.contains (this)); - owner->positionsToMaintain.removeValue (this); + owner->positionsToMaintain.removeFirstMatchingValue (this); } } } diff --git a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp index db567e756f..04af78b80e 100644 --- a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp @@ -328,7 +328,7 @@ ActiveXControlComponent::ActiveXControlComponent() ActiveXControlComponent::~ActiveXControlComponent() { deleteControl(); - ActiveXHelpers::activeXComps.removeValue (this); + ActiveXHelpers::activeXComps.removeFirstMatchingValue (this); } void ActiveXControlComponent::paint (Graphics& g) diff --git a/modules/juce_opengl/native/juce_OpenGL_android.h b/modules/juce_opengl/native/juce_OpenGL_android.h index a2c66b0661..3681f69f6f 100644 --- a/modules/juce_opengl/native/juce_OpenGL_android.h +++ b/modules/juce_opengl/native/juce_OpenGL_android.h @@ -56,7 +56,7 @@ public: { { const ScopedLock sl (contextListLock); - contextList.removeValue (this); + contextList.removeFirstMatchingValue (this); } android.activity.callVoidMethod (JuceAppActivity.deleteView, glView.get());