From 0d7ed8f5f3b8a308c495c71c7427b41157d769b1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Feb 2017 17:39:47 +0100 Subject: streamline libdl detection and linking instead of having a library and a test, use a library with two sources, the first being empty (i.e., just libc). this allows us doing away with the "libdl" feature, and using just the "dlopen" one. subsequently, replace all LIBS+=$$QMAKE_LIBS_DYNLOAD with QMAKE_USE+=libdl. the definitions of QMAKE_LIBS_DYNLOAD remain in the qmakespecs for backwards compat only. n.b.: the only specs where it is not empty or "-ldl" (i.e., what we support now) are the hpux ones, where the library is called 'dld'. technically, the "library" feature should depend on '!unix || dlopen', but that's for a later patch. Change-Id: Ib8546affc4b7bc757f1a76729573ddd00e152176 Reviewed-by: Lars Knoll Reviewed-by: Ulf Hermann --- src/plugins/platforms/eglfs/eglfsdeviceintegration.pro | 2 -- src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp | 4 ++-- src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro index 35af3615bd..2593df937b 100644 --- a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro +++ b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro @@ -17,8 +17,6 @@ QT += \ qtHaveModule(input_support-private): \ QT += input_support-private -LIBS += $$QMAKE_LIBS_DYNLOAD - # Avoid X11 header collision, use generic EGL native types DEFINES += QT_EGL_NO_X11 diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 1f36a1ad2a..56b2b1fd23 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -54,7 +54,7 @@ #include #include -#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) +#if !defined(QT_STATIC) && QT_CONFIG(dlopen) #include #endif @@ -564,7 +564,7 @@ QFunctionPointer QGLXContext::getProcAddress(const char *procName) if (!glXGetProcAddressARB) { QList glxExt = QByteArray(glXGetClientString(m_display, GLX_EXTENSIONS)).split(' '); if (glxExt.contains("GLX_ARB_get_proc_address")) { -#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) +#if QT_CONFIG(dlopen) void *handle = dlopen(NULL, RTLD_LAZY); if (handle) { glXGetProcAddressARB = (qt_glXGetProcAddressARB) dlsym(handle, "glXGetProcAddressARB"); diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro index 8aa6e1febd..215f5a3fe1 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro @@ -12,7 +12,7 @@ qtConfig(xcb-glx) { QMAKE_USE += xcb_glx } -LIBS += $$QMAKE_LIBS_DYNLOAD +!static:qtConfig(dlopen): QMAKE_USE += libdl HEADERS += \ qxcbglxintegration.h \ -- cgit v1.2.3 From 1a5deb7e0ea9a129d4ebc59677893c7477ad5a3a Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 1 Mar 2017 14:29:25 +0100 Subject: xcb: fix misuse of xcb_send_event This fixes the following Valgrind warning: "Syscall param writev(vector[...]) points to uninitialised byte(s) Uninitialised value was created by a stack allocation" The xcb_send_event() requires all events to have 32 bytes. It calls memcpy() on the passed in event. If the passed in event is less than 32 bytes, memcpy() reaches into unrelated memory. And as it turns out, this behavior is actually described in the xcb_send_event function's documentation. This patch adds a macro that declares an event for safe usage with xcb_send_event. Change-Id: Ifcaab5e9a3b52b7f64ac930b423e0c7798bbfedb Done-with: Uli Schlachter Task-number: QTBUG-56518 Reviewed-by: Marc Mutz --- src/plugins/platforms/xcb/qxcbclipboard.cpp | 2 +- src/plugins/platforms/xcb/qxcbconnection.h | 13 +++++++++++++ src/plugins/platforms/xcb/qxcbdrag.cpp | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index cee011bbdf..a293066b93 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -607,7 +607,7 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) return; } - xcb_selection_notify_event_t event; + Q_DECLARE_XCB_EVENT(event, xcb_selection_notify_event_t); event.response_type = XCB_SELECTION_NOTIFY; event.requestor = req->requestor; event.selection = req->selection; diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index a9208ffe09..01a97a187a 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -734,6 +734,19 @@ private: QXcbConnection *m_connection; }; +template +union q_padded_xcb_event { + T event; + char padding[32]; +}; + +// The xcb_send_event() requires all events to have 32 bytes. It calls memcpy() on the +// passed in event. If the passed in event is less than 32 bytes, memcpy() reaches into +// unrelated memory. +#define Q_DECLARE_XCB_EVENT(event_var, event_type) \ + q_padded_xcb_event store = {}; \ + auto &event_var = store.event; + #ifdef Q_XCB_DEBUG template cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 58fb1f3918..60d142157f 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -1163,7 +1163,7 @@ static xcb_window_t findXdndAwareParent(QXcbConnection *c, xcb_window_t window) void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event) { - xcb_selection_notify_event_t notify; + Q_DECLARE_XCB_EVENT(notify, xcb_selection_notify_event_t); notify.response_type = XCB_SELECTION_NOTIFY; notify.requestor = event->requestor; notify.selection = event->selection; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index ffbe9a2325..78d000c774 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -864,7 +864,7 @@ void QXcbWindow::hide() Q_XCB_CALL(xcb_unmap_window(xcb_connection(), m_window)); // send synthetic UnmapNotify event according to icccm 4.1.4 - xcb_unmap_notify_event_t event; + Q_DECLARE_XCB_EVENT(event, xcb_unmap_notify_event_t); event.response_type = XCB_UNMAP_NOTIFY; event.event = xcbScreen()->root(); event.window = m_window; -- cgit v1.2.3 From d6330a19b29ebff359a6746250c78437dbcaf77d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 19 Dec 2016 10:34:32 +0100 Subject: Use QT_CONFIG(library) instead of QT_NO_LIBRARY For the windows file system engine, we add an extra macro to use library loading if configured to do so, but avoid it on WinRT, as none of the symbols would be found. We also QT_REQUIRE_CONFIG(library) in the library headers and exclude the sources from the build if library loading is disabled. This, in turn, makes it necessary to clean up some header inclusions. Change-Id: I2b152cb5b47a2658996b6f4702b038536a5704ec Reviewed-by: Oswald Buddenhagen --- src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp | 8 ++++---- .../xcb/gl_integrations/qxcbglintegrationfactory.cpp | 6 +++--- .../xcb/gl_integrations/xcb_glx/qglxintegration.cpp | 4 +++- src/plugins/platforms/xcb/qxcbcursor.cpp | 12 +++++++----- src/plugins/platforms/xcb/qxcbcursor.h | 2 +- 5 files changed, 18 insertions(+), 14 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp index 863a115b74..3558b929fa 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp @@ -69,16 +69,16 @@ Q_LOGGING_CATEGORY(qLcEglDevDebug, "qt.qpa.egldeviceintegration") Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QEglFSDeviceIntegrationFactoryInterface_iid, QLatin1String("/egldeviceintegrations"), Qt::CaseInsensitive)) -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QEglFSDeviceIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) QStringList QEglFSDeviceIntegrationFactory::keys(const QString &pluginPath) { QStringList list; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) if (!pluginPath.isEmpty()) { QCoreApplication::addLibraryPath(pluginPath); list = directLoader()->keyMap().values(); @@ -102,7 +102,7 @@ QStringList QEglFSDeviceIntegrationFactory::keys(const QString &pluginPath) QEglFSDeviceIntegration *QEglFSDeviceIntegrationFactory::create(const QString &key, const QString &pluginPath) { QEglFSDeviceIntegration *integration = Q_NULLPTR; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) if (!pluginPath.isEmpty()) { QCoreApplication::addLibraryPath(pluginPath); integration = qLoadPlugin(directLoader(), key); diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp index 6650ca44ae..d69d969783 100644 --- a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp @@ -50,14 +50,14 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QXcbGlIntegrationFactoryInterface_iid, QLatin1String("/xcbglintegrations"), Qt::CaseInsensitive)) -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QXcbGlIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) -#endif // !QT_NO_LIBRARY +#endif // QT_CONFIG(library) QXcbGlIntegration *QXcbGlIntegrationFactory::create(const QString &platform, const QString &pluginPath) { -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) // Try loading the plugin from pluginPath first: if (!pluginPath.isEmpty()) { QCoreApplication::addLibraryPath(pluginPath); diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 56b2b1fd23..4e0c73450e 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -38,7 +38,9 @@ ****************************************************************************/ #include +#if QT_CONFIG(library) #include +#endif #include "qxcbwindow.h" #include "qxcbscreen.h" @@ -573,7 +575,7 @@ QFunctionPointer QGLXContext::getProcAddress(const char *procName) if (!glXGetProcAddressARB) #endif { -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) extern const QString qt_gl_library_name(); // QLibrary lib(qt_gl_library_name()); QLibrary lib(QLatin1String("GL")); diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index 80fe5a2199..d257ab1242 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -43,7 +43,9 @@ #include "qxcbimage.h" #include "qxcbxsettings.h" +#if QT_CONFIG(library) #include +#endif #include #include #include @@ -58,7 +60,7 @@ typedef char *(*PtrXcursorLibraryGetTheme)(void *); typedef int (*PtrXcursorLibrarySetTheme)(void *, const char *); typedef int (*PtrXcursorLibraryGetDefaultSize)(void *); -#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) +#if defined(XCB_USE_XLIB) && QT_CONFIG(library) #include enum { XCursorShape = CursorShape @@ -306,7 +308,7 @@ QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen) const char *cursorStr = "cursor"; xcb_open_font(xcb_connection(), cursorFont, strlen(cursorStr), cursorStr); -#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) +#if defined(XCB_USE_XLIB) && QT_CONFIG(library) static bool function_ptrs_not_initialized = true; if (function_ptrs_not_initialized) { QLibrary xcursorLib(QLatin1String("Xcursor"), 1); @@ -507,7 +509,7 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) return cursor; } -#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) +#if defined(XCB_USE_XLIB) && QT_CONFIG(library) bool updateCursorTheme(void *dpy, const QByteArray &theme) { if (!ptrXcursorLibraryGetTheme || !ptrXcursorLibrarySetTheme) @@ -551,7 +553,7 @@ static xcb_cursor_t loadCursor(void *dpy, int cshape) } return cursor; } -#endif //XCB_USE_XLIB / QT_NO_LIBRARY +#endif // XCB_USE_XLIB / QT_CONFIG(library) xcb_cursor_t QXcbCursor::createFontCursor(int cshape) { @@ -560,7 +562,7 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape) xcb_cursor_t cursor = XCB_NONE; // Try Xcursor first -#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) +#if defined(XCB_USE_XLIB) && QT_CONFIG(library) if (cshape >= 0 && cshape <= Qt::LastCursor) { void *dpy = connection()->xlib_display(); // special case for non-standard dnd-* cursors diff --git a/src/plugins/platforms/xcb/qxcbcursor.h b/src/plugins/platforms/xcb/qxcbcursor.h index c15225f6d2..41ec4dbbf8 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.h +++ b/src/plugins/platforms/xcb/qxcbcursor.h @@ -101,7 +101,7 @@ private: #ifndef QT_NO_CURSOR CursorHash m_cursorHash; #endif -#if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) +#if defined(XCB_USE_XLIB) && QT_CONFIG(library) static void cursorThemePropertyChanged(QXcbVirtualDesktop *screen, const QByteArray &name, const QVariant &property, -- cgit v1.2.3 From 473248df1458c34c73e63f14f9831104b266bd4a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 27 Feb 2017 13:37:09 +0100 Subject: put load(qt_plugin) at end of project file amends a28364bc1. Change-Id: I8e6044abcbfffde8688d87cd3aa722c0c362534c Reviewed-by: Andy Nichols --- src/plugins/platforms/vnc/vnc.pro | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro index 3cd7e9b160..1fa682303f 100644 --- a/src/plugins/platforms/vnc/vnc.pro +++ b/src/plugins/platforms/vnc/vnc.pro @@ -1,10 +1,5 @@ TARGET = qvnc -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QVncIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) - QT += \ core-private network gui-private \ service_support-private theme_support-private fb_support-private \ @@ -29,3 +24,8 @@ HEADERS = \ qvncclient.h OTHER_FILES += vnc.json + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QVncIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) -- cgit v1.2.3