From 1bd5b083cb48c13f901f276fc5d94c1b0a1ef9a1 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 16 Mar 2026 22:38:32 -0700 Subject: [PATCH] hyprland/ipc: add null checks and ws preinit to toplevel object init Previously HyprlandToplevel::updateFromObject did not call findWorkspaceByName with createIfMissing=true, leaving bWorkspace null for a later insertToplevel call from HyprlandIpc::refreshToplevels. --- changelog/next.md | 1 + src/wayland/hyprland/ipc/connection.cpp | 2 +- src/wayland/hyprland/ipc/hyprland_toplevel.cpp | 10 +++------- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/changelog/next.md b/changelog/next.md index 3969d55..cceb79e 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -48,6 +48,7 @@ set shell id. - Fixed volumes not initializing if a pipewire device was already loaded before its node. - Fixed hyprland active toplevel not resetting after window closes. - Fixed hyprland ipc window names and titles being reversed. +- Fixed a hyprland ipc crash when refreshing toplevels before workspaces. - Fixed missing signals for system tray item title and description updates. - Fixed asynchronous loaders not working after reload. - Fixed asynchronous loaders not working before window creation. diff --git a/src/wayland/hyprland/ipc/connection.cpp b/src/wayland/hyprland/ipc/connection.cpp index d2d5105..d15701d 100644 --- a/src/wayland/hyprland/ipc/connection.cpp +++ b/src/wayland/hyprland/ipc/connection.cpp @@ -729,7 +729,7 @@ void HyprlandIpc::refreshToplevels() { } auto* workspace = toplevel->bindableWorkspace().value(); - workspace->insertToplevel(toplevel); + if (workspace) workspace->insertToplevel(toplevel); } }); } diff --git a/src/wayland/hyprland/ipc/hyprland_toplevel.cpp b/src/wayland/hyprland/ipc/hyprland_toplevel.cpp index 7b07bc8..43b9838 100644 --- a/src/wayland/hyprland/ipc/hyprland_toplevel.cpp +++ b/src/wayland/hyprland/ipc/hyprland_toplevel.cpp @@ -72,20 +72,16 @@ void HyprlandToplevel::updateFromObject(const QVariantMap& object) { Qt::beginPropertyUpdateGroup(); bool ok = false; auto address = addressStr.toULongLong(&ok, 16); - if (!ok || !address) { - return; - } + if (ok && address) this->setAddress(address); - this->setAddress(address); this->bTitle = title; auto workspaceMap = object.value("workspace").toMap(); auto workspaceName = workspaceMap.value("name").toString(); - auto* workspace = this->ipc->findWorkspaceByName(workspaceName, false); - if (!workspace) return; + auto* workspace = this->ipc->findWorkspaceByName(workspaceName, true); + if (workspace) this->setWorkspace(workspace); - this->setWorkspace(workspace); this->bLastIpcObject = object; Qt::endPropertyUpdateGroup(); }