void Request::ActionDialog::OnActionChoice(CppConsUI::Button& activator, size_t i, GCallback cb) { if (cb) reinterpret_cast<PurpleRequestActionCb>(cb)(user_data, i); /* It's possible that the callback action already called * purple_request_destroy() in which case 'this' object is already deleted * and calling Close() in such a case leads to an error. */ Requests *requests = &REQUEST->requests; if (requests->find(this) != requests->end()) Close(); }