From c06a4aa87e09b81a3447f0e1620e233ddc141257 Mon Sep 17 00:00:00 2001 From: AshBastian Date: Tue, 7 Jan 2020 16:03:54 +0100 Subject: [PATCH] Absturz behoben Bei Mausraddrehen kam es zu Absturz, wenn Tool nullptr, weil Zugriff auf Tool --- src/Layer/PaintingArea.cpp | 12 +++++++----- src/Tool/IntelliToolPolygon.cpp | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 4bf1c77..638fe99 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -277,11 +277,13 @@ void PaintingArea::mouseReleaseEvent(QMouseEvent*event){ } void PaintingArea::wheelEvent(QWheelEvent*event){ - QPoint numDegrees = event->angleDelta() / 8; - if(!numDegrees.isNull()) { - QPoint numSteps = numDegrees / 15; - Tool->onWheelScrolled(numSteps.y()* -1); - } + if(this->Tool != nullptr){ + QPoint numDegrees = event->angleDelta() / 8; + if(!numDegrees.isNull()) { + QPoint numSteps = numDegrees / 15; + Tool->onWheelScrolled(numSteps.y()* -1); + } + } } // QPainter provides functions to draw on the widget diff --git a/src/Tool/IntelliToolPolygon.cpp b/src/Tool/IntelliToolPolygon.cpp index da61406..a4a6685 100644 --- a/src/Tool/IntelliToolPolygon.cpp +++ b/src/Tool/IntelliToolPolygon.cpp @@ -5,7 +5,7 @@ #include IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker) - : IntelliTool(Area, colorPicker){ + : IntelliTool(Area, colorPicker){ this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 255,0,255,1); lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",5,1,10,1); isPointNearStart = false; @@ -107,7 +107,7 @@ bool IntelliToolPolygon::isNearStart(int x, int y, QPoint Startpoint){ bool isNear = false; int StartX = Startpoint.x(); int StartY = Startpoint.y(); - int valueToNear = 10; + int valueToNear = 5; for(int i = StartX - valueToNear; i < StartX + valueToNear; i++) { for(int j = StartY - valueToNear; j < StartY + valueToNear; j++) {