summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qlogging.cpp3
-rw-r--r--src/corelib/global/qt_pch.h6
-rw-r--r--src/corelib/global/qtrace_p.h17
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp9
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp8
-rw-r--r--src/corelib/qtcore.tracepoints10
-rw-r--r--src/corelib/tools/qdatetime_p.h4
-rw-r--r--src/corelib/tools/qstring.cpp4
-rw-r--r--src/corelib/tools/qtimezoneprivate_tz.cpp55
9 files changed, 79 insertions, 37 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index a4d86e393b..4941ca45aa 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -57,6 +57,7 @@
#include "private/qloggingregistry_p.h"
#include "private/qcoreapplication_p.h"
#include "private/qsimd_p.h"
+#include <qtcore_tracepoints_p.h>
#endif
#ifdef Q_OS_WIN
#include <qt_windows.h>
@@ -1811,6 +1812,8 @@ static void ungrabMessageHandler() { }
static void qt_message_print(QtMsgType msgType, const QMessageLogContext &context, const QString &message)
{
#ifndef QT_BOOTSTRAPPED
+ Q_TRACE(qt_message_print, msgType, context.category, context.function, context.file, context.line, message);
+
// qDebug, qWarning, ... macros do not check whether category is enabled
if (isDefaultCategory(context.category)) {
if (QLoggingCategory *defaultCategory = QLoggingCategory::defaultCategory()) {
diff --git a/src/corelib/global/qt_pch.h b/src/corelib/global/qt_pch.h
index 76e46374c3..3972991618 100644
--- a/src/corelib/global/qt_pch.h
+++ b/src/corelib/global/qt_pch.h
@@ -60,12 +60,18 @@
# undef _POSIX_
#endif
#include <qcoreapplication.h>
+#include <qcoreevent.h>
+#include <qiodevice.h>
#include <qlist.h>
#include <qvariant.h> /* All moc genereated code has this include */
#include <qobject.h>
#include <qregexp.h>
+#include <qscopedpointer.h>
+#include <qshareddata.h>
#include <qstring.h>
#include <qstringlist.h>
+#include <qtimer.h>
+#include <qvector.h>
#if QT_CONFIG(textcodec)
#include <qtextcodec.h>
#endif
diff --git a/src/corelib/global/qtrace_p.h b/src/corelib/global/qtrace_p.h
index 56d1f9a318..b72fdd886d 100644
--- a/src/corelib/global/qtrace_p.h
+++ b/src/corelib/global/qtrace_p.h
@@ -52,11 +52,18 @@
//
/*
- * The Qt tracepoints API consists of only three macros:
+ * The Qt tracepoints API consists of only five macros:
*
* - Q_TRACE(tracepoint, args...)
* Fires 'tracepoint' if it is enabled.
*
+ * - Q_TRACE_EXIT(tracepoint, args...)
+ * Fires 'tracepoint' if it is enabled when the current scope exists.
+ *
+ * - Q_TRACE_SCOPE(tracepoint, args...)
+ * Wrapper around Q_TRACE/_EXIT to trace entry and exit. First it traces
+ * `${tracepoint}_entry` and then `${tracepoint}_exit` on scope exit.
+ *
* - Q_UNCONDITIONAL_TRACE(tracepoint, args...)
* Fires 'tracepoint' unconditionally: no check is performed to query
* whether 'tracepoint' is enabled.
@@ -110,17 +117,25 @@
*/
#include <QtCore/qglobal.h>
+#include <QtCore/qscopeguard.h>
QT_BEGIN_NAMESPACE
#if defined(Q_TRACEPOINT) && !defined(QT_BOOTSTRAPPED)
# define Q_HAS_TRACEPOINTS 1
# define Q_TRACE(x, ...) QtPrivate::trace_ ## x(__VA_ARGS__)
+# define Q_TRACE_EXIT(x, ...) \
+ const auto qTraceExit_ ## x ## __COUNTER__ = qScopeGuard([&]() { Q_TRACE(x, __VA_ARGS__); });
+# define Q_TRACE_SCOPE(x, ...) \
+ Q_TRACE(x ## _entry, __VA_ARGS__); \
+ Q_TRACE_EXIT(x ## _exit, __VA_ARGS__);
# define Q_UNCONDITIONAL_TRACE(x, ...) QtPrivate::do_trace_ ## x(__VA_ARGS__)
# define Q_TRACE_ENABLED(x) QtPrivate::trace_ ## x ## _enabled()
#else
# define Q_HAS_TRACEPOINTS 0
# define Q_TRACE(x, ...)
+# define Q_TRACE_EXIT(x, ...)
+# define Q_TRACE_SCOPE(x, ...)
# define Q_UNCONDITIONAL_TRACE(x, ...)
# define Q_TRACE_ENABLED(x) false
#endif // defined(Q_TRACEPOINT) && !defined(QT_BOOTSTRAPPED)
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index 1809861fc6..c2c3b2702b 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -86,15 +86,6 @@ static void appendOrganizationAndApp(QString &path) // Courtesy qstandardpaths_u
#endif
}
-static inline QString displayName(QStandardPaths::StandardLocation type)
-{
-#ifndef QT_BOOTSTRAPPED
- return QStandardPaths::displayName(type);
-#else
- return QString::number(type);
-#endif
-}
-
static inline void appendTestMode(QString &path)
{
if (QStandardPaths::isTestModeEnabled())
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 4100fad28e..d9fdb7f785 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -769,7 +769,7 @@ QCoreApplication::QCoreApplication(int &argc, char **argv
void QCoreApplicationPrivate::init()
{
- Q_TRACE(QCoreApplicationPrivate_init_entry);
+ Q_TRACE_SCOPE(QCoreApplicationPrivate_init);
#if defined(Q_OS_MACOS)
QMacAutoReleasePool pool;
@@ -869,8 +869,6 @@ void QCoreApplicationPrivate::init()
#ifndef QT_NO_QOBJECT
is_app_running = true; // No longer starting up.
#endif
-
- Q_TRACE(QCoreApplicationPrivate_init_exit);
}
/*!
@@ -1185,7 +1183,7 @@ bool QCoreApplicationPrivate::notify_helper(QObject *receiver, QEvent * event)
{
// Note: when adjusting the tracepoints in here
// consider adjusting QApplicationPrivate::notify_helper too.
- Q_TRACE(QCoreApplication_notify_entry, receiver, event, event->type());
+ Q_TRACE_SCOPE(QCoreApplication_notify, receiver, event, event->type());
// send to all application event filters (only does anything in the main thread)
if (QCoreApplication::self
@@ -1484,7 +1482,7 @@ bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *event)
*/
void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
{
- Q_TRACE(QCoreApplication_postEvent_entry, receiver, event, event->type());
+ Q_TRACE_SCOPE(QCoreApplication_postEvent, receiver, event, event->type());
if (receiver == 0) {
qWarning("QCoreApplication::postEvent: Unexpected null receiver");
diff --git a/src/corelib/qtcore.tracepoints b/src/corelib/qtcore.tracepoints
index 33734a4274..3a70136741 100644
--- a/src/corelib/qtcore.tracepoints
+++ b/src/corelib/qtcore.tracepoints
@@ -1,3 +1,9 @@
+{
+QT_BEGIN_NAMESPACE
+class QEvent;
+QT_END_NAMESPACE
+}
+
QCoreApplicationPrivate_init_entry()
QCoreApplicationPrivate_init_exit()
@@ -10,6 +16,7 @@ QEvent_ctor(QEvent *event, int type)
QEvent_dtor(QEvent *event, int type)
QCoreApplication_postEvent_entry(QObject *receiver, QEvent *event, int type)
+QCoreApplication_postEvent_exit(QObject *receiver, QEvent *event, int type)
QCoreApplication_postEvent_event_compressed(QObject *receiver, QEvent *event)
QCoreApplication_postEvent_event_posted(QObject *receiver, QEvent *event, int type)
@@ -17,6 +24,7 @@ QCoreApplication_sendEvent(QObject *receiver, QEvent *event, int type)
QCoreApplication_sendSpontaneousEvent(QObject *receiver, QEvent *event, int type)
QCoreApplication_notify_entry(QObject *receiver, QEvent *event, int type)
+QCoreApplication_notify_exit(QObject *receiver, QEvent *event, int type)
QCoreApplication_notify_event_filtered(QObject *receiver, QEvent *event, int type)
QCoreApplication_notify_before_delivery(QObject *receiver, QEvent *event, int type)
QCoreApplication_notify_after_delivery(QObject *receiver, QEvent *event, int type, bool consumed)
@@ -32,3 +40,5 @@ QMetaObject_activate_begin_slot_functor(void *slotObject)
QMetaObject_activate_end_slot_functor(void *slotObject)
QMetaObject_activate_begin_declarative_signal(QObject *sender, int signalIndex)
QMetaObject_activate_end_declarative_signal(QObject *sender, int signalIndex)
+
+qt_message_print(int type, const char *category, const char *function, const char *file, int line, const QString &message)
diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h
index 6e4120d762..6018f8f7b0 100644
--- a/src/corelib/tools/qdatetime_p.h
+++ b/src/corelib/tools/qdatetime_p.h
@@ -140,6 +140,10 @@ public:
// Inlined for its one caller in qdatetime.cpp
inline void setUtcOffsetByTZ(qint64 atMSecsSinceEpoch);
#endif // timezone
+
+ // ### Qt 5.14: expose publicly in QDateTime
+ // The first and last years of which QDateTime can represent some part:
+ enum class YearRange : qint32 { First = -292275056, Last = +292278994 };
};
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 39cb016d98..029499039c 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -494,7 +494,11 @@ bool qt_is_ascii(const char *&ptr, const char *end) noexcept
while (ptr + 4 <= end) {
quint32 data = qFromUnaligned<quint32>(ptr);
if (data &= 0x80808080U) {
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ uint idx = qCountLeadingZeroBits(data);
+#else
uint idx = qCountTrailingZeroBits(data);
+#endif
ptr += idx / 8;
return false;
}
diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp
index 6105c93a23..fab0b2cbf1 100644
--- a/src/corelib/tools/qtimezoneprivate_tz.cpp
+++ b/src/corelib/tools/qtimezoneprivate_tz.cpp
@@ -39,6 +39,7 @@
#include "qtimezone.h"
#include "qtimezoneprivate_p.h"
+#include "qdatetime_p.h" // ### Qt 5.14: remove once YearRange is on QDateTime
#include <QtCore/QFile>
#include <QtCore/QHash>
@@ -520,19 +521,14 @@ PosixZone PosixZone::parse(const char *&pos, const char *end)
static QVector<QTimeZonePrivate::Data> calculatePosixTransitions(const QByteArray &posixRule,
int startYear, int endYear,
- int lastTranMSecs)
+ qint64 lastTranMSecs)
{
QVector<QTimeZonePrivate::Data> result;
- // Limit year by qint64 max size for msecs
- if (startYear > 292278994)
- startYear = 292278994;
- if (endYear > 292278994)
- endYear = 292278994;
-
// POSIX Format is like "TZ=CST6CDT,M3.2.0/2:00:00,M11.1.0/2:00:00"
// i.e. "std offset dst [offset],start[/time],end[/time]"
- // See the section about TZ at http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
+ // See the section about TZ at
+ // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
QList<QByteArray> parts = posixRule.split(',');
PosixZone stdZone, dstZone = PosixZone::invalid();
@@ -583,6 +579,13 @@ static QVector<QTimeZonePrivate::Data> calculatePosixTransitions(const QByteArra
else
stdTime = QTime(2, 0, 0);
+ // Limit year to the range QDateTime can represent:
+ const int minYear = int(QDateTimePrivate::YearRange::First);
+ const int maxYear = int(QDateTimePrivate::YearRange::Last);
+ startYear = qBound(minYear, startYear, maxYear);
+ endYear = qBound(minYear, endYear, maxYear);
+ Q_ASSERT(startYear <= endYear);
+
for (int year = startYear; year <= endYear; ++year) {
QTimeZonePrivate::Data dstData;
QDateTime dst(calculatePosixDate(dstDateRule, year), dstTime, Qt::UTC);
@@ -598,13 +601,16 @@ static QVector<QTimeZonePrivate::Data> calculatePosixTransitions(const QByteArra
stdData.standardTimeOffset = stdZone.offset;
stdData.daylightTimeOffset = 0;
stdData.abbreviation = stdZone.name;
- // Part of the high year will overflow
- if (year == 292278994 && (dstData.atMSecsSinceEpoch < 0 || stdData.atMSecsSinceEpoch < 0)) {
+ // Part of maxYear will overflow (likewise for minYear, below):
+ if (year == maxYear && (dstData.atMSecsSinceEpoch < 0 || stdData.atMSecsSinceEpoch < 0)) {
if (dstData.atMSecsSinceEpoch > 0) {
result << dstData;
} else if (stdData.atMSecsSinceEpoch > 0) {
result << stdData;
}
+ } else if (year < 1970) { // We ignore DST before the epoch.
+ if (year > minYear || stdData.atMSecsSinceEpoch != QTimeZonePrivate::invalidMSecs())
+ result << stdData;
} else if (dst < std) {
result << dstData << stdData;
} else {
@@ -794,6 +800,8 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000;
m_tranTimes.append(tran);
}
+ if (m_tranTimes.isEmpty() && m_posixRule.isEmpty())
+ return; // Invalid after all !
if (ianaId.isEmpty())
m_id = systemTimeZoneId();
@@ -954,22 +962,25 @@ QVector<QTimeZonePrivate::Data> QTzTimeZonePrivate::getPosixTransitions(qint64 m
QTimeZonePrivate::Data QTzTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const
{
// If the required time is after the last transition (or there were none)
- // and we have a POSIX rule then use it:
- if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch)
- && !m_posixRule.isEmpty() && forMSecsSinceEpoch >= 0) {
+ // and we have a POSIX rule, then use it:
+ if (!m_posixRule.isEmpty()
+ && (m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch)) {
QVector<QTimeZonePrivate::Data> posixTrans = getPosixTransitions(forMSecsSinceEpoch);
auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(),
[forMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) {
return at.atMSecsSinceEpoch <= forMSecsSinceEpoch;
});
- if (it > posixTrans.cbegin()) {
- QTimeZonePrivate::Data data = *--it;
+ // Use most recent, if any in the past; or the first if we have no other rules:
+ if (it > posixTrans.cbegin() || (m_tranTimes.isEmpty() && it < posixTrans.cend())) {
+ QTimeZonePrivate::Data data = *(it > posixTrans.cbegin() ? it - 1 : it);
data.atMSecsSinceEpoch = forMSecsSinceEpoch;
return data;
}
}
+ if (m_tranTimes.isEmpty()) // Only possible if !isValid()
+ return invalidData();
- // Otherwise, if we can find a valid tran, then use its rule:
+ // Otherwise, use the rule for the most recent or first transition:
auto last = std::partition_point(m_tranTimes.cbegin(), m_tranTimes.cend(),
[forMSecsSinceEpoch] (const QTzTransitionTime &at) {
return at.atMSecsSinceEpoch <= forMSecsSinceEpoch;
@@ -989,9 +1000,9 @@ bool QTzTimeZonePrivate::hasTransitions() const
QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSinceEpoch) const
{
// If the required time is after the last transition (or there were none)
- // and we have a POSIX rule then use it:
- if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < afterMSecsSinceEpoch)
- && !m_posixRule.isEmpty() && afterMSecsSinceEpoch >= 0) {
+ // and we have a POSIX rule, then use it:
+ if (!m_posixRule.isEmpty()
+ && (m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < afterMSecsSinceEpoch)) {
QVector<QTimeZonePrivate::Data> posixTrans = getPosixTransitions(afterMSecsSinceEpoch);
auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(),
[afterMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) {
@@ -1012,9 +1023,9 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSince
QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const
{
// If the required time is after the last transition (or there were none)
- // and we have a POSIX rule then use it:
- if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < beforeMSecsSinceEpoch)
- && !m_posixRule.isEmpty() && beforeMSecsSinceEpoch > 0) {
+ // and we have a POSIX rule, then use it:
+ if (!m_posixRule.isEmpty()
+ && (m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < beforeMSecsSinceEpoch)) {
QVector<QTimeZonePrivate::Data> posixTrans = getPosixTransitions(beforeMSecsSinceEpoch);
auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(),
[beforeMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) {