From: "Lubomir I. Ivanov" <neolit...@gmail.com>

RulerNodeItem2::recalculate() does something which is
apparently not a good idea in combination with
RulerNodeItem2::mouseMoveEvent().

Each time the mouse moves, setPos() is called. Then in
recalculate() the x() value is checked and if less than 0
it's changed to x = 0 (setPos(0, y());).

This last call (setPos(0, y());)
however does not work and the value remains less than zero
leaving one of the ruler points outside of the graph.

To solve the issue we add a silly explicit check if x() < 0
before calling setPos() in RulerNodeItem2::mouseMoveEvent().

The 'x() > timeAxis->posAtValue(data->sec)' strangely works
on the other hand.

Signed-off-by: Lubomir I. Ivanov <neolit...@gmail.com>
---

This looks like non-sense but you can observe it yourself
with some qDebug() calls. The order of calls does not follow
what should happen. I'm guessing concurency or something else
at play?
---
 qt-ui/profile/ruleritem.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp
index 0bf97f9..c6cab22 100644
--- a/qt-ui/profile/ruleritem.cpp
+++ b/qt-ui/profile/ruleritem.cpp
@@ -61,7 +61,9 @@ void RulerNodeItem2::recalculate()
 
 void RulerNodeItem2::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
 {
-       setPos(event->scenePos());
+       qreal x = event->scenePos().x();
+       if (x < 0.0) x = 0.0;
+       setPos(x, event->scenePos().y());
        recalculate();
        ruler->recalculate();
 }
-- 
1.7.11.msysgit.0

_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to