From 5950daa0613e6533efed606c5081d7323e09add4 Mon Sep 17 00:00:00 2001 From: miklosh Date: Sun, 6 Aug 2006 21:29:57 +0000 Subject: [PATCH] Notify save failure by throwing "save_failed". --- src/extension/internal/cairo-pdf-out.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/extension/internal/cairo-pdf-out.cpp b/src/extension/internal/cairo-pdf-out.cpp index 52eb668c9..c73faaef6 100644 --- a/src/extension/internal/cairo-pdf-out.cpp +++ b/src/extension/internal/cairo-pdf-out.cpp @@ -38,7 +38,7 @@ CairoPdfOutput::check (Inkscape::Extension::Extension * module) } -static void +static unsigned int pdf_print_document_to_file(SPDocument *doc, gchar const *filename) { Inkscape::Extension::Print *mod; @@ -62,10 +62,14 @@ pdf_print_document_to_file(SPDocument *doc, gchar const *filename) mod->arena = NRArena::create(); mod->dkey = sp_item_display_key_new(1); mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + /* Print document */ ret = mod->begin(doc); - sp_item_invoke_print(mod->base, &context); - ret = mod->finish(); + if (ret) { + sp_item_invoke_print(mod->base, &context); + ret = mod->finish(); + } + /* Release arena */ sp_item_invoke_hide(mod->base, mod->dkey); mod->base = NULL; @@ -78,7 +82,7 @@ pdf_print_document_to_file(SPDocument *doc, gchar const *filename) mod->set_param_string("destination", oldoutput); g_free(oldoutput); - return; + return ret; } @@ -96,6 +100,7 @@ void CairoPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gchar *uri) { Inkscape::Extension::Extension * ext; + unsigned int ret; ext = Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_CAIRO_PDF); if (ext == NULL) @@ -103,8 +108,11 @@ CairoPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const g gchar * final_name; final_name = g_strdup_printf("> %s", uri); - pdf_print_document_to_file(doc, final_name); + ret = pdf_print_document_to_file(doc, final_name); g_free(final_name); + + if (!ret) + throw Inkscape::Extension::Output::save_failed(); return; } -- 2.30.2