Fix crash when drawing bitmaps with mask in wxGTK with GTK+ < 2.20.

r73386 introduced a crash in wxGTK drawing code when using old GTK+ versions
by releasing the mask pixmap prematurely. Apparently GTK+ itself was fixed at
some time in 2.19.x time frame but work around the bug for the sake of older
GTK+ versions in wxGTK itself by simply releasing the pixmap at the end of
DoDrawBitmap(), as pre-r73386 code did.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73549 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-02-21 14:32:04 +00:00
parent 4e5e421c78
commit c92374f0a2

View File

@@ -1132,9 +1132,10 @@ void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap,
if (m)
mask = *m;
}
GdkPixmap* mask_new = NULL;
if (mask)
{
GdkPixmap* mask_new = NULL;
if (isScaled)
{
mask = ScaleMask(mask, 0, 0, w, h, ww, hh, m_scaleX, m_scaleY);
@@ -1151,8 +1152,6 @@ void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap,
}
gdk_gc_set_clip_mask(use_gc, mask);
gdk_gc_set_clip_origin(use_gc, xx, yy);
if (mask_new)
g_object_unref(mask_new);
}
// determine whether to use pixmap or pixbuf
@@ -1199,7 +1198,16 @@ void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap,
if (pixmap_new)
g_object_unref(pixmap_new);
if (mask)
{
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).
if (mask_new)
g_object_unref(mask_new);
}
}
bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest,