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
| 176 | // upgrading users. Reading the file by hand (like the UiScale bootstrap) avoids |
| 177 | // touching the singleton at all. |
| 178 | QString 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 |
no test coverage detected