Browse Source

Replaced the badly-named method Array::removeValue() with two new methods: removeFirstMatchingValue() and removeAllInstancesOf(). If you call the old method anywhere, you can just replace any calls with removeFirstMatchingValue(), which does the same job, but whose name makes it clear that not all instances of the value will be removed.

tags/2021-05-28
jules 13 years ago
parent
commit
591e89cd87
31 changed files with 59 additions and 41 deletions
  1. +1
    -1
      extras/Introjucer/Source/Project/jucer_ProjectType.cpp
  2. +1
    -1
      modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp
  3. +1
    -1
      modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp
  4. +1
    -1
      modules/juce_audio_devices/native/juce_ios_Audio.cpp
  5. +1
    -1
      modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp
  6. +1
    -1
      modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp
  7. +2
    -2
      modules/juce_audio_devices/native/juce_win32_Midi.cpp
  8. +3
    -3
      modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp
  9. +19
    -1
      modules/juce_core/containers/juce_Array.h
  10. +1
    -1
      modules/juce_core/native/juce_android_SystemStats.cpp
  11. +1
    -1
      modules/juce_core/streams/juce_OutputStream.cpp
  12. +2
    -2
      modules/juce_core/threads/juce_ThreadPool.cpp
  13. +3
    -3
      modules/juce_core/threads/juce_TimeSliceThread.cpp
  14. +1
    -1
      modules/juce_core/unit_tests/juce_UnitTest.cpp
  15. +1
    -1
      modules/juce_events/broadcasters/juce_ListenerList.h
  16. +1
    -1
      modules/juce_events/messages/juce_DeletedAtShutdown.cpp
  17. +1
    -1
      modules/juce_gui_basics/components/juce_Component.cpp
  18. +1
    -1
      modules/juce_gui_basics/components/juce_Desktop.cpp
  19. +1
    -1
      modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp
  20. +3
    -3
      modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp
  21. +1
    -1
      modules/juce_gui_basics/menus/juce_PopupMenu.cpp
  22. +1
    -1
      modules/juce_gui_basics/mouse/juce_MouseCursor.cpp
  23. +1
    -1
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm
  24. +2
    -2
      modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp
  25. +1
    -1
      modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp
  26. +2
    -2
      modules/juce_gui_basics/windows/juce_AlertWindow.cpp
  27. +1
    -1
      modules/juce_gui_basics/windows/juce_ComponentPeer.cpp
  28. +1
    -1
      modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp
  29. +1
    -1
      modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp
  30. +1
    -1
      modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp
  31. +1
    -1
      modules/juce_opengl/native/juce_OpenGL_android.h

+ 1
- 1
extras/Introjucer/Source/Project/jucer_ProjectType.cpp View File

@@ -38,7 +38,7 @@ ProjectType::ProjectType (const String& type_, const String& desc_)
ProjectType::~ProjectType()
{
getAllTypes().removeValue (this);
getAllTypes().removeFirstMatchingValue (this);
}
Array<ProjectType*>& ProjectType::getAllTypes()


+ 1
- 1
modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp View File

@@ -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);
}

+ 1
- 1
modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp View File

@@ -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)


+ 1
- 1
modules/juce_audio_devices/native/juce_ios_Audio.cpp View File

@@ -45,7 +45,7 @@ public:
~IPhoneAudioIODevice()
{
getSessionHolder().activeDevices.removeValue (this);
getSessionHolder().activeDevices.removeFirstMatchingValue (this);
close();
}


+ 1
- 1
modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp View File

@@ -257,7 +257,7 @@ namespace CoreMidiHelpers
{
const ScopedLock sl (callbackLock);
activeCallbacks.removeValue (this);
activeCallbacks.removeFirstMatchingValue (this);
}
if (portAndEndpoint != nullptr && portAndEndpoint->port != 0)


+ 1
- 1
modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp View File

@@ -1297,7 +1297,7 @@ Array<int> AudioCDReader::findIndexesInTrack (const int trackNumber)
pos += samplesPerFrame * framesPerIndexRead;
}
indexes.removeValue (trackStart);
indexes.removeFirstMatchingValue (trackStart);
}
return indexes;


+ 2
- 2
modules/juce_audio_devices/native/juce_win32_Midi.cpp View File

@@ -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;
}
}


+ 3
- 3
modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp View File

@@ -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


+ 19
- 1
modules/juce_core/containers/juce_Array.h View File

@@ -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,


+ 1
- 1
modules/juce_core/native/juce_android_SystemStats.cpp View File

@@ -31,7 +31,7 @@ JNIClassBase::JNIClassBase (const char* classPath_)
JNIClassBase::~JNIClassBase()
{
getClasses().removeValue (this);
getClasses().removeFirstMatchingValue (this);
}
Array<JNIClassBase*>& JNIClassBase::getClasses()


+ 1
- 1
modules/juce_core/streams/juce_OutputStream.cpp View File

