deps/obs-scripting: Allow NULL script with script_log
(This commit also modifies the frontend-tools module) Prevents a potential crash when script_log is called by a thread spawned by a python library.
This commit is contained in:
parent
c87597f7d6
commit
a2ae16e98c
@ -494,9 +494,14 @@ static void script_log(void *, obs_script_t *script, int log_level,
|
||||
const char *message)
|
||||
{
|
||||
QString qmsg;
|
||||
qmsg = QStringLiteral("[%1] %2").arg(
|
||||
obs_script_get_file(script),
|
||||
message);
|
||||
|
||||
if (script) {
|
||||
qmsg = QStringLiteral("[%1] %2").arg(
|
||||
obs_script_get_file(script),
|
||||
message);
|
||||
} else {
|
||||
qmsg = QStringLiteral("[Unknown Script] %1").arg(message);
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(scriptLogWindow, "AddLogMsg",
|
||||
Q_ARG(int, log_level),
|
||||
|
17
deps/obs-scripting/obs-scripting-logging.c
vendored
17
deps/obs-scripting/obs-scripting-logging.c
vendored
@ -28,14 +28,19 @@ void script_log_va(obs_script_t *script, int level, const char *format,
|
||||
const char *lang = "(Unknown)";
|
||||
size_t start_len;
|
||||
|
||||
switch (script->type) {
|
||||
case OBS_SCRIPT_LANG_UNKNOWN: lang = "(Unknown language)"; break;
|
||||
case OBS_SCRIPT_LANG_LUA: lang = "Lua"; break;
|
||||
case OBS_SCRIPT_LANG_PYTHON: lang = "Python"; break;
|
||||
if (script) {
|
||||
switch (script->type) {
|
||||
case OBS_SCRIPT_LANG_UNKNOWN: lang = "(Unknown language)"; break;
|
||||
case OBS_SCRIPT_LANG_LUA: lang = "Lua"; break;
|
||||
case OBS_SCRIPT_LANG_PYTHON: lang = "Python"; break;
|
||||
}
|
||||
|
||||
start_len = snprintf(msg, sizeof(msg), "[%s: %s] ",
|
||||
lang, script->file.array);
|
||||
} else {
|
||||
start_len = snprintf(msg, sizeof(msg), "[Unknown Script] ");
|
||||
}
|
||||
|
||||
start_len = snprintf(msg, sizeof(msg), "[%s: %s] ",
|
||||
lang, script->file.array);
|
||||
vsnprintf(msg + start_len, sizeof(msg) - start_len, format, args);
|
||||
|
||||
if (callback)
|
||||
|
6
deps/obs-scripting/obs-scripting-python.c
vendored
6
deps/obs-scripting/obs-scripting-python.c
vendored
@ -1193,7 +1193,11 @@ static PyObject *py_script_log_internal(PyObject *self, PyObject *args,
|
||||
|
||||
while (endl) {
|
||||
*endl = 0;
|
||||
script_log(&cur_python_script->base, log_level, "%s", start);
|
||||
if (cur_python_script)
|
||||
script_log(&cur_python_script->base, log_level, "%s",
|
||||
start);
|
||||
else
|
||||
script_log(NULL, log_level, "%s", start);
|
||||
*endl = '\n';
|
||||
|
||||
start = endl + 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user