From 3d03f4e989e0ae53569a1a2e390d71c41d91f329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 28 Jul 2020 15:31:44 +0200 Subject: Register QPlatformBackingStoreOpenGLSupport when needed Static builds can not rely on a constructor function in the QtOpenGL library, as that will be linked out unless something in the application pulls it in. Instead we export a helper function that clients that depend on OpenGL support in QPlatformBackingStore can use to bring it it. Change-Id: Ic54058bf413a476287884c78df5624b862f97695 Reviewed-by: Laszlo Agocs --- src/opengl/qplatformbackingstoreopenglsupport.cpp | 15 ++++++--------- src/opengl/qplatformbackingstoreopenglsupport.h | 2 ++ 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src/opengl') diff --git a/src/opengl/qplatformbackingstoreopenglsupport.cpp b/src/opengl/qplatformbackingstoreopenglsupport.cpp index 6f893671c0..46e36c23d4 100644 --- a/src/opengl/qplatformbackingstoreopenglsupport.cpp +++ b/src/opengl/qplatformbackingstoreopenglsupport.cpp @@ -450,17 +450,14 @@ GLuint QPlatformBackingStoreOpenGLSupport::toTexture(const QRegion &dirtyRegion, return textureId; } -static QPlatformBackingStoreOpenGLSupportBase *createOpenGLSupport() +void qt_registerDefaultPlatformBackingStoreOpenGLSupport() { - return new QPlatformBackingStoreOpenGLSupport; -} - -static void setDefaultOpenGLSupportFactoryFunction() -{ - if (!QPlatformBackingStoreOpenGLSupportBase::factoryFunction()) - QPlatformBackingStoreOpenGLSupportBase::setFactoryFunction(createOpenGLSupport); + if (!QPlatformBackingStoreOpenGLSupportBase::factoryFunction()) { + QPlatformBackingStoreOpenGLSupportBase::setFactoryFunction([]() -> QPlatformBackingStoreOpenGLSupportBase* { + return new QPlatformBackingStoreOpenGLSupport; + }); + } } -Q_CONSTRUCTOR_FUNCTION(setDefaultOpenGLSupportFactoryFunction); #endif // QT_NO_OPENGL diff --git a/src/opengl/qplatformbackingstoreopenglsupport.h b/src/opengl/qplatformbackingstoreopenglsupport.h index 4821f7300f..ae9d972c6a 100644 --- a/src/opengl/qplatformbackingstoreopenglsupport.h +++ b/src/opengl/qplatformbackingstoreopenglsupport.h @@ -78,6 +78,8 @@ private: QOpenGLTextureBlitter *blitter = nullptr; }; +Q_OPENGL_EXPORT void qt_registerDefaultPlatformBackingStoreOpenGLSupport(); + QT_END_NAMESPACE #endif // QT_NO_OPENGL -- cgit v1.2.3