@@ -58,7 +58,7 @@ OutputStream::OutputStream()
OutputStream::~OutputStream()
{
#if JUCE_DEBUG
danglingStreamChecker.activeStreams.removeValue (this);
danglingStreamChecker.activeStreams.removeFirstMatchingValue (this);
#endif
}


+ 2
- 2
modules/juce_core/threads/juce_ThreadPool.cpp View File

@@ -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();


+ 3
- 3
modules/juce_core/threads/juce_TimeSliceThread.cpp View File

@@ -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;
}


+ 1
- 1
modules/juce_core/unit_tests/juce_UnitTest.cpp View File

@@ -31,7 +31,7 @@ UnitTest::UnitTest (const String& name_)
UnitTest::~UnitTest()
{
getAllTests().removeValue (this);
getAllTests().removeFirstMatchingValue (this);
}
Array<UnitTest*>& UnitTest::getAllTests()


+ 1
- 1
modules/juce_events/broadcasters/juce_ListenerList.h View File

@@ -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. */


+ 1
- 1
modules/juce_events/messages/juce_DeletedAtShutdown.cpp View File

@@ -34,7 +34,7 @@ DeletedAtShutdown::DeletedAtShutdown()
DeletedAtShutdown::~DeletedAtShutdown()
{
const SpinLock::ScopedLockType sl (deletedAtShutdownLock);
getObjects().removeValue (this);
getObjects().removeFirstMatchingValue (this);
}
void DeletedAtShutdown::deleteAll()


+ 1
- 1
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -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; }


+ 1
- 1
modules/juce_gui_basics/components/juce_Desktop.cpp View File

@@ -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)


+ 1
- 1
modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp View File

@@ -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();


+ 3
- 3
modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp View File

@@ -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);
}
}


+ 1
- 1
modules/juce_gui_basics/menus/juce_PopupMenu.cpp View File

@@ -287,7 +287,7 @@ public:
~Window()
{
getActiveWindows().removeValue (this);
getActiveWindows().removeFirstMatchingValue (this);
Desktop::getInstance().removeGlobalMouseListener (this);
activeSubMenu = nullptr;
items.clear();


+ 1
- 1
modules/juce_gui_basics/mouse/juce_MouseCursor.cpp View File

@@ -77,7 +77,7 @@ public:
if (isStandard)
{
const SpinLock::ScopedLockType sl (lock);
getCursors().removeValue (this);
getCursors().removeFirstMatchingValue (this);
}
delete this;


+ 1
- 1
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -836,7 +836,7 @@ public:
if (isKeyDown)
keysCurrentlyDown.addIfNotAlreadyThere (keyCode);
else
keysCurrentlyDown.removeValue (keyCode);
keysCurrentlyDown.removeFirstMatchingValue (keyCode);
}
}


+ 2
- 2
modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp View File

@@ -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()


+ 1
- 1
modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp View File

@@ -480,7 +480,7 @@ void TableHeaderComponent::addListener (Listener* const newListener)
void TableHeaderComponent::removeListener (Listener* const listenerToRemove)
{
listeners.removeValue (listenerToRemove);
listeners.removeFirstMatchingValue (listenerToRemove);
}
//==============================================================================


+ 2
- 2
modules/juce_gui_basics/windows/juce_AlertWindow.cpp View File

@@ -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);


+ 1
- 1
modules/juce_gui_basics/windows/juce_ComponentPeer.cpp View File

@@ -45,7 +45,7 @@ ComponentPeer::ComponentPeer (Component* const component_, const int styleFlags_
ComponentPeer::~ComponentPeer()
{
heavyweightPeers.removeValue (this);
heavyweightPeers.removeFirstMatchingValue (this);
Desktop::getInstance().triggerFocusCallback();
}


+ 1
- 1
modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp View File

@@ -92,7 +92,7 @@ public:
if (currentActive == w)
currentActive = nullptr;
windows.removeValue (w);
windows.removeFirstMatchingValue (w);
if (windows.size() == 0)
deleteInstance();


+ 1
- 1
modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp View File

@@ -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);
}
}
}


+ 1
- 1
modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp View File

@@ -328,7 +328,7 @@ ActiveXControlComponent::ActiveXControlComponent()
ActiveXControlComponent::~ActiveXControlComponent()
{
deleteControl();
ActiveXHelpers::activeXComps.removeValue (this);
ActiveXHelpers::activeXComps.removeFirstMatchingValue (this);
}
void ActiveXControlComponent::paint (Graphics& g)


+ 1
- 1
modules/juce_opengl/native/juce_OpenGL_android.h View File

@@ -56,7 +56,7 @@ public:
{
{
const ScopedLock sl (contextListLock);
contextList.removeValue (this);
contextList.removeFirstMatchingValue (this);
}
android.activity.callVoidMethod (JuceAppActivity.deleteView, glView.get());


Loading…
Cancel
Save