From 84f0596c0ca7cb5a31077cea29592781899c13f4 Mon Sep 17 00:00:00 2001 From: Mate Barany Date: Fri, 13 Jan 2023 18:18:08 +0100 Subject: Avoid potential data races caused by qt_ntfs_permission_lookup qt_ntfs_permission_lookup is a global, non-atomic variable which could cause problems in case of multiple threads. Introduce a new atomic variable to handle permission lookups but instead of manual incrementation/decrementation, implement a class to manage the variable. Since the atomic variable is not directly available to the user, implement helper functions to increase/decrease/check the status of the variable. Task-number: QTBUG-105804 Change-Id: If6cbcdd653c7f50ad9853a5c309e24fdeb520788 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- src/corelib/io/qfileinfo.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/corelib/io/qfileinfo.cpp') diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 49573347ca..5c9ae5df70 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -278,6 +278,19 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) threads other than the main thread have started or after every thread other than the main thread has ended. + \note From Qt 6.6 the variable \c qt_ntfs_permission_lookup is + deprecated. Please use the following alternatives. + + The safe and easy way to manage permission checks is to use the RAII class + \c QNtfsPermissionCheckGuard. + + \snippet ntfsp.cpp raii + + If you need more fine-grained control, it is possible to manage the permission + with the following functions instead: + + \snippet ntfsp.cpp free-funcs + \section1 Performance Considerations Some of QFileInfo's functions query the file system, but for -- cgit v1.2.3