summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/arch/arch.pri2
-rw-r--r--src/corelib/arch/qatomic_cxx11.h2
-rw-r--r--src/corelib/configure.json254
-rw-r--r--src/corelib/corelib.pro10
-rw-r--r--src/corelib/global/qcompilerdetection.h3
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp13
-rw-r--r--src/corelib/io/qfilesystemwatcher_kqueue.cpp3
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp9
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp14
-rw-r--r--src/corelib/io/qsavefile.cpp6
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp10
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp4
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.h4
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel_p.h3
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp3
-rw-r--r--src/corelib/tools/qhash.h16
-rw-r--r--src/corelib/tools/qlocale.cpp2
17 files changed, 270 insertions, 88 deletions
diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri
index b628bcc6ec..e490617c6b 100644
--- a/src/corelib/arch/arch.pri
+++ b/src/corelib/arch/arch.pri
@@ -4,4 +4,4 @@ HEADERS += \
arch/qatomic_bootstrap.h \
arch/qatomic_cxx11.h
-qtConfig(libatomic): QMAKE_USE += libatomic
+qtConfig(std-atomic64): QMAKE_USE += libatomic
diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/arch/qatomic_cxx11.h
index 484ec73e7f..1404849382 100644
--- a/src/corelib/arch/qatomic_cxx11.h
+++ b/src/corelib/arch/qatomic_cxx11.h
@@ -187,7 +187,7 @@ template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<2>::isLockFree()
{ return false; }
#endif
-#ifndef QT_NO_STD_ATOMIC64
+#if QT_CONFIG(std_atomic64)
template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; };
# define Q_ATOMIC_INT64_IS_SUPPORTED
# if ATOMIC_LLONG_LOCK_FREE == 2
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index 7e5a7b8fde..44d6ccfdf5 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -22,14 +22,26 @@
"libraries": {
"doubleconversion": {
"label": "DoubleConversion",
- "test": "unix/doubleconversion",
+ "test": {
+ "include": "double-conversion/double-conversion.h",
+ "main": "(void) double_conversion::StringToDoubleConverter::NO_FLAGS;"
+ },
"sources": [
"-ldouble-conversion"
]
},
"glib": {
"label": "GLib",
- "test": "unix/glib",
+ "test": {
+ "head": "typedef struct _GMainContext GMainContext;",
+ "include": "glib.h",
+ "main": [
+ "g_thread_init(NULL);",
+ "(void) g_main_context_default();",
+ "(void) g_source_new(0, 0);",
+ "g_source_add_poll(NULL, NULL);"
+ ]
+ },
"sources": [
{ "type": "pkgConfig", "args": "glib-2.0 gthread-2.0" }
]
@@ -37,14 +49,29 @@
"gnu_iconv": {
"label": "GNU libiconv",
"export": "iconv",
- "test": "unix/gnu-libiconv",
+ "test": "gnu-libiconv",
"sources": [
"-liconv"
]
},
"icu": {
"label": "ICU",
- "test": "unix/icu",
+ "test": {
+ "include": [ "unicode/utypes.h", "unicode/ucol.h", "unicode/ustring.h" ],
+ "main": [
+ "UErrorCode status = U_ZERO_ERROR;",
+ "UCollator *collator = ucol_open(\"ru_RU\", &status);",
+ "if (!U_FAILURE(status))",
+ " ucol_close(collator);"
+ ],
+ "qmake": [
+ "CONFIG += build_all",
+ "CONFIG(debug, debug|release): \\",
+ " LIBS += $$LIBS_DEBUG",
+ "else: \\",
+ " LIBS += $$LIBS_RELEASE"
+ ]
+ },
"sources": [
{
"builds": {
@@ -62,22 +89,48 @@
},
"journald": {
"label": "journald",
- "test": "unix/journald",
+ "test": {
+ "include": [ "systemd/sd-journal.h", "syslog.h" ],
+ "main": "sd_journal_send(\"PRIORITY=%i\", LOG_INFO, NULL);"
+ },
"sources": [
{ "type": "pkgConfig", "args": "libsystemd" },
{ "type": "pkgConfig", "args": "libsystemd-journal" }
]
},
"libatomic": {
- "label": "64 bit atomics in libatomic",
- "test": "common/atomic64",
+ "label": "64 bit atomics",
+ "test": {
+ "include": [ "atomic", "cstdint" ],
+ "tail": [
+ "void test(volatile std::atomic<std::int64_t> &a)",
+ "{",
+ " std::int64_t v = a.load(std::memory_order_acquire);",
+ " while (!a.compare_exchange_strong(v, v + 1,",
+ " std::memory_order_acq_rel,",
+ " std::memory_order_acquire)) {",
+ " v = a.exchange(v - 1);",
+ " }",
+ " a.store(v + 1, std::memory_order_release);",
+ "}"
+ ],
+ "main": [
+ "void *ptr = (void*)0xffffffc0; // any random pointer",
+ "test(*reinterpret_cast<std::atomic<std::int64_t> *>(ptr));"
+ ],
+ "qmake": "CONFIG += c++11"
+ },
"sources": [
+ "",
"-latomic"
]
},
"libdl": {
"label": "dlopen()",
- "test": "unix/dlopen",
+ "test": {
+ "include": "dlfcn.h",
+ "main": "dlopen(0, 0);"
+ },
"sources": [
"",
"-ldl"
@@ -85,7 +138,10 @@
},
"librt": {
"label": "clock_gettime()",
- "test": "unix/clock-gettime",
+ "test": {
+ "include": [ "unistd.h", "time.h" ],
+ "main": "timespec ts; clock_gettime(CLOCK_REALTIME, &ts);"
+ },
"sources": [
"",
"-lrt"
@@ -93,21 +149,38 @@
},
"pcre2": {
"label": "PCRE2",
- "test": "unix/pcre2",
+ "test": {
+ "head": "#define PCRE2_CODE_UNIT_WIDTH 16",
+ "include": "pcre2.h",
+ "tail": [
+ "#if (PCRE2_MAJOR < 10) || ((PCRE2_MAJOR == 10) && (PCRE2_MINOR < 20))",
+ "# error This PCRE version is not supported",
+ "#endif"
+ ]
+ },
"sources": [
"-lpcre2-16"
]
},
"pps": {
"label": "PPS",
- "test": "unix/pps",
+ "test": {
+ "include": "sys/pps.h",
+ "main": [
+ "pps_decoder_t decoder;",
+ "pps_decoder_initialize(&decoder, NULL);"
+ ]
+ },
"sources": [
"-lpps"
]
},
"slog2": {
"label": "slog2",
- "test": "unix/slog2",
+ "test": {
+ "include": "slog2.h",
+ "main": "slog2_set_default_buffer((slog2_buffer_t)-1);"
+ },
"export": "",
"sources": [
"-lslog2"
@@ -116,26 +189,67 @@
},
"tests": {
- "atomic64": {
- "label": "64 bit atomics",
- "type": "compile",
- "test": "common/atomic64"
- },
"atomicfptr": {
"label": "working std::atomic for function pointers",
"type": "compile",
- "test": "common/atomicfptr"
+ "test": {
+ "include": "atomic",
+ "tail": [
+ "typedef void (*fptr)(int);",
+ "typedef std::atomic<fptr> atomicfptr;",
+ "void testfunction(int) { }",
+ "void test(volatile atomicfptr &a)",
+ "{",
+ " fptr v = a.load(std::memory_order_acquire);",
+ " while (!a.compare_exchange_strong(v, &testfunction,",
+ " std::memory_order_acq_rel,",
+ " std::memory_order_acquire)) {",
+ " v = a.exchange(&testfunction);",
+ " }",
+ " a.store(&testfunction, std::memory_order_release);",
+ "}"
+ ],
+ "main": [
+ "atomicfptr fptr(testfunction);",
+ "test(fptr);"
+ ],
+ "qmake": "CONFIG += c++11"
+ }
},
"clock-monotonic": {
"label": "POSIX monotonic clock",
"type": "compile",
- "test": "unix/clock-monotonic",
+ "test": {
+ "include": [ "unistd.h", "time.h" ],
+ "main": [
+ "#if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK-0 >= 0)",
+ "timespec ts;",
+ "clock_gettime(CLOCK_MONOTONIC, &ts);",
+ "#else",
+ "# error Feature _POSIX_MONOTONIC_CLOCK not available",
+ "#endif"
+ ]
+ },
"use": "librt"
},
"cloexec": {
"label": "O_CLOEXEC",
"type": "compile",
- "test": "unix/cloexec"
+ "test": {
+ "head": "#define _GNU_SOURCE 1",
+ "include": [ "sys/types.h", "sys/socket.h", "fcntl.h", "unistd.h" ],
+ "main": [
+ "int pipes[2];",
+ "(void) pipe2(pipes, O_CLOEXEC | O_NONBLOCK);",
+ "(void) fcntl(0, F_DUPFD_CLOEXEC, 0);",
+ "(void) dup3(0, 3, O_CLOEXEC);",
+ "#if defined(__NetBSD__)",
+ "(void) paccept(0, 0, 0, NULL, SOCK_CLOEXEC | SOCK_NONBLOCK);",
+ "#else",
+ "(void) accept4(0, 0, 0, SOCK_CLOEXEC | SOCK_NONBLOCK);",
+ "#endif"
+ ]
+ }
},
"cxx11_random": {
"label": "C++11 <random>",
@@ -145,7 +259,15 @@
"eventfd": {
"label": "eventfd",
"type": "compile",
- "test": "unix/eventfd"
+ "test": {
+ "include": "sys/eventfd.h",
+ "main": [
+ "eventfd_t value;",
+ "int fd = eventfd(0, EFD_CLOEXEC);",
+ "eventfd_read(fd, &value);",
+ "eventfd_write(fd, value);"
+ ]
+ }
},
"futimens": {
"label": "futimens()",
@@ -175,57 +297,104 @@
"posix-iconv": {
"label": "POSIX iconv",
"type": "compile",
- "test": "unix/iconv"
+ "test": "iconv"
},
"sun-iconv": {
"label": "SUN libiconv",
"type": "compile",
- "test": "unix/sun-libiconv"
+ "test": "sun-libiconv"
},
"inotify": {
"label": "inotify",
"type": "compile",
- "test": "unix/inotify"
+ "test": {
+ "include": "sys/inotify.h",
+ "main": [
+ "inotify_init();",
+ "inotify_add_watch(0, \"foobar\", IN_ACCESS);",
+ "inotify_rm_watch(0, 1);"
+ ]
+ }
},
"ipc_sysv": {
"label": "SysV IPC",
"type": "compile",
- "test": "unix/ipc_sysv"
+ "test": {
+ "include": [ "sys/types.h", "sys/ipc.h", "sys/sem.h", "sys/shm.h", "fcntl.h" ],
+ "main": [
+ "key_t unix_key = ftok(\"test\", 'Q');",
+ "semctl(semget(unix_key, 1, 0666 | IPC_CREAT | IPC_EXCL), 0, IPC_RMID, 0);",
+ "shmget(unix_key, 0, 0666 | IPC_CREAT | IPC_EXCL);",
+ "shmctl(0, 0, (struct shmid_ds *)(0));"
+ ]
+ }
},
"ipc_posix": {
"label": "POSIX IPC",
"type": "compile",
- "test": "unix/ipc_posix"
- },
- "journald": {
- "label": "journald",
- "type": "compile",
- "test": "unix/journald"
+ "test": {
+ "include": [ "sys/types.h", "sys/mman.h", "semaphore.h", "fcntl.h" ],
+ "main": [
+ "sem_close(sem_open(\"test\", O_CREAT | O_EXCL, 0666, 0));",
+ "shm_open(\"test\", O_RDWR | O_CREAT | O_EXCL, 0666);",
+ "shm_unlink(\"test\");"
+ ],
+ "qmake": "linux: LIBS += -lpthread -lrt"
+ }
},
"ppoll": {
"label": "ppoll()",
"type": "compile",
- "test": "unix/ppoll"
+ "test": {
+ "include": [ "signal.h", "poll.h" ],
+ "main": [
+ "struct pollfd pfd;",
+ "struct timespec ts;",
+ "sigset_t sig;",
+ "ppoll(&pfd, 1, &ts, &sig);"
+ ]
+ }
},
"pollts": {
"label": "pollts()",
"type": "compile",
- "test": "unix/pollts"
+ "test": {
+ "include": [ "poll.h", "signal.h", "time.h" ],
+ "main": [
+ "struct pollfd pfd;",
+ "struct timespec ts;",
+ "sigset_t sig;",
+ "pollts(&pfd, 1, &ts, &sig);"
+ ]
+ }
},
"poll": {
"label": "poll()",
"type": "compile",
- "test": "unix/poll"
+ "test": {
+ "include": "poll.h",
+ "main": [
+ "struct pollfd pfd;",
+ "poll(&pfd, 1, 0);"
+ ]
+ }
},
"syslog": {
"label": "syslog",
"type": "compile",
- "test": "unix/syslog"
+ "test": {
+ "include": "syslog.h",
+ "main": [
+ "openlog(\"qt\", 0, LOG_USER);",
+ "syslog(LOG_INFO, \"configure\");",
+ "closelog();"
+ ]
+ }
},
"xlocalescanprint": {
"label": "xlocale.h (or equivalents)",
"type": "compile",
- "test": "common/xlocalescanprint"
+ "test": "xlocalescanprint"
}
},
@@ -301,7 +470,7 @@
"label": "iconv",
"purpose": "Provides internationalization on Unix.",
"section": "Internationalization",
- "condition": "!features.icu && (features.posix-libiconv || features.sun-libiconv || features.gnu-libiconv)",
+ "condition": "!features.icu && features.textcodec && (features.posix-libiconv || features.sun-libiconv || features.gnu-libiconv)",
"output": [ "privateFeature", "feature" ]
},
"posix-libiconv": {
@@ -349,13 +518,8 @@
},
"std-atomic64": {
"label": "64 bit atomic operations",
- "condition": "tests.atomic64 || libs.libatomic",
- "output": [ { "type": "define", "negative": true, "name": "QT_NO_STD_ATOMIC64" } ]
- },
- "libatomic": {
- "label": "64 bit atomic operations in libatomic",
- "condition": "!tests.atomic64 && libs.libatomic",
- "output": [ "privateFeature" ]
+ "condition": "libs.libatomic",
+ "output": [ "publicFeature" ]
},
"mimetype": {
"label": "Mimetype handling",
@@ -675,7 +839,7 @@ You need to use libdouble-conversion for double/string conversion."
"condition": "!tests.atomicfptr",
"message": "detected a std::atomic implementation that fails for function pointers.
Please apply the patch corresponding to your Standard Library vendor, found in
- qtbase/config.tests/common/atomicfptr"
+ qtbase/config.tests/atomicfptr"
}
],
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 5d1b24f065..376ef872ee 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -104,11 +104,17 @@ cmake_umbrella_config_version_file.output = $$DESTDIR/cmake/Qt5/Qt5ConfigVersion
load(cmake_functions)
+defineTest(pathIsAbsolute) {
+ p = $$clean_path($$1)
+ !isEmpty(p):isEqual(p, $$absolute_path($$p)): return(true)
+ return(false)
+}
+
##### This requires fixing, so that the feature system works with cmake as well
CMAKE_DISABLED_FEATURES = $$join(QT_DISABLED_FEATURES, "$$escape_expand(\\n) ")
CMAKE_HOST_DATA_DIR = $$cmakeRelativePath($$[QT_HOST_DATA/src], $$[QT_INSTALL_PREFIX])
-contains(CMAKE_HOST_DATA_DIR, "^\\.\\./.*"):!isEmpty(CMAKE_HOST_DATA_DIR) {
+pathIsAbsolute($$CMAKE_HOST_DATA_DIR) {
CMAKE_HOST_DATA_DIR = $$[QT_HOST_DATA/src]/
CMAKE_HOST_DATA_DIR_IS_ABSOLUTE = True
}
@@ -117,7 +123,7 @@ cmake_extras_mkspec_dir.input = $$PWD/Qt5CoreConfigExtrasMkspecDir.cmake.in
cmake_extras_mkspec_dir.output = $$DESTDIR/cmake/Qt5Core/Qt5CoreConfigExtrasMkspecDir.cmake
CMAKE_INSTALL_DATA_DIR = $$cmakeRelativePath($$[QT_HOST_DATA], $$[QT_INSTALL_PREFIX])
-contains(CMAKE_INSTALL_DATA_DIR, "^\\.\\./.*"):!isEmpty(CMAKE_INSTALL_DATA_DIR) {
+pathIsAbsolute($$CMAKE_INSTALL_DATA_DIR) {
CMAKE_INSTALL_DATA_DIR = $$[QT_HOST_DATA]/
CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE = True
}
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 05e3f6c45a..2c58ff87e9 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1172,7 +1172,8 @@
# define Q_DECL_ALIGN(n) alignas(n)
#endif
-#if QT_HAS_CPP_ATTRIBUTE(nodiscard) // P0188R1
+#if QT_HAS_CPP_ATTRIBUTE(nodiscard) && !defined(Q_CC_CLANG) // P0188R1
+// Can't use [[nodiscard]] with Clang, see https://bugs.llvm.org/show_bug.cgi?id=33518
# undef Q_REQUIRED_RESULT
# define Q_REQUIRED_RESULT [[nodiscard]]
#endif
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 24050dbbf8..5a9864edb2 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -541,13 +541,20 @@ QByteArray fileIdWin8(HANDLE handle)
QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
{
QByteArray result;
- const HANDLE handle =
+
#ifndef Q_OS_WINRT
+ const HANDLE handle =
CreateFile((wchar_t*)entry.nativeFilePath().utf16(), 0,
- FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ FILE_SHARE_READ, NULL, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, NULL);
#else // !Q_OS_WINRT
+ CREATEFILE2_EXTENDED_PARAMETERS params;
+ params.dwSize = sizeof(params);
+ params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
+ params.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS;
+ const HANDLE handle =
CreateFile2((const wchar_t*)entry.nativeFilePath().utf16(), 0,
- FILE_SHARE_READ, OPEN_EXISTING, NULL);
+ FILE_SHARE_READ, OPEN_EXISTING, &params);
#endif // Q_OS_WINRT
if (handle != INVALID_HANDLE_VALUE) {
result = id(handle);
diff --git a/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/src/corelib/io/qfilesystemwatcher_kqueue.cpp
index 4f6c83ebcf..c33fba2d1f 100644
--- a/src/corelib/io/qfilesystemwatcher_kqueue.cpp
+++ b/src/corelib/io/qfilesystemwatcher_kqueue.cpp
@@ -111,13 +111,12 @@ QStringList QKqueueFileSystemWatcherEngine::addPaths(const QStringList &paths,
continue;
}
if (fd >= (int)FD_SETSIZE / 2 && fd < (int)FD_SETSIZE) {
- int fddup = fcntl(fd, F_DUPFD, FD_SETSIZE);
+ int fddup = qt_safe_dup(fd, FD_SETSIZE);
if (fddup != -1) {
::close(fd);
fd = fddup;
}
}
- fcntl(fd, F_SETFD, FD_CLOEXEC);
QT_STATBUF st;
if (QT_FSTAT(fd, &st) == -1) {
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index ff0d45935c..2b5cb63282 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -113,7 +113,8 @@ public:
signals:
void driveAdded();
- void driveRemoved(const QString &);
+ void driveRemoved(); // Some drive removed
+ void driveRemoved(const QString &); // Watched/known drive removed
void driveLockForRemoval(const QString &);
void driveLockForRemovalFailed(const QString &);
@@ -252,7 +253,8 @@ inline void QWindowsRemovableDriveListener::handleDbtDriveArrivalRemoval(const M
case DBT_DEVICEARRIVAL:
emit driveAdded();
break;
- case DBT_DEVICEREMOVECOMPLETE: // handled by DBT_DEVTYP_HANDLE above
+ case DBT_DEVICEREMOVECOMPLETE: // See above for handling of drives registered with watchers
+ emit driveRemoved();
break;
}
}
@@ -348,7 +350,8 @@ QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(QObject *parent
this, &QWindowsFileSystemWatcherEngine::driveLockForRemoval);
QObject::connect(m_driveListener, &QWindowsRemovableDriveListener::driveLockForRemovalFailed,
this, &QWindowsFileSystemWatcherEngine::driveLockForRemovalFailed);
- QObject::connect(m_driveListener, &QWindowsRemovableDriveListener::driveRemoved,
+ QObject::connect(m_driveListener,
+ QOverload<const QString &>::of(&QWindowsRemovableDriveListener::driveRemoved),
this, &QWindowsFileSystemWatcherEngine::driveRemoved);
#endif // !Q_OS_WINRT
}
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 5a7057aa80..0decd26179 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -141,20 +141,6 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
{
Q_Q(QFSFileEngine);
- // Check if the file name is valid:
- // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions
- const QString fileName = fileEntry.fileName();
- for (QString::const_iterator it = fileName.constBegin(), end = fileName.constEnd();
- it != end; ++it) {
- const QChar c = *it;
- if (c == QLatin1Char('<') || c == QLatin1Char('>') || c == QLatin1Char(':') ||
- c == QLatin1Char('\"') || c == QLatin1Char('/') || c == QLatin1Char('\\') ||
- c == QLatin1Char('|') || c == QLatin1Char('?') || c == QLatin1Char('*')) {
- q->setError(QFile::OpenError, QStringLiteral("Invalid file name"));
- return false;
- }
- }
-
// All files are opened in share mode (both read and write).
DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp
index 0283c5f31f..3f45ca5f91 100644
--- a/src/corelib/io/qsavefile.cpp
+++ b/src/corelib/io/qsavefile.cpp
@@ -232,7 +232,11 @@ bool QSaveFile::open(OpenMode mode)
}
d->fileEngine = new QTemporaryFileEngine;
- static_cast<QTemporaryFileEngine *>(d->fileEngine)->initialize(d->finalFileName, 0666);
+ // 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
+ int perm = (existingFile.exists() ? 0600 : 0666);
+ static_cast<QTemporaryFileEngine *>(d->fileEngine)->initialize(d->finalFileName, perm);
// Same as in QFile: QIODevice provides the buffering, so there's no need to request it from the file engine.
if (!d->fileEngine->open(mode | QIODevice::Unbuffered)) {
QFileDevice::FileError err = d->fileEngine->error();
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index 8e3de2d620..75cb8a7ede 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -197,7 +197,15 @@ bool QWindowsPipeWriter::write(const QByteArray &ba)
overlapped, &writeFileCompleted)) {
writeSequenceStarted = false;
buffer.clear();
- qErrnoWarning("QWindowsPipeWriter::write failed.");
+
+ const DWORD errorCode = GetLastError();
+ switch (errorCode) {
+ case ERROR_NO_DATA: // "The pipe is being closed."
+ // The other end has closed the pipe. This can happen in QLocalSocket. Do not warn.
+ break;
+ default:
+ qErrnoWarning(errorCode, "QWindowsPipeWriter::write failed.");
+ }
return false;
}
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index 8dcd80808b..59a10e9057 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -44,8 +44,6 @@
#include <algorithm>
#include <functional>
-#ifndef QT_NO_ITEMVIEWS
-
QT_BEGIN_NAMESPACE
/*!
@@ -1917,5 +1915,3 @@ QDebug operator<<(QDebug dbg, const QItemSelectionRange &range)
QT_END_NAMESPACE
#include "moc_qitemselectionmodel.cpp"
-
-#endif // QT_NO_ITEMVIEWS
diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h
index 2421610bce..9d33303ddc 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.h
+++ b/src/corelib/itemmodels/qitemselectionmodel.h
@@ -42,8 +42,6 @@
#include <QtCore/qglobal.h>
-#ifndef QT_NO_ITEMVIEWS
-
#include <QtCore/qset.h>
#include <QtCore/qvector.h>
#include <QtCore/qlist.h>
@@ -273,6 +271,4 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QItemSelectionRange)
Q_DECLARE_METATYPE(QItemSelection)
-#endif // QT_NO_ITEMVIEWS
-
#endif // QITEMSELECTIONMODEL_H
diff --git a/src/corelib/itemmodels/qitemselectionmodel_p.h b/src/corelib/itemmodels/qitemselectionmodel_p.h
index c2d9384b09..dfc0387563 100644
--- a/src/corelib/itemmodels/qitemselectionmodel_p.h
+++ b/src/corelib/itemmodels/qitemselectionmodel_p.h
@@ -55,7 +55,6 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_ITEMVIEWS
class QItemSelectionModelPrivate: public QObjectPrivate
{
Q_DECLARE_PUBLIC(QItemSelectionModel)
@@ -106,8 +105,6 @@ public:
int tableColCount, tableRowCount;
};
-#endif // QT_NO_ITEMVIEWS
-
QT_END_NAMESPACE
#endif // QITEMSELECTIONMODEL_P_H
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index b7fe1557d3..569fbc2796 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -209,7 +209,8 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
// in the queue. WM_QT_ACTIVATENOTIFIERS will be posted again as a result of
// event processing.
MSG msg;
- if (!PeekMessage(&msg, 0, WM_QT_SOCKETNOTIFIER, WM_QT_SOCKETNOTIFIER, PM_NOREMOVE)
+ if (!PeekMessage(&msg, d->internalHwnd,
+ WM_QT_SOCKETNOTIFIER, WM_QT_SOCKETNOTIFIER, PM_NOREMOVE)
&& d->queuedSocketEvents.isEmpty()) {
// register all socket notifiers
for (QSFDict::iterator it = d->active_fd.begin(), end = d->active_fd.end();
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 0b0f935b26..715acc77ce 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -959,8 +959,22 @@ Q_OUTOFLINE_TEMPLATE bool QHash<Key, T>::operator==(const QHash &other) const
return false;
// Keys in the ranges are equal by construction; this checks only the values.
- if (!std::is_permutation(it, thisEqualRangeEnd, otherEqualRange.first))
+ //
+ // When using the 3-arg std::is_permutation, MSVC will emit warning C4996,
+ // passing an unchecked iterator to a Standard Library algorithm. We don't
+ // want to suppress the warning, and we can't use stdext::make_checked_array_iterator
+ // because QHash::(const_)iterator does not work with size_t and thus will
+ // emit more warnings. Use the 4-arg std::is_permutation instead (which
+ // is supported since MSVC 2015).
+ //
+ // ### Qt 6: if C++14 library support is a mandated minimum, remove the ifdef for MSVC.
+ if (!std::is_permutation(it, thisEqualRangeEnd, otherEqualRange.first
+#if defined(Q_CC_MSVC) && _MSC_VER >= 1900
+ , otherEqualRange.second
+#endif
+ )) {
return false;
+ }
it = thisEqualRangeEnd;
}
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 789a15dded..5db181885c 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -320,7 +320,7 @@ QByteArray QLocalePrivate::bcp47Name(char separator) const
if (m_data->m_language_id == QLocale::AnyLanguage)
return QByteArray();
if (m_data->m_language_id == QLocale::C)
- return QByteArrayLiteral("C");
+ return QByteArrayLiteral("en");
QLocaleId localeId = QLocaleId::fromIds(m_data->m_language_id, m_data->m_script_id, m_data->m_country_id);
return localeId.withLikelySubtagsRemoved().name(separator);