[PATCH] maintab.cpp: fix editing dive profiles from trips

Lubomir I. Ivanov neolit123 at gmail.com
Wed Mar 25 17:41:04 PDT 2015


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

Once a manually added dive is part of a trip and this trip
is edited, applying the modifications leaves the dive profile
in edit mode (e.g. points can be dragged and gas swapping can
be applied).

The issue can be viewed from another angle. Why enable
profile edits of a manually added dive which is in a trip,
while the trip is being edited in the first place?

If there are more than one manually added dives in said trip
we are enabled to edit one of the dive but probably
it's not intended to modify all manually added dives after the
changes are applied for the trip.

This patch disables the functionality in question and it also...

Fixes #864

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
---
 qt-ui/maintab.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index abf1382..998e645 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -280,11 +280,15 @@ void MainTab::updateTextLabels(bool showUnits)
 
 void MainTab::enableEdition(EditMode newEditMode)
 {
+	const bool isTripEdit = MainWindow::instance() &&
+		MainWindow::instance()->dive_list()->selectedTrips().count() == 1;
+
 	if (((newEditMode == DIVE || newEditMode == NONE) && current_dive == NULL) || editMode != NONE)
 		return;
 	modified = false;
 	copyPaste = false;
 	if ((newEditMode == DIVE || newEditMode == NONE) &&
+	    !isTripEdit &&
 	    current_dive->dc.model &&
 	    strcmp(current_dive->dc.model, "manually added dive") == 0) {
 		// editCurrentDive will call enableEdition with newEditMode == MANUALLY_ADDED_DIVE
@@ -295,7 +299,6 @@ void MainTab::enableEdition(EditMode newEditMode)
 		// FIXME : can we get rid of this recursive crap?
 
 
-
 		MainWindow::instance()->editCurrentDive();
 		return;
 	}
@@ -306,7 +309,7 @@ void MainTab::enableEdition(EditMode newEditMode)
 	if (amount_selected == 1 && newEditMode != ADD)
 		MainWindow::instance()->globe()->prepareForGetDiveCoordinates();
 
-	if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) {
+	if (isTripEdit) {
 		// we are editing trip location and notes
 		displayMessage(tr("This trip is being edited."));
 		memset(&displayedTrip, 0, sizeof(displayedTrip));
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list