use cleaner way to instantiate PyRainmeter
This commit is contained in:
parent
7dccf686d9
commit
60c3938ccd
|
@ -193,10 +193,10 @@ PyObject* CreateRainmeterObject(void *rm)
|
|||
{
|
||||
if (!(rainmeterType.tp_flags & Py_TPFLAGS_READY))
|
||||
{
|
||||
rainmeterType.tp_new = PyType_GenericNew;
|
||||
PyType_Ready(&rainmeterType);
|
||||
}
|
||||
Py_INCREF(&rainmeterType);
|
||||
RainmeterObject *obj = PyObject_New(RainmeterObject, &rainmeterType);
|
||||
obj->rm = rm;
|
||||
PyObject *obj = PyObject_CallObject((PyObject*) &rainmeterType, NULL);
|
||||
((RainmeterObject*)obj)->rm = rm;
|
||||
return (PyObject*) obj;
|
||||
}
|
||||
|
|
|
@ -169,12 +169,12 @@ PLUGIN_EXPORT double Update(void* data)
|
|||
if (resultObj != NULL)
|
||||
{
|
||||
result = PyFloat_Check(resultObj) ? PyFloat_AsDouble(resultObj) : 0.0;
|
||||
Py_DECREF(resultObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_Clear();
|
||||
}
|
||||
Py_XDECREF(resultObj);
|
||||
PyEval_SaveThread();
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue