SAMSON Forum
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • SAMSON Connect
    • Get SAMSON

    Solved How do you notify an app that the active document is closed ?

    Apps
    2
    2
    2114
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      CLEMENT last edited by Admin

      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...

      1 Reply Last reply Reply Quote 1
      • Yassine
        Yassine last edited by Yassine

        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

        1 Reply Last reply Reply Quote 1
        • Yassine
          Yassine last edited by Yassine

          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

          1 Reply Last reply Reply Quote 1
          • First post
            Last post