From 5a3b08e994b9120a370123d1a8d96f28216eaeca Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 30 Dec 2011 14:18:28 +0100 Subject: Do not unconditionally define QT_BEGIN_MOC_NAMESPACE Qt5 modules are supposed to be in a namespace, but if the namespace definition is hidden in a macro, then moc doesn't know about it and generates invalid moc_xx.cpp that cannot be compiled due to usage of classes outside of their namespaces - e.g. in qtjsondb we have QtAddOn::JsonDb::Foo class, but the moc_foo.cpp expects to find that class in the global namespace instead. Fixed it in QtJsonDb to define QT_BEGIN_MOC_NAMESPACE="QT_USE_NAMESPACE QT_ADDON_JSONDB_USE_NAMESPACE", however we need to ensure qglobal.h doesn't re-define that macro back. Change-Id: Ic8407f50c11d2d787167ad2f92457aa3ec126d45 Reviewed-by: Andy Shaw Reviewed-by: Richard J. Moore Reviewed-by: Toby Tomkins Reviewed-by: Olivier Goffart --- src/corelib/global/qglobal.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e75118fc3a..785ee4a49a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -76,8 +76,12 @@ # define QT_END_NAMESPACE # define QT_BEGIN_INCLUDE_NAMESPACE # define QT_END_INCLUDE_NAMESPACE +#ifndef QT_BEGIN_MOC_NAMESPACE # define QT_BEGIN_MOC_NAMESPACE +#endif +#ifndef QT_END_MOC_NAMESPACE # define QT_END_MOC_NAMESPACE +#endif # define QT_FORWARD_DECLARE_CLASS(name) class name; # define QT_FORWARD_DECLARE_STRUCT(name) struct name; # define QT_MANGLE_NAMESPACE(name) name @@ -90,8 +94,12 @@ # define QT_END_NAMESPACE } # define QT_BEGIN_INCLUDE_NAMESPACE } # define QT_END_INCLUDE_NAMESPACE namespace QT_NAMESPACE { +#ifndef QT_BEGIN_MOC_NAMESPACE # define QT_BEGIN_MOC_NAMESPACE QT_USE_NAMESPACE +#endif +#ifndef QT_END_MOC_NAMESPACE # define QT_END_MOC_NAMESPACE +#endif # define QT_FORWARD_DECLARE_CLASS(name) \ QT_BEGIN_NAMESPACE class name; QT_END_NAMESPACE \ using QT_PREPEND_NAMESPACE(name); -- cgit v1.2.3