egl: Fix Terminate with shared gbm screens
authorBenjamin Franzke <benjaminfranzke@googlemail.com>
Mon, 27 Jun 2011 08:23:34 +0000 (10:23 +0200)
committerBenjamin Franzke <benjaminfranzke@googlemail.com>
Mon, 27 Jun 2011 08:25:12 +0000 (10:25 +0200)
NOTE: This is a candidate for the 7.11 branch.

src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/egl_dri2.h
src/gallium/state_trackers/egl/drm/native_drm.c

index f9a5eb108e50e91864f45b1330b2ca089077fc43..5680c360f1d3c20110526002befa3b2b17cfafba 100644 (file)
@@ -506,6 +506,8 @@ dri2_create_screen(_EGLDisplay *disp)
       return EGL_FALSE;
    }
 
+   dri2_dpy->own_dri_screen = 1;
+
    extensions = dri2_dpy->core->getExtensions(dri2_dpy->dri_screen);
    
    if (dri2_dpy->dri2) {
@@ -576,10 +578,12 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
    _eglReleaseDisplayResources(drv, disp);
    _eglCleanupDisplay(disp);
 
-   dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen);
+   if (dri2_dpy->own_dri_screen)
+      dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen);
    if (dri2_dpy->fd)
       close(dri2_dpy->fd);
-   dlclose(dri2_dpy->driver);
+   if (dri2_dpy->driver)
+      dlclose(dri2_dpy->driver);
 
    if (disp->PlatformDisplay == NULL) {
       switch (disp->Platform) {
index cd52d421ddf07b0854f5c25c748f02eb5faa6384..83ea21e5dc85479420b5fde02c06f36eda654682 100644 (file)
@@ -71,6 +71,7 @@ struct dri2_egl_display
    int                       dri2_major;
    int                       dri2_minor;
    __DRIscreen              *dri_screen;
+   int                       own_dri_screen;
    const __DRIconfig       **driver_configs;
    void                     *driver;
    __DRIcoreExtension       *core;
index de4eb852eb7913e4a93283d69988b633208a7951..47910de8d3c4b138cbf8c65c9b8520737852467c 100644 (file)
@@ -127,6 +127,8 @@ drm_display_destroy(struct native_display *ndpy)
 
    drm_display_fini_modeset(&drmdpy->base);
 
+   /* gbm owns screen */
+   ndpy->screen = NULL;
    ndpy_uninit(ndpy);
 
    if (drmdpy->device_name)