summaryrefslogtreecommitdiff
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-06-28 15:40:14 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-06-28 15:40:14 +0200
commit3832720273ac1390faf3df52af6d00c09c370919 (patch)
tree7f0f7aecd8df5c8902d6b9a85985267491832e3a /src/managers/input/InputManager.cpp
parent9fcef41d6653a2541a06275d0843bb61aaf5ea1b (diff)
fix possible crash in cinputmanager
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index e5780608..85767e69 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -344,9 +344,7 @@ Vector2D CInputManager::getMouseCoordsInternal() {
}
void CInputManager::newKeyboard(wlr_input_device* keyboard) {
- m_lKeyboards.push_back(SKeyboard());
-
- const auto PNEWKEYBOARD = &m_lKeyboards.back();
+ const auto PNEWKEYBOARD = &m_lKeyboards.emplace_back();
PNEWKEYBOARD->keyboard = keyboard;
@@ -385,9 +383,14 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
const auto VARIANT = g_pConfigManager->getString("input:kb_variant");
const auto OPTIONS = g_pConfigManager->getString("input:kb_options");
- if (RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options) {
- Debug::log(LOG, "Not applying config to keyboard, it did not change.");
- return;
+ try {
+ if (RULES != "" && RULES == std::string(pKeyboard->currentRules.rules) && MODEL == std::string(pKeyboard->currentRules.model) && LAYOUT == std::string(pKeyboard->currentRules.layout) && VARIANT == std::string(pKeyboard->currentRules.variant) && OPTIONS == std::string(pKeyboard->currentRules.options)) {
+ Debug::log(LOG, "Not applying config to keyboard, it did not change.");
+ return;
+ }
+ } catch (std::exception& e) {
+ // can be libc errors for null std::string
+ // we can ignore those and just apply
}
xkb_rule_names rules = {