Fixed QDateTime compatibility with old versions

This commit is contained in:
alby128 2017-10-06 19:59:30 +02:00
parent dff5138f54
commit d8edc2d3ca
2 changed files with 4 additions and 4 deletions

View File

@ -279,10 +279,8 @@ class ConfigDialog(QtWidgets.QDialog):
settings = QSettings("Syncplay", "Interface")
settings.beginGroup("Update")
self.lastCheckedForUpdates = settings.value("lastChecked", None)
if self.lastCheckedForUpdates:
if self.lastCheckedForUpdates and type(self.lastCheckedForUpdates).__name__ == 'QDateTime':
if self.config["lastCheckedForUpdates"] is not None and self.config["lastCheckedForUpdates"] is not "":
if type(self.lastCheckedForUpdates).__name__ is 'datetime':
self.lastCheckedForUpdates = QDateTime.fromString(self.lastCheckedForUpdates.strftime('%Y-%m-%d %H:%M:%S'),'yyyy-MM-dd hh:mm:ss')
if self.lastCheckedForUpdates.toPython() > datetime.strptime(self.config["lastCheckedForUpdates"], "%Y-%m-%d %H:%M:%S.%f"):
self.config["lastCheckedForUpdates"] = self.lastCheckedForUpdates.toString("yyyy-MM-d HH:mm:ss.z")
else:

View File

@ -1524,8 +1524,10 @@ class MainWindow(QtWidgets.QMainWindow):
return
if self.config['lastCheckedForUpdates']:
configLastChecked = datetime.strptime(self.config["lastCheckedForUpdates"], "%Y-%m-%d %H:%M:%S.%f")
if type(self.lastCheckedForUpdates).__name__ != 'QDateTime':
self.lastCheckedForUpdates = None
if self.lastCheckedForUpdates is None or configLastChecked > self.lastCheckedForUpdates.toPython():
self.lastCheckedForUpdates = configLastChecked
self.lastCheckedForUpdates = QDateTime.fromString(self.config["lastCheckedForUpdates"],'yyyy-MM-dd HH-mm-ss')
if self.lastCheckedForUpdates is None:
self.checkForUpdates()
else: