From 1a965c03fefe03debb05130f0bfa223f59c60424 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 30 May 2014 16:29:13 +0000 Subject: [PATCH] Fix X 'BadPixmap' crash in Blit() with mask when GTK+ <= 2.16, closes #16303 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76626 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/gtk/dcclient.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 20e5bc2354..eb0258d46b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -625,6 +625,7 @@ wxGTK: special folder from combobox - Fix wxSystemSettings::GetColour() returning transparent colors with GTK3. - Fix setting client data when adding items to a sorted wxListBox. +- Fix X 'BadPixmap' crash in wxDC::Blit() with mask when GTK+ <= 2.16. wxMSW: diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 2c4a716964..7af0853973 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -1199,9 +1199,8 @@ void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap, gdk_gc_set_clip_region(use_gc, clipRegion); // Notice that we can only release the mask now, we can't do it before - // the calls to gdk_draw_xxx() above as they crash with X error with - // GTK+ up to 2.20.1 (i.e. it works with 2.20 but is known to not work - // with 2.16.1 and below). + // the calls to gdk_draw_xxx() above as they crash with BadPixmap X + // error with GTK+ 2.16 and earlier. if (mask_new) g_object_unref(mask_new); } @@ -1311,6 +1310,7 @@ bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, GdkGC* const use_gc = m_penGC; + GdkPixmap* mask_new = NULL; if (mask) { int srcMask_x = src_x; @@ -1320,7 +1320,6 @@ bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, srcMask_x = source->LogicalToDeviceX(xsrcMask); srcMask_y = source->LogicalToDeviceY(ysrcMask); } - GdkPixmap* mask_new = NULL; if (isScaled) { mask = ScaleMask(mask, srcMask_x, srcMask_y, @@ -1343,8 +1342,6 @@ bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, } gdk_gc_set_clip_mask(use_gc, mask); gdk_gc_set_clip_origin(use_gc, dst_x - srcMask_x, dst_y - srcMask_y); - if (mask_new) - g_object_unref(mask_new); } GdkPixmap* pixmap = NULL; @@ -1385,7 +1382,12 @@ bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, if (pixmap) g_object_unref(pixmap); if (mask) + { gdk_gc_set_clip_region(use_gc, clipRegion); + // see comment at end of DoDrawBitmap() + if (mask_new) + g_object_unref(mask_new); + } return true; }