Comment 150 for bug 1512120

Revision history for this message
In , Rocketx86 (rocketx86) wrote :

(In reply to Jan Havran from comment #0)

> thunar_file_compare_by_name() function is called even for only one file in
> working directory - both file_a->collate_key_nocase and
> file_b->collate_key_nocase are NULL. I noticed that sometimes this function
> is not called, but when it is (it is random), then it crashes.

This patch will keep thunar_file_compare_by_name() from crashing when the collate keys are NULL. When using this patch, users may notice a random occurance of 2 files appearing selected together with the same name. The cause of this random occurance may be a result of the underlying issue after 'successful' sorting.

diff -Naurp Thunar-1.6.10/thunar/thunar-file.c Thunar-1.6.10-fix/thunar/thunar-file.c
--- Thunar-1.6.10/thunar/thunar-file.c 2015-05-22 13:25:36.000000000 +0000
+++ Thunar-1.6.10-fix/thunar/thunar-file.c 2016-08-04 17:41:14.330000001 +0000
@@ -4020,11 +4020,11 @@ thunar_file_compare_by_name (const Thuna

   /* case insensitive checking */
   if (G_LIKELY (!case_sensitive))
- result = strcmp (file_a->collate_key_nocase, file_b->collate_key_nocase);
+ result = g_strcmp0 (file_a->collate_key_nocase, file_b->collate_key_nocase);

   /* fall-back to case sensitive */
   if (result == 0)
- result = strcmp (file_a->collate_key, file_b->collate_key);
+ result = g_strcmp0 (file_a->collate_key, file_b->collate_key);

   /* this happens in the trash */
   if (result == 0)