Fix shutdown
This commit is contained in:
parent
b870140608
commit
78e37f0d87
@ -274,7 +274,7 @@ PythonIntegrationPlugin::PythonIntegrationPlugin(QObject *parent) : IntegrationP
|
|||||||
|
|
||||||
PythonIntegrationPlugin::~PythonIntegrationPlugin()
|
PythonIntegrationPlugin::~PythonIntegrationPlugin()
|
||||||
{
|
{
|
||||||
PyGILState_Ensure();
|
PyGILState_STATE s = PyGILState_Ensure();
|
||||||
|
|
||||||
while (!m_runningThreads.isEmpty()) {
|
while (!m_runningThreads.isEmpty()) {
|
||||||
PyObject *loop = m_runningThreads.keys().first();
|
PyObject *loop = m_runningThreads.keys().first();
|
||||||
@ -283,7 +283,7 @@ PythonIntegrationPlugin::~PythonIntegrationPlugin()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Py_XDECREF(s_plugins.take(this));
|
Py_XDECREF(s_plugins.take(this));
|
||||||
Py_FinalizeEx();
|
PyGILState_Release(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PythonIntegrationPlugin::initPython()
|
void PythonIntegrationPlugin::initPython()
|
||||||
@ -302,6 +302,13 @@ void PythonIntegrationPlugin::initPython()
|
|||||||
s_mainThread = PyEval_SaveThread();
|
s_mainThread = PyEval_SaveThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PythonIntegrationPlugin::deinitPython()
|
||||||
|
{
|
||||||
|
PyEval_RestoreThread(s_mainThread);
|
||||||
|
|
||||||
|
Py_FinalizeEx();
|
||||||
|
}
|
||||||
|
|
||||||
bool PythonIntegrationPlugin::loadScript(const QString &scriptFile)
|
bool PythonIntegrationPlugin::loadScript(const QString &scriptFile)
|
||||||
{
|
{
|
||||||
QFileInfo fi(scriptFile);
|
QFileInfo fi(scriptFile);
|
||||||
|
|||||||
@ -22,6 +22,7 @@ public:
|
|||||||
~PythonIntegrationPlugin();
|
~PythonIntegrationPlugin();
|
||||||
|
|
||||||
static void initPython();
|
static void initPython();
|
||||||
|
static void deinitPython();
|
||||||
|
|
||||||
bool loadScript(const QString &scriptFile);
|
bool loadScript(const QString &scriptFile);
|
||||||
|
|
||||||
|
|||||||
@ -101,6 +101,7 @@ ThingManagerImplementation::ThingManagerImplementation(HardwareManager *hardware
|
|||||||
|
|
||||||
ThingManagerImplementation::~ThingManagerImplementation()
|
ThingManagerImplementation::~ThingManagerImplementation()
|
||||||
{
|
{
|
||||||
|
|
||||||
delete m_translator;
|
delete m_translator;
|
||||||
|
|
||||||
foreach (Thing *thing, m_configuredThings) {
|
foreach (Thing *thing, m_configuredThings) {
|
||||||
@ -116,6 +117,8 @@ ThingManagerImplementation::~ThingManagerImplementation()
|
|||||||
qCDebug(dcThingManager()) << "Not deleting plugin" << plugin->pluginName();
|
qCDebug(dcThingManager()) << "Not deleting plugin" << plugin->pluginName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PythonIntegrationPlugin::deinitPython();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ThingManagerImplementation::pluginSearchDirs()
|
QStringList ThingManagerImplementation::pluginSearchDirs()
|
||||||
@ -1951,7 +1954,7 @@ void ThingManagerImplementation::loadThingStates(Thing *thing)
|
|||||||
ThingClass thingClass = m_supportedThings.value(thing->thingClassId());
|
ThingClass thingClass = m_supportedThings.value(thing->thingClassId());
|
||||||
foreach (const StateType &stateType, thingClass.stateTypes()) {
|
foreach (const StateType &stateType, thingClass.stateTypes()) {
|
||||||
if (stateType.cached()) {
|
if (stateType.cached()) {
|
||||||
QVariant value(stateType.defaultValue());
|
QVariant value = stateType.defaultValue();
|
||||||
|
|
||||||
if (settings.contains(stateType.id().toString())) {
|
if (settings.contains(stateType.id().toString())) {
|
||||||
value = settings.value(stateType.id().toString());
|
value = settings.value(stateType.id().toString());
|
||||||
@ -1963,6 +1966,7 @@ void ThingManagerImplementation::loadThingStates(Thing *thing)
|
|||||||
}
|
}
|
||||||
value.convert(stateType.type());
|
value.convert(stateType.type());
|
||||||
thing->setStateValue(stateType.id(), value);
|
thing->setStateValue(stateType.id(), value);
|
||||||
|
qWarning() << "**** loaded state" << stateType.name() << value;
|
||||||
} else {
|
} else {
|
||||||
thing->setStateValue(stateType.id(), stateType.defaultValue());
|
thing->setStateValue(stateType.id(), stateType.defaultValue());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user