Skip to content

Commit d352958

Browse files
committed
Saving settings only once when needed
1 parent 953ca11 commit d352958

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/fheroes2/dialog/dialog_selectfile.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ namespace
318318

319319
Settings & settings = Settings::Get();
320320
const bool isEvilInterface = settings.isEvilInterfaceEnabled();
321+
const SaveFileSortingMethod fileSortingMethod = settings.GetSaveFileSortingMethod();
321322

322323
int32_t scrollbarOffsetX = dialogArea.x + dialogArea.width - 35;
323324
background.renderScrollbarBackground( { scrollbarOffsetX, listRoi.y, listRoi.width, listRoi.height }, isEvilInterface );
@@ -432,7 +433,7 @@ namespace
432433
}
433434

434435
if ( le.MouseClickLeft( buttonCancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) {
435-
return {};
436+
break;
436437
}
437438

438439
const int listId = listbox.getCurrentId();
@@ -486,7 +487,6 @@ namespace
486487
const int currentId = listbox.getCurrentId();
487488

488489
settings.changeSaveFileSortingMethod();
489-
settings.Save( Settings::configFileName );
490490
sortMapInfos( lists );
491491
listUpdated = true;
492492

@@ -622,6 +622,12 @@ namespace
622622
}
623623
}
624624

625+
const SaveFileSortingMethod lastFileSortingMethod = settings.GetSaveFileSortingMethod();
626+
627+
if ( lastFileSortingMethod != fileSortingMethod ) {
628+
settings.Save( Settings::configFileName );
629+
}
630+
625631
return result;
626632
}
627633
}

0 commit comments

Comments
 (0)