Observer/observable destruction management #788
Replies: 1 comment
-
Following the bug fix in #835, here is another way to fix #834
int verticeObserverId = core.vertexAttribs().getAttrib( handle ).attach( VerticesUpdater( disp, core ) );
ObservableVoid *observedVertices = core.vertexAttribs().getAttribPtr( handle );
// Prepare to disconnect observer at RenderObject deletion
auto signalManager = RadiumEngine::getInstance()->getSignalManager();
signalManager->getRenderObjectDestroyedNotifier().attach(
[verticeObserverId, observedVertices, observedRo](const Scene::ItemEntry&e) {
if (e.m_roIndex == observedRo)
observedVertices->detach(verticeObserverId) ;
}
); The lambda connected to the RenderObject destruction signal will disconnect the observers set on attribs by the function. As SignalManager sends this signal before RO deletion (and geometry/attrib deletion), the observer will be detached before the attrib is deleted, without being notified. I prefer the simpler solution proposed in #835 : observable should detach all observers in their destructor. |
Beta Was this translation helpful? Give feedback.
-
See beginning of the discussion here
Originally posted by @dlyr in #786 (comment)
Beta Was this translation helpful? Give feedback.
All reactions