diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-09-24 01:10:46 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-09-24 01:10:46 +0800 |
commit | 26252b0f4a24e536074aa034a88868bf8ea07b76 (patch) | |
tree | 60c3a3d8718a9a1a789277fa7dd8480047a26d78 /src/platform/gui/xcb/Keyboard.cpp | |
parent | 4927e536aac37607cd8aeaf6475b8e5bc91ddd1d (diff) | |
download | cru-26252b0f4a24e536074aa034a88868bf8ea07b76.tar.gz cru-26252b0f4a24e536074aa034a88868bf8ea07b76.tar.bz2 cru-26252b0f4a24e536074aa034a88868bf8ea07b76.zip |
Free all xcb reply.
Diffstat (limited to 'src/platform/gui/xcb/Keyboard.cpp')
-rw-r--r-- | src/platform/gui/xcb/Keyboard.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/platform/gui/xcb/Keyboard.cpp b/src/platform/gui/xcb/Keyboard.cpp index d7559062..e5f6da8e 100644 --- a/src/platform/gui/xcb/Keyboard.cpp +++ b/src/platform/gui/xcb/Keyboard.cpp @@ -1,4 +1,5 @@ #include "cru/platform/gui/xcb/Keyboard.h" +#include "cru/base/Guard.h" #include "cru/platform/gui/Keyboard.h" #include "cru/platform/gui/xcb/UiApplication.h" @@ -82,8 +83,8 @@ KeyCode XorgKeycodeToCruKeyCode(XcbUiApplication *application, // Get keyboard mapping auto mapping_cookie = xcb_get_keyboard_mapping(connection, keycode, 1); - auto *mapping_reply = - xcb_get_keyboard_mapping_reply(connection, mapping_cookie, NULL); + auto mapping_reply = FreeLater( + xcb_get_keyboard_mapping_reply(connection, mapping_cookie, NULL)); if (!mapping_reply) { throw XcbException("Cannot get keyboard mapping."); @@ -107,7 +108,8 @@ using KeymapBitset = KeymapBitset GetXorgKeymap(xcb_connection_t *connection) { auto keymap_cookie = xcb_query_keymap(connection); - auto keymap_reply = xcb_query_keymap_reply(connection, keymap_cookie, NULL); + auto keymap_reply = + FreeLater(xcb_query_keymap_reply(connection, keymap_cookie, NULL)); if (!keymap_reply) { throw XcbException("Cannot get keymap."); @@ -136,8 +138,8 @@ std::unordered_map<KeyCode, bool> GetKeyboardState( // Get keyboard mapping auto mapping_cookie = xcb_get_keyboard_mapping(connection, min_keycode, max_keycode - min_keycode + 1); - auto *mapping_reply = - xcb_get_keyboard_mapping_reply(connection, mapping_cookie, NULL); + auto mapping_reply = FreeLater( + xcb_get_keyboard_mapping_reply(connection, mapping_cookie, NULL)); if (!mapping_reply) { throw XcbException("Cannot get keyboard mapping."); |