1
0
mirror of synced 2024-11-24 15:50:16 +01:00

impr: Automatically remove null provider if another one is opened

This commit is contained in:
WerWolv 2023-12-07 11:20:37 +01:00
parent 00a24bc84b
commit bfb2c6ab5f

View File

@ -1,13 +1,24 @@
#pragma once
#include <hex/providers/provider.hpp>
#include <hex/api/event_manager.hpp>
namespace hex::plugin::builtin {
class NullProvider : public hex::prv::Provider {
public:
explicit NullProvider() = default;
~NullProvider() override = default;
NullProvider() {
EventManager::subscribe<EventProviderOpened>([this](auto *newProvider) {
if (newProvider == this)
return;
ImHexApi::Provider::remove(this, true);
});
}
~NullProvider() override {
EventManager::unsubscribe<EventProviderOpened>(this);
}
[[nodiscard]] bool isAvailable() const override { return true; }
[[nodiscard]] bool isReadable() const override { return true; }