From f9c3b858ae9a161f5e1ea431ec7270fa185542cd Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Mon, 18 Dec 2017 19:22:54 +0100 Subject: [PATCH] Fix segfault in generation of button positions --- src/capture/widget/buttonhandler.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/capture/widget/buttonhandler.cpp b/src/capture/widget/buttonhandler.cpp index 17ed5a18..44690896 100644 --- a/src/capture/widget/buttonhandler.cpp +++ b/src/capture/widget/buttonhandler.cpp @@ -252,13 +252,13 @@ void ButtonHandler::updatePosition(const QRect &selection, if (elemsAtCorners > 1 && !horizontalBlocked && !oneHorizontalBlocked) { addCounter += 2; - } else if ((elemsAtCorners == 1 && - (!horizontalBlocked || oneHorizontalBlocked)) || - (elemsAtCorners > 1 && oneHorizontalBlocked)) { + } else if ((elemsAtCorners >= 1 && + (!horizontalBlocked || oneHorizontalBlocked))){ addCounter += 1; } QPoint center = QPoint(baseArea.center().x(), baseArea.top() - (SEPARATION+baseHeight)); + addCounter = qBound(0, addCounter, vecLength - elemIndicator); if (addCounter == 1 + buttonsPerRow) { if (blockedLeft) { center.setX(center.x() + (baseWidth+SEPARATION)/2); @@ -281,9 +281,6 @@ void ButtonHandler::updatePosition(const QRect &selection, (vecLength - elemIndicator < buttonsPerCol) ? vecLength - elemIndicator : buttonsPerCol; - if (vecLength - elemIndicator < buttonsPerCol) { - addCounter = vecLength - elemIndicator; - } QPoint center = QPoint(baseArea.left() - (SEPARATION + baseWidth), baseArea.center().y()); QVector positions = verticalPoints(center, addCounter, true);