diff --git a/GreenshotPlugin/Controls/GreenshotForm.cs b/GreenshotPlugin/Controls/GreenshotForm.cs index 294687146..c645562d9 100644 --- a/GreenshotPlugin/Controls/GreenshotForm.cs +++ b/GreenshotPlugin/Controls/GreenshotForm.cs @@ -61,6 +61,10 @@ namespace GreenshotPlugin.Controls { if (typeof(IGreenshotLanguageBindable).IsAssignableFrom(field.FieldType)) { IGreenshotLanguageBindable languageBindable = controlObject as IGreenshotLanguageBindable; if (!string.IsNullOrEmpty(languageBindable.LanguageKey)) { + if (!language.hasKey(languageBindable.LanguageKey)) { + LOG.WarnFormat("Wrong language key '{0}' configured for field '{1}'", languageBindable.LanguageKey, field.Name); + continue; + } Control control = controlObject as Control; control.Text = language.GetString(languageBindable.LanguageKey); } else { @@ -85,6 +89,10 @@ namespace GreenshotPlugin.Controls { if (!string.IsNullOrEmpty(configBindable.SectionName) && !string.IsNullOrEmpty(configBindable.PropertyName)) { IniSection section = IniConfig.GetIniSection(configBindable.SectionName); if (section != null) { + if (!section.Values.ContainsKey(configBindable.PropertyName)) { + LOG.WarnFormat("Wrong property '{0}' configured for field '{1}'",configBindable.PropertyName,field.Name); + continue; + } if (typeof(CheckBox).IsAssignableFrom(field.FieldType)) { CheckBox checkBox = controlObject as CheckBox; checkBox.Checked = (bool)section.Values[configBindable.PropertyName].Value; diff --git a/GreenshotPlugin/Core/LanguageHelper.cs b/GreenshotPlugin/Core/LanguageHelper.cs index 6641a9fda..32b8e6ad2 100644 --- a/GreenshotPlugin/Core/LanguageHelper.cs +++ b/GreenshotPlugin/Core/LanguageHelper.cs @@ -379,18 +379,30 @@ namespace GreenshotPlugin.Core { } public bool hasKey(Enum key) { + if (key == null) { + return false; + } return hasKey(key.ToString()); } public bool hasKey(string key) { + if (key == null) { + return false; + } return strings.ContainsKey(key); } public string GetString(Enum key) { + if (key == null) { + return null; + } return GetString(key.ToString()); } public string GetString(string key) { + if (key == null) { + return null; + } try { return strings[key]; } catch (KeyNotFoundException) {