glx: set the loader_logger early and for everyone
[mesa.git] / src / glx / glxext.c
index 459b6c2b07e7e737676b4d0790c0e4d07b20e7dc..cbc59e80921d5b606702bcf23cbdacc3ed4f3943 100644 (file)
@@ -50,6 +50,7 @@
 #include "glxextensions.h"
 
 #include "util/debug.h"
+#include "dri_common.h"
 
 #include <X11/Xlib-xcb.h>
 #include <xcb/xcb.h>
@@ -214,6 +215,8 @@ FreeScreenConfigs(struct glx_display * priv)
    screens = ScreenCount(priv->dpy);
    for (i = 0; i < screens; i++) {
       psc = priv->screens[i];
+      if (!psc)
+         continue;
       glx_screen_cleanup(psc);
 
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
@@ -712,7 +715,8 @@ static GLboolean
    LockDisplay(dpy);
 
    psc->configs = NULL;
-   if (atof(priv->serverGLXversion) >= 1.3) {
+   if (priv->majorVersion > 1 ||
+       (priv->majorVersion == 1 && priv->minorVersion >= 3)) {
       GetReq(GLXGetFBConfigs, fb_req);
       fb_req->reqType = priv->majorOpcode;
       fb_req->glxCode = X_GLXGetFBConfigs;
@@ -792,7 +796,7 @@ AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv)
     ** First allocate memory for the array of per screen configs.
     */
    screens = ScreenCount(dpy);
-   priv->screens = malloc(screens * sizeof *priv->screens);
+   priv->screens = calloc(screens, sizeof *priv->screens);
    if (!priv->screens)
       return GL_FALSE;
 
@@ -904,6 +908,9 @@ __glXInitialize(Display * dpy)
 
    dpyPriv->drawHash = __glxHashCreate();
 
+   /* Set the logger before the *CreateDisplay functions. */
+   loader_set_logger(dri_message);
+
    /*
     ** Initialize the direct rendering per display data and functions.
     ** Note: This _must_ be done before calling any other DRI routines