Skip to content

Commit c03cd74

Browse files
florianlinkmsmolens
authored andcommitted
fixed error handling for evalFile
made name->objectName alias optional (off by default, add PYTHONQT_SUPPORT_NAME_PROPERTY to DEFINES if you need it) added py_delete() slot support for built-in delete() method git-svn-id: http://svn.code.sf.net/p/pythonqt/code/trunk@396 ea8d5007-eb21-0410-b261-ccb3ea6e24a9
1 parent e5badfb commit c03cd74

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/PythonQt.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,12 +880,10 @@ QVariant PythonQt::evalScript(PyObject* object, const QString& script, int start
880880

881881
void PythonQt::evalFile(PyObject* module, const QString& filename)
882882
{
883+
// NOTE: error checking is done by parseFile and evalCode
883884
PythonQtObjectPtr code = parseFile(filename);
884-
clearError();
885885
if (code) {
886886
evalCode(module, code);
887-
} else {
888-
handleError();
889887
}
890888
}
891889

src/PythonQtClassInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ bool PythonQtClassInfo::lookForPropertyAndCache(const char* memberName)
134134
const char* attributeName = memberName;
135135
// look for properties
136136
int i = _meta->indexOfProperty(attributeName);
137+
#ifdef PYTHONQT_SUPPORT_NAME_PROPERTY
137138
if (i==-1) {
138139
// try to map name to objectName
139140
if (qstrcmp(attributeName, "name")==0) {
@@ -142,6 +143,7 @@ bool PythonQtClassInfo::lookForPropertyAndCache(const char* memberName)
142143
i = _meta->indexOfProperty(attributeName);
143144
}
144145
}
146+
#endif
145147
if (i!=-1) {
146148
PythonQtMemberInfo newInfo(_meta->property(i));
147149
_cachedMembers.insert(attributeName, newInfo);

src/PythonQtInstanceWrapper.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,14 @@ static PyObject *PythonQtInstanceWrapper_help(PythonQtInstanceWrapper* obj)
345345

346346
PyObject *PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper * self)
347347
{
348-
PythonQtInstanceWrapper_deleteObject(self, true);
348+
PythonQtMemberInfo deleteSlot = self->classInfo()->member("py_delete");
349+
if (deleteSlot._type == PythonQtMemberInfo::Slot) {
350+
// call the py_delete slot instead of internal C++ destructor...
351+
PyObject* resultObj = PythonQtSlotFunction_CallImpl(self->classInfo(), self->_obj, deleteSlot._slot, NULL, NULL, self->_wrappedPtr);
352+
Py_XDECREF(resultObj);
353+
} else {
354+
PythonQtInstanceWrapper_deleteObject(self, true);
355+
}
349356
Py_INCREF(Py_None);
350357
return Py_None;
351358
}

0 commit comments

Comments
 (0)