mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
Make views get auto deleted
This commit is contained in:
@@ -104,14 +104,14 @@ namespace hex {
|
||||
Views() = delete;
|
||||
|
||||
template<hex::derived_from<View> T, typename ... Args>
|
||||
static T* add(Args&& ... args) {
|
||||
return static_cast<T*>(add(new T(std::forward<Args>(args)...)));
|
||||
static void add(Args&& ... args) {
|
||||
return add(std::make_unique<T>(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
static std::vector<View*>& getEntries();
|
||||
static std::vector<std::unique_ptr<View>>& getEntries();
|
||||
|
||||
private:
|
||||
static View* add(View *view);
|
||||
static void add(std::unique_ptr<View> &&view);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/event.hpp>
|
||||
#include <hex/views/view.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <ImGuiFileBrowser.h>
|
||||
@@ -55,7 +57,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<View*> views;
|
||||
static std::vector<std::unique_ptr<View>> views;
|
||||
static std::vector<ContentRegistry::Tools::Entry> toolsEntries;
|
||||
static std::vector<ContentRegistry::DataInspector::Entry> dataInspectorEntries;
|
||||
static u32 patternPaletteOffset;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <ImGuiFileBrowser.h>
|
||||
|
||||
#include <hex/api/event.hpp>
|
||||
#include <hex/helpers/shared_data.hpp>
|
||||
#include <hex/providers/provider.hpp>
|
||||
|
||||
#include <functional>
|
||||
@@ -24,7 +23,7 @@ namespace hex {
|
||||
virtual void drawContent() = 0;
|
||||
virtual void drawMenu();
|
||||
virtual bool handleShortcut(int key, int mods);
|
||||
virtual bool isAvailable() { return SharedData::currentProvider != nullptr && SharedData::currentProvider->isAvailable(); }
|
||||
virtual bool isAvailable();
|
||||
|
||||
static void openFileBrowser(std::string title, imgui_addons::ImGuiFileBrowser::DialogMode mode, std::string validExtensions, const std::function<void(std::string)> &callback);
|
||||
static void doLater(std::function<void()> &&function);
|
||||
|
||||
Reference in New Issue
Block a user