From 90f206f92aee2ccd18e9b2549e4bcc2228c5004e Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 18 Oct 2022 18:36:00 +0200 Subject: [PATCH] Fix crash on quickly switching workspaces The hyprland/window widget had an assertion ensuring that the output from hyprctl matched the currently selected workspace id. However this assertion fails if workspaces are switched too quickly, causing the selected workspace to differ in id from the one in hyprctl, failing this assertion which then crashes the entire program. This fix simply changes this assertion into an if statement, and if a mismatch is found, empty string is returned as the window name. --- src/modules/hyprland/window.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/hyprland/window.cpp b/src/modules/hyprland/window.cpp index cd1584d..8d02cf3 100644 --- a/src/modules/hyprland/window.cpp +++ b/src/modules/hyprland/window.cpp @@ -59,7 +59,10 @@ std::string Window::getLastWindowTitle(uint workspaceID) { auto workspace = std::find_if(json.begin(), json.end(), [&](Json::Value workspace) { return workspace["id"].as() == workspaceID; }); - assert(workspace != std::end(json)); + + if (workspace != std::end(json)) { + return ""; + } return (*workspace)["lastwindowtitle"].as(); }