Skip to content

Commit 1cf3614

Browse files
committed
Fix settings list handling for single string values
When the list contains only one string, settings may be read as a string instead of a list on Linux.
1 parent fb182a1 commit 1cf3614

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

qgitc/settings.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def _makeFont(families: List[str], pointSize: int):
8787

8888
def logViewFont(self):
8989
families = self.value("lvFonts", [])
90+
if isinstance(families, str):
91+
families = [families]
9092
fontSize = self.value(
9193
"lvFontSize", QApplication.font().pointSize(), type=int)
9294
if not families:
@@ -105,6 +107,8 @@ def setLogViewFont(self, font: QFont):
105107

106108
def diffViewFont(self):
107109
families = self.value("dvFonts", [])
110+
if isinstance(families, str):
111+
families = [families]
108112
fontSize = self.value(
109113
"dvFontSize", QApplication.font().pointSize(), type=int)
110114
if not families:
@@ -376,6 +380,8 @@ def submodulesCache(self, repoDir):
376380
cache = self.value(key, [])
377381
if cache is None:
378382
cache = []
383+
elif isinstance(cache, str):
384+
cache = [cache]
379385
self.endGroup()
380386
return cache
381387

@@ -462,8 +468,10 @@ def setCommitActions(self, repoName: str, actions: List[CommitAction]):
462468
def globalCommitActions(self) -> List[CommitAction]:
463469
self.beginGroup("commit")
464470
actions = self.value("actions", [])
471+
if isinstance(actions, str):
472+
actions = [actions]
465473
self.endGroup()
466-
return actions
474+
return actions or []
467475

468476
def setGlobalCommitActions(self, actions: List[CommitAction]):
469477
self.beginGroup("commit")
@@ -543,7 +551,10 @@ def logLevel(self):
543551
return self.value("logLevel", logging.WARNING, type=int)
544552

545553
def aiExcludedFileExtensions(self):
546-
return self.value("aiExcludedFileExtensions", [])
554+
value = self.value("aiExcludedFileExtensions", [])
555+
if isinstance(value, str):
556+
return [value]
557+
return value or []
547558

548559
def setAiExcludedFileExtensions(self, extensions: List[str]):
549560
self.setValue("aiExcludedFileExtensions", extensions)
@@ -627,7 +638,11 @@ def showFetchSlowAlert(self) -> bool:
627638

628639
def recentRepositories(self) -> List[str]:
629640
"""Get list of recently visited repositories"""
630-
return self.value("recentRepositories", [])
641+
# settings type=list here is not working well
642+
value = self.value("recentRepositories", [])
643+
if isinstance(value, str):
644+
return [value]
645+
return value or []
631646

632647
def setRecentRepositories(self, repos: List[str]):
633648
"""Set list of recently visited repositories"""

0 commit comments

Comments
 (0)