From 1a3a8cf87b322b45fe38db7c270ce8235e979d3b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 17 Nov 2016 11:17:33 +0100 Subject: QDeadlineTimer: mark more functions nothrow Change-Id: I3be9c69b46901311e9150a7f718707d8ff523e9e Reviewed-by: Thiago Macieira --- src/corelib/kernel/qdeadlinetimer.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h index 3b97b89359..aa0f735fcc 100644 --- a/src/corelib/kernel/qdeadlinetimer.h +++ b/src/corelib/kernel/qdeadlinetimer.h @@ -62,7 +62,7 @@ public: : t1(std::numeric_limits::max()), t2(0), type(type_) {} explicit QDeadlineTimer(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW; - void swap(QDeadlineTimer &other) + void swap(QDeadlineTimer &other) Q_DECL_NOTHROW { qSwap(t1, other.t1); qSwap(t2, other.t2); qSwap(type, other.type); } Q_DECL_CONSTEXPR bool isForever() const Q_DECL_NOTHROW @@ -88,17 +88,17 @@ public: static QDeadlineTimer addNSecs(QDeadlineTimer dt, qint64 nsecs) Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION; static QDeadlineTimer current(Qt::TimerType timerType = Qt::CoarseTimer) Q_DECL_NOTHROW; - friend bool operator==(QDeadlineTimer d1, QDeadlineTimer d2) + friend bool operator==(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW { return d1.t1 == d2.t1 && d1.t2 == d2.t2; } - friend bool operator!=(QDeadlineTimer d1, QDeadlineTimer d2) + friend bool operator!=(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW { return !(d1 == d2); } - friend bool operator<(QDeadlineTimer d1, QDeadlineTimer d2) + friend bool operator<(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW { return d1.t1 < d2.t1 || (d1.t1 == d2.t1 && d1.t2 < d2.t2); } - friend bool operator<=(QDeadlineTimer d1, QDeadlineTimer d2) + friend bool operator<=(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW { return d1 == d2 || d1 < d2; } - friend bool operator>(QDeadlineTimer d1, QDeadlineTimer d2) + friend bool operator>(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW { return d2 < d1; } - friend bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2) + friend bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW { return !(d1 < d2); } friend QDeadlineTimer operator+(QDeadlineTimer dt, qint64 msecs) -- cgit v1.2.3 From b5222307af591c5360a64ffa311bde4a61af97d6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 19 Oct 2016 16:37:53 +0200 Subject: Fix some qdoc-warnings qtbase/src/corelib/kernel/qdeadlinetimer.cpp:343: warning: Cannot find 'setPreciseRemainingTime(...)' in '\fn' void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, unsigned nsecs, Qt::TimerType type) qtbase/src/corelib/kernel/qdeadlinetimer.cpp:459: warning: Overrides a previous doc qtbase/src/corelib/kernel/qelapsedtimer.cpp:86: warning: Unknown command '\ref' qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_2_2' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_3_0' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_2_1' in QSysInfo::MacVersion qtbase/src/corelib/global/qglobal.cpp:1184: warning: Undocumented enum item 'MV_WATCHOS_2_0' in QSysInfo::MacVersion qtbase/src/corelib/kernel/qdeadlinetimer.cpp:175: warning: Missing parameter name qtbase/src/corelib/kernel/qdeadlinetimer.cpp:175: warning: No such parameter 'ForeverConstant' in QDeadlineTimer::QDeadlineTimer() qtbase/src/corelib/kernel/qdeadlinetimer.h:156: warning: No documentation for 'QDeadlineTimer::remainingTimeAsDuration()' qtbase/src/gui/painting/qcolor.cpp:796: warning: Undocumented parameter 'name' in QColor::QColor() qtbase/src/gui/painting/qcolor.cpp:802: warning: Undocumented parameter 'name' in QColor::QColor() Some errors in QDeadlineTimer remain due to qdoc not fully supporting templates. Change-Id: Ie7afd91c48048748eeda23c32056583c31fd7490 Reviewed-by: Nico Vertriest Reviewed-by: Jake Petroules --- src/corelib/kernel/qdeadlinetimer.cpp | 25 ++++--------------------- src/corelib/kernel/qelapsedtimer.cpp | 2 +- 2 files changed, 5 insertions(+), 22 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp index 17a74b22d7..d670637d53 100644 --- a/src/corelib/kernel/qdeadlinetimer.cpp +++ b/src/corelib/kernel/qdeadlinetimer.cpp @@ -173,9 +173,9 @@ Q_DECL_CONST_FUNCTION static inline QPair toSecsAndNSecs(qint64 */ /*! - \fn QDeadlineTimer::QDeadlineTimer(ForeverConstant, Qt::TimerType timerType) + \fn QDeadlineTimer::QDeadlineTimer(ForeverConstant foreverConstant, Qt::TimerType timerType) - QDeadlineTimer objects created with parameter \a ForeverConstant never expire. + QDeadlineTimer objects created with parameter \a foreverConstant never expire. For such objects, remainingTime() will return -1, deadline() will return the maximum value, and isForever() will return true. @@ -295,7 +295,7 @@ void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) Q_D parameters are zero, this QDeadlineTimer will be marked as expired. The timer type for this QDeadlineTimer object will be set to the specified - \a type. + \a timerType. \sa setRemainingTime(), hasExpired(), isForever(), remainingTime() */ @@ -341,24 +341,7 @@ void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::Time */ /*! - \fn void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, unsigned nsecs, Qt::TimerType type) - - Sets the remaining time for this QDeadlineTimer object to \a secs seconds - and \a nsecs nanoseconds from now, if \a secs is a positive value. If both - values are zero, this QDeadlineTimer object will be marked as expired, - whereas if \a secs is -1, it will set it to never expire. - - If value of \a nsecs is more than 1 billion nanoseconds (1 second), this - function will adjust \a secs accordingly. - - The timer type for this QDeadlineTimer object will be set to the specified \a type. - - \sa setRemainingTime(), hasExpired(), isForever(), remainingTime() -*/ - -/*! - \overload - \fn Duration QDeadlineTimer::remainingTime() const + \fn std::chrono::nanoseconds remainingTimeAsDuration() const Returns a \c{std::chrono::duration} object of type \c{Duration} containing the remaining time in this QDeadlineTimer, if it still has time left. If diff --git a/src/corelib/kernel/qelapsedtimer.cpp b/src/corelib/kernel/qelapsedtimer.cpp index 5e9d1317ac..e578b5b8b3 100644 --- a/src/corelib/kernel/qelapsedtimer.cpp +++ b/src/corelib/kernel/qelapsedtimer.cpp @@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE \snippet qelapsedtimer/main.cpp 2 - It is often more convenient to use \ref{QDeadlineTimer} in this case, which + It is often more convenient to use \l{QDeadlineTimer} in this case, which counts towards a timeout in the future instead of tracking elapsed time. \section1 Reference Clocks -- cgit v1.2.3 From a32424b46cd3ef6fd8d644354e3cec434d5ab951 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 15 Nov 2016 17:15:56 +0100 Subject: AreArgumentsNarrowedBase: Correct logic for narrowing connect() casts The prior test deemed there to be narrowing if source and destination integral-or-enum types didn't have the same signedness; but all values of an unsigned source type can be represented in a larger signed destination type, so there is no narrowing in this case. Updated QObject test-case to match. Change-Id: I517a5997adcad70e185d7469a8d26788e463cb75 Reviewed-by: Giuseppe D'Angelo --- src/corelib/kernel/qobjectdefs_impl.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index e94e713e1f..79c9c8303e 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -229,8 +229,14 @@ namespace QtPrivate { (std::is_floating_point::value && std::is_integral::value) || (std::is_floating_point::value && std::is_floating_point::value && sizeof(From) > sizeof(To)) || ((std::is_integral::value || std::is_enum::value) && std::is_floating_point::value) || - (std::is_integral::value && std::is_integral::value && (sizeof(From) > sizeof(To) || std::is_signed::value != std::is_signed::value)) || - (std::is_enum::value && std::is_integral::value && (sizeof(From) > sizeof(To) || IsEnumUnderlyingTypeSigned::value != std::is_signed::value)) + (std::is_integral::value && std::is_integral::value + && (sizeof(From) > sizeof(To) + || (std::is_signed::value ? !std::is_signed::value + : (std::is_signed::value && sizeof(From) == sizeof(To))))) || + (std::is_enum::value && std::is_integral::value + && (sizeof(From) > sizeof(To) + || (IsEnumUnderlyingTypeSigned::value ? !std::is_signed::value + : (std::is_signed::value && sizeof(From) == sizeof(To))))) > { }; -- cgit v1.2.3 From 8f2088db171a6941feb1903a2912a8b7fdf3a9ec Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 24 Nov 2016 15:44:57 +0100 Subject: winrt: Check for removed timers after sending events After all the check makes sense here. If a timer was removed as a result of sendEvent and it was not at the end of the list the list is not shrunk but the timer info's id is just set to INVALID_TIMER_ID. Additionally the timer's object should be fetched before we unlock the locker as timerIdToObject is changed in removeTimer and we might access a nullptr if the timer has been removed. Reverts c83ba01f7bc542368973f3f24dfb59c6052dd78a Task-number: QTBUG-56756 Change-Id: Ib1a04c02fbfcf4c939b4891d42f954dc9e87149e Reviewed-by: Maurice Kalinowski --- src/corelib/kernel/qeventdispatcher_winrt.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp index ff397fc750..33753ed507 100644 --- a/src/corelib/kernel/qeventdispatcher_winrt.cpp +++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp @@ -166,7 +166,7 @@ private: timerIdToHandle.insert(id, handle); timerIdToCancelHandle.insert(id, cancelHandle); } - timerIdToObject.insert(id, obj); + const quint64 targetTime = qt_msectime() + interval; const WinRTTimerInfo info(id, interval, type, obj, targetTime); QMutexLocker locker(&timerInfoLock); @@ -587,15 +587,18 @@ bool QEventDispatcherWinRT::event(QEvent *e) break; info.inEvent = true; + QObject *timerObj = d->timerIdToObject.value(id); locker.unlock(); QTimerEvent te(id); - QCoreApplication::sendEvent(d->timerIdToObject.value(id), &te); + QCoreApplication::sendEvent(timerObj, &te); locker.relock(); - // The timer might have been removed in the meanwhile - if (id >= d->timerInfos.size()) + // The timer might have been removed in the meanwhile. If the timer was + // the last one in the list, id is bigger than the list's size. + // Otherwise, the id will just be set to INVALID_TIMER_ID. + if (id >= d->timerInfos.size() || info.timerId == INVALID_TIMER_ID) break; if (info.interval == 0 && info.inEvent) { -- cgit v1.2.3 From b82650891ee594628fb1bd150408a23a37217e72 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 18 Nov 2016 13:22:25 +0100 Subject: Use poll related features properly And get rid of related DEFINES in the pri file Change-Id: I54cf25b7cb447af22b410213759044e8018939a6 Reviewed-by: Oswald Buddenhagen --- src/corelib/kernel/kernel.pri | 3 --- src/corelib/kernel/qcore_unix.cpp | 14 +++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index 7799113d30..61d0f2bdf1 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -151,9 +151,6 @@ unix|integrity { kernel/qtimerinfo_unix_p.h qtConfig(poll_select): SOURCES += kernel/qpoll.cpp - qtConfig(poll_poll): DEFINES += QT_HAVE_POLL - qtConfig(poll_ppoll): DEFINES += QT_HAVE_POLL QT_HAVE_PPOLL - qtConfig(poll_pollts): DEFINES += QT_HAVE_POLL QT_HAVE_POLLTS qtConfig(glib) { SOURCES += \ diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index 2042964427..686143f8c7 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -38,6 +38,7 @@ ** ****************************************************************************/ +#include #include "qcore_unix_p.h" #include "qelapsedtimer.h" @@ -49,9 +50,8 @@ QT_BEGIN_NAMESPACE -#if !defined(QT_HAVE_PPOLL) && defined(QT_HAVE_POLLTS) -# define ppoll pollts -# define QT_HAVE_PPOLL +#if QT_CONFIG(poll_pollts) +# define ppoll pollts #endif static inline bool time_update(struct timespec *tv, const struct timespec &start, @@ -64,7 +64,7 @@ static inline bool time_update(struct timespec *tv, const struct timespec &start return tv->tv_sec >= 0; } -#if !defined(QT_HAVE_PPOLL) && defined(QT_HAVE_POLL) +#if QT_CONFIG(poll_poll) static inline int timespecToMillisecs(const struct timespec *ts) { return (ts == NULL) ? -1 : @@ -77,9 +77,9 @@ int qt_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts); static inline int qt_ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts) { -#if defined(QT_HAVE_PPOLL) - return ::ppoll(fds, nfds, timeout_ts, Q_NULLPTR); -#elif defined(QT_HAVE_POLL) +#if QT_CONFIG(poll_ppoll) || QT_CONFIG(poll_pollts) + return ::ppoll(fds, nfds, timeout_ts, nullptr); +#elif QT_CONFIG(poll_poll) return ::poll(fds, nfds, timespecToMillisecs(timeout_ts)); #else return qt_poll(fds, nfds, timeout_ts); -- cgit v1.2.3 From fec08545ff0b4fb2ce68a7d7502273a599472141 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Tue, 18 Oct 2016 17:44:54 +0300 Subject: QVariant: optimize convert() for bool case Do not create QByteArray from const char* to compare with other QByteArray, because there is an overloaded operator==. So avoid needless allocations. Reorder condition, because isEmpty() method is cheaper than string compare. Change-Id: I8d2c8a0fb247528d9ce485007431167372d62bff Reviewed-by: Edward Welbourne --- src/corelib/kernel/qvariant.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index ccfa7d0d38..0ffc22d810 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -319,7 +319,7 @@ template inline bool qt_convertToBool(const QVariant::Private *const d) { TInput str = v_cast(d)->toLower(); - return !(str == LiteralWrapper("0") || str == LiteralWrapper("false") || str.isEmpty()); + return !(str.isEmpty() || str == LiteralWrapper("0") || str == LiteralWrapper("false")); } /*! @@ -700,7 +700,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) bool *b = static_cast(result); switch(d->type) { case QVariant::ByteArray: - *b = qt_convertToBool(d); + *b = qt_convertToBool(d); break; case QVariant::String: *b = qt_convertToBool(d); -- cgit v1.2.3