Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Stop leaking file loaders #18244

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Core/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ MetaFileSystem pspFileSystem;
ParamSFOData g_paramSFO;
static GlobalUIState globalUIState;
CoreParameter g_CoreParameter;
static FileLoader *loadedFile;
static FileLoader *g_loadedFile;
// For background loading thread.
static std::mutex loadingLock;
// For loadingReason updates.
Expand Down Expand Up @@ -324,6 +324,7 @@ bool CPU_Init(std::string *errorString, FileLoader *loadedFile) {

// If they shut down early, we'll catch it when load completes.
// Note: this may return before init is complete, which is checked if CPU_IsReady().
g_loadedFile = loadedFile;
if (!LoadFile(&loadedFile, &g_CoreParameter.errorString)) {
CPU_Shutdown();
g_CoreParameter.fileToStart.clear();
Expand Down Expand Up @@ -368,8 +369,8 @@ void CPU_Shutdown() {
Memory::Shutdown();
HLEPlugins::Shutdown();

delete loadedFile;
loadedFile = nullptr;
delete g_loadedFile;
g_loadedFile = nullptr;

delete g_CoreParameter.mountIsoLoader;
delete g_symbolMap;
Expand All @@ -380,8 +381,8 @@ void CPU_Shutdown() {

// TODO: Maybe loadedFile doesn't even belong here...
void UpdateLoadedFile(FileLoader *fileLoader) {
delete loadedFile;
loadedFile = fileLoader;
delete g_loadedFile;
g_loadedFile = fileLoader;
}

void Core_UpdateState(CoreState newState) {
Expand Down