Fix cleaning up things when a setup fails in python plugins
This commit is contained in:
parent
28d2f53261
commit
2596eb46b6
@ -544,6 +544,7 @@ void PythonIntegrationPlugin::setupThing(ThingSetupInfo *info)
|
|||||||
|
|
||||||
connect(info->thing(), &Thing::destroyed, this, [=](){
|
connect(info->thing(), &Thing::destroyed, this, [=](){
|
||||||
PyEval_RestoreThread(m_threadState);
|
PyEval_RestoreThread(m_threadState);
|
||||||
|
m_things.remove(thing); // In case thingRemoved is never called (e.g. failed setup) it needs to be removed too
|
||||||
pyThing->thing = nullptr;
|
pyThing->thing = nullptr;
|
||||||
Py_DECREF(pyThing);
|
Py_DECREF(pyThing);
|
||||||
m_threadPool->setMaxThreadCount(m_threadPool->maxThreadCount() - 1);
|
m_threadPool->setMaxThreadCount(m_threadPool->maxThreadCount() - 1);
|
||||||
@ -598,7 +599,7 @@ void PythonIntegrationPlugin::executeAction(ThingActionInfo *info)
|
|||||||
|
|
||||||
void PythonIntegrationPlugin::thingRemoved(Thing *thing)
|
void PythonIntegrationPlugin::thingRemoved(Thing *thing)
|
||||||
{
|
{
|
||||||
PyThing *pyThing = m_things.take(thing);
|
PyThing *pyThing = m_things.take(thing); // removing thing from myThings() before the thingRemoved call
|
||||||
callPluginFunction("thingRemoved", reinterpret_cast<PyObject*>(pyThing));
|
callPluginFunction("thingRemoved", reinterpret_cast<PyObject*>(pyThing));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user