Settings saved before a settings file exists overwrite each other
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 88/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- desktop-dev
Direzione di ricerca
Ispeziona os_config_write_string e os_config_write_uint in osregistry.cpp, poi traccia dove vengono inizializzati e letti Osreg_profile e Mod_settings_profile. La correzione dovrebbe aggiornare la globale rilevante dopo la scrittura, e i test o la riproduzione dovrebbero confermare che più impostazioni persistono invece di sostituirsi a vicenda. Controlla anche il percorso di perdita intorno a profile_update.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
When there's no settings file yet, every setting the game saves replaces the whole file with just that one setting. On a fresh install without fs2_open.ini, changing several options in the in-game options menu and saving keeps only the last one written, and the pilot name, PXO login and similar settings overwrite each other the same way. Once a file exists, from the next launch on, saving should work normally, since the profile is read from it at startup.
In os_config_write_string and os_config_write_uint (osregistry.cpp), the profile is copied into a local, updated and saved, but the result is never stored back into Osreg_profile or Mod_settings_profile. When those start out null (no file at startup), each write builds a fresh one-entry profile, saves it over the file and leaks it. From reading the code (not tested on Windows): on Windows the main settings fall back to the registry when there's no file, so only the in-game options' mod settings file would be affected there; on Linux and macOS both are.
Steps to reproduce
- Start FSO (master at 12a36dc1a, Linux) with an empty preferences folder: no
fs2_open.iniand no mod settings file. - Create a pilot and go to the main hall.
- In the in-game options, change three settings (I used Lightshafts, Use Mouse and 3D Shockwaves) and save.
- Look at
fs2_open.iniand the mod'sdata/<mod>_settings.ini.
Also reproducible with three settings written one after another (pilot select writes LastPlayer, then setting the PXO login and squad from Lua): after each write the file holds only that one key.
Expected vs. actual behavior
Expected: the settings file contains every setting saved during the session.
Actual: after saving three in-game options, the mod settings file contained one unrelated entry ([Graphics] SmallDebris=4) and none of the three changes. fs2_open.ini likewise ends up holding only the last key written. AddressSanitizer also reports the discarded profiles as leaks (profile_update, osregistry.cpp:720 and 776).
Proposed fixes
Ranked by simplicity, then maintainability, then thoroughness.
- In both write functions, store the updated profile back into the global it came from (
Osreg_profileorMod_settings_profile). A couple of lines, and it fixes the overwriting and the leak. - Move the "pick the profile, update it, store it back, save it" steps into one helper both write functions call, so the uint and string paths can't drift apart again.
- Create empty profiles at startup when the files don't exist, so neither global is ever null, and drop the null-dependent branches.
- Lingua principale
- C++
- Stelle
- 488
- Fork
- 184
- Merge medio
- 2g 9h
- PR unite (30g)
- 43
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di scp-fs2open/fs2open.github.com
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
scp-fs2open/fs2open.github.com#7901 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
scp-fs2open/fs2open.github.com#7890 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
scp-fs2open/fs2open.github.com#7900 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
scp-fs2open/fs2open.github.com#7891 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
scp-fs2open/fs2open.github.com#7889 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di scp-fs2open/fs2open.github.com
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
(S1 - Need confirmation)
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
CleverRaven/Cataclysm-DDA#89182 ·
I maintainer di solito rispondono entro 1 giorno
-
ai_p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
ClickHouse/ClickHouse#126833 ·
I maintainer di solito rispondono entro 1 giorno
-
clang:static analyzer
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
llvm/llvm-project#233598 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100