From 9a9ea0c295fb2aa902abc30c64cbfe269606f850 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 1 Apr 2015 14:38:14 +0200 Subject: [PATCH] Fix bug with clearing shared alpha channel in wxImage::ClearAlpha(). Allocate our own exclusive copy of the data before modifying it, otherwise calling ClearAlpha() would clear alpha not only for the image it was called on but also for all the other images sharing data with it. --- docs/changes.txt | 1 + src/common/image.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index ac8a75c52c..230b970c86 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -591,6 +591,7 @@ All (GUI): - Fix updating nested window scrollbars in some cases (sbrowne). - Fix wxPGChoices copy ctor (Snoits). - Fix wxPixelData::Offset() for alpha (Markus Rollmann). +- Fix bug in wxImage::ClearAlpha() for shared data (Markus Rollmann). wxGTK: diff --git a/src/common/image.cpp b/src/common/image.cpp index b800e58ad8..2120296c56 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -2040,6 +2040,8 @@ void wxImage::ClearAlpha() { wxCHECK_RET( HasAlpha(), wxT("image already doesn't have an alpha channel") ); + AllocExclusive(); + if ( !M_IMGDATA->m_staticAlpha ) free( M_IMGDATA->m_alpha );