<table><tr><td style="">rjvbb created this revision.<br />rjvbb added a reviewer: Frameworks.<br />rjvbb added a project: Frameworks.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D8043" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>KDirWatch is not current thread-safe which can cause problems when feeding or deleting directories in a multi-threaded approach. In addition, the class uses a single QFileSystemWatcher instance (<tt style="background: #ebebeb; font-size: 13px;">fsWatcher</tt>) when using the <tt style="background: #ebebeb; font-size: 13px;">QFSWatch</tt> method.</p>
<p>Thus, as a function of which internal method is being used, multi-thread access should be protected with a mutex that can either be a regular class variable or needs to be a static class variable.</p>
<p>Making the KDirWatch instance methods virtual allows to derive KDirWatch in a specialised class which adds e.g. the appropriate mutex, with minimal modification of existing code and without having to burden applications that use the class in a strictly single-threaded approach with mutex'ing overhead.</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>Tested (on Mac): works as expected. Code can continue to use the result of functions returning a derived class pointer as <tt style="background: #ebebeb; font-size: 13px;">KDirWatch*</tt> and still benefit from thread-safeties in the derived class.<br />
CD</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R244 KCoreAddons</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D8043" rel="noreferrer">https://phabricator.kde.org/D8043</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/lib/io/kdirwatch.h</div></div></div><br /><div><strong>To: </strong>rjvbb, Frameworks<br /></div>