[Mesa-dev] [PATCH 2/2] glx: Do error checking in CreateDrawable
Chad Versace
chad at chad-versace.us
Fri Jun 24 18:17:22 PDT 2011
If CreateDRIDrawable fails, then return 0 as the GLXDrawable.
Cc: nobled at dreamwidth.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33758
Note: This is candidate for the stable branch.
Signed-off-by: Chad Versace <chad at chad-versace.us>
---
src/glx/glx_pbuffer.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c
index 1f4c0f3..19be4e5 100644
--- a/src/glx/glx_pbuffer.c
+++ b/src/glx/glx_pbuffer.c
@@ -34,6 +34,7 @@
#include <X11/extensions/extutil.h>
#include <X11/extensions/Xext.h>
#include <assert.h>
+#include <stdbool.h>
#include <string.h>
#include "glxextensions.h"
@@ -187,7 +188,7 @@ determineTextureFormat(const int *attribs, int numAttribs)
return 0;
}
-static void
+static bool
CreateDRIDrawable(Display *dpy, struct glx_config *config,
XID drawable, XID glxdrawable,
const int *attrib_list, size_t num_attribs)
@@ -204,16 +205,17 @@ CreateDRIDrawable(Display *dpy, struct glx_config *config,
glxdrawable, config);
if (pdraw == NULL) {
fprintf(stderr, "failed to create drawable\n");
- return;
+ return false;
}
if (__glxHashInsert(priv->drawHash, glxdrawable, pdraw)) {
(*pdraw->destroyDrawable) (pdraw);
- return; /* FIXME: Check what we're supposed to do here... */
+ return false;
}
pdraw->textureTarget = determineTextureTarget(attrib_list, num_attribs);
pdraw->textureFormat = determineTextureFormat(attrib_list, num_attribs);
+ return true;
}
static void
@@ -371,6 +373,7 @@ static GLXDrawable
CreateDrawable(Display *dpy, struct glx_config *config,
Drawable drawable, const int *attrib_list, CARD8 glxCode)
{
+ bool ok;
xGLXCreateWindowReq *req;
CARD32 *data;
unsigned int i;
@@ -405,9 +408,11 @@ CreateDrawable(Display *dpy, struct glx_config *config,
UnlockDisplay(dpy);
SyncHandle();
- CreateDRIDrawable(dpy, config, drawable, xid, attrib_list, i);
-
- return xid;
+ ok = CreateDRIDrawable(dpy, config, drawable, xid, attrib_list, i);
+ if (ok)
+ return xid;
+ else
+ return 0;
}
--
1.7.5.4
More information about the mesa-dev
mailing list