Fix xcb's native resource getters.

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 <samuel.rodal@nokia.com>
Reviewed-by: Jani Uusi-Rantala <jani.uusi-rantala@nokia.com>
bb10
Laszlo Agocs 2012-02-10 16:28:19 +02:00 committed by Qt by Nokia
parent 1e744d2523
commit a4fbae9fd9
1 changed files with 10 additions and 2 deletions

View File

@ -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;
}