Applied a patch from Nils Labugt which fixes a bug in the gui_core component (Bug ID: 3171720).

The bug details are below:
    dlib GUI applications don't work anymore after I upgraded to Ubuntu 10.10 (AMD64). They
    consistently crash in base_window::set_title. XwcTextListToTextProperty returns
    XLocaleNotSupported instead of initializing 'property', but dlib ignores the return value,
    resulting in a crash in XLib when XSetWMName is called with garbage input or when
    property.value is XFreed without having been allocated.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404120
This commit is contained in:
Davis King 2011-02-03 22:45:24 +00:00
parent 8f118e3e12
commit c547e7bcc5
1 changed files with 5 additions and 3 deletions

View File

@ -183,7 +183,7 @@ namespace dlib
{ {
// You are supposed to call this if using XLib in a threaded program. Note // You are supposed to call this if using XLib in a threaded program. Note
// however that at one point I nocied that calling this causes a dead-lock // however that at one point I noticed that calling this causes a dead-lock
// when using XIM. But I can't reproduce that anymore and not calling it // when using XIM. But I can't reproduce that anymore and not calling it
// sometimes causes XCloseDisplay() to hang. // sometimes causes XCloseDisplay() to hang.
if (XInitThreads() == 0) if (XInitThreads() == 0)
@ -225,9 +225,11 @@ namespace dlib
xim = NULL; xim = NULL;
window_table.get_mutex().lock(); window_table.get_mutex().lock();
if (setlocale( LC_CTYPE, "" ) && XSupportsLocale() && XSetLocaleModifiers("")){ std::string saved_locale(setlocale (LC_CTYPE, NULL));
if (setlocale( LC_CTYPE, "" ) && XSupportsLocale() && XSetLocaleModifiers(""))
xim = XOpenIM(disp, NULL, NULL, NULL); xim = XOpenIM(disp, NULL, NULL, NULL);
} else
setlocale( LC_CTYPE, saved_locale.c_str() );
window_table.get_mutex().unlock(); window_table.get_mutex().unlock();
if (xim) if (xim)