From bbb08b17be023377a163cebc0f61a44f7d3e6d18 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 10 Oct 2011 19:58:48 +0200 Subject: [PATCH] g_object_ref the print settings (as seen in the GTK+ documentation) --- commands.c | 1 + database-sqlite.c | 1 + print.c | 19 +++++++++++++------ shortcuts.c | 1 + 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/commands.c b/commands.c index f88fcf7..7415df3 100644 --- a/commands.c +++ b/commands.c @@ -270,3 +270,4 @@ cmd_savef(girara_session_t* session, girara_list_t* argument_list) return true; } + diff --git a/database-sqlite.c b/database-sqlite.c index eba12ef..a95508f 100644 --- a/database-sqlite.c +++ b/database-sqlite.c @@ -232,3 +232,4 @@ zathura_db_get_fileinfo(zathura_database_t* db, const char* file, unsigned int* sqlite3_finalize(stmt); return true; } + diff --git a/print.c b/print.c index f1a2c2f..2c6d14d 100644 --- a/print.c +++ b/print.c @@ -34,9 +34,16 @@ print(zathura_t* zathura) GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL); if (result == GTK_PRINT_OPERATION_RESULT_APPLY) { + if (zathura->print.settings != NULL) { + g_object_unref(zathura->print.settings); + } + if (zathura->print.page_setup != NULL) { + g_object_unref(zathura->print.page_setup); + } + /* save previous settings */ - zathura->print.settings = gtk_print_operation_get_print_settings(print_operation); - zathura->print.page_setup = gtk_print_operation_get_default_page_setup(print_operation); + zathura->print.settings = g_object_ref(gtk_print_operation_get_print_settings(print_operation)); + zathura->print.page_setup = g_object_ref(gtk_print_operation_get_default_page_setup(print_operation)); } else if (result == GTK_PRINT_OPERATION_RESULT_ERROR) { girara_error("Error occured while printing progress"); } @@ -75,14 +82,14 @@ cb_print_draw_page(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext* /* render page */ cairo_t* cairo = gtk_print_context_get_cairo_context(context); zathura_page_t* page = zathura->document->pages[page_number]; - double requested_with = gtk_print_context_get_width(context); - double tmp_scale = zathura->document->scale; - zathura->document->scale = requested_with / page->width; - if (cairo == NULL || page == NULL) { return; } + double requested_with = gtk_print_context_get_width(context); + double tmp_scale = zathura->document->scale; + zathura->document->scale = requested_with / page->width; + zathura_page_render(page, cairo); zathura->document->scale = tmp_scale; diff --git a/shortcuts.c b/shortcuts.c index 820dc57..085c4f2 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -542,3 +542,4 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, unsigned int return false; } +