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

View File

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

View File

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

View File

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

View File

@ -29,6 +29,7 @@ class wxTextCtrl;
class AudacityProject;
class LabelTrack;
class ShuttleGui;
class Track;
class ExportMultiple final : public wxDialogWrapper
{
@ -111,7 +112,10 @@ private:
LabelTrack *mLabels;
int mNumLabels;
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
formats (mFormat) of the selected export format.
This list includes all possible

View File

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

View File

@ -100,19 +100,27 @@ size_t FileHistory::GetCount()
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) {
mMenus.Add(menu);
if (!found)
mMenus.push_back(menu);
else {
wxASSERT(false);
}
}
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) {
mMenus.Remove(menu);
if (found)
mMenus.erase(iter);
else {
wxASSERT(false);
}
}
@ -151,9 +159,8 @@ void FileHistory::Save(wxConfigBase & config, const wxString & group)
void FileHistory::AddFilesToMenu()
{
for (size_t i = 0; i < mMenus.GetCount(); i++) {
AddFilesToMenu((wxMenu *) mMenus[i]);
}
for (auto pMenu : mMenus)
AddFilesToMenu(pMenu);
}
void FileHistory::AddFilesToMenu(wxMenu *menu)

View File

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