提交 8a55f3bd 编写于 作者: M Manuel Kroeber 提交者: jp9000

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)
上级 7d3eedbc
......@@ -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 (srcdata->text_file != NULL &&
strcmp(srcdata->text_file, tmp) == 0 &&
!vbuf_needs_update)
goto error;
if (!tmp || !*tmp || !os_file_exists(tmp)) {
const char *emptystr = " ";
bfree(srcdata->text_file);
bfree(srcdata->text);
srcdata->text = NULL;
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();
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;
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();
}
}
else {
const char *tmp = obs_data_get_string(settings, "text");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册