mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 18:00:06 +00:00 
			
		
		
		
	Make sure unordered map references aren't invalidated by reserving sufficient space
This commit is contained in:
		
							parent
							
								
									26a22d4e84
								
							
						
					
					
						commit
						8f4325f61a
					
				
					 7 changed files with 39 additions and 4 deletions
				
			
		|  | @ -57,7 +57,10 @@ public: | |||
|                    config::CountyDatabase::GetCountyName(value) != value; | ||||
|          }); | ||||
| 
 | ||||
|       for (auto& phenomenon : types::GetAlertAudioPhenomena()) | ||||
|       auto& alertAudioPhenomena = types::GetAlertAudioPhenomena(); | ||||
|       alertEnabled_.reserve(alertAudioPhenomena.size() + 1); | ||||
| 
 | ||||
|       for (auto& phenomenon : alertAudioPhenomena) | ||||
|       { | ||||
|          std::string phenomenonCode = awips::GetPhenomenonCode(phenomenon); | ||||
|          std::string name           = fmt::format("{}_enabled", phenomenonCode); | ||||
|  |  | |||
|  | @ -50,6 +50,8 @@ class HotkeySettings::Impl | |||
| public: | ||||
|    explicit Impl() | ||||
|    { | ||||
|       hotkey_.reserve(types::HotkeyIterator().count() + 1); | ||||
| 
 | ||||
|       for (const auto& hotkey : types::HotkeyIterator()) | ||||
|       { | ||||
|          const std::string& name = types::GetHotkeyShortName(hotkey); | ||||
|  |  | |||
|  | @ -78,6 +78,8 @@ class PaletteSettings::Impl | |||
| public: | ||||
|    explicit Impl() | ||||
|    { | ||||
|       palette_.reserve(kPaletteKeys_.size()); | ||||
| 
 | ||||
|       for (const auto& name : kPaletteKeys_) | ||||
|       { | ||||
|          const std::string& defaultValue = kDefaultPalettes_.at(name); | ||||
|  | @ -92,6 +94,9 @@ public: | |||
|          variables_.push_back(&settingsVariable); | ||||
|       }; | ||||
| 
 | ||||
|       activeAlertColor_.reserve(kAlertColors_.size()); | ||||
|       inactiveAlertColor_.reserve(kAlertColors_.size()); | ||||
| 
 | ||||
|       for (auto& alert : kAlertColors_) | ||||
|       { | ||||
|          std::string phenomenonCode = awips::GetPhenomenonCode(alert.first); | ||||
|  |  | |||
|  | @ -122,6 +122,8 @@ TextSettings& TextSettings::operator=(TextSettings&&) noexcept = default; | |||
| 
 | ||||
| void TextSettings::Impl::InitializeFontVariables() | ||||
| { | ||||
|    fontData_.reserve(types::FontCategoryIterator().count()); | ||||
| 
 | ||||
|    for (auto fontCategory : types::FontCategoryIterator()) | ||||
|    { | ||||
|       auto  result = fontData_.emplace(fontCategory, FontData {}); | ||||
|  |  | |||
|  | @ -46,6 +46,8 @@ public: | |||
| 
 | ||||
|       int row = 0; | ||||
| 
 | ||||
|       hotkeys_.reserve(types::HotkeyIterator().count()); | ||||
| 
 | ||||
|       for (types::Hotkey hotkey : types::HotkeyIterator()) | ||||
|       { | ||||
|          const std::string& labelText = types::GetHotkeyLongName(hotkey); | ||||
|  |  | |||
|  | @ -658,6 +658,8 @@ void SettingsDialogImpl::SetupPalettesColorTablesTab() | |||
|    QGridLayout* colorTableLayout = | ||||
|       reinterpret_cast<QGridLayout*>(self_->ui->colorTableContents->layout()); | ||||
| 
 | ||||
|    colorTables_.reserve(kColorTableTypes_.size()); | ||||
| 
 | ||||
|    int colorTableRow = 0; | ||||
|    for (auto& colorTableType : kColorTableTypes_) | ||||
|    { | ||||
|  | @ -764,8 +766,13 @@ void SettingsDialogImpl::SetupPalettesAlertsTab() | |||
|    alertsLayout->addWidget(activeLabel, 0, 1, 1, 4); | ||||
|    alertsLayout->addWidget(inactiveLabel, 0, 5, 1, 4); | ||||
| 
 | ||||
|    auto& alertPhenomena = settings::PaletteSettings::alert_phenomena(); | ||||
| 
 | ||||
|    activeAlertColors_.reserve(alertPhenomena.size()); | ||||
|    inactiveAlertColors_.reserve(alertPhenomena.size()); | ||||
| 
 | ||||
|    int alertsRow = 1; | ||||
|    for (auto& phenomenon : settings::PaletteSettings::alert_phenomena()) | ||||
|    for (auto& phenomenon : alertPhenomena) | ||||
|    { | ||||
|       QFrame* activeFrame   = new QFrame(self_); | ||||
|       QFrame* inactiveFrame = new QFrame(self_); | ||||
|  | @ -963,10 +970,13 @@ void SettingsDialogImpl::SetupAudioTab() | |||
|    alertAudioLongitude_.SetResetButton( | ||||
|       self_->ui->resetAlertAudioLongitudeButton); | ||||
| 
 | ||||
|    auto alertAudioLayout = | ||||
|    auto& alertAudioPhenomena = types::GetAlertAudioPhenomena(); | ||||
|    auto  alertAudioLayout = | ||||
|       static_cast<QGridLayout*>(self_->ui->alertAudioGroupBox->layout()); | ||||
| 
 | ||||
|    for (const auto& phenomenon : types::GetAlertAudioPhenomena()) | ||||
|    alertAudioEnabled_.reserve(alertAudioPhenomena.size()); | ||||
| 
 | ||||
|    for (const auto& phenomenon : alertAudioPhenomena) | ||||
|    { | ||||
|       QCheckBox* alertAudioCheckbox = new QCheckBox(self_); | ||||
|       alertAudioCheckbox->setText( | ||||
|  | @ -1062,6 +1072,12 @@ void SettingsDialogImpl::SetupTextTab() | |||
|    settings::TextSettings& textSettings = settings::TextSettings::Instance(); | ||||
| 
 | ||||
|    self_->ui->fontListView->setModel(fontCategoryModel_); | ||||
| 
 | ||||
|    const auto fontCategoryCount = types::FontCategoryIterator().count(); | ||||
|    fontFamilies_.reserve(fontCategoryCount); | ||||
|    fontStyles_.reserve(fontCategoryCount); | ||||
|    fontPointSizes_.reserve(fontCategoryCount); | ||||
| 
 | ||||
|    for (const auto& fontCategory : types::FontCategoryIterator()) | ||||
|    { | ||||
|       // Add font category to list view
 | ||||
|  |  | |||
|  | @ -28,6 +28,11 @@ public: | |||
|       static const Iterator endIterator = ++Iterator(endValue); | ||||
|       return endIterator; | ||||
|    } | ||||
|    std::size_t count() | ||||
|    { | ||||
|       return static_cast<value_t>(endValue) - static_cast<value_t>(beginValue) + | ||||
|              1; | ||||
|    } | ||||
|    bool operator!=(const Iterator& i) { return value_ != i.value_; } | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat