Remove uses of GetActiveProject in import
This commit is contained in:
parent
a1eeb528b7
commit
7592227f14
|
@ -1620,7 +1620,7 @@ bool ProjectFileManager::Import(
|
|||
auto newTags = oldTags->Duplicate();
|
||||
Tags::Set( project, newTags );
|
||||
|
||||
bool success = Importer::Get().Import(fileName,
|
||||
bool success = Importer::Get().Import(project, fileName,
|
||||
&TrackFactory::Get( project ),
|
||||
newTracks,
|
||||
newTags.get(),
|
||||
|
|
|
@ -409,13 +409,14 @@ std::unique_ptr<ExtImportItem> Importer::CreateDefaultImportItem()
|
|||
}
|
||||
|
||||
// returns number of tracks imported
|
||||
bool Importer::Import(const FilePath &fName,
|
||||
bool Importer::Import( AudacityProject &project,
|
||||
const FilePath &fName,
|
||||
TrackFactory *trackFactory,
|
||||
TrackHolders &tracks,
|
||||
Tags *tags,
|
||||
TranslatableString &errorMessage)
|
||||
{
|
||||
AudacityProject *pProj = GetActiveProject();
|
||||
AudacityProject *pProj = &project;
|
||||
auto cleanup = valueRestorer( pProj->mbBusyImporting, true );
|
||||
|
||||
const FileExtension extension{ fName.AfterLast(wxT('.')) };
|
||||
|
@ -589,7 +590,7 @@ bool Importer::Import(const FilePath &fName,
|
|||
{
|
||||
// Try to open the file with this plugin (probe it)
|
||||
wxLogMessage(wxT("Opening with %s"),plugin->GetPluginStringID());
|
||||
auto inFile = plugin->Open(fName);
|
||||
auto inFile = plugin->Open(fName, pProj);
|
||||
if ( (inFile != NULL) && (inFile->GetStreamCount() > 0) )
|
||||
{
|
||||
wxLogMessage(wxT("Open(%s) succeeded"), fName);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
class wxArrayString;
|
||||
class wxListBox;
|
||||
class AudacityProject;
|
||||
class Tags;
|
||||
class TrackFactory;
|
||||
class Track;
|
||||
|
@ -158,7 +159,8 @@ public:
|
|||
std::unique_ptr<ExtImportItem> CreateDefaultImportItem();
|
||||
|
||||
// if false, the import failed and errorMessage will be set.
|
||||
bool Import(const FilePath &fName,
|
||||
bool Import( AudacityProject &project,
|
||||
const FilePath &fName,
|
||||
TrackFactory *trackFactory,
|
||||
TrackHolders &tracks,
|
||||
Tags *tags,
|
||||
|
|
|
@ -183,7 +183,8 @@ public:
|
|||
TranslatableString GetPluginFormatDescription() override;
|
||||
|
||||
///! Probes the file and opens it if appropriate
|
||||
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
|
||||
std::unique_ptr<ImportFileHandle> Open(
|
||||
const FilePath &Filename, AudacityProject*) override;
|
||||
|
||||
unsigned SequenceNumber() const override;
|
||||
};
|
||||
|
@ -291,7 +292,8 @@ TranslatableString FFmpegImportPlugin::GetPluginFormatDescription()
|
|||
return DESC;
|
||||
}
|
||||
|
||||
std::unique_ptr<ImportFileHandle> FFmpegImportPlugin::Open(const FilePath &filename)
|
||||
std::unique_ptr<ImportFileHandle> FFmpegImportPlugin::Open(
|
||||
const FilePath &filename, AudacityProject*)
|
||||
{
|
||||
auto handle = std::make_unique<FFmpegImportFileHandle>(filename);
|
||||
|
||||
|
|
|
@ -135,7 +135,8 @@ class FLACImportPlugin final : public ImportPlugin
|
|||
|
||||
wxString GetPluginStringID() override { return wxT("libflac"); }
|
||||
TranslatableString GetPluginFormatDescription() override;
|
||||
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
|
||||
std::unique_ptr<ImportFileHandle> Open(
|
||||
const FilePath &Filename, AudacityProject*) override;
|
||||
|
||||
unsigned SequenceNumber() const override;
|
||||
};
|
||||
|
@ -291,7 +292,8 @@ TranslatableString FLACImportPlugin::GetPluginFormatDescription()
|
|||
}
|
||||
|
||||
|
||||
std::unique_ptr<ImportFileHandle> FLACImportPlugin::Open(const FilePath &filename)
|
||||
std::unique_ptr<ImportFileHandle> FLACImportPlugin::Open(
|
||||
const FilePath &filename, AudacityProject*)
|
||||
{
|
||||
// First check if it really is a FLAC file
|
||||
|
||||
|
|
|
@ -247,7 +247,8 @@ public:
|
|||
FileExtensions GetSupportedExtensions() override;
|
||||
|
||||
///! Probes the file and opens it if appropriate
|
||||
std::unique_ptr<ImportFileHandle> Open(const wxString &Filename) override;
|
||||
std::unique_ptr<ImportFileHandle> Open(
|
||||
const wxString &Filename, AudacityProject*) override;
|
||||
|
||||
unsigned SequenceNumber() const override;
|
||||
};
|
||||
|
@ -409,7 +410,8 @@ GStreamerImportPlugin::GetSupportedExtensions()
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Open the file and return an importer "file handle"
|
||||
std::unique_ptr<ImportFileHandle> GStreamerImportPlugin::Open(const wxString &filename)
|
||||
std::unique_ptr<ImportFileHandle> GStreamerImportPlugin::Open(
|
||||
const wxString &filename, AudacityProject*)
|
||||
{
|
||||
auto handle = std::make_unique<GStreamerImportFileHandle>(filename);
|
||||
|
||||
|
|
|
@ -114,7 +114,8 @@ public:
|
|||
|
||||
wxString GetPluginStringID() override { return wxT("lof"); }
|
||||
TranslatableString GetPluginFormatDescription() override;
|
||||
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
|
||||
std::unique_ptr<ImportFileHandle> Open(
|
||||
const FilePath &Filename, AudacityProject *pProject) override;
|
||||
|
||||
unsigned SequenceNumber() const override;
|
||||
};
|
||||
|
@ -123,7 +124,8 @@ public:
|
|||
class LOFImportFileHandle final : public ImportFileHandle
|
||||
{
|
||||
public:
|
||||
LOFImportFileHandle(const FilePath & name, std::unique_ptr<wxTextFile> &&file);
|
||||
LOFImportFileHandle( AudacityProject *pProject,
|
||||
const FilePath & name, std::unique_ptr<wxTextFile> &&file);
|
||||
~LOFImportFileHandle();
|
||||
|
||||
TranslatableString GetFileDescription() override;
|
||||
|
@ -150,7 +152,7 @@ private:
|
|||
std::unique_ptr<wxTextFile> mTextFile;
|
||||
wxFileName mLOFFileName; /**< The name of the LOF file, which is used to
|
||||
interpret relative paths in it */
|
||||
AudacityProject *mProject{ GetActiveProject() };
|
||||
AudacityProject *mProject{};
|
||||
|
||||
// In order to know whether or not to create a NEW window
|
||||
bool windowCalledOnce{ false };
|
||||
|
@ -164,11 +166,12 @@ private:
|
|||
double scrollOffset{ 0 };
|
||||
};
|
||||
|
||||
LOFImportFileHandle::LOFImportFileHandle
|
||||
(const FilePath & name, std::unique_ptr<wxTextFile> &&file)
|
||||
: ImportFileHandle(name),
|
||||
mTextFile(std::move(file))
|
||||
LOFImportFileHandle::LOFImportFileHandle( AudacityProject *pProject,
|
||||
const FilePath & name, std::unique_ptr<wxTextFile> &&file)
|
||||
: ImportFileHandle(name)
|
||||
, mTextFile(std::move(file))
|
||||
, mLOFFileName{name}
|
||||
, mProject{ pProject }
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -177,7 +180,8 @@ TranslatableString LOFImportPlugin::GetPluginFormatDescription()
|
|||
return DESC;
|
||||
}
|
||||
|
||||
std::unique_ptr<ImportFileHandle> LOFImportPlugin::Open(const FilePath &filename)
|
||||
std::unique_ptr<ImportFileHandle> LOFImportPlugin::Open(
|
||||
const FilePath &filename, AudacityProject *pProject)
|
||||
{
|
||||
// Check if it is a binary file
|
||||
{
|
||||
|
@ -208,7 +212,8 @@ std::unique_ptr<ImportFileHandle> LOFImportPlugin::Open(const FilePath &filename
|
|||
if (!file->IsOpened())
|
||||
return nullptr;
|
||||
|
||||
return std::make_unique<LOFImportFileHandle>(filename, std::move(file));
|
||||
return std::make_unique<LOFImportFileHandle>(
|
||||
pProject, filename, std::move(file));
|
||||
}
|
||||
|
||||
TranslatableString LOFImportFileHandle::GetFileDescription()
|
||||
|
|
|
@ -115,7 +115,8 @@ public:
|
|||
|
||||
wxString GetPluginStringID() override { return wxT("libmad"); }
|
||||
TranslatableString GetPluginFormatDescription() override;
|
||||
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
|
||||
std::unique_ptr<ImportFileHandle> Open(
|
||||
const FilePath &Filename, AudacityProject*) override;
|
||||
|
||||
unsigned SequenceNumber() const override;
|
||||
};
|
||||
|
@ -177,7 +178,8 @@ TranslatableString MP3ImportPlugin::GetPluginFormatDescription()
|
|||
return DESC;
|
||||
}
|
||||
|
||||
std::unique_ptr<ImportFileHandle> MP3ImportPlugin::Open(const FilePath &Filename)
|
||||
std::unique_ptr<ImportFileHandle> MP3ImportPlugin::Open(
|
||||
const FilePath &Filename, AudacityProject*)
|
||||
{
|
||||
auto file = std::make_unique<wxFile>(Filename);
|
||||
|
||||
|
|
|
@ -89,7 +89,8 @@ public:
|
|||
|
||||
wxString GetPluginStringID() override { return wxT("liboggvorbis"); }
|
||||
TranslatableString GetPluginFormatDescription() override;
|
||||
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
|
||||
std::unique_ptr<ImportFileHandle> Open(
|
||||
const FilePath &Filename, AudacityProject*) override;
|
||||
|
||||
unsigned SequenceNumber() const override;
|
||||
};
|
||||
|
@ -167,7 +168,8 @@ TranslatableString OggImportPlugin::GetPluginFormatDescription()
|
|||
return DESC;
|
||||
}
|
||||
|
||||
std::unique_ptr<ImportFileHandle> OggImportPlugin::Open(const FilePath &filename)
|
||||
std::unique_ptr<ImportFileHandle> OggImportPlugin::Open(
|
||||
const FilePath &filename, AudacityProject*)
|
||||
{
|
||||
// Suppress some compiler warnings about unused global variables in the library header
|
||||
wxUnusedVar(OV_CALLBACKS_DEFAULT);
|
||||
|
|
|
@ -87,7 +87,8 @@ public:
|
|||
|
||||
wxString GetPluginStringID() override { return wxT("libsndfile"); }
|
||||
TranslatableString GetPluginFormatDescription() override;
|
||||
std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) override;
|
||||
std::unique_ptr<ImportFileHandle> Open(
|
||||
const FilePath &Filename, AudacityProject*) override;
|
||||
|
||||
unsigned SequenceNumber() const override;
|
||||
};
|
||||
|
@ -126,7 +127,8 @@ TranslatableString PCMImportPlugin::GetPluginFormatDescription()
|
|||
return DESC;
|
||||
}
|
||||
|
||||
std::unique_ptr<ImportFileHandle> PCMImportPlugin::Open(const FilePath &filename)
|
||||
std::unique_ptr<ImportFileHandle> PCMImportPlugin::Open(
|
||||
const FilePath &filename, AudacityProject*)
|
||||
{
|
||||
SF_INFO info;
|
||||
wxFile f; // will be closed when it goes out of scope
|
||||
|
|
|
@ -52,6 +52,7 @@ but little else.
|
|||
|
||||
#include "ImportRaw.h" // defines TrackHolders
|
||||
|
||||
class AudacityProject;
|
||||
class wxArrayString;
|
||||
class ProgressDialog;
|
||||
enum class ProgressResult : unsigned;
|
||||
|
@ -92,7 +93,8 @@ public:
|
|||
// Open the given file, returning true if it is in a recognized
|
||||
// format, false otherwise. This puts the importer into the open
|
||||
// state.
|
||||
virtual std::unique_ptr<ImportFileHandle> Open(const FilePath &Filename) = 0;
|
||||
virtual std::unique_ptr<ImportFileHandle> Open(
|
||||
const FilePath &Filename, AudacityProject*) = 0;
|
||||
|
||||
virtual unsigned SequenceNumber() const = 0;
|
||||
|
||||
|
|
|
@ -122,7 +122,8 @@ class QTImportPlugin final : public ImportPlugin
|
|||
wxString GetPluginStringID() override { return wxT("quicktime"); }
|
||||
|
||||
TranslatableString GetPluginFormatDescription() override;
|
||||
std::unique_ptr<ImportFileHandle> Open(const wxString & Filename) override;
|
||||
std::unique_ptr<ImportFileHandle> Open(
|
||||
const wxString & Filename, AudacityProject*) override;
|
||||
|
||||
unsigned SequenceNumber() const override;
|
||||
|
||||
|
@ -180,7 +181,8 @@ TranslatableString QTImportPlugin::GetPluginFormatDescription()
|
|||
return DESC;
|
||||
}
|
||||
|
||||
std::unique_ptr<ImportFileHandle> QTImportPlugin::Open(const wxString & Filename)
|
||||
std::unique_ptr<ImportFileHandle> QTImportPlugin::Open(
|
||||
const wxString & Filename, AudacityProject*)
|
||||
{
|
||||
OSErr err;
|
||||
FSRef inRef;
|
||||
|
|
Loading…
Reference in New Issue