mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Small fixes to the model
Prevent a crash when no cylinder type description is set. Correctly calculate the cylinder volume. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									76903849de
								
							
						
					
					
						commit
						7bf07b890a
					
				
					 1 changed files with 5 additions and 4 deletions
				
			
		| 
						 | 
					@ -123,7 +123,7 @@ bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, in
 | 
				
			||||||
	case TYPE:
 | 
						case TYPE:
 | 
				
			||||||
		if (!value.isNull()) {
 | 
							if (!value.isNull()) {
 | 
				
			||||||
			char *text = value.toByteArray().data();
 | 
								char *text = value.toByteArray().data();
 | 
				
			||||||
			if (strcmp(cyl->type.description, text)) {
 | 
								if (!cyl->type.description || strcmp(cyl->type.description, text)) {
 | 
				
			||||||
				cyl->type.description = strdup(text);
 | 
									cyl->type.description = strdup(text);
 | 
				
			||||||
				mark_divelist_changed(TRUE);
 | 
									mark_divelist_changed(TRUE);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -431,9 +431,10 @@ QVariant TankInfoModel::data(const QModelIndex& index, int role) const
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int bar = ((info->psi) ? psi_to_bar(info->psi) : info->bar) * 1000 + 0.5;
 | 
						int bar = ((info->psi) ? psi_to_bar(info->psi) : info->bar) * 1000 + 0.5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (info->cuft) {
 | 
						if (info->cuft && info->psi) {
 | 
				
			||||||
		double airvolume = cuft_to_l(info->cuft) * 1000.0;
 | 
							pressure_t p;
 | 
				
			||||||
		ml = airvolume / bar_to_atm(bar) + 0.5;
 | 
							p.mbar = psi_to_mbar(info->psi);
 | 
				
			||||||
 | 
							ml = wet_volume(info->cuft, p);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (role == Qt::DisplayRole) {
 | 
						if (role == Qt::DisplayRole) {
 | 
				
			||||||
		switch(index.column()) {
 | 
							switch(index.column()) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue