diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2021-04-20 14:45:59 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2021-04-22 15:56:36 +0200 |
commit | a372b35d93d4deb14ba9b855c49bcbd328b32381 (patch) | |
tree | 74af10d116adca1290811f1f4b24c81ad6007d26 /src/imports | |
parent | f42abbcb7794bcfc884e8aee75f73bd9ab8fbda4 (diff) |
Native style: fix statically built apps that links to both widgets and controls
The c++ symbols are already namespaced into QQC2. But since there is no
namespace concept in obj-c, we use QT_MANGLE_NAMESPACE to wrap those
symbols into a "fake" namespace by concatinating symbol name and
namespace name together.
The problem is that QT_MANGLE_NAMESPACE only take the QT_NAMESPACE
into account, and not the additional QQC2 namespace. The result is
that the application will fail linking because of duplicate obj-c
symbols when you combine widgets and controls in a statically linked
application.
This patch will redefine the affected macros locally in
qquickmacstyle_mac, so that both the Qt namespace and the controls
namespace are taken into account.
Pick-to: 6.0 6.1 6.1.0
Fixes: QTBUG-92883
Change-Id: Ic2f84ad9c0005fdd2553729d897cee113a4ff24d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm | 22 | ||||
-rw-r--r-- | src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac_p.h | 6 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm index 257bde31..47fac5b3 100644 --- a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm +++ b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm @@ -67,6 +67,24 @@ QT_USE_NAMESPACE +// OBS! Changing QT_MANGLE_NAMESPACE and QT_NAMESPACE_ALIAS_OBJC_CLASS to take +// both QT_NAMESPACE and QQC2_NAMESPACE into account (and not only QT_NAMESPACE, which +// would otherwise be the case). This will make it possible to link in both widgets and +// controls in the same application when building statically. +#undef QT_MANGLE_NAMESPACE +#undef QT_NAMESPACE_ALIAS_OBJC_CLASS + +#define QQC2_MANGLE1(a, b) a##_##b +#define QQC2_MANGLE2(a, b) QQC2_MANGLE1(a, b) + +#if defined(QT_NAMESPACE) + #define QT_MANGLE_NAMESPACE(name) QQC2_MANGLE2(QQC2_MANGLE1(name, QQC2_NAMESPACE), QT_NAMESPACE) + #define QT_NAMESPACE_ALIAS_OBJC_CLASS(name) @compatibility_alias name QT_MANGLE_NAMESPACE(name) +#else + #define QT_MANGLE_NAMESPACE(name) QQC2_MANGLE2(name, QQC2_NAMESPACE) + #define QT_NAMESPACE_ALIAS_OBJC_CLASS(name) @compatibility_alias name QT_MANGLE_NAMESPACE(name) +#endif + @interface QT_MANGLE_NAMESPACE(QIndeterminateProgressIndicator) : NSProgressIndicator @property (readonly, nonatomic) NSInteger animators; @@ -171,7 +189,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QDarkNSBox); QT_BEGIN_NAMESPACE -namespace QQC2 { +namespace QQC2_NAMESPACE { // The following constants are used for adjusting the size // of push buttons so that they are drawn inside their bounds. @@ -6046,6 +6064,6 @@ QIcon QMacStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *o } } -} // namespace QQC2 +} // QQC2_NAMESPACE QT_END_NAMESPACE diff --git a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac_p.h b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac_p.h index 2604cfc6..b9e1c5f3 100644 --- a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac_p.h +++ b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac_p.h @@ -50,11 +50,13 @@ #include "qquickcommonstyle.h" +#define QQC2_NAMESPACE QQC2 + QT_BEGIN_NAMESPACE class QPalette; -namespace QQC2 { +namespace QQC2_NAMESPACE { class QStyleOptionButton; class QMacStylePrivate; @@ -95,7 +97,7 @@ private: Q_DECLARE_PRIVATE(QMacStyle) }; -} // namespace QQC2 +} // QQC2_NAMESPACE QT_END_NAMESPACE |