--- a/Templates/TemplateViewer.py Fri Sep 10 12:41:55 2010 +0200 +++ b/Templates/TemplateViewer.py Fri Sep 10 20:03:59 2010 +0200 @@ -858,20 +858,20 @@ @param filename name of a templates file to read (string) """ - try: - if filename is None: - filename = os.path.join(Utilities.getConfigDir(), "eric5templates.e4c") - f = open(filename, "w", encoding = "utf-8") - - TemplatesWriter(f, self).writeXML() - - f.close() - except IOError: + if filename is None: + filename = os.path.join(Utilities.getConfigDir(), "eric5templates.e4c") + f = QFile(filename) + ok = f.open(QIODevice.WriteOnly) + if not ok: E5MessageBox.critical(self, self.trUtf8("Save templates"), self.trUtf8("<p>The templates file <b>{0}</b> could not be written.</p>") .format(filename)) + return + TemplatesWriter(f, self).writeXML() + f.close() + def readTemplates(self, filename = None): """ Public method to read in the templates file (.e4c) @@ -962,4 +962,4 @@ names = [] for group in list(self.groups.values()): names.extend(group.getEntryNames(start)) - return sorted(names) \ No newline at end of file + return sorted(names)