diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-25 18:30:12 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-25 18:30:12 +1000 |
| commit | 423ca87181d4d9ff06714cd30d81feb246a88c7a (patch) | |
| tree | 4dbef8038bfb1db6affaa12fb2526cdbec84e3bc | |
| parent | plugin/hypr: fix devices + better error handling (diff) | |
| download | caelestia-shell-423ca87181d4d9ff06714cd30d81feb246a88c7a.tar.gz caelestia-shell-423ca87181d4d9ff06714cd30d81feb246a88c7a.tar.bz2 caelestia-shell-423ca87181d4d9ff06714cd30d81feb246a88c7a.zip | |
plugin/hypr: fix updating keyboards
| -rw-r--r-- | plugin/src/Caelestia/Internal/hyprdevices.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/plugin/src/Caelestia/Internal/hyprdevices.cpp b/plugin/src/Caelestia/Internal/hyprdevices.cpp index 2c94d90..3aa0158 100644 --- a/plugin/src/Caelestia/Internal/hyprdevices.cpp +++ b/plugin/src/Caelestia/Internal/hyprdevices.cpp @@ -93,13 +93,18 @@ bool HyprDevices::updateLastIpcObject(QJsonObject object) { const auto val = object.value("keyboards").toArray(); bool dirty = false; - for (const auto& keyboard : std::as_const(m_keyboards)) { - if (std::find_if(val.begin(), val.end(), [keyboard](const QJsonValue& object) { - return object.toObject().value("address").toString() == keyboard->address(); - }) == val.end()) { + for (auto it = m_keyboards.begin(); it != m_keyboards.end();) { + auto* const keyboard = *it; + const auto inNewValues = std::any_of(val.begin(), val.end(), [keyboard](const QJsonValue& object) { + return object.toObject().value("address").toString() == keyboard->address(); + }); + + if (!inNewValues) { dirty = true; - m_keyboards.removeAll(keyboard); + it = m_keyboards.erase(it); keyboard->deleteLater(); + } else { + ++it; } } |