mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-24 23:31:36 +08:00
obs-scripting: Make callback "removed" variable atomic
Makes the callback variable "removed" atomic, and on script unload, first sets all callbacks to removed before actually unloading the script out of a safety precaution. (See note at the bottom for further details) This minimizes the possibility of a race condition where the script callback could be called while those callbacks were being removed. Big note for this change, this change should eventually be replaced with a reference counting ownership method where script callbacks can hold a reference and share ownership of the script if it's still alive while the script callback is being called. That way the script callbacks can safely execute. May require a fair amount of reworking of the script object.
This commit is contained in:
+2
-2
@@ -280,7 +280,7 @@ static void frontend_save_callback(obs_data_t *save_data, bool saving,
|
||||
{
|
||||
struct python_obs_callback *cb = priv;
|
||||
|
||||
if (cb->base.removed) {
|
||||
if (script_callback_removed(&cb->base)) {
|
||||
obs_frontend_remove_save_callback(frontend_save_callback, cb);
|
||||
return;
|
||||
}
|
||||
@@ -355,7 +355,7 @@ static void frontend_event_callback(enum obs_frontend_event event, void *priv)
|
||||
{
|
||||
struct python_obs_callback *cb = priv;
|
||||
|
||||
if (cb->base.removed) {
|
||||
if (script_callback_removed(&cb->base)) {
|
||||
obs_frontend_remove_event_callback(frontend_event_callback, cb);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user