Skip to content

Commit

Permalink
[JSONRPC] Drop lazy registering to ConnectionServer notifications (rd…
Browse files Browse the repository at this point in the history
…kcentral#1574)

Co-authored-by: Pierre Wielders <[email protected]>
  • Loading branch information
sebaszm and pwielders authored Apr 21, 2024
1 parent 259c1bb commit 33bff2f
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions Source/plugins/JSONRPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,17 +719,16 @@ namespace PluginHost {
_service->AddRef();
_callsign = _service->Callsign();

_service->Register(&_notification);

_adminLock.Unlock();
}
void Deactivate() override
{
_adminLock.Lock();

if (_service != nullptr) {
if (_observers.empty() == false) {
_service->Unregister(&_notification);
}

_service->Unregister(&_notification);
_service->Release();
_service = nullptr;
}
Expand Down Expand Up @@ -807,12 +806,6 @@ namespace PluginHost {
ObserverMap::iterator index = _observers.find(eventId);

if (index == _observers.end()) {

if (_observers.empty() == true) {
ASSERT(_service != nullptr);
_service->Register(&_notification);
}

index = _observers.emplace(std::piecewise_construct,
std::forward_as_tuple(eventId),
std::forward_as_tuple()).first;
Expand All @@ -837,9 +830,6 @@ namespace PluginHost {

if ((result == Core::ERROR_NONE) && (index->second.IsEmpty() == true)) {
_observers.erase(index);

ASSERT(_service != nullptr);
_service->Unregister(&_notification);
}
}

Expand All @@ -861,12 +851,6 @@ namespace PluginHost {

if (index->second.IsEmpty() == true) {
index = _observers.erase(index);

if (_observers.empty() == true) {
ASSERT(_service != nullptr);

_service->Unregister(&_notification);
}
}
else {
index++;
Expand Down

0 comments on commit 33bff2f

Please sign in to comment.