Skip to content

Commit

Permalink
Fix two crasher bugs in hs.camera watcher functions. Fixes HAMMERSPOO…
Browse files Browse the repository at this point in the history
…N-D4
  • Loading branch information
cmsj committed Jul 1, 2022
1 parent 22f1e69 commit 3e7b042
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion extensions/camera/libcamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ static int stopWatcher(lua_State *L) {
[skin checkArgs:LS_TBREAK];
}

if (!deviceWatcher) {
return 0;
}

NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center removeObserver:deviceWatcherAddedObserver
name:AVCaptureDeviceWasConnectedNotification
Expand All @@ -474,7 +478,7 @@ static int isWatcherRunning(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L];
[skin checkArgs:LS_TBREAK];

lua_pushboolean(L, deviceWatcher->running);
lua_pushboolean(L, deviceWatcher && deviceWatcher->running);

return 1;
}
Expand Down

0 comments on commit 3e7b042

Please sign in to comment.