]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Fix Segmentation fault when trying to print an empty plot.
authorRiccardo Albertini <ssirowain@gmail.com>
Tue, 20 Sep 2011 12:44:45 +0000 (14:44 +0200)
committerRiccardo Albertini <ssirowain@gmail.com>
Tue, 20 Sep 2011 12:44:45 +0000 (14:44 +0200)
When printing an empty plot, the function was missing nullability check for 'current_dive'. Now the print of an empty plot results with an empty blank page.
A better solution could be making unsensitive the Print entry in the menu, until a plot is loaded.

Signed-off-by: Riccardo Albertini <ssirowain@gmail.com>
print.c

diff --git a/print.c b/print.c
index 0fe958a008095a1ea596556cc1d15116ee21a263..57cac80757f3533c2ce458c9249cd5196d54365f 100644 (file)
--- a/print.c
+++ b/print.c
@@ -22,7 +22,8 @@ static void draw_page(GtkPrintOperation *operation,
        h = gtk_print_context_get_height(context);
 
        /* Do the profile on the top half of the page.. */
-       plot(&gc, w, h/2, current_dive);
+       if (current_dive)
+               plot(&gc, w, h/2, current_dive);
 
        pango_cairo_show_layout(cr,layout);
        g_object_unref(layout);