Created attachment 3485 Fix for the bug To reproduce: 1. install a CD drive 2. remove media from the drive 3. open Thunar 4. insert a CD that has a special icon (e.g. a Windows game) 5. click on the CD drive in the side pane and wait until it is mounted 6. navigate to computer:/// 7. move the cursor over the CD drive entry Result: GLib-GIO-CRITICAL **: char *g_file_get_path(GFile *): assertion `G_IS_FILE (file)' failed (more assertion failures and maybe crash)
That's weird. g_file_icon_get_file() returns the icon->file member of the GFileIcon and g_object_get(..., "file", &icon_file, ...) returns exactly the same thing, or should do that at least. You can see this here: http://git.gnome.org/browse/glib/tree/gio/gfileicon.c Do you know if this was different in older releases of GLib?
Sorry, I don't really know why the original code crashes. Seems like the cast of GIcon to GFileIcon is done wrong, but I've never done any GLib programming. I just changed it do use a propery like the code a few line above does for themed icons.
I checked again in the GLib/GIO source code and both ways should work exactly the same way. g_file_icon_get_file() was even introduced before there was a "file" property, so I think it is the better choice. The cast is correct but still... I wonder why the patch works for you and the current code doesn't...
You're right, there's nothing wrong with that piece of code. This smells of memory corruption. I'll investigate further. Can you reproduce it? I should note that it has to be a CD/DVD; a .desktop file with an absolute file for Icon will not trigger it.
I cannot reproduce it yet because I first have to find a CD with a special icon. ;)
Created attachment 3487 Better fix for the bug Got it! :)
Yep, that's indeed it. g_file_icon_get_file() doesn't increase the reference count of the GFile it returns. Good catch! Fixed in master and the xfce-4.8 branch. I've credited you as the author of the commit: commit d5739ef148b02a5212dea2c0d7dcb7de4c79dd46 Author: Ambroz Bizjak <ambrop7@gmail.com> Date: Sat Feb 19 18:26:20 2011 +0100 Don't decrease refcount of files returned by GFileIcon (bug #7309). This fixes a crash when hovering CD drives with a special icon in computer://. Signed-off-by: Jannis Pohlmann <jannis@xfce.org>