From fd0d15b28e6a043d8fde97b705a1f320279780c3 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 25 May 2022 01:00:50 -0500 Subject: [PATCH] [nostalgia/studio] Fix memory leak of ProjectExplorer not getting freed --- src/nostalgia/studio/studioapp.cpp | 7 +++---- src/nostalgia/studio/studioapp.hpp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/nostalgia/studio/studioapp.cpp b/src/nostalgia/studio/studioapp.cpp index d5b3e690..5b3352d4 100644 --- a/src/nostalgia/studio/studioapp.cpp +++ b/src/nostalgia/studio/studioapp.cpp @@ -9,7 +9,6 @@ #include "lib/configio.hpp" #include "builtinmodules.hpp" #include "filedialogmanager.hpp" -#include "nostalgia/core/input.hpp" #include "studioapp.hpp" namespace nostalgia { @@ -32,7 +31,7 @@ oxModelEnd() StudioUI::StudioUI(core::Context *ctx) noexcept { m_ctx = ctx; - m_projectExplorer = new ProjectExplorer(m_ctx); + m_projectExplorer = ox::make_unique(m_ctx); m_projectExplorer->fileChosen.connect(this, &StudioUI::openFile); loadModules(); // open project and files @@ -283,8 +282,8 @@ ox::Error StudioUI::openProject(const ox::String &path) noexcept { m_project = ox::make_unique(m_ctx->rom.get(), path); auto sctx = applicationData(m_ctx); sctx->project = m_project.get(); - m_project->fileAdded.connect(m_projectExplorer, &ProjectExplorer::refreshProjectTreeModel); - m_project->fileDeleted.connect(m_projectExplorer, &ProjectExplorer::refreshProjectTreeModel); + m_project->fileAdded.connect(m_projectExplorer.get(), &ProjectExplorer::refreshProjectTreeModel); + m_project->fileDeleted.connect(m_projectExplorer.get(), &ProjectExplorer::refreshProjectTreeModel); m_openFiles.clear(); m_editors.clear(); studio::editConfig(m_ctx, [&](StudioConfig *config) { diff --git a/src/nostalgia/studio/studioapp.hpp b/src/nostalgia/studio/studioapp.hpp index 7fccd74d..ce24a84a 100644 --- a/src/nostalgia/studio/studioapp.hpp +++ b/src/nostalgia/studio/studioapp.hpp @@ -27,7 +27,7 @@ class StudioUI: public ox::SignalHandler { ox::Vector> m_editors; ox::Vector> m_widgets; ox::HashMap m_editorMakers; - ProjectExplorer *m_projectExplorer = nullptr; + ox::UniquePtr m_projectExplorer; ox::Vector m_openFiles; studio::BaseEditor *m_activeEditor = nullptr; studio::BaseEditor *m_activeEditorUpdatePending = nullptr;