diff --git a/UI/obs-frontend-api/obs-frontend-api.cpp b/UI/obs-frontend-api/obs-frontend-api.cpp index 34747fc07..df753551b 100644 --- a/UI/obs-frontend-api/obs-frontend-api.cpp +++ b/UI/obs-frontend-api/obs-frontend-api.cpp @@ -13,7 +13,7 @@ void obs_frontend_set_callbacks_internal(obs_frontend_callbacks *callbacks) static inline bool callbacks_valid_(const char *func_name) { if (!c) { - blog(LOG_WARNING, "Tried to call %s with no callbacks!", + blog(LOG_ERROR, "Tried to call %s with no callbacks!", func_name); return false; } diff --git a/UI/source-tree.cpp b/UI/source-tree.cpp index 8fb21918e..dd7af31f4 100644 --- a/UI/source-tree.cpp +++ b/UI/source-tree.cpp @@ -640,6 +640,9 @@ void SourceTreeModel::OBSFrontendEvent(enum obs_frontend_event event, void *ptr) stm->SceneChanged(); break; case OBS_FRONTEND_EVENT_EXIT: + stm->Clear(); + obs_frontend_remove_event_callback(OBSFrontendEvent, stm); + break; case OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP: stm->Clear(); break; @@ -860,11 +863,6 @@ SourceTreeModel::SourceTreeModel(SourceTree *st_) obs_frontend_add_event_callback(OBSFrontendEvent, this); } -SourceTreeModel::~SourceTreeModel() -{ - obs_frontend_remove_event_callback(OBSFrontendEvent, this); -} - int SourceTreeModel::rowCount(const QModelIndex &parent) const { return parent.isValid() ? 0 : items.count(); diff --git a/UI/source-tree.hpp b/UI/source-tree.hpp index 1e4139751..0ab3ad80f 100644 --- a/UI/source-tree.hpp +++ b/UI/source-tree.hpp @@ -132,7 +132,6 @@ class SourceTreeModel : public QAbstractListModel { public: explicit SourceTreeModel(SourceTree *st); - ~SourceTreeModel(); virtual int rowCount(const QModelIndex &parent) const override; virtual QVariant data(const QModelIndex &index, diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 29bfcecac..bafd4666c 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -5076,6 +5076,10 @@ void OBSBasic::closeEvent(QCloseEvent *event) if (api) api->on_event(OBS_FRONTEND_EVENT_EXIT); + // Destroys the frontend API so plugins can't continue calling it + obs_frontend_set_callbacks_internal(nullptr); + api = nullptr; + QMetaObject::invokeMethod(App(), "quit", Qt::QueuedConnection); } diff --git a/UI/window-basic-stats.cpp b/UI/window-basic-stats.cpp index 732dba2d0..c3acee73d 100644 --- a/UI/window-basic-stats.cpp +++ b/UI/window-basic-stats.cpp @@ -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); }