X11: Fix function returning before cleanup

The _glfwPlatformSetWindowFloating function would return without freeing
the state array if the window was already in the requested state.

(cherry picked from commit 071d7c0f46)
This commit is contained in:
Camilla Löwy 2021-08-15 14:55:13 +02:00
parent 123643df2d
commit 50b09938e7
2 changed files with 17 additions and 16 deletions

View File

@ -126,6 +126,7 @@ information on what to include when reporting a bug.
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874) - [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
- [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after - [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after
related events were emitted related events were emitted
- [X11] Bugfix: Changing `GLFW_FLOATING` could leak memory
- [NSGL] Bugfix: Defining `GL_SILENCE_DEPRECATION` externally caused - [NSGL] Bugfix: Defining `GL_SILENCE_DEPRECATION` externally caused
a duplicate definition warning (#1840) a duplicate definition warning (#1840)
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843) - [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)

View File

@ -2686,15 +2686,15 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
break; break;
} }
if (i < count) if (i == count)
return; {
XChangeProperty(_glfw.x11.display, window->x11.handle, XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.NET_WM_STATE, XA_ATOM, 32, _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
PropModeAppend, PropModeAppend,
(unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE, (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
1); 1);
} }
}
else if (states) else if (states)
{ {
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -2703,9 +2703,8 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
break; break;
} }
if (i == count) if (i < count)
return; {
states[i] = states[count - 1]; states[i] = states[count - 1];
count--; count--;
@ -2713,6 +2712,7 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
_glfw.x11.NET_WM_STATE, XA_ATOM, 32, _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
PropModeReplace, (unsigned char*) states, count); PropModeReplace, (unsigned char*) states, count);
} }
}
if (states) if (states)
XFree(states); XFree(states);