1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-20 04:33:36 +00:00

Fix bug in dmon_deinit;

Stale state prevented library from working when reinitialized.
This commit is contained in:
bjorn 2023-12-03 06:26:51 -08:00
parent 7e5aea54c5
commit fcac1b13bf
2 changed files with 4 additions and 6 deletions

View file

@ -611,13 +611,13 @@ DMON_API_IMPL void dmon_deinit(void)
if (_dmon.watches[i]) {
_dmon_unwatch(_dmon.watches[i]);
DMON_FREE(_dmon.watches[i]);
_dmon.watches[i] = NULL;
}
}
}
DeleteCriticalSection(&_dmon.mutex);
stb_sb_free(_dmon.events);
memset(&_dmon, 0x0, sizeof(_dmon));
_dmon_init = false;
}
@ -1156,13 +1156,13 @@ DMON_API_IMPL void dmon_deinit(void)
if (_dmon.watches[i]) {
_dmon_unwatch(_dmon.watches[i]);
DMON_FREE(_dmon.watches[i]);
_dmon.watches[i] = NULL;
}
}
}
pthread_mutex_destroy(&_dmon.mutex);
stb_sb_free(_dmon.events);
memset(&_dmon, 0x0, sizeof(_dmon));
_dmon_init = false;
}
@ -1547,7 +1547,6 @@ DMON_API_IMPL void dmon_deinit(void)
if (_dmon.watches[i]) {
_dmon_unwatch(_dmon.watches[i]);
DMON_FREE(_dmon.watches[i]);
_dmon.watches[i] = NULL;
}
}
}
@ -1557,6 +1556,7 @@ DMON_API_IMPL void dmon_deinit(void)
if (_dmon.cf_alloc_ref)
CFRelease(_dmon.cf_alloc_ref);
memset(&_dmon, 0x0, sizeof(_dmon));
_dmon_init = false;
}

View file

@ -78,7 +78,6 @@ struct File {
static struct {
uint32_t ref;
bool watching;
dmon_watch_id watchId;
Archive* archives;
size_t savePathLength;
char savePath[1024];
@ -218,14 +217,13 @@ void lovrFilesystemWatch(void) {
if (!state.watching && fs_stat(state.source, &info) && info.type == FILE_DIRECTORY) {
state.watching = true;
dmon_init();
state.watchId = dmon_watch(state.source, onFileEvent, DMON_WATCHFLAGS_RECURSIVE, NULL);
dmon_watch(state.source, onFileEvent, DMON_WATCHFLAGS_RECURSIVE, NULL);
}
}
void lovrFilesystemUnwatch(void) {
if (state.watching) {
state.watching = false;
dmon_unwatch(state.watchId);
dmon_deinit();
}
}