add some ctx cleanup
This commit is contained in:
parent
a4092298fb
commit
14f751af0b
@ -11,8 +11,8 @@
|
||||
#include <limits>
|
||||
#include <iostream>
|
||||
|
||||
static std::unique_ptr<MessageFragmentStore> g_mfs = nullptr;
|
||||
static std::unique_ptr<Backends::FilesystemStorage> g_fsb = nullptr;
|
||||
static std::unique_ptr<MessageFragmentStore> g_mfs = nullptr;
|
||||
|
||||
constexpr const char* plugin_name = "MessageFragmentStore";
|
||||
|
||||
@ -62,6 +62,7 @@ SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) {
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT float solana_plugin_tick(float time_delta) {
|
||||
// HACK
|
||||
static bool scan_triggered {false};
|
||||
if (!scan_triggered) {
|
||||
g_fsb->scanAsync();
|
||||
|
@ -81,6 +81,7 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) {
|
||||
}
|
||||
|
||||
_potentially_dirty_contacts.emplace(m.registry()->ctx().get<Contact3>()); // always mark dirty here
|
||||
_touched_contacts.emplace(m.registry()->ctx().get<Contact3>());
|
||||
if (m.any_of<Message::Components::ViewCurserBegin, Message::Components::ViewCurserEnd>()) {
|
||||
// not an actual message, but we probalby need to check and see if we need to load fragments
|
||||
//std::cout << "MFS: new or updated curser\n";
|
||||
@ -94,6 +95,7 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) {
|
||||
}
|
||||
// TODO: check if file object has id
|
||||
|
||||
|
||||
// TODO: use fid, saving full fuid for every message consumes alot of memory (and heap frag)
|
||||
if (!m.all_of<Message::Components::MFSObj>()) {
|
||||
std::cout << "MFS: new msg missing Object\n";
|
||||
@ -538,6 +540,15 @@ MessageFragmentStore::~MessageFragmentStore(void) {
|
||||
_fs_ignore_event = false;
|
||||
_frag_save_queue.pop_front(); // pop unconditionally
|
||||
}
|
||||
|
||||
for (const auto c : _touched_contacts) {
|
||||
auto* mr_ptr = static_cast<const RegistryMessageModelI&>(_rmm).get(c);
|
||||
if (mr_ptr != nullptr) {
|
||||
mr_ptr->ctx().erase<Message::Contexts::OpenFragments>();
|
||||
mr_ptr->ctx().erase<Message::Contexts::ContactFragments>();
|
||||
mr_ptr->ctx().erase<Message::Contexts::LoadedContactFragments>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// checks range against all cursers in msgreg
|
||||
@ -872,6 +883,7 @@ bool MessageFragmentStore::onEvent(const ObjectStore::Events::ObjectConstruct& e
|
||||
// TODO: this is an erroious path
|
||||
return false;
|
||||
}
|
||||
_touched_contacts.emplace(frag_contact);
|
||||
|
||||
if (!msg_reg->ctx().contains<Message::Contexts::ContactFragments>()) {
|
||||
msg_reg->ctx().emplace<Message::Contexts::ContactFragments>();
|
||||
@ -928,6 +940,7 @@ bool MessageFragmentStore::onEvent(const ObjectStore::Events::ObjectUpdate& e) {
|
||||
// TODO: this is an erroious path
|
||||
return false;
|
||||
}
|
||||
_touched_contacts.emplace(frag_contact);
|
||||
|
||||
if (!msg_reg->ctx().contains<Message::Contexts::ContactFragments>()) {
|
||||
msg_reg->ctx().emplace<Message::Contexts::ContactFragments>();
|
||||
|
@ -86,6 +86,9 @@ class MessageFragmentStore : public RegistryMessageModelEventI, public ObjectSto
|
||||
// so we need to keep them dirty until nothing was loaded.
|
||||
entt::dense_set<Contact3> _potentially_dirty_contacts;
|
||||
|
||||
// for cleaning up the ctx vars we create
|
||||
entt::dense_set<Contact3> _touched_contacts;
|
||||
|
||||
public:
|
||||
MessageFragmentStore(
|
||||
Contact3Registry& cr,
|
||||
|
Loading…
Reference in New Issue
Block a user