From 822ffb85196abfc931a76d6784f321777b95058c Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 3 Apr 2016 21:44:04 -0700 Subject: [PATCH] libobs: Add obs_obj_invalid function Determines whether an obs object was created successfully. If a plugin that's used for a saved object is removed (third party plugins), its data will become invalid, but the objects can often still be created for the sake of preserving user settings, but sometimes these objects can cause problems if they're actually used (such as using them for transitions). --- libobs/obs.c | 9 +++++++++ libobs/obs.h | 1 + 2 files changed, 10 insertions(+) diff --git a/libobs/obs.c b/libobs/obs.c index d3e8607da..3c93b8635 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -1831,3 +1831,12 @@ const char *obs_obj_get_id(void *obj) return NULL; } + +bool obs_obj_invalid(void *obj) +{ + struct obs_context_data *context = obj; + if (!context) + return true; + + return !context->data; +} diff --git a/libobs/obs.h b/libobs/obs.h index cc9b6cd9a..bba2d793f 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -575,6 +575,7 @@ enum obs_obj_type { EXPORT enum obs_obj_type obs_obj_get_type(void *obj); EXPORT const char *obs_obj_get_id(void *obj); +EXPORT bool obs_obj_invalid(void *obj); /* ------------------------------------------------------------------------- */