From 6a8537356be5766fcdc5cf8fcb5fabb81abd09e7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 6 Aug 2012 16:27:18 +0200 Subject: Mark QElapsedTimer functions as Q_DECL_NOTHROW All functions in QElapsedTimer are marked Q_DECL_NOTHROW. This code is often introduced in many places to deal with timeouts and doesn't need exception handlers. In particular, it's used in QMutex locking. In addition, mark QDateTime::currentMSecsSinceEpoch as nothrow, as it can't throw exceptions either and it is needed by the generic QElapsedTimer. Q{Date,Time}::current{Date,Time} operate on local time and run into at least one cancellation point, which we must consider throwing. And returning a QDateTime allocates memory. Change-Id: Id776c5ec831fc06d7419a9ff5442d9b35cff1a22 Reviewed-by: Marc Mutz Reviewed-by: Lars Knoll --- src/corelib/tools/qelapsedtimer_generic.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/corelib/tools/qelapsedtimer_generic.cpp') diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/tools/qelapsedtimer_generic.cpp index a20b6b5662..fc53fd9b8a 100644 --- a/src/corelib/tools/qelapsedtimer_generic.cpp +++ b/src/corelib/tools/qelapsedtimer_generic.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE \sa isMonotonic() */ -QElapsedTimer::ClockType QElapsedTimer::clockType() +QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW { return SystemTime; } @@ -61,7 +61,7 @@ QElapsedTimer::ClockType QElapsedTimer::clockType() \sa clockType(), QElapsedTimer::ClockType */ -bool QElapsedTimer::isMonotonic() +bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW { return false; } @@ -76,7 +76,7 @@ bool QElapsedTimer::isMonotonic() \sa restart(), invalidate(), elapsed() */ -void QElapsedTimer::start() +void QElapsedTimer::start() Q_DECL_NOTHROW { restart(); } @@ -95,7 +95,7 @@ void QElapsedTimer::start() \sa start(), invalidate(), elapsed() */ -qint64 QElapsedTimer::restart() +qint64 QElapsedTimer::restart() Q_DECL_NOTHROW { qint64 old = t1; t1 = QDateTime::currentMSecsSinceEpoch(); @@ -114,7 +114,7 @@ qint64 QElapsedTimer::restart() \sa start(), restart(), hasExpired(), invalidate() */ -qint64 QElapsedTimer::nsecsElapsed() const +qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW { return elapsed() * 1000000; } @@ -126,7 +126,7 @@ qint64 QElapsedTimer::nsecsElapsed() const \sa start(), restart(), hasExpired(), invalidate() */ -qint64 QElapsedTimer::elapsed() const +qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW { return QDateTime::currentMSecsSinceEpoch() - t1; } @@ -142,7 +142,7 @@ qint64 QElapsedTimer::elapsed() const \sa clockType(), elapsed() */ -qint64 QElapsedTimer::msecsSinceReference() const +qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW { return t1; } @@ -157,7 +157,7 @@ qint64 QElapsedTimer::msecsSinceReference() const \sa secsTo(), elapsed() */ -qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const +qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW { qint64 diff = other.t1 - t1; return diff; @@ -172,7 +172,7 @@ qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const \sa msecsTo(), elapsed() */ -qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const +qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW { return msecsTo(other) / 1000; } @@ -186,7 +186,7 @@ qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const and the other isn't. However, two invalid timers are equal and thus this function will return false. */ -bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) +bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW { return v1.t1 < v2.t1; } -- cgit v1.2.3