Browse Source

frontend-tools: Fix a few issues with the clock source script

Fix the image files not being freed, and remove the unused source
definition function 'update', which was additionally calling
image_source_load with the wrong number of parameters.
jp9000 7 years ago
parent
commit
f956203764
1 changed files with 21 additions and 16 deletions
  1. 21 16
      UI/frontend-plugins/frontend-tools/data/scripts/clock-source.lua

+ 21 - 16
UI/frontend-plugins/frontend-tools/data/scripts/clock-source.lua

@@ -5,6 +5,22 @@ source_def = {}
 source_def.id = "lua_clock_source"
 source_def.output_flags = bit.bor(obs.OBS_SOURCE_VIDEO, obs.OBS_SOURCE_CUSTOM_DRAW)
 
+function image_source_load(image, file)
+	obs.obs_enter_graphics();
+	obs.gs_image_file_free(image);
+	obs.obs_leave_graphics();
+
+	obs.gs_image_file_init(image, file);
+
+	obs.obs_enter_graphics();
+	obs.gs_image_file_init_texture(image);
+	obs.obs_leave_graphics();
+
+	if not image.loaded then
+		print("failed to load texture " .. file);
+	end
+end
+
 source_def.get_name = function()
 	return "Lua Clock"
 end
@@ -24,24 +40,13 @@ source_def.create = function(source, settings)
 	return data
 end
 
-function image_source_load(image, file)
+source_def.destroy = function(data)
 	obs.obs_enter_graphics();
-	obs.gs_image_file_free(image);
+	obs.gs_image_file_free(data.image);
+	obs.gs_image_file_free(data.hour_image);
+	obs.gs_image_file_free(data.minute_image);
+	obs.gs_image_file_free(data.second_image);
 	obs.obs_leave_graphics();
-
-	obs.gs_image_file_init(image, file);
-
-	obs.obs_enter_graphics();
-	obs.gs_image_file_init_texture(image);
-	obs.obs_leave_graphics();
-
-	if not image.loaded then
-		print("failed to load texture " .. file);
-	end
-end
-
-source_def.update = function(data, settings)
-	image_source_load(data)
 end
 
 source_def.video_render = function(data, effect)