Do nothing in wxMemoryDC::SelectObject() if the bitmap is already selected.

It doesn't make sense to make a copy of the bitmap in order to select it into
wxMemoryDC if it's already selected into it.

See #11640.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65913 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-10-24 22:41:46 +00:00
parent 648c1af93d
commit 71f5b0e7da
2 changed files with 14 additions and 4 deletions

View File

@@ -81,13 +81,17 @@ public:
should use when you select a bitmap because you want to modify it, e.g.
drawing on this DC.
Using SelectObjectAsSource() when modifying the bitmap may incurr some
Using SelectObjectAsSource() when modifying the bitmap may incur some
problems related to wxBitmap being a reference counted object (see
@ref overview_refcount).
Also, before using the updated bitmap data, make sure to select it out
of context first (for example by selecting ::wxNullBitmap into the device
context).
Before using the updated bitmap data, make sure to select it out of
context first either by selecting ::wxNullBitmap into the device
context or destroying the device context entirely.
If the bitmap is already selected in this device context, nothing is
done. If it is selected in another context, the function asserts and
drawing on the bitmap won't work correctly.
@see wxDC::DrawBitmap()
*/

View File

@@ -236,6 +236,12 @@ wxMemoryDC::wxMemoryDC(wxDC *dc)
void wxMemoryDC::SelectObject(wxBitmap& bmp)
{
if ( bmp.IsSameAs(GetSelectedBitmap()) )
{
// Nothing to do, this bitmap is already selected.
return;
}
// make sure that the given wxBitmap is not sharing its data with other
// wxBitmap instances as its contents will be modified by any drawing
// operation done on this DC