Skip to content

Commit edc56b1

Browse files
usiemsmrbean-bremen
authored andcommitted
Revert "Stylistic changes and refcount fixes in PythonQtImporter_load_module"
This reverts commit 295a9ce.
1 parent f2c49ad commit edc56b1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/PythonQt.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ void PythonQt_init_QtCoreBuiltin(PyObject*);
7171
static inline int PyModule_AddObject_DECREF(PyObject *module, const char *name, PyObject *value)
7272
{
7373
int ret = PyModule_AddObject(module, name, value);
74-
if (ret < 0) {
74+
if (ret < 0)
7575
Py_XDECREF(value);
76-
}
7776
return ret;
7877
}
7978

@@ -2147,9 +2146,8 @@ const QMetaObject* PythonQtPrivate::buildDynamicMetaObject(PythonQtClassWrapper*
21472146
PyObject* value = NULL;
21482147
PyObject* key = NULL;
21492148
static PyObject* qtSlots = NULL;
2150-
if (!qtSlots) {
2151-
qtSlots = PyString_FromString("_qtSlots");
2152-
}
2149+
if (!qtSlots)
2150+
qtSlots = PyString_FromString("_qtSlots");
21532151

21542152
bool needsMetaObject = false;
21552153
// Iterate over all members and check if they affect the QMetaObject:

src/PythonQtImporter.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ PythonQtImporter_load_module(PyObject *obj, PyObject *args)
224224
PyObject *code = NULL, *mod = NULL, *dict = NULL;
225225
char *fullname;
226226

227-
if (!PyArg_ParseTuple(args, "s:PythonQtImporter.load_module", &fullname)) {
227+
if (!PyArg_ParseTuple(args, "s:PythonQtImporter.load_module",
228+
&fullname))
228229
return NULL;
229-
}
230230

231231
PythonQtImport::ModuleInfo info = PythonQtImport::getModuleInfo(self, fullname);
232232
if (info.type == PythonQtImport::MI_NOT_FOUND) {
@@ -250,6 +250,7 @@ PythonQtImporter_load_module(PyObject *obj, PyObject *args)
250250

251251
if (PyDict_SetItemString(dict, "__loader__", (PyObject *)self) != 0) {
252252
Py_DECREF(code);
253+
Py_DECREF(mod);
253254
return NULL;
254255
}
255256

@@ -264,19 +265,22 @@ PythonQtImporter_load_module(PyObject *obj, PyObject *args)
264265
QStringToPythonConstCharPointer(subname));
265266
if (fullpath == NULL) {
266267
Py_DECREF(code);
268+
Py_DECREF(mod);
267269
return NULL;
268270
}
269271

270272
pkgpath = Py_BuildValue("[O]", fullpath);
271273
Py_DECREF(fullpath);
272274
if (pkgpath == NULL) {
273275
Py_DECREF(code);
276+
Py_DECREF(mod);
274277
return NULL;
275278
}
276279
err = PyDict_SetItemString(dict, "__path__", pkgpath);
277280
Py_DECREF(pkgpath);
278281
if (err != 0) {
279282
Py_DECREF(code);
283+
Py_DECREF(mod);
280284
return NULL;
281285
}
282286

@@ -290,10 +294,12 @@ PythonQtImporter_load_module(PyObject *obj, PyObject *args)
290294
Py_XDECREF(fullnameObj);
291295
if (err != 0) {
292296
Py_DECREF(code);
297+
Py_DECREF(mod);
293298
return NULL;
294299
}
295300
#endif
296301
}
302+
Py_DECREF(mod);
297303

298304
#ifdef PY3K
299305
PyObject* fullnameObj = PyUnicode_FromString(fullname);

0 commit comments

Comments
 (0)