How do you notify an app that the active document is closed ?
-
How do you notify an app that the active document is closed ?
Problem statement:
My app is currently listening to a state updater event:SBSimulatorEvent::StateUpdateEndbut when I close the document my app is not notified and tries to address some elements that are not anymore in the datagraph and therefore crash...
-
Hi Clement,
To listen to the document closed signal I connect my nodes to a custom signal like this:
SB_FOR(SBNode* node, atomIndexer) node->connectBaseSignalToSlot(this, SB_SLOT(&SENormalModesAnalysisApp::onBaseEvent));Then, in my
onBaseEventfunction I catch theNodeEraseBeginevent which corresponds to the signal emitted when the document is closed or the nodes erased.void SENormalModesAnalysisApp::onBaseEvent(SBBaseEvent* event) { if (event->getType() == SBBaseEvent::NodeEraseBegin) { //disconnet the connected nodes SB_FOR(SBNode* node, atomIndexer) {node->disconnectBaseSignalFromSlot(this, SB_SLOT(&SENormalModesAnalysisApp::onBaseEvent)); } //....// }Remember to disconnect the connected nodes.
Hope I answered your question,
Yassine
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login