text-freetype2: Fix bug 0000151
Fix bug 0000151: File loading not properly handled. Link to bug: https://obsproject.com/mantis/view.php?id=151 A newly selected font is not loaded properly if "read from file" is active without a valid file. Old error handling lead to random memory being displayed. Closes Pull Request #390 (message edited by Jim)master
parent
7d3eedbcb0
commit
8a55f3bda7
|
@ -360,28 +360,37 @@ static void ft2_source_update(void *data, obs_data_t *settings)
|
|||
|
||||
if (srcdata->font_face)
|
||||
cache_standard_glyphs(srcdata);
|
||||
skip_font_load:;
|
||||
|
||||
skip_font_load:
|
||||
if (from_file) {
|
||||
const char *tmp = obs_data_get_string(settings, "text_file");
|
||||
if (!tmp || !*tmp) {
|
||||
blog(LOG_WARNING,
|
||||
"FT2-text: Failed to open %s for reading", tmp);
|
||||
goto error;
|
||||
|
||||
if (!tmp || !*tmp || !os_file_exists(tmp)) {
|
||||
const char *emptystr = " ";
|
||||
|
||||
bfree(srcdata->text);
|
||||
srcdata->text = NULL;
|
||||
|
||||
os_utf8_to_wcs_ptr(emptystr, strlen(emptystr),
|
||||
&srcdata->text);
|
||||
blog(LOG_WARNING, "FT2-text: Failed to open %s for "
|
||||
"reading", tmp);
|
||||
}
|
||||
else {
|
||||
if (srcdata->text_file != NULL &&
|
||||
strcmp(srcdata->text_file, tmp) == 0 &&
|
||||
!vbuf_needs_update)
|
||||
goto error;
|
||||
|
||||
if (srcdata->text_file != NULL &&
|
||||
strcmp(srcdata->text_file, tmp) == 0 &&
|
||||
!vbuf_needs_update)
|
||||
goto error;
|
||||
bfree(srcdata->text_file);
|
||||
|
||||
bfree(srcdata->text_file);
|
||||
|
||||
srcdata->text_file = bstrdup(tmp);
|
||||
if (chat_log_mode)
|
||||
read_from_end(srcdata, tmp);
|
||||
else
|
||||
load_text_from_file(srcdata, tmp);
|
||||
srcdata->last_checked = os_gettime_ns();
|
||||
srcdata->text_file = bstrdup(tmp);
|
||||
if (chat_log_mode)
|
||||
read_from_end(srcdata, tmp);
|
||||
else
|
||||
load_text_from_file(srcdata, tmp);
|
||||
srcdata->last_checked = os_gettime_ns();
|
||||
}
|
||||
}
|
||||
else {
|
||||
const char *tmp = obs_data_get_string(settings, "text");
|
||||
|
|
Loading…
Reference in New Issue