Commit e68116ca authored by Davis King's avatar Davis King

Made X11 code a little more robust (I think).

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403857
parent 29e07bdf
...@@ -182,8 +182,10 @@ namespace dlib ...@@ -182,8 +182,10 @@ namespace dlib
try try
{ {
/* // You are supposed to call this if using XLib in a threaded program. Note
// causes dead-lock when using with XIM // however that at one point I nocied that calling this causes a dead-lock
// when using XIM. But I can't reproduce that anymore and not calling it
// sometimes causes XCloseDisplay() to hang.
if (XInitThreads() == 0) if (XInitThreads() == 0)
{ {
dlog << LFATAL << "Unable to initialize threading support."; dlog << LFATAL << "Unable to initialize threading support.";
...@@ -194,7 +196,6 @@ namespace dlib ...@@ -194,7 +196,6 @@ namespace dlib
window_table.get_mutex().unlock(); window_table.get_mutex().unlock();
return; return;
} }
*/
window_table.get_mutex().lock(); window_table.get_mutex().lock();
disp = XOpenDisplay(NULL); disp = XOpenDisplay(NULL);
...@@ -1675,6 +1676,14 @@ namespace dlib ...@@ -1675,6 +1676,14 @@ namespace dlib
{ {
using namespace gui_core_kernel_2_globals; using namespace gui_core_kernel_2_globals;
close_window(); close_window();
if (x11_stuff.globals->xim != NULL)
{
XDestroyIC(x11_stuff.xic);
x11_stuff.xic = 0;
XFreeFontSet(x11_stuff.globals->disp,x11_stuff.fs);
}
delete &x11_stuff; delete &x11_stuff;
} }
...@@ -1691,12 +1700,6 @@ namespace dlib ...@@ -1691,12 +1700,6 @@ namespace dlib
has_been_destroyed = true; has_been_destroyed = true;
x11_stuff.globals->window_table.destroy(x11_stuff.hwnd); x11_stuff.globals->window_table.destroy(x11_stuff.hwnd);
if (x11_stuff.globals->xim != NULL)
{
XDestroyIC(x11_stuff.xic);
x11_stuff.xic = 0;
XFreeFontSet(x11_stuff.globals->disp,x11_stuff.fs);
}
XDestroyWindow(x11_stuff.globals->disp,x11_stuff.hwnd); XDestroyWindow(x11_stuff.globals->disp,x11_stuff.hwnd);
x11_stuff.hwnd = 0; x11_stuff.hwnd = 0;
......
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