remove use of new on Layout

pull/2064/head
en3wton 2023-03-21 19:30:35 +00:00
parent 4ab4ff790e
commit bbcfb5e138
2 changed files with 8 additions and 6 deletions

View File

@ -26,7 +26,7 @@ class Language : public waybar::ALabel, public EventHandler {
std::string short_description; std::string short_description;
}; };
auto getLayout(const std::string&) -> Layout*; auto getLayout(const std::string&) -> Layout;
std::mutex mutex_; std::mutex mutex_;
const Bar& bar_; const Bar& bar_;

View File

@ -68,7 +68,7 @@ void Language::onEvent(const std::string& ev) {
layoutName = waybar::util::sanitize_string(layoutName); layoutName = waybar::util::sanitize_string(layoutName);
layout_ = *getLayout(layoutName); layout_ = getLayout(layoutName);
spdlog::debug("hyprland language onevent with {}", layoutName); spdlog::debug("hyprland language onevent with {}", layoutName);
@ -89,7 +89,7 @@ void Language::initLanguage() {
searcher = waybar::util::sanitize_string(searcher); searcher = waybar::util::sanitize_string(searcher);
layout_ = *getLayout(searcher); layout_ = getLayout(searcher);
spdlog::debug("hyprland language initLanguage found {}", layout_.full_name); spdlog::debug("hyprland language initLanguage found {}", layout_.full_name);
@ -100,7 +100,7 @@ void Language::initLanguage() {
} }
} }
auto Language::getLayout(const std::string& fullName) -> Layout* { auto Language::getLayout(const std::string& fullName) -> Layout {
const auto CONTEXT = rxkb_context_new(RXKB_CONTEXT_LOAD_EXOTIC_RULES); const auto CONTEXT = rxkb_context_new(RXKB_CONTEXT_LOAD_EXOTIC_RULES);
rxkb_context_parse_default_ruleset(CONTEXT); rxkb_context_parse_default_ruleset(CONTEXT);
@ -121,7 +121,7 @@ auto Language::getLayout(const std::string& fullName) -> Layout* {
std::string short_description = std::string short_description =
short_description_ == nullptr ? "" : std::string(short_description_); short_description_ == nullptr ? "" : std::string(short_description_);
Layout* info = new Layout{nameOfLayout, name, variant, short_description}; Layout info = Layout{nameOfLayout, name, variant, short_description};
rxkb_context_unref(CONTEXT); rxkb_context_unref(CONTEXT);
@ -130,7 +130,9 @@ auto Language::getLayout(const std::string& fullName) -> Layout* {
rxkb_context_unref(CONTEXT); rxkb_context_unref(CONTEXT);
return NULL; spdlog::debug("hyprland language didn't find matching layout");
return Layout {"", "", "", ""};
} }
} // namespace waybar::modules::hyprland } // namespace waybar::modules::hyprland