]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/bitmap.cpp
attempt to fix race condition between Delete() and Wait()
[wxWidgets.git] / src / msw / bitmap.cpp
index 0e5ab48c9f1aaea1efd86178c43dce87a7400915..bac7a9c0cae9b7bacc37881131bc7189a0076316 100644 (file)
@@ -1910,8 +1910,8 @@ HBITMAP wxInvertMask(HBITMAP hbmpMask, int w, int h)
         wxLogLastError(wxT("CreateBitmap"));
     }
 
-    ::SelectObject(hdcSrc, hbmpMask);
-    ::SelectObject(hdcDst, hbmpInvMask);
+    HGDIOBJ srcTmp = ::SelectObject(hdcSrc, hbmpMask);
+    HGDIOBJ dstTmp = ::SelectObject(hdcDst, hbmpInvMask);
     if ( !::BitBlt(hdcDst, 0, 0, w, h,
                    hdcSrc, 0, 0,
                    NOTSRCCOPY) )
@@ -1919,6 +1919,10 @@ HBITMAP wxInvertMask(HBITMAP hbmpMask, int w, int h)
         wxLogLastError(wxT("BitBlt"));
     }
 
+    // Deselect objects
+    SelectObject(hdcSrc,srcTmp);
+    SelectObject(hdcDst,dstTmp);
+    
     ::DeleteDC(hdcSrc);
     ::DeleteDC(hdcDst);