summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-04-05 16:58:36 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2010-04-05 18:39:53 -0300
commit140eab5f0afaaad6f0f1c3ccec507692cf68ce13 (patch)
tree143f34aca3f39226f1999a57dd12612e67ce4e38
parent2f9545f876f13cf53d795c488d04dd4cdfd654af (diff)
downloadshiboken-140eab5f0afaaad6f0f1c3ccec507692cf68ce13.tar.gz
shiboken-140eab5f0afaaad6f0f1c3ccec507692cf68ce13.tar.xz
shiboken-140eab5f0afaaad6f0f1c3ccec507692cf68ce13.zip
Fix crash caused by a None type passed as argument in comparison functions.
-rw-r--r--cppgenerator.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index a0a8eec5..1dde93fc 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -2199,9 +2199,10 @@ void CppGenerator::writeRichCompareFunction(QTextStream& s, const AbstractMetaCl
s << "if (" << cpythonCheckFunction(type, numberType) << "(other)) {" << endl;
{
Indentation indent(INDENT);
+ s << INDENT << "// " << func->signature() << endl;
s << INDENT;
+ AbstractMetaClass* clz = classes().findClass(type->typeEntry());
if (type->typeEntry()->isValue()) {
- AbstractMetaClass* clz = classes().findClass(type->typeEntry());
Q_ASSERT(clz);
s << clz->qualifiedCppName() << '*';
} else
@@ -2212,7 +2213,15 @@ void CppGenerator::writeRichCompareFunction(QTextStream& s, const AbstractMetaCl
else
writeToCppConversion(s, type, metaClass, "other");
s << ';' << endl;
- s << INDENT << "result = (cpp_self " << op << ' ' << (type->typeEntry()->isValue() ? "(*" : "");
+
+ s << INDENT << "result = ";
+ // It's a value type and the conversion for a pointer returned null.
+ if (type->typeEntry()->isValue()) {
+ s << "!cpp_other ? cpp_self == ";
+ writeToCppConversion(s, type, metaClass, "other", ExcludeReference);
+ s << " : ";
+ }
+ s << "(cpp_self " << op << ' ' << (type->typeEntry()->isValue() ? "(*" : "");
s << "cpp_other" << (type->typeEntry()->isValue() ? ")" : "") << ");" << endl;
}
s << INDENT << '}';