From 0e916ebbf7c531557504549d2cc34bf6ebb24a0d Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Wed, 25 Aug 2021 00:54:32 +0200 Subject: [PATCH] Fix myCount() not being updated before thingRemoved in python plugins --- libnymea-core/integrations/pythonintegrationplugin.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libnymea-core/integrations/pythonintegrationplugin.cpp b/libnymea-core/integrations/pythonintegrationplugin.cpp index 3bdedb41..bd25058f 100644 --- a/libnymea-core/integrations/pythonintegrationplugin.cpp +++ b/libnymea-core/integrations/pythonintegrationplugin.cpp @@ -89,7 +89,7 @@ PyObject *PythonIntegrationPlugin::pyMyThings(PyObject *self, PyObject */*args*/ qCWarning(dcThingManager()) << "Cannot find plugin instance for this python module."; return nullptr; } - + plugin->m_mutex.lock(); PyObject* result = PyTuple_New(plugin->m_things.count()); for (int i = 0; i < plugin->m_things.count(); i++) { @@ -540,7 +540,6 @@ void PythonIntegrationPlugin::setupThing(ThingSetupInfo *info) connect(info->thing(), &Thing::destroyed, this, [=](){ PyEval_RestoreThread(m_threadState); - m_things.remove(thing); pyThing->thing = nullptr; Py_DECREF(pyThing); m_threadPool->setMaxThreadCount(m_threadPool->maxThreadCount() - 1); @@ -595,7 +594,7 @@ void PythonIntegrationPlugin::executeAction(ThingActionInfo *info) void PythonIntegrationPlugin::thingRemoved(Thing *thing) { - PyThing *pyThing = m_things.value(thing); + PyThing *pyThing = m_things.take(thing); callPluginFunction("thingRemoved", reinterpret_cast(pyThing)); }