Reset BitmapWriteAccess before further bitmap use

It started failing an assertion recently (maybe after the 1-bit images
support drop in commit 21734247d58a6e915b058d8fa55ece949d049613), when
opening Styles sidebar, with this call stack:

  ucrtbased.dll!_wassert(const wchar_t * expression, const wchar_t * file_name, unsigned int line_number) Line 444	C++
  vcllo.dll!SkiaSalBitmap::AcquireBuffer(BitmapAccessMode nMode) Line 230	C++
  vcllo.dll!BitmapInfoAccess::BitmapInfoAccess(Bitmap & rBitmap, BitmapAccessMode nMode) Line 47	C++
  vcllo.dll!Bitmap::AcquireInfoAccess() Line 368	C++
  vcllo.dll!vcl::ScopedBitmapAccess<BitmapInfoAccess,Bitmap,&Bitmap::AcquireInfoAccess>::ScopedBitmapAccess<BitmapInfoAccess,Bitmap,&Bitmap::AcquireInfoAccess>(Bitmap & rBitmap) Line 55	C++
  vcllo.dll!Bitmap::HasGreyPalette8Bit() Line 291	C++
  vcllo.dll!Bitmap::Convert(BmpConversion eConversion) Line 868	C++
  vcllo.dll!AlphaMask::AlphaMask(const Bitmap & rBitmap) Line 35	C++
  vcllo.dll!BitmapEx::BitmapEx(const Bitmap & rBmp, const AlphaMask & rAlphaMask) Line 142	C++
  vcllo.dll!vcl::bitmap::CreateFromData(const unsigned char * pData, long nWidth, long nHeight, long nStride, char nBitCount, bool bReversColors, bool bReverseAlpha) Line 216	C++
  ...

The comment at the assert in SkiaSalBitmap::AcquireBuffer (that is called
from BitmapInfoAccess ctor) tells:

  BitmapWriteAccess stores also a copy of the palette and it can
  be modified, so concurrent reading of it might result in inconsistencies

Change-Id: I364060cf3c2073cfd8bf3288140a7ab3604cd2a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145659
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2023-01-17 11:27:25 +03:00
parent fdf95de18e
commit ebac691388

View File

@ -212,6 +212,9 @@ BitmapEx CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHei
}
}
}
// Avoid further bitmap use with unfinished write access
pWrite.reset();
xMaskAcc.reset();
if (nBitCount == 32)
return BitmapEx(aBmp, *pAlphaMask);
else