Hello,
When running 'yad --file --add-preview', if the user enter into a directory containing pipe file(s) and the selection is moved to one of these, yad freezes.
How to reproduce :
$ mkdir /tmp/FREEZE-TEST $ echo -n "" > /tmp/FREEZE-TEST/file1.txt $ echo -n "" > /tmp/FREEZE-TEST/file2.txt $ mkfifo /tmp/FREEZE-TEST/pipe1.txt $ yad --center --width=800 --height=600 --file --add-preview --filename=/tmp/FREEZE-TEST # Select the file /tmp/FREEZE-TEST/pipe1.txt, to freeze yad.
backtrace (snippet):
0x00007f5cf741d714 in open64 () from /lib64/libc.so.6 #0 0x00007f5cf741d714 in open64 () at /lib64/libc.so.6 #1 0x00007f5cf73a5382 in _IO_file_open () at /lib64/libc.so.6 #2 0x00007f5cf73a56a2 in __GI__IO_file_fopen () at /lib64/libc.so.6 #3 0x00007f5cf7398bca in fopen@@GLIBC_2.2.5 () at /lib64/libc.so.6 #4 0x00007f5cf7a7e7b7 in gdk_pixbuf_new_from_file_at_scale () at /usr/lib64/libgdk_pixbuf-2.0.so.0 #5 0x000000000042a272 in update_preview (chooser=0x23d9c80, p=0x247f700) at util.c:192 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Below (and in attachment) a patch to fix this issue :
--- src/util.c.orig 2021-05-29 15:08:10.286076412 +0200 +++ src/util.c 2021-07-13 16:50:40.645399423 +0200 @@ -185,39 +185,45 @@ pb = gdk_pixbuf_new_from_file (file, NULL); else { + struct stat statinfo ; + /* try to create it */ g_free (file); file = g_filename_from_uri (uri, NULL, NULL); - if (options.common_data.large_preview) - pb = gdk_pixbuf_new_from_file_at_scale (file, 256, 256, TRUE, NULL); - else - pb = gdk_pixbuf_new_from_file_at_scale (file, 128, 128, TRUE, NULL); - if (pb) - { - struct stat st; - gchar *smtime; + + if ( !stat(file,&statinfo) && S_ISREG(statinfo.st_mode) ) + { + if (options.common_data.large_preview) + pb = gdk_pixbuf_new_from_file_at_scale (file, 256, 256, TRUE, NULL); + else + pb = gdk_pixbuf_new_from_file_at_scale (file, 128, 128, TRUE, NULL); + if (pb) + { + struct stat st; + gchar *smtime; - stat (file, &st); - smtime = g_strdup_printf ("%lu", st.st_mtime); - g_free (file); + stat (file, &st); + smtime = g_strdup_printf ("%lu", st.st_mtime); + g_free (file); - /* save thumbnail */ - if (options.common_data.large_preview) - { - g_mkdir_with_parents (large_path, 0755); - file = g_strdup_printf ("%s/%s.png", large_path, g_checksum_get_string (chs)); - } - else - { - g_mkdir_with_parents (normal_path, 0755); - file = g_strdup_printf ("%s/%s.png", normal_path, g_checksum_get_string (chs)); - } - gdk_pixbuf_save (pb, file, "png", NULL, - "tEXt::Thumb::URI", uri, - "tEXt::Thumb::MTime", smtime, - NULL); - g_free (smtime); - } + /* save thumbnail */ + if (options.common_data.large_preview) + { + g_mkdir_with_parents (large_path, 0755); + file = g_strdup_printf ("%s/%s.png", large_path, g_checksum_get_string (chs)); + } + else + { + g_mkdir_with_parents (normal_path, 0755); + file = g_strdup_printf ("%s/%s.png", normal_path, g_checksum_get_string (chs)); + } + gdk_pixbuf_save (pb, file, "png", NULL, + "tEXt::Thumb::URI", uri, + "tEXt::Thumb::MTime", smtime, + NULL); + g_free (smtime); + } + } } } g_checksum_free (chs);
Hope this helps.
--
SeB