mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
impr: Use smart pointers to allocate Views
This commit is contained in:
@@ -354,25 +354,25 @@ namespace hex {
|
||||
|
||||
namespace impl {
|
||||
|
||||
std::map<std::string, View *> &getEntries() {
|
||||
static std::map<std::string, View *> views;
|
||||
std::map<std::string, std::unique_ptr<View>> &getEntries() {
|
||||
static std::map<std::string, std::unique_ptr<View>> views;
|
||||
|
||||
return views;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void impl::add(View *view) {
|
||||
void impl::add(std::unique_ptr<View> &&view) {
|
||||
log::debug("Registered new view: {}", view->getUnlocalizedName());
|
||||
|
||||
impl::getEntries().insert({ view->getUnlocalizedName(), view });
|
||||
impl::getEntries().insert({ view->getUnlocalizedName(), std::move(view) });
|
||||
}
|
||||
|
||||
View *getViewByName(const std::string &unlocalizedName) {
|
||||
View* getViewByName(const std::string &unlocalizedName) {
|
||||
auto &views = impl::getEntries();
|
||||
|
||||
if (views.contains(unlocalizedName))
|
||||
return views[unlocalizedName];
|
||||
return views[unlocalizedName].get();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace hex {
|
||||
return pressedShortcut;
|
||||
}
|
||||
|
||||
void ShortcutManager::process(View *currentView, bool ctrl, bool alt, bool shift, bool super, bool focused, u32 keyCode) {
|
||||
void ShortcutManager::process(const std::unique_ptr<View> ¤tView, bool ctrl, bool alt, bool shift, bool super, bool focused, u32 keyCode) {
|
||||
Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, keyCode);
|
||||
|
||||
if (focused && currentView->m_shortcuts.contains(pressedShortcut))
|
||||
|
||||
Reference in New Issue
Block a user