diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-06-11 09:11:46 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-06-11 10:58:05 (GMT) |
commit | 713e52d9531277b8c13856246701729de16d4502 (patch) | |
tree | 4ecee572d3037ab168940b502a9a051e61073fe3 /src/tools/moc | |
parent | 0295d0aa5111f31eec8dd8109b4df6389f4efbce (diff) | |
download | Qt-713e52d9531277b8c13856246701729de16d4502.zip Qt-713e52d9531277b8c13856246701729de16d4502.tar.gz Qt-713e52d9531277b8c13856246701729de16d4502.tar.bz2 |
Only include QMetaType if required in moc generated files
Including it might cause build errors. (and thus break source
compatibility)
The problem was seen on KDE where some cpp files included x11 headers
and then later included the .moc file, then qmetatype.h complains that
Bool is defined
Reviewed-by: Brad
Diffstat (limited to 'src/tools/moc')
-rw-r--r-- | src/tools/moc/moc.cpp | 8 | ||||
-rw-r--r-- | src/tools/moc/moc.h | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 4629ac5..a1738a5 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -767,7 +767,8 @@ void Moc::generate(FILE *out) if (classList.size() && classList.first().classname == "Qt") fprintf(out, "#include <QtCore/qobject.h>\n"); - fprintf(out, "#include <QtCore/qmetatype.h>\n"); + if (mustIncludeQMetaTypeH) + fprintf(out, "#include <QtCore/qmetatype.h>\n"); fprintf(out, "#if !defined(Q_MOC_OUTPUT_REVISION)\n" "#error \"The header file '%s' doesn't include <QObject>.\"\n", (const char *)fn); @@ -900,6 +901,9 @@ void Moc::parseProperty(ClassDef *def) type = "qlonglong"; else if (type == "ULongLong") type = "qulonglong"; + else if (type == "qreal") + mustIncludeQMetaTypeH = true; + propDef.type = type; next(); @@ -961,7 +965,7 @@ void Moc::parseProperty(ClassDef *def) msg += " has no READ accessor function. The property will be invalid."; warning(msg.constData()); } - if(!propDef.notify.isEmpty()) + if(!propDef.notify.isEmpty()) def->notifyableProperties++; def->propertyList += propDef; diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 689104c..4a1dee9 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -177,13 +177,14 @@ class Moc : public Parser { public: Moc() - : noInclude(false), generatedCode(false) + : noInclude(false), generatedCode(false), mustIncludeQMetaTypeH(false) {} QByteArray filename; bool noInclude; bool generatedCode; + bool mustIncludeQMetaTypeH; QByteArray includePath; QList<QByteArray> includeFiles; QList<ClassDef> classList; |