Page 1 of 1

Win32Display::SizeChanged() BUG

Posted: 08 Apr 2022, 20:33
by Elad8a
There are missing parentheses in line 1018 1019 in the Win32Display::SizeChanged() method. It causes the window to change its size if it is far enough from the top left corner.

Here is the fixed code:
void Win32Display::SizeChanged()
{
    // SizeChanged callback is not invoked in the middle of a resize operation to avoid unnecessary 
    // render target recreations. This avoids massive memory spikes and even driver crashes

    if (!mInsideSizeMove)
    {
        RECT r;
        BOOL ret = GetWindowRect(mWindowHandle, &r);
        NS_ASSERT(ret != 0);

        float scale = GetScale();
        uint32_t width = Round((r.right - r.left) / scale); // here was the bug
        uint32_t height = Round((r.bottom - r.top) / scale); // here was the bug
        if (IsWindowVisible(mWindowHandle) && !IsIconic(mWindowHandle))
        {
            if (width != mWidth || height != mHeight)
            {
                mSizeChanged(this, width, height);
                mWidth = width;
                mHeight = height;
            }
        }
    }
}

Re: Win32Display::SizeChanged() BUG

Posted: 11 Apr 2022, 13:13
by sfernandez
Thanks a lot for pointing this out, we just commit the fix for the next release.