On Thu, Feb 4, 2016 at 8:44 PM, Dirk Hohndel <[email protected]> wrote:
> On Thu, Feb 04, 2016 at 07:49:27PM +0200, Miika Turkia wrote:
>> Should we be merging dives with zero depth? I do not see any real
>> reason to have the check in place, but it would not be the first time
>> I am missing something.
>
> SACRILEGE! You are attempting to change code that was written by the
> MASTER himself in 2012! That code is by definition perfect and inmutable!

I know :D

> /me snaps out of it...
>
> Hmm, I think the rationale was that having a duration or depth of ZERO is
> special in that it means there is no dive. And "no dive" and "a very short
> dive" (or a very shallow dive - this is used both for duration and
> maxdepth), are actually quite different.
>
> So in THAT sense there might be some value here...
>
> BUT:
>
>> Of course, it does not really make sense to have dives with zero depth,
>> but as the bug report is from importing, it really makes even less sense
>> to have a 0 depth dive multiple times in the log.
>
> Well, how about a different fix that keeps the original intent (which I am
> guessing was put there because we found dives where this mattered)?
>
> Add a check for BOTH being 0 before the first check. Because if they are
> BOTH zero, they are the same again, right?

yeah, they are the same, even though not dives in my book :D

miika
From 150db5adf4b47ea7fa57615ceb90bcf4c66fae97 Mon Sep 17 00:00:00 2001
From: Miika Turkia <[email protected]>
Date: Thu, 4 Feb 2016 21:16:04 +0200
Subject: [PATCH] Allow merging of dives with zero depth/duration

Fixes #1003

Signed-off-by: Miika Turkia <[email protected]>
---
 subsurface-core/dive.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/subsurface-core/dive.c b/subsurface-core/dive.c
index 9af6379..fd0d259 100644
--- a/subsurface-core/dive.c
+++ b/subsurface-core/dive.c
@@ -2162,6 +2162,9 @@ static int find_sample_offset(struct divecomputer *a, struct divecomputer *b)
  */
 static int similar(unsigned long a, unsigned long b, unsigned long expected)
 {
+	if (!a && !b)
+		return 1;
+
 	if (a && b) {
 		unsigned long min, max, diff;
 
-- 
2.5.0

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

Reply via email to