mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	planner: fix gas selection
The lambda that created the list of gases took a copy not a reference of the planned dive. Of course, that never had its gases updated. Ultimately this would crash, because this sent an index of "-1" on change. Fix by 1) Using a reference to the dive, not the copy 2) Catch an invalid "-1" index (by Michael Keller <github@ike.ch>) Fixes #4188 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									306dad575c
								
							
						
					
					
						commit
						d061a54e3d
					
				
					 3 changed files with 4 additions and 5 deletions
				
			
		|  | @ -371,8 +371,8 @@ void AirTypesDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, | |||
| } | ||||
| 
 | ||||
| AirTypesDelegate::AirTypesDelegate(const dive &d, QObject *parent) : | ||||
| 	ComboBoxDelegate([d] (QWidget *parent) { return new GasSelectionModel(d, parent); }, | ||||
| 			      parent, false) | ||||
| 	ComboBoxDelegate([&d] (QWidget *parent) { return new GasSelectionModel(d, parent); }, | ||||
| 			       parent, false) | ||||
| { | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -614,9 +614,8 @@ void CylindersModel::updateNumRows() | |||
| // Only invoked from planner.
 | ||||
| void CylindersModel::moveAtFirst(int cylid) | ||||
| { | ||||
| 	if (!d) | ||||
| 	if (!d || cylid <= 0 || cylid >= d->cylinders.nr) | ||||
| 		return; | ||||
| 
 | ||||
| 	cylinder_t temp_cyl; | ||||
| 
 | ||||
| 	beginMoveRows(QModelIndex(), cylid, cylid, QModelIndex(), 0); | ||||
|  |  | |||
|  | @ -381,7 +381,7 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v | |||
| 			if (value.toInt() >= 0) | ||||
| 				p.cylinderid = value.toInt(); | ||||
| 			/* Did we change the start (dp 0) cylinder to another cylinderid than 0? */ | ||||
| 			if (value.toInt() != 0 && index.row() == 0) | ||||
| 			if (value.toInt() > 0 && index.row() == 0) | ||||
| 				cylinders.moveAtFirst(value.toInt()); | ||||
| 			cylinders.updateTrashIcon(); | ||||
| 			break; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue