From d3be9a736367e75c2db7791e62ed99a1652acb30 Mon Sep 17 00:00:00 2001 From: zjeffer <4633209+zjeffer@users.noreply.github.com> Date: Tue, 4 Jul 2023 19:40:43 +0200 Subject: [PATCH 1/2] Fix rare segfault when destroying workspace --- src/modules/hyprland/workspaces.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/hyprland/workspaces.cpp b/src/modules/hyprland/workspaces.cpp index f5cc832..e169f91 100644 --- a/src/modules/hyprland/workspaces.cpp +++ b/src/modules/hyprland/workspaces.cpp @@ -104,7 +104,7 @@ void Workspaces::remove_workspace(int id) { [&](std::unique_ptr &x) { return x->id() == id; }); if (workspace == workspaces_.end()) { - spdlog::warn("Can't find workspace with id {}", workspace->get()->id()); + spdlog::warn("Can't find workspace with id {}", id); return; } From 7ef80d563b156733b42746a4d385a9c27914727f Mon Sep 17 00:00:00 2001 From: zjeffer <4633209+zjeffer@users.noreply.github.com> Date: Tue, 4 Jul 2023 19:48:04 +0200 Subject: [PATCH 2/2] Formatting fixes --- src/modules/gamemode.cpp | 1 - src/modules/sway/window.cpp | 2 +- src/modules/upower/upower.cpp | 1 - src/modules/upower/upower_tooltip.cpp | 1 - src/util/gtk_icon.cpp | 7 +++---- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/modules/gamemode.cpp b/src/modules/gamemode.cpp index 10a7ec7..811f13c 100644 --- a/src/modules/gamemode.cpp +++ b/src/modules/gamemode.cpp @@ -18,7 +18,6 @@ #include "glibmm/varianttype.h" #include "gtkmm/label.h" #include "gtkmm/tooltip.h" - #include "util/gtk_icon.hpp" namespace waybar::modules { diff --git a/src/modules/sway/window.cpp b/src/modules/sway/window.cpp index 6f97b2e..50aea60 100644 --- a/src/modules/sway/window.cpp +++ b/src/modules/sway/window.cpp @@ -11,8 +11,8 @@ #include #include -#include "util/rewrite_string.hpp" #include "util/gtk_icon.hpp" +#include "util/rewrite_string.hpp" namespace waybar::modules::sway { diff --git a/src/modules/upower/upower.cpp b/src/modules/upower/upower.cpp index ea03934..1262d0a 100644 --- a/src/modules/upower/upower.cpp +++ b/src/modules/upower/upower.cpp @@ -6,7 +6,6 @@ #include #include "gtkmm/tooltip.h" - #include "util/gtk_icon.hpp" namespace waybar::modules::upower { diff --git a/src/modules/upower/upower_tooltip.cpp b/src/modules/upower/upower_tooltip.cpp index fddb688..45544bb 100644 --- a/src/modules/upower/upower_tooltip.cpp +++ b/src/modules/upower/upower_tooltip.cpp @@ -4,7 +4,6 @@ #include "gtkmm/enums.h" #include "gtkmm/image.h" #include "gtkmm/label.h" - #include "util/gtk_icon.hpp" namespace waybar::modules::upower { diff --git a/src/util/gtk_icon.cpp b/src/util/gtk_icon.cpp index 70aeec2..5dd741f 100644 --- a/src/util/gtk_icon.cpp +++ b/src/util/gtk_icon.cpp @@ -5,19 +5,18 @@ * access can cause data corruption and lead to invalid memory access and crashes. * Even concurrent calls that seem read only such as has_icon can cause issues because * the GTK lib may update the internal icon cache on this calls. -*/ + */ std::mutex DefaultGtkIconThemeWrapper::default_theme_mutex; bool DefaultGtkIconThemeWrapper::has_icon(const std::string& value) { - const std::lock_guard lock(default_theme_mutex); return Gtk::IconTheme::get_default()->has_icon(value); } -Glib::RefPtr DefaultGtkIconThemeWrapper::load_icon(const char *name, int tmp_size, Gtk::IconLookupFlags flags) { - +Glib::RefPtr DefaultGtkIconThemeWrapper::load_icon(const char* name, int tmp_size, + Gtk::IconLookupFlags flags) { const std::lock_guard lock(default_theme_mutex); auto default_theme = Gtk::IconTheme::get_default();