Package: gpicview
Version: 0.1.9-2
Severity: grave
Justification: causes non-serious data loss
Tags: patch

*** Please type your report below this line ***

Save or auto-save on gif files will empty that file. It is because the
gdk_pixbuf_save() is only supporting bmp/ico/jpeg/png/tiff currently.
Other formats like gif/pcx/pnm/xbm/xpm... is not supported and if we
directly call that function, it erases the file.

The patch detects which formats are currently supported by gdk-pixbuf
and only do the save on supported types.

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core)
Locale: LANG=zh_TW.UTF-8, LC_CTYPE=zh_TW.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages gpicview depends on:
ii  libatk1.0-0                   1.22.0-1   The ATK accessibility toolkit
ii  libc6                         2.7-13     GNU C Library: Shared libraries
ii  libcairo2                     1.6.4-6    The Cairo 2D vector
graphics libra
ii  libglib2.0-0                  2.16.5-1   The GLib library of C routines
ii  libgtk2.0-0                   2.12.11-3  The GTK+ graphical user
interface
ii  libjpeg62                     6b-14      The Independent JPEG
Group's JPEG
ii  libpango1.0-0                 1.20.5-1   Layout and rendering of
internatio
ii  libx11-6                      2:1.1.4-2  X11 client-side library

Versions of packages gpicview recommends:
ii  xdg-utils                     1.0.2-6    desktop integration
utilities from

gpicview suggests no packages.

-- no debconf information

-- 
                                                PaulLiu(劉穎駿)
E-mail address: [EMAIL PROTECTED]
Index: main-win.c
===================================================================
--- main-win.c	(revision 848)
+++ main-win.c	(working copy)
@@ -1285,6 +1285,9 @@
 
 gboolean main_win_save( MainWin* mw, const char* file_path, const char* type, gboolean confirm )
 {
+    gboolean result1,gdk_save_supported;
+    GSList *gdk_formats;
+    GSList *gdk_formats_i;
     if( ! mw->pix )
         return FALSE;
 
@@ -1306,13 +1309,38 @@
         }
     }
 
+    /* detect if the current type can be save by gdk_pixbuf_save() */
+    gdk_save_supported = FALSE;
+    gdk_formats = gdk_pixbuf_get_formats();
+    for (gdk_formats_i = gdk_formats; gdk_formats_i;
+         gdk_formats_i = g_slist_next(gdk_formats_i))
+    {
+        GdkPixbufFormat *data;
+        data = gdk_formats_i->data;
+        if (gdk_pixbuf_format_is_writable(data))
+        {
+            if ( strcmp(type, gdk_pixbuf_format_get_name(data))==0)
+            {
+                gdk_save_supported = TRUE;
+                break;
+            }
+        }
+    }
+    g_slist_free (gdk_formats);
+
     GError* err = NULL;
-    if( ! gdk_pixbuf_save( mw->pix, file_path, type, &err, NULL ) )
+    if (!gdk_save_supported)
     {
+        /* FIXME: we should show some error messages here when the type
+           is not supported to save */
+        return FALSE;
+    }
+    result1 = gdk_pixbuf_save( mw->pix, file_path, type, &err, NULL );
+    if( ! result1 )
+    {
         main_win_show_error( mw, err->message );
         return FALSE;
     }
-
     return TRUE;
 }
 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to