diff options
| author | Martin Owens <doctormo@gmail.com> | 2014-01-27 18:19:30 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2014-01-27 18:19:30 +0000 |
| commit | fd1ceb05805f20402606fd9fae1a048e0bca8e78 (patch) | |
| tree | fc1d38325e4d55dc62aa2c512b5eba7bf7604752 /src | |
| parent | Protect export options from blank filenames, png, pdf, emf and wmf. This shou... (diff) | |
| download | inkscape-fd1ceb05805f20402606fd9fae1a048e0bca8e78.tar.gz inkscape-fd1ceb05805f20402606fd9fae1a048e0bca8e78.zip | |
Protect pdf and png exports from failure and output reasonalbe warnings.
(bzr r12982)
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper/png-write.cpp | 2 | ||||
| -rw-r--r-- | src/main.cpp | 15 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index b8b815b4c..a16fe8e12 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -142,7 +142,7 @@ sp_png_write_rgba_striped(SPDocument *doc, Inkscape::IO::dump_fopen_call(filename, "M"); fp = Inkscape::IO::fopen_utf8name(filename, "wb"); - g_return_val_if_fail(fp != NULL, false); + if(fp == NULL) return false; /* Create and initialize the png_struct with the desired error handler * functions. If you want to use the default stderr and longjump method, diff --git a/src/main.cpp b/src/main.cpp index 868f389a8..25f813c2b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1632,10 +1632,13 @@ static int sp_do_export_png(SPDocument *doc) g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi); - g_print("Bitmap saved as: %s\n", filename.c_str()); - if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { - sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL); + if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi, + dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL) == 1 ) { + g_print("Bitmap saved as: %s\n", filename.c_str()); + } else { + g_warning("Bitmap failed to save to: %s", filename.c_str()); + } } else { g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX); } @@ -1794,7 +1797,11 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) ? "PostScript level 3" : "PostScript level 2"); } - (*i)->save(doc, uri); + try { + (*i)->save(doc, uri); + } catch(...) { + g_warning("Failed to save pdf to: %s", uri); + } return 0; } |
