mirror of
https://github.com/polybar/polybar.git
synced 2024-11-03 04:33:30 -05:00
fix: Memory leak
This commit is contained in:
parent
51d8f289fa
commit
ab5666a7ea
3 changed files with 19 additions and 15 deletions
|
@ -13,18 +13,19 @@ namespace bspwm_util {
|
|||
auto children = conn.query_tree(conn.screen()->root).children();
|
||||
|
||||
for (auto it = children.begin(); it != children.end(); it++) {
|
||||
auto cookie = xcb_icccm_get_wm_class(conn, *it);
|
||||
xcb_icccm_get_wm_class_reply_t reply;
|
||||
reply.class_name = reply.instance_name = nullptr;
|
||||
|
||||
if (xcb_icccm_get_wm_class_reply(conn, cookie, &reply, nullptr) == 0)
|
||||
continue;
|
||||
|
||||
if (!string_util::compare("Bspwm", reply.class_name) ||
|
||||
!string_util::compare("root", reply.instance_name))
|
||||
continue;
|
||||
|
||||
if (xcb_icccm_get_wm_class_reply(conn, xcb_icccm_get_wm_class(conn, *it), &reply, nullptr)) {
|
||||
if (string_util::compare("Bspwm", reply.class_name) && string_util::compare("root", reply.instance_name)) {
|
||||
roots.emplace_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
if (reply.class_name != nullptr || reply.instance_name != nullptr) {
|
||||
xcb_icccm_get_wm_class_reply_wipe(&reply);
|
||||
}
|
||||
}
|
||||
|
||||
return roots;
|
||||
}
|
||||
|
|
|
@ -19,17 +19,19 @@ namespace i3_util {
|
|||
auto children = conn.query_tree(conn.screen()->root).children();
|
||||
|
||||
for (auto it = children.begin(); it != children.end(); it++) {
|
||||
auto cookie = xcb_icccm_get_wm_name(conn, *it);
|
||||
xcb_icccm_get_text_property_reply_t reply;
|
||||
reply.name = nullptr;
|
||||
|
||||
if (xcb_icccm_get_wm_name_reply(conn, cookie, &reply, nullptr) == 0)
|
||||
continue;
|
||||
|
||||
if (("[i3 con] output " + output_name).compare(0, 16 + output_name.length(), reply.name) != 0)
|
||||
continue;
|
||||
|
||||
if (xcb_icccm_get_wm_name_reply(conn, xcb_icccm_get_wm_name(conn, *it), &reply, nullptr)) {
|
||||
if (("[i3 con] output " + output_name).compare(0, 16 + output_name.length(), reply.name) == 0) {
|
||||
roots.emplace_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
if (reply.name != nullptr) {
|
||||
xcb_icccm_get_text_property_reply_wipe(&reply);
|
||||
}
|
||||
}
|
||||
|
||||
return roots;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "x11/connection.hpp"
|
||||
|
||||
LEMONBUDDY_NS
|
||||
|
||||
/**
|
||||
* Preload required xcb atoms
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue