Browse Source

obs-text: Fix file reader occasionally not updating

Delayed reading the text file till the update after the timestamp
changes, this should fix a minor issue where if the file updates twice
in one second, only the first change it displayed.
Skid-Inc 8 years ago
parent
commit
2b085da63a
1 changed files with 7 additions and 1 deletions
  1. 7 1
      plugins/obs-text/gdiplus/obs-text.cpp

+ 7 - 1
plugins/obs-text/gdiplus/obs-text.cpp

@@ -197,6 +197,7 @@ struct TextSource {
 	bool read_from_file = false;
 	string file;
 	time_t file_timestamp = 0;
+	bool update_file = false;
 	float update_time_elapsed = 0.0f;
 
 	wstring text;
@@ -775,10 +776,15 @@ inline void TextSource::Tick(float seconds)
 		time_t t = get_modified_timestamp(file.c_str());
 		update_time_elapsed = 0.0f;
 
-		if (file_timestamp != t) {
+		if (update_file) {
 			LoadFileText();
 			RenderText();
+			update_file = false;
+		}
+
+		if (file_timestamp != t) {
 			file_timestamp = t;
+			update_file = true;
 		}
 	}
 }