mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 09:33:46 -07:00
Fixed bug #3597535 by making sure the IniChanged event isn't hooked before the editor is loaded. Also added a log statement in the ini loading code, and added a better try catch.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2409 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
e64b5bfd9f
commit
c352c4061b
2 changed files with 17 additions and 5 deletions
|
@ -90,9 +90,8 @@ namespace Greenshot {
|
||||||
var thread = new Thread(delegate() {AddDestinations();});
|
var thread = new Thread(delegate() {AddDestinations();});
|
||||||
thread.Name = "add destinations";
|
thread.Name = "add destinations";
|
||||||
thread.Start();
|
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
|
// Make sure the editor is placed on the same location as the last editor was on close
|
||||||
WindowDetails thisForm = new WindowDetails(this.Handle);
|
WindowDetails thisForm = new WindowDetails(this.Handle);
|
||||||
|
|
|
@ -229,11 +229,24 @@ namespace Greenshot.IniFile {
|
||||||
fixedProperties = Read(CreateIniLocation(configName + FIXED_POSTFIX + INI_EXTENSION));
|
fixedProperties = Read(CreateIniLocation(configName + FIXED_POSTFIX + INI_EXTENSION));
|
||||||
|
|
||||||
foreach (IniSection section in sectionMap.Values) {
|
foreach (IniSection section in sectionMap.Values) {
|
||||||
|
try {
|
||||||
section.Fill(PropertiesForSection(section));
|
section.Fill(PropertiesForSection(section));
|
||||||
FixProperties(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This "fixes" the properties of the section, meaning any properties in the fixed file can't be changed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="section">IniSection</param>
|
||||||
private static void FixProperties(IniSection section) {
|
private static void FixProperties(IniSection section) {
|
||||||
// Make properties unchangable
|
// Make properties unchangable
|
||||||
if (fixedProperties != null) {
|
if (fixedProperties != null) {
|
||||||
|
@ -257,7 +270,7 @@ namespace Greenshot.IniFile {
|
||||||
LOG.Info("Can't find file: " + iniLocation);
|
LOG.Info("Can't find file: " + iniLocation);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
LOG.DebugFormat("Loading ini-file: {0}", iniLocation);
|
LOG.InfoFormat("Loading ini-file: {0}", iniLocation);
|
||||||
//LOG.Info("Reading ini-properties from file: " + iniLocation);
|
//LOG.Info("Reading ini-properties from file: " + iniLocation);
|
||||||
Dictionary<string, Dictionary<string, string>> newSections = IniReader.read(iniLocation, Encoding.UTF8);
|
Dictionary<string, Dictionary<string, string>> newSections = IniReader.read(iniLocation, Encoding.UTF8);
|
||||||
// Merge the newly loaded properties to the already available
|
// Merge the newly loaded properties to the already available
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue