From 2a02f84b9467069a17055dd96c88ba9ab5ca9127 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 17 Sep 2008 22:20:38 +0000 Subject: [PATCH] ensure that the copies of the bitmap passed to wxMemoryDC ctor are not modified when this bitmap is git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55694 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dcbase.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index 168ea59a21..33586d4629 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -157,9 +157,19 @@ wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner ) return new wxMemoryDCImpl( owner ); } -wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner, wxBitmap &bitmap ) -{ - return new wxMemoryDCImpl( owner, bitmap ); +wxDCImpl* wxNativeDCFactory::CreateMemoryDC(wxMemoryDC *owner, wxBitmap& bitmap) +{ + // the bitmap may be modified when it's selected into a memory DC so make + // sure changing this bitmap doesn't affect any other shallow copies of it + // (see wxMemoryDC::SelectObject()) + // + // notice that we don't provide any ctor equivalent to SelectObjectAsSource + // method because this should be rarely needed and easy to work around by + // using the default ctor and calling SelectObjectAsSource itself + if ( bitmap.IsOk() ) + bitmap.UnShare(); + + return new wxMemoryDCImpl(owner, bitmap); } wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner, wxDC *dc ) -- 2.45.2