kim_error err = KIM_NO_ERROR;
CFStringRef key = NULL;
- if (!err && !in_value) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ /* in_value may be NULL if removing the key */
if (!err) {
key = kim_os_preferences_cfstring_for_key (in_key);
/* in_options may be KIM_OPTIONS_DEFAULT, in which case we empty the dict */
- if (!err) {
+ if (!err && in_options) {
dictionary = CFDictionaryCreateMutable (kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
if (!dictionary) { err = check_error (KIM_OUT_OF_MEMORY_ERR); }
- }
-
- if (!err && in_options) {
- err = kim_os_preferences_options_to_dictionary (in_options, dictionary);
+
+ if (!err) {
+ err = kim_os_preferences_options_to_dictionary (in_options, dictionary);
+ }
}
if (!err) {
+ /* NULL dictioray will remove any entry for this key */
err = kim_os_preferences_set_value (in_key, dictionary);
}