add loop to catch null values
This commit is contained in:
parent
6252ce466c
commit
3fc844c15a
2 changed files with 8 additions and 7 deletions
|
@ -152,13 +152,13 @@ void SystemPreferences::RegisterDefaults(mate::Arguments* args) {
|
||||||
} else {
|
} else {
|
||||||
@try {
|
@try {
|
||||||
NSDictionary* dict = DictionaryValueToNSDictionary(value);
|
NSDictionary* dict = DictionaryValueToNSDictionary(value);
|
||||||
// for (id key in dict) {
|
for (id key in dict) {
|
||||||
// id value = [dict objectForKey:key];
|
id value = [dict objectForKey:key];
|
||||||
// if (value == nil) {
|
if ([value isKindOfClass:[NSNull class]] || value == nil) {
|
||||||
// printf("HELLO\n");
|
args->ThrowError("Invalid userDefault data provided");
|
||||||
// args->ThrowError("Invalid userDefault data provided");
|
return;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
|
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
|
||||||
} @catch (NSException* exception) {
|
} @catch (NSException* exception) {
|
||||||
args->ThrowError("Invalid userDefault data provided");
|
args->ThrowError("Invalid userDefault data provided");
|
||||||
|
|
|
@ -66,6 +66,7 @@ describe('systemPreferences module', () => {
|
||||||
1,
|
1,
|
||||||
null,
|
null,
|
||||||
new Date(),
|
new Date(),
|
||||||
|
{ 'one': null }
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const badDefault of badDefaults) {
|
for (const badDefault of badDefaults) {
|
||||||
|
|
Loading…
Reference in a new issue