Elad8a
Topic Author
Posts: 11
Joined: 17 Jun 2018, 20:52

Win32Display::SizeChanged() BUG

08 Apr 2022, 20:33

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;
            }
        }
    }
}
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: Win32Display::SizeChanged() BUG

11 Apr 2022, 13:13

Thanks a lot for pointing this out, we just commit the fix for the next release.

Who is online

Users browsing this forum: Google [Bot], vinick and 63 guests