[PATCH weston 3/4] compositor-drm: Make drm_destroy safe during init
Daniel Stone
daniel at fooishbar.org
Mon Jun 18 11:10:32 PDT 2012
Make drm_destroy a bit more paranoid, so it's safe to call it during
initialisation.
Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
src/compositor-drm.c | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index c91b2be..d1715c6 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1436,6 +1436,9 @@ destroy_sprites(struct drm_compositor *compositor)
struct drm_sprite *sprite, *next;
struct drm_output *output;
+ if (wl_list_empty(&compositor->base.output_list))
+ return;
+
output = container_of(compositor->base.output_list.next,
struct drm_output, base.link);
@@ -1628,22 +1631,34 @@ drm_destroy(struct weston_compositor *ec)
wl_list_for_each_safe(seat, next, &ec->seat_list, link)
evdev_input_destroy(seat);
- wl_event_source_remove(d->udev_drm_source);
- wl_event_source_remove(d->drm_source);
+ if (d->udev_drm_source)
+ wl_event_source_remove(d->udev_drm_source);
+ if (d->drm_source)
+ wl_event_source_remove(d->drm_source);
weston_compositor_shutdown(ec);
/* Work around crash in egl_dri2.c's dri2_make_current() */
- eglMakeCurrent(ec->display, EGL_NO_SURFACE, EGL_NO_SURFACE,
- EGL_NO_CONTEXT);
- eglTerminate(ec->display);
- eglReleaseThread();
+ if (ec->display) {
+ eglMakeCurrent(ec->display, EGL_NO_SURFACE, EGL_NO_SURFACE,
+ EGL_NO_CONTEXT);
+ eglTerminate(ec->display);
+ eglReleaseThread();
+ }
- gbm_device_destroy(d->gbm);
+ if (d->gbm)
+ gbm_device_destroy(d->gbm);
destroy_sprites(d);
- if (weston_launcher_drm_set_master(&d->base, d->drm.fd, 0) < 0)
- weston_log("failed to drop master: %m\n");
- tty_destroy(d->tty);
+
+ if (d->drm.fd >= 0)
+ if (weston_launcher_drm_set_master(&d->base, d->drm.fd, 0) < 0)
+ weston_log("failed to drop master: %m\n");
+
+ if (d->tty)
+ tty_destroy(d->tty);
+
+ if (d->udev)
+ udev_unref(d->udev);
free(d);
}
--
1.7.10
More information about the wayland-devel
mailing list