fix: guard against divide by 0 in effects (#68)

This commit is contained in:
Sewer. 2025-03-29 18:09:29 +00:00 committed by GitHub
commit 2e7ea0224d
Failed to generate hash of commit
4 changed files with 6 additions and 4 deletions

View file

@ -15,7 +15,7 @@ SModeResult CModeStretch::update(Vector2D pos) {
auto limit = g_pShapeRuleHandler->getIntOr(CONFIG_STRETCH_LIMIT, **PLIMIT);
// create samples array
int max = g_pHyprRenderer->m_pMostHzMonitor->refreshRate / 10; // 100ms worth of history
int max = std::max(1, (int)(g_pHyprRenderer->m_pMostHzMonitor->refreshRate / 10)); // 100ms worth of history, avoiding divide by 0
samples.resize(max, pos);
// capture current sample

View file

@ -15,7 +15,7 @@ SModeResult CModeTilt::update(Vector2D pos) {
auto limit = g_pShapeRuleHandler->getIntOr(CONFIG_TILT_LIMIT, **PLIMIT);
// create samples array
int max = g_pHyprRenderer->m_pMostHzMonitor->refreshRate / 10; // 100ms worth of history
int max = std::max(1, (int)(g_pHyprRenderer->m_pMostHzMonitor->refreshRate / 10)); // 100ms worth of history, avoiding divide by 0
samples.resize(max, pos);
// capture current sample