UI: Destroy the frontend API after OBS_FRONTEND_EVENT_EXIT

The frontend API was never explicitly cleaned up which has lead to
several crashes from plugins continuing to call it even after OBS itself
has been destroyed. We now destroy the API after the exit event, so
further calls by plugins will be no-ops instead of potentially accessing
destroyed OBS state.

This also required some changes to our own use of the API, as we relied
on the OBSBasic destructor to clean up some callbacks, by which point
the API should have already been destroyed.
This commit is contained in:
Richard Stanway
2023-02-28 23:34:44 +01:00
committed by Lain
parent f7eb634788
commit d997a56fb6
5 changed files with 11 additions and 9 deletions

View File

@@ -29,6 +29,9 @@ void OBSBasicStats::OBSFrontendEvent(enum obs_frontend_event event, void *ptr)
case OBS_FRONTEND_EVENT_RECORDING_STOPPED:
stats->ResetRecTimeLeft();
break;
case OBS_FRONTEND_EVENT_EXIT:
obs_frontend_remove_event_callback(OBSFrontendEvent, stats);
break;
default:
break;
}
@@ -234,8 +237,6 @@ void OBSBasicStats::closeEvent(QCloseEvent *event)
OBSBasicStats::~OBSBasicStats()
{
obs_frontend_remove_event_callback(OBSFrontendEvent, this);
delete shortcutFilter;
os_cpu_usage_info_destroy(cpu_info);
}