Skip to content

Commit 8e76e20

Browse files
committed
fixed return value
fixed wrong isValid negation
1 parent 5a90da6 commit 8e76e20

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

generator/abstractmetalang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ QString AbstractMetaClass::getDefaultNonZeroFunction() const
855855
return "isNull";
856856
}
857857
}
858-
return false;
858+
return QString();
859859
}
860860

861861
/*******************************************************************************

generator/shellheadergenerator.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,11 @@ void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
397397
}
398398
QString nonZeroFunc = meta_class->getDefaultNonZeroFunction();
399399
if (!nonZeroFunc.isEmpty()) {
400-
s << " bool __nonzero__(" << meta_class->qualifiedCppName() << "* obj) { return !obj->" << nonZeroFunc << "(); }" << endl;
400+
s << " bool __nonzero__(" << meta_class->qualifiedCppName() << "* obj) { return ";
401+
if (nonZeroFunc != "isValid") {
402+
s << "!";
403+
}
404+
s << "obj->" << nonZeroFunc << "(); }" << endl;
401405
}
402406

403407
AbstractMetaFieldList fields = meta_class->fields();

0 commit comments

Comments
 (0)