- // this will delete this object itself
- wxPersistenceManager::Get().SaveAndUnregister(GetWindow());
+ // only react to the destruction of this object itself, not of any of
+ // its children
+ if ( event.GetEventObject() == GetObject() )
+ {
+ // this will delete this object itself
+ wxPersistenceManager::Get().SaveAndUnregister(GetWindow());
+ }