mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Fix crash when moving divepoints rigorously
I have no idea how the index ends up outside the range, but at least this prevents a crash in this case. See #784 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									d34965135a
								
							
						
					
					
						commit
						6f795a0059
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		|  | @ -1003,6 +1003,12 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, gasmix *gas_in, | |||
| 
 | ||||
| void DivePlannerPointsModel::editStop(int row, divedatapoint newData) | ||||
| { | ||||
| 	/*
 | ||||
| 	 * When moving divepoints rigorously, we might end up with index | ||||
| 	 * out of range, thus returning the last one instead. | ||||
| 	 */ | ||||
| 	if (row >= divepoints.count()) | ||||
| 		return; | ||||
| 	divepoints[row] = newData; | ||||
| 	std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan); | ||||
| 	emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); | ||||
|  | @ -1015,6 +1021,12 @@ int DivePlannerPointsModel::size() | |||
| 
 | ||||
| divedatapoint DivePlannerPointsModel::at(int row) | ||||
| { | ||||
| 	/*
 | ||||
| 	 * When moving divepoints rigorously, we might end up with index | ||||
| 	 * out of range, thus returning the last one instead. | ||||
| 	 */ | ||||
| 	if (row >= divepoints.count()) | ||||
| 		return divepoints.at(divepoints.count() - 1); | ||||
| 	return divepoints.at(row); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue