MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / readSavedIdFromFile

Function readSavedIdFromFile

src/core/GpuSelector.cpp:178–196  ·  view source on GitHub ↗

Startup read: parse the persisted "Graphics" → "gpu" id straight from the settings XML. Constructing AppSettings::instance() this early would run its migrateSettingsPath() before setApplicationName(), computing the wrong AppConfigLocation path and permanently skipping the old→new migration for upgrading users. Reading the file by hand (like the UiScale bootstrap) avoids touching the singleton at

Source from the content-addressed store, hash-verified

176// upgrading users. Reading the file by hand (like the UiScale bootstrap) avoids
177// touching the singleton at all.
178QString readSavedIdFromFile()
179{
180 const QString fallback = QString::fromLatin1(GpuSelector::kAutoId);
181 QFile f(settingsFilePath());
182 if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
183 return fallback;
184 }
185 QXmlStreamReader xml(&f);
186 while (!xml.atEnd()) {
187 if (xml.readNext() == QXmlStreamReader::StartElement
188 && xml.name() == QLatin1String("Graphics")) {
189 // readElementText() unescapes the XML entities, yielding the raw JSON.
190 const QJsonObject o =
191 QJsonDocument::fromJson(xml.readElementText().toUtf8()).object();
192 return o.value(QStringLiteral("gpu")).toString(fallback);
193 }
194 }
195 return fallback;
196}
197
198} // namespace
199

Callers 1

applyAtStartupMethod · 0.85

Calls 5

settingsFilePathFunction · 0.85
openMethod · 0.45
nameMethod · 0.45
toStringMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected