Commit 290494bb authored by Davis King's avatar Davis King

Fixed some of the errors in the X11 gui stuff that

come out of valgrind.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402509
parent 363d6884
...@@ -41,6 +41,7 @@ namespace dlib ...@@ -41,6 +41,7 @@ namespace dlib
Window hwnd; Window hwnd;
Time last_click_time; Time last_click_time;
XIC xic; XIC xic;
XFontSet fs;
}; };
typedef sync_extension<binary_search_tree<Window,base_window*>::kernel_1a>::kernel_1a typedef sync_extension<binary_search_tree<Window,base_window*>::kernel_1a>::kernel_1a
...@@ -48,7 +49,7 @@ namespace dlib ...@@ -48,7 +49,7 @@ namespace dlib
int depth; int depth;
Display* disp; Display* disp;
static XIM xim; static XIM xim = NULL;
static XIMStyle xim_style; static XIMStyle xim_style;
static Screen* screen; static Screen* screen;
...@@ -379,6 +380,7 @@ namespace dlib ...@@ -379,6 +380,7 @@ namespace dlib
auto_mutex window_table_locker(window_table.get_mutex()); auto_mutex window_table_locker(window_table.get_mutex());
XEvent ev; XEvent ev;
memset(&ev, 0, sizeof(ev));
while (XPending(disp) == 0){ while (XPending(disp) == 0){
window_table.get_mutex().unlock(); window_table.get_mutex().unlock();
// wait until receiving X11 next event // wait until receiving X11 next event
...@@ -1032,7 +1034,15 @@ namespace dlib ...@@ -1032,7 +1034,15 @@ namespace dlib
XFlush(disp); XFlush(disp);
wait(); wait();
if (xim != NULL)
{
XCloseIM(xim);
}
XCloseDisplay(disp); XCloseDisplay(disp);
} }
else else
{ {
...@@ -1134,6 +1144,7 @@ namespace dlib ...@@ -1134,6 +1144,7 @@ namespace dlib
} }
if (xim_style) break; if (xim_style) break;
} }
XFree(xim_styles);
} }
// make this window just so we can send messages to it and trigger // make this window just so we can send messages to it and trigger
...@@ -1571,10 +1582,10 @@ namespace dlib ...@@ -1571,10 +1582,10 @@ namespace dlib
char fontset[256]; char fontset[256];
const long native_font_height = 12; const long native_font_height = 12;
sprintf(fontset, "-*-*-medium-r-normal--%lu-*-*-*-", native_font_height); sprintf(fontset, "-*-*-medium-r-normal--%lu-*-*-*-", native_font_height);
XFontSet fs = XCreateFontSet(gui_core_kernel_2_globals::disp, fontset, &mlist, &mcount, &def_str); x11_stuff.fs = XCreateFontSet(gui_core_kernel_2_globals::disp, fontset, &mlist, &mcount, &def_str);
xpoint.x = 0; xpoint.x = 0;
xpoint.y = 0; xpoint.y = 0;
xva_nlist = XVaCreateNestedList(0, XNSpotLocation, &xpoint, XNFontSet, fs, NULL); xva_nlist = XVaCreateNestedList(0, XNSpotLocation, &xpoint, XNFontSet, x11_stuff.fs, NULL);
x11_stuff.xic = XCreateIC( x11_stuff.xic = XCreateIC(
gui_core_kernel_2_globals::xim, gui_core_kernel_2_globals::xim,
XNInputStyle, gui_core_kernel_2_globals::xim_style, XNInputStyle, gui_core_kernel_2_globals::xim_style,
...@@ -1583,6 +1594,7 @@ namespace dlib ...@@ -1583,6 +1594,7 @@ namespace dlib
NULL NULL
); );
XFree(xva_nlist); XFree(xva_nlist);
XFreeStringList(mlist);
} }
Window temp = x11_stuff.hwnd; Window temp = x11_stuff.hwnd;
...@@ -1651,10 +1663,11 @@ namespace dlib ...@@ -1651,10 +1663,11 @@ namespace dlib
has_been_destroyed = true; has_been_destroyed = true;
gui_core_kernel_2_globals::window_table.destroy(x11_stuff.hwnd); gui_core_kernel_2_globals::window_table.destroy(x11_stuff.hwnd);
if (x11_stuff.xic) if (gui_core_kernel_2_globals::xim != NULL)
{ {
XDestroyIC(x11_stuff.xic); XDestroyIC(x11_stuff.xic);
x11_stuff.xic = 0; x11_stuff.xic = 0;
XFreeFontSet(gui_core_kernel_2_globals::disp,x11_stuff.fs);
} }
XDestroyWindow(gui_core_kernel_2_globals::disp,x11_stuff.hwnd); XDestroyWindow(gui_core_kernel_2_globals::disp,x11_stuff.hwnd);
......
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