Blog about software development


Xubuntu 16.04: Thunar crashes on rename

15 May 2016 - by 'Maurits van der Schee'

I love Ubuntu, but I prefer XFCE over Unity as a window manager for its speed and classic (Gnome2-like) looks. In Xubuntu 16.04 Thunar contains a bug that makes it crash when files are renamed. Note that "Xubuntu" is Ubuntu with the XFCE window manager and "Thunar" is the file manager of XFCE. The actual file operation of the rename is executed without being affected, but it is nevertheless annoying that Thunar crashes as you have to re-open Thunar and navigate to the path you were working in. Fortunately this is all open-source software and we can just "scratch our own itch". This post will explain what I did to get rid of this bug.

Testing Thunar

To determine whether or not you are affected by the bug you can run the following test (from Ubuntu QA):

mkdir thunar-test
cd thunar-test
Thunar .
for i in $(seq 1 10); do touch "$i.txt"; done
while true; do for i in $(seq 1 10); do mv "$i.txt" "$i.txt.txt"; done; sleep 1; for i in $(seq 1 10); do mv "$i.txt.txt" "$i.txt"; done; sleep 1; done

The above script should open a window showing 10 files and every second the filenames should be adjusted to either end in ".txt" or in ".txt.txt". You can let the script run. If the Thunar window goes away (crashes) after a few minutes, then you are affected. Note that the script does not clean up, so you may have to remove the "thunar-test" directory and it's contents afterwards.

Building Thunar

We can just download the source code, fix the bug, recompile and install the newly created Thunar. Sounds easy right? Well with these instructions it is:

wget http://archive.xfce.org/src/xfce/thunar/1.6/Thunar-1.6.10.tar.bz2
tar xvjf Thunar-1.6.10.tar.bz2 
cd Thunar-1.6.10
sudo apt-get install build-essential xfce4-dev-tools automake libtool autoconf
sudo apt-get install intltool libglib2.0-dev libgtk2.0-dev libexo-1-dev libxfce4ui-1-dev
sudo make install

The above code downloads the Thunar source code untars it, installs the dependencies and recompiles. The final line will install (replace) the Thunar executable. This does not fix the problem as we just downloaded, compiled and installed the same version as should have been installed already.

Patching Thunar

Now let's patch the file using following patch (by Harald Judt):

--- Thunar-1.6.10/thunar/thunar-file.c  2015-05-22 15:25:36.000000000 +0200
+++ Thunar-1.6.10-patched/thunar/thunar-file.c  2016-05-15 15:13:21.613406924 +0200
@@ -3918,7 +3918,9 @@
 thunar_file_reload (ThunarFile *file)
-  _thunar_return_if_fail (THUNAR_IS_FILE (file));
+  /* if the file has already been destroyed, break here */
+  if (!THUNAR_IS_FILE (file))
+      return FALSE;

   /* clear file pxmap cache */
   thunar_icon_factory_clear_pixmap_cache (file);

Save this file as "Thunar-1.6.10.patch" next to the folder "Thunar-1.6.10". Now do NOT enter that folder and run:

patch -p0 -i Thunar-1.6.10.patch

The expected output is 1 line saying:

patching file Thunar-1.6.10/thunar/thunar-file.c

After this you can recompile and reinstall using:

cd Thunar-1.6.10
sudo make install

Now re-run the test case to verify that the problem has disappeared and enjoy a rock solid Xubuntu 16.04!


The following links are relevant for this specific problem:

  1. Thunar additional tests 1512120 in Xubuntu Desktop
  2. Bug #1512120: thunar crashes on file renaming
  3. How to for newbie devs: Build a debug version of Thunar in Linux Mint
  4. XFCE Bug 12264: Crash when renaming single file in folder
  5. Patch by Harald Judt: Check if a thunar file is still valid before reloading

PS: Liked this article? Please share it on Facebook, Twitter or LinkedIn.