Fixes #730459 and 4 unreported bugs.

This commit is contained in:
Mattias Põldaru 2011-03-08 09:38:25 +02:00
parent ffca971bb0
commit 562a88a993
2 changed files with 19 additions and 19 deletions

View File

@ -349,11 +349,11 @@ class MediaManagerItem(QtGui.QWidget):
Validates whether an image still exists and, if it does, is the Validates whether an image still exists and, if it does, is the
thumbnail representation of the image up to date. thumbnail representation of the image up to date.
""" """
if not os.path.exists(image): if not os.path.exists(unicode(image)):
return False return False
if os.path.exists(thumb): if os.path.exists(thumb):
imageDate = os.stat(image).st_mtime imageDate = os.stat(unicode(image)).st_mtime
thumbDate = os.stat(thumb).st_mtime thumbDate = os.stat(unicode(thumb)).st_mtime
# If image has been updated rebuild icon # If image has been updated rebuild icon
if imageDate > thumbDate: if imageDate > thumbDate:
self.iconFromFile(image, thumb) self.iconFromFile(image, thumb)

View File

@ -416,36 +416,37 @@ class ServiceManager(QtGui.QWidget):
if not self.fileName(): if not self.fileName():
return self.saveFileAs() return self.saveFileAs()
else: else:
fileName = self.fileName() path_file_name = unicode(self.fileName())
log.debug(u'ServiceManager.saveFile - %s' % fileName) (path, file_name) = os.path.split(path_file_name)
basename = file_name[0:file_name.rfind(u'.')-1]
file_name = basename + '.osz'
service_file_name = basename + '.osd'
log.debug(u'ServiceManager.saveFile - %s' % path_file_name)
SettingsManager.set_last_dir(self.mainwindow.serviceSettingsSection, SettingsManager.set_last_dir(self.mainwindow.serviceSettingsSection,
split_filename(fileName)[0]) path)
service = [] service = []
serviceFileName = fileName.replace(u'.osz', u'.osd')
zip = None zip = None
file = None file = None
try: try:
write_list = [] write_list = []
zip = zipfile.ZipFile(unicode(fileName), 'w') zip = zipfile.ZipFile(path_file_name, 'w')
for item in self.serviceItems: for item in self.serviceItems:
service.append({u'serviceitem': \ service.append({u'serviceitem':
item[u'service_item'].get_service_repr()}) item[u'service_item'].get_service_repr()})
if item[u'service_item'].uses_file(): if item[u'service_item'].uses_file():
for frame in item[u'service_item'].get_frames(): for frame in item[u'service_item'].get_frames():
if item[u'service_item'].is_image(): if item[u'service_item'].is_image():
path_from = frame[u'path'] path_from = frame[u'path']
else: else:
path_from = unicode(os.path.join( path_from = os.path.join(frame[u'path'],
frame[u'path'], frame[u'title'])
frame[u'title']))
# On write a file once # On write a file once
if not path_from in write_list: if not path_from in write_list:
write_list.append(path_from) write_list.append(path_from)
zip.write(path_from.encode(u'utf-8')) zip.write(path_from,
file = open(serviceFileName, u'wb') path_from.encode(u'utf-8'))
cPickle.dump(service, file) zip.writestr(service_file_name.encode(u'utf-8'),
file.close() cPickle.dumps(service))
zip.write(serviceFileName.encode(u'utf-8'))
except IOError: except IOError:
log.exception(u'Failed to save service to disk') log.exception(u'Failed to save service to disk')
finally: finally:
@ -453,8 +454,7 @@ class ServiceManager(QtGui.QWidget):
file.close() file.close()
if zip: if zip:
zip.close() zip.close()
delete_file(serviceFileName) self.mainwindow.addRecentFile(path_file_name)
self.mainwindow.addRecentFile(fileName)
self.setModified(False) self.setModified(False)
return True return True