From 4d71c10ed216be5f0f4dc52e28696a204988dd3d Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Tue, 21 Nov 2017 00:54:29 +0100 Subject: 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 --- src/extension/internal/cairo-render-context.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/extension/internal/cairo-render-context.cpp') 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) -- cgit v1.2.3 From 3a4c187f4dc5a047484b018df56944b1517ccd99 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Tue, 21 Nov 2017 22:39:29 +0100 Subject: Two fixes (should work on Linux now) - do not call cairo_show_page as the GtkPrintOperation seems to do that internally (calling it manually will emit the current page, clear it, and the cleared page seems to be emitted in error later) - we can (and should) still call cairo_surface_destroy as it's doing reference counting internally (we increase the reference count in CairoRenderContext::setSurfaceTarget) and won't actually destroy anything until the count reaches zero --- src/extension/internal/cairo-render-context.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/extension/internal/cairo-render-context.cpp') diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 16100dc88..4869472da 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -882,7 +882,7 @@ CairoRenderContext::finish(bool finish_surface) { g_assert( _is_valid ); - if (_vector_based_target) + if (_vector_based_target && finish_surface) cairo_show_page(_cr); // PDF+TeX Output, see CairoRenderContext::_prepareRenderGraphic() @@ -898,8 +898,7 @@ CairoRenderContext::finish(bool finish_surface) if (finish_surface) cairo_surface_finish(_surface); cairo_status_t status = cairo_surface_status(_surface); - if (finish_surface) - cairo_surface_destroy(_surface); + cairo_surface_destroy(_surface); _surface = NULL; if (_layout) -- cgit v1.2.3