Skip to content

Commit

Permalink
Merge pull request #2754 from Hammerspoon/fix-2753
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsj committed Mar 10, 2021
2 parents 307b769 + f32271a commit 1d29cef
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions extensions/settings/internal.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N

// [LuaSkin logWarn:[NSString stringWithFormat:@"in observeValueForKeyPath for %@ with %@", keyPath, change]] ;
if (context == myKVOContext && _watchedKeys && _watchedKeys[keyPath]) {
NSMutableDictionary *fnCallbacks = _watchedKeys[keyPath] ;
// [LuaSkin logWarn:[NSString stringWithFormat:@"in callback for %@ with %@", keyPath, fnCallbacks]] ;
LuaSkin *skin = [LuaSkin sharedWithState:NULL] ;
_lua_stackguard_entry(skin.L);
[fnCallbacks enumerateKeysAndObjectsUsingBlock:^(NSString *watcherID, NSNumber *refN, __unused BOOL *stop) {
[skin pushLuaRef:refTable ref:refN.intValue] ;
[skin pushNSObject:keyPath] ;
[skin protectedCallAndError:[NSString stringWithFormat:@"hs.settings:watcher %@ callback", watcherID] nargs:1 nresults:0];
}] ;
_lua_stackguard_exit(skin.L);
dispatch_async(dispatch_get_main_queue(), ^{
NSMutableDictionary *fnCallbacks = self->_watchedKeys[keyPath] ;
// [LuaSkin logWarn:[NSString stringWithFormat:@"in callback for %@ with %@", keyPath, fnCallbacks]] ;
LuaSkin *skin = [LuaSkin sharedWithState:NULL] ;
_lua_stackguard_entry(skin.L);
[fnCallbacks enumerateKeysAndObjectsUsingBlock:^(NSString *watcherID, NSNumber *refN, __unused BOOL *stop) {
[skin pushLuaRef:refTable ref:refN.intValue] ;
[skin pushNSObject:keyPath] ;
[skin protectedCallAndError:[NSString stringWithFormat:@"hs.settings:watcher %@ callback", watcherID] nargs:1 nresults:0];
}] ;
_lua_stackguard_exit(skin.L);
});
}
}

Expand Down

0 comments on commit 1d29cef

Please sign in to comment.