internal: fix some misused configStringToInt conversions

fixes #8523
This commit is contained in:
Vaxry 2024-11-20 10:32:50 +00:00
parent c4eda46d0e
commit e5fa017172
4 changed files with 9 additions and 9 deletions

View file

@ -2101,13 +2101,13 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co
PANIM->second.pValues = &PANIM->second; PANIM->second.pValues = &PANIM->second;
// This helper casts strings like "1", "true", "off", "yes"... to int. // This helper casts strings like "1", "true", "off", "yes"... to int.
int64_t enabledInt = configStringToInt(ARGS[1]) == 1; int64_t enabledInt = configStringToInt(ARGS[1]).value_or(0) == 1;
// Checking that the int is 1 or 0 because the helper can return integers out of range. // Checking that the int is 1 or 0 because the helper can return integers out of range.
if (enabledInt != 0 && enabledInt != 1) if (enabledInt != 0 && enabledInt != 1)
return "invalid animation on/off state"; return "invalid animation on/off state";
PANIM->second.internalEnabled = configStringToInt(ARGS[1]) == 1; PANIM->second.internalEnabled = configStringToInt(ARGS[1]).value_or(0) == 1;
if (PANIM->second.internalEnabled) { if (PANIM->second.internalEnabled) {
// speed // speed

View file

@ -707,7 +707,7 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
*(search->second(m_pSelf.lock())) = CWindowOverridableVar(true, priority); *(search->second(m_pSelf.lock())) = CWindowOverridableVar(true, priority);
} else { } else {
try { try {
*(search->second(m_pSelf.lock())) = CWindowOverridableVar((bool)configStringToInt(VARS[1]), priority); *(search->second(m_pSelf.lock())) = CWindowOverridableVar((bool)configStringToInt(VARS[1]).value_or(0), priority);
} catch (...) {} } catch (...) {}
} }
} else if (auto search = g_pConfigManager->miWindowProperties.find(VARS[0]); search != g_pConfigManager->miWindowProperties.end()) { } else if (auto search = g_pConfigManager->miWindowProperties.find(VARS[0]); search != g_pConfigManager->miWindowProperties.end()) {

View file

@ -332,7 +332,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
const auto SHOULDBESPECIAL = configStringToInt(prop); const auto SHOULDBESPECIAL = configStringToInt(prop);
if ((bool)SHOULDBESPECIAL != m_bIsSpecialWorkspace) if (SHOULDBESPECIAL && (bool)*SHOULDBESPECIAL != m_bIsSpecialWorkspace)
return false; return false;
continue; continue;
} }
@ -367,7 +367,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
const auto WANTSNAMED = configStringToInt(prop); const auto WANTSNAMED = configStringToInt(prop);
if (WANTSNAMED != (m_iID <= -1337)) if (WANTSNAMED && *WANTSNAMED != (m_iID <= -1337))
return false; return false;
continue; continue;
} }

View file

@ -2961,13 +2961,13 @@ SDispatchResult CKeybindManager::setProp(std::string args) {
CWindowOverridableVar(SAlphaValue{std::stof(VAL), PWINDOW->m_sWindowData.alphaFullscreen.valueOrDefault().m_bOverride}, PRIORITY_SET_PROP); CWindowOverridableVar(SAlphaValue{std::stof(VAL), PWINDOW->m_sWindowData.alphaFullscreen.valueOrDefault().m_bOverride}, PRIORITY_SET_PROP);
} else if (PROP == "alphaoverride") { } else if (PROP == "alphaoverride") {
PWINDOW->m_sWindowData.alpha = PWINDOW->m_sWindowData.alpha =
CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alpha.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL)}, PRIORITY_SET_PROP); CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alpha.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL).value_or(0)}, PRIORITY_SET_PROP);
} else if (PROP == "alphainactiveoverride") { } else if (PROP == "alphainactiveoverride") {
PWINDOW->m_sWindowData.alphaInactive = PWINDOW->m_sWindowData.alphaInactive =
CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alphaInactive.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL)}, PRIORITY_SET_PROP); CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alphaInactive.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL).value_or(0)}, PRIORITY_SET_PROP);
} else if (PROP == "alphafullscreenoverride") { } else if (PROP == "alphafullscreenoverride") {
PWINDOW->m_sWindowData.alphaFullscreen = PWINDOW->m_sWindowData.alphaFullscreen =
CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alphaFullscreen.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL)}, PRIORITY_SET_PROP); CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alphaFullscreen.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL).value_or(0)}, PRIORITY_SET_PROP);
} else if (PROP == "activebordercolor" || PROP == "inactivebordercolor") { } else if (PROP == "activebordercolor" || PROP == "inactivebordercolor") {
CGradientValueData colorData = {}; CGradientValueData colorData = {};
if (vars.size() > 4) { if (vars.size() > 4) {
@ -2998,7 +2998,7 @@ SDispatchResult CKeybindManager::setProp(std::string args) {
else if (VAL == "unset") else if (VAL == "unset")
pWindowDataElement->unset(PRIORITY_SET_PROP); pWindowDataElement->unset(PRIORITY_SET_PROP);
else else
*pWindowDataElement = CWindowOverridableVar((bool)configStringToInt(VAL), PRIORITY_SET_PROP); *pWindowDataElement = CWindowOverridableVar((bool)configStringToInt(VAL).value_or(0), PRIORITY_SET_PROP);
} else if (auto search = g_pConfigManager->miWindowProperties.find(PROP); search != g_pConfigManager->miWindowProperties.end()) { } else if (auto search = g_pConfigManager->miWindowProperties.find(PROP); search != g_pConfigManager->miWindowProperties.end()) {
if (VAL == "unset") if (VAL == "unset")
search->second(PWINDOW)->unset(PRIORITY_SET_PROP); search->second(PWINDOW)->unset(PRIORITY_SET_PROP);