[cogl] kms: gracefully handle NULL save_state at cleanup



commit 0f33c942f2f1599866416dcc9215cd9f8dc3f35d
Author: Robert Bragg <robert linux intel com>
Date:   Mon Jan 23 15:39:10 2012 +0000

    kms: gracefully handle NULL save_state at cleanup
    
    If we failed to save any crtc state then we skip trying to restore the
    old state at cleanup.
    
    Reviewed-by: Neil Roberts <neil linux intel com>

 cogl/winsys/cogl-winsys-egl-kms.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/cogl/winsys/cogl-winsys-egl-kms.c b/cogl/winsys/cogl-winsys-egl-kms.c
index b39c45d..7864bd2 100644
--- a/cogl/winsys/cogl-winsys-egl-kms.c
+++ b/cogl/winsys/cogl-winsys-egl-kms.c
@@ -297,19 +297,22 @@ _cogl_winsys_egl_cleanup_context (CoglDisplay *display)
   CoglRenderer *renderer = display->renderer;
   CoglRendererEGL *egl_renderer = renderer->winsys;
   CoglRendererKMS *kms_renderer = egl_renderer->platform;
-  int ret;
 
   /* Restore the saved CRTC - this failing should not propagate an error */
-  ret = drmModeSetCrtc (kms_renderer->fd,
-                        kms_display->saved_crtc->crtc_id,
-                        kms_display->saved_crtc->buffer_id,
-                        kms_display->saved_crtc->x, kms_display->saved_crtc->y,
-                        &kms_display->connector->connector_id, 1,
-                        &kms_display->saved_crtc->mode);
-  if (ret)
-    g_critical (G_STRLOC ": Error restoring saved CRTC");
-
-  drmModeFreeCrtc (kms_display->saved_crtc);
+  if (kms_display->saved_crtc)
+    {
+      int ret = drmModeSetCrtc (kms_renderer->fd,
+                                kms_display->saved_crtc->crtc_id,
+                                kms_display->saved_crtc->buffer_id,
+                                kms_display->saved_crtc->x,
+                                kms_display->saved_crtc->y,
+                                &kms_display->connector->connector_id, 1,
+                                &kms_display->saved_crtc->mode);
+      if (ret)
+        g_critical (G_STRLOC ": Error restoring saved CRTC");
+
+      drmModeFreeCrtc (kms_display->saved_crtc);
+    }
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]