Skip to content

Commit 9c2e489

Browse files
author
florianlink
committed
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 2d445d5 commit 9c2e489

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
@@ -877,12 +877,10 @@ QVariant PythonQt::evalScript(PyObject* object, const QString& script, int start
877877

878878
void PythonQt::evalFile(PyObject* module, const QString& filename)
879879
{
880+
// NOTE: error checking is done by parseFile and evalCode
880881
PythonQtObjectPtr code = parseFile(filename);
881-
clearError();
882882
if (code) {
883883
evalCode(module, code);
884-
} else {
885-
handleError();
886884
}
887885
}
888886

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
@@ -343,7 +343,14 @@ static PyObject *PythonQtInstanceWrapper_help(PythonQtInstanceWrapper* obj)
343343

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

0 commit comments

Comments
 (0)