Add window handle checks for glfwSetWindowIcon to Win32 and X11.

This commit is contained in:
ws909 2023-03-09 16:37:59 +01:00
parent 6381d7ed20
commit 6cd800a54d
3 changed files with 17 additions and 1 deletions

View File

@ -1521,6 +1521,14 @@ void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* im
{ {
HICON bigIcon = NULL, smallIcon = NULL; HICON bigIcon = NULL, smallIcon = NULL;
if (window == NULL)
{
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
"Win32: Requires a valid window handle to set the icon. There is no application icon to set.");
return;
}
if (count) if (count)
{ {
const GLFWimage* bigImage = _glfwChooseImage(count, images, const GLFWimage* bigImage = _glfwChooseImage(count, images,

View File

@ -1899,7 +1899,7 @@ void _glfwSetWindowIconWayland(_GLFWwindow* window,
int count, const GLFWimage* images) int count, const GLFWimage* images)
{ {
_glfwInputError(GLFW_FEATURE_UNAVAILABLE, _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
"Wayland: The platform does not support setting the window icon"); "Wayland: The platform does not support setting the window or application icon");
} }
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos) void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos)

View File

@ -2104,6 +2104,14 @@ void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title)
void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images) void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images)
{ {
if (window == NULL)
{
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
"X11: Requires a valid window handle to set the icon. There is no application icon to set.");
return;
}
if (count) if (count)
{ {
int longCount = 0; int longCount = 0;