Move exports conflicting with QtDeclarative into namespace

Move exported qml* symbols that conflict with QtDeclarative into an
- automatically imported - namespace. This ensures apps can
link against both QtDeclarative and QtQml.

To keep the BC promise the old symbols are still exported.

Task-number: QTBUG-29584
Change-Id: I3d31c36ca4e2faaf6f5d67a77c5c5a304c0338a4
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
This commit is contained in:
Kai Koehne 2013-05-08 10:24:15 +02:00 committed by The Qt Project
parent 3dbbfe0a9c
commit c74e4a74ba
4 changed files with 84 additions and 12 deletions

View File

@ -419,11 +419,17 @@ class QQmlContext;
class QQmlEngine;
class QJSValue;
class QJSEngine;
Q_QML_EXPORT void qmlExecuteDeferred(QObject *);
Q_QML_EXPORT QQmlContext *qmlContext(const QObject *);
Q_QML_EXPORT QQmlEngine *qmlEngine(const QObject *);
Q_QML_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true);
Q_QML_EXPORT QObject *qmlAttachedPropertiesObject(int *, const QObject *, const QMetaObject *, bool create);
namespace QtQml {
// declared in namespace to avoid symbol conflicts with QtDeclarative
Q_QML_EXPORT void qmlExecuteDeferred(QObject *);
Q_QML_EXPORT QQmlContext *qmlContext(const QObject *);
Q_QML_EXPORT QQmlEngine *qmlEngine(const QObject *);
Q_QML_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true);
Q_QML_EXPORT QObject *qmlAttachedPropertiesObject(int *, const QObject *,
const QMetaObject *, bool create);
}
using namespace QtQml;
template<typename T>
QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true)

View File

@ -1279,6 +1279,8 @@ void QQmlEnginePrivate::doDeleteInEngineThread()
delete d;
}
namespace QtQml {
Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object)
{
QQmlData *data = QQmlData::get(object);
@ -1352,6 +1354,41 @@ QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
return qmlAttachedPropertiesObjectById(*idCache, object, create);
}
} // namespace QtQml
#if QT_DEPRECATED_SINCE(5, 1)
// Also define symbols outside namespace to keep binary compatibility with Qt 5.0
Q_QML_EXPORT void qmlExecuteDeferred(QObject *obj)
{
QtQml::qmlExecuteDeferred(obj);
}
Q_QML_EXPORT QQmlContext *qmlContext(const QObject *obj)
{
return QtQml::qmlContext(obj);
}
Q_QML_EXPORT QQmlEngine *qmlEngine(const QObject *obj)
{
return QtQml::qmlEngine(obj);
}
Q_QML_EXPORT QObject *qmlAttachedPropertiesObjectById(int id, const QObject *obj, bool create)
{
return QtQml::qmlAttachedPropertiesObjectById(id, obj, create);
}
Q_QML_EXPORT QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
const QMetaObject *attachedMetaObject,
bool create)
{
return QtQml::qmlAttachedPropertiesObject(idCache, object, attachedMetaObject, create);
}
#endif // QT_DEPRECATED_SINCE(5, 1)
QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool printWarning)
{
#ifndef QQML_NO_DEBUG_PROTOCOL

View File

@ -165,6 +165,8 @@ QQmlInfo::~QQmlInfo()
}
}
namespace QtQml {
QQmlInfo qmlInfo(const QObject *me)
{
QQmlInfoPrivate *d = new QQmlInfoPrivate;
@ -188,5 +190,27 @@ QQmlInfo qmlInfo(const QObject *me, const QList<QQmlError> &errors)
return QQmlInfo(d);
}
} // namespace QtQml
#if QT_DEPRECATED_SINCE(5, 1)
// Also define symbols outside namespace to keep binary compatibility with Qt 5.0
QQmlInfo qmlInfo(const QObject *me)
{
return QtQml::qmlInfo(me);
}
QQmlInfo qmlInfo(const QObject *me, const QQmlError &error)
{
return QtQml::qmlInfo(me, error);
}
QQmlInfo qmlInfo(const QObject *me, const QList<QQmlError> &errors)
{
return QtQml::qmlInfo(me, errors);
}
#endif // QT_DEPRECATED_SINCE(5, 1)
QT_END_NAMESPACE

View File

@ -48,6 +48,15 @@
QT_BEGIN_NAMESPACE
class QQmlInfo;
namespace QtQml {
// declared in namespace to avoid symbol conflicts with QtDeclarative
Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me);
Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QQmlError &error);
Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QList<QQmlError> &errors);
}
using namespace QtQml;
class QQmlInfoPrivate;
class Q_QML_EXPORT QQmlInfo : public QDebug
@ -82,18 +91,14 @@ public:
#endif
private:
friend Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me);
friend Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QQmlError &error);
friend Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QList<QQmlError> &errors);
friend Q_QML_EXPORT QQmlInfo QtQml::qmlInfo(const QObject *me);
friend Q_QML_EXPORT QQmlInfo QtQml::qmlInfo(const QObject *me, const QQmlError &error);
friend Q_QML_EXPORT QQmlInfo QtQml::qmlInfo(const QObject *me, const QList<QQmlError> &errors);
QQmlInfo(QQmlInfoPrivate *);
QQmlInfoPrivate *d;
};
Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me);
Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QQmlError &error);
Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QList<QQmlError> &errors);
QT_END_NAMESPACE
#endif // QQMLINFO_H