From bfb2c6ab5f65f3adc707ce0ea3333b16d87401ea Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 7 Dec 2023 11:20:37 +0100 Subject: [PATCH] impr: Automatically remove null provider if another one is opened --- .../include/content/providers/null_provider.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/builtin/include/content/providers/null_provider.hpp b/plugins/builtin/include/content/providers/null_provider.hpp index 9658fa71e..ff3a3e328 100644 --- a/plugins/builtin/include/content/providers/null_provider.hpp +++ b/plugins/builtin/include/content/providers/null_provider.hpp @@ -1,13 +1,24 @@ #pragma once #include +#include namespace hex::plugin::builtin { class NullProvider : public hex::prv::Provider { public: - explicit NullProvider() = default; - ~NullProvider() override = default; + NullProvider() { + EventManager::subscribe([this](auto *newProvider) { + if (newProvider == this) + return; + + ImHexApi::Provider::remove(this, true); + }); + } + + ~NullProvider() override { + EventManager::unsubscribe(this); + } [[nodiscard]] bool isAvailable() const override { return true; } [[nodiscard]] bool isReadable() const override { return true; }