mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Change tank editing behavior for multi dive edit
Previously we only applied the type of tank (description, volume, working pressure) to all selected dives where the tank description matched. With this patch we also copy the gas mix into all matching cylinders. Additionally this addresses the issue that we should have a separate copy of the cylinder description string for each dive. Fixes #754 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									54692fb814
								
							
						
					
					
						commit
						c9e7528370
					
				
					 1 changed files with 16 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -744,14 +744,26 @@ void MainTab::acceptChanges()
 | 
			
		|||
			MODIFY_SELECTED_DIVES(
 | 
			
		||||
				for (int i = 0; i < MAX_CYLINDERS; i++) {
 | 
			
		||||
					if (mydive != cd) {
 | 
			
		||||
						if (same_string(mydive->cylinder[i].type.description, cd->cylinder[i].type.description))
 | 
			
		||||
							// only copy the cylinder type, none of the other values
 | 
			
		||||
							mydive->cylinder[i].type = displayed_dive.cylinder[i].type;
 | 
			
		||||
						if (same_string(mydive->cylinder[i].type.description, cd->cylinder[i].type.description)) {
 | 
			
		||||
							// if we started out with the same cylinder description make sure that we have the same cylinder type
 | 
			
		||||
							// and copy the gasmix, but DON'T copy the start and end pressures (those are per dive after all)
 | 
			
		||||
							if (!same_string(mydive->cylinder[i].type.description, displayed_dive.cylinder[i].type.description)) {
 | 
			
		||||
								free((void*)mydive->cylinder[i].type.description);
 | 
			
		||||
								mydive->cylinder[i].type.description = copy_string(displayed_dive.cylinder[i].type.description);
 | 
			
		||||
							}
 | 
			
		||||
							mydive->cylinder[i].type.size = displayed_dive.cylinder[i].type.size;
 | 
			
		||||
							mydive->cylinder[i].type.workingpressure = displayed_dive.cylinder[i].type.workingpressure;
 | 
			
		||||
							mydive->cylinder[i].gasmix = displayed_dive.cylinder[i].gasmix;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			);
 | 
			
		||||
			for (int i = 0; i < MAX_CYLINDERS; i++)
 | 
			
		||||
			for (int i = 0; i < MAX_CYLINDERS; i++) {
 | 
			
		||||
				// copy the cylinder but make sure we have our own copy of the strings
 | 
			
		||||
				free((void*)cd->cylinder[i].type.description);
 | 
			
		||||
				cd->cylinder[i] = displayed_dive.cylinder[i];
 | 
			
		||||
				cd->cylinder[i].type.description = copy_string(displayed_dive.cylinder[i].type.description);
 | 
			
		||||
			}
 | 
			
		||||
			do_replot = true;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue