Merge pull request #2460 from xercesblue/set_urgent_segfault

modules/hyprland: Fix segfault when attempting to set_urgent on a missing workspace
pull/2466/head
Alexis Rouillard 2023-09-05 08:42:39 +02:00 committed by GitHub
commit f7ff005dd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -450,7 +450,7 @@ auto Workspace::handle_clicked(GdkEventButton *bt) -> bool {
void Workspaces::set_urgent_workspace(std::string windowaddress) { void Workspaces::set_urgent_workspace(std::string windowaddress) {
const Json::Value clients_json = gIPC->getSocket1JsonReply("clients"); const Json::Value clients_json = gIPC->getSocket1JsonReply("clients");
int workspace_id; int workspace_id = -1;
for (Json::Value client_json : clients_json) { for (Json::Value client_json : clients_json) {
if (client_json["address"].asString().ends_with(windowaddress)) { if (client_json["address"].asString().ends_with(windowaddress)) {
@ -462,7 +462,7 @@ void Workspaces::set_urgent_workspace(std::string windowaddress) {
auto workspace = auto workspace =
std::find_if(workspaces_.begin(), workspaces_.end(), std::find_if(workspaces_.begin(), workspaces_.end(),
[&](std::unique_ptr<Workspace> &x) { return x->id() == workspace_id; }); [&](std::unique_ptr<Workspace> &x) { return x->id() == workspace_id; });
if (workspace->get() != nullptr) { if (workspace != workspaces_.end()) {
workspace->get()->set_urgent(); workspace->get()->set_urgent();
} }
} }