diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-04-05 16:58:36 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-04-05 18:39:53 -0300 |
commit | 140eab5f0afaaad6f0f1c3ccec507692cf68ce13 (patch) | |
tree | 143f34aca3f39226f1999a57dd12612e67ce4e38 | |
parent | 2f9545f876f13cf53d795c488d04dd4cdfd654af (diff) |
Fix crash caused by a None type passed as argument in comparison functions.
-rw-r--r-- | cppgenerator.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp index a0a8eec5c..1dde93fcb 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 << '}'; |