Skip to content
0
  • Recent
  • Tags
  • Popular
  • SAMSON Connect
  • Get SAMSON
  • Recent
  • Tags
  • Popular
  • SAMSON Connect
  • Get SAMSON
Collapse
SAMSON Forum
  1. Home
  2. Develop
  3. Apps
  4. How do you notify an app that the active document is closed ?

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

Scheduled Pinned Locked Moved Solved Apps
2 Posts 2 Posters 3.0k Views
  • 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
    C
    CLEMENT
    wrote on last edited by Admin
    #1

    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
    1
    • YassineY
      YassineY
      Yassine
      wrote on last edited by Yassine
      #2

      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
      1

      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
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Login or register to search.
      • First post
        Last post