Commit c52e0409 authored by Mike Blumenkrantz's avatar Mike Blumenkrantz Committed by Carsten Haitzler (Rasterman)

ecore-x: perform internal shutdown on io error if callback is set

avoid crashing in callback when referencing dead display or handling events

@fix
parent ebd903e0
......@@ -783,14 +783,11 @@ ecore_x_init_from_display(Ecore_X_Display *display)
return --_ecore_x_init_count;
}
static int
_ecore_x_shutdown(int close_display)
int
_ecore_x_shutdown(void)
{
if (--_ecore_x_init_count != 0)
return _ecore_x_init_count;
if (!_ecore_x_disp)
return _ecore_x_init_count;
return 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
......@@ -857,19 +854,9 @@ _ecore_x_shutdown(int close_display)
ECORE_X_EVENT_PRESENT_COMPLETE,
ECORE_X_EVENT_PRESENT_IDLE);
ecore_main_fd_handler_del(_ecore_x_fd_handler_handle);
if (close_display)
XCloseDisplay(_ecore_x_disp);
else
{
close(ConnectionNumber(_ecore_x_disp));
// FIXME: may have to clean up x display internal here
// getting segv here? hmmm. odd. disable
// XFree(_ecore_x_disp);
}
free(_ecore_x_event_handlers);
_ecore_x_fd_handler_handle = NULL;
_ecore_x_disp = NULL;
_ecore_x_event_handlers = NULL;
_ecore_x_events_shutdown();
_ecore_x_input_shutdown();
......@@ -877,6 +864,12 @@ _ecore_x_shutdown(int close_display)
_ecore_x_dnd_shutdown();
ecore_x_netwm_shutdown();
return 0;
}
static void
_ecore_x_shutdown2(void)
{
ecore_event_shutdown();
ecore_shutdown();
......@@ -884,8 +877,6 @@ _ecore_x_shutdown(int close_display)
_ecore_xlib_log_dom = -1;
eina_shutdown();
_ecore_xlib_sync = EINA_FALSE;
return _ecore_x_init_count;
}
/**
......@@ -901,7 +892,14 @@ _ecore_x_shutdown(int close_display)
EAPI int
ecore_x_shutdown(void)
{
return _ecore_x_shutdown(1);
if (--_ecore_x_init_count != 0)
return _ecore_x_init_count;
if (_ecore_x_shutdown()) return _ecore_x_init_count;
if (_ecore_x_disp)
XCloseDisplay(_ecore_x_disp);
_ecore_x_disp = NULL;
_ecore_x_shutdown2();
return 0;
}
/**
......@@ -914,7 +912,16 @@ ecore_x_shutdown(void)
EAPI int
ecore_x_disconnect(void)
{
return _ecore_x_shutdown(0);
if (--_ecore_x_init_count != 0)
return _ecore_x_init_count;
if (_ecore_x_shutdown()) return _ecore_x_init_count;
close(ConnectionNumber(_ecore_x_disp));
// FIXME: may have to clean up x display internal here
// getting segv here? hmmm. odd. disable
// XFree(_ecore_x_disp);
_ecore_x_disp = NULL;
_ecore_x_shutdown2();
return 0;
}
/**
......
......@@ -172,7 +172,11 @@ _ecore_x_io_error_handle(Display *d)
if (d == _ecore_x_disp)
{
if (_io_error_func)
_io_error_func(_io_error_data);
{
_ecore_x_disp = NULL;
_ecore_x_shutdown();
_io_error_func(_io_error_data);
}
else
exit(-1);
}
......
......@@ -396,6 +396,7 @@ Ecore_Event_Mouse_Button *_ecore_mouse_button(int event,
void _ecore_x_modifiers_get(void);
KeySym _ecore_x_XKeycodeToKeysym(Display *display, KeyCode keycode, int index);
int _ecore_x_shutdown(void);
//#define LOGFNS 1
#ifdef LOGFNS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment