Skip to content

Commit 6588bb0

Browse files
committed
Fix Python error when launching the plugin for the first time fix #302
1 parent 0cc394f commit 6588bb0

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

cadastre/dialogs/dialog_common.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,25 @@ def load_default_values(self):
7474
WidgetSettings('liDbConnection', 'connection'),
7575
WidgetSettings('liDbSchema', 'schema'),
7676
]
77-
is_postgis = settings.value("cadastre/databaseType", type=str, defaultValue='') == 'postgis'
77+
# Default to PostGIS ticket #302
78+
is_postgis = settings.value("cadastre/databaseType", type=str, defaultValue='postgis') == 'postgis'
7879
for widget in widgets:
79-
80+
# Widgets are ordered by hierarchy, so we quit the loop as soon as a value is not correct
8081
if widget.settings == 'schema' and not is_postgis:
8182
return
8283

8384
if not hasattr(self.dialog, widget.ui):
8485
return
86+
8587
value = settings.value("cadastre/" + widget.settings, type=str, defaultValue='')
88+
if not value:
89+
return
90+
8691
combo = getattr(self.dialog, widget.ui)
8792
index = combo.findText(value, Qt.MatchFixedString)
8893
if not index:
8994
return
95+
9096
combo.setCurrentIndex(index)
9197

9298
def updateConnectionList(self):

0 commit comments

Comments
 (0)