author | eckhart.koppen@nokia.com |
Wed, 31 Mar 2010 11:06:36 +0300 | |
changeset 7 | f7bc934e204c |
parent 0 | 1918ee327afb |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtCore module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
||
43 |
#include <qplatformdefs.h> |
|
44 |
||
45 |
#include "qfilesystemwatcher.h" |
|
46 |
#include "qfilesystemwatcher_fsevents_p.h" |
|
47 |
||
48 |
#include <qdebug.h> |
|
49 |
#include <qfile.h> |
|
50 |
#include <qdatetime.h> |
|
51 |
#include <qfileinfo.h> |
|
52 |
#include <qvarlengtharray.h> |
|
53 |
||
54 |
#include <mach/mach.h> |
|
55 |
#include <sys/types.h> |
|
56 |
#include <CoreFoundation/CFRunLoop.h> |
|
57 |
#include <CoreFoundation/CFUUID.h> |
|
58 |
#include <CoreServices/CoreServices.h> |
|
59 |
#include <AvailabilityMacros.h> |
|
60 |
#include <private/qcore_mac_p.h> |
|
61 |
||
62 |
QT_BEGIN_NAMESPACE |
|
63 |
||
64 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 |
|
65 |
// Static operator overloading so for the sake of some convieniece. |
|
66 |
// They only live in this compilation unit to avoid polluting Qt in general. |
|
67 |
static bool operator==(const struct ::timespec &left, const struct ::timespec &right) |
|
68 |
{ |
|
69 |
return left.tv_sec == right.tv_sec |
|
70 |
&& left.tv_nsec == right.tv_nsec; |
|
71 |
} |
|
72 |
||
73 |
static bool operator==(const struct ::stat64 &left, const struct ::stat64 &right) |
|
74 |
{ |
|
75 |
return left.st_dev == right.st_dev |
|
76 |
&& left.st_mode == right.st_mode |
|
77 |
&& left.st_size == right.st_size |
|
78 |
&& left.st_ino == right.st_ino |
|
79 |
&& left.st_uid == right.st_uid |
|
80 |
&& left.st_gid == right.st_gid |
|
81 |
&& left.st_mtimespec == right.st_mtimespec |
|
82 |
&& left.st_ctimespec == right.st_ctimespec |
|
83 |
&& left.st_flags == right.st_flags; |
|
84 |
} |
|
85 |
||
86 |
static bool operator!=(const struct ::stat64 &left, const struct ::stat64 &right) |
|
87 |
{ |
|
88 |
return !(operator==(left, right)); |
|
89 |
} |
|
90 |
||
91 |
||
92 |
static void addPathToHash(PathHash &pathHash, const QString &key, const QFileInfo &fileInfo, |
|
93 |
const QString &path) |
|
94 |
{ |
|
95 |
PathInfoList &list = pathHash[key]; |
|
96 |
list.push_back(PathInfo(path, |
|
97 |
fileInfo.absoluteFilePath().normalized(QString::NormalizationForm_D).toUtf8())); |
|
98 |
pathHash.insert(key, list); |
|
99 |
} |
|
100 |
||
101 |
static void removePathFromHash(PathHash &pathHash, const QString &key, const QString &path) |
|
102 |
{ |
|
103 |
PathInfoList &list = pathHash[key]; |
|
104 |
// We make the assumption that the list contains unique paths |
|
105 |
PathInfoList::iterator End = list.end(); |
|
106 |
PathInfoList::iterator it = list.begin(); |
|
107 |
while (it != End) { |
|
108 |
if (it->originalPath == path) { |
|
109 |
list.erase(it); |
|
110 |
break; |
|
111 |
} |
|
112 |
++it; |
|
113 |
} |
|
114 |
if (list.isEmpty()) |
|
115 |
pathHash.remove(key); |
|
116 |
} |
|
117 |
||
118 |
static void stopFSStream(FSEventStreamRef stream) |
|
119 |
{ |
|
120 |
if (stream) { |
|
121 |
FSEventStreamStop(stream); |
|
122 |
FSEventStreamInvalidate(stream); |
|
123 |
} |
|
124 |
} |
|
125 |
||
126 |
static QString createFSStreamPath(const QString &absolutePath) |
|
127 |
{ |
|
128 |
// The path returned has a trailing slash, so ensure that here. |
|
129 |
QString string = absolutePath; |
|
130 |
string.reserve(string.size() + 1); |
|
131 |
string.append(QLatin1Char('/')); |
|
132 |
return string; |
|
133 |
} |
|
134 |
||
135 |
static void cleanupFSStream(FSEventStreamRef stream) |
|
136 |
{ |
|
137 |
if (stream) |
|
138 |
FSEventStreamRelease(stream); |
|
139 |
} |
|
140 |
||
141 |
const FSEventStreamCreateFlags QtFSEventFlags = (kFSEventStreamCreateFlagUseCFTypes | kFSEventStreamCreateFlagNoDefer /* | kFSEventStreamCreateFlagWatchRoot*/); |
|
142 |
||
143 |
const CFTimeInterval Latency = 0.033; // This will do updates 30 times a second which is probably more than you need. |
|
144 |
#endif |
|
145 |
||
146 |
QFSEventsFileSystemWatcherEngine::QFSEventsFileSystemWatcherEngine() |
|
147 |
: fsStream(0), pathsToWatch(0), threadsRunLoop(0) |
|
148 |
{ |
|
149 |
} |
|
150 |
||
151 |
QFSEventsFileSystemWatcherEngine::~QFSEventsFileSystemWatcherEngine() |
|
152 |
{ |
|
153 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 |
|
154 |
// I assume that at this point, QFileSystemWatcher has already called stop |
|
155 |
// on me, so I don't need to invalidate or stop my stream, simply |
|
156 |
// release it. |
|
157 |
cleanupFSStream(fsStream); |
|
158 |
if (pathsToWatch) |
|
159 |
CFRelease(pathsToWatch); |
|
160 |
#endif |
|
161 |
} |
|
162 |
||
163 |
QFSEventsFileSystemWatcherEngine *QFSEventsFileSystemWatcherEngine::create() |
|
164 |
{ |
|
165 |
return new QFSEventsFileSystemWatcherEngine(); |
|
166 |
} |
|
167 |
||
168 |
QStringList QFSEventsFileSystemWatcherEngine::addPaths(const QStringList &paths, |
|
169 |
QStringList *files, |
|
170 |
QStringList *directories) |
|
171 |
{ |
|
172 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 |
|
173 |
stop(); |
|
174 |
QMutexLocker locker(&mutex); |
|
175 |
QStringList failedToAdd; |
|
176 |
// if we have a running FSStreamEvent, we have to kill it, we'll re-add the stream soon. |
|
177 |
FSEventStreamEventId idToCheck; |
|
178 |
if (fsStream) { |
|
179 |
idToCheck = FSEventStreamGetLatestEventId(fsStream); |
|
180 |
cleanupFSStream(fsStream); |
|
181 |
} else { |
|
182 |
idToCheck = kFSEventStreamEventIdSinceNow; |
|
183 |
} |
|
184 |
||
185 |
// Brain-dead approach, but works. FSEvents actually can already read sub-trees, but since it's |
|
186 |
// work to figure out if we are doing a double register, we just register it twice as FSEvents |
|
187 |
// seems smart enough to only deliver one event. We also duplicate directory entries in here |
|
188 |
// (e.g., if you watch five files in the same directory, you get that directory included in the |
|
189 |
// array 5 times). This stupidity also makes remove work correctly though. I'll freely admit |
|
190 |
// that we could make this a bit smarter. If you do, check the auto-tests, they should catch at |
|
191 |
// least a couple of the issues. |
|
192 |
QCFType<CFMutableArrayRef> tmpArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); |
|
193 |
for (int i = 0; i < paths.size(); ++i) { |
|
194 |
const QString &path = paths.at(i); |
|
195 |
||
196 |
QFileInfo fileInfo(path); |
|
197 |
if (!fileInfo.exists()) { |
|
198 |
failedToAdd.append(path); |
|
199 |
continue; |
|
200 |
} |
|
201 |
||
202 |
if (fileInfo.isDir()) { |
|
203 |
if (directories->contains(path)) { |
|
204 |
failedToAdd.append(path); |
|
205 |
continue; |
|
206 |
} else { |
|
207 |
directories->append(path); |
|
208 |
// Full file path for dirs. |
|
209 |
QCFString cfpath(createFSStreamPath(fileInfo.absoluteFilePath())); |
|
210 |
addPathToHash(dirPathInfoHash, cfpath, fileInfo, path); |
|
211 |
CFArrayAppendValue(tmpArray, cfpath); |
|
212 |
} |
|
213 |
} else { |
|
214 |
if (files->contains(path)) { |
|
215 |
failedToAdd.append(path); |
|
216 |
continue; |
|
217 |
} else { |
|
218 |
// Just the absolute path (minus it's filename) for files. |
|
219 |
QCFString cfpath(createFSStreamPath(fileInfo.absolutePath())); |
|
220 |
files->append(path); |
|
221 |
addPathToHash(filePathInfoHash, cfpath, fileInfo, path); |
|
222 |
CFArrayAppendValue(tmpArray, cfpath); |
|
223 |
} |
|
224 |
} |
|
225 |
} |
|
226 |
||
227 |
if (!pathsToWatch && failedToAdd.size() == paths.size()) { |
|
228 |
return failedToAdd; |
|
229 |
} |
|
230 |
||
231 |
if (CFArrayGetCount(tmpArray) > 0) { |
|
232 |
if (pathsToWatch) { |
|
233 |
CFArrayAppendArray(tmpArray, pathsToWatch, CFRangeMake(0, CFArrayGetCount(pathsToWatch))); |
|
234 |
CFRelease(pathsToWatch); |
|
235 |
} |
|
236 |
pathsToWatch = CFArrayCreateCopy(kCFAllocatorDefault, tmpArray); |
|
237 |
} |
|
238 |
||
239 |
FSEventStreamContext context = { 0, this, 0, 0, 0 }; |
|
240 |
fsStream = FSEventStreamCreate(kCFAllocatorDefault, |
|
241 |
QFSEventsFileSystemWatcherEngine::fseventsCallback, |
|
242 |
&context, pathsToWatch, |
|
243 |
idToCheck, Latency, QtFSEventFlags); |
|
244 |
warmUpFSEvents(); |
|
245 |
||
246 |
return failedToAdd; |
|
247 |
#else |
|
248 |
Q_UNUSED(paths); |
|
249 |
Q_UNUSED(files); |
|
250 |
Q_UNUSED(directories); |
|
251 |
return QStringList(); |
|
252 |
#endif |
|
253 |
} |
|
254 |
||
255 |
void QFSEventsFileSystemWatcherEngine::warmUpFSEvents() |
|
256 |
{ |
|
257 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 |
|
258 |
// This function assumes that the mutex has already been grabbed before calling it. |
|
259 |
// It exits with the mutex still locked (Q_ASSERT(mutex.isLocked()) ;-). |
|
260 |
start(); |
|
261 |
waitCondition.wait(&mutex); |
|
262 |
#endif |
|
263 |
} |
|
264 |
||
265 |
QStringList QFSEventsFileSystemWatcherEngine::removePaths(const QStringList &paths, |
|
266 |
QStringList *files, |
|
267 |
QStringList *directories) |
|
268 |
{ |
|
269 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 |
|
270 |
stop(); |
|
271 |
QMutexLocker locker(&mutex); |
|
272 |
// short circuit for smarties that call remove before add and we have nothing. |
|
273 |
if (pathsToWatch == 0) |
|
274 |
return paths; |
|
275 |
QStringList failedToRemove; |
|
276 |
// if we have a running FSStreamEvent, we have to stop it, we'll re-add the stream soon. |
|
277 |
FSEventStreamEventId idToCheck; |
|
278 |
if (fsStream) { |
|
279 |
idToCheck = FSEventStreamGetLatestEventId(fsStream); |
|
280 |
cleanupFSStream(fsStream); |
|
281 |
fsStream = 0; |
|
282 |
} else { |
|
283 |
idToCheck = kFSEventStreamEventIdSinceNow; |
|
284 |
} |
|
285 |
||
286 |
CFIndex itemCount = CFArrayGetCount(pathsToWatch); |
|
287 |
QCFType<CFMutableArrayRef> tmpArray = CFArrayCreateMutableCopy(kCFAllocatorDefault, itemCount, |
|
288 |
pathsToWatch); |
|
289 |
CFRelease(pathsToWatch); |
|
290 |
pathsToWatch = 0; |
|
291 |
for (int i = 0; i < paths.size(); ++i) { |
|
292 |
// Get the itemCount at the beginning to avoid any overruns during the iteration. |
|
293 |
itemCount = CFArrayGetCount(tmpArray); |
|
294 |
const QString &path = paths.at(i); |
|
295 |
QFileInfo fi(path); |
|
296 |
QCFString cfpath(createFSStreamPath(fi.absolutePath())); |
|
297 |
||
298 |
CFIndex index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfpath); |
|
299 |
if (index != -1) { |
|
300 |
CFArrayRemoveValueAtIndex(tmpArray, index); |
|
301 |
files->removeAll(path); |
|
302 |
removePathFromHash(filePathInfoHash, cfpath, path); |
|
303 |
} else { |
|
304 |
// Could be a directory we are watching instead. |
|
305 |
QCFString cfdirpath(createFSStreamPath(fi.absoluteFilePath())); |
|
306 |
index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfdirpath); |
|
307 |
if (index != -1) { |
|
308 |
CFArrayRemoveValueAtIndex(tmpArray, index); |
|
309 |
directories->removeAll(path); |
|
310 |
removePathFromHash(dirPathInfoHash, cfpath, path); |
|
311 |
} else { |
|
312 |
failedToRemove.append(path); |
|
313 |
} |
|
314 |
} |
|
315 |
} |
|
316 |
itemCount = CFArrayGetCount(tmpArray); |
|
317 |
if (itemCount != 0) { |
|
318 |
pathsToWatch = CFArrayCreateCopy(kCFAllocatorDefault, tmpArray); |
|
319 |
||
320 |
FSEventStreamContext context = { 0, this, 0, 0, 0 }; |
|
321 |
fsStream = FSEventStreamCreate(kCFAllocatorDefault, |
|
322 |
QFSEventsFileSystemWatcherEngine::fseventsCallback, |
|
323 |
&context, pathsToWatch, idToCheck, Latency, QtFSEventFlags); |
|
324 |
warmUpFSEvents(); |
|
325 |
} |
|
326 |
return failedToRemove; |
|
327 |
#else |
|
328 |
Q_UNUSED(paths); |
|
329 |
Q_UNUSED(files); |
|
330 |
Q_UNUSED(directories); |
|
331 |
return QStringList(); |
|
332 |
#endif |
|
333 |
} |
|
334 |
||
335 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 |
|
336 |
void QFSEventsFileSystemWatcherEngine::updateList(PathInfoList &list, bool directory, bool emitSignals) |
|
337 |
{ |
|
338 |
PathInfoList::iterator End = list.end(); |
|
339 |
PathInfoList::iterator it = list.begin(); |
|
340 |
while (it != End) { |
|
341 |
struct ::stat64 newInfo; |
|
342 |
if (::stat64(it->absolutePath, &newInfo) == 0) { |
|
343 |
if (emitSignals) { |
|
344 |
if (newInfo != it->savedInfo) { |
|
345 |
it->savedInfo = newInfo; |
|
346 |
if (directory) |
|
347 |
emit directoryChanged(it->originalPath, false); |
|
348 |
else |
|
349 |
emit fileChanged(it->originalPath, false); |
|
350 |
} |
|
351 |
} else { |
|
352 |
it->savedInfo = newInfo; |
|
353 |
} |
|
354 |
} else { |
|
355 |
if (errno == ENOENT) { |
|
356 |
if (emitSignals) { |
|
357 |
if (directory) |
|
358 |
emit directoryChanged(it->originalPath, true); |
|
359 |
else |
|
360 |
emit fileChanged(it->originalPath, true); |
|
361 |
} |
|
362 |
it = list.erase(it); |
|
363 |
continue; |
|
364 |
} else { |
|
365 |
qWarning("%s:%d:QFSEventsFileSystemWatcherEngine: stat error on %s:%s", |
|
366 |
__FILE__, __LINE__, qPrintable(it->originalPath), strerror(errno)); |
|
367 |
||
368 |
} |
|
369 |
} |
|
370 |
++it; |
|
371 |
} |
|
372 |
} |
|
373 |
||
374 |
void QFSEventsFileSystemWatcherEngine::updateHash(PathHash &pathHash) |
|
375 |
{ |
|
376 |
PathHash::iterator HashEnd = pathHash.end(); |
|
377 |
PathHash::iterator it = pathHash.begin(); |
|
378 |
const bool IsDirectory = (&pathHash == &dirPathInfoHash); |
|
379 |
while (it != HashEnd) { |
|
380 |
updateList(it.value(), IsDirectory, false); |
|
381 |
if (it.value().isEmpty()) |
|
382 |
it = pathHash.erase(it); |
|
383 |
else |
|
384 |
++it; |
|
385 |
} |
|
386 |
} |
|
387 |
#endif |
|
388 |
||
389 |
void QFSEventsFileSystemWatcherEngine::fseventsCallback(ConstFSEventStreamRef , |
|
390 |
void *clientCallBackInfo, size_t numEvents, |
|
391 |
void *eventPaths, |
|
392 |
const FSEventStreamEventFlags eventFlags[], |
|
393 |
const FSEventStreamEventId []) |
|
394 |
{ |
|
395 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 |
|
396 |
QFSEventsFileSystemWatcherEngine *watcher = static_cast<QFSEventsFileSystemWatcherEngine *>(clientCallBackInfo); |
|
397 |
QMutexLocker locker(&watcher->mutex); |
|
398 |
CFArrayRef paths = static_cast<CFArrayRef>(eventPaths); |
|
399 |
for (size_t i = 0; i < numEvents; ++i) { |
|
400 |
const QString path = QCFString::toQString( |
|
401 |
static_cast<CFStringRef>(CFArrayGetValueAtIndex(paths, i))); |
|
402 |
const FSEventStreamEventFlags pathFlags = eventFlags[i]; |
|
403 |
// There are several flags that may be passed, but we really don't care about them ATM. |
|
404 |
// Here they are and why we don't care. |
|
405 |
// kFSEventStreamEventFlagHistoryDone--(very unlikely to be gotten, but even then, not much changes). |
|
406 |
// kFSEventStreamEventFlagMustScanSubDirs--Likely means the data is very much out of date, we |
|
407 |
// aren't coalescing our directories, so again not so much of an issue |
|
408 |
// kFSEventStreamEventFlagRootChanged | kFSEventStreamEventFlagMount | kFSEventStreamEventFlagUnmount-- |
|
409 |
// These three flags indicate something has changed, but the stat will likely show this, so |
|
410 |
// there's not really much to worry about. |
|
411 |
// (btw, FSEvents is not the correct way of checking for mounts/unmounts, |
|
412 |
// there are real CarbonCore events for that.) |
|
413 |
Q_UNUSED(pathFlags); |
|
414 |
if (watcher->filePathInfoHash.contains(path)) |
|
415 |
watcher->updateList(watcher->filePathInfoHash[path], false, true); |
|
416 |
||
417 |
if (watcher->dirPathInfoHash.contains(path)) |
|
418 |
watcher->updateList(watcher->dirPathInfoHash[path], true, true); |
|
419 |
} |
|
420 |
#else |
|
421 |
Q_UNUSED(clientCallBackInfo); |
|
422 |
Q_UNUSED(numEvents); |
|
423 |
Q_UNUSED(eventPaths); |
|
424 |
Q_UNUSED(eventFlags); |
|
425 |
#endif |
|
426 |
} |
|
427 |
||
428 |
void QFSEventsFileSystemWatcherEngine::stop() |
|
429 |
{ |
|
430 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 |
|
431 |
QMutexLocker locker(&mutex); |
|
432 |
stopFSStream(fsStream); |
|
433 |
if (threadsRunLoop) { |
|
434 |
CFRunLoopStop(threadsRunLoop); |
|
435 |
waitForStop.wait(&mutex); |
|
436 |
} |
|
437 |
#endif |
|
438 |
} |
|
439 |
||
440 |
void QFSEventsFileSystemWatcherEngine::updateFiles() |
|
441 |
{ |
|
442 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 |
|
443 |
QMutexLocker locker(&mutex); |
|
444 |
updateHash(filePathInfoHash); |
|
445 |
updateHash(dirPathInfoHash); |
|
446 |
if (filePathInfoHash.isEmpty() && dirPathInfoHash.isEmpty()) { |
|
447 |
// Everything disappeared before we got to start, don't bother. |
|
448 |
stop(); |
|
449 |
cleanupFSStream(fsStream); |
|
450 |
} |
|
451 |
waitCondition.wakeAll(); |
|
452 |
#endif |
|
453 |
} |
|
454 |
||
455 |
void QFSEventsFileSystemWatcherEngine::run() |
|
456 |
{ |
|
457 |
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 |
|
458 |
threadsRunLoop = CFRunLoopGetCurrent(); |
|
459 |
FSEventStreamScheduleWithRunLoop(fsStream, threadsRunLoop, kCFRunLoopDefaultMode); |
|
460 |
bool startedOK = FSEventStreamStart(fsStream); |
|
461 |
// It's recommended by Apple that you only update the files after you've started |
|
462 |
// the stream, because otherwise you might miss an update in between starting it. |
|
463 |
updateFiles(); |
|
464 |
#ifdef QT_NO_DEBUG |
|
465 |
Q_UNUSED(startedOK); |
|
466 |
#else |
|
467 |
Q_ASSERT(startedOK); |
|
468 |
#endif |
|
469 |
// If for some reason we called stop up above (and invalidated our stream), this call will return |
|
470 |
// immediately. |
|
471 |
CFRunLoopRun(); |
|
472 |
threadsRunLoop = 0; |
|
473 |
QMutexLocker locker(&mutex); |
|
474 |
waitForStop.wakeAll(); |
|
475 |
#endif |
|
476 |
} |
|
477 |
||
478 |
QT_END_NAMESPACE |