 la_mojo nodes and modules: register for events only when fully built
A handler was registered in the basicEventHandler constructor (before
the derived members existed) and removed in its destructor (after they
were destroyed): the event heap could call dispatchEvent() on a half-
built or half-destroyed node or module when one was created or deleted
while la_mojo runs (node / module reload).
- Camera nodes (deviceNodePTZCamControl, deviceNodePresetCamControl,
deviceNodeStaticCamControl): basicEventHandler(false), attachEvents()
at the end of both constructors, detachEvents() first thing in the
destructor.
- Kernel modules: kernelModule no longer registers in its constructor;
kernelModuleFactory attaches a module right after creating it (all
modules are created there), before startService(). Every module
destructor (USB relay, Kafka, FlyHunter, SSDP, ONVIF observer, embed
video (both variants), modem manager, Bosch, attention cloud, report
backupper) calls detachEvents() first.
- basicEventHeap::moveHandlerTop/Bottom no longer register a handler
that is not registered (would have registered an object twice once
attachEvents() runs).
Sensor nodes are not event handlers and are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
55 minutes ago  la_mojo nodes and modules: register for events only when fully built
A handler was registered in the basicEventHandler constructor (before
the derived members existed) and removed in its destructor (after they
were destroyed): the event heap could call dispatchEvent() on a half-
built or half-destroyed node or module when one was created or deleted
while la_mojo runs (node / module reload).
- Camera nodes (deviceNodePTZCamControl, deviceNodePresetCamControl,
deviceNodeStaticCamControl): basicEventHandler(false), attachEvents()
at the end of both constructors, detachEvents() first thing in the
destructor.
- Kernel modules: kernelModule no longer registers in its constructor;
kernelModuleFactory attaches a module right after creating it (all
modules are created there), before startService(). Every module
destructor (USB relay, Kafka, FlyHunter, SSDP, ONVIF observer, embed
video (both variants), modem manager, Bosch, attention cloud, report
backupper) calls detachEvents() first.
- basicEventHeap::moveHandlerTop/Bottom no longer register a handler
that is not registered (would have registered an object twice once
attachEvents() runs).
Sensor nodes are not event handlers and are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
55 minutes ago |
|
#include "kernelModule.h"
#ifdef USE_MYSQL
#include "MySQL_dataBinder.h"
#else
#include "SQLite_dataBinder.h"
#endif
// Not registered for events here: the derived module's members are not built yet. The module factory
// calls attachEvents() once the module is constructed; each module calls detachEvents() first thing in
// its destructor.
kernelModule::kernelModule(uint32_t id, KERNEL_MODULE_TYPE type) : basicEventHandler(false), basicEngine(){ m_pLog = basicLogCollection::getInstance();#ifdef USE_MYSQL
m_pDBC = mysqlDBC::getInstance();#else
m_pDBC = sqliteDBC::getInstance();#endif
// m_pKernel = argusKernel::getInstance();
m_eType = type; m_nDBID = id; m_bDetached = false; m_bEnabled = false; m_nDBAUXID = 0;
// Clear Events flags
if (m_pDBC) { DBC_MODULE_DATA * tData = NULL; tData = m_pDBC->getModuleData(m_nDBID); if (tData) { m_nDBAUXID = tData->aux_id; m_bEnabled = tData->enabled; free(tData); }; }; for (int i = 0; i < EVT_COUNT; i++) { m_bEvtFlags[i] = false; }}
kernelModule::~kernelModule() {}
|