diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp index cab3816480..e918bc993e 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp @@ -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::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(); dataFile->m_Flags = header.flags; dataFile->m_Version = header.file_version; diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.h b/Source/Core/Core/FifoPlayer/FifoDataFile.h index 5d21ddcbf7..8c2d449eb0 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.h +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include @@ -70,7 +71,7 @@ public: u32 GetFrameCount() const { return static_cast(m_Frames.size()); } bool Save(const std::string& filename); - static FifoDataFile* Load(const std::string& filename, bool flagsOnly); + static std::unique_ptr Load(const std::string& filename, bool flagsOnly); private: enum diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index 3078326b1b..99b35a0ad5 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -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; diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.h b/Source/Core/Core/FifoPlayer/FifoPlayer.h index 46d1f69b7c..db09fadde9 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.h +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.h @@ -64,7 +64,7 @@ public: // PowerPC state. std::unique_ptr 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 m_File; std::vector m_FrameInfo; };