mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-02 00:29:41 +02:00
DirManager.cpp does not depend on Sequence.cpp...
... This does not yet break any dependency cycles
This commit is contained in:
parent
9b32fc7a2b
commit
d46bb29e3a
@ -340,10 +340,9 @@ bool RecordingRecoveryHandler::HandleXMLTag(const wxChar *tag,
|
||||
const auto &dirManager = mProject->GetDirManager();
|
||||
dirManager->SetLoadingFormat(seq->GetSampleFormat());
|
||||
|
||||
BlockArray array;
|
||||
array.resize(1);
|
||||
dirManager->SetLoadingTarget(&array, 0);
|
||||
auto &blockFile = array[0].f;
|
||||
BlockFilePtr blockFile;
|
||||
dirManager->SetLoadingTarget(
|
||||
[&]() -> BlockFilePtr& { return blockFile; } );
|
||||
|
||||
if (!dirManager->HandleXMLTag(tag, attrs) || !blockFile)
|
||||
{
|
||||
|
@ -94,7 +94,6 @@
|
||||
#include "InconsistencyException.h"
|
||||
#include "Project.h"
|
||||
#include "Prefs.h"
|
||||
#include "Sequence.h"
|
||||
#include "widgets/Warning.h"
|
||||
#include "widgets/ErrorDialog.h"
|
||||
#include "widgets/ProgressDialog.h"
|
||||
@ -397,8 +396,6 @@ DirManager::DirManager()
|
||||
projPath = wxT("");
|
||||
projName = wxT("");
|
||||
|
||||
mLoadingTarget = NULL;
|
||||
mLoadingTargetIdx = 0;
|
||||
mMaxSamples = ~size_t(0);
|
||||
|
||||
// toplevel pool hash is fully populated to begin
|
||||
@ -1345,12 +1342,13 @@ BlockFilePtr DirManager::CopyBlockFile(const BlockFilePtr &b)
|
||||
|
||||
bool DirManager::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
{
|
||||
if( mLoadingTarget == NULL )
|
||||
if( !mLoadingTarget )
|
||||
return false;
|
||||
|
||||
BlockFilePtr pBlockFile {};
|
||||
|
||||
BlockFilePtr &target = mLoadingTarget->at(mLoadingTargetIdx).f;
|
||||
BlockFilePtr &target = mLoadingTarget();
|
||||
mLoadingTarget = nullptr;
|
||||
|
||||
if (!wxStricmp(tag, wxT("silentblockfile"))) {
|
||||
// Silent blocks don't actually have a file associated, so
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "audacity/Types.h"
|
||||
#include "xml/XMLTagHandler.h"
|
||||
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
|
||||
class wxFileNameWrapper;
|
||||
@ -156,10 +157,10 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler {
|
||||
|
||||
bool EnsureSafeFilename(const wxFileName &fName);
|
||||
|
||||
void SetLoadingTarget(BlockArray *pArray, unsigned idx)
|
||||
using LoadingTarget = std::function< BlockFilePtr &() >;
|
||||
void SetLoadingTarget( LoadingTarget loadingTarget )
|
||||
{
|
||||
mLoadingTarget = pArray;
|
||||
mLoadingTargetIdx = idx;
|
||||
mLoadingTarget = loadingTarget;
|
||||
}
|
||||
void SetLoadingFormat(sampleFormat format) { mLoadingFormat = format; }
|
||||
void SetLoadingBlockLength(size_t len) { mLoadingBlockLen = len; }
|
||||
@ -254,8 +255,7 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler {
|
||||
|
||||
FilePaths aliasList;
|
||||
|
||||
BlockArray *mLoadingTarget;
|
||||
unsigned mLoadingTargetIdx;
|
||||
LoadingTarget mLoadingTarget;
|
||||
sampleFormat mLoadingFormat;
|
||||
size_t mLoadingBlockLen;
|
||||
|
||||
|
@ -867,7 +867,9 @@ bool Sequence::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
} // while
|
||||
|
||||
mBlock.push_back(wb);
|
||||
mDirManager->SetLoadingTarget(&mBlock, mBlock.size() - 1);
|
||||
auto index = mBlock.size() - 1;
|
||||
mDirManager->SetLoadingTarget(
|
||||
[this, index] () -> BlockFilePtr& { return mBlock[index].f; } );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user