[PATCH 4/5] Remove 'when_from_file' field from dive trip

Linus Torvalds torvalds at linux-foundation.org
Sun Nov 25 20:30:22 PST 2012


From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Sun, 25 Nov 2012 19:09:04 -0800
Subject: [PATCH 4/5] Remove 'when_from_file' field from dive trip

It had become a write-only field (apart from some now useless debugging)
when simplifying the remove_autogen_trips() function.

So remove it.

Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---

Small cleanup. The use of 'when_from_file' was always broken, considering 
that when you did undo the autogenerated trips, restoring the original 
date was *wrong* anyway. Think "you autogenerated some, but edited others 
manually".

 dive.h      |  1 -
 divelist.c  | 13 +------------
 parse-xml.c |  4 +---
 3 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/dive.h b/dive.h
index 43b7b8d591b0..18a48c94edfa 100644
--- a/dive.h
+++ b/dive.h
@@ -275,7 +275,6 @@ extern const char *tripflag_names[NUM_TRIPFLAGS];
 typedef struct dive_trip {
 	tripflag_t tripflag;
 	timestamp_t when;
-	timestamp_t when_from_file;
 	char *location;
 	char *notes;
 	struct dive *dives;
diff --git a/divelist.c b/divelist.c
index 7174e9dfb111..8f9b3de40548 100644
--- a/divelist.c
+++ b/divelist.c
@@ -949,11 +949,6 @@ static void dump_trip_list(void)
 			++i, dive_trip->location,
 			tm.tm_year + 1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
 			dive_trip->nrdives, dive_trip);
-		if (dive_trip->when_from_file && dive_trip->when != dive_trip->when_from_file) {
-			utc_mkdate(dive_trip->when_from_file, &tm);
-			printf("originally on %04u-%02u-%02u %02u:%02u:%02u\n",	tm.tm_year + 1900,
-				tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
-		}
 		last_time = dive_trip->when;
 	}
 	printf("-----\n");
@@ -1609,7 +1604,6 @@ static void merge_dive_into_trip_above_cb(GtkWidget *menuitem, GtkTreePath *path
 		add_dive_to_trip(dive, prev_dive->divetrip);
 		/* we intentionally changed the dive_trip, so update the time
 		 * stamp that we fall back to when toggling autogroup */
-		dive->divetrip->when_from_file = dive->divetrip->when;
 		dive->tripflag = IN_TRIP;
 		free(move_dive_between_trips(&dive_iter, NULL, &trip_iter, NULL, TRUE));
 		prev_dive = dive;
@@ -1636,7 +1630,6 @@ static void turn_dive_into_trip(GtkTreePath *path)
 	char *location;
 	int idx;
 	struct dive *dive;
-	dive_trip_t *dive_trip;
 
 	/* this is a dive on the top level, insert trip AFTER it, populate its date / location, and
 	 * then move the dive below that trip */
@@ -1651,10 +1644,7 @@ static void turn_dive_into_trip(GtkTreePath *path)
 	treepath = gtk_tree_model_get_path(MODEL(dive_list), newiter);
 	gtk_tree_view_expand_to_path(GTK_TREE_VIEW(dive_list.tree_view), treepath);
 	dive = get_dive(idx);
-	/* this trip is intentionally created so it should be treated as if
-	 * it was read from a file */
-	dive_trip = create_and_hookup_trip_from_dive(dive);
-	dive_trip->when_from_file = dive_trip->when;
+	create_and_hookup_trip_from_dive(dive);
 	free(newiter);
 }
 
@@ -1702,7 +1692,6 @@ static void insert_trip_before(GtkTreePath *path)
 			break;
 	}
 	/* treat this divetrip as if it had been read from a file */
-	new_divetrip->when_from_file = new_divetrip->when;
 	treepath = gtk_tree_model_get_path(MODEL(dive_list), &newparent);
 	gtk_tree_view_expand_to_path(GTK_TREE_VIEW(dive_list.tree_view), treepath);
 #ifdef DEBUG_TRIP
diff --git a/parse-xml.c b/parse-xml.c
index 5f1dfed82692..1d08ca009165 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1201,10 +1201,8 @@ static void try_to_fill_trip(dive_trip_t **dive_trip_p, const char *name, char *
 
 	if (MATCH(".date", divedate, &dive_trip->when))
 		return;
-	if (MATCH(".time", divetime, &dive_trip->when)) {
-		dive_trip->when_from_file = dive_trip->when;
+	if (MATCH(".time", divetime, &dive_trip->when))
 		return;
-	}
 	if (MATCH(".location", utf8_string, &dive_trip->location))
 		return;
 	if (MATCH(".notes", utf8_string, &dive_trip->notes))
-- 
1.8.0.dirty



More information about the subsurface mailing list