From 07fffa60103fed42efed86f928fcec30f9d98815 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 21 Feb 2017 11:01:46 -0800 Subject: QDateTime: Fix clearing the ShortData flag in setMSecsSinceEpoch Unlike setTimeSpec, this forgot to clear the bit when detaching. So it's possible that some further use of the flags could incorrectly conclude that the data was short and then proceed to corrupt the pointer. The example from QTBUG-59061 caused this because toUTC() -> toTimeSpec() calls setMSecsSinceEpoch which left the bit set; then addDays() calls setDateTime(), which calls checkValidDateTime() and that corrupted the pointer. This problem was more visible on 32-bit systems because no QDateTime was short (except for default constructed ones), but it can happen on 64-bit with sufficiently large dates. Task-number: QTBUG-59061 Change-Id: Ibc5c715fda334a75bd2efffd14a562a375a4e69b Reviewed-by: Edward Welbourne --- src/corelib/tools/qdatetime.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index a642358770..bf92be2dd4 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2842,6 +2842,9 @@ inline bool QDateTime::Data::isShort() const { bool b = quintptr(d) & QDateTimePrivate::ShortData; + // sanity check: + Q_ASSERT(b || (d->m_status & QDateTimePrivate::ShortData) == 0); + // even if CanBeSmall = false, we have short data for a default-constructed // QDateTime object. But it's unlikely. if (CanBeSmall) @@ -3658,7 +3661,7 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs) d.data.status = status; } else { d.detach(); - d->m_status = status; + d->m_status = status & ~QDateTimePrivate::ShortData; d->m_msecs = msecs; } -- cgit v1.2.3 From e3bcab935c9fe37b344394c3ee8afd6773a8cd7e Mon Sep 17 00:00:00 2001 From: Christian Gagneraud Date: Wed, 22 Feb 2017 12:15:41 +1300 Subject: Fix documentation typos This patch fixes 2 simple typos in QGraphicsItem and QPainter documentation and a copy/paste error between QAbstractItemModel's beginRemoveColumns and beginRemoveRows documentation. Change-Id: I32bdc4dc69154a40fe30a5b8c08d0c3a001853f8 Reviewed-by: Harri Porten Reviewed-by: Marc Mutz --- src/corelib/itemmodels/qabstractitemmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 7fdf107383..6848a408f6 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -3071,7 +3071,7 @@ void QAbstractItemModel::endRemoveColumns() When reimplementing a subclass, this method simplifies moving entities in your model. This method is responsible for moving persistent indexes in the model, which you would otherwise be - required to do yourself. Using beginMoveRows and endMoveRows + required to do yourself. Using beginMoveColumns and endMoveColumns is an alternative to emitting layoutAboutToBeChanged and layoutChanged directly along with changePersistentIndex. -- cgit v1.2.3 From 0d7ed8f5f3b8a308c495c71c7427b41157d769b1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Feb 2017 17:39:47 +0100 Subject: streamline libdl detection and linking instead of having a library and a test, use a library with two sources, the first being empty (i.e., just libc). this allows us doing away with the "libdl" feature, and using just the "dlopen" one. subsequently, replace all LIBS+=$$QMAKE_LIBS_DYNLOAD with QMAKE_USE+=libdl. the definitions of QMAKE_LIBS_DYNLOAD remain in the qmakespecs for backwards compat only. n.b.: the only specs where it is not empty or "-ldl" (i.e., what we support now) are the hpux ones, where the library is called 'dld'. technically, the "library" feature should depend on '!unix || dlopen', but that's for a later patch. Change-Id: Ib8546affc4b7bc757f1a76729573ddd00e152176 Reviewed-by: Lars Knoll Reviewed-by: Ulf Hermann --- src/corelib/configure.json | 17 ++++------------- src/corelib/plugin/plugin.pri | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 76dfed3128..c13ad25c15 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -74,10 +74,10 @@ ] }, "libdl": { - "label": "dlopen() in libdl", - "export": "", + "label": "dlopen()", "test": "unix/dlopen", "sources": [ + "", "-ldl" ] }, @@ -131,11 +131,6 @@ "type": "compile", "test": "unix/cloexec" }, - "dlopen": { - "label": "dlopen() in libc", - "type": "compile", - "test": "unix/dlopen" - }, "eventfd": { "label": "eventfd", "type": "compile", @@ -211,12 +206,8 @@ }, "dlopen": { "label": "dlopen()", - "condition": "tests.dlopen || libs.libdl" - }, - "libdl": { - "label": "dlopen() in libdl", - "condition": "!tests.dlopen && libs.libdl", - "output": [ { "type": "privateConfig", "negative": true } ] + "condition": "config.unix && libs.libdl", + "output": [ "privateFeature" ] }, "doubleconversion": { "label": "DoubleConversion", diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri index 473480eb55..bb3843cc36 100644 --- a/src/corelib/plugin/plugin.pri +++ b/src/corelib/plugin/plugin.pri @@ -35,4 +35,4 @@ integrity { SOURCES += plugin/qlibrary_unix.cpp } -!no-libdl: LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD +qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl -- cgit v1.2.3 From 85b30fda7ceccecfd3938703979b3431bdedc9a2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Feb 2017 18:37:05 +0100 Subject: fix detection of static icu under unix the library has a dependency on libdl. Task-number: QTBUG-58301 Change-Id: I36567ded32980b241ff2f01cfdec044510405a75 Reviewed-by: Thiago Macieira Reviewed-by: Joerg Bornemann --- src/corelib/configure.json | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index c13ad25c15..6da3b61a2d 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -56,6 +56,9 @@ }, { "libs": "-licuin -licuuc -licudt", "condition": "config.win32 && features.shared" }, { "libs": "-licui18n -licuuc -licudata", "condition": "!config.win32" } + ], + "use": [ + { "lib": "libdl", "condition": "features.dlopen" } ] }, "journald": { -- cgit v1.2.3 From 44af54419eaceb27bb729717d6363917fd6bb819 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 23 Nov 2016 12:25:17 +0100 Subject: Properly use the "process" feature Replace all QT_NO_PROCESS with QT_CONFIG(process), define it in qconfig-bootstrapped.h, add QT_REQUIRE_CONFIG(process) to the qprocess headers, exclude the sources from compilation when switched off, guard header inclusions in places where compilation without QProcess seems supported, drop some unused includes, and fix some tests that were apparently designed to work with QT_NO_PROCESS but failed to. Change-Id: Ieceea2504dea6fdf43b81c7c6b65c547b01b9714 Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qconfig-bootstrapped.h | 1 + src/corelib/io/forkfd_qt.cpp | 1 - src/corelib/io/io.pri | 18 +++++++++++++----- src/corelib/io/qprocess.cpp | 5 ----- src/corelib/io/qprocess.h | 7 ++----- src/corelib/io/qprocess_p.h | 7 +++---- src/corelib/io/qprocess_unix.cpp | 4 ---- src/corelib/io/qprocess_win.cpp | 4 ---- src/corelib/io/qwindowspipewriter_p.h | 2 +- src/corelib/kernel/qcore_unix_p.h | 4 ++-- 10 files changed, 22 insertions(+), 31 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index 1c806e0774..a2c0b011e7 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -74,6 +74,7 @@ #define QT_NO_LIBRARY #define QT_FEATURE_library -1 #define QT_NO_QOBJECT +#define QT_FEATURE_process -1 #define QT_NO_SYSTEMLOCALE #define QT_FEATURE_slog2 -1 #define QT_FEATURE_syslog -1 diff --git a/src/corelib/io/forkfd_qt.cpp b/src/corelib/io/forkfd_qt.cpp index 141efeb08c..dce0ebb4da 100644 --- a/src/corelib/io/forkfd_qt.cpp +++ b/src/corelib/io/forkfd_qt.cpp @@ -39,7 +39,6 @@ // these might be defined via precompiled headers #include -#include "qprocess_p.h" #define FORKFD_NO_SPAWNFD diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 0414ae966a..b5bfec8857 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -22,8 +22,6 @@ HEADERS += \ io/qlockfile.h \ io/qlockfile_p.h \ io/qnoncontiguousbytedevice_p.h \ - io/qprocess.h \ - io/qprocess_p.h \ io/qtextstream.h \ io/qtextstream_p.h \ io/qtemporarydir.h \ @@ -72,7 +70,6 @@ SOURCES += \ io/qiodevice.cpp \ io/qlockfile.cpp \ io/qnoncontiguousbytedevice.cpp \ - io/qprocess.cpp \ io/qstorageinfo.cpp \ io/qtextstream.cpp \ io/qtemporarydir.cpp \ @@ -96,6 +93,19 @@ SOURCES += \ io/qloggingcategory.cpp \ io/qloggingregistry.cpp +qtConfig(process) { + SOURCES += \ + io/qprocess.cpp + HEADERS += \ + io/qprocess.h \ + io/qprocess_p.h + + win32:!winrt: \ + SOURCES += io/qprocess_win.cpp + else: unix: \ + SOURCES += io/qprocess_unix.cpp +} + win32 { SOURCES += io/qfsfileengine_win.cpp SOURCES += io/qlockfile_win.cpp @@ -112,7 +122,6 @@ win32 { io/qwinoverlappedionotifier_p.h SOURCES += \ - io/qprocess_win.cpp \ io/qsettings_win.cpp \ io/qstandardpaths_win.cpp \ io/qstorageinfo_win.cpp \ @@ -132,7 +141,6 @@ win32 { io/qfsfileengine_unix.cpp \ io/qfilesystemengine_unix.cpp \ io/qlockfile_unix.cpp \ - io/qprocess_unix.cpp \ io/qfilesystemiterator_unix.cpp !integrity:!uikit { diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index c7d6cb426d..fd340ca607 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -99,8 +99,6 @@ QT_END_NAMESPACE #include #endif -#ifndef QT_NO_PROCESS - QT_BEGIN_NAMESPACE /*! @@ -2604,6 +2602,3 @@ QString QProcess::nullDevice() QT_END_NAMESPACE #include "moc_qprocess.cpp" - -#endif // QT_NO_PROCESS - diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index 4ce0503761..67c163c012 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -46,10 +46,9 @@ #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(process); -#ifndef QT_NO_PROCESS +QT_BEGIN_NAMESPACE #if !defined(Q_OS_WIN) || defined(Q_QDOC) typedef qint64 Q_PID; @@ -298,8 +297,6 @@ private: friend class QProcessManager; }; -#endif // QT_NO_PROCESS - QT_END_NAMESPACE #endif // QPROCESS_H diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index ae236c8c60..250eeb5de6 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -57,6 +57,9 @@ #include "QtCore/qhash.h" #include "QtCore/qshareddata.h" #include "private/qiodevice_p.h" + +QT_REQUIRE_CONFIG(process); + #ifdef Q_OS_UNIX #include #endif @@ -70,8 +73,6 @@ typedef int Q_PIPE; #define INVALID_Q_PIPE -1 #endif -#ifndef QT_NO_PROCESS - QT_BEGIN_NAMESPACE class QSocketNotifier; @@ -388,6 +389,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_PROCESS - #endif // QPROCESS_P_H diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index b39816dd7d..03e2c0c4ce 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -41,8 +41,6 @@ //#define QPROCESS_DEBUG #include "qdebug.h" -#ifndef QT_NO_PROCESS - #if defined QPROCESS_DEBUG #include "private/qtools_p.h" #include @@ -1045,5 +1043,3 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a } QT_END_NAMESPACE - -#endif // QT_NO_PROCESS diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index d0e922bf2b..6dd431eb47 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -59,8 +59,6 @@ #define PIPE_REJECT_REMOTE_CLIENTS 0x08 #endif -#ifndef QT_NO_PROCESS - QT_BEGIN_NAMESPACE //#define QPROCESS_DEBUG @@ -893,5 +891,3 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a } QT_END_NAMESPACE - -#endif // QT_NO_PROCESS diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h index 5a0d04855f..c43e986f34 100644 --- a/src/corelib/io/qwindowspipewriter_p.h +++ b/src/corelib/io/qwindowspipewriter_p.h @@ -156,4 +156,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_PROCESS +#endif // QWINDOWSPIPEWRITER_P_H diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 80058d9115..8f37aec6e2 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -300,7 +300,7 @@ static inline int qt_safe_close(int fd) #define QT_CLOSE qt_safe_close // - VxWorks & iOS/tvOS/watchOS don't have processes -#if !defined(Q_OS_VXWORKS) && !defined(QT_NO_PROCESS) +#if QT_CONFIG(process) static inline int qt_safe_execve(const char *filename, char *const argv[], char *const envp[]) { @@ -329,7 +329,7 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options) EINTR_LOOP(ret, ::waitpid(pid, status, options)); return ret; } -#endif // Q_OS_VXWORKS +#endif // QT_CONFIG(process) #if !defined(_POSIX_MONOTONIC_CLOCK) # define _POSIX_MONOTONIC_CLOCK -1 -- cgit v1.2.3 From 657bea873b9bf66764848d612b4188039ec7e583 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Wed, 25 Jan 2017 15:20:26 +0100 Subject: Doc: added info about return type for function QMutex::try_lock() qmutex.cpp:266: warning: Undocumented return value Change-Id: Ib93a5a2505f663f266871dbe5582fb5856096889 Reviewed-by: Venugopal Shivashankar --- src/corelib/thread/qmutex.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index b9b16e066f..29095f8b51 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -266,6 +266,9 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT /*! \fn bool QMutex::try_lock() \since 5.8 + This function returns \c true if the lock was obtained; otherwise it + returns \c false. + This function is provided for compatibility with the Standard Library concept \c Lockable. It is equivalent to tryLock(). -- cgit v1.2.3 From 17d780ad457fb9cbfc92bf6114bfcf4cc4ac5a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 28 Feb 2017 08:54:56 +0100 Subject: QTimer: Avoid implicit conversion warnings This fixes compiling an application using QTimer and -Wshorten-64-to-32 on a 64-bit system without getting this warning: ... 5.8/clang_64/lib/QtCore.framework/Headers/qtimer.h:171:21: warning: implicit conversion loses integer precision: 'rep' (aka 'long long') to 'int' [-Wshorten-64-to-32] setInterval(value.count()); ~~~~~~~~~~~ ^~~~~~~~~~~~~ Change-Id: I3e0407a7193c841308f7271c41a8dd5a2eb2a534 Reviewed-by: Marc Mutz --- src/corelib/kernel/qtimer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 96c7efd8f5..9303f82544 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -168,7 +168,7 @@ public: Q_ALWAYS_INLINE void setInterval(std::chrono::milliseconds value) { - setInterval(value.count()); + setInterval(int(value.count())); } Q_ALWAYS_INLINE -- cgit v1.2.3 From 2ae8292d03beab5869a1319e3d18ea281a5d014c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 28 Feb 2017 09:22:41 +0100 Subject: QList: Avoid implicit conversion warning This fixes compiling an application using QList and -Wshorten-64-to-32 on a 64-bit system without getting this warning: ... 5.8/clang_64/lib/QtCore.framework/Headers/qlist.h:897:26: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] int removedCount = e - n; ~~~~~~~~~~~~ ~~^~~ Change-Id: I688ed086805c431821c2ee6078fa5aeb631e7a07 Reviewed-by: Marc Mutz --- src/corelib/tools/qlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index c0a92aaa10..5995be47a9 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -894,7 +894,7 @@ Q_OUTOFLINE_TEMPLATE int QList::removeAll(const T &_t) *n++ = *i; } - int removedCount = e - n; + int removedCount = int(e - n); d->end -= removedCount; return removedCount; } -- cgit v1.2.3 From 04b8db3d57970631351fc6330af9553e94f1b14d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 25 Feb 2017 11:21:44 -0800 Subject: Fix parsing of day-of-week names that start with another name Task-number: QTBUG-59159 Change-Id: I95c9e502ccc74af3bcf0fffd14a69e0cd27ce96b Reviewed-by: Edward Welbourne --- src/corelib/tools/qdatetimeparser.cpp | 41 ++++++++--------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index d66416207b..c8aa4fbc89 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -49,7 +49,7 @@ //#define QDATETIMEPARSER_DEBUG #if defined (QDATETIMEPARSER_DEBUG) && !defined(QT_NO_DEBUG_STREAM) -# define QDTPDEBUG qDebug() << QString("%1:%2").arg(__FILE__).arg(__LINE__) +# define QDTPDEBUG qDebug() # define QDTPDEBUGN qDebug #else # define QDTPDEBUG if (false) qDebug() @@ -1325,39 +1325,16 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex } const QLocale l = locale(); for (int day=startDay; day<=7; ++day) { - const QString str2 = l.dayName(day, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat); - - if (str1.startsWith(str2.toLower())) { - if (used) - *used = str2.size(); - if (usedDay) { - *usedDay = str2; - } - return day; - } - if (context == FromString) - continue; + const QString dayName = l.dayName(day, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat); + const QString str2 = dayName.toLower(); const int limit = qMin(str1.size(), str2.size()); - bool found = true; - for (int i=0; i bestCount) { - bestCount = i; - bestMatch = day; - } - found = false; - break; - } - - } - if (found) { - if (used) - *used = limit; - if (usedDay) - *usedDay = str2; - - return day; + int i = 0; + while (i < limit && str1.at(i) == str2.at(i)) + ++i; + if (i > bestCount) { + bestCount = i; + bestMatch = day; } } if (usedDay && bestMatch != -1) { -- cgit v1.2.3 From 62e6aa6195680fde73807bab3a43c63f10c585f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 28 Feb 2017 09:42:08 +0100 Subject: QVector: Avoid implicit conversion warnings This fixes compiling an application using QVector and -Wshorten-64-to-32 on a 64-bit system without getting this warning: ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:695:18: warning: implicit conversion loses integer precision: 'typename iterator_traits::difference_type' (aka 'long') to 'int' [-Wshorten-64-to-32] int offset = std::distance(d->begin(), before); ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:731:35: warning: implicit conversion loses integer precision: 'long' to 'const int' [-Wshorten-64-to-32] const int itemsToErase = aend - abegin; ~~~~~~~~~~~~ ~~~~~^~~~~~~~ ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:740:39: warning: implicit conversion loses integer precision: 'long' to 'const int' [-Wshorten-64-to-32] const int itemsUntouched = abegin - d->begin(); ~~~~~~~~~~~~~~ ~~~~~~~^~~~~~~~~~~~ Change-Id: I52d85908f4aac20c7e9ac8063ac760ce52f85541 Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/tools/qvector.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 5225b68d40..a526d35ddc 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -692,7 +692,7 @@ typename QVector::iterator QVector::insert(iterator before, size_type n, c { Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid"); - int offset = std::distance(d->begin(), before); + const auto offset = std::distance(d->begin(), before); if (n != 0) { const T copy(t); if (!isDetached() || d->size + n > int(d->alloc)) @@ -728,7 +728,7 @@ typename QVector::iterator QVector::erase(iterator abegin, iterator aend) Q_ASSERT_X(isValidIterator(abegin), "QVector::erase", "The specified iterator argument 'abegin' is invalid"); Q_ASSERT_X(isValidIterator(aend), "QVector::erase", "The specified iterator argument 'aend' is invalid"); - const int itemsToErase = aend - abegin; + const auto itemsToErase = aend - abegin; if (!itemsToErase) return abegin; @@ -737,7 +737,7 @@ typename QVector::iterator QVector::erase(iterator abegin, iterator aend) Q_ASSERT(aend <= d->end()); Q_ASSERT(abegin <= aend); - const int itemsUntouched = abegin - d->begin(); + const auto itemsUntouched = abegin - d->begin(); // FIXME we could do a proper realloc, which copy constructs only needed data. // FIXME we are about to delete data - maybe it is good time to shrink? @@ -766,7 +766,7 @@ typename QVector::iterator QVector::erase(iterator abegin, iterator aend) memmove(static_cast(abegin), static_cast(aend), (d->size - itemsToErase - itemsUntouched) * sizeof(T)); } - d->size -= itemsToErase; + d->size -= int(itemsToErase); } return d->begin() + itemsUntouched; } -- cgit v1.2.3 From a1c27748d22f94d608cc499db527bf989a5516f2 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 2 Mar 2017 14:23:05 +0100 Subject: Make QLocale consistent about special handling of the C locale QLocale::matchingLocales() simply created each locale using the basic data, without (unless the matching conditions stipulated Language C) applying number-options hacks that it applies everywhere else, when creating the C locale. Thus the C locale in its returned list (if it wasn't the only entry) ended up with the default number options, without omiting separators in numbers. Thus QLocale::c() didn't actually appear as an entry in the list. Discovered while investigating QTBUG-58947. Added a dumb autotest that checks various ways of getting the C locale do actually give us equal locale objects. Fixed matchingLocales() to apply the same hack as is used elsewhere for the C locale. Change-Id: I263f31da623052b63171f5b5a83c65802383df21 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 2ce410062a..c183224c82 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2115,8 +2115,8 @@ QList QLocale::matchingLocales(QLocale::Language language, && (language == QLocale::AnyLanguage || data->m_language_id == uint(language))) { if ((script == QLocale::AnyScript || data->m_script_id == uint(script)) && (country == QLocale::AnyCountry || data->m_country_id == uint(country))) { - QLocale locale(*QLocalePrivate::create(data)); - result.append(locale); + result.append(QLocale(*(data->m_language_id == C ? c_private() + : QLocalePrivate::create(data)))); } ++data; } -- cgit v1.2.3 From d6330a19b29ebff359a6746250c78437dbcaf77d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 19 Dec 2016 10:34:32 +0100 Subject: Use QT_CONFIG(library) instead of QT_NO_LIBRARY For the windows file system engine, we add an extra macro to use library loading if configured to do so, but avoid it on WinRT, as none of the symbols would be found. We also QT_REQUIRE_CONFIG(library) in the library headers and exclude the sources from the build if library loading is disabled. This, in turn, makes it necessary to clean up some header inclusions. Change-Id: I2b152cb5b47a2658996b6f4702b038536a5704ec Reviewed-by: Oswald Buddenhagen --- src/corelib/codecs/qiconvcodec.cpp | 1 - src/corelib/global/qconfig-bootstrapped.h | 1 - src/corelib/io/qfilesystemengine_win.cpp | 29 +++++++++-------- src/corelib/io/qfsfileengine_win.cpp | 6 ++-- src/corelib/kernel/qcoreapplication.cpp | 12 +++---- src/corelib/kernel/qcoreapplication.h | 4 +-- src/corelib/plugin/plugin.pri | 53 +++++++++++++++---------------- src/corelib/plugin/qelfparser_p.cpp | 2 -- src/corelib/plugin/qelfparser_p.h | 4 +-- src/corelib/plugin/qfactoryloader.cpp | 12 +++---- src/corelib/plugin/qfactoryloader_p.h | 6 ++-- src/corelib/plugin/qlibrary.cpp | 4 --- src/corelib/plugin/qlibrary.h | 6 ++-- src/corelib/plugin/qlibrary_p.h | 7 ++-- src/corelib/plugin/qlibrary_unix.cpp | 4 --- src/corelib/plugin/qlibrary_win.cpp | 4 --- src/corelib/plugin/qmachparser.cpp | 2 +- src/corelib/plugin/qmachparser_p.h | 4 +-- src/corelib/plugin/qpluginloader.cpp | 4 +-- src/corelib/plugin/qpluginloader.h | 7 ++-- src/corelib/tools/qharfbuzz.cpp | 4 ++- src/corelib/tools/qlocale_icu.cpp | 1 - 22 files changed, 81 insertions(+), 96 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index e4fb359f2c..d6362b6fbc 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -43,7 +43,6 @@ QT_REQUIRE_CONFIG(iconv); #include "qiconvcodec_p.h" #include "qtextcodec_p.h" -#include #include #include diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index a2c0b011e7..bda8ad7916 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -71,7 +71,6 @@ #define QT_FEATURE_iconv -1 #define QT_FEATURE_icu -1 #define QT_FEATURE_journald -1 -#define QT_NO_LIBRARY #define QT_FEATURE_library -1 #define QT_NO_QOBJECT #define QT_FEATURE_process -1 diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index cdb64d08e1..0d4ef94622 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -158,14 +158,15 @@ Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0; #if defined(Q_OS_WINRT) static QString qfsPrivateCurrentDir = QLatin1String(""); -// As none of the functions we try to resolve do exist on WinRT -// we use QT_NO_LIBRARY to shorten everything up a little bit. -# ifndef QT_NO_LIBRARY -# define QT_NO_LIBRARY 1 -# endif +// As none of the functions we try to resolve do exist on WinRT we +// avoid library loading on WinRT in general to shorten everything +// up a little bit. +# define QT_FEATURE_fslibs -1 +#else +# define QT_FEATURE_fslibs QT_FEATURE_library #endif // Q_OS_WINRT -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) QT_BEGIN_INCLUDE_NAMESPACE typedef DWORD (WINAPI *PtrGetNamedSecurityInfoW)(LPWSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION, PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*); static PtrGetNamedSecurityInfoW ptrGetNamedSecurityInfoW = 0; @@ -273,7 +274,7 @@ static void resolveLibs() ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); } } -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(fslibs) typedef DWORD (WINAPI *PtrNetShareEnum)(LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD, LPDWORD); static PtrNetShareEnum ptrNetShareEnum = 0; @@ -343,7 +344,7 @@ static QString readSymLink(const QFileSystemEntry &link) free(rdb); CloseHandle(handle); -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) resolveLibs(); QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive); if (matchVolName.indexIn(result) == 0) { @@ -353,7 +354,7 @@ static QString readSymLink(const QFileSystemEntry &link) if (GetVolumePathNamesForVolumeName(reinterpret_cast(volumeName.utf16()), buffer, MAX_PATH, &len) != 0) result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer)); } -#endif // !Q_OS_WINRT +#endif // QT_CONFIG(fslibs) } #else Q_UNUSED(link); @@ -363,7 +364,7 @@ static QString readSymLink(const QFileSystemEntry &link) static QString readLink(const QFileSystemEntry &link) { -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) QString ret; bool neededCoInit = false; @@ -402,7 +403,7 @@ static QString readLink(const QFileSystemEntry &link) #else Q_UNUSED(link); return QString(); -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(fslibs) } static bool uncShareExists(const QString &server) @@ -648,7 +649,7 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry) QString QFileSystemEngine::owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own) { QString name; -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) extern int qt_ntfs_permission_lookup; if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) { resolveLibs(); @@ -698,7 +699,7 @@ QString QFileSystemEngine::owner(const QFileSystemEntry &entry, QAbstractFileEng bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) { -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) { resolveLibs(); if(ptrGetNamedSecurityInfoW && ptrBuildTrusteeWithSidW && ptrGetEffectiveRightsFromAclW) { @@ -1162,7 +1163,7 @@ QString QFileSystemEngine::rootPath() QString QFileSystemEngine::homePath() { QString ret; -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(fslibs) resolveLibs(); if (ptrGetUserProfileDirectoryW) { HANDLE hnd = ::GetCurrentProcess(); diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 117c224318..e427b62136 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -589,7 +589,7 @@ bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) cons bool QFSFileEngine::link(const QString &newName) { #if !defined(Q_OS_WINRT) -# if !defined(QT_NO_LIBRARY) +# if QT_CONFIG(library) bool ret = false; QString linkName = newName; @@ -630,10 +630,10 @@ bool QFSFileEngine::link(const QString &newName) CoUninitialize(); return ret; -# else // QT_NO_LIBRARY +# else // QT_CONFIG(library) Q_UNUSED(newName); return false; -# endif // QT_NO_LIBRARY +# endif // QT_CONFIG(library) #else // !Q_OS_WINRT Q_UNUSED(newName); Q_UNIMPLEMENTED(); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index c5f2e71f8c..baf140b3b2 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -339,7 +339,7 @@ struct QCoreApplicationData { QString applicationVersion; bool applicationNameSet; // true if setApplicationName was called -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QScopedPointer app_libpaths; QScopedPointer manual_libpaths; #endif @@ -534,7 +534,7 @@ void QCoreApplicationPrivate::checkReceiverThread(QObject *receiver) void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths() { -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QStringList *app_libpaths = coreappdata()->app_libpaths.data(); if (!app_libpaths) coreappdata()->app_libpaths.reset(app_libpaths = new QStringList); @@ -735,7 +735,7 @@ void QCoreApplicationPrivate::init() QLoggingRegistry::instance()->init(); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) // Reset the lib paths, so that they will be recomputed, taking the availability of argv[0] // into account. If necessary, recompute right away and replay the manual changes on top of the // new lib paths. @@ -834,7 +834,7 @@ QCoreApplication::~QCoreApplication() QCoreApplicationPrivate::eventDispatcher = 0; #endif -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) coreappdata()->app_libpaths.reset(); coreappdata()->manual_libpaths.reset(); #endif @@ -2414,7 +2414,7 @@ QString QCoreApplication::applicationVersion() return coreappdata()->applicationVersion; } -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC_WITH_ARGS(QMutex, libraryPathMutex, (QMutex::Recursive)) @@ -2626,7 +2626,7 @@ void QCoreApplication::removeLibraryPath(const QString &path) QFactoryLoader::refreshAll(); } -#endif //QT_NO_LIBRARY +#endif // QT_CONFIG(library) #ifndef QT_NO_QOBJECT diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index a22e1c4f9e..5e10136dc5 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -141,12 +141,12 @@ public: static QString applicationFilePath(); static qint64 applicationPid(); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) static void setLibraryPaths(const QStringList &); static QStringList libraryPaths(); static void addLibraryPath(const QString &); static void removeLibraryPath(const QString &); -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) #ifndef QT_NO_TRANSLATION static bool installTranslator(QTranslator * messageFile); diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri index bb3843cc36..a0e0d76044 100644 --- a/src/corelib/plugin/plugin.pri +++ b/src/corelib/plugin/plugin.pri @@ -1,38 +1,37 @@ # Qt core library plugin module HEADERS += \ - plugin/qfactoryinterface.h \ - plugin/qpluginloader.h \ - plugin/qlibrary.h \ - plugin/qlibrary_p.h \ - plugin/qplugin.h \ - plugin/quuid.h \ - plugin/qfactoryloader_p.h \ - plugin/qsystemlibrary_p.h \ - plugin/qelfparser_p.h \ - plugin/qmachparser_p.h + plugin/qfactoryinterface.h \ + plugin/qpluginloader.h \ + plugin/qplugin.h \ + plugin/quuid.h \ + plugin/qfactoryloader_p.h SOURCES += \ - plugin/qfactoryinterface.cpp \ - plugin/qpluginloader.cpp \ - plugin/qfactoryloader.cpp \ - plugin/quuid.cpp \ - plugin/qlibrary.cpp \ - plugin/qelfparser_p.cpp \ - plugin/qmachparser.cpp + plugin/qfactoryinterface.cpp \ + plugin/qpluginloader.cpp \ + plugin/qfactoryloader.cpp \ + plugin/quuid.cpp win32 { - SOURCES += \ - plugin/qlibrary_win.cpp \ - plugin/qsystemlibrary.cpp + HEADERS += plugin/qsystemlibrary_p.h + SOURCES += plugin/qsystemlibrary.cpp } -unix { - SOURCES += plugin/qlibrary_unix.cpp -} +qtConfig(library) { + HEADERS += \ + plugin/qlibrary.h \ + plugin/qlibrary_p.h \ + plugin/qelfparser_p.h \ + plugin/qmachparser_p.h -integrity { - SOURCES += plugin/qlibrary_unix.cpp -} + SOURCES += \ + plugin/qlibrary.cpp \ + plugin/qelfparser_p.cpp \ + plugin/qmachparser.cpp + + unix: SOURCES += plugin/qlibrary_unix.cpp + else: SOURCES += plugin/qlibrary_win.cpp -qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl + qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl +} diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp index ef1fc4ded3..85478e376e 100644 --- a/src/corelib/plugin/qelfparser_p.cpp +++ b/src/corelib/plugin/qelfparser_p.cpp @@ -39,7 +39,6 @@ #include "qelfparser_p.h" -#ifndef QT_NO_LIBRARY #if defined (Q_OF_ELF) && defined(Q_CC_GNU) #include "qlibrary_p.h" @@ -235,4 +234,3 @@ int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library QT_END_NAMESPACE #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qelfparser_p.h b/src/corelib/plugin/qelfparser_p.h index bcda19e8b5..3e73c5d149 100644 --- a/src/corelib/plugin/qelfparser_p.h +++ b/src/corelib/plugin/qelfparser_p.h @@ -54,7 +54,8 @@ #include #include -#ifndef QT_NO_LIBRARY +QT_REQUIRE_CONFIG(library); + #if defined (Q_OF_ELF) && defined(Q_CC_GNU) QT_BEGIN_NAMESPACE @@ -101,6 +102,5 @@ public: QT_END_NAMESPACE #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) -#endif // QT_NO_LIBRARY #endif // QELFPARSER_P_H diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index b8e18cc9a8..21f1007d5b 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -62,7 +62,7 @@ class QFactoryLoaderPrivate : public QObjectPrivate public: QFactoryLoaderPrivate(){} QByteArray iid; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) ~QFactoryLoaderPrivate(); mutable QMutex mutex; QList libraryList; @@ -73,7 +73,7 @@ public: #endif }; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC(QList, qt_factory_loaders) @@ -232,7 +232,7 @@ void QFactoryLoader::refreshAll() } } -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) QFactoryLoader::QFactoryLoader(const char *iid, const QString &suffix, @@ -242,7 +242,7 @@ QFactoryLoader::QFactoryLoader(const char *iid, moveToThread(QCoreApplicationPrivate::mainThread()); Q_D(QFactoryLoader); d->iid = iid; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) d->cs = cs; d->suffix = suffix; @@ -259,7 +259,7 @@ QList QFactoryLoader::metaData() const { Q_D(const QFactoryLoader); QList metaData; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QMutexLocker locker(&d->mutex); for (int i = 0; i < d->libraryList.size(); ++i) metaData.append(d->libraryList.at(i)->metaData); @@ -281,7 +281,7 @@ QObject *QFactoryLoader::instance(int index) const if (index < 0) return 0; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QMutexLocker lock(&d->mutex); if (index < d->libraryList.size()) { QLibraryPrivate *library = d->libraryList.at(index); diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h index 70a934c976..7be18942ae 100644 --- a/src/corelib/plugin/qfactoryloader_p.h +++ b/src/corelib/plugin/qfactoryloader_p.h @@ -60,7 +60,9 @@ #include "QtCore/qjsondocument.h" #include "QtCore/qmap.h" #include "QtCore/qendian.h" +#if QT_CONFIG(library) #include "private/qlibrary_p.h" +#endif QT_BEGIN_NAMESPACE @@ -84,7 +86,7 @@ public: const QString &suffix = QString(), Qt::CaseSensitivity = Qt::CaseSensitive); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) ~QFactoryLoader(); void update(); @@ -93,7 +95,7 @@ public: #if defined(Q_OS_UNIX) && !defined (Q_OS_MAC) QLibraryPrivate *library(const QString &key) const; #endif // Q_OS_UNIX && !Q_OS_MAC -#endif // !QT_NO_LIBRARY +#endif // QT_CONFIG(library) QMultiMap keyMap() const; int indexOf(const QString &needle) const; diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index a4a654cd88..6421e7c5d8 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -40,8 +40,6 @@ #include "qplatformdefs.h" #include "qlibrary.h" -#ifndef QT_NO_LIBRARY - #include "qfactoryloader_p.h" #include "qlibrary_p.h" #include @@ -1131,5 +1129,3 @@ bool qt_debug_component() } QT_END_NAMESPACE - -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qlibrary.h b/src/corelib/plugin/qlibrary.h index 2b91fa4007..89be52aac3 100644 --- a/src/corelib/plugin/qlibrary.h +++ b/src/corelib/plugin/qlibrary.h @@ -42,9 +42,9 @@ #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(library); -#ifndef QT_NO_LIBRARY +QT_BEGIN_NAMESPACE class QLibraryPrivate; @@ -99,8 +99,6 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QLibrary::LoadHints) -#endif //QT_NO_LIBRARY - QT_END_NAMESPACE #endif //QLIBRARY_H diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h index 7147ff6ca2..3f650501c8 100644 --- a/src/corelib/plugin/qlibrary_p.h +++ b/src/corelib/plugin/qlibrary_p.h @@ -62,10 +62,9 @@ # include "QtCore/qt_windows.h" #endif -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_LIBRARY +QT_REQUIRE_CONFIG(library); +QT_BEGIN_NAMESPACE bool qt_debug_component(); @@ -130,8 +129,6 @@ private: friend class QLibraryStore; }; -#endif // QT_NO_LIBRARY - QT_END_NAMESPACE #endif // QLIBRARY_P_H diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index 8b16021303..6c1253ea08 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -44,8 +44,6 @@ #include #include -#ifndef QT_NO_LIBRARY - #ifdef Q_OS_MAC # include #endif @@ -308,5 +306,3 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol) } QT_END_NAMESPACE - -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp index 48aa0cdbb6..a4d3f67c27 100644 --- a/src/corelib/plugin/qlibrary_win.cpp +++ b/src/corelib/plugin/qlibrary_win.cpp @@ -44,8 +44,6 @@ #include "qfileinfo.h" #include -#ifndef QT_NO_LIBRARY - #include QT_BEGIN_NAMESPACE @@ -174,5 +172,3 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol) return QFunctionPointer(address); } QT_END_NAMESPACE - -#endif // QT_NO_LIBRARY diff --git a/src/corelib/plugin/qmachparser.cpp b/src/corelib/plugin/qmachparser.cpp index a599fbcb23..f506a6a6b1 100644 --- a/src/corelib/plugin/qmachparser.cpp +++ b/src/corelib/plugin/qmachparser.cpp @@ -39,7 +39,7 @@ #include "qmachparser_p.h" -#if defined(Q_OF_MACH_O) && !defined(QT_NO_LIBRARY) +#if defined(Q_OF_MACH_O) #include #include "qlibrary_p.h" diff --git a/src/corelib/plugin/qmachparser_p.h b/src/corelib/plugin/qmachparser_p.h index ff7eaadb70..3884c92797 100644 --- a/src/corelib/plugin/qmachparser_p.h +++ b/src/corelib/plugin/qmachparser_p.h @@ -54,7 +54,8 @@ #include #include -#ifndef QT_NO_LIBRARY +QT_REQUIRE_CONFIG(library); + #if defined(Q_OF_MACH_O) QT_BEGIN_NAMESPACE @@ -72,6 +73,5 @@ public: QT_END_NAMESPACE #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) -#endif // QT_NO_LIBRARY #endif // QMACHPARSER_P_H diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index 6723877ad5..dbd3bee556 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) /*! \class QPluginLoader @@ -417,7 +417,7 @@ QLibrary::LoadHints QPluginLoader::loadHints() const return d ? d->loadHints() : QLibrary::LoadHints(); } -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) typedef QVector StaticPluginList; Q_GLOBAL_STATIC(StaticPluginList, staticPluginList) diff --git a/src/corelib/plugin/qpluginloader.h b/src/corelib/plugin/qpluginloader.h index 5dca59c271..80b10f76bf 100644 --- a/src/corelib/plugin/qpluginloader.h +++ b/src/corelib/plugin/qpluginloader.h @@ -40,12 +40,15 @@ #ifndef QPLUGINLOADER_H #define QPLUGINLOADER_H +#include +#if QT_CONFIG(library) #include +#endif #include QT_BEGIN_NAMESPACE -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) class QLibraryPrivate; class QJsonObject; @@ -93,7 +96,7 @@ public: static QVector staticPlugins(); }; -#endif // QT_NO_LIBRARY +#endif // QT_CONFIG(library) QT_END_NAMESPACE diff --git a/src/corelib/tools/qharfbuzz.cpp b/src/corelib/tools/qharfbuzz.cpp index fdd861690d..a3e266ccd2 100644 --- a/src/corelib/tools/qharfbuzz.cpp +++ b/src/corelib/tools/qharfbuzz.cpp @@ -40,7 +40,9 @@ #include "qharfbuzz_p.h" #include "qunicodetables_p.h" +#if QT_CONFIG(library) #include "qlibrary.h" +#endif QT_USE_NAMESPACE @@ -70,7 +72,7 @@ HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch) void (*HB_Library_Resolve(const char *library, int version, const char *symbol))() { -#ifdef QT_NO_LIBRARY +#if !QT_CONFIG(library) Q_UNUSED(library); Q_UNUSED(version); Q_UNUSED(symbol); diff --git a/src/corelib/tools/qlocale_icu.cpp b/src/corelib/tools/qlocale_icu.cpp index 0066e95d88..afe0aae583 100644 --- a/src/corelib/tools/qlocale_icu.cpp +++ b/src/corelib/tools/qlocale_icu.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "qglobal.h" -#include "qlibrary.h" #include "qdebug.h" #include "qlocale_p.h" #include "qmutex.h" -- cgit v1.2.3 From 6797570a59529b90b5a28923825b56703173fa56 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 27 Feb 2017 12:13:13 +0100 Subject: Fix UB in QFutureInterface: invalid casts from ResultStoreBase to ResultStore<> ResultStore never actually exists, only ResutStoreBase does. So casting to ResultStore and calling its member functions is UB. Put the type dependent function as template member functions within ResultStoreBase and so we don't need QtPrivate::ResultStore anymore. Same goes for the iterator. Change-Id: I739b9d234ba2238977863df77fde3a4471a9abd2 Reviewed-by: Marc Mutz --- src/corelib/thread/qfutureinterface.h | 28 ++++++--------- src/corelib/thread/qresultstore.cpp | 6 ++++ src/corelib/thread/qresultstore.h | 64 +++++++++-------------------------- 3 files changed, 33 insertions(+), 65 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h index 559d26e231..7b12f51e3e 100644 --- a/src/corelib/thread/qfutureinterface.h +++ b/src/corelib/thread/qfutureinterface.h @@ -159,7 +159,7 @@ public: ~QFutureInterface() { if (!derefT()) - resultStore().clear(); + resultStoreBase().template clear(); } static QFutureInterface canceledResult() @@ -169,7 +169,7 @@ public: { other.refT(); if (!derefT()) - resultStore().clear(); + resultStoreBase().template clear(); QFutureInterfaceBase::operator=(other); return *this; } @@ -184,11 +184,6 @@ public: inline const T &resultReference(int index) const; inline const T *resultPointer(int index) const; inline QList results(); -private: - QtPrivate::ResultStore &resultStore() - { return static_cast &>(resultStoreBase()); } - const QtPrivate::ResultStore &resultStore() const - { return static_cast &>(resultStoreBase()); } }; template @@ -199,15 +194,14 @@ inline void QFutureInterface::reportResult(const T *result, int index) return; } - QtPrivate::ResultStore &store = resultStore(); - + QtPrivate::ResultStoreBase &store = resultStoreBase(); if (store.filterMode()) { const int resultCountBefore = store.count(); - store.addResult(index, result); + store.addResult(index, result); this->reportResultsReady(resultCountBefore, resultCountBefore + store.count()); } else { - const int insertIndex = store.addResult(index, result); + const int insertIndex = store.addResult(index, result); this->reportResultsReady(insertIndex, insertIndex + 1); } } @@ -226,7 +220,7 @@ inline void QFutureInterface::reportResults(const QVector &_results, int b return; } - QtPrivate::ResultStore &store = resultStore(); + auto &store = resultStoreBase(); if (store.filterMode()) { const int resultCountBefore = store.count(); @@ -250,14 +244,14 @@ template inline const T &QFutureInterface::resultReference(int index) const { QMutexLocker lock(mutex()); - return resultStore().resultAt(index).value(); + return resultStoreBase().resultAt(index).template value(); } template inline const T *QFutureInterface::resultPointer(int index) const { QMutexLocker lock(mutex()); - return resultStore().resultAt(index).pointer(); + return resultStoreBase().resultAt(index).template pointer(); } template @@ -272,9 +266,9 @@ inline QList QFutureInterface::results() QList res; QMutexLocker lock(mutex()); - QtPrivate::ResultIterator it = resultStore().begin(); - while (it != resultStore().end()) { - res.append(it.value()); + QtPrivate::ResultIteratorBase it = resultStoreBase().begin(); + while (it != resultStoreBase().end()) { + res.append(it.value()); ++it; } diff --git a/src/corelib/thread/qresultstore.cpp b/src/corelib/thread/qresultstore.cpp index aa7ec02d6e..9a6fcec678 100644 --- a/src/corelib/thread/qresultstore.cpp +++ b/src/corelib/thread/qresultstore.cpp @@ -98,6 +98,12 @@ bool ResultIteratorBase::canIncrementVectorIndex() const ResultStoreBase::ResultStoreBase() : insertIndex(0), resultCount(0), m_filterMode(false), filteredResults(0) { } +ResultStoreBase::~ResultStoreBase() +{ + // QFutureInterface's dtor must delete the contents of m_results. + Q_ASSERT(m_results.isEmpty()); +} + void ResultStoreBase::setFilterMode(bool enable) { m_filterMode = enable; diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h index 56cfcb6ed6..be9f632557 100644 --- a/src/corelib/thread/qresultstore.h +++ b/src/corelib/thread/qresultstore.h @@ -93,20 +93,14 @@ public: protected: QMap::const_iterator mapIterator; int m_vectorIndex; -}; - -template -class ResultIterator : public ResultIteratorBase -{ public: - ResultIterator(const ResultIteratorBase &base) - : ResultIteratorBase(base) { } - + template const T &value() const { - return *pointer(); + return *pointer(); } + template const T *pointer() const { if (mapIterator.value().isVector()) @@ -130,7 +124,7 @@ public: ResultIteratorBase resultAt(int index) const; bool contains(int index) const; int count() const; - virtual ~ResultStoreBase() { } + virtual ~ResultStoreBase(); protected: int insertResultItem(int index, ResultItem &resultItem); @@ -147,64 +141,44 @@ protected: QMap pendingResults; int filteredResults; -}; - -template -class ResultStore : public ResultStoreBase -{ public: - ResultStore() { } - - ResultStore(const ResultStoreBase &base) - : ResultStoreBase(base) { } - - int addResult(int index, const T *result) + template + int addResult(int index, const T *result) { if (result == 0) - return ResultStoreBase::addResult(index, result); + return addResult(index, static_cast(nullptr)); else - return ResultStoreBase::addResult(index, new T(*result)); + return addResult(index, static_cast(new T(*result))); } + template int addResults(int index, const QVector *results) { - return ResultStoreBase::addResults(index, new QVector(*results), results->count(), results->count()); + return addResults(index, new QVector(*results), results->count(), results->count()); } + template int addResults(int index, const QVector *results, int totalCount) { if (m_filterMode == true && results->count() != totalCount && 0 == results->count()) - return ResultStoreBase::addResults(index, 0, 0, totalCount); + return addResults(index, 0, 0, totalCount); else - return ResultStoreBase::addResults(index, new QVector(*results), results->count(), totalCount); + return addResults(index, new QVector(*results), results->count(), totalCount); } int addCanceledResult(int index) { - return addResult(index, 0); + return addResult(index, static_cast(nullptr)); } + template int addCanceledResults(int index, int _count) { QVector empty; return addResults(index, &empty, _count); } - ResultIterator begin() const - { - return static_cast >(ResultStoreBase::begin()); - } - - ResultIterator end() const - { - return static_cast >(ResultStoreBase::end()); - } - - ResultIterator resultAt(int index) const - { - return static_cast >(ResultStoreBase::resultAt(index)); - } - + template void clear() { QMap::const_iterator mapIterator = m_results.constBegin(); @@ -218,12 +192,6 @@ public: resultCount = 0; m_results.clear(); } - - ~ResultStore() - { - clear(); - } - }; } // namespace QtPrivate -- cgit v1.2.3 From e7295c959b73cec09e36d3703d5619e8e7aa5fb1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 16 Dec 2016 12:56:23 -0800 Subject: Add -Wfloat-equal to Qt's header clean check Task-number: QTBUG-57649 Change-Id: I15b62e0f9cec482fbb40fffd1490d802c54bf0fe Reviewed-by: Marc Mutz Reviewed-by: Lars Knoll --- src/corelib/tools/qrect.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index f973cf3494..4030cccbd5 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -662,12 +662,18 @@ Q_DECL_CONSTEXPR inline QRectF::QRectF(const QRect &r) Q_DECL_NOTHROW { } +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") + Q_DECL_CONSTEXPR inline bool QRectF::isNull() const Q_DECL_NOTHROW { return w == 0. && h == 0.; } Q_DECL_CONSTEXPR inline bool QRectF::isEmpty() const Q_DECL_NOTHROW { return w <= 0. || h <= 0.; } +QT_WARNING_POP + Q_DECL_CONSTEXPR inline bool QRectF::isValid() const Q_DECL_NOTHROW { return w > 0. && h > 0.; } -- cgit v1.2.3