Avoid inadvertently destroying a shared PangoContext on GTK2
wxMemoryDC and wxScreenDC dtors were freeing a context they didn't own, potentially causing a crash. Fixed by having the base wxWindowDC dtor free the context. See #18566
This commit is contained in:
@@ -2629,6 +2629,7 @@ public:
|
|||||||
m_window = window;
|
m_window = window;
|
||||||
|
|
||||||
m_context = window->GTKGetPangoDefaultContext();
|
m_context = window->GTKGetPangoDefaultContext();
|
||||||
|
g_object_ref(m_context);
|
||||||
m_layout = pango_layout_new( m_context );
|
m_layout = pango_layout_new( m_context );
|
||||||
m_fontdesc = pango_font_description_copy(gtk_widget_get_style(widget)->font_desc);
|
m_fontdesc = pango_font_description_copy(gtk_widget_get_style(widget)->font_desc);
|
||||||
|
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window ) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_context = window->GTKGetPangoDefaultContext();
|
m_context = window->GTKGetPangoDefaultContext();
|
||||||
|
g_object_ref(m_context);
|
||||||
m_layout = pango_layout_new( m_context );
|
m_layout = pango_layout_new( m_context );
|
||||||
m_fontdesc = pango_font_description_copy( widget->style->font_desc );
|
m_fontdesc = pango_font_description_copy( widget->style->font_desc );
|
||||||
|
|
||||||
@@ -344,6 +345,8 @@ wxWindowDCImpl::~wxWindowDCImpl()
|
|||||||
{
|
{
|
||||||
Destroy();
|
Destroy();
|
||||||
|
|
||||||
|
if (m_context)
|
||||||
|
g_object_unref(m_context);
|
||||||
if (m_layout)
|
if (m_layout)
|
||||||
g_object_unref (m_layout);
|
g_object_unref (m_layout);
|
||||||
if (m_fontdesc)
|
if (m_fontdesc)
|
||||||
@@ -1539,6 +1542,10 @@ void wxWindowDCImpl::SetFont( const wxFont &font )
|
|||||||
// at least, and it doesn't hurt to do it.
|
// at least, and it doesn't hurt to do it.
|
||||||
if (oldContext != m_context)
|
if (oldContext != m_context)
|
||||||
{
|
{
|
||||||
|
g_object_ref(m_context);
|
||||||
|
if (oldContext)
|
||||||
|
g_object_unref(oldContext);
|
||||||
|
|
||||||
if (m_layout)
|
if (m_layout)
|
||||||
g_object_unref (m_layout);
|
g_object_unref (m_layout);
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ wxMemoryDCImpl::wxMemoryDCImpl( wxMemoryDC *owner, wxDC *WXUNUSED(dc) )
|
|||||||
|
|
||||||
wxMemoryDCImpl::~wxMemoryDCImpl()
|
wxMemoryDCImpl::~wxMemoryDCImpl()
|
||||||
{
|
{
|
||||||
g_object_unref(m_context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMemoryDCImpl::Init()
|
void wxMemoryDCImpl::Init()
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ void wxScreenDCImpl::Init()
|
|||||||
|
|
||||||
wxScreenDCImpl::~wxScreenDCImpl()
|
wxScreenDCImpl::~wxScreenDCImpl()
|
||||||
{
|
{
|
||||||
g_object_unref(m_context);
|
|
||||||
|
|
||||||
gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
|
gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
|
||||||
gdk_gc_set_subwindow( m_brushGC, GDK_CLIP_BY_CHILDREN );
|
gdk_gc_set_subwindow( m_brushGC, GDK_CLIP_BY_CHILDREN );
|
||||||
gdk_gc_set_subwindow( m_textGC, GDK_CLIP_BY_CHILDREN );
|
gdk_gc_set_subwindow( m_textGC, GDK_CLIP_BY_CHILDREN );
|
||||||
|
|||||||
Reference in New Issue
Block a user