views: Keep a reference to the handlers so that installs overlapping them don't kill them

This commit is contained in:
Olivier Galibert 2021-03-03 11:34:55 +01:00
parent 7a9e85c627
commit c57c3c9930
2 changed files with 11 additions and 0 deletions

View File

@ -1844,6 +1844,7 @@ public:
};
memory_view(device_t &device, std::string name);
~memory_view();
memory_view_entry &operator[](int slot);

View File

@ -637,6 +637,14 @@ memory_view::memory_view(device_t &device, std::string name) : m_device(device),
device.view_register(this);
}
memory_view::~memory_view()
{
if (m_handler_read) {
m_handler_read->unref();
m_handler_write->unref();
}
}
void memory_view::register_state()
{
m_device.machine().save().save_item(&m_device, "view", m_name.c_str(), 0, NAME(m_cur_slot));
@ -776,6 +784,8 @@ std::pair<handler_entry *, handler_entry *> memory_view::make_handlers(address_s
}
h_make(awidth, m_config->data_width(), m_config->addr_shift(), m_config->endianness(), space, *this, m_handler_read, m_handler_write);
m_handler_read->ref();
m_handler_write->ref();
}
return std::make_pair(m_handler_read, m_handler_write);