summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-12-20 21:36:12 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-12-21 14:51:30 +0100
commitd99800dcacc0c3e09f7d98321e12257ef55b98da (patch)
tree14abc79dbb60be2d2c6e3013d305f5889992a58f
parentbde2764ab0a1bfdd253426ab466583e229be93f9 (diff)
Make sure that QCocoaWindowManager is initialized in static builds
If code has no external references, then with a static build of Qt the linker is free to strip those object files from the final executable. This is what happened with QCocoaWindowManager, which had no exported symbols, and no callers from other files. To prevent the linker from stripping the object file and to ensure that the constructor function gets called during startup, move that function declaration to the QCocoaIntegration code, which is always loaded. Fixes: QTBUG-99280 Pick-to: 6.2 6.3 Change-Id: Icdafea372a1b42c6ecdb43e36aeb0a04a70e3d4e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindowmanager.mm3
2 files changed, 6 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index b8954509b9..92edeac558 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -57,6 +57,7 @@
#if QT_CONFIG(sessionmanager)
# include "qcocoasessionmanager.h"
#endif
+#include "qcocoawindowmanager.h"
#include <qpa/qplatforminputcontextfactory_p.h>
#include <qpa/qplatformaccessibility.h>
@@ -81,6 +82,11 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpa, "qt.qpa", QtWarningMsg);
+// Lives here so that the linker is forced to include the QCocoaWindowManager
+// object file also in static builds.
+static void initializeWindowManager() { Q_UNUSED(QCocoaWindowManager::instance()); }
+Q_CONSTRUCTOR_FUNCTION(initializeWindowManager)
+
static void logVersionInformation()
{
if (!lcQpa().isInfoEnabled())
diff --git a/src/plugins/platforms/cocoa/qcocoawindowmanager.mm b/src/plugins/platforms/cocoa/qcocoawindowmanager.mm
index bb72fea5e6..71bcecdbc6 100644
--- a/src/plugins/platforms/cocoa/qcocoawindowmanager.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindowmanager.mm
@@ -116,8 +116,5 @@ void QCocoaWindowManager::modalSessionChanged()
}
}
-static void initializeWindowManager() { Q_UNUSED(QCocoaWindowManager::instance()); }
-Q_CONSTRUCTOR_FUNCTION(initializeWindowManager)
-
QT_END_NAMESPACE