# HG changeset patch # User František Kučera # Date 1702243237 -3600 # Node ID 42341f66de52651a6764f7b883ce6409eb53567b # Parent 12262f2420de0b4724c48cc8814a563cc28ef89c monitor texture and shader file writes using inotify: improved resource management diff -r 12262f2420de -r 42341f66de52 FileMonitor.cpp --- 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 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 {