Comment 4 for bug 199229

Revision history for this message
mehiel (aggelos-karalias) wrote :

I can confirm that on a debian lenny..

My specs are:
 linux kernel: 2.6.26-1-amd64
 gnome: 2.22.3
 gnome-splashscreen-manager: 0.2-12(testing)

I am not so familiar with ruby but i tried to find out what happened and i think that the problem is on the download_pixbuf method of the splash_screen.rb script. The loader throws a Gdk::PixbufError if the file is not a correct image file (from a corrupted download maybe) and this exception is unhandled. This method is used by the create_thumbnail method to read the image and create the thumbnail for the program's main window.

So because the MainWindow.rb constructor at start reads the #{Home_dir}/#{Gnome_dir}/splash-screens.xml and creates the thumbnails of the image files, it goes down..

You can reproduce it very easy, just add a <splash_screen> entry at #{Home_dir}/#{Gnome_dir}/splash-screens.xml file and touch the file you entered for filename in the entry. The file is not a correct image file and the whole thing will fail.

I think that the solution is pretty simple but I 'm a java developer at most and not at all familiar with ruby (so maybe there is a more sophisticated way to handle this situation), what I did to fix it is:

1) changed the splash_screens.rb script at line 190 to add an exception handler and return nil on error:
old code snippet:
 loader = Gdk::PixbufLoader.new
     open(url) { |f|
 loader.last_write(f.read)
     }

new code snippet:
 begin
      loader = Gdk::PixbufLoader.new
      open(url) { |f|
        loader.last_write(f.read)
      }
 rescue
  puts "Error in image file format: "+url

  return nil
 end

2) now edit the splash_screens.rb again into method create_thumbnail (line 205 with the new code snippet):
add between pixbuf = download_pixbuf(url) and pixbuf.scale(130, 90, Gdk::Pixbuf::INTERP_BILINEAR) this code snippet:
      if (pixbuf == nil)
            return nil
      end

and you are ok..

now the reload_splash_screens method that runs at start of the program will load the thumbnails and every nil thumbnail will be deleted from your #{Home_dir}/#{Gnome_dir}/splash-screens.xml file with a notification message at standard output to delete the image file manually from your filesystem.

thats all, sorry for my verbosity..
mehiel