]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix referencing of cairo_t returned from wxDCImpl::GetCairoContext().
authorPaul Cornett <paulcor@bullseye.com>
Tue, 3 Sep 2013 05:37:30 +0000 (05:37 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Tue, 3 Sep 2013 05:37:30 +0000 (05:37 +0000)
It was assumed that all callers were going to unref the cairo_t, but that is not
true, so callers that are going to unref it should ref it themselves.
See #15455

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74746 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/graphicc.cpp
src/gtk/dc.cpp
src/gtk/print.cpp

index 1cf971d0e6f0dc9bce9be159b82c06f7856ad050..c89d338f51566603672b402d19030d9b450ecdf7 100644 (file)
@@ -1654,7 +1654,9 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC&
 
 #ifdef __WXGTK20__
     const wxDCImpl *impl = dc.GetImpl();
-    Init( (cairo_t*) impl->GetCairoContext() );
+    cairo_t* cr = static_cast<cairo_t*>(impl->GetCairoContext());
+    if (cr)
+        Init(cairo_reference(cr));
 #endif
     wxSize sz = dc.GetSize();
     m_width = sz.x;
@@ -1700,7 +1702,7 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC&
 #ifdef __WXGTK3__
     cairo_t* cr = static_cast<cairo_t*>(dc.GetImpl()->GetCairoContext());
     if (cr)
-        Init(cr);
+        Init(cairo_reference(cr));
 #elif defined __WXGTK20__
     wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
     Init( gdk_cairo_create( impldc->GetGDKWindow() ) );
@@ -1775,7 +1777,7 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC&
 #ifdef __WXGTK3__
     cairo_t* cr = static_cast<cairo_t*>(dc.GetImpl()->GetCairoContext());
     if (cr)
-        Init(cr);
+        Init(cairo_reference(cr));
 #elif defined __WXGTK20__
     wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
     Init( gdk_cairo_create( impldc->GetGDKWindow() ) );
index 9814072bef1c7997660128569acc5dc13fca0786..7640bf3c6e0cad1ba1c0ef081ab8ed28c1afc56b 100644 (file)
@@ -181,8 +181,6 @@ void* wxGTKCairoDCImpl::GetCairoContext() const
     cairo_t* cr = NULL;
     if (m_graphicContext)
         cr = static_cast<cairo_t*>(m_graphicContext->GetNativeContext());
-    if (cr)
-        cairo_reference(cr);
     return cr;
 }
 //-----------------------------------------------------------------------------
index beff9c1be29598f8bd26c1c5b84af488d4165e0c..d309ffd6add8832b03750aeb34041e39c1238ffb 100644 (file)
@@ -1209,7 +1209,7 @@ bool wxGtkPrinterDCImpl::IsOk() const
 
 void* wxGtkPrinterDCImpl::GetCairoContext() const
 {
-    return (void*) cairo_reference( m_cairo );
+    return m_cairo;
 }
 
 void* wxGtkPrinterDCImpl::GetHandle() const