diff --git a/src/qt/bitmap.cpp b/src/qt/bitmap.cpp index b6fa8d8c08..b98a13d984 100644 --- a/src/qt/bitmap.cpp +++ b/src/qt/bitmap.cpp @@ -601,7 +601,12 @@ void wxBitmap::QtBlendMaskWithAlpha() { AllocExclusive(); M_PIXDATA.setMask(*M_MASK->GetHandle()); - wxDELETE(M_MASK); + + // Notice that if the mask was created from a colour that does not exist in + // the bitmap, setMask() will have no effect on the bitmap. So only delete + // it if it has been applied successfully. + if ( HasAlpha() ) + wxDELETE(M_MASK); } }