comctl32: imagelist: Fix simultaneous selection of one bitmap into two device contexts.

Misha Koshelev mk144210 at
Thu May 31 23:32:41 CDT 2007

This fixes a visual glitch I noticed in several places in Vector NTI listviews that I tracked down to this.
Specifically, if you do a +bitmap log here you see:

warn:bitmap:BITMAP_SelectObject Bitmap already selected in another DC

If you look at the original code you see these statements (and the analogous situation in the second case a few
lines down, I added my comments on the right hand side):

        SelectObject (hdcBitmap, hbmNewBitmap);
        imagelist_copy_images( himl, himl->hdcImage, hdcBitmap, 0, nCopyCount, 0 );

	/* FIXME: delete 'empty' image space? */

        SelectObject (himl->hdcImage, hbmNewBitmap);        <-- Fails as bitmap still selected in hdcBitmap
	DeleteObject (himl->hbmImage);                      <-- Deleted, but stays selected in himl->hdcImage
	himl->hbmImage = hbmNewBitmap;

The fix selects the original bitmap object in the temporary hdcBitmap after it is used, so that the bitmap
is properly selected in himl->hdcImage which does not lead to problems down the line (specifically it
was leading to having the old bitmap stay selected in hdcImage even though it was getting deleted, and then
in ImageList_DrawIndirect the BlendMaskBmp was staying selected as the "old bitmap" returned by SelectObject
was actually this old, destroyed hbmImage, leading to visual corruption and eventually a "Bad Pixmap" crash in X).

 dlls/comctl32/imagelist.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bd18626759decaa6c9967c884bb8f401bb50b92d.diff
Type: text/x-patch
Size: 1350 bytes
Desc: not available
Url :

More information about the wine-patches mailing list