mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 04:59:30 -07:00
BUG-2745: Fixed registering issue when a hotkey is not or wrongly configured.
This commit is contained in:
parent
20e59ddd1c
commit
96d04334ef
1 changed files with 9 additions and 4 deletions
|
@ -532,21 +532,26 @@ namespace Greenshot.Forms {
|
||||||
|
|
||||||
private static bool RegisterWrapper(StringBuilder failedKeys, string functionName, string configurationKey, HotKeyHandler handler, bool ignoreFailedRegistration) {
|
private static bool RegisterWrapper(StringBuilder failedKeys, string functionName, string configurationKey, HotKeyHandler handler, bool ignoreFailedRegistration) {
|
||||||
IniValue hotkeyValue = _conf.Values[configurationKey];
|
IniValue hotkeyValue = _conf.Values[configurationKey];
|
||||||
|
var hotkeyStringValue = hotkeyValue.Value?.ToString();
|
||||||
|
if (string.IsNullOrEmpty(hotkeyStringValue))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
bool success = RegisterHotkey(failedKeys, functionName, hotkeyValue.Value.ToString(), handler);
|
bool success = RegisterHotkey(failedKeys, functionName, hotkeyStringValue, handler);
|
||||||
if (!success && ignoreFailedRegistration) {
|
if (!success && ignoreFailedRegistration) {
|
||||||
LOG.DebugFormat("Ignoring failed hotkey registration for {0}, with value '{1}', resetting to 'None'.", functionName, hotkeyValue);
|
LOG.DebugFormat("Ignoring failed hotkey registration for {0}, with value '{1}', resetting to 'None'.", functionName, hotkeyStringValue);
|
||||||
_conf.Values[configurationKey].Value = Keys.None.ToString();
|
_conf.Values[configurationKey].Value = Keys.None.ToString();
|
||||||
_conf.IsDirty = true;
|
_conf.IsDirty = true;
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOG.Warn(ex);
|
LOG.Warn(ex);
|
||||||
LOG.WarnFormat("Restoring default hotkey for {0}, stored under {1} from '{2}' to '{3}'", functionName, configurationKey, hotkeyValue.Value, hotkeyValue.Attributes.DefaultValue);
|
LOG.WarnFormat("Restoring default hotkey for {0}, stored under {1} from '{2}' to '{3}'", functionName, configurationKey, hotkeyStringValue, hotkeyValue.Attributes.DefaultValue);
|
||||||
// when getting an exception the key wasn't found: reset the hotkey value
|
// when getting an exception the key wasn't found: reset the hotkey value
|
||||||
hotkeyValue.UseValueOrDefault(null);
|
hotkeyValue.UseValueOrDefault(null);
|
||||||
hotkeyValue.ContainingIniSection.IsDirty = true;
|
hotkeyValue.ContainingIniSection.IsDirty = true;
|
||||||
return RegisterHotkey(failedKeys, functionName, hotkeyValue.Value.ToString(), handler);
|
return RegisterHotkey(failedKeys, functionName, hotkeyStringValue, handler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue