From 9405c7133e00a2188cb0dfbf0c69926da87cc471 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sat, 27 Jun 2026 10:22:53 +0200 Subject: [PATCH] desktop/groups: fix crash on dissolution (#15135) --- hyprtester/src/tests/main/groups.cpp | 12 ++++++++++++ src/desktop/view/Group.cpp | 7 +++++-- tests/helpers/MiscFunctions.cpp | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/hyprtester/src/tests/main/groups.cpp b/hyprtester/src/tests/main/groups.cpp index cb15bdf2f..62742b9a2 100644 --- a/hyprtester/src/tests/main/groups.cpp +++ b/hyprtester/src/tests/main/groups.cpp @@ -472,3 +472,15 @@ TEST_CASE(groups) { Tests::killAllWindows(); ASSERT(Tests::windowCount(), 0); } + +TEST_CASE(groupsNoCrash) { + auto kittyA = Tests::spawnKitty("kittyA"); + + OK(getFromSocket("/dispatch hl.dsp.group.toggle()")); + OK(getFromSocket("/dispatch hl.dsp.group.toggle()")); + + { + auto curr = getFromSocket("/activewindow"); + EXPECT_CONTAINS(curr, "kittyA"); + } +} \ No newline at end of file diff --git a/src/desktop/view/Group.cpp b/src/desktop/view/Group.cpp index afa4885e1..40aad3735 100644 --- a/src/desktop/view/Group.cpp +++ b/src/desktop/view/Group.cpp @@ -66,7 +66,9 @@ void CGroup::init() { } void CGroup::destroy() { - while (true) { + const auto POWNER = head(); + + while (!m_windows.empty()) { if (m_windows.size() == 1) { remove(m_windows.at(0).lock()); break; @@ -75,7 +77,8 @@ void CGroup::destroy() { remove(m_windows.at(0).lock()); } - g_pEventManager->postEvent(SHyprIPCEvent({.event = "togglegroup", .data = std::format("0,{:x}", rc(m_windows.at(0).get()))})); + if (POWNER) + g_pEventManager->postEvent(SHyprIPCEvent({.event = "togglegroup", .data = std::format("0,{:x}", rc(POWNER.get()))})); } CGroup::~CGroup() { diff --git a/tests/helpers/MiscFunctions.cpp b/tests/helpers/MiscFunctions.cpp index e32766a2b..44e026cfe 100644 --- a/tests/helpers/MiscFunctions.cpp +++ b/tests/helpers/MiscFunctions.cpp @@ -36,6 +36,7 @@ TEST(Helpers, isDirectionString) { EXPECT_FALSE(isDirection("leftover")); EXPECT_FALSE(isDirection("desc:Monitor")); EXPECT_FALSE(isDirection("")); + EXPECT_FALSE(isDirection("i_am_single")); } // normalizeAngleRad