Skip to content

Instantly share code, notes, and snippets.

@deephack1982
Created September 10, 2019 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deephack1982/2227441cfff80cf674b8f0636e7532f2 to your computer and use it in GitHub Desktop.
Save deephack1982/2227441cfff80cf674b8f0636e7532f2 to your computer and use it in GitHub Desktop.
class CWidget
{
...
public:
CEventListener* m_ppEventListeners;
int m_EventListenerCount;
private:
CWidget* m_pFirstChild;
CWidget* m_pSibling;
};
void DestroyWidget(CWidget *pRoot)
{
if(pRoot != 0)
{
if(pRoot->m_ppEventListeners != 0)
{
for(int j = 0; j < pRoot->m_EventListenerCount; ++j)
{
pRoot->m_ppEventListeners[j]->UnRegister(pRoot);
}
delete pRoot->m_ppEventListeners;
}
CWidget *pChild = pRoot->GetFirstChild();
while(pChild)
{
DestroyWidget(pChild);
pChild = pChild->GetSibling();
}
}
delete pRoot;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment