summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEduard Braun <eduard.braun2@gmx.de>2017-11-20 23:54:29 +0000
committerEduard Braun <eduard.braun2@gmx.de>2017-11-20 23:54:29 +0000
commit4d71c10ed216be5f0f4dc52e28696a204988dd3d (patch)
tree02747cdad3b3573a1de224e35f65e38461a8f98f /src
parentMore memleaks fixes (diff)
downloadinkscape-4d71c10ed216be5f0f4dc52e28696a204988dd3d.tar.gz
inkscape-4d71c10ed216be5f0f4dc52e28696a204988dd3d.zip
Fix printing multiple copies of a document
Previously only the first page was printed properly, all following pages were either blank or were not printed at all. This was caused by finishing/destroying the cairo surface of the cairo context associated with the GtkPrintContext used for printing which made it impossible to draw to it for any consecutive page Fixed bugs: - https://bugs.launchpad.net/inkscape/+bug/1733424 - https://bugs.launchpad.net/inkscape/+bug/490866
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/cairo-render-context.cpp11
-rw-r--r--src/extension/internal/cairo-render-context.h2
-rw-r--r--src/ui/dialog/print.cpp6
3 files changed, 13 insertions, 6 deletions
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index 972081c0d..16100dc88 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -878,7 +878,7 @@ CairoRenderContext::_finishSurfaceSetup(cairo_surface_t *surface, cairo_matrix_t
}
bool
-CairoRenderContext::finish(void)
+CairoRenderContext::finish(bool finish_surface)
{
g_assert( _is_valid );
@@ -893,10 +893,13 @@ CairoRenderContext::finish(void)
}
cairo_destroy(_cr);
- cairo_surface_finish(_surface);
- cairo_status_t status = cairo_surface_status(_surface);
- cairo_surface_destroy(_surface);
_cr = NULL;
+
+ if (finish_surface)
+ cairo_surface_finish(_surface);
+ cairo_status_t status = cairo_surface_status(_surface);
+ if (finish_surface)
+ cairo_surface_destroy(_surface);
_surface = NULL;
if (_layout)
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index be5169a74..a0ca2665b 100644
--- a/src/extension/internal/cairo-render-context.h
+++ b/src/extension/internal/cairo-render-context.h
@@ -72,7 +72,7 @@ class CairoRenderContext {
public:
CairoRenderContext *cloneMe(void) const;
CairoRenderContext *cloneMe(double width, double height) const;
- bool finish(void);
+ bool finish(bool finish_surface = true);
CairoRenderer *getRenderer(void) const;
cairo_t *getCairoContext(void) const;
diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp
index 532a8c364..ea99ffa19 100644
--- a/src/ui/dialog/print.cpp
+++ b/src/ui/dialog/print.cpp
@@ -35,6 +35,10 @@ static void draw_page(GtkPrintOperation *,
gint /*page_nr*/,
gpointer user_data)
{
+ // TODO: If the user prints multiple copies we render the whole page for each copy
+ // It would be more efficient to render the page once (e.g. in "begin_print")
+ // and simply print this result as often as necessary
+
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
struct workaround_gtkmm *junk = (struct workaround_gtkmm*)user_data;
//printf("%s %d\n",__FUNCTION__, page_nr);
@@ -120,7 +124,7 @@ static void draw_page(GtkPrintOperation *,
ret = renderer.setupDocument (ctx, junk->_doc, TRUE, 0., NULL);
if (ret) {
renderer.renderItem(ctx, junk->_base);
- ctx->finish();
+ ctx->finish(false); // do not finish the cairo_surface_t - it's owned by our GtkPrintContext!
}
else {
g_warning("%s", _("Could not set up Document"));