1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 15:49:36 +02:00

Don't use wxArrayPtrVoid with casts, use std::vector

This commit is contained in:
Paul Licameli 2016-09-08 11:04:35 -04:00
parent 43b4d3cc99
commit 2263a0f477
8 changed files with 49 additions and 38 deletions

View File

@ -2046,8 +2046,8 @@ void Effect::CopyInputTracks()
void Effect::CopyInputTracks(int trackType) void Effect::CopyInputTracks(int trackType)
{ {
// Reset map // Reset map
mIMap.Clear(); mIMap.clear();
mOMap.Clear(); mOMap.clear();
mOutputTracks = std::make_unique<TrackList>(); mOutputTracks = std::make_unique<TrackList>();
mOutputTracksType = trackType; mOutputTracksType = trackType;
@ -2063,16 +2063,16 @@ void Effect::CopyInputTracks(int trackType)
(trackType == Track::All && aTrack->IsSyncLockSelected())) (trackType == Track::All && aTrack->IsSyncLockSelected()))
{ {
Track *o = mOutputTracks->Add(aTrack->Duplicate()); Track *o = mOutputTracks->Add(aTrack->Duplicate());
mIMap.Add(aTrack); mIMap.push_back(aTrack);
mOMap.Add(o); mOMap.push_back(o);
} }
} }
} }
Track *Effect::AddToOutputTracks(std::unique_ptr<Track> &&t) Track *Effect::AddToOutputTracks(std::unique_ptr<Track> &&t)
{ {
mIMap.Add(NULL); mIMap.push_back(NULL);
mOMap.Add(t.get()); mOMap.push_back(t.get());
return mOutputTracks->Add(std::move(t)); return mOutputTracks->Add(std::move(t));
} }
@ -2178,8 +2178,8 @@ void Effect::ReplaceProcessedTracks(const bool bGoodResult)
mOutputTracks->Clear(); mOutputTracks->Clear();
// Reset map // Reset map
mIMap.Clear(); mIMap.clear();
mOMap.Clear(); mOMap.clear();
//TODO:undo the non-gui ODTask transfer //TODO:undo the non-gui ODTask transfer
return; return;
@ -2187,7 +2187,7 @@ void Effect::ReplaceProcessedTracks(const bool bGoodResult)
auto iterOut = mOutputTracks->begin(), iterEnd = mOutputTracks->end(); auto iterOut = mOutputTracks->begin(), iterEnd = mOutputTracks->end();
size_t cnt = mOMap.GetCount(); size_t cnt = mOMap.size();
size_t i = 0; size_t i = 0;
for (; iterOut != iterEnd; ++i) { for (; iterOut != iterEnd; ++i) {
@ -2195,7 +2195,7 @@ void Effect::ReplaceProcessedTracks(const bool bGoodResult)
// If tracks were removed from mOutputTracks, then there will be // If tracks were removed from mOutputTracks, then there will be
// tracks in the map that must be removed from mTracks. // tracks in the map that must be removed from mTracks.
while (i < cnt && mOMap[i] != o.get()) { while (i < cnt && mOMap[i] != o.get()) {
Track *t = (Track *) mIMap[i]; const auto t = mIMap[i];
if (t) { if (t) {
mTracks->Remove(t); mTracks->Remove(t);
} }
@ -2208,7 +2208,7 @@ void Effect::ReplaceProcessedTracks(const bool bGoodResult)
// Remove the track from the output list...don't DELETE it // Remove the track from the output list...don't DELETE it
iterOut = mOutputTracks->erase(iterOut); iterOut = mOutputTracks->erase(iterOut);
Track *t = (Track *) mIMap[i]; const auto t = mIMap[i];
if (t == NULL) if (t == NULL)
{ {
// This track is a NEW addition to output tracks; add it to mTracks // This track is a NEW addition to output tracks; add it to mTracks
@ -2232,16 +2232,16 @@ void Effect::ReplaceProcessedTracks(const bool bGoodResult)
// If tracks were removed from mOutputTracks, then there may be tracks // If tracks were removed from mOutputTracks, then there may be tracks
// left at the end of the map that must be removed from mTracks. // left at the end of the map that must be removed from mTracks.
while (i < cnt) { while (i < cnt) {
Track *t = (Track *) mIMap[i]; const auto t = mIMap[i];
if (t) { if (t) {
mTracks->Remove((Track *)mIMap[i]); mTracks->Remove(t);
} }
i++; i++;
} }
// Reset map // Reset map
mIMap.Clear(); mIMap.clear();
mOMap.Clear(); mOMap.clear();
// Make sure we processed everything // Make sure we processed everything
wxASSERT(mOutputTracks->empty()); wxASSERT(mOutputTracks->empty());

View File

@ -494,8 +494,8 @@ private:
bool mUIDebug; bool mUIDebug;
wxArrayPtrVoid mIMap; std::vector<Track*> mIMap;
wxArrayPtrVoid mOMap; std::vector<Track*> mOMap;
int mNumTracks; //v This is really mNumWaveTracks, per CountWaveTracks() and GetNumWaveTracks(). int mNumTracks; //v This is really mNumWaveTracks, per CountWaveTracks() and GetNumWaveTracks().
int mNumGroups; int mNumGroups;

View File

@ -329,10 +329,11 @@ bool EffectEqualization48x::TrackCompare()
mEffectEqualization->mM=(mEffectEqualization->mM&(~15))+1; mEffectEqualization->mM=(mEffectEqualization->mM&(~15))+1;
AllocateBuffersWorkers(sMathPath&MATH_FUNCTION_THREADED); AllocateBuffersWorkers(sMathPath&MATH_FUNCTION_THREADED);
// Reset map // Reset map
wxArrayPtrVoid SecondIMap; // PRL: These two maps aren't really used
wxArrayPtrVoid SecondOMap; std::vector<Track*> SecondIMap;
SecondIMap.Clear(); std::vector<Track*> SecondOMap;
SecondOMap.Clear(); SecondIMap.clear();
SecondOMap.clear();
TrackList SecondOutputTracks; TrackList SecondOutputTracks;
@ -346,8 +347,8 @@ bool EffectEqualization48x::TrackCompare()
(mEffectEqualization->mOutputTracksType == Track::All && aTrack->IsSyncLockSelected())) (mEffectEqualization->mOutputTracksType == Track::All && aTrack->IsSyncLockSelected()))
{ {
auto o = aTrack->Duplicate(); auto o = aTrack->Duplicate();
SecondIMap.Add(aTrack); SecondIMap.push_back(aTrack);
SecondIMap.Add(o.get()); SecondIMap.push_back(o.get());
SecondOutputTracks.Add(std::move(o)); SecondOutputTracks.Add(std::move(o));
} }
} }

View File

@ -925,9 +925,8 @@ int ExportMultiple::ExportMultipleByTrack(bool byName,
} }
// Restore the selection states // Restore the selection states
for (size_t i = 0; i < mSelected.GetCount(); i++) { for (auto pTrack : mSelected)
selected[i]->SetSelected(true); pTrack->SetSelected(true);
}
return ok ; return ok ;
} }

