diff --git a/src/api/dirmonitor.c b/src/api/dirmonitor.c index 2769aa6b..fd92f4e9 100644 --- a/src/api/dirmonitor.c +++ b/src/api/dirmonitor.c @@ -63,6 +63,7 @@ static int f_dirmonitor_new(lua_State* L) { struct dirmonitor* monitor = lua_newuserdata(L, sizeof(struct dirmonitor)); luaL_setmetatable(L, API_TYPE_DIRMONITOR); memset(monitor, 0, sizeof(struct dirmonitor)); + monitor->mutex = SDL_CreateMutex(); monitor->internal = init_dirmonitor(); return 1; } diff --git a/src/api/dirmonitor/fsevents.c b/src/api/dirmonitor/fsevents.c index 6d22ca51..18e5799f 100644 --- a/src/api/dirmonitor/fsevents.c +++ b/src/api/dirmonitor/fsevents.c @@ -22,6 +22,7 @@ struct dirmonitor_internal* init_dirmonitor() { monitor->stream = NULL; monitor->changes = NULL; monitor->count = 0; + monitor->lock = NULL; return monitor; } @@ -136,6 +137,8 @@ int translate_changes_dirmonitor( int add_dirmonitor(struct dirmonitor_internal* monitor, const char* path) { stop_monitor_stream(monitor); + monitor->lock = SDL_CreateMutex(); + FSEventStreamContext context = { .info = monitor, .retain = NULL,