Skip to content

Commit

Permalink
Merge pull request #46 from stfufane/fswatcher-mac-deprecated
Browse files Browse the repository at this point in the history
Update filesystemwatcher deprecated MacOS API
  • Loading branch information
FigBug authored Mar 6, 2024
2 parents 2294811 + 8f6f57c commit 93dfb89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@
Debug
Release
.vs
.idea
*.user

xcuserdata
Builds
cmake-build-debug
cmake-build-release
JuceLibraryCode
juce
bin
Expand Down
5 changes: 3 additions & 2 deletions modules/gin/utilities/gin_filesystemwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ class FileSystemWatcher::Impl
context.release = nil;
context.copyDescription = nil;

dispatch_queue_t queue = dispatch_queue_create("com.gin.filesystemwatcher", DISPATCH_QUEUE_SERIAL);
stream = FSEventStreamCreate (kCFAllocatorDefault, callback, &context, (CFArrayRef)paths, kFSEventStreamEventIdSinceNow, 0.05,
kFSEventStreamCreateFlagNoDefer | kFSEventStreamCreateFlagFileEvents);
if (stream)
{
FSEventStreamScheduleWithRunLoop (stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
FSEventStreamSetDispatchQueue(stream, queue);
FSEventStreamStart (stream);
}

Expand All @@ -36,7 +37,7 @@ class FileSystemWatcher::Impl
if (stream)
{
FSEventStreamStop (stream);
FSEventStreamUnscheduleFromRunLoop (stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
FSEventStreamSetDispatchQueue(stream, nullptr);
FSEventStreamInvalidate (stream);
FSEventStreamRelease (stream);
}
Expand Down

0 comments on commit 93dfb89

Please sign in to comment.