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.
master
Skid-Inc 2017-06-27 11:14:26 +01:00
parent 2d84da2f7e
commit 2b085da63a
1 changed files with 7 additions and 1 deletions

View File

@ -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;
}
}
}