Hello Robert,

The attached patch tries to resolve the looping issue with the
"entered" branch of yours. I am assuming that you were referring to
this in irc today morning, I was sleeping then and missed it.

I need to still figure out the segmentation fault issue occurs after
closing or making another edit after it displays waypoints. I will
send another patch soon, where I have been working in a different way
to this problem.

Thank you,
Lakshman
From 84ee40f951c3eca00f161c1e48287bfb5fc97c86 Mon Sep 17 00:00:00 2001
From: Lakshman Anumolu <[email protected]>
Date: Sun, 30 Mar 2014 11:14:40 -0500
Subject: [PATCH] Partially resolves infinite loop

This patch is build on "entered" and partially resolves infinite loop
issue. Reason for this occurance is because everytime a row is inserted,
a signal is emitted to call "pointInserted" function which calls
"drawProfile". This never stops, since addStop is called in drawProfile.

A new variable "emitPointEdit" addresses this issue. However this didnot
make the code perfect yet. Somehow a new edit in the plan is resulting
in segmentation fault, which needs to be resolved.

Signed-off-by: Lakshman Anumolu <[email protected]>
---
 qt-ui/diveplanner.cpp | 23 ++++++++++++++---------
 qt-ui/diveplanner.h   |  1 +
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 2996f09..f7bf515 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -55,6 +55,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget *parent) : QGraphicsView(parent
 	timeHandler(new ExpanderGraphics()),
 	minMinutes(TIME_INITIAL_MAX),
 	minDepth(M_OR_FT(40, 120)),
+	emitPointEdit(true),
 	dpMaxTime(0)
 {
 	setBackgroundBrush(profile_color[BACKGROUND].at(0));
@@ -173,16 +174,18 @@ void DivePlannerGraphics::settingsChanged()
 
 void DivePlannerGraphics::pointInserted(const QModelIndex &parent, int start, int end)
 {
-	DiveHandler *item = new DiveHandler();
-	scene()->addItem(item);
-	handles << item;
+	if (emitPointEdit) {
+		DiveHandler *item = new DiveHandler();
+		scene()->addItem(item);
+		handles << item;
 
-	QGraphicsSimpleTextItem *gasChooseBtn = new QGraphicsSimpleTextItem();
-	scene()->addItem(gasChooseBtn);
-	gasChooseBtn->setZValue(10);
-	gasChooseBtn->setFlag(QGraphicsItem::ItemIgnoresTransformations);
-	gases << gasChooseBtn;
-	drawProfile();
+		QGraphicsSimpleTextItem *gasChooseBtn = new QGraphicsSimpleTextItem();
+		scene()->addItem(gasChooseBtn);
+		gasChooseBtn->setZValue(10);
+		gasChooseBtn->setFlag(QGraphicsItem::ItemIgnoresTransformations);
+		gases << gasChooseBtn;
+		drawProfile();
+	}
 }
 
 void DivePlannerGraphics::keyDownAction()
@@ -523,7 +526,9 @@ void DivePlannerGraphics::drawProfile()
 			lines << item;
 			if (dp->depth){
 				qDebug() << "Time: " << dp->time / 60 << " depth: " << dp->depth / 1000;
+				emitPointEdit = false;
 				plannerModel->addStop(dp->depth, dp->time, dp->o2, dp->he, 0, false);
+				emitPointEdit = true;
 			}
 		}
 		lastx = xpos;
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index 1393d9f..189112f 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -176,6 +176,7 @@ class DivePlannerGraphics : public QGraphicsView {
 	Q_OBJECT
 public:
 	DivePlannerGraphics(QWidget *parent = 0);
+	bool emitPointEdit;
 
 protected:
 	virtual void mouseDoubleClickEvent(QMouseEvent *event);
-- 
1.8.3.2

_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to