Skip to content

Commit 2a81aba

Browse files
committedJun 14, 2013
[Plugin Manager] Don't crash on invalid values from QSettings
1 parent 820a0f7 commit 2a81aba

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed
 

‎python/pyplugin_installer/installer_data.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ def __init__(self,*args):
189189
elif proxyType in ["5","FtpCachingProxy"] and QT_VERSION >= 0X040400: self.proxy.setType(QNetworkProxy.FtpCachingProxy)
190190
else: self.proxy.setType(QNetworkProxy.DefaultProxy)
191191
self.proxy.setHostName(settings.value("/proxyHost","", type=unicode))
192-
self.proxy.setPort(settings.value("/proxyPort", 0, type=int))
192+
try:
193+
# QSettings may contain non-int value...
194+
self.proxy.setPort(settings.value("/proxyPort", 0, type=int))
195+
except:
196+
pass
193197
self.proxy.setUser(settings.value("/proxyUser", "", type=unicode))
194198
self.proxy.setPassword(settings.value("/proxyPassword", "", type=unicode))
195199
self.setProxy(self.proxy)
@@ -320,7 +324,12 @@ def setCheckingOnStart(self, state):
320324
def checkingOnStartInterval(self):
321325
""" return checking for news and updates interval """
322326
settings = QSettings()
323-
i = settings.value(settingsGroup+"/checkOnStartInterval", 1, type=int)
327+
try:
328+
# QSettings may contain non-int value...
329+
i = settings.value(settingsGroup+"/checkOnStartInterval", 1, type=int)
330+
except:
331+
# fallback do 1 day by default
332+
i = 1
324333
if i < 0: i = 1
325334
# allowed values: 0,1,3,7,14,30 days
326335
interval = 0
@@ -350,7 +359,11 @@ def timeForChecking(self):
350359
if self.checkingOnStartInterval() == 0:
351360
return True
352361
settings = QSettings()
353-
interval = settings.value(settingsGroup+"/checkOnStartLastDate",type=QDate).daysTo(QDate.currentDate())
362+
try:
363+
# QSettings may contain ivalid value...
364+
interval = settings.value(settingsGroup+"/checkOnStartLastDate",type=QDate).daysTo(QDate.currentDate())
365+
except:
366+
interval = 0
354367
if interval >= self.checkingOnStartInterval():
355368
return True
356369
else:

0 commit comments

Comments
 (0)
Please sign in to comment.