Created
August 7, 2012 03:34
-
-
Save jeffomatic/3281169 to your computer and use it in GitHub Desktop.
blog: jl_signal, code: boy scout principle of signal disconnection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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