1
0
mirror of synced 2024-11-28 09:30:51 +01:00

fix: View registers causing crashes when being deleted

This commit is contained in:
WerWolv 2024-03-28 22:20:35 +01:00
parent cb1dcc2c9f
commit f084bc4147

View File

@ -9,15 +9,8 @@ namespace hex::plugin::builtin {
class ViewProvider : public hex::prv::Provider {
public:
explicit ViewProvider() {
EventProviderClosing::subscribe(this, [this](const prv::Provider *provider, bool*) {
if (m_provider == provider)
ImHexApi::Provider::remove(this, false);
});
}
~ViewProvider() override {
EventProviderClosing::unsubscribe(this);
}
ViewProvider() = default;
~ViewProvider() override = default;
[[nodiscard]] bool isAvailable() const override {
if (m_provider == nullptr)
@ -52,8 +45,20 @@ namespace hex::plugin::builtin {
m_provider->save();
}
[[nodiscard]] bool open() override { return m_provider != this; }
void close() override { }
[[nodiscard]] bool open() override {
if (m_provider == this)
return false;
EventProviderClosing::subscribe(this, [this](const prv::Provider *provider, bool*) {
if (m_provider == provider)
ImHexApi::Provider::remove(this, false);
});
return true;
}
void close() override {
EventProviderClosing::unsubscribe(this);
}
void resizeRaw(u64 newSize) override {
m_size = newSize;