From 03987b19a588d48221b8a3d4c6792a4cc0905b8b Mon Sep 17 00:00:00 2001 From: Ashwin Rajesh <46510831+VanillaViking@users.noreply.github.com> Date: Thu, 6 Oct 2022 06:39:02 +1100 Subject: [PATCH] fix(xwindow): Crash when no tag is set in format (#2833) * xwindow works without tag * changelog --- CHANGELOG.md | 1 + src/modules/xwindow.cpp | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c05fc5b..c557059d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - config: - Error reporting for deprecated config values ([`#2724`](https://github.com/polybar/polybar/issues/2724)) - Also monitor include-files for changes when --reload is set ([`#675`](https://github.com/polybar/polybar/issues/675), [`#2759`](https://github.com/polybar/polybar/pull/2759)) +- `internal/xwindow`: module does not crash when a tag is not provided in format ([`#2826`](https://github.com/polybar/polybar/issues/2826), [`#2833`](https://github.com/polybar/polybar/pull/2833)) by [@VanillaViking](https://github.com/VanillaViking) ## [3.6.3] - 2022-05-04 ### Fixed diff --git a/src/modules/xwindow.cpp b/src/modules/xwindow.cpp index eb5f7fbf..32867a82 100644 --- a/src/modules/xwindow.cpp +++ b/src/modules/xwindow.cpp @@ -123,14 +123,16 @@ namespace modules { } } - if (m_active) { - m_label = m_statelabels.at(state::ACTIVE)->clone(); - m_label->reset_tokens(); - m_label->replace_token("%title%", m_active->title()); - m_label->replace_token("%instance%", m_active->instance_name()); - m_label->replace_token("%class%", m_active->class_name()); - } else { - m_label = m_statelabels.at(state::EMPTY)->clone(); + if (!m_statelabels.empty()) { + if (m_active) { + m_label = m_statelabels.at(state::ACTIVE)->clone(); + m_label->reset_tokens(); + m_label->replace_token("%title%", m_active->title()); + m_label->replace_token("%instance%", m_active->instance_name()); + m_label->replace_token("%class%", m_active->class_name()); + } else { + m_label = m_statelabels.at(state::EMPTY)->clone(); + } } }