Skip to content

Commit 9c139c2

Browse files
committed
Merge pull request #1230 from dakcarto/issue_9704_gdal-qsettings
Fix #9704, GdalTools file dialogs return QPyNullVariant due to QSettings undefined return type
2 parents 60e1a9b + 073dbf1 commit 9c139c2

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

python/plugins/GdalTools/GdalTools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__( self, iface ):
7676
if not overrideLocale:
7777
localeFullName = QLocale.system().name()
7878
else:
79-
localeFullName = QSettings().value( "locale/userLocale", "" )
79+
localeFullName = QSettings().value( "locale/userLocale", "", type=str )
8080

8181
if QFileInfo( userPluginPath ).exists():
8282
translationPath = userPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"

python/plugins/GdalTools/tools/GdalTools_utils.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ def escapeAndJoin(strList):
5959
# Retrieves last used dir from persistent settings
6060
def getLastUsedDir():
6161
settings = QSettings()
62-
lastProjectDir = settings.value( "/UI/lastProjectDir", ".", type=str )
63-
return settings.value( "/GdalTools/lastUsedDir", lastProjectDir, type=str )
62+
lastProjectDir = settings.value( "/UI/lastProjectDir", u".", type=unicode )
63+
return settings.value( "/GdalTools/lastUsedDir", lastProjectDir, type=unicode )
6464

6565
# Stores last used dir in persistent settings
6666
def setLastUsedDir(filePath):
@@ -75,7 +75,7 @@ def setLastUsedDir(filePath):
7575
# Retrieves GDAL binaries location
7676
def getGdalBinPath():
7777
settings = QSettings()
78-
return settings.value( "/GdalTools/gdalPath", u"" )
78+
return settings.value( "/GdalTools/gdalPath", u"", type=unicode )
7979

8080
# Stores GDAL binaries location
8181
def setGdalBinPath( path ):
@@ -85,7 +85,7 @@ def setGdalBinPath( path ):
8585
# Retrieves GDAL python modules location
8686
def getGdalPymodPath():
8787
settings = QSettings()
88-
return settings.value( "/GdalTools/gdalPymodPath", u"" )
88+
return settings.value( "/GdalTools/gdalPymodPath", u"", type=unicode )
8989

9090
# Stores GDAL python modules location
9191
def setGdalPymodPath( path ):
@@ -95,7 +95,7 @@ def setGdalPymodPath( path ):
9595
# Retrieves GDAL help files location
9696
def getHelpPath():
9797
settings = QSettings()
98-
return settings.value( "/GdalTools/helpPath", u"" )
98+
return settings.value( "/GdalTools/helpPath", u"", type=unicode )
9999

100100
# Stores GDAL help files location
101101
def setHelpPath( path ):
@@ -105,7 +105,7 @@ def setHelpPath( path ):
105105
# Retrieves last used encoding from persistent settings
106106
def getLastUsedEncoding():
107107
settings = QSettings()
108-
return settings.value( "/UI/encoding", u"System" )
108+
return settings.value( "/UI/encoding", u"System", type=unicode )
109109

110110
# Stores last used encoding in persistent settings
111111
def setLastUsedEncoding(encoding):
@@ -347,7 +347,7 @@ def getDialog(self, parent = None, caption = '', acceptMode = QFileDialog.Accept
347347
dialog.setFileMode(fileMode)
348348
dialog.setAcceptMode(acceptMode)
349349

350-
if selectedFilter != None:
350+
if selectedFilter is not None:
351351
dialog.selectNameFilter(selectedFilter[0])
352352

353353
if not dialog.exec_():
@@ -356,7 +356,7 @@ def getDialog(self, parent = None, caption = '', acceptMode = QFileDialog.Accept
356356
return ''
357357

358358
# change the selected filter value
359-
if selectedFilter != None:
359+
if selectedFilter is not None:
360360
selectedFilter[0] = dialog.selectedNameFilter()
361361

362362
# save the last used dir and return the selected files
@@ -409,7 +409,7 @@ class FileFilter:
409409
@classmethod
410410
def getFilter(self, typeName):
411411
settings = QSettings()
412-
return settings.value( "/GdalTools/" + typeName + "FileFilter", u"" )
412+
return settings.value( "/GdalTools/" + typeName + "FileFilter", u"", type=unicode )
413413

414414
@classmethod
415415
def setFilter(self, typeName, aFilter):

0 commit comments

Comments
 (0)