impr: Automatically remove null provider if another one is opened
This commit is contained in:
parent
00a24bc84b
commit
bfb2c6ab5f
@ -1,13 +1,24 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hex/providers/provider.hpp>
|
#include <hex/providers/provider.hpp>
|
||||||
|
#include <hex/api/event_manager.hpp>
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
class NullProvider : public hex::prv::Provider {
|
class NullProvider : public hex::prv::Provider {
|
||||||
public:
|
public:
|
||||||
explicit NullProvider() = default;
|
NullProvider() {
|
||||||
~NullProvider() override = default;
|
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 isAvailable() const override { return true; }
|
||||||
[[nodiscard]] bool isReadable() const override { return true; }
|
[[nodiscard]] bool isReadable() const override { return true; }
|
||||||
|
Loading…
Reference in New Issue
Block a user