diff --git a/.valgrind-suppressions b/.valgrind-suppressions index a66b72fe..5d83a045 100644 --- a/.valgrind-suppressions +++ b/.valgrind-suppressions @@ -66,3 +66,20 @@ ... ... } +{ + xresource manager + Memcheck:Leak + match-leak-kinds: definite + fun:realloc + obj:/usr/lib/libX11.so.6.3.0 + obj:/usr/lib/libX11.so.6.3.0 + obj:/usr/lib/libX11.so.6.3.0 + fun:_XlcCreateLC + fun:_XlcDefaultLoader + fun:_XOpenLC + fun:_XrmInitParseInfo + obj:/usr/lib/libX11.so.6.3.0 + fun:XrmGetStringDatabase + ... + ... +} diff --git a/include/x11/xresources.hpp b/include/x11/xresources.hpp index 194bca28..65ba2243 100644 --- a/include/x11/xresources.hpp +++ b/include/x11/xresources.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include "common.hpp" @@ -22,8 +23,9 @@ class xresource_manager { string load_value(const string& key, const string& res_type, size_t n) const; private: - char* m_manager{nullptr}; + Display* m_display{nullptr}; XrmDatabase m_db; + char* m_manager{nullptr}; }; POLYBAR_NS_END diff --git a/src/x11/xresources.cpp b/src/x11/xresources.cpp index d7e99769..538a124e 100644 --- a/src/x11/xresources.cpp +++ b/src/x11/xresources.cpp @@ -22,13 +22,11 @@ xresource_manager::make_type xresource_manager::make() { xresource_manager::xresource_manager() { XrmInitialize(); - if (xlib::get_display() == nullptr) { + if ((m_display = xlib::get_display()) == nullptr) { return; - } - if ((m_manager = XResourceManagerString(xlib::get_display())) == nullptr) { + } else if ((m_manager = XResourceManagerString(xlib::get_display())) == nullptr) { return; - } - if ((m_db = XrmGetStringDatabase(m_manager)) == nullptr) { + } else if ((m_db = XrmGetStringDatabase(m_manager)) == nullptr) { return; } }