FifoDataFile: Make Load return a unique_ptr
This commit is contained in:
parent
41335752e5
commit
8943d23a4c
|
@ -130,7 +130,7 @@ bool FifoDataFile::Save(const std::string& filename)
|
|||
return true;
|
||||
}
|
||||
|
||||
FifoDataFile* FifoDataFile::Load(const std::string& filename, bool flagsOnly)
|
||||
std::unique_ptr<FifoDataFile> FifoDataFile::Load(const std::string& filename, bool flagsOnly)
|
||||
{
|
||||
File::IOFile file;
|
||||
file.Open(filename, "rb");
|
||||
|
@ -146,7 +146,7 @@ FifoDataFile* FifoDataFile::Load(const std::string& filename, bool flagsOnly)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
FifoDataFile* dataFile = new FifoDataFile;
|
||||
auto dataFile = std::make_unique<FifoDataFile>();
|
||||
|
||||
dataFile->m_Flags = header.flags;
|
||||
dataFile->m_Version = header.file_version;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -70,7 +71,7 @@ public:
|
|||
u32 GetFrameCount() const { return static_cast<u32>(m_Frames.size()); }
|
||||
bool Save(const std::string& filename);
|
||||
|
||||
static FifoDataFile* Load(const std::string& filename, bool flagsOnly);
|
||||
static std::unique_ptr<FifoDataFile> Load(const std::string& filename, bool flagsOnly);
|
||||
|
||||
private:
|
||||
enum
|
||||
|
|
|
@ -28,7 +28,6 @@ bool IsPlayingBackFifologWithBrokenEFBCopies = false;
|
|||
|
||||
FifoPlayer::~FifoPlayer()
|
||||
{
|
||||
delete m_File;
|
||||
}
|
||||
|
||||
bool FifoPlayer::Open(const std::string& filename)
|
||||
|
@ -40,7 +39,7 @@ bool FifoPlayer::Open(const std::string& filename)
|
|||
if (m_File)
|
||||
{
|
||||
FifoAnalyzer::Init();
|
||||
FifoPlaybackAnalyzer::AnalyzeFrames(m_File, m_FrameInfo);
|
||||
FifoPlaybackAnalyzer::AnalyzeFrames(m_File.get(), m_FrameInfo);
|
||||
|
||||
m_FrameRangeEnd = m_File->GetFrameCount();
|
||||
}
|
||||
|
@ -53,8 +52,7 @@ bool FifoPlayer::Open(const std::string& filename)
|
|||
|
||||
void FifoPlayer::Close()
|
||||
{
|
||||
delete m_File;
|
||||
m_File = nullptr;
|
||||
m_File.reset();
|
||||
|
||||
m_FrameRangeStart = 0;
|
||||
m_FrameRangeEnd = 0;
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
// PowerPC state.
|
||||
std::unique_ptr<CPUCoreBase> GetCPUCore();
|
||||
|
||||
FifoDataFile* GetFile() { return m_File; }
|
||||
FifoDataFile* GetFile() { return m_File.get(); }
|
||||
u32 GetFrameObjectCount();
|
||||
u32 GetCurrentFrameNum() const { return m_CurrentFrame; }
|
||||
const AnalyzedFrameInfo& GetAnalyzedFrameInfo(u32 frame) const { return m_FrameInfo[frame]; }
|
||||
|
@ -143,7 +143,7 @@ private:
|
|||
CallbackFunc m_FileLoadedCb;
|
||||
CallbackFunc m_FrameWrittenCb;
|
||||
|
||||
FifoDataFile* m_File;
|
||||
std::unique_ptr<FifoDataFile> m_File;
|
||||
|
||||
std::vector<AnalyzedFrameInfo> m_FrameInfo;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue