Lets not delete the image before we copy it. Doh

Fixes: https://launchpad.net/bugs/712097
This commit is contained in:
Tim Bentley 2011-02-05 07:54:23 +00:00
parent 6577f6c25e
commit c7d3193762

View File

@ -268,8 +268,8 @@ class ThemeManager(QtGui.QWidget):
newThemeName = unicode(self.fileRenameForm.fileNameEdit.text()) newThemeName = unicode(self.fileRenameForm.fileNameEdit.text())
if self.checkIfThemeExists(newThemeName): if self.checkIfThemeExists(newThemeName):
oldThemeData = self.getThemeData(oldThemeName) oldThemeData = self.getThemeData(oldThemeName)
self.deleteTheme(oldThemeName)
self.cloneThemeData(oldThemeData, newThemeName) self.cloneThemeData(oldThemeData, newThemeName)
self.deleteTheme(oldThemeName)
for plugin in self.mainwindow.pluginManager.plugins: for plugin in self.mainwindow.pluginManager.plugins:
if plugin.usesTheme(oldThemeName): if plugin.usesTheme(oldThemeName):
plugin.renameTheme(oldThemeName, newThemeName) plugin.renameTheme(oldThemeName, newThemeName)
@ -295,11 +295,13 @@ class ThemeManager(QtGui.QWidget):
log.debug(u'cloneThemeData') log.debug(u'cloneThemeData')
saveTo = None saveTo = None
saveFrom = None saveFrom = None
print themeData.background_type
if themeData.background_type == u'image': if themeData.background_type == u'image':
saveTo = os.path.join(self.path, newThemeName, saveTo = os.path.join(self.path, newThemeName,
os.path.split(unicode(themeData.background_filename))[1]) os.path.split(unicode(themeData.background_filename))[1])
saveFrom = themeData.background_filename saveFrom = themeData.background_filename
themeData.theme_name = newThemeName themeData.theme_name = newThemeName
themeData.extend_image_filename(self.path)
self.saveTheme(themeData, saveFrom, saveTo) self.saveTheme(themeData, saveFrom, saveTo)
def onEditTheme(self): def onEditTheme(self):
@ -349,7 +351,7 @@ class ThemeManager(QtGui.QWidget):
shutil.rmtree(os.path.join(self.path, theme).encode(encoding)) shutil.rmtree(os.path.join(self.path, theme).encode(encoding))
except OSError: except OSError:
log.exception(u'Error deleting theme %s', theme) log.exception(u'Error deleting theme %s', theme)
# As we do not reload the themes push out the change # As we do not reload the themes, push out the change
# Reaload the list as the internal lists and events need # Reaload the list as the internal lists and events need
# to be triggered # to be triggered
self.pushThemes() self.pushThemes()
@ -577,6 +579,7 @@ class ThemeManager(QtGui.QWidget):
theme_dir = os.path.join(self.path, name) theme_dir = os.path.join(self.path, name)
check_directory_exists(theme_dir) check_directory_exists(theme_dir)
theme_file = os.path.join(theme_dir, name + u'.xml') theme_file = os.path.join(theme_dir, name + u'.xml')
print imageTo, self.oldBackgroundImage
if imageTo and self.oldBackgroundImage and \ if imageTo and self.oldBackgroundImage and \
imageTo != self.oldBackgroundImage: imageTo != self.oldBackgroundImage:
delete_file(self.oldBackgroundImage) delete_file(self.oldBackgroundImage)
@ -589,6 +592,7 @@ class ThemeManager(QtGui.QWidget):
finally: finally:
if outfile: if outfile:
outfile.close() outfile.close()
print imageFrom, imageTo
if imageFrom and imageFrom != imageTo: if imageFrom and imageFrom != imageTo:
try: try:
encoding = get_filesystem_encoding() encoding = get_filesystem_encoding()
@ -603,7 +607,7 @@ class ThemeManager(QtGui.QWidget):
def generateAndSaveImage(self, dir, name, theme): def generateAndSaveImage(self, dir, name, theme):
log.debug(u'generateAndSaveImage %s %s', dir, name) log.debug(u'generateAndSaveImage %s %s', dir, name)
theme_xml = theme.extract_xml() #theme_xml = theme.extract_xml()
frame = self.generateImage(theme) frame = self.generateImage(theme)
samplepathname = os.path.join(self.path, name + u'.png') samplepathname = os.path.join(self.path, name + u'.png')
if os.path.exists(samplepathname): if os.path.exists(samplepathname):