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::StateUpdateEnd
    

    but 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 onBaseEvent function I catch the NodeEraseBegin event 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


Log in to reply
 

Looks like your connection to SAMSON Connect - Forum was lost, please wait while we try to reconnect.