summaryrefslogtreecommitdiffstats
path: root/src/glx/x11/glx_pbuffer.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-02-07 00:39:56 +0000
committerBrian Paul <[email protected]>2006-02-07 00:39:56 +0000
commit42725d6f545087d094b1479d1ebcbd45ec6ac15c (patch)
treea3fc53ce0b299afb9f3af897d41f6a2784ad5471 /src/glx/x11/glx_pbuffer.c
parent4cd0e24f86a5e3fa67774be546f922ca241cb0ea (diff)
David Reveman's GLX_EXT_texture_from_pixmap extension patch
Diffstat (limited to 'src/glx/x11/glx_pbuffer.c')
-rw-r--r--src/glx/x11/glx_pbuffer.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/src/glx/x11/glx_pbuffer.c b/src/glx/x11/glx_pbuffer.c
index 83c550559c0..afdf7107908 100644
--- a/src/glx/x11/glx_pbuffer.c
+++ b/src/glx/x11/glx_pbuffer.c
@@ -200,6 +200,7 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
GLboolean use_glx_1_3 = ((priv->majorVersion > 1)
|| (priv->minorVersion >= 3));
+ *value = 0;
if ( (dpy == NULL) || (drawable == 0) ) {
return 0;
@@ -230,33 +231,41 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
_XReply(dpy, (xReply*) &reply, 0, False);
+ if (reply.type == X_Error)
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+
length = reply.length;
- num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
- data = (CARD32 *) Xmalloc( length * sizeof(CARD32) );
- if ( data == NULL ) {
- /* Throw data on the floor */
- _XEatData(dpy, length);
- } else {
- _XRead(dpy, (char *)data, length * sizeof(CARD32) );
+ if (length)
+ {
+ num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
+ data = (CARD32 *) Xmalloc( length * sizeof(CARD32) );
+ if ( data == NULL ) {
+ /* Throw data on the floor */
+ _XEatData(dpy, length);
+ } else {
+ _XRead(dpy, (char *)data, length * sizeof(CARD32) );
+
+ /* Search the set of returned attributes for the attribute requested by
+ * the caller.
+ */
+ for ( i = 0 ; i < num_attributes ; i++ ) {
+ if ( data[i*2] == attribute ) {
+ *value = data[ (i*2) + 1 ];
+ break;
+ }
+ }
+
+ Xfree( data );
+ }
}
UnlockDisplay(dpy);
SyncHandle();
-
- /* Search the set of returned attributes for the attribute requested by
- * the caller.
- */
-
- for ( i = 0 ; i < num_attributes ; i++ ) {
- if ( data[i*2] == attribute ) {
- *value = data[ (i*2) + 1 ];
- break;
- }
- }
-
- Xfree( data );
-
return 0;
}