From afd2246de26a81239b1f8d02a825685d9fcab94b Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 11 Mar 2015 08:35:17 +0100 Subject: Windows Embedded: GetTickCount64 won't be available so just remove it Since GetTickCount64 still relies on the usage of kernel32, then it will not find the function anyway as the library does not exist for Windows Embedded. Therefore it is best to remove it altogether to save time trying to locate something we know is not there. Change-Id: Id879382fdd0692fb9443231a405c0e28d9bcc328 Reviewed-by: Thiago Macieira --- src/corelib/tools/qelapsedtimer_win.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp index 55c93d6361..44d8cbc593 100644 --- a/src/corelib/tools/qelapsedtimer_win.cpp +++ b/src/corelib/tools/qelapsedtimer_win.cpp @@ -52,19 +52,13 @@ static void resolveLibs() if (done) return; -#ifndef Q_OS_WINRT +#if !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE) // try to get GetTickCount64 from the system HMODULE kernel32 = GetModuleHandleW(L"kernel32"); if (!kernel32) return; - -#if defined(Q_OS_WINCE) - // does this function exist on WinCE, or will ever exist? - ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, L"GetTickCount64"); -#else ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, "GetTickCount64"); -#endif -#endif // !Q_OS_WINRT +#endif // !Q_OS_WINRT && !Q_OS_WINCE // Retrieve the number of high-resolution performance counter ticks per second LARGE_INTEGER frequency; -- cgit v1.2.3 From 8f061836993059996d79d7fbed2bb68b16028ad7 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 9 Mar 2015 10:29:55 +0100 Subject: Core: fix crash in QCollator if ucol_open() failed If ucol_open() failed, call back to QString::compare() implementation. Task-number: QTBUG-44796 Change-Id: I03446e5227e1dedac6c5f824ac6d74a494fc0ace Reviewed-by: Gergely Nagy Reviewed-by: Lars Knoll --- src/corelib/tools/qcollator_icu.cpp | 43 ++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp index 4442442a65..4c13335521 100644 --- a/src/corelib/tools/qcollator_icu.cpp +++ b/src/corelib/tools/qcollator_icu.cpp @@ -52,8 +52,12 @@ void QCollatorPrivate::init() UErrorCode status = U_ZERO_ERROR; QByteArray name = locale.bcp47Name().replace(QLatin1Char('-'), QLatin1Char('_')).toLatin1(); collator = ucol_open(name.constData(), &status); - if (U_FAILURE(status)) + if (U_FAILURE(status)) { qWarning("Could not create collator: %d", status); + collator = 0; + dirty = false; + return; + } // enable normalization by default ucol_setAttribute(collator, UCOL_NORMALIZATION_MODE, UCOL_ON, &status); @@ -97,17 +101,26 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con if (d->dirty) d->init(); - return ucol_strcoll(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2); + if (d->collator) + return ucol_strcoll(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2); + + return QString::compare(QString(s1, len1), QString(s2, len2), d->caseSensitivity); } int QCollator::compare(const QString &s1, const QString &s2) const { - return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); + if (d->collator) + return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); + + return QString::compare(s1, s2, d->caseSensitivity); } int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const { - return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); + if (d->collator) + return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); + + return QStringRef::compare(s1, s2, d->caseSensitivity); } QCollatorSortKey QCollator::sortKey(const QString &string) const @@ -115,16 +128,20 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const if (d->dirty) d->init(); - QByteArray result(16 + string.size() + (string.size() >> 2), Qt::Uninitialized); - int size = ucol_getSortKey(d->collator, (const UChar *)string.constData(), - string.size(), (uint8_t *)result.data(), result.size()); - if (size > result.size()) { - result.resize(size); - size = ucol_getSortKey(d->collator, (const UChar *)string.constData(), - string.size(), (uint8_t *)result.data(), result.size()); + if (d->collator) { + QByteArray result(16 + string.size() + (string.size() >> 2), Qt::Uninitialized); + int size = ucol_getSortKey(d->collator, (const UChar *)string.constData(), + string.size(), (uint8_t *)result.data(), result.size()); + if (size > result.size()) { + result.resize(size); + size = ucol_getSortKey(d->collator, (const UChar *)string.constData(), + string.size(), (uint8_t *)result.data(), result.size()); + } + result.truncate(size); + return QCollatorSortKey(new QCollatorSortKeyPrivate(result)); } - result.truncate(size); - return QCollatorSortKey(new QCollatorSortKeyPrivate(result)); + + return QCollatorSortKey(new QCollatorSortKeyPrivate(QByteArray())); } int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const -- cgit v1.2.3 From 7c2360b762817743484ddc5bc9ba3f48a7b68d84 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 30 Mar 2015 11:10:27 +0200 Subject: Split out some inline qdebug formatting helpers to qdebug_p.h. Extract helpers to be able to format classes without type names and use those for formatting QEvents to reduce clutter. For example: QWidgetWindow/"MainWindowClassWindow" QMouseEvent(QEvent::Type(MouseMove), buttons=QFlags(LeftButton), localPos=QPointF(50,116), screenPos=QPointF(948,652)) QWidget/"qt_scrollarea_viewport" QMouseEvent(QEvent::Type(MouseMove), buttons=QFlags(LeftButton), localPos=QPointF(45,32), screenPos=QPointF(948,652)) becomes QWidgetWindow/"MainWindowClassWindow" QMouseEvent(MouseMove, LeftButton, localPos=50,116, screenPos=948,652) QWidget/"qt_scrollarea_viewport" QMouseEvent(MouseMove, LeftButton, localPos=45,32, screenPos=948,652) Change-Id: Ie5441d922962a05caed6b7079a74ea8a2b8a64fb Reviewed-by: Kai Koehne --- src/corelib/tools/qmargins.cpp | 21 ++++++++++++++------- src/corelib/tools/qpoint.cpp | 13 ++++++++++--- src/corelib/tools/qrect.cpp | 15 ++++++++++----- src/corelib/tools/qsize.cpp | 13 ++++++++++--- 4 files changed, 44 insertions(+), 18 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index a9413d6b5c..92c977a73b 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -33,7 +33,8 @@ #include "qmargins.h" #include "qdatastream.h" -#include "qdebug.h" + +#include QT_BEGIN_NAMESPACE @@ -431,10 +432,13 @@ QDataStream &operator>>(QDataStream &s, QMargins &m) #endif // QT_NO_DATASTREAM #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QMargins &m) { +QDebug operator<<(QDebug dbg, const QMargins &m) +{ QDebugStateSaver saver(dbg); - dbg.nospace() << "QMargins(" << m.left() << ", " - << m.top() << ", " << m.right() << ", " << m.bottom() << ')'; + dbg.nospace(); + dbg << "QMargins" << '('; + QtDebugUtils::formatQMargins(dbg, m); + dbg << ')'; return dbg; } #endif @@ -764,10 +768,13 @@ QDataStream &operator>>(QDataStream &s, QMarginsF &m) #endif // QT_NO_DATASTREAM #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QMarginsF &m) { +QDebug operator<<(QDebug dbg, const QMarginsF &m) +{ QDebugStateSaver saver(dbg); - dbg.nospace() << "QMarginsF(" << m.left() << ", " - << m.top() << ", " << m.right() << ", " << m.bottom() << ')'; + dbg.nospace(); + dbg << "QMarginsF" << '('; + QtDebugUtils::formatQMargins(dbg, m); + dbg << ')'; return dbg; } #endif diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp index ebce6c9422..dc2a2d9739 100644 --- a/src/corelib/tools/qpoint.cpp +++ b/src/corelib/tools/qpoint.cpp @@ -33,7 +33,8 @@ #include "qpoint.h" #include "qdatastream.h" -#include "qdebug.h" + +#include QT_BEGIN_NAMESPACE @@ -447,14 +448,20 @@ QDataStream &operator>>(QDataStream &s, QPoint &p) QDebug operator<<(QDebug dbg, const QPoint &p) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QPoint(" << p.x() << ',' << p.y() << ')'; + dbg.nospace(); + dbg << "QPoint" << '('; + QtDebugUtils::formatQPoint(dbg, p); + dbg << ')'; return dbg; } QDebug operator<<(QDebug dbg, const QPointF &p) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QPointF(" << p.x() << ',' << p.y() << ')'; + dbg.nospace(); + dbg << "QPointF" << '('; + QtDebugUtils::formatQPoint(dbg, p); + dbg << ')'; return dbg; } #endif diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 35cf2d5e5b..b2174745e4 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -33,9 +33,10 @@ #include "qrect.h" #include "qdatastream.h" -#include "qdebug.h" #include "qmath.h" +#include + QT_BEGIN_NAMESPACE /*! @@ -1279,8 +1280,10 @@ QDataStream &operator>>(QDataStream &s, QRect &r) QDebug operator<<(QDebug dbg, const QRect &r) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QRect(" << r.x() << ',' << r.y() << ' ' - << r.width() << 'x' << r.height() << ')'; + dbg.nospace(); + dbg << "QRect" << '('; + QtDebugUtils::formatQRect(dbg, r); + dbg << ')'; return dbg; } #endif @@ -2488,8 +2491,10 @@ QDataStream &operator>>(QDataStream &s, QRectF &r) QDebug operator<<(QDebug dbg, const QRectF &r) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QRectF(" << r.x() << ',' << r.y() << ' ' - << r.width() << 'x' << r.height() << ')'; + dbg.nospace(); + dbg << "QRectF" << '('; + QtDebugUtils::formatQRect(dbg, r); + dbg << ')'; return dbg; } #endif diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp index d91dd0d130..19227432f2 100644 --- a/src/corelib/tools/qsize.cpp +++ b/src/corelib/tools/qsize.cpp @@ -33,7 +33,8 @@ #include "qsize.h" #include "qdatastream.h" -#include "qdebug.h" + +#include QT_BEGIN_NAMESPACE @@ -440,7 +441,10 @@ QDataStream &operator>>(QDataStream &s, QSize &sz) QDebug operator<<(QDebug dbg, const QSize &s) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QSize(" << s.width() << ", " << s.height() << ')'; + dbg.nospace(); + dbg << "QSize("; + QtDebugUtils::formatQSize(dbg, s); + dbg << ')'; return dbg; } #endif @@ -867,7 +871,10 @@ QDataStream &operator>>(QDataStream &s, QSizeF &sz) QDebug operator<<(QDebug dbg, const QSizeF &s) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QSizeF(" << s.width() << ", " << s.height() << ')'; + dbg.nospace(); + dbg << "QSizeF("; + QtDebugUtils::formatQSize(dbg, s); + dbg << ')'; return dbg; } #endif -- cgit v1.2.3 From 1db3de6a1e09216aaf92b60fc167a7326c6a62d8 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 19 Mar 2015 17:13:22 +0100 Subject: QVLA: Add operator= for initializer lists Add a dedicated operator=(std::initializer_list) that first resizes the QCLA, and then replaces the elements one by one. This should be usually faster than creating a temporary QCLA and then copying it, except for the case where the new array does not fit into the allocated stack - but this is IMO nothing to optimize for. Task-number: QTBUG-45041 Change-Id: I147d6d01186b1ca3c635b2c8365d8f6e638ce6fe GPush-Base: 08de3113051e1289f0de0651ec5647c9ee6feb27 Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/tools/qvarlengtharray.h | 9 +++++++++ src/corelib/tools/qvarlengtharray.qdoc | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 95cd0447d8..90b54b7297 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -91,6 +91,15 @@ public: return *this; } +#ifdef Q_COMPILER_INITIALIZER_LISTS + QVarLengthArray &operator=(std::initializer_list list) + { + resize(list.size()); + std::copy(list.begin(), list.end(), this->begin()); + return *this; + } +#endif + inline void removeLast() { Q_ASSERT(s > 0); realloc(s - 1, a); diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index d1b87f381e..a2d4c55f7a 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -362,6 +362,15 @@ Assigns \a other to this array and returns a reference to this array. */ +/*! \fn QVarLengthArray &QVarLengthArray::operator=(std::initializer_list list) + \since 5.5 + + Assigns the values of \a list to this array, and returns a reference to this array. + + This constructor is only enabled if the compiler supports C++11 initializer + lists. +*/ + /*! \fn QVarLengthArray::QVarLengthArray(const QVarLengthArray &other) Constructs a copy of \a other. */ -- cgit v1.2.3 From 9eb0b09abce28b11e4915fc9c3b3e996eb19cef2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 5 Apr 2015 12:39:14 -0700 Subject: Removed unused code on QT_STRING_UCS4 macro This isn't defined or used anywhere else. Change-Id: I9a75ad8521ae4e5cbbe5ffff13d2356883b82dbc Reviewed-by: Konstantin Ritt --- src/corelib/tools/qstring.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index e74a8eebee..a0067178ac 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -8379,12 +8379,6 @@ QDataStream &operator<<(QDataStream &out, const QString &str) QDataStream &operator>>(QDataStream &in, QString &str) { -#ifdef QT_QSTRING_UCS_4 -#if defined(Q_CC_GNU) -#warning "operator>> not working properly" -#endif -#endif - if (in.version() == 1) { QByteArray l; in >> l; -- cgit v1.2.3