monitor texture and shader file writes using inotify: improved resource management
--- a/FileMonitor.cpp Wed Dec 06 22:55:43 2023 +0100
+++ b/FileMonitor.cpp Sun Dec 10 22:20:37 2023 +0100
@@ -52,9 +52,9 @@
std::map<int, std::string> fileNames;
void unwatch(int wd) {
+ fileNames.erase(wd);
int result = inotify_rm_watch(fd, wd);
checkError(result < 0, "unable to stop monitoring a file: ");
- fileNames.erase(wd);
}
virtual ~Impl() {
@@ -109,7 +109,12 @@
}
WatchedFile::Impl::~Impl() {
- fileMonitorImpl->unwatch(wd);
+ try {
+ fileMonitorImpl->unwatch(wd);
+ } catch (const std::exception& e) {
+ // ignored, fails after file deletion
+ // std::cerr << "unwatch failed: " << e.what() << std::endl;
+ }
}
FileMonitor WatchedFile::getFileMonitor() const {