diff options
author | Liang Qi <liang.qi@qt.io> | 2018-02-16 08:07:08 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2018-02-16 22:31:50 +0000 |
commit | 048d8dee52545a9b0a548b4c56958a75a99d9aee (patch) | |
tree | c549685860a49e71809e06e90cc0fa6031a2def1 /src/corelib/io | |
parent | 6ffb358822db2e0d30fb34853c3222cd866d57c5 (diff) | |
parent | 942ab490724fcc9544e786e5783718e1a07aa50b (diff) |
Merge "Merge remote-tracking branch 'origin/5.11' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/QTEMPORARYFILE_LICENSE.txt | 26 | ||||
-rw-r--r-- | src/corelib/io/io.pri | 2 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_unix.cpp | 5 | ||||
-rw-r--r-- | src/corelib/io/qloggingregistry.cpp | 10 | ||||
-rw-r--r-- | src/corelib/io/qprocess_win.cpp | 3 | ||||
-rw-r--r-- | src/corelib/io/qsavefile.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qsettings.cpp | 5 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_android.cpp | 15 | ||||
-rw-r--r-- | src/corelib/io/qt_attribution.json | 15 | ||||
-rw-r--r-- | src/corelib/io/qtemporaryfile.cpp | 11 | ||||
-rw-r--r-- | src/corelib/io/qtemporaryfile_p.h | 7 | ||||
-rw-r--r-- | src/corelib/io/qurlrecode.cpp | 4 |
12 files changed, 49 insertions, 56 deletions
diff --git a/src/corelib/io/QTEMPORARYFILE_LICENSE.txt b/src/corelib/io/QTEMPORARYFILE_LICENSE.txt deleted file mode 100644 index f5f1a2e05e..0000000000 --- a/src/corelib/io/QTEMPORARYFILE_LICENSE.txt +++ /dev/null @@ -1,26 +0,0 @@ -Copyright (c) 1987, 1993 - The Regents of the University of California. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of the University nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index c6a5973306..d138ab2f00 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -159,7 +159,7 @@ win32 { } else { LIBS += -framework MobileCoreServices } - } else:android { + } else:android:!android-embedded { SOURCES += \ io/qstandardpaths_android.cpp \ io/qstorageinfo_unix.cpp diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 7dd4f6556d..bc39ea73ee 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -185,10 +185,11 @@ bool QFSFileEnginePrivate::nativeFlush() bool QFSFileEnginePrivate::nativeSyncToDisk() { Q_Q(QFSFileEngine); + int ret; #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0 - const int ret = fdatasync(nativeHandle()); + EINTR_LOOP(ret, fdatasync(nativeHandle())); #else - const int ret = fsync(nativeHandle()); + EINTR_LOOP(ret, fsync(nativeHandle())); #endif if (ret != 0) q->setError(QFile::WriteError, qt_error_string(errno)); diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index b5f8e30b80..cd97268d71 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -44,6 +44,7 @@ #include <QtCore/qstandardpaths.h> #include <QtCore/qtextstream.h> #include <QtCore/qdir.h> +#include <QtCore/qcoreapplication.h> // We can't use the default macros because this would lead to recursion. // Instead let's define our own one that unconditionally logs... @@ -255,6 +256,15 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line) QLoggingRegistry::QLoggingRegistry() : categoryFilter(defaultCategoryFilter) { +#if defined(Q_OS_ANDROID) + // Unless QCoreApplication has been constructed we can't be sure that + // we are on Qt's main thread. If we did allow logging here, we would + // potentially set Qt's main thread to Android's thread 0, which would + // confuse Qt later when running main(). + if (!qApp) + return; +#endif + initializeRules(); // Init on first use } diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 6ab806d9fe..3a62a67e3b 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -101,7 +101,8 @@ static void qt_create_pipe(Q_PIPE *pipe, bool isInputPipe) unsigned int attempts = 1000; forever { _snwprintf(pipeName, sizeof(pipeName) / sizeof(pipeName[0]), - L"\\\\.\\pipe\\qt-%X", QRandomGenerator::global()->generate()); + L"\\\\.\\pipe\\qt-%lX-%X", long(QCoreApplication::applicationPid()), + QRandomGenerator::global()->generate()); DWORD dwOpenMode = FILE_FLAG_OVERLAPPED; DWORD dwOutputBufferSize = 0; diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp index 56934a9a0f..0cbc8c2234 100644 --- a/src/corelib/io/qsavefile.cpp +++ b/src/corelib/io/qsavefile.cpp @@ -264,7 +264,7 @@ bool QSaveFile::open(OpenMode mode) } #endif - d->fileEngine = new QTemporaryFileEngine(&d->finalFileName); + d->fileEngine = new QTemporaryFileEngine(&d->finalFileName, QTemporaryFileEngine::Win32NonShared); // if the target file exists, we'll copy its permissions below, // but until then, let's ensure the temporary file is not accessible // to a third party diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index bbc66120b5..4b1b9888d8 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -2366,6 +2366,11 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, limitations is to store the settings using the IniFormat instead of the NativeFormat. + \li On Windows, when the Windows system registry is used, QSettings + does not preserve the original type of the value. Therefore, + the type of the value might change when a new value is set. For + example, a value with type \c REG_EXPAND_SZ will change to \c REG_SZ. + \li On \macos and iOS, allKeys() will return some extra keys for global settings that apply to all applications. These keys can be read using value() but cannot be changed, only shadowed. diff --git a/src/corelib/io/qstandardpaths_android.cpp b/src/corelib/io/qstandardpaths_android.cpp index 2a44daf8b5..0667d170c7 100644 --- a/src/corelib/io/qstandardpaths_android.cpp +++ b/src/corelib/io/qstandardpaths_android.cpp @@ -217,7 +217,16 @@ static QString getFilesDir() if (!path.isEmpty()) return path; - return (path = QDir::homePath()); + QJNIObjectPrivate appCtx = applicationContext(); + if (!appCtx.isValid()) + return QString(); + + QJNIObjectPrivate file = appCtx.callObjectMethod("getFilesDir", + "()Ljava/io/File;"); + if (!file.isValid()) + return QString(); + + return (path = getAbsolutePath(file)); } QString QStandardPaths::writableLocation(StandardLocation type) @@ -319,7 +328,9 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) if (!ba.isEmpty()) return QStringList((fontLocation = QDir::cleanPath(QString::fromLocal8Bit(ba)))); - return QStringList((fontLocation = QLatin1String("/system/fonts"))); + // Don't cache the fallback, as we might just have been called before + // QT_ANDROID_FONT_LOCATION has been set. + return QStringList(QLatin1String("/system/fonts")); } return QStringList(writableLocation(type)); diff --git a/src/corelib/io/qt_attribution.json b/src/corelib/io/qt_attribution.json index 0fa4502db4..e9eb9c85e4 100644 --- a/src/corelib/io/qt_attribution.json +++ b/src/corelib/io/qt_attribution.json @@ -1,17 +1,3 @@ -[ -{ - "Id": "qtemporaryfile", - "Name": "Parts of QTemporaryFile", - "QDocModule": "qtcore", - "QtUsage": "Used in Qt Core. Disable the qtemporaryfile feature to avoid.", - "Path": "qtemporaryfile.cpp", - - "Description": "Generates a unique file path and returns a native handle to the open file.", - "License": "BSD 3-clause \"New\" or \"Revised\" License", - "LicenseId": "BSD-3-Clause", - "LicenseFile": "QTEMPORARYFILE_LICENSE.txt", - "Copyright": "Copyright (c) 1987, 1993 The Regents of the University of California." -}, { "Id": "psl", "Name": "The Public Suffix List", @@ -39,4 +25,3 @@ supported by Qt (by the QNetworkCookieJar class).", "Copyright": "The list was originally provided by Jo Hermans <jo.hermans@gmail.com>. It is now maintained on github (https://github.com/publicsuffix/list)." } -] diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 73249d7df8..1983a22c65 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -207,7 +207,7 @@ QFileSystemEntry::NativePath QTemporaryFileName::generateNext() changed and contain the generated path name. */ static bool createFileFromTemplate(NativeFileHandle &file, QTemporaryFileName &templ, - quint32 mode, QSystemError &error) + quint32 mode, int flags, QSystemError &error) { const int maxAttempts = 16; for (int attempt = 0; attempt < maxAttempts; ++attempt) { @@ -216,16 +216,18 @@ static bool createFileFromTemplate(NativeFileHandle &file, QTemporaryFileName &t #if defined(Q_OS_WIN) Q_UNUSED(mode); + const DWORD shareMode = (flags & QTemporaryFileEngine::Win32NonShared) + ? 0u : (FILE_SHARE_READ | FILE_SHARE_WRITE); # ifndef Q_OS_WINRT file = CreateFile((const wchar_t *)path.constData(), GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_NEW, + shareMode, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); # else // !Q_OS_WINRT file = CreateFile2((const wchar_t *)path.constData(), GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, CREATE_NEW, + shareMode, CREATE_NEW, NULL); # endif // Q_OS_WINRT @@ -247,6 +249,7 @@ static bool createFileFromTemplate(NativeFileHandle &file, QTemporaryFileName &t return false; } #else // POSIX + Q_UNUSED(flags) file = QT_OPEN(path.constData(), QT_OPEN_CREAT | QT_OPEN_EXCL | QT_OPEN_RDWR | QT_OPEN_LARGEFILE, static_cast<mode_t>(mode)); @@ -366,7 +369,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) unnamedFile = true; d->fileEntry.clear(); } else if (st == CreateUnnamedFileStatus::NotSupported && - createFileFromTemplate(file, tfn, fileMode, error)) { + createFileFromTemplate(file, tfn, fileMode, flags, error)) { filePathIsTemplate = false; unnamedFile = false; d->fileEntry = QFileSystemEntry(tfn.path, QFileSystemEntry::FromNativePath()); diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h index fb8887af53..0fec88d3cd 100644 --- a/src/corelib/io/qtemporaryfile_p.h +++ b/src/corelib/io/qtemporaryfile_p.h @@ -108,8 +108,10 @@ class QTemporaryFileEngine : public QFSFileEngine { Q_DECLARE_PRIVATE(QFSFileEngine) public: - QTemporaryFileEngine(const QString *templateName) - : templateName(*templateName) + enum Flags { Win32NonShared = 0x1 }; + + explicit QTemporaryFileEngine(const QString *_templateName, int _flags = 0) + : templateName(*_templateName), flags(_flags) {} void initialize(const QString &file, quint32 mode, bool nameIsTemplate = true) @@ -144,6 +146,7 @@ public: const QString &templateName; quint32 fileMode; + int flags = 0; bool filePathIsTemplate; bool filePathWasTemplate; bool unnamedFile = false; diff --git a/src/corelib/io/qurlrecode.cpp b/src/corelib/io/qurlrecode.cpp index ce90ab49d3..a9b23babc0 100644 --- a/src/corelib/io/qurlrecode.cpp +++ b/src/corelib/io/qurlrecode.cpp @@ -511,7 +511,7 @@ static int decode(QString &appendTo, const ushort *begin, const ushort *end) if (Q_UNLIKELY(end - input < 3 || !isHex(input[1]) || !isHex(input[2]))) { // badly-encoded data appendTo.resize(origSize + (end - begin)); - memcpy(appendTo.begin() + origSize, begin, (end - begin) * sizeof(ushort)); + memcpy(static_cast<void *>(appendTo.begin() + origSize), static_cast<const void *>(begin), (end - begin) * sizeof(ushort)); return end - begin; } @@ -519,7 +519,7 @@ static int decode(QString &appendTo, const ushort *begin, const ushort *end) // detach appendTo.resize(origSize + (end - begin)); output = reinterpret_cast<ushort *>(appendTo.begin()) + origSize; - memcpy(output, begin, (input - begin) * sizeof(ushort)); + memcpy(static_cast<void *>(output), static_cast<const void *>(begin), (input - begin) * sizeof(ushort)); output += input - begin; } |