diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qresource.cpp | 27 | ||||
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qdatetimeparser.cpp | 5 | ||||
-rw-r--r-- | src/corelib/tools/qelapsedtimer_unix.cpp | 6 |
4 files changed, 25 insertions, 15 deletions
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 1ead114235..96957ac11d 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -1194,9 +1194,10 @@ protected: private: uchar *map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags); bool unmap(uchar *ptr); + void uncompress() const; qint64 offset; QResource resource; - QByteArray uncompressed; + mutable QByteArray uncompressed; protected: QResourceFileEnginePrivate() : offset(0) { } }; @@ -1231,13 +1232,6 @@ QResourceFileEngine::QResourceFileEngine(const QString &file) : { Q_D(QResourceFileEngine); d->resource.setFileName(file); - if(d->resource.isCompressed() && d->resource.size()) { -#ifndef QT_NO_COMPRESS - d->uncompressed = qUncompress(d->resource.data(), d->resource.size()); -#else - Q_ASSERT(!"QResourceFileEngine::open: Qt built without support for compression"); -#endif - } } QResourceFileEngine::~QResourceFileEngine() @@ -1259,6 +1253,7 @@ bool QResourceFileEngine::open(QIODevice::OpenMode flags) } if(flags & QIODevice::WriteOnly) return false; + d->uncompress(); if (!d->resource.isValid()) { d->errorString = qt_error_string(ENOENT); return false; @@ -1324,8 +1319,10 @@ qint64 QResourceFileEngine::size() const Q_D(const QResourceFileEngine); if(!d->resource.isValid()) return 0; - if(d->resource.isCompressed()) + if (d->resource.isCompressed()) { + d->uncompress(); return d->uncompressed.size(); + } return d->resource.size(); } @@ -1493,6 +1490,18 @@ bool QResourceFileEnginePrivate::unmap(uchar *ptr) Q_UNUSED(ptr); return true; } + +void QResourceFileEnginePrivate::uncompress() const +{ + if (resource.isCompressed() && uncompressed.isEmpty() && resource.size()) { +#ifndef QT_NO_COMPRESS + uncompressed = qUncompress(resource.data(), resource.size()); +#else + Q_ASSERT(!"QResourceFileEngine::open: Qt built without support for compression"); +#endif + } +} + #endif // !defined(QT_BOOTSTRAPPED) QT_END_NAMESPACE diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 7cc86eb3f1..e18c220884 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -4699,7 +4699,7 @@ QDateTime QDateTime::fromString(const QString &string, const QString &format) Q_UNUSED(string); Q_UNUSED(format); #endif - return QDateTime(QDate(), QTime(-1, -1, -1)); + return QDateTime(); } #endif // QT_NO_DATESTRING diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index c1abdf11a7..fbf91fe8a4 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -1555,10 +1555,7 @@ QString QDateTimeParser::SectionNode::format() const qWarning("QDateTimeParser::sectionFormat Internal error 2"); return QString(); } - - QString str; - str.fill(fillChar, count); - return str; + return QString(count, fillChar); } diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp index 1e672531c8..e1fc77fb4c 100644 --- a/src/corelib/tools/qelapsedtimer_unix.cpp +++ b/src/corelib/tools/qelapsedtimer_unix.cpp @@ -115,7 +115,11 @@ static inline void qt_clock_gettime(clockid_t clock, struct timespec *ts) static int unixCheckClockType() { -#if (_POSIX_MONOTONIC_CLOCK-0 == 0) && defined(_SC_MONOTONIC_CLOCK) +#ifdef Q_OS_LINUX + // Despite glibc claiming that we should check at runtime, the Linux kernel + // always supports the monotonic clock + return CLOCK_MONOTONIC; +#elif (_POSIX_MONOTONIC_CLOCK-0 == 0) && defined(_SC_MONOTONIC_CLOCK) // we need a value we can store in a clockid_t that isn't a valid clock // check if the valid ones are both non-negative or both non-positive # if CLOCK_MONOTONIC >= 0 && CLOCK_REALTIME >= 0 |