Mercurial > hg > easyhg
comparison src/fswatcher.cpp @ 730:f1dc72b940d5
Crude way to avoid callback on a deleted watcher on exit (macOS)
author | Chris Cannam |
---|---|
date | Mon, 17 Dec 2018 10:54:29 +0000 |
parents | 646e48a0d3a5 |
children |
comparison
equal
deleted
inserted
replaced
729:cd4617b18960 | 730:f1dc72b940d5 |
---|---|
89 * linked with the FSEvents API to run on 10.4 without some fiddling, | 89 * linked with the FSEvents API to run on 10.4 without some fiddling, |
90 * and I'm not really keen to do that either. That may be our cue to | 90 * and I'm not really keen to do that either. That may be our cue to |
91 * drop 10.4 support for EasyMercurial. | 91 * drop 10.4 support for EasyMercurial. |
92 */ | 92 */ |
93 | 93 |
94 static bool abandoning = false; // emergency flag for use by non-member callback | |
95 | |
94 FsWatcher::FsWatcher() : | 96 FsWatcher::FsWatcher() : |
95 m_lastToken(0), | 97 m_lastToken(0), |
96 m_lastCounter(0) | 98 m_lastCounter(0) |
97 { | 99 { |
98 #ifdef Q_OS_MAC | 100 #ifdef Q_OS_MAC |
105 #endif | 107 #endif |
106 } | 108 } |
107 | 109 |
108 FsWatcher::~FsWatcher() | 110 FsWatcher::~FsWatcher() |
109 { | 111 { |
112 QMutexLocker locker(&m_mutex); | |
113 abandoning = true; | |
110 } | 114 } |
111 | 115 |
112 void | 116 void |
113 FsWatcher::setWorkDirPath(QString path) | 117 FsWatcher::setWorkDirPath(QString path) |
114 { | 118 { |
149 size_t numEvents, | 153 size_t numEvents, |
150 void *paths, | 154 void *paths, |
151 const FSEventStreamEventFlags /* eventFlags */[], | 155 const FSEventStreamEventFlags /* eventFlags */[], |
152 const FSEventStreamEventId /*eventIDs */[]) | 156 const FSEventStreamEventId /*eventIDs */[]) |
153 { | 157 { |
158 if (abandoning) return; | |
154 FsWatcher *watcher = reinterpret_cast<FsWatcher *>(clientCallBackInfo); | 159 FsWatcher *watcher = reinterpret_cast<FsWatcher *>(clientCallBackInfo); |
155 const char *const *cpaths = reinterpret_cast<const char *const *>(paths); | 160 const char *const *cpaths = reinterpret_cast<const char *const *>(paths); |
156 for (size_t i = 0; i < numEvents; ++i) { | 161 for (size_t i = 0; i < numEvents; ++i) { |
157 #ifdef DEBUG_FSWATCHER | 162 #ifdef DEBUG_FSWATCHER |
158 std::cerr << "path " << i << " = " << cpaths[i] << std::endl; | 163 std::cerr << "path " << i << " = " << cpaths[i] << std::endl; |