mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Desktop: support no-cylinders in dive information tab
The tab was crashing if there were no cylinders because 1) per_cylinder_mean_depth() would access non-existing cylinders. 2) TabDiveInformation::updateProfile() would access a non-existing mean. Fix both of these crash conditions by checking whether the dive actually has cylinders. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									fd23c3d908
								
							
						
					
					
						commit
						6a1e2cd8c2
					
				
					 2 changed files with 4 additions and 1 deletions
				
			
		|  | @ -753,6 +753,9 @@ void per_cylinder_mean_depth(const struct dive *dive, struct divecomputer *dc, i | |||
| 	bool *used_cylinders; | ||||
| 	int num_used_cylinders; | ||||
| 
 | ||||
| 	if (dive->cylinders.nr <= 0) | ||||
| 		return; | ||||
| 
 | ||||
| 	for (i = 0; i < dive->cylinders.nr; i++) | ||||
| 		mean[i] = duration[i] = 0; | ||||
| 	if (!dc) | ||||
|  |  | |||
|  | @ -82,7 +82,7 @@ void TabDiveInformation::updateProfile() | |||
| 	ui->diveTimeText->setText(get_dive_duration_string(current_dive->duration.seconds, tr("h"), tr("min"), tr("sec"), | ||||
| 			" ", current_dive->dc.divemode == FREEDIVE)); | ||||
| 
 | ||||
| 	ui->sacText->setText( mean[0] ? SACs : QString()); | ||||
| 	ui->sacText->setText(current_dive->cylinders.nr > 0 && mean[0] ? SACs : QString()); | ||||
| 
 | ||||
| 	if (current_dive->surface_pressure.mbar == 0) { | ||||
| 		ui->atmPressVal->clear();			// If no atm pressure for dive then clear text box
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue