summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfileinfo.cpp85
-rw-r--r--src/corelib/io/qfilesystemiterator_unix.cpp6
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp19
-rw-r--r--src/corelib/io/qloggingcategory.cpp267
-rw-r--r--src/corelib/io/qresource.cpp10
-rw-r--r--src/corelib/io/qsavefile.cpp14
-rw-r--r--src/corelib/io/qsettings.cpp7
-rw-r--r--src/corelib/io/qstandardpaths.cpp4
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp3
-rw-r--r--src/corelib/io/qtldurl.cpp8
-rw-r--r--src/corelib/io/qurl.cpp2
11 files changed, 247 insertions, 178 deletions
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index a6f8b45ea3..89834de29f 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -249,16 +249,18 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request)
isSymLink(). The symLinkTarget() function provides the name of the file
the symlink points to.
- On Unix (including \macos and iOS), the symlink has the same size() has
- the file it points to, because Unix handles symlinks
- transparently; similarly, opening a symlink using QFile
- effectively opens the link's target. For example:
+ On Unix (including \macos and iOS), the property getter functions in this
+ class return the properties such as times and size of the target file, not
+ the symlink, because Unix handles symlinks transparently. Opening a symlink
+ using QFile effectively opens the link's target. For example:
\snippet code/src_corelib_io_qfileinfo.cpp 0
- On Windows, shortcuts are \c .lnk files. The reported size() is that of
- the shortcut (not the link's target), and opening a shortcut using QFile
- opens the \c .lnk file. For example:
+ On Windows, shortcuts (\c .lnk files) are currently treated as symlinks. As
+ on Unix systems, the property getters return the size of the targeted file,
+ not the \c .lnk file itself. This behavior is deprecated and will likely be
+ removed in a future version of Qt, after which \c .lnk files will be treated
+ as regular files.
\snippet code/src_corelib_io_qfileinfo.cpp 1
@@ -903,6 +905,9 @@ QDir QFileInfo::absoluteDir() const
/*!
Returns \c true if the user can read the file; otherwise returns \c false.
+ If the file is a symlink, this function returns true if the target is
+ readable (not the symlink).
+
\note If the \l{NTFS permissions} check has not been enabled, the result
on Windows will merely reflect whether the file exists.
@@ -920,6 +925,9 @@ bool QFileInfo::isReadable() const
/*!
Returns \c true if the user can write to the file; otherwise returns \c false.
+ If the file is a symlink, this function returns true if the target is
+ writeable (not the symlink).
+
\note If the \l{NTFS permissions} check has not been enabled, the result on
Windows will merely reflect whether the file is marked as Read Only.
@@ -937,6 +945,9 @@ bool QFileInfo::isWritable() const
/*!
Returns \c true if the file is executable; otherwise returns \c false.
+ If the file is a symlink, this function returns true if the target is
+ executable (not the symlink).
+
\sa isReadable(), isWritable(), permission()
*/
bool QFileInfo::isExecutable() const
@@ -951,8 +962,13 @@ bool QFileInfo::isExecutable() const
/*!
Returns \c true if this is a `hidden' file; otherwise returns \c false.
- \b{Note:} This function returns \c true for the special entries
- "." and ".." on Unix, even though QDir::entryList threats them as shown.
+ \b{Note:} This function returns \c true for the special entries "." and
+ ".." on Unix, even though QDir::entryList threats them as shown. And note
+ that, since this function inspects the file name, on Unix it will inspect
+ the name of the symlink, if this file is a symlink, not the target's name.
+
+ On Windows, this function returns \c true if the target file is hidden (not
+ the symlink).
*/
bool QFileInfo::isHidden() const
{
@@ -991,6 +1007,9 @@ bool QFileInfo::isNativePath() const
link to a file. Returns \c false if the
object points to something which isn't a file, such as a directory.
+ If the file is a symlink, this function returns true if the target is a
+ regular file (not the symlink).
+
\sa isDir(), isSymLink(), isBundle()
*/
bool QFileInfo::isFile() const
@@ -1006,6 +1025,9 @@ bool QFileInfo::isFile() const
Returns \c true if this object points to a directory or to a symbolic
link to a directory; otherwise returns \c false.
+ If the file is a symlink, this function returns true if the target is a
+ directory (not the symlink).
+
\sa isFile(), isSymLink(), isBundle()
*/
bool QFileInfo::isDir() const
@@ -1023,6 +1045,9 @@ bool QFileInfo::isDir() const
Returns \c true if this object points to a bundle or to a symbolic
link to a bundle on \macos and iOS; otherwise returns \c false.
+ If the file is a symlink, this function returns true if the target is a
+ bundle (not the symlink).
+
\sa isDir(), isSymLink(), isFile()
*/
bool QFileInfo::isBundle() const
@@ -1044,7 +1069,8 @@ bool QFileInfo::isBundle() const
the \l{symLinkTarget()}{link's target}.
In addition, true will be returned for shortcuts (\c *.lnk files) on
- Windows. Opening those will open the \c .lnk file itself.
+ Windows. This behavior is deprecated and will likely change in a future
+ version of Qt. Opening those will open the \c .lnk file itself.
Example:
@@ -1190,6 +1216,9 @@ QString QFileInfo::symLinkTarget() const
milliseconds). On Windows, it will return an empty string unless
the \l{NTFS permissions} check has been enabled.
+ If the file is a symlink, this function returns the owner of the target
+ (not the symlink).
+
\sa ownerId(), group(), groupId()
*/
QString QFileInfo::owner() const
@@ -1206,6 +1235,9 @@ QString QFileInfo::owner() const
On Windows and on systems where files do not have owners this
function returns ((uint) -2).
+ If the file is a symlink, this function returns the id of the owner of the target
+ (not the symlink).
+
\sa owner(), group(), groupId()
*/
uint QFileInfo::ownerId() const
@@ -1225,6 +1257,9 @@ uint QFileInfo::ownerId() const
This function can be time consuming under Unix (in the order of
milliseconds).
+ If the file is a symlink, this function returns the owning group of the
+ target (not the symlink).
+
\sa groupId(), owner(), ownerId()
*/
QString QFileInfo::group() const
@@ -1241,6 +1276,9 @@ QString QFileInfo::group() const
On Windows and on systems where files do not have groups this
function always returns (uint) -2.
+ If the file is a symlink, this function returns the id of the group owning the
+ target (not the symlink).
+
\sa group(), owner(), ownerId()
*/
uint QFileInfo::groupId() const
@@ -1266,6 +1304,9 @@ uint QFileInfo::groupId() const
Example:
\snippet code/src_corelib_io_qfileinfo.cpp 10
+ If the file is a symlink, this function checks the permissions of the
+ target (not the symlink).
+
\sa isReadable(), isWritable(), isExecutable()
*/
bool QFileInfo::permission(QFile::Permissions permissions) const
@@ -1288,6 +1329,9 @@ bool QFileInfo::permission(QFile::Permissions permissions) const
\note The result might be inaccurate on Windows if the
\l{NTFS permissions} check has not been enabled.
+
+ If the file is a symlink, this function returns the permissions of the
+ target (not the symlink).
*/
QFile::Permissions QFileInfo::permissions() const
{
@@ -1305,6 +1349,9 @@ QFile::Permissions QFileInfo::permissions() const
Returns the file size in bytes. If the file does not exist or cannot be
fetched, 0 is returned.
+ If the file is a symlink, the size of the target file is returned
+ (not the symlink).
+
\sa exists()
*/
qint64 QFileInfo::size() const
@@ -1334,6 +1381,9 @@ qint64 QFileInfo::size() const
the time the file was created, metadataChangeTime() to get the time its
metadata was last changed, or lastModified() to get the time it was last modified.
+ If the file is a symlink, the time of the target file is returned
+ (not the symlink).
+
\sa birthTime(), metadataChangeTime(), lastModified(), lastRead()
*/
QDateTime QFileInfo::created() const
@@ -1352,6 +1402,9 @@ QDateTime QFileInfo::created() const
If the file birth time is not available, this function returns an invalid
QDateTime.
+ If the file is a symlink, the time of the target file is returned
+ (not the symlink).
+
\sa lastModified(), lastRead(), metadataChangeTime()
*/
QDateTime QFileInfo::birthTime() const
@@ -1366,6 +1419,9 @@ QDateTime QFileInfo::birthTime() const
user writes or sets inode information (for example, changing the file
permissions).
+ If the file is a symlink, the time of the target file is returned
+ (not the symlink).
+
\sa lastModified(), lastRead()
*/
QDateTime QFileInfo::metadataChangeTime() const
@@ -1376,6 +1432,9 @@ QDateTime QFileInfo::metadataChangeTime() const
/*!
Returns the date and local time when the file was last modified.
+ If the file is a symlink, the time of the target file is returned
+ (not the symlink).
+
\sa birthTime(), lastRead(), metadataChangeTime(), fileTime()
*/
QDateTime QFileInfo::lastModified() const
@@ -1389,6 +1448,9 @@ QDateTime QFileInfo::lastModified() const
On platforms where this information is not available, returns the
same as lastModified().
+ If the file is a symlink, the time of the target file is returned
+ (not the symlink).
+
\sa birthTime(), lastModified(), metadataChangeTime(), fileTime()
*/
QDateTime QFileInfo::lastRead() const
@@ -1402,6 +1464,9 @@ QDateTime QFileInfo::lastRead() const
Returns the file time specified by \a time. If the time cannot be
determined, an invalid date time is returned.
+ If the file is a symlink, the time of the target file is returned
+ (not the symlink).
+
\sa QFile::FileTime, QDateTime::isValid()
*/
QDateTime QFileInfo::fileTime(QFile::FileTime time) const
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
index 7194a2faf7..ceea3a467c 100644
--- a/src/corelib/io/qfilesystemiterator_unix.cpp
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -69,7 +69,9 @@ static bool checkNameDecodable(const char *d_name, qsizetype len)
# ifdef QT_LOCALE_IS_UTF8
int mibEnum = 106;
# else
- int mibEnum = codec->mibEnum();
+ int mibEnum = 4; // Latin 1
+ if (codec)
+ mibEnum = codec->mibEnum();
# endif
if (Q_LIKELY(mibEnum == 106)) // UTF-8
return QUtf8::isValidUtf8(d_name, len).isValidUtf8;
@@ -86,6 +88,8 @@ static bool checkNameDecodable(const char *d_name, qsizetype len)
Q_UNUSED(d_name);
Q_UNUSED(len);
// if we have no text codecs, then QString::fromLocal8Bit is fromLatin1
+ Q_UNUSED(d_name)
+ Q_UNUSED(len)
return true;
#endif
}
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 64c422c55a..54460aff77 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -41,9 +41,9 @@
#include "qfilesystemwatcher_p.h"
#include <qdatetime.h>
-#include <qdebug.h>
#include <qdir.h>
#include <qfileinfo.h>
+#include <qloggingcategory.h>
#include <qset.h>
#include <qtimer.h>
@@ -67,6 +67,8 @@
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcWatcher, "qt.core.filesystemwatcher")
+
QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent)
{
#if defined(Q_OS_WIN)
@@ -137,6 +139,7 @@ void QFileSystemWatcherPrivate::initPollerEngine()
void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed)
{
Q_Q(QFileSystemWatcher);
+ qCDebug(lcWatcher) << "file changed" << path << "removed?" << removed << "watching?" << files.contains(path);
if (!files.contains(path)) {
// the path was removed after a change was detected, but before we delivered the signal
return;
@@ -149,6 +152,7 @@ void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed
void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool removed)
{
Q_Q(QFileSystemWatcher);
+ qCDebug(lcWatcher) << "directory changed" << path << "removed?" << removed << "watching?" << directories.contains(path);
if (!directories.contains(path)) {
// perhaps the path was removed after a change was detected, but before we delivered the signal
return;
@@ -355,7 +359,7 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths)
qWarning("QFileSystemWatcher::addPaths: list is empty");
return p;
}
-
+ qCDebug(lcWatcher) << "adding" << paths;
const auto selectEngine = [this, d]() -> QFileSystemWatcherEngine* {
#ifdef QT_BUILD_INTERNAL
const QString on = objectName();
@@ -364,11 +368,11 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths)
// Autotest override case - use the explicitly selected engine only
const QStringRef forceName = on.midRef(26);
if (forceName == QLatin1String("poller")) {
- qDebug("QFileSystemWatcher: skipping native engine, using only polling engine");
+ qCDebug(lcWatcher, "QFileSystemWatcher: skipping native engine, using only polling engine");
d_func()->initPollerEngine();
return d->poller;
} else if (forceName == QLatin1String("native")) {
- qDebug("QFileSystemWatcher: skipping polling engine, using only native engine");
+ qCDebug(lcWatcher, "QFileSystemWatcher: skipping polling engine, using only native engine");
return d->native;
}
return nullptr;
@@ -431,6 +435,7 @@ QStringList QFileSystemWatcher::removePaths(const QStringList &paths)
qWarning("QFileSystemWatcher::removePaths: list is empty");
return p;
}
+ qCDebug(lcWatcher) << "removing" << paths;
if (d->native)
p = d->native->removePaths(p, &d->files, &d->directories);
@@ -446,6 +451,12 @@ QStringList QFileSystemWatcher::removePaths(const QStringList &paths)
This signal is emitted when the file at the specified \a path is
modified, renamed or removed from disk.
+ \note As a safety measure, many applications save an open file by
+ writing a new file and then deleting the old one. In your slot
+ function, you can check \c watcher.files().contains(path).
+ If it returns \c false, check whether the file still exists
+ and then call \c addPath() to continue watching it.
+
\sa directoryChanged()
*/
diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp
index f6ff56c83c..4d4784cdf7 100644
--- a/src/corelib/io/qloggingcategory.cpp
+++ b/src/corelib/io/qloggingcategory.cpp
@@ -70,14 +70,16 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
QLoggingCategory represents a certain logging category - identified by a
string - at runtime. A category can be configured to enable or disable
- logging of messages per message type. Whether a message type is enabled or
- not can be checked with the \l isDebugEnabled(), \l isInfoEnabled(),
- \l isWarningEnabled(), and \l isCriticalEnabled() methods.
-
- All objects are meant to be configured by a common registry (see also
- \l{Configuring Categories}). Different objects can also represent the same
- category. It is therefore not recommended to export objects across module
- boundaries, nor to manipulate the objects directly, nor to inherit from
+ logging of messages per message type.
+
+ To check whether a message type is enabled or not, use one of these methods:
+ \l isDebugEnabled(), \l isInfoEnabled(), \l isWarningEnabled(), and
+ \l isCriticalEnabled().
+
+ All objects are meant to be configured by a common registry, as described in
+ \l{Configuring Categories}. Different objects can also represent the same
+ category. Therefore, it's \b{not} recommended to export objects across
+ module boundaries, to manipulate the objects directly, or to inherit from
QLoggingCategory.
\section1 Creating Category Objects
@@ -87,17 +89,17 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
\snippet qloggingcategory/main.cpp 1
- \note Category names are free text. However, to allow easy configuration
- of the categories using \l{Logging Rules} the names should follow some rules:
+ Category names are free text; to configure categories using \l{Logging Rules}, their
+ names should follow this convention:
\list
\li Use letters and numbers only.
- \li Further structure categories into common areas by using dots.
- \li Avoid the category names \c{debug}, \c{info}, \c{warning}, and \c{critical}.
- \li Category names starting with \c{qt} are reserved for Qt modules.
+ \li Use dots to further structure categories into common areas.
+ \li Avoid the category names: \c{debug}, \c{info}, \c{warning}, and \c{critical}.
+ \li Category names with the \c{qt} prefix are solely reserved for Qt modules.
\endlist
- QLoggingCategory objects implicitly defined by Q_LOGGING_CATEGORY()
- are created on first use in a thread-safe manner.
+ QLoggingCategory objects that are implicitly defined by Q_LOGGING_CATEGORY()
+ are created on first use, in a thread-safe manner.
\section1 Checking Category Configuration
@@ -105,8 +107,8 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
\l isWarningEnabled(), \l isCriticalEnabled(), as well as \l isEnabled()
to check whether messages for the given message type should be logged.
- \note The qCDebug(), qCWarning(), qCCritical() macros prevent arguments
- from being evaluated if the respective message types are not enabled for the
+ The qCDebug(), qCWarning(), and qCCritical() macros prevent arguments from
+ being evaluated if the respective message types are not enabled for the
category, so explicit checking is not needed:
\snippet qloggingcategory/main.cpp 4
@@ -119,28 +121,27 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
\snippet qloggingcategory/main.cpp 5
- will log messages of type \c QtWarningMsg, \c QtCriticalMsg, \c QtFatalMsg, but will
- ignore messages of type \c QtDebugMsg and \c QtInfoMsg.
+ logs messages of type \c QtWarningMsg, \c QtCriticalMsg, \c QtFatalMsg, but
+ ignores messages of type \c QtDebugMsg and \c QtInfoMsg.
- If no argument is passed, all messages will be logged.
+ If no argument is passed, all messages are logged.
\section1 Configuring Categories
- The default configuration of categories can be overridden either by setting logging
- rules, or by installing a custom filter.
+ You can override the default configuration for categories either by setting
+ logging rules, or by installing a custom filter.
\section2 Logging Rules
- Logging rules allow logging for categories to be enabled or disabled in a
- flexible way. Rules are specified in text, where every line must have the
- format
+ Logging rules let you enable or disable logging for categories in a flexible
+ way. Rules are specified in text, where every line must have the format:
\snippet code/src_corelib_io_qloggingcategory.cpp 0
\c <category> is the name of the category, potentially with \c{*} as a
- wildcard symbol as the first or last character (or at both positions).
- The optional \c <type> must be either \c debug, \c info, \c warning, or \c critical.
- Lines that do not fit this scheme are ignored.
+ wildcard symbol for the first or last character; or at both positions.
+ The optional \c <type> must be \c debug, \c info, \c warning, or \c critical.
+ Lines that don't fit this scheme are ignored.
Rules are evaluated in text order, from first to last. That is, if two rules
apply to a category/type, the rule that comes later is applied.
@@ -149,47 +150,37 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
\snippet code/src_corelib_io_qloggingcategory.cpp 1
- Since Qt 5.3, logging rules are also
- automatically loaded from the \c [Rules] section of a logging
- configuration file. Such configuration files are looked up in the QtProject
- configuration directory, or explicitly set in a \c QT_LOGGING_CONF
- environment variable:
+ Logging rules are automatically loaded from the \c [Rules] section in a logging
+ configuration file. These configuration files are looked up in the QtProject
+ configuration directory, or explicitly set in a \c QT_LOGGING_CONF environment
+ variable:
\snippet code/src_corelib_io_qloggingcategory.cpp 2
- Since Qt 5.3, logging rules can also be specified in a \c QT_LOGGING_RULES
- environment variable. And since Qt 5.6, multiple rules can also be
- separated by semicolons:
+ Logging rules can also be specified in a \c QT_LOGGING_RULES environment variable;
+ multiple rules can also be separated by semicolons:
\snippet code/src_corelib_io_qloggingcategory.cpp 3
- Rules set by \l setFilterRules() take precedence over rules specified
- in the QtProject configuration directory, and can, in turn, be
- overwritten by rules from the configuration file specified by
- \c QT_LOGGING_CONF, and rules set by \c QT_LOGGING_RULES.
-
- Order of evaluation:
- \list
- \li [QLibraryInfo::DataPath]/qtlogging.ini
- \li QtProject/qtlogging.ini
- \li \l setFilterRules()
- \li \c QT_LOGGING_CONF
- \li \c QT_LOGGING_RULES
+ Rules set by \l setFilterRules() take precedence over rules specified in the
+ QtProject configuration directory. In turn, these rules can be overwritten by those
+ from the configuration file specified by \c QT_LOGGING_CONF, and those set by
+ \c QT_LOGGING_RULES.
+
+ The order of evaluation is as follows:
+ \list 1
+ \li [QLibraryInfo::DataPath]/qtlogging.ini
+ \li QtProject/qtlogging.ini
+ \li \l setFilterRules()
+ \li \c QT_LOGGING_CONF
+ \li \c QT_LOGGING_RULES
\endlist
The \c QtProject/qtlogging.ini file is looked up in all directories returned
- by QStandardPaths::GenericConfigLocation, e.g.
+ by QStandardPaths::GenericConfigLocation.
- \list
- \li on \macos and iOS: \c ~/Library/Preferences
- \li on Unix: \c ~/.config, \c /etc/xdg
- \li on Windows: \c %LOCALAPPDATA%, \c %ProgramData%,
- \l QCoreApplication::applicationDirPath(),
- QCoreApplication::applicationDirPath() + \c "/data"
- \endlist
-
- Set the \c QT_LOGGING_DEBUG environment variable to see from where
- logging rules are loaded.
+ Set the \c QT_LOGGING_DEBUG environment variable to find out where you logging
+ rules are loaded from.
\section2 Installing a Custom Filter
@@ -211,7 +202,7 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
If \a category is \c{0}, the category name is changed to \c "default".
- Note that \a category must be kept valid during the lifetime of this object.
+ \note \a category must be kept valid during the lifetime of this object.
*/
QLoggingCategory::QLoggingCategory(const char *category)
: d(nullptr),
@@ -226,7 +217,7 @@ QLoggingCategory::QLoggingCategory(const char *category)
If \a category is \c{0}, the category name is changed to \c "default".
- Note that \a category must be kept valid during the lifetime of this object.
+ \note \a category must be kept valid during the lifetime of this object.
\since 5.4
*/
@@ -251,7 +242,7 @@ void QLoggingCategory::init(const char *category, QtMsgType severityLevel)
}
/*!
- Destructs a QLoggingCategory object.
+ Destroys a QLoggingCategory object.
*/
QLoggingCategory::~QLoggingCategory()
{
@@ -268,24 +259,24 @@ QLoggingCategory::~QLoggingCategory()
/*!
\fn bool QLoggingCategory::isDebugEnabled() const
- Returns \c true if debug messages should be shown for this category.
- Returns \c false otherwise.
+ Returns \c true if debug messages should be shown for this category;
+ \c false otherwise.
- \note The \l qCDebug() macro already does this check before executing any
- code. However, calling this method may be useful to avoid
- expensive generation of data that is only used for debug output.
+ \note The \l qCDebug() macro already does this check before running any
+ code. However, calling this method may be useful to avoid the
+ expensive generation of data for debug output only.
*/
/*!
\fn bool QLoggingCategory::isInfoEnabled() const
- Returns \c true if informational messages should be shown for this category.
- Returns \c false otherwise.
+ Returns \c true if informational messages should be shown for this category;
+ \c false otherwise.
\note The \l qCInfo() macro already does this check before executing any
- code. However, calling this method may be useful to avoid
- expensive generation of data that is only used for debug output.
+ code. However, calling this method may be useful to avoid the
+ expensive generation of data for debug output only.
\since 5.5
*/
@@ -294,28 +285,28 @@ QLoggingCategory::~QLoggingCategory()
/*!
\fn bool QLoggingCategory::isWarningEnabled() const
- Returns \c true if warning messages should be shown for this category.
- Returns \c false otherwise.
+ Returns \c true if warning messages should be shown for this category;
+ \c false otherwise.
\note The \l qCWarning() macro already does this check before executing any
- code. However, calling this method may be useful to avoid
- expensive generation of data that is only used for debug output.
+ code. However, calling this method may be useful to avoid the
+ expensive generation of data for debug output only.
*/
/*!
\fn bool QLoggingCategory::isCriticalEnabled() const
- Returns \c true if critical messages should be shown for this category.
- Returns \c false otherwise.
+ Returns \c true if critical messages should be shown for this category;
+ \c false otherwise.
\note The \l qCCritical() macro already does this check before executing any
- code. However, calling this method may be useful to avoid
- expensive generation of data that is only used for debug output.
+ code. However, calling this method may be useful to avoid the
+ expensive generation of data for debug output only.
*/
/*!
Returns \c true if a message of type \a msgtype for the category should be
- shown. Returns \c false otherwise.
+ shown; \c false otherwise.
*/
bool QLoggingCategory::isEnabled(QtMsgType msgtype) const
{
@@ -332,11 +323,11 @@ bool QLoggingCategory::isEnabled(QtMsgType msgtype) const
/*!
Changes the message type \a type for the category to \a enable.
- This method is meant to be used only from inside a filter
- installed by \l installFilter(). See \l {Configuring Categories} for
- an overview on how to configure categories globally.
+ This method is meant for use only from inside a filter installed with
+ \l installFilter(). For an overview on how to configure categories globally,
+ see \l {Configuring Categories}.
- \note \c QtFatalMsg cannot be changed. It will always remain \c true.
+ \note \c QtFatalMsg cannot be changed; it will always remain \c true.
*/
void QLoggingCategory::setEnabled(QtMsgType type, bool enable)
{
@@ -359,28 +350,25 @@ void QLoggingCategory::setEnabled(QtMsgType type, bool enable)
/*!
\fn QLoggingCategory &QLoggingCategory::operator()()
- Returns the object itself. This allows both a QLoggingCategory variable, and
- a factory method returning a QLoggingCategory, to be used in \l qCDebug(),
- \l qCWarning(), \l qCCritical() macros.
+ Returns the object itself. This allows for both: a QLoggingCategory variable, and
+ a factory method that returns a QLoggingCategory, to be used in \l qCDebug(),
+ \l qCWarning(), or \l qCCritical() macros.
*/
/*!
\fn const QLoggingCategory &QLoggingCategory::operator()() const
- Returns the object itself. This allows both a QLoggingCategory variable, and
- a factory method returning a QLoggingCategory, to be used in \l qCDebug(),
- \l qCWarning(), \l qCCritical() macros.
+ Returns the object itself. This allows for both: a QLoggingCategory variable, and
+ a factory method that returns a QLoggingCategory, to be used in \l qCDebug(),
+ \l qCWarning(), or \l qCCritical() macros.
*/
/*!
- Returns a pointer to the global category \c "default" that
- is used e.g. by qDebug(), qInfo(), qWarning(), qCritical(), qFatal().
+ Returns a pointer to the global category \c "default" that is used, for
+ example, by qDebug(), qInfo(), qWarning(), qCritical(), or qFatal().
- \note The returned pointer may be null during destruction of
- static objects.
-
- \note Ownership of the category is not transferred, do not
- \c delete the returned pointer.
+ \note The pointer returned may be null during destruction of static objects.
+ Also, don't \c delete this pointer, as ownership of the category isn't transferred.
*/
QLoggingCategory *QLoggingCategory::defaultCategory()
@@ -391,8 +379,7 @@ QLoggingCategory *QLoggingCategory::defaultCategory()
/*!
\typedef QLoggingCategory::CategoryFilter
- This is a typedef for a pointer to a function with the following
- signature:
+ This is a typedef for a pointer to a function with the following signature:
\snippet qloggingcategory/main.cpp 20
@@ -408,14 +395,13 @@ QLoggingCategory *QLoggingCategory::defaultCategory()
filter is free to change the respective category configuration with
\l setEnabled().
- The filter might be called from different threads, but never concurrently.
- The filter shall not call any static functions of QLoggingCategory.
+ When you define your filter, note that it can be called from different threads; but never
+ concurrently. This filter cannot call any static functions from QLoggingCategory.
Example:
\snippet qloggingcategory/main.cpp 21
- An alternative way of configuring the default filter is via
- \l setFilterRules().
+ Alternatively, you can configure the default filter via \l setFilterRules().
*/
QLoggingCategory::CategoryFilter
QLoggingCategory::installFilter(QLoggingCategory::CategoryFilter filter)
@@ -425,15 +411,15 @@ QLoggingCategory::installFilter(QLoggingCategory::CategoryFilter filter)
/*!
Configures which categories and message types should be enabled through a
- a set of \a rules.
+ set of \a rules.
Example:
\snippet qloggingcategory/main.cpp 2
\note The rules might be ignored if a custom category filter is installed
- with \l installFilter(), or if the user defined \c QT_LOGGING_CONF or \c QT_LOGGING_RULES
- environment variable.
+ with \l installFilter(), or if the user has defined the \c QT_LOGGING_CONF
+ or the \c QT_LOGGING_RULES environment variable.
*/
void QLoggingCategory::setFilterRules(const QString &rules)
{
@@ -446,7 +432,7 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\threadsafe
\since 5.2
- Returns an output stream for debug messages in the logging category
+ Returns an output stream for debug messages in the logging category,
\a category.
The macro expands to code that checks whether
@@ -457,8 +443,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\snippet qloggingcategory/main.cpp 10
- \note Arguments are not processed if debug output for the category is not
- enabled, so do not rely on any side effects.
+ \note Arguments aren't processed if the debug output for that \a category is not
+ enabled, so don't rely on any side effects.
\sa qDebug()
*/
@@ -469,16 +455,16 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\threadsafe
\since 5.3
- Logs a debug message \a message in the logging category \a category.
- \a message might contain place holders that are replaced by additional
- arguments, similar to the C printf() function.
+ Logs a debug message, \a message, in the logging category, \a category.
+ \a message may contain place holders to be replaced by additional arguments,
+ similar to the C printf() function.
Example:
\snippet qloggingcategory/main.cpp 13
- \note Arguments might not be processed if debug output for the category is
- not enabled, so do not rely on any side effects.
+ \note Arguments aren't processed if the debug output for that \a category is not
+ enabled, so don't rely on any side effects.
\sa qDebug()
*/
@@ -489,7 +475,7 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\threadsafe
\since 5.5
- Returns an output stream for informational messages in the logging category
+ Returns an output stream for informational messages in the logging category,
\a category.
The macro expands to code that checks whether
@@ -500,8 +486,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\snippet qloggingcategory/main.cpp qcinfo_stream
- \note Arguments are not processed if debug output for the category is not
- enabled, so do not rely on any side effects.
+ \note If the debug output for a particular category isn't enabled, arguments
+ won't be processed, so don't rely on any side effects.
\sa qInfo()
*/
@@ -512,16 +498,16 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\threadsafe
\since 5.5
- Logs an informational message \a message in the logging category \a category.
- \a message might contain place holders that are replaced by additional
- arguments, similar to the C printf() function.
+ Logs an informational message, \a message, in the logging category, \a category.
+ \a message may contain place holders to be replaced by additional arguments,
+ similar to the C printf() function.
Example:
\snippet qloggingcategory/main.cpp qcinfo_printf
- \note Arguments might not be processed if debug output for the category is
- not enabled, so do not rely on any side effects.
+ \note If the debug output for a particular category isn't enabled, arguments
+ won't be processed, so don't rely on any side effects.
\sa qInfo()
*/
@@ -532,7 +518,7 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\threadsafe
\since 5.2
- Returns an output stream for warning messages in the logging category
+ Returns an output stream for warning messages in the logging category,
\a category.
The macro expands to code that checks whether
@@ -543,8 +529,8 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\snippet qloggingcategory/main.cpp 11
- \note Arguments are not processed if warning output for the category is not
- enabled, so do not rely on any side effects.
+ \note If the warning output for a particular category isn't enabled, arguments
+ won't be processed, so don't rely on any side effects.
\sa qWarning()
*/
@@ -555,16 +541,16 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\threadsafe
\since 5.3
- Logs a warning message \a message in the logging category \a category.
- \a message might contain place holders that are replaced by additional
- arguments, similar to the C printf() function.
+ Logs a warning message, \a message, in the logging category, \a category.
+ \a message may contain place holders to be replaced by additional arguments,
+ similar to the C printf() function.
Example:
\snippet qloggingcategory/main.cpp 14
- \note Arguments might not be processed if warning output for the category is
- not enabled, so do not rely on any side effects.
+ \note If the warning output for a particular category isn't enabled, arguments
+ won't be processed, so don't rely on any side effects.
\sa qWarning()
*/
@@ -575,7 +561,7 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\threadsafe
\since 5.2
- Returns an output stream for critical messages in the logging category
+ Returns an output stream for critical messages in the logging category,
\a category.
The macro expands to code that checks whether
@@ -586,8 +572,9 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\snippet qloggingcategory/main.cpp 12
- \note Arguments are not processed if critical output for the category is not
- enabled, so do not rely on any side effects.
+
+ \note If the critical output for a particular category isn't enabled, arguments
+ won't be processed, so don't rely on any side effects.
\sa qCritical()
*/
@@ -598,16 +585,16 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\threadsafe
\since 5.3
- Logs a critical message \a message in the logging category \a category.
- \a message might contain place holders that are replaced by additional
- arguments, similar to the C printf() function.
+ Logs a critical message, \a message, in the logging category, \a category.
+ \a message may contain place holders to be replaced by additional arguments,
+ similar to the C printf() function.
Example:
\snippet qloggingcategory/main.cpp 15
- \note Arguments might not be processed if critical output for the category
- is not enabled, so do not rely on any side effects.
+ \note If the critical output for a particular category isn't enabled, arguments
+ won't be processed, so don't rely on any side effects.
\sa qCritical()
*/
@@ -633,7 +620,7 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\a string identifier. By default, all message types are enabled.
Only one translation unit in a library or executable can define a category
- with a specific name. The implicitly defined QLoggingCategory object is
+ with a specific name. The implicitly-defined QLoggingCategory object is
created on first use, in a thread-safe manner.
This macro must be used outside of a class or method.
@@ -650,7 +637,7 @@ void QLoggingCategory::setFilterRules(const QString &rules)
and more severe are enabled, types with a lower severity are disabled.
Only one translation unit in a library or executable can define a category
- with a specific name. The implicitly defined QLoggingCategory object is
+ with a specific name. The implicitly-defined QLoggingCategory object is
created on first use, in a thread-safe manner.
This macro must be used outside of a class or method. It is only defined
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 22c22ce711..86d361b06a 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -1109,14 +1109,8 @@ bool QDynamicFileResourceRoot::registerSelf(const QString &f)
uchar *data = nullptr;
qsizetype data_len = 0;
-#ifdef QT_USE_MMAP
- int fd = QT_OPEN(QFile::encodeName(f), O_RDONLY,
-#if defined(Q_OS_WIN)
- _S_IREAD | _S_IWRITE
-#else
- 0666
-#endif
- );
+#if defined(QT_USE_MMAP)
+ int fd = QT_OPEN(QFile::encodeName(f), O_RDONLY, 0666);
if (fd >= 0) {
QT_STATBUF st;
if (!QT_FSTAT(fd, &st) && st.st_size <= std::numeric_limits<qsizetype>::max()) {
diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp
index f41e6302a2..0a884a7df9 100644
--- a/src/corelib/io/qsavefile.cpp
+++ b/src/corelib/io/qsavefile.cpp
@@ -243,9 +243,15 @@ bool QSaveFile::open(OpenMode mode)
return false;
};
+ bool requiresDirectWrite = false;
#ifdef Q_OS_WIN
// check if it is an Alternate Data Stream
- if (d->finalFileName == d->fileName && d->fileName.indexOf(QLatin1Char(':'), 2) > 1) {
+ requiresDirectWrite = d->finalFileName == d->fileName && d->fileName.indexOf(QLatin1Char(':'), 2) > 1;
+#elif defined(Q_OS_ANDROID)
+ // check if it is a content:// URL
+ requiresDirectWrite = d->fileName.startsWith(QLatin1String("content://"));
+#endif
+ if (requiresDirectWrite) {
// yes, we can't rename onto it...
if (d->directWriteFallback) {
if (openDirectly())
@@ -254,14 +260,12 @@ bool QSaveFile::open(OpenMode mode)
d->fileEngine.reset();
} else {
QString msg =
- QSaveFile::tr("QSaveFile cannot open '%1' without direct write fallback "
- "enabled: path contains an Alternate Data Stream specifier")
- .arg(QDir::toNativeSeparators(d->fileName));
+ QSaveFile::tr("QSaveFile cannot open '%1' without direct write fallback enabled.")
+ .arg(QDir::toNativeSeparators(d->fileName));
d->setError(QFileDevice::OpenError, msg);
}
return false;
}
-#endif
d->fileEngine.reset(new QTemporaryFileEngine(&d->finalFileName, QTemporaryFileEngine::Win32NonShared));
// if the target file exists, we'll copy its permissions below,
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 4a119a1e2f..fc7122d904 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -746,7 +746,6 @@ bool QSettingsPrivate::iniUnescapedStringList(const QByteArray &str, int from, i
{ '\'', '\'' },
{ '\\', '\\' }
};
- static const int numEscapeCodes = sizeof(escapeCodes) / sizeof(escapeCodes[0]);
bool isStringList = false;
bool inQuotedString = false;
@@ -770,9 +769,9 @@ StNormal:
goto end;
ch = str.at(i++);
- for (int j = 0; j < numEscapeCodes; ++j) {
- if (ch == escapeCodes[j][0]) {
- stringResult += QLatin1Char(escapeCodes[j][1]);
+ for (const auto &escapeCode : escapeCodes) {
+ if (ch == escapeCode[0]) {
+ stringResult += QLatin1Char(escapeCode[1]);
goto StNormal;
}
}
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index f56fef7f8e..7874b854e4 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -232,7 +232,7 @@ QT_BEGIN_NAMESPACE
\row \li DocumentsLocation
\li "~/Documents"
\row \li FontsLocation
- \li "~/.fonts"
+ \li "~/.fonts", "~/.local/share/fonts", "/usr/local/share/fonts", "/usr/share/fonts"
\row \li ApplicationsLocation
\li "~/.local/share/applications", "/usr/local/share/applications", "/usr/share/applications"
\row \li MusicLocation
@@ -345,6 +345,8 @@ QT_BEGIN_NAMESPACE
\note On Android, applications with open files on the external storage (<USER> locations),
will be killed if the external storage is unmounted.
+ \note On Android, reading/writing to GenericDataLocation needs the READ_EXTERNAL_STORAGE/WRITE_EXTERNAL_STORAGE permission granted.
+
\note On iOS, if you do pass \c {QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()}
as argument to \l{QFileDialog::setDirectory()},
a native image picker dialog will be used for accessing the user's photo album.
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index 6425890e3f..c35d7adc9f 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -339,6 +339,9 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
break;
case FontsLocation:
dirs += QDir::homePath() + QLatin1String("/.fonts");
+ dirs += xdgDataDirs();
+ for (int i = 1; i < dirs.count(); ++i)
+ dirs[i].append(QLatin1String("/fonts"));
break;
default:
break;
diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp
index 912609ec91..fc3e16b241 100644
--- a/src/corelib/io/qtldurl.cpp
+++ b/src/corelib/io/qtldurl.cpp
@@ -125,10 +125,10 @@ Q_CORE_EXPORT bool qIsEffectiveTLD(const QStringRef &domain)
return true;
const int dot = domain.indexOf(QLatin1Char('.'));
- if (dot >= 0) {
- if (containsTLDEntry(domain.mid(dot), SuffixMatch)) // 2
- return !containsTLDEntry(domain, ExceptionMatch); // 3
- }
+ if (dot < 0) // Actual TLD: may be effective if the subject of a wildcard rule:
+ return containsTLDEntry(QString(QLatin1Char('.') + domain), SuffixMatch);
+ if (containsTLDEntry(domain.mid(dot), SuffixMatch)) // 2
+ return !containsTLDEntry(domain, ExceptionMatch); // 3
return false;
}
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 878e007fb0..a7650390f9 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -979,7 +979,7 @@ inline bool QUrlPrivate::setScheme(const QString &value, int len, bool doSetErro
// validate it:
int needsLowercasing = -1;
- const ushort *p = reinterpret_cast<const ushort *>(value.constData());
+ const ushort *p = value.utf16();
for (int i = 0; i < len; ++i) {
if (p[i] >= 'a' && p[i] <= 'z')
continue;