How do UN-subscribe from an event?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

How do UN-subscribe from an event?

Postby Van » Sat Apr 01, 2006 04:56

How does one UN-subscribe from an event?

Code: Select all

   while ( mCur )
   {
      mNext = mCur->NextItem;
      if ( mCur->mDWSlotRow )
      {
         mCur->mSISlotBox->removeEvent( CEGUI::StaticImage::EventDragDropItemDropped );
         mCur->mSISlotBox->removeEvent( CEGUI::StaticImage::EventChildAdded );
         mCur->mSISlotBox->removeEvent( CEGUI::StaticImage::EventChildRemoved );

         if ( mCur->GUIInvItemEquip )
         {
            mCur->mSISlotBox->removeChildWindow( mCur->GUIInvItemEquip->getDragContainer() );
            delete mCur->GUIInvItemEquip;
         }

         mWinMgr->destroyWindow( mCur->mDWSlotRow );
      }

      delete mCur;
      mCur = mNext;
   }



Causes me all kinds of grief when mWinMgr->destroyWindow( mCur->mDWSlotRow ); gets called.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Sun Apr 02, 2006 09:00

Hi,

When you subscribe to an event, you are returned an instance of Event::Connection, you can use this object to keep track of, and disconnect, from the event.

There is also an Event::ScopedConnection which will auto-disconnect from the event when the ScopedConnection object goes out of scope (is destroyed).

You may also find this topic of interest.

HTH

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 13 guests