obs-scripting: Fix compiler warnings

* obs-scripting: Fix unused 'varargs' warning

* obs-scripting: Fix PyEval deprecation warnings
Remove PyEval_InitThreads() and PyEval_ThreadsInitialized() call for
Python 3.7 and later as Python calls it automatically now.

This removes deprecation warnings when using Python 3.9 or later.

https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads
master
tytan652 2021-12-13 15:45:20 +01:00 committed by Jim
parent f4809b614e
commit c98617849a
2 changed files with 22 additions and 0 deletions

View File

@ -1644,9 +1644,11 @@ bool obs_scripting_load_python(const char *python_path)
dstr_free(&old_path);
#endif
#if PY_VERSION_HEX < 0x03070000
PyEval_InitThreads();
if (!PyEval_ThreadsInitialized())
return false;
#endif
/* ---------------------------------------------- */
/* Must set arguments for guis to work */

View File

@ -30,6 +30,15 @@
#include "obs-frontend-api.h"
#endif
/* Redefine SWIG_PYTHON_INITIALIZE_THREADS if:
* - Python version is 3.7 or later because PyEval_InitThreads() became deprecated and unnecessary
* - SWIG version is not 4.1 or later because SWIG_PYTHON_INITIALIZE_THREADS will be define correctly
* with Python 3.7 and later */
#if PY_VERSION_HEX >= 0x03070000 && SWIGVERSION < 0x040100
#undef SWIG_PYTHON_INITIALIZE_THREADS
#define SWIG_PYTHON_INITIALIZE_THREADS
#endif
%}
#define DEPRECATED_START
@ -82,6 +91,17 @@ static inline void wrap_blog(int log_level, const char *message)
%ignore obs_hotkey_pair_register_service;
%ignore obs_hotkey_pair_register_source;
/* The function gs_debug_marker_begin_format has a va_args.
* By default, SWIG just drop it and replace it with a single NULL pointer.
* Source: http://swig.org/Doc4.0/Varargs.html#Varargs_nn4
*
* But the generated wrapper will make the compiler emit a warning
* because varargs is an unused parameter.
* So in the check step, varargs will be treated like any unused parameter. */
%typemap(check) (const float color[4], const char *format, ...) {
(void)varargs;
}
%include "graphics/graphics.h"
%include "graphics/vec4.h"
%include "graphics/vec3.h"