sys: Explicitly delete views so destructors get called properly

This commit is contained in:
WerWolv
2021-03-16 22:44:37 +01:00
parent b7dd936dae
commit ef747cc4c0
5 changed files with 12 additions and 8 deletions

View File

@@ -107,13 +107,13 @@ namespace hex {
template<hex::derived_from<View> T, typename ... Args>
static void add(Args&& ... args) {
return add(std::make_unique<T>(std::forward<Args>(args)...));
return add(new T(std::forward<Args>(args)...));
}
static std::vector<std::unique_ptr<View>>& getEntries();
static std::vector<View*>& getEntries();
private:
static void add(std::unique_ptr<View> &&view);
static void add(View *view);
};

View File

@@ -56,7 +56,7 @@ namespace hex {
static u32 customEventsLastId;
static std::vector<ContentRegistry::CommandPaletteCommands::Entry> commandPaletteCommands;
static std::map<std::string, ContentRegistry::PatternLanguageFunctions::Function> patternLanguageFunctions;
static std::vector<std::unique_ptr<View>> views;
static std::vector<View*> views;
static std::vector<ContentRegistry::Tools::Entry> toolsEntries;
static std::vector<ContentRegistry::DataInspector::Entry> dataInspectorEntries;
static u32 patternPaletteOffset;

View File

@@ -172,11 +172,11 @@ namespace hex {
/* Views */
void ContentRegistry::Views::add(std::unique_ptr<View> &&view) {
getEntries().emplace_back(std::move(view));
void ContentRegistry::Views::add(View *view) {
getEntries().emplace_back(view);
}
std::vector<std::unique_ptr<View>>& ContentRegistry::Views::getEntries() {
std::vector<View*>& ContentRegistry::Views::getEntries() {
return SharedData::views;
}

View File

@@ -11,7 +11,7 @@ namespace hex {
u32 SharedData::customEventsLastId;
std::vector<ContentRegistry::CommandPaletteCommands::Entry> SharedData::commandPaletteCommands;
std::map<std::string, ContentRegistry::PatternLanguageFunctions::Function> SharedData::patternLanguageFunctions;
std::vector<std::unique_ptr<View>> SharedData::views;
std::vector<View*> SharedData::views;
std::vector<ContentRegistry::Tools::Entry> SharedData::toolsEntries;
std::vector<ContentRegistry::DataInspector::Entry> SharedData::dataInspectorEntries;
u32 SharedData::patternPaletteOffset;