diff options
author | horchi <vdr@jwendel.de> | 2020-02-11 06:51:26 +0100 |
---|---|---|
committer | horchi <vdr@jwendel.de> | 2020-02-11 06:51:26 +0100 |
commit | 1e909e497d67231832f511ed5c1b609650766c09 (patch) | |
tree | b62965af29ddf74e95c6015a4d8b592b13658fe9 /lib | |
parent | 31b5956bf2b4e9e9815925d372fc3fe4472a4497 (diff) | |
download | vdr-epg-daemon-1e909e497d67231832f511ed5c1b609650766c09.tar.gz vdr-epg-daemon-1e909e497d67231832f511ed5c1b609650766c09.tar.bz2 |
2020-02-11: version 1.1.155 (horchi)\n - bugfix: Fixed crash due to wrong handling of python object (thx to Alexander Grothe)\n\n1.1.155
Diffstat (limited to 'lib')
-rw-r--r-- | lib/python.c | 12 | ||||
-rw-r--r-- | lib/python.h | 1 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/python.c b/lib/python.c index da6f25e..f857c94 100644 --- a/lib/python.c +++ b/lib/python.c @@ -8,6 +8,7 @@ #include "python.h" cDbTable* Python::globalEventsDb = 0; +int Python::usages = 0; int Python::globalNamingMode = 0; const char* Python::globalTmplExpression = ""; @@ -221,14 +222,16 @@ int Python::init(const char* modulePath) #if PY_MAJOR_VERSION >= 3 PyImport_AppendInittab("event", &PyInitEvent); - Py_Initialize(); // initialize the Python interpreter + if (!usages) Py_Initialize(); // initialize the Python interpreter pName = PyUnicode_FromString(file); #else - Py_Initialize(); // initialize the Python interpreter + if (!usages) Py_Initialize(); // initialize the Python interpreter Py_InitModule("event", eventMethods); pName = PyString_FromString(file); #endif + usages++; + // add search path for Python modules if (modulePath) @@ -272,13 +275,16 @@ int Python::init(const char* modulePath) int Python::exit() { + usages--; + if (pFunc) Py_XDECREF(pFunc); if (pModule) Py_DECREF(pModule); - Py_Finalize(); + if (!usages) + Py_Finalize(); return success; } diff --git a/lib/python.h b/lib/python.h index eb50964..e240992 100644 --- a/lib/python.h +++ b/lib/python.h @@ -63,6 +63,7 @@ class Python // static stuff + static int usages; static cDbTable* globalEventsDb; static int globalNamingMode; static const char* globalTmplExpression; |