mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
UpdateRegion: Fix bug where storage for update regions was never reallocated
This commit is contained in:
parent
65206568c4
commit
cd6176bd00
1 changed files with 21 additions and 18 deletions
|
|
@ -364,7 +364,7 @@ void UpdateRegion::findRECTAndValidate (HWND windowHandle)
|
||||||
{
|
{
|
||||||
numRect = 0;
|
numRect = 0;
|
||||||
|
|
||||||
auto regionHandle = CreateRectRgn (0, 0, 0, 0);
|
auto* regionHandle = CreateRectRgn (0, 0, 0, 0);
|
||||||
|
|
||||||
if (regionHandle == nullptr)
|
if (regionHandle == nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -372,33 +372,36 @@ void UpdateRegion::findRECTAndValidate (HWND windowHandle)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto regionType = GetUpdateRgn (windowHandle, regionHandle, false);
|
const ScopeGuard regionDeleter { [&] { DeleteObject (regionHandle); } };
|
||||||
|
const auto regionType = GetUpdateRgn (windowHandle, regionHandle, false);
|
||||||
|
|
||||||
if (regionType == SIMPLEREGION || regionType == COMPLEXREGION)
|
if (regionType == ERROR || regionType == NULLREGION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto requiredBytes = GetRegionData (regionHandle, 0, nullptr);
|
||||||
|
block.ensureSize (requiredBytes);
|
||||||
|
|
||||||
|
const auto regionDataResult = GetRegionData (regionHandle,
|
||||||
|
(DWORD) block.getSize(),
|
||||||
|
static_cast<RGNDATA*> (block.getData()));
|
||||||
|
|
||||||
|
numRect = std::invoke ([&]() -> decltype (numRect)
|
||||||
{
|
{
|
||||||
auto regionDataBytes = GetRegionData (regionHandle, (DWORD) block.getSize(), (RGNDATA*) block.getData());
|
if (regionDataResult < sizeof (RGNDATAHEADER))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (regionDataBytes > block.getSize())
|
const auto* header = static_cast<RGNDATAHEADER const* const> (block.getData());
|
||||||
{
|
|
||||||
block.ensureSize (regionDataBytes);
|
|
||||||
regionDataBytes = GetRegionData (regionHandle, (DWORD) block.getSize(), (RGNDATA*) block.getData());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regionDataBytes > 0)
|
if (header->iType != RDH_RECTANGLES)
|
||||||
{
|
return 0;
|
||||||
auto header = (RGNDATAHEADER const* const) block.getData();
|
|
||||||
|
|
||||||
if (header->iType == RDH_RECTANGLES)
|
return header->nCount;
|
||||||
numRect = header->nCount;
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numRect > 0)
|
if (numRect > 0)
|
||||||
ValidateRgn (windowHandle, regionHandle);
|
ValidateRgn (windowHandle, regionHandle);
|
||||||
else
|
else
|
||||||
ValidateRect (windowHandle, nullptr);
|
ValidateRect (windowHandle, nullptr);
|
||||||
|
|
||||||
DeleteObject (regionHandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue