]> git.saurik.com Git - wxWidgets.git/commitdiff
ensure that the copies of the bitmap passed to wxMemoryDC ctor are not modified when...
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 17 Sep 2008 22:20:38 +0000 (22:20 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 17 Sep 2008 22:20:38 +0000 (22:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55694 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/dcbase.cpp

index 168ea59a211720df41edfed4e8374575006c04eb..33586d4629d9e7854e83a43f029aa29112052f6f 100644 (file)
@@ -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 )