diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index e9e6166cdc..157a0f2d1c 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -45,6 +45,7 @@ FileLoader *ConstructFileLoader(const Path &filename) { } // TODO : improve, look in the file more +// Does not take ownership. IdentifiedFileType Identify_File(FileLoader *fileLoader, std::string *errorString) { errorString->clear(); if (fileLoader == nullptr) { diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index 11e633f635..cfda50e21a 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -52,6 +52,7 @@ GameManager g_GameManager; +// Close the return value with ZipClose (if non-null, of course). struct zip *ZipOpenPath(Path fileName) { int error = 0; // Need to special case for content URI here, similar to OpenCFile. @@ -73,7 +74,8 @@ struct zip *ZipOpenPath(Path fileName) { } void ZipClose(struct zip *z) { - zip_close(z); + if (z) + zip_close(z); } GameManager::GameManager() { diff --git a/GPU/Debugger/Playback.cpp b/GPU/Debugger/Playback.cpp index 7bfb9e6f19..7481cdd01f 100644 --- a/GPU/Debugger/Playback.cpp +++ b/GPU/Debugger/Playback.cpp @@ -63,6 +63,18 @@ enum class OpType { Done, }; +static const char *OpTypeToString(OpType type) { + switch (type) { + case OpType::None: return "None"; + case OpType::UpdateStallAddr: return "UpdateStallAddr"; + case OpType::EnqueueList: return "EnqueueList"; + case OpType::ListSync: return "ListSync"; + case OpType::ReapplyGfxState: return "ReapplyGfxState"; + case OpType::Done: return "Done"; + default: return "N/A"; + } +} + struct Operation { OpType type; u32 listID; // also listPC in EnqueueList @@ -888,6 +900,8 @@ static u32 LoadReplay(const std::string &filename) { } void Replay_Unload() { + // TODO: Hm, we have a problem here. We might be paused inside a replay and exiting - in this case, the thread is still running. + _dbg_assert_(!replayThread.joinable()); lastExecFilename.clear(); diff --git a/UI/InstallZipScreen.cpp b/UI/InstallZipScreen.cpp index 7256295e42..15ef41c57e 100644 --- a/UI/InstallZipScreen.cpp +++ b/UI/InstallZipScreen.cpp @@ -59,7 +59,7 @@ void InstallZipScreen::CreateViews() { std::string shortFilename = zipPath_.GetFilename(); // TODO: Do in the background? - struct zip *z = ZipOpenPath(zipPath_); + struct zip *zipFile = ZipOpenPath(zipPath_); bool showDeleteCheckbox = false; returnToHomebrew_ = false; @@ -71,8 +71,8 @@ void InstallZipScreen::CreateViews() { std::vector destOptions; - if (z) { - DetectZipFileContents(z, &zipFileInfo_); // Even if this fails, it sets zipInfo->contents. + if (zipFile) { + DetectZipFileContents(zipFile, &zipFileInfo_); // Even if this fails, it sets zipInfo->contents. if (zipFileInfo_.contents == ZipFileContents::ISO_FILE || zipFileInfo_.contents == ZipFileContents::PSP_GAME_DIR) { std::string_view question = iz->T("Install game from ZIP file?"); @@ -120,7 +120,7 @@ void InstallZipScreen::CreateViews() { leftColumn->Add(new TextView(zipFileInfo_.gameTitle + ": " + zipFileInfo_.savedataDir)); Path savedataDir = GetSysDirectory(DIRECTORY_SAVEDATA); - bool overwrite = !CanExtractWithoutOverwrite(z, savedataDir, 50); + bool overwrite = !CanExtractWithoutOverwrite(zipFile, savedataDir, 50); destFolders_.push_back(savedataDir); @@ -163,6 +163,7 @@ void InstallZipScreen::CreateViews() { } else { leftColumn->Add(new TextView(iz->T("Zip file does not contain PSP software"), ALIGN_LEFT, false, new AnchorLayoutParams(10, 10, NONE, NONE))); } + ZipClose(zipFile); } else { leftColumn->Add(new TextView(er->T("The file is not a valid zip file"), ALIGN_LEFT, false, new AnchorLayoutParams(10, 10, NONE, NONE))); } diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 5dd649fcfa..bf79356b05 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -77,14 +77,13 @@ bool MainScreen::showHomebrewTab = false; bool LaunchFile(ScreenManager *screenManager, const Path &path) { // Depending on the file type, we don't want to launch EmuScreen at all. - auto loader = ConstructFileLoader(path); + std::unique_ptr loader(ConstructFileLoader(path)); if (!loader) { return false; } std::string errorString; - IdentifiedFileType type = Identify_File(loader, &errorString); - delete loader; + IdentifiedFileType type = Identify_File(loader.get(), &errorString); switch (type) { case IdentifiedFileType::ARCHIVE_ZIP: