From 548c2fbb3aa1ae6b7d3614b6381ea051977e2834 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 19 Jul 2017 15:22:15 +0200 Subject: QHash: make MSVC happy about the iterators passed to is_permutation MSVC warns about iterators being passed to certain Standard Library algorithms. dbd55cdaf367bdc9d6774bcb9927cbe19f18065f introduced a usa of std::is_permutation in a public header, which is causing such a warning to be emitted. To suppress the warning, Microsoft suggests to either use the 4-arg std::is_permutation overload (which however is not available in MSVC 2013) or to use a Standard Library extension, which we are already using elsewhere in Qt to deal with the same problem. However, that extension requires the iterator to be moved by size_t quantities, which isn't the case for QHash::iterator, and therefore generates more warnings about loss of precision (size_t -> int). Therefore, go with the 4-arg std::is_permutation, only on MSVC >= 2015. Change-Id: Idfcff28d14e0f1fde5d77f1deb9eec27c87ff5cd Task-number: QTBUG-61902 Reviewed-by: Thiago Macieira --- src/corelib/tools/qhash.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 035ec57957..703066857d 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -950,8 +950,22 @@ Q_OUTOFLINE_TEMPLATE bool QHash::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; } -- cgit v1.2.3 From d819d6864a52d78cb86be3f2d3250a2c51835aeb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 17 Jul 2017 13:50:36 -0700 Subject: QFileSystemWatcher/kqueue: make the fd duplication + FD_CLOEXEC atomic The original fd was already FD_CLOEXEC due to qt_safe_open. Change-Id: Ief61d358e2b54a0fac37fffd14d2394ee02da059 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qfilesystemwatcher_kqueue.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib') 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) { -- cgit v1.2.3 From b28b3af38507942791df9d874ebaca71decc59ca Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 9 Jul 2017 12:41:32 -0700 Subject: QFileSystemEngine::id/Windows: Fix use with directories The Microsoft documentation says that CreateFile cannot be used to create directories, so you can only use it on a directory with OPEN_EXISTING and FILE_FLAG_BACKUP_SEMANTICS. This commit implements that. Change-Id: I658f552684924f8aa2cafffd14cfc0e5660a4a62 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemengine_win.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 1cb4c75699..0542d9e16c 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -612,13 +612,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, ¶ms); #endif // Q_OS_WINRT if (handle != INVALID_HANDLE_VALUE) { result = id(handle); -- cgit v1.2.3 From 3becc8527e632e5d54e3d05d5c4f72246100c963 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 14 Jul 2017 11:13:20 +0200 Subject: Let QWindowsPipeWriter::write only warn about unexpected errors Do not print a critical message when the pipe connection dropped as this can happen with regular QLocalSocket usage as demonstrated in qtremoteobjects. Change-Id: If79915ce5d83b8cae5e090c04e893dafcb5a88a7 Reviewed-by: Friedemann Kleint --- src/corelib/io/qwindowspipewriter.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index 7eb6dd0389..846891102f 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -201,7 +201,15 @@ bool QWindowsPipeWriter::write(const QByteArray &ba) writeSequenceStarted = false; numberOfBytesToWrite = 0; 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; } -- cgit v1.2.3 From 16f375f5490dec4bc69ceb52cd1f26e68011484f Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 22 Jul 2017 15:19:13 +0200 Subject: Convert features.itemviews to QT_[REQUIRE_]CONFIG The QT_NO_ITEMVIEWS queries in corelib/ seem to had no effect at all. Change-Id: I494ee2309a96b0cf25de18781fc9a675878a2ee9 Reviewed-by: Oswald Buddenhagen --- src/corelib/itemmodels/qitemselectionmodel.cpp | 4 ---- src/corelib/itemmodels/qitemselectionmodel.h | 4 ---- src/corelib/itemmodels/qitemselectionmodel_p.h | 3 --- 3 files changed, 11 deletions(-) (limited to 'src/corelib') 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 #include -#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 -#ifndef QT_NO_ITEMVIEWS - #include #include #include @@ -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 -- cgit v1.2.3 From af7e756155cf44e05816cf91be04e13d9e7ca084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Tue, 18 Jul 2017 10:41:20 +0200 Subject: Return "en" for QLocale::c().bcp47Name() Currently QLocale::c().bcp47Name() returns "C" which, according to [BCP47], is not a valid language tag. In particular it does not conform to the ABNF grammar in section 2.1 which specifies a minimum length of 2 characters for all language tags. [BCP47]: https://tools.ietf.org/html/bcp47 This patch changes the return value to "en" seeing as the documentation for QLocale::Language states that the C language is identical in behavior to English. Task-number: QTBUG-61949 Change-Id: I2a381def8fb7156467e01d105da92bb1f4821204 Reviewed-by: Edward Welbourne --- src/corelib/tools/qlocale.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index ab95f60115..63219b5bab 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -328,7 +328,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); -- cgit v1.2.3 From be93d2de031fb870a1ff244304311e07536a13b9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 21 Jul 2017 10:22:01 -0700 Subject: Blacklist use of [[nodiscard]] with Clang __has_cpp_attribute(nodiscard) is 1 in all compilation modes, but if you use it outside of C++1z, you get a warning. LLVM-bug: https://bugs.llvm.org/show_bug.cgi?id=33518 Task-number: QTBUG-61840 Task-number: QTBUG-62085 Change-Id: I84e45059a888497fb55ffffd14d3683f4808978b Reviewed-by: Eike Ziller Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') 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 -- cgit v1.2.3 From 7c45c6a3c44f73aac5a7422ce66235bf32b510e3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 26 Jul 2017 10:35:55 -0700 Subject: Revert "Make QFile::open fail when using an invalid file name" This reverts commit 346cd79192ef71afa572812e17f1d422594651a0. The bug report was incorrect, since the suggested file name is actually valid, it just happens to name an Alternate Data Stream (ADS) "20:803Z.txt" in file "testLog-03". [ChangeLog][QtCore][QFile] Reverted an incorrect change from Qt 5.9.0 that forbade the creation and access to Alternate Data Streams on NTFS on Windows. This means that file names containing a colon (':') are allowed again, but note that they are not regular files. Task-number: QTBUG-57023 Change-Id: I81480fdb578d4d43b3fcfffd14d4f2147e8a0ade Reviewed-by: Oswald Buddenhagen Reviewed-by: Kai Koehne Reviewed-by: Jesus Fernandez --- src/corelib/io/qfsfileengine_win.cpp | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 7a010df671..c99a25f30d 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -108,20 +108,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; -- cgit v1.2.3 From 5978be31295eb78106fa968a86ba3182f31b2d21 Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Thu, 27 Jul 2017 21:51:33 +0200 Subject: Use correct paths in Qt5CoreConfigExtrasMkspecDir Before we generated the following content: set(_qt5_corelib_extra_includes "${_qt5Core_install_prefix}/X:/src/qt5.9/qtbase/mkspecs/win32-msvc") Which lead to the following error when used: CMake Error at Z:/build/qt59/qtbase/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:15 (message): The imported target "Qt5::Core" references the file "Z:/build/qt59/qtbase/X:/src/qt5.9/qtbase//mkspecs/win32-msvc" => We prefixed an absolute path with another absolute path which is obviously wrong After the patch we generate this content: set(_qt5_corelib_extra_includes "X:/src/qt5.9/qtbase/mkspecs/win32-msvc") This patch ensures we never prefix an absolute path additionally Patch by Konstantin Tokarev Change-Id: I05dab7f681958723594ceb78064be41798e83fb8 Task-number: QTBUG-61768 Reviewed-by: Thiago Macieira Reviewed-by: Konstantin Tokarev --- src/corelib/corelib.pro | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 0bd7c9b99d..7d09070b81 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 } -- cgit v1.2.3 From 23187ade6075e88e9212acef7c829a319f0a39dc Mon Sep 17 00:00:00 2001 From: Antonio Larrosa Date: Tue, 18 Apr 2017 17:56:35 +0200 Subject: Fix open/chmod race condition in QSaveFile This fixes a problem introduced in a60571b3700e80f44705ebc4bab9628cf852891c The problem happens when an application like Kate (actually, ktexteditor) uses QSaveFile to save files. So if you open a secretfile.txt file (with permissions 0600), edit and save it, then QSaveFile currently generates a temporary file with 0666 that afterwards gets chmod'ed to 0600 again, but in between, some other user in the system can open the temporary file and get a file descriptor that would allow him/her to read the contents of a file with 0600 permissions. Change-Id: I824025f54d6faf853da88e4dfcb092b577b4df04 Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qsavefile.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/corelib') 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(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(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(); -- cgit v1.2.3 From 8f32e34734832013da9be7a2d794ca2125113a7e Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 29 Apr 2017 19:52:43 +0200 Subject: Fix build for -no-feature-icu -no-feature-textcodec Change-Id: Ibb19e5bce3da81518f0967ae7677f42de80ec73e Reviewed-by: Thiago Macieira --- src/corelib/configure.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 2b3efbeb15..6399e4d3c4 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -241,7 +241,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": { -- cgit v1.2.3 From 7c2850cd8f1029b74d960fad5754320b61176f46 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 24 Jul 2017 09:35:12 +0200 Subject: QEventDispatcherWin32: Check for WM_QT_SOCKETNOTIFIER on internal window only Restrict the checking to the internal window handle to prevent it being thrown off by other WM_USER messages used by applications. Complements change 124b9a6ff89da8be83a256135ec6c4d0603e9a6f. Task-number: QTBUG-62083 Change-Id: Ifb1b00e4ff70cb7e53873943e46cea0d72ff6257 Reviewed-by: Alex Trotsenko Reviewed-by: Thiago Macieira --- src/corelib/kernel/qeventdispatcher_win.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 0952464f53..7a6149b405 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -207,7 +207,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(); -- cgit v1.2.3 From 256854cf9760f2b8e8702c2ce2066f67213c0169 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 28 Jul 2017 10:54:44 +0200 Subject: Windows/QFileSystemModel: Fix updating of removed drives Previously, the updating of drives in QFileSystemModel was connected to a signal triggering when a drive containing watched files was removed via QFileSystemWatcher notification. This did not trigger when a drive that was not expanded in the view was removed, since no files were watched. Since QFileSystemModel is not interested in the path of the drive being removed, add a generic signal triggered by DBT_DEVTYP_VOLUME/DBT_DEVICEREMOVECOMPLETE and use that to update the drives. Complements 8e79806d08ab77aa0f87b69a2ef65789216f41c0. Task-number: QTBUG-18729 Task-number: QTBUG-53436 Change-Id: Ibcde4665824c41151042237d4d620c48bc1e2e18 Reviewed-by: Oliver Wolff Reviewed-by: Joerg Bornemann --- src/corelib/io/qfilesystemwatcher_win.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/corelib') 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::of(&QWindowsRemovableDriveListener::driveRemoved), this, &QWindowsFileSystemWatcherEngine::driveRemoved); #endif // !Q_OS_WINRT } -- cgit v1.2.3 From a3b5020a1aee9f8d505b82ba70700518e5786686 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 31 Jul 2017 11:42:44 +0200 Subject: configure: prune dead tests::journald libraries::journald is the actually used one. Change-Id: I2da4ae106dd1041cdb269e05def93523ed5011b2 Reviewed-by: Thiago Macieira --- src/corelib/configure.json | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 6399e4d3c4..0cbb35e688 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -167,11 +167,6 @@ "type": "compile", "test": "unix/ipc_posix" }, - "journald": { - "label": "journald", - "type": "compile", - "test": "unix/journald" - }, "ppoll": { "label": "ppoll()", "type": "compile", -- cgit v1.2.3 From acf75d733708f2275cc363566c2457f5c4486362 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 31 Jul 2017 12:17:09 +0200 Subject: configure: standardize handling of 64 bit atomics replace the custom QT_NO_STD_ATOMIC64 with a regular public feature, and give libatomic an empty source rather than using a separate config test. Change-Id: Iaf4a7f4c4874f61bf93aa58fe41843a86baf1ab7 Reviewed-by: Thiago Macieira --- src/corelib/arch/arch.pri | 2 +- src/corelib/arch/qatomic_cxx11.h | 2 +- src/corelib/configure.json | 17 ++++------------- 3 files changed, 6 insertions(+), 15 deletions(-) (limited to 'src/corelib') 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 0cbb35e688..67a1a2ad4b 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -69,9 +69,10 @@ ] }, "libatomic": { - "label": "64 bit atomics in libatomic", + "label": "64 bit atomics", "test": "common/atomic64", "sources": [ + "", "-latomic" ] }, @@ -116,11 +117,6 @@ }, "tests": { - "atomic64": { - "label": "64 bit atomics", - "type": "compile", - "test": "common/atomic64" - }, "atomicfptr": { "label": "working std::atomic for function pointers", "type": "compile", @@ -284,13 +280,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", -- cgit v1.2.3 From f54f7d847099db448223fd630c5416b6fbd84c9e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 1 Aug 2017 18:30:33 +0200 Subject: configure: Add a feature to write tests in the .json file We're adding a lot of unnecessary files that end up later as cargo-cult, for at most a handful of lines. So instead move the testcases directly into the .json file. The following sources were not inlined, because multiple tests share them, and the inlining infra does not support that (yet): - avx512 - openssl - gnu-libiconv/sun-libiconv (there is also a command line option to select the exact variant, which makes it hard/impossible to properly coalesce the library sources) The following sources were not inlined because of "complications": - verifyspec contains a lengthy function in the project file - stl contains lots of code in the source file - xlocalescanprint includes a private header from the source tree via a relative path, which we can't do, as the test's physical location is variable. - corewlan uses objective c++, which the inline system doesn't support reduce_relocs and reduce_exports now create libraries with main(), which is weird enough, but doesn't hurt. Done-with: Oswald Buddenhagen Change-Id: Ic3a088f9f08a4fd7ae91fffd14ce8a262021cca0 Reviewed-by: Oswald Buddenhagen --- src/corelib/configure.json | 220 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 199 insertions(+), 21 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 67a1a2ad4b..5596280250 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" } ] @@ -44,7 +56,22 @@ }, "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,7 +89,10 @@ }, "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" } @@ -70,7 +100,26 @@ }, "libatomic": { "label": "64 bit atomics", - "test": "common/atomic64", + "test": { + "include": [ "atomic", "cstdint" ], + "tail": [ + "void test(volatile std::atomic &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 *>(ptr));" + ], + "qmake": "CONFIG += c++11" + }, "sources": [ "", "-latomic" @@ -78,7 +127,10 @@ }, "libdl": { "label": "dlopen()", - "test": "unix/dlopen", + "test": { + "include": "dlfcn.h", + "main": "dlopen(0, 0);" + }, "sources": [ "", "-ldl" @@ -86,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" @@ -94,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" @@ -120,23 +192,77 @@ "atomicfptr": { "label": "working std::atomic for function pointers", "type": "compile", - "test": "common/atomicfptr" + "test": { + "include": "atomic", + "tail": [ + "typedef void (*fptr)(int);", + "typedef std::atomic 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" + ] + } }, "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);" + ] + } }, "posix-iconv": { "label": "POSIX iconv", @@ -151,37 +277,89 @@ "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" + "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)", -- cgit v1.2.3 From b0060d1056d6d1752d91652261de97db909c7862 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 31 Jul 2017 12:51:38 +0200 Subject: configure: un-namespace remaining non-inline configure tests only few tests remain, and many of these were mis-classified anyway. Change-Id: Ic3bc96928a0c79fe77b9ec10e6508d4822f18df2 Reviewed-by: Thiago Macieira --- src/corelib/configure.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 5596280250..91f7bb4fd6 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -49,7 +49,7 @@ "gnu_iconv": { "label": "GNU libiconv", "export": "iconv", - "test": "unix/gnu-libiconv", + "test": "gnu-libiconv", "sources": [ "-liconv" ] @@ -267,12 +267,12 @@ "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", @@ -364,7 +364,7 @@ "xlocalescanprint": { "label": "xlocale.h (or equivalents)", "type": "compile", - "test": "common/xlocalescanprint" + "test": "xlocalescanprint" } }, @@ -774,7 +774,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" } ], -- cgit v1.2.3