[gnumeric] gnm_print_sheet might be called with NULL wbc



commit 6f6b8075c1975ed036a5bbc51a79f2f58507e885
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed May 18 21:09:49 2011 -0600

    gnm_print_sheet might be called with NULL wbc
    
    2011-05-18  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/print.c (gnm_print_sheet): wbc may be NULL

 ChangeLog   |    4 ++++
 src/print.c |   42 ++++++++++++++++++++++++------------------
 2 files changed, 28 insertions(+), 18 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 174fe19..efcbc0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-05-18  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* src/print.c (gnm_print_sheet): wbc may be NULL
+
 2011-05-17  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/parse-util.h (_GnmConventions): add name_validate field
diff --git a/src/print.c b/src/print.c
index cebf8ae..91b5a70 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1618,7 +1618,7 @@ gnm_print_sheet (WorkbookControl *wbc, Sheet *sheet,
 				      PRINT_ALL_SHEETS, PRINT_ACTIVE_SHEET,
 				      PRINT_SHEET_SELECTION, PRINT_ACTIVE_SHEET,
 				      PRINT_SHEET_SELECTION_IGNORE_PRINTAREA};
-	GODoc *doc = wb_control_get_doc (wbc);
+	GODoc *doc;
 	gchar *output_uri = NULL;
 	gchar const *saved_uri = NULL;
 
@@ -1626,6 +1626,8 @@ gnm_print_sheet (WorkbookControl *wbc, Sheet *sheet,
 	preview_via_pdf = preview;
 #endif
 
+	g_return_if_fail (sheet != NULL && sheet->workbook != NULL);
+
 	if (preview)
 		g_return_if_fail (!export_dst && wbc);
 
@@ -1654,23 +1656,27 @@ gnm_print_sheet (WorkbookControl *wbc, Sheet *sheet,
 	gtk_print_settings_set_use_color (settings,
 					  !sheet->print_info->print_black_and_white);
 
-	/* We should be setting the output file name to somethig reasonable */
-	saved_uri = print_info_get_printtofile_uri (sheet->print_info);
-	if (saved_uri != NULL && 
-	    g_ascii_strncasecmp (doc->uri, "file:///", 8) == 0)
-		output_uri = gnm_print_uri_change_extension (saved_uri,
-							     settings);
-	else
-		saved_uri = NULL;
-	if (output_uri == NULL && doc->uri != NULL 
-	    && g_ascii_strncasecmp (doc->uri, "file:///", 8) == 0)
-		output_uri = gnm_print_uri_change_extension (doc->uri, 
-								settings);
-	if (output_uri != NULL) {
-		gtk_print_settings_set (settings, 
-					GTK_PRINT_SETTINGS_OUTPUT_URI,
-					output_uri);
-		g_free (output_uri);
+	if (!export_dst && !preview_via_pdf && !preview) {
+		/* We should be setting the output file name to somethig */
+		/* reasonable */
+		doc = GO_DOC (sheet->workbook);
+		saved_uri = print_info_get_printtofile_uri (sheet->print_info);
+		if (saved_uri != NULL && 
+		    g_ascii_strncasecmp (doc->uri, "file:///", 8) == 0)
+			output_uri = gnm_print_uri_change_extension (saved_uri,
+								     settings);
+		else
+			saved_uri = NULL;
+		if (output_uri == NULL && doc->uri != NULL 
+		    && g_ascii_strncasecmp (doc->uri, "file:///", 8) == 0)
+			output_uri = gnm_print_uri_change_extension (doc->uri, 
+								     settings);
+		if (output_uri != NULL) {
+			gtk_print_settings_set (settings, 
+						GTK_PRINT_SETTINGS_OUTPUT_URI,
+						output_uri);
+			g_free (output_uri);
+		}
 	}
 
 	gtk_print_operation_set_print_settings (print, settings);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]