From a4fbae9fd9ad41bea52d328d559cd7f7c10af84b Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 10 Feb 2012 16:28:19 +0200 Subject: [PATCH] Fix xcb's native resource getters. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Returning pointers to unexpected types for unknown keys is quite wrong. The clients expect 0 in such a case but what they got (until now) was whatever was associated with the default constructed enum value. Change-Id: Iefd7bf461bfb2c1f4c73f5f9f291aecad60219eb Reviewed-by: Samuel Rødal Reviewed-by: Jani Uusi-Rantala --- src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index b7403cf..406f9c2 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -84,6 +84,9 @@ QXcbNativeInterface::QXcbNativeInterface() void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) { QByteArray lowerCaseResource = resourceString.toLower(); + if (!qXcbResourceMap()->contains(lowerCaseResource)) + return 0; + ResourceType resource = qXcbResourceMap()->value(lowerCaseResource); void *result = 0; switch(resource) { @@ -91,14 +94,18 @@ void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceSt result = eglContextForContext(context); break; default: - result = 0; + break; } + return result; } void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) { QByteArray lowerCaseResource = resourceString.toLower(); + if (!qXcbResourceMap()->contains(lowerCaseResource)) + return 0; + ResourceType resource = qXcbResourceMap()->value(lowerCaseResource); void *result = 0; switch(resource) { @@ -118,8 +125,9 @@ void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceStr result = graphicsDeviceForWindow(window); break; default: - result = 0; + break; } + return result; } -- 2.7.4