// schedule this object for deletion wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL; if ( traits ) { // let the traits object decide what to do with us traits->ScheduleForDestroy(this); } else // no app or no traits { // in wxBase we might have no app object at all, don't leak memory delete this; }