1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-25 05:52:50 -05:00

settings: guard saving before load completed

This commit is contained in:
bbedward
2026-01-01 11:30:09 -05:00
parent 37f972d075
commit c141ad1e34
2 changed files with 15 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ Singleton {
readonly property bool isGreeterMode: Quickshell.env("DMS_RUN_GREETER") === "1" || Quickshell.env("DMS_RUN_GREETER") === "true"
property bool hasTriedDefaultSession: false
property bool _parseError: false
property bool _hasLoaded: false
readonly property string _stateUrl: StandardPaths.writableLocation(StandardPaths.GenericStateLocation)
readonly property string _stateDir: Paths.strip(_stateUrl)
@@ -111,8 +112,10 @@ Singleton {
function parseSettings(content) {
_parseError = false;
try {
if (!content || !content.trim())
if (!content || !content.trim()) {
_parseError = true;
return;
}
var settings = JSON.parse(content);
isLightMode = settings.isLightMode !== undefined ? settings.isLightMode : false;
@@ -178,6 +181,7 @@ Singleton {
includedTransitions = settings.includedTransitions !== undefined ? settings.includedTransitions : availableWallpaperTransitions.filter(t => t !== "none");
recentColors = settings.recentColors !== undefined ? settings.recentColors : [];
showThirdPartyPlugins = settings.showThirdPartyPlugins !== undefined ? settings.showThirdPartyPlugins : false;
_hasLoaded = true;
if (settings.configVersion === undefined) {
migrateFromUndefinedToV1(settings);
@@ -202,7 +206,7 @@ Singleton {
}
function saveSettings() {
if (isGreeterMode || _parseError)
if (isGreeterMode || _parseError || !_hasLoaded)
return;
settingsFile.setText(JSON.stringify({
"isLightMode": isLightMode,