Really fix setting wxBitmap scale factor

Optimization of 2ae80673ff (Avoid unnecessarily unsharing bitmaps in
wxMSW, 2022-02-02) broke setting the scale factor because we didn't
update the right bitmap data in case bitmap hadn't had exclusive
ownership of its data before. Fix this by not using a reference which
may refer to another object after AllocExclusive() call.

Also change the other ports to unshared the bitmap when modifying its
scale factor so that the new unit test passes for them too.
This commit is contained in:
Vadim Zeitlin
2022-02-10 13:13:59 +00:00
parent eaa769a73a
commit 20d1188e82
4 changed files with 40 additions and 5 deletions

View File

@@ -1391,7 +1391,12 @@ void wxBitmap::SetScaleFactor(double scale)
{
wxCHECK_RET( IsOk(), wxT("invalid bitmap") );
return GetBitmapData()->SetScaleFactor(scale) ;
if ( GetBitmapData()->GetScaleFactor() != scale )
{
AllocExclusive();
GetBitmapData()->SetScaleFactor(scale) ;
}
}
double wxBitmap::GetScaleFactor() const