[357/906] x11: Don't crash when the X11 display is not available.

Error out cleanly instead of crashing when the X11 display can't
be contacted.
This commit is contained in:
Jan Schmidt 2009-07-13 12:52:31 +01:00 committed by Tim-Philipp Müller
parent 3fbe0f0a98
commit 4ddbded3a8

View file

@ -102,7 +102,7 @@ gst_gl_window_finalize (GObject * object)
g_mutex_lock (priv->x_lock); g_mutex_lock (priv->x_lock);
priv->parent = 0; priv->parent = 0;
if (priv->device) {
XUnmapWindow (priv->device, priv->internal_win_id); XUnmapWindow (priv->device, priv->internal_win_id);
ret = glXMakeCurrent (priv->device, None, NULL); ret = glXMakeCurrent (priv->device, None, NULL);
@ -114,9 +114,7 @@ gst_gl_window_finalize (GObject * object)
XFree (priv->visual_info); XFree (priv->visual_info);
XReparentWindow (priv->device, priv->internal_win_id, priv->root, 0, 0); XReparentWindow (priv->device, priv->internal_win_id, priv->root, 0, 0);
XDestroyWindow (priv->device, priv->internal_win_id); XDestroyWindow (priv->device, priv->internal_win_id);
XSync (priv->device, FALSE); XSync (priv->device, FALSE);
while (XPending (priv->device)) while (XPending (priv->device))
@ -137,10 +135,9 @@ gst_gl_window_finalize (GObject * object)
//XCloseDisplay (priv->device); //XCloseDisplay (priv->device);
g_debug ("display receiver closed\n"); g_debug ("display receiver closed\n");
XCloseDisplay (priv->disp_send); XCloseDisplay (priv->disp_send);
g_debug ("display sender closed\n"); g_debug ("display sender closed\n");
}
if (priv->cond_send_message) { if (priv->cond_send_message) {
g_cond_free (priv->cond_send_message); g_cond_free (priv->cond_send_message);
@ -280,6 +277,8 @@ gst_gl_window_new (gint width, gint height, gulong external_gl_context)
g_mutex_lock (priv->x_lock); g_mutex_lock (priv->x_lock);
priv->device = XOpenDisplay (priv->display_name); priv->device = XOpenDisplay (priv->display_name);
if (priv->device == NULL)
goto no_display;
XSynchronize (priv->device, FALSE); XSynchronize (priv->device, FALSE);
@ -410,6 +409,10 @@ gst_gl_window_new (gint width, gint height, gulong external_gl_context)
g_mutex_unlock (priv->x_lock); g_mutex_unlock (priv->x_lock);
return window; return window;
no_display:
g_mutex_unlock (priv->x_lock);
g_object_unref (window);
return NULL;
} }
GQuark GQuark