aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-03-23 18:20:40 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:15:18 -0300
commita12f4499d7c3d762abde50ec46ca7665426e597a (patch)
treedb8a593ce5d531e568381efc0a04a8f6b55bab08
parentd7fa80decce5b37a4bc77d2bb61768414ead8be7 (diff)
Check for object validity on property getters and setters before using them.
-rw-r--r--generator/cppgenerator.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index a6d810158..f2afba1d8 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -2767,6 +2767,11 @@ void CppGenerator::writeGetterFunction(QTextStream& s, const AbstractMetaField*
{
s << "static PyObject* " << cpythonGetterFunctionName(metaField) << "(PyObject* self, void*)" << endl;
s << '{' << endl;
+ s << INDENT << "if (!Shiboken::Object::isValid(self))\n";
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return 0;\n";
+ }
s << INDENT << "PyObject* val = ";
QString cppField;
@@ -2806,6 +2811,11 @@ void CppGenerator::writeSetterFunction(QTextStream& s, const AbstractMetaField*
{
s << "static int " << cpythonSetterFunctionName(metaField) << "(PyObject* self, PyObject* value, void*)" << endl;
s << '{' << endl;
+ s << INDENT << "if (!Shiboken::Object::isValid(self))\n";
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "return 0;\n";
+ }
s << INDENT << "if (value == 0) {" << endl;
{