Added DBus pointer checks

This commit is contained in:
GamesTrap 2023-03-08 14:47:40 +01:00
parent ef4d722b76
commit 589e6b78d9
No known key found for this signature in database
GPG Key ID: 31DFD452434ECDA3
3 changed files with 88 additions and 59 deletions

View File

@ -41,8 +41,9 @@ void _glfwInitDBusPOSIX(void)
_glfw.dbus.connection = NULL;
_glfw.dbus.handle = _glfwPlatformLoadModule("libdbus-1.so.3");
if (_glfw.dbus.handle)
{
if (!_glfw.dbus.handle)
return;
_glfw.dbus.error_init = (PFN_dbus_error_init)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_error_init");
_glfw.dbus.error_is_set = (PFN_dbus_error_is_set)
@ -72,6 +73,26 @@ void _glfwInitDBusPOSIX(void)
_glfw.dbus.message_iter_close_container = (PFN_dbus_message_iter_close_container)
_glfwPlatformGetModuleSymbol(_glfw.dbus.handle, "dbus_message_iter_close_container");
if (!_glfw.dbus.error_init ||
!_glfw.dbus.error_is_set ||
!_glfw.dbus.error_free ||
!_glfw.dbus.connection_unref ||
!_glfw.dbus.connection_send ||
!_glfw.dbus.connection_flush ||
!_glfw.dbus.bus_request_name ||
!_glfw.dbus.bus_get ||
!_glfw.dbus.message_unref ||
!_glfw.dbus.message_new_signal ||
!_glfw.dbus.message_iter_init_append ||
!_glfw.dbus.message_iter_append_basic ||
!_glfw.dbus.message_iter_open_container ||
!_glfw.dbus.message_iter_close_container)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"POSIX: Failed to load DBus entry points");
return;
}
//Initialize DBus connection
dbus_error_init(&_glfw.dbus.error);
_glfw.dbus.connection = dbus_bus_get(DBUS_BUS_SESSION, &_glfw.dbus.error);
@ -106,14 +127,6 @@ void _glfwInitDBusPOSIX(void)
}
}
if(_glfw.dbus.connection)
{
//Window NULL is safe here because it won't get
//used inside the SetWindowTaskbarProgress function
_glfw.platform.setWindowProgressIndicator(NULL, GLFW_PROGRESS_INDICATOR_DISABLED, 0);
}
}
void _glfwTerminateDBusPOSIX(void)
{
if (_glfw.dbus.connection)

View File

@ -1843,6 +1843,14 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window,
return GLFW_FALSE;
}
//Reset progress state as it gets saved between application runs
if(_glfw.dbus.connection)
{
//Window NULL is safe here because it won't get
//used inside the SetWindowTaskbarProgress function
_glfwSetWindowProgressIndicatorWayland(NULL, GLFW_PROGRESS_INDICATOR_DISABLED, 0.0);
}
return GLFW_TRUE;
}

View File

@ -2040,6 +2040,14 @@ GLFWbool _glfwCreateWindowX11(_GLFWwindow* window,
}
}
//Reset progress state as it gets saved between application runs
if(_glfw.dbus.connection)
{
//Window NULL is safe here because it won't get
//used inside the SetWindowTaskbarProgress function
_glfwSetWindowProgressIndicatorX11(NULL, GLFW_PROGRESS_INDICATOR_DISABLED, 0.0);
}
XFlush(_glfw.x11.display);
return GLFW_TRUE;
}