View File

@ -29,6 +29,7 @@ class wxTextCtrl;
class AudacityProject; class AudacityProject;
class LabelTrack; class LabelTrack;
class ShuttleGui; class ShuttleGui;
class Track;
class ExportMultiple final : public wxDialogWrapper class ExportMultiple final : public wxDialogWrapper
{ {
@ -111,7 +112,10 @@ private:
LabelTrack *mLabels; LabelTrack *mLabels;
int mNumLabels; int mNumLabels;
int mNumWaveTracks; int mNumWaveTracks;
wxArrayPtrVoid mSelected;
// PRL: This is never populated anywhere?
std::vector<Track*> mSelected;
int mFilterIndex; /**< The index in the drop-down list of export int mFilterIndex; /**< The index in the drop-down list of export
formats (mFormat) of the selected export format. formats (mFormat) of the selected export format.
This list includes all possible This list includes all possible

View File

@ -19,7 +19,6 @@
#include "ToolBar.h" #include "ToolBar.h"
class wxArrayPtrVoid;
class wxCommandEvent; class wxCommandEvent;
class wxEraseEvent; class wxEraseEvent;
class wxSizeEvent; class wxSizeEvent;

View File

@ -100,19 +100,27 @@ size_t FileHistory::GetCount()
void FileHistory::UseMenu(wxMenu *menu) void FileHistory::UseMenu(wxMenu *menu)
{ {
wxASSERT(mMenus.Index(menu) == wxNOT_FOUND); auto end = mMenus.end();
auto iter = std::find(mMenus.begin(), end, menu);
auto found = (iter != end);
if (mMenus.Index(menu) == wxNOT_FOUND) { if (!found)
mMenus.Add(menu); mMenus.push_back(menu);
else {
wxASSERT(false);
} }
} }
void FileHistory::RemoveMenu(wxMenu *menu) void FileHistory::RemoveMenu(wxMenu *menu)
{ {
wxASSERT(mMenus.Index(menu) != wxNOT_FOUND); auto end = mMenus.end();
auto iter = std::find(mMenus.begin(), end, menu);
auto found = (iter != end);
if (mMenus.Index(menu) != wxNOT_FOUND) { if (found)
mMenus.Remove(menu); mMenus.erase(iter);
else {
wxASSERT(false);
} }
} }
@ -151,9 +159,8 @@ void FileHistory::Save(wxConfigBase & config, const wxString & group)
void FileHistory::AddFilesToMenu() void FileHistory::AddFilesToMenu()
{ {
for (size_t i = 0; i < mMenus.GetCount(); i++) { for (auto pMenu : mMenus)
AddFilesToMenu((wxMenu *) mMenus[i]); AddFilesToMenu(pMenu);
}
} }
void FileHistory::AddFilesToMenu(wxMenu *menu) void FileHistory::AddFilesToMenu(wxMenu *menu)

View File

@ -11,6 +11,7 @@
#ifndef __AUDACITY_WIDGETS_FILEHISTORY__ #ifndef __AUDACITY_WIDGETS_FILEHISTORY__
#define __AUDACITY_WIDGETS_FILEHISTORY__ #define __AUDACITY_WIDGETS_FILEHISTORY__
#include <vector>
#include <wx/defs.h> #include <wx/defs.h>
#include <wx/choice.h> #include <wx/choice.h>
#include <wx/dynarray.h> #include <wx/dynarray.h>
@ -43,7 +44,7 @@ class AUDACITY_DLL_API FileHistory
size_t mMaxFiles; size_t mMaxFiles;
wxWindowID mIDBase; wxWindowID mIDBase;
wxArrayPtrVoid mMenus; std::vector<wxMenu*> mMenus;
wxArrayString mHistory; wxArrayString mHistory;
}; };