diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs index 983c0ecf4..6f5351aa8 100644 --- a/Greenshot/Forms/ImageEditorForm.cs +++ b/Greenshot/Forms/ImageEditorForm.cs @@ -90,9 +90,8 @@ namespace Greenshot { var thread = new Thread(delegate() {AddDestinations();}); thread.Name = "add destinations"; thread.Start(); + IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration); }; - - IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration); // Make sure the editor is placed on the same location as the last editor was on close WindowDetails thisForm = new WindowDetails(this.Handle); diff --git a/GreenshotPlugin/IniFile/IniConfig.cs b/GreenshotPlugin/IniFile/IniConfig.cs index 208fd6f7f..276f6abfc 100644 --- a/GreenshotPlugin/IniFile/IniConfig.cs +++ b/GreenshotPlugin/IniFile/IniConfig.cs @@ -229,11 +229,24 @@ namespace Greenshot.IniFile { fixedProperties = Read(CreateIniLocation(configName + FIXED_POSTFIX + INI_EXTENSION)); foreach (IniSection section in sectionMap.Values) { - section.Fill(PropertiesForSection(section)); - FixProperties(section); + try { + section.Fill(PropertiesForSection(section)); + FixProperties(section); + } catch (Exception ex) { + string sectionName = "unknown"; + if (section != null && section.IniSectionAttribute != null && section.IniSectionAttribute.Name != null) { + sectionName = section.IniSectionAttribute.Name; + } + LOG.WarnFormat("Problem reading the ini section {0}", sectionName); + LOG.Warn("Exception", ex); + } } } + /// + /// This "fixes" the properties of the section, meaning any properties in the fixed file can't be changed. + /// + /// IniSection private static void FixProperties(IniSection section) { // Make properties unchangable if (fixedProperties != null) { @@ -257,7 +270,7 @@ namespace Greenshot.IniFile { LOG.Info("Can't find file: " + iniLocation); return null; } - LOG.DebugFormat("Loading ini-file: {0}", iniLocation); + LOG.InfoFormat("Loading ini-file: {0}", iniLocation); //LOG.Info("Reading ini-properties from file: " + iniLocation); Dictionary> newSections = IniReader.read(iniLocation, Encoding.UTF8); // Merge the newly loaded properties to the already available