Improve support of empty input data
This commit is contained in:
		
							parent
							
								
									e36fbbf3b0
								
							
						
					
					
						commit
						ff19f87b44
					
				@ -82,8 +82,7 @@ Substitutions SubstitutionsTable::substitutions() const
 | 
			
		||||
  Substitutions result;
 | 
			
		||||
  for (auto row = 0, end = rowCount(); row < end; ++row) {
 | 
			
		||||
    const auto pair = at(row);
 | 
			
		||||
    SOFT_ASSERT(!pair.first.isEmpty(), continue);
 | 
			
		||||
    if (pair.second.source.isEmpty())
 | 
			
		||||
    if (pair.first.isEmpty() || pair.second.source.isEmpty())
 | 
			
		||||
      continue;
 | 
			
		||||
    result.emplace(pair.first, pair.second);
 | 
			
		||||
  }
 | 
			
		||||
@ -124,6 +123,9 @@ std::pair<LanguageId, Substitution> SubstitutionsTable::at(int row) const
 | 
			
		||||
  auto combo = static_cast<QComboBox *>(cellWidget(row, int(E::Language)));
 | 
			
		||||
  SOFT_ASSERT(combo, return {});
 | 
			
		||||
 | 
			
		||||
  if (combo->currentText().isEmpty())
 | 
			
		||||
    return {};
 | 
			
		||||
 | 
			
		||||
  const auto langId = LanguageCodes::idForName(combo->currentText());
 | 
			
		||||
  SOFT_ASSERT(!langId.isEmpty(), return {});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -123,11 +123,16 @@ void Translator::updateSettings()
 | 
			
		||||
  }
 | 
			
		||||
  tabs_->blockSignals(false);
 | 
			
		||||
 | 
			
		||||
  if (settings_.translators.empty()) {
 | 
			
		||||
    manager_.fatalError(tr("No translators selected"));
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const auto loaded =
 | 
			
		||||
      loadScripts(settings_.translatorsDir, settings_.translators);
 | 
			
		||||
  if (loaded.empty()) {
 | 
			
		||||
    manager_.fatalError(
 | 
			
		||||
        tr("No translators loaded from %1 (named %2)")
 | 
			
		||||
        tr("No translators loaded from %1 (%2)")
 | 
			
		||||
            .arg(settings_.translatorsDir, settings_.translators.join(", ")));
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user