mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Ensure correct length of the created dive
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									b60b7c108e
								
							
						
					
					
						commit
						f1c46927ef
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		|  | @ -94,6 +94,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d) | ||||||
| 	// average samples so we end up with a total of 100 samples.
 | 	// average samples so we end up with a total of 100 samples.
 | ||||||
| 	int plansamples = dc->samples <= 100 ? dc->samples : 100; | 	int plansamples = dc->samples <= 100 ? dc->samples : 100; | ||||||
| 	int j = 0; | 	int j = 0; | ||||||
|  | 	int cylinderid; | ||||||
| 	for (int i = 0; i < plansamples - 1; i++) { | 	for (int i = 0; i < plansamples - 1; i++) { | ||||||
| 		while (j * plansamples <= i * dc->samples) { | 		while (j * plansamples <= i * dc->samples) { | ||||||
| 			const sample &s = dc->sample[j]; | 			const sample &s = dc->sample[j]; | ||||||
|  | @ -105,7 +106,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d) | ||||||
| 			j++; | 			j++; | ||||||
| 		} | 		} | ||||||
| 		if (samplecount) { | 		if (samplecount) { | ||||||
| 			int cylinderid = get_cylinderid_at_time(d, dc, lasttime); | 			cylinderid = get_cylinderid_at_time(d, dc, lasttime); | ||||||
| 			if (newtime.seconds - lastrecordedtime.seconds > 10) { | 			if (newtime.seconds - lastrecordedtime.seconds > 10) { | ||||||
| 				addStop(depthsum / samplecount, newtime.seconds, cylinderid, 0, true); | 				addStop(depthsum / samplecount, newtime.seconds, cylinderid, 0, true); | ||||||
| 				lastrecordedtime = newtime; | 				lastrecordedtime = newtime; | ||||||
|  | @ -115,6 +116,8 @@ void DivePlannerPointsModel::loadFromDive(dive *d) | ||||||
| 			samplecount = 0; | 			samplecount = 0; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | 	// make sure we get the last point right so the duration is correct
 | ||||||
|  | 	addStop(0, d->dc.duration.seconds,cylinderid, 0, true); | ||||||
| 	recalc = oldRec; | 	recalc = oldRec; | ||||||
| 	emitDataChanged(); | 	emitDataChanged(); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue