Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a few asan reported leaks on exit of hyprland #5852

Merged
merged 5 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,22 @@ void CCompositor::cleanup() {
g_pWatchdog.reset();
g_pXWaylandManager.reset();

wl_display_terminate(m_sWLDisplay);
if (m_sWLRCursor)
wlr_cursor_destroy(m_sWLRCursor);

if (m_sSeat.seat)
wlr_seat_destroy(m_sSeat.seat);

if (m_sWLRRenderer)
wlr_renderer_destroy(m_sWLRRenderer);

if (m_sWLRAllocator)
wlr_allocator_destroy(m_sWLRAllocator);

if (m_sWLRBackend)
wlr_backend_destroy(m_sWLRBackend);

wl_display_terminate(m_sWLDisplay);
m_sWLDisplay = nullptr;
}

Expand Down
7 changes: 7 additions & 0 deletions src/debug/HyprNotificationOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ CHyprNotificationOverlay::CHyprNotificationOverlay() {
m_szIconFontName = fonts.substr(COLON + 2, LASTCHAR - (COLON + 2));
}

CHyprNotificationOverlay::~CHyprNotificationOverlay() {
if (m_pCairo)
cairo_destroy(m_pCairo);
if (m_pCairoSurface)
cairo_surface_destroy(m_pCairoSurface);
}

void CHyprNotificationOverlay::addNotification(const std::string& text, const CColor& color, const float timeMs, const eIcons icon, const float fontSize) {
const auto PNOTIF = m_dNotifications.emplace_back(std::make_unique<SNotification>()).get();

Expand Down
1 change: 1 addition & 0 deletions src/debug/HyprNotificationOverlay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct SNotification {
class CHyprNotificationOverlay {
public:
CHyprNotificationOverlay();
~CHyprNotificationOverlay();

void draw(CMonitor* pMonitor);
void addNotification(const std::string& text, const CColor& color, const float timeMs, const eIcons icon = ICON_NONE, const float fontSize = 13.f);
Expand Down
5 changes: 5 additions & 0 deletions src/helpers/WLClasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ struct SKeyboard {
bool operator==(const SKeyboard& rhs) const {
return keyboard == rhs.keyboard;
}

~SKeyboard() {
if (xkbTranslationState)
xkb_state_unref(xkbTranslationState);
}
};

struct SMouse {
Expand Down
5 changes: 5 additions & 0 deletions src/managers/CursorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ CCursorManager::CCursorManager() {
static auto P = g_pHookSystem->hookDynamic("monitorLayoutChanged", [this](void* self, SCallbackInfo& info, std::any param) { this->updateTheme(); });
}

CCursorManager::~CCursorManager() {
if (m_pWLRXCursorMgr)
wlr_xcursor_manager_destroy(m_pWLRXCursorMgr);
}

void CCursorManager::dropBufferRef(CCursorManager::CCursorBuffer* ref) {
std::erase_if(m_vCursorBuffers, [ref](const auto& buf) { return buf.get() == ref; });
}
Expand Down
1 change: 1 addition & 0 deletions src/managers/CursorManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct wlr_xwayland;
class CCursorManager {
public:
CCursorManager();
~CCursorManager();

wlr_buffer* getCursorBuffer();

Expand Down
6 changes: 6 additions & 0 deletions src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ CKeybindManager::CKeybindManager() {
});
}

CKeybindManager::~CKeybindManager() {
if (m_pXKBTranslationState)
xkb_state_unref(m_pXKBTranslationState);
}

void CKeybindManager::addKeybind(SKeybind kb) {
m_lKeybinds.push_back(kb);

Expand Down Expand Up @@ -219,6 +224,7 @@ void CKeybindManager::updateXKBTranslationState() {

xkb_context_unref(PCONTEXT);
m_pXKBTranslationState = xkb_state_new(PKEYMAP);
xkb_keymap_unref(PKEYMAP);
}

bool CKeybindManager::ensureMouseBindState() {
Expand Down
1 change: 1 addition & 0 deletions src/managers/KeybindManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct SParsedKey {
class CKeybindManager {
public:
CKeybindManager();
~CKeybindManager();

bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*);
bool onAxisEvent(wlr_pointer_axis_event*);
Expand Down
Loading