From dfa59b0b9c2d07bceb1c9a61322ac23b04051784 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Mon, 21 Feb 2022 09:45:09 +1100 Subject: Bug [#2317] Fix pixmap leak on GTK. --- doc/ScintillaHistory.html | 4 ++++ gtk/PlatGTK.cxx | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 515b72be2..af650203c 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -583,6 +583,10 @@ Enable multi-threaded layout on GTK.
  • + Fix pixmap leak on GTK. + Bug #2317. +
  • +
  • Fix re-entrant painting on GTK to maintain update region.
  • diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 8610485de..fcd0fb1f7 100755 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -125,7 +125,7 @@ class SurfaceImpl : public Surface { EncodingType et= EncodingType::singleByte; WindowID widSave = nullptr; cairo_t *context = nullptr; - UniqueCairo pixmapContext; + UniqueCairo cairoOwned; UniqueCairoSurface surf; bool inited = false; UniquePangoContext pcontext; @@ -303,8 +303,8 @@ SurfaceImpl::SurfaceImpl(cairo_t *context_, int width, int height, SurfaceMode m surf.reset(cairo_surface_create_similar( psurfContext, CAIRO_CONTENT_COLOR_ALPHA, width, height)); - pixmapContext.reset(cairo_create(surf.get())); - context = pixmapContext.get(); + cairoOwned.reset(cairo_create(surf.get())); + context = cairoOwned.get(); pcontext.reset(gtk_widget_create_pango_context(PWidget(wid))); PLATFORM_ASSERT(pcontext); SetFractionalPositions(pcontext.get()); @@ -322,7 +322,7 @@ SurfaceImpl::SurfaceImpl(cairo_t *context_, int width, int height, SurfaceMode m void SurfaceImpl::Release() noexcept { et = EncodingType::singleByte; - pixmapContext.reset(); + cairoOwned.reset(); context = nullptr; surf.reset(); layout.reset(); @@ -397,7 +397,8 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID wid) { PLATFORM_ASSERT(sid); Release(); PLATFORM_ASSERT(wid); - context = cairo_reference(static_cast(sid)); + cairoOwned.reset(cairo_reference(static_cast(sid))); + context = cairoOwned.get(); pcontext.reset(gtk_widget_create_pango_context(PWidget(wid))); SetFractionalPositions(pcontext.get()); // update the Pango context in case sid isn't the widget's surface -- cgit v1.2.3