Browse Source

libobs: Always free effect if not cached

Fix an issue where effects that fail to compile will not properly free
their data if they cannot not be parsed or compiled.
jp9000 10 years ago
parent
commit
ea8327ce5b
3 changed files with 3 additions and 1 deletions
  1. 1 1
      libobs/graphics/effect.c
  2. 1 0
      libobs/graphics/effect.h
  3. 1 0
      libobs/graphics/graphics.c

+ 1 - 1
libobs/graphics/effect.c

@@ -30,7 +30,7 @@ void gs_effect_actually_destroy(gs_effect_t *effect)
 void gs_effect_destroy(gs_effect_t *effect)
 {
 	if (effect) {
-		if (!effect->effect_path)
+		if (!effect->cached)
 			gs_effect_actually_destroy(effect);
 	}
 }

+ 1 - 0
libobs/graphics/effect.h

@@ -137,6 +137,7 @@ static inline void effect_technique_free(struct gs_effect_technique *t)
 
 struct gs_effect {
 	bool processing;
+	bool cached;
 	char *effect_path, *effect_dir;
 
 	DARRAY(struct gs_effect_param) params;

+ 1 - 0
libobs/graphics/graphics.c

@@ -732,6 +732,7 @@ gs_effect_t *gs_effect_create(const char *effect_string, const char *filename,
 		pthread_mutex_lock(&thread_graphics->effect_mutex);
 
 		if (effect->effect_path) {
+			effect->cached = true;
 			effect->next = thread_graphics->first_effect;
 			thread_graphics->first_effect = effect;
 		}