diff -urp Xcursor.orig/ChangeLog Xcursor/ChangeLog --- Xcursor.orig/ChangeLog 2005-01-03 17:24:43.000000000 -0600 +++ Xcursor/ChangeLog 2005-09-12 09:39:14.000000000 -0500 @@ -1,3 +1,23 @@ +2005-09-12 Federico Mena Quintero + + Fixes bug #4244: + + * xcursorint.h (XcursorDisplayInfo): Added a "theme_from_config" + field. We store the configuration's value for Xcursor.theme in + here, and we refer to it if the user calls + XcursorSetTheme(dpy, NULL). + + * display.c (_XcursorGetDisplayInfo): Fill in the + info->theme_from_config. + (_XcursorFreeDisplayInfo): New utility function to free the fields + of a XcursorDisplayInfo and then free the structure itself. + (_XcursorCloseDisplay): Use _XcursorFreeDisplayInfo() instead of + freeing the info ourselves. + (_XcursorGetDisplayInfo): Likewise. + (XcursorSetTheme): If the specified theme is null, use the + info->theme_from_config to reset the theme name to the one set in + the configuration. + 2004-02-24 Fredrik Höglund * configure.ac: diff -urp Xcursor.orig/display.c Xcursor/display.c --- Xcursor.orig/display.c 2005-01-03 17:24:43.000000000 -0600 +++ Xcursor/display.c 2005-09-12 09:38:50.000000000 -0500 @@ -27,6 +27,18 @@ static XcursorDisplayInfo *_XcursorDisplayInfo; +static void +_XcursorFreeDisplayInfo (XcursorDisplayInfo *info) +{ + if (info->theme) + free (info->theme); + + if (info->theme_from_config) + free (info->theme_from_config); + + free (info); +} + static int _XcursorCloseDisplay (Display *dpy, XExtCodes *codes) { @@ -43,10 +55,8 @@ _XcursorCloseDisplay (Display *dpy, XExt break; } _XUnlockMutex (_Xglobal_lock); - - if (info->theme) - free (info->theme); - free (info); + + _XcursorFreeDisplayInfo (info); return 0; } @@ -189,6 +199,7 @@ _XcursorGetDisplayInfo (Display *dpy) } info->theme = 0; + info->theme_from_config = 0; /* * Get the desired theme @@ -198,9 +209,17 @@ _XcursorGetDisplayInfo (Display *dpy) v = XGetDefault (dpy, "Xcursor", "theme"); if (v) { - info->theme = malloc (strlen (v) + 1); + int len; + + len = strlen (v) + 1; + + info->theme = malloc (len); if (info->theme) strcpy (info->theme, v); + + info->theme_from_config = malloc (len); + if (info->theme_from_config) + strcpy (info->theme_from_config, v); } /* @@ -252,9 +271,7 @@ _XcursorGetDisplayInfo (Display *dpy) break; if (old) { - if (info->theme) - free (info->theme); - free (info); + _XcursorFreeDisplayInfo (info); info = old; } else @@ -312,6 +329,10 @@ XcursorSetTheme (Display *dpy, const cha if (!info) return XcursorFalse; + + if (!theme) + theme = info->theme_from_config; + if (theme) { copy = malloc (strlen (theme) + 1); diff -urp Xcursor.orig/xcursorint.h Xcursor/xcursorint.h --- Xcursor.orig/xcursorint.h 2005-01-03 17:24:43.000000000 -0600 +++ Xcursor/xcursorint.h 2005-09-12 09:29:06.000000000 -0500 @@ -85,6 +85,7 @@ typedef struct _XcursorDisplayInfo { int size; XcursorFontInfo *fonts; char *theme; + char *theme_from_config; XcursorDither dither; XcursorBitmapInfo bitmaps[NUM_BITMAPS]; } XcursorDisplayInfo;