mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-07-28 16:16:21 -04:00
UI: Add cleanup of stats callback on window close
Moving the cleanup to OBS_FRONTEND_EVENT_EXIT in #8735 only handled the cleanup from the dockable window, as the regular stats window is deleted on close when the UI is shut down. This caused an event handler leak each time the window is manually closed, resulting in crashes. This code looks a bit wrong since we delete the same handler in multiple places, but this is due to the code being used by both the dock (non-closable) and the window (closable). The OBS_FRONTEND_EVENT_EXIT handler handles cleanup from the dockable stats window, and the window close handler now handles cleanup from the non-dockable stats window.
This commit is contained in:
@@ -30,6 +30,9 @@ void OBSBasicStats::OBSFrontendEvent(enum obs_frontend_event event, void *ptr)
|
||||
stats->ResetRecTimeLeft();
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_EXIT:
|
||||
// This is only reached when the non-closable (dock) stats
|
||||
// window is being cleaned up. Thee closable stats window is
|
||||
// already gone by this point as it's deleted on close.
|
||||
obs_frontend_remove_event_callback(OBSFrontendEvent, stats);
|
||||
break;
|
||||
default:
|
||||
@@ -231,6 +234,10 @@ void OBSBasicStats::closeEvent(QCloseEvent *event)
|
||||
config_save_safe(main->Config(), "tmp", nullptr);
|
||||
}
|
||||
|
||||
// This code is only reached when the non-dockable stats window is
|
||||
// manually closed or OBS is exiting.
|
||||
obs_frontend_remove_event_callback(OBSFrontendEvent, this);
|
||||
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user