summaryrefslogtreecommitdiffstats
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>2011-03-25 11:32:54 -0300
commit6eabc682fb8ffd9db9057740cf550989c1c25e4f (patch)
treecd017e709979fd36485904f58f128159ed1d78e9
parent2e026d26caa4b7005c17d2e00271358093529a0a (diff)
downloadshiboken-6eabc682fb8ffd9db9057740cf550989c1c25e4f.tar.gz
shiboken-6eabc682fb8ffd9db9057740cf550989c1c25e4f.tar.xz
shiboken-6eabc682fb8ffd9db9057740cf550989c1c25e4f.zip
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 a6d81015..f2afba1d 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;
{