Skip to content

Instantly share code, notes, and snippets.

@jeffomatic
Created August 7, 2012 03:34
Show Gist options
  • Save jeffomatic/3281169 to your computer and use it in GitHub Desktop.
Save jeffomatic/3281169 to your computer and use it in GitHub Desktop.
blog: jl_signal, code: boy scout principle of signal disconnection
// The "Boy Scout" principle of signal disconnection:
// clean up your own mess!
class ExampleContext
{
void Init()
{
m_pButton = new Button();
m_pWindow = new Window();
m_pButton->ClickSignal()->Connect( m_pWindow, &Window::Open );
}
void Deinit()
{
m_pButton->ClickSignal()->Disconnect( m_pWindow, &Window::Open );
delete m_pWindow; m_pWindow = 0;
delete m_pButton; m_pButton = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment