[SCM] Rasmol packaging branch, master, updated. debian/2.7.4.2-5-34-g3fc03e3

Teemu Ikonen tpikonen at gmail.com
Wed Apr 27 09:36:40 UTC 2011


The following commit has been merged in the master branch:
commit cba2ac55b41c7f05d36935a59041f12e3c7a114c
Author: Teemu Ikonen <tpikonen at gmail.com>
Date:   Mon Dec 13 21:03:01 2010 +0100

    Fix segfault in image exporting with GTK.
    
    File->Export segfaulted when the exported image size was different
    from the image buffer size currently on the screen.
    
    The fix is to not try to render to user supplied buffer in
    render_buffer(), but to copy FBuffer to the supplied buffer after
    resizing.
    
    Also fixed the temporary image buffer allocation in export_cb() to use
    sizeof(Pixel) instead of 4.

diff --git a/src/gtkwin.c b/src/gtkwin.c
index 765e1ba..a9fce02 100755
--- a/src/gtkwin.c
+++ b/src/gtkwin.c
@@ -396,17 +396,13 @@ void save_cb(GtkAction *action, gpointer user_data)
 /* Render the current image to a given memory buffer with a given size */
 void render_buffer(Pixel * buf, int xsize, int ysize)
 {
-    Pixel *old_fbuffer;
     int old_xrange, old_yrange, old_hrange, old_wrange, old_range,
         old_interactive, dx;
 
-    old_fbuffer = FBuffer;
     old_xrange = XRange;
     old_yrange = YRange;
-    FBuffer = buf;
     XRange = xsize;
     YRange = ysize;
-
     if ((dx = XRange % 4))
         XRange += 4 - dx;
 
@@ -420,10 +416,11 @@ void render_buffer(Pixel * buf, int xsize, int ysize)
     ReDrawFlag |= RFReSize;
     old_interactive = Interactive;
     Interactive = False;
-    RefreshScreen();            // *buf now contains the image
+    RefreshScreen();            // FBuffer now contains the image
+    memcpy(buf, FBuffer, sizeof(Pixel) * xsize * ysize);
+
     Interactive = old_interactive;
 
-    FBuffer = old_fbuffer;
     XRange = old_xrange;
     YRange = old_yrange;
     HRange = old_hrange;
@@ -602,7 +599,7 @@ void export_cb(GtkAction * action, gpointer user_data)
         guint format = 0;
         gchar *formatname = NULL;
         GSList *tmplist = NULL;
-        guchar *tmpbuf;
+        Pixel *tmpbuf;
 
         if (gtk_dialog_run(GTK_DIALOG(exportdialog)) != GTK_RESPONSE_ACCEPT) {
             break;
@@ -652,12 +649,13 @@ void export_cb(GtkAction * action, gpointer user_data)
             egg_file_format_chooser_get_format_data(EGG_FILE_FORMAT_CHOOSER
                                                     (format_chooser), format);
 
-        tmpbuf = g_new(guchar, 4 * export_x * export_y);
-        render_buffer((Pixel *) tmpbuf, export_x, export_y);
-        pbuf = gdk_pixbuf_new_from_data(tmpbuf,
+        tmpbuf = g_new(Pixel, export_x * export_y);
+        render_buffer(tmpbuf, export_x, export_y);
+        pbuf = gdk_pixbuf_new_from_data((guchar *) tmpbuf,
                                         GDK_COLORSPACE_RGB,
                                         TRUE, 8,
-                                        export_x, export_y, 4 * export_x,
+                                        export_x, export_y,
+                                        sizeof(Pixel) * export_x,
                                         NULL, NULL);
         success = gdk_pixbuf_save(pbuf, fname, formatname, &err, NULL);
 

-- 
Rasmol packaging



More information about the debian-science-commits mailing list