Fix myCount() not being updated before thingRemoved in python plugins

This commit is contained in:
Michael Zanetti 2021-08-25 00:54:32 +02:00
parent 685450fdb3
commit 0e916ebbf7

View File

@ -540,7 +540,6 @@ 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);
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);
@ -595,7 +594,7 @@ void PythonIntegrationPlugin::executeAction(ThingActionInfo *info)
void PythonIntegrationPlugin::thingRemoved(Thing *thing) void PythonIntegrationPlugin::thingRemoved(Thing *thing)
{ {
PyThing *pyThing = m_things.value(thing); PyThing *pyThing = m_things.take(thing);
callPluginFunction("thingRemoved", reinterpret_cast<PyObject*>(pyThing)); callPluginFunction("thingRemoved", reinterpret_cast<PyObject*>(pyThing));
} }