mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Undo: Make PasteState cylinders list dynamically allocated
Instead of using a sub-array, use a std::vector<>. This is a necessary step in removing the MAX_CYLINDERS restriction. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									16bdbc54b9
								
							
						
					
					
						commit
						77e5dbac73
					
				
					 2 changed files with 7 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -687,7 +687,8 @@ static void swapCandQString(QString &q, char *&c)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
PasteState::PasteState(dive *dIn, const dive *data, dive_components what) : d(dIn),
 | 
			
		||||
	tags(nullptr)
 | 
			
		||||
	tags(nullptr),
 | 
			
		||||
	cylinders(MAX_CYLINDERS)
 | 
			
		||||
{
 | 
			
		||||
	memset(&cylinders[0], 0, sizeof(cylinders));
 | 
			
		||||
	memset(&weightsystems, 0, sizeof(weightsystems));
 | 
			
		||||
| 
						 | 
				
			
			@ -742,8 +743,10 @@ void PasteState::swap(dive_components what)
 | 
			
		|||
		std::swap(divesite, d->dive_site);
 | 
			
		||||
	if (what.tags)
 | 
			
		||||
		std::swap(tags, d->tag_list);
 | 
			
		||||
	if (what.cylinders)
 | 
			
		||||
		std::swap(cylinders, d->cylinder);
 | 
			
		||||
	if (what.cylinders) {
 | 
			
		||||
		for (int i = 0; i < MAX_CYLINDERS; ++i)
 | 
			
		||||
			std::swap(cylinders[i], d->cylinder[i]);
 | 
			
		||||
	}
 | 
			
		||||
	if (what.weights)
 | 
			
		||||
		std::swap(weightsystems, d->weightsystems);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -246,7 +246,7 @@ struct PasteState {
 | 
			
		|||
	int rating;
 | 
			
		||||
	int visibility;
 | 
			
		||||
	tag_entry *tags;
 | 
			
		||||
	cylinder_t cylinders[MAX_CYLINDERS];
 | 
			
		||||
	std::vector<cylinder_t> cylinders;
 | 
			
		||||
	struct weightsystem_table weightsystems;
 | 
			
		||||
 | 
			
		||||
	PasteState(dive *d, const dive *data, dive_components what); // Read data from dive data for dive d
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue