Package: gtk-theme-switch
Followup-For: Bug #229384
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm not sure whether all of this applies to bug #229384, but some of
it does, so here goes.
switch (i.e. switch for gtk 1.x) wouldn't change themes for me at
all. (Actually, it's more complex than that: it works on one of my
Debian boxes, but not the rest). In addition, I'd get a few
Gtk-CRITICAL errors when I tried to change themes, including the
> Gtk-CRITICAL **: file gtkentry.c: line 440 (gtk_entry_set_text):
> assertion `text != NULL' failed.
reported by the originator of this bug.
I've found several problems. The major one for me (which caused the
non-changing theme fault) was in the get_dirs() function when adding
the theme and its directory into the hash table (two places; around
lines 77 and 100 in switch.c):
> g_hash_table_insert (hash, dent->d_name, dirname);
dirname is an automatic variable, which means that it'll be gone once
the function ends. In fact, it's changed in the function anyway. dent,
for its part, is an iteration variable which will change as we go
through the loop. In both cases, the solution is to make a copy with
g_strdup() and put the copy in the hash instead.
I also removed the two warnings about not freeing dirname, which only
confused the issue.
I have no idea how this ever worked: a lot depends, I suppose, on the
contents of memory when you run switch. On my machine, my ~/.gtkrc had
something like
> include "(null)/Smooth-Sea-Ice/gtk/gtkrc"
instead of
> include "/usr/share/themes/Smooth-Sea-Ice/gtk/gtkrc"
after I ran switch, and that's why the theme didn't change.
Now to the other problem. My ~/.gtkrc doesn't have any font
specified, which may explain the GTK-CRITICAL errors. They occur in
two places in switch.c, around line 189 and line 413. If
style->rc_style->font_name is null (as it was on my boxes),
gtk_entry_set_text() throws the error noted above. The fix is to add a
check for font_name being null before calling gtk_entry_set_text().
These problems may be related to other bugs, too (perhaps #244968
and #255723). I should note that I've been getting the occasional
segfault, which I can't reliably reproduce (even when I repeat the
actions that caused it), so there may be other dangling pointers
around. I'll keep looking as time permits.
Patch attached.
.....Ron
P.S. Ignore the "2.0.4rjmx3" version number. It's just 2.0.4 with the
attached patch.
- -- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)
Kernel: Linux 2.6.21.1-khufu-0
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash
Versions of packages gtk-theme-switch depends on:
ii libatk1.0-0 1.12.4-3 The ATK accessibility toolkit
ii libc6 2.3.6.ds1-13 GNU C Library: Shared libraries
ii libcairo2 1.2.4-4 The Cairo 2D vector graphics libra
ii libfontconfig1 2.4.2-1.2 generic font configuration library
ii libglib1.2 1.2.10-17 The GLib library of C routines
ii libglib2.0-0 2.12.4-2 The GLib library of C routines
ii libgtk1.2 1.2.10-18 The GIMP Toolkit set of widgets fo
ii libgtk2.0-0 2.8.20-7 The GTK+ graphical user interface
ii libpango1.0-0 1.14.8-5 Layout and rendering of internatio
ii libx11-6 2:1.0.3-7 X11 client-side library
ii libxcursor1 1.1.7-4 X cursor management library
ii libxext6 1:1.0.1-2 X11 miscellaneous extension librar
ii libxfixes3 1:4.0.1-5 X11 miscellaneous 'fixes' extensio
ii libxi6 1:1.0.1-4 X11 Input extension library
ii libxinerama1 1:1.0.1-4.1 X11 Xinerama extension library
ii libxrandr2 2:1.1.0.2-5 X11 RandR extension library
ii libxrender1 1:0.9.1-3 X Rendering Extension client libra
Versions of packages gtk-theme-switch recommends:
ii gtk-engines-pixmap 0.12-8.1 Pixmap-based theme for GTK+ 1.2
- -- debconf-show failed
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFGUmtMitqjxNhsdN4RAjoVAJsGsnmFe6zVkwYXCqYOpVjeMB6RPwCfSEiu
5EmBIr8TS8pmIg808PDeKoE=
=3HSf
-----END PGP SIGNATURE-----
*** switch.c.orig Sat Apr 30 20:28:31 2005
--- switch.c Mon May 21 22:54:03 2007
***************
*** 68,112 ****
{
while ((dent = readdir (dir)))
{
! gchar* gtkrc_path = g_strconcat(dent->d_name, "/gtk/gtkrc", NULL);
stat(dent->d_name,&stats);
if (!S_ISDIR(stats.st_mode)) continue;
if (strcmp(dent->d_name,"." ) == 0) continue;
if (strcmp(dent->d_name,"..") == 0) continue;
! if (access(gtkrc_path, R_OK) == -1) continue;
! g_hash_table_insert (hash, dent->d_name, dirname);
! list = g_list_insert_sorted(list, g_strdup(dent->d_name), (GCompareFunc)strcmp);
g_free(gtkrc_path);
}
}
-
- /* DO NOT FREE dirname!! */
- /* We are supposed to. */
- /* But we need our own copy anyway, to store in the hash table */
! dirname = gtk_rc_get_theme_dir();
chdir (dirname);
dir = opendir (dirname);
if (dir)
{
while ((dent = readdir (dir)))
{
! gchar* gtkrc_path = g_strconcat(dent->d_name, "/gtk/gtkrc", NULL);
stat(dent->d_name,&stats);
if (!S_ISDIR(stats.st_mode)) continue;
if (strcmp(dent->d_name, "." ) == 0) continue;
if (strcmp(dent->d_name, "..") == 0) continue;
if (access(gtkrc_path, R_OK) == -1) continue;
! g_hash_table_insert (hash, dent->d_name, dirname);
! list = g_list_insert_sorted(list, g_strdup(dent->d_name), (GCompareFunc)strcmp);
! g_free(gtkrc_path);
}
}
-
- /* DO NOT FREE dirname!! */
- /* We are supposed to. */
- /* But we need our own copy anyway, to store in the hash table */
chdir(origdir); /* Go back to where we were */
g_free(origdir); /* Now go play like a good little program */
--- 68,112 ----
{
while ((dent = readdir (dir)))
{
! gchar* gtkrc_path = g_strconcat(dent->d_name, "/gtk/gtkrc", NULL);
stat(dent->d_name,&stats);
if (!S_ISDIR(stats.st_mode)) continue;
if (strcmp(dent->d_name,"." ) == 0) continue;
if (strcmp(dent->d_name,"..") == 0) continue;
! if (access(gtkrc_path, R_OK) == -1) continue;
! g_hash_table_insert (hash, g_strdup(dent->d_name),
! g_strdup(dirname));
! list = g_list_insert_sorted(list, g_strdup(dent->d_name),
! (GCompareFunc)strcmp);
g_free(gtkrc_path);
}
}
! g_free(dirname);
!
! dirname = gtk_rc_get_theme_dir();
chdir (dirname);
dir = opendir (dirname);
if (dir)
{
while ((dent = readdir (dir)))
{
! gchar* gtkrc_path = g_strconcat(dent->d_name, "/gtk/gtkrc", NULL);
stat(dent->d_name,&stats);
if (!S_ISDIR(stats.st_mode)) continue;
if (strcmp(dent->d_name, "." ) == 0) continue;
if (strcmp(dent->d_name, "..") == 0) continue;
if (access(gtkrc_path, R_OK) == -1) continue;
! g_hash_table_insert (hash, g_strdup(dent->d_name),
! g_strdup(dirname));
! list = g_list_insert_sorted(list, g_strdup(dent->d_name),
! (GCompareFunc)strcmp);
! g_free(gtkrc_path);
}
}
+ g_free(dirname);
+
chdir(origdir); /* Go back to where we were */
g_free(origdir); /* Now go play like a good little program */
***************
*** 173,181 ****
gchar *dir = g_hash_table_lookup(hash,entry);
gchar *name = g_strdup_printf ("%s/%s/gtk/gtkrc", dir, entry);
GtkStyle *style;
-
update_newfont ();
!
ok_clicked(name);
g_free(name);
--- 173,180 ----
gchar *dir = g_hash_table_lookup(hash,entry);
gchar *name = g_strdup_printf ("%s/%s/gtk/gtkrc", dir, entry);
GtkStyle *style;
update_newfont ();
!
ok_clicked(name);
g_free(name);
***************
*** 185,191 ****
/* sync the font field with the GTK font */
style = gtk_rc_get_style (font_entry);
! if (style && style->rc_style)
gtk_entry_set_text (GTK_ENTRY(font_entry), style->rc_style->font_name);
}
--- 184,190 ----
/* sync the font field with the GTK font */
style = gtk_rc_get_style (font_entry);
! if (style && style->rc_style && style->rc_style->font_name)
gtk_entry_set_text (GTK_ENTRY(font_entry), style->rc_style->font_name);
}
***************
*** 388,394 ****
gtk_container_add(GTK_CONTAINER(evbox), pixmap);
gtk_box_pack_start(GTK_BOX(box),evbox,FALSE,FALSE,FALSE);
! gtk_widget_show_all(box);
box = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dockwin)->vbox), box, FALSE, FALSE, 0);
--- 387,393 ----
gtk_container_add(GTK_CONTAINER(evbox), pixmap);
gtk_box_pack_start(GTK_BOX(box),evbox,FALSE,FALSE,FALSE);
! gtk_widget_show_all(box);
box = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dockwin)->vbox), box, FALSE, FALSE, 0);
***************
*** 409,415 ****
else
{
GtkStyle *style = gtk_rc_get_style (font_entry);
! if (style && style->rc_style)
gtk_entry_set_text (GTK_ENTRY(font_entry), style->rc_style->font_name);
}
--- 408,414 ----
else
{
GtkStyle *style = gtk_rc_get_style (font_entry);
! if (style && style->rc_style && style->rc_style->font_name)
gtk_entry_set_text (GTK_ENTRY(font_entry), style->rc_style->font_name);
}