summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.h6
-rw-r--r--src/corelib/io/qurl.cpp15
-rw-r--r--src/corelib/io/qurl.h20
-rw-r--r--src/corelib/thread/qthreadpool.cpp28
-rw-r--r--src/corelib/tools/qdatetime.cpp15
-rw-r--r--src/corelib/tools/qhash.h9
6 files changed, 52 insertions, 41 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index f9629ff430..41f21bb0dd 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -681,11 +681,13 @@ typedef void (*QFunctionPointer)();
# define Q_UNIMPLEMENTED() qWarning("%s:%d: %s: Unimplemented code.", __FILE__, __LINE__, Q_FUNC_INFO)
#endif
+Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2)
{
return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2)));
}
+Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2)
{
return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2)));
@@ -694,6 +696,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2)
/*!
\internal
*/
+Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d)
{
return qAbs(d) <= 0.000000000001;
@@ -702,6 +705,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d)
/*!
\internal
*/
+Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f)
{
return qAbs(f) <= 0.00001f;
@@ -712,6 +716,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f)
check whether the actual value is 0 or close to 0, but whether
it is binary 0, disregarding sign.
*/
+static inline bool qIsNull(double d) Q_REQUIRED_RESULT;
static inline bool qIsNull(double d)
{
union U {
@@ -728,6 +733,7 @@ static inline bool qIsNull(double d)
check whether the actual value is 0 or close to 0, but whether
it is binary 0, disregarding sign.
*/
+static inline bool qIsNull(float f) Q_REQUIRED_RESULT;
static inline bool qIsNull(float f)
{
union U {
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 9607f14853..9f9653ea94 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -1089,8 +1089,11 @@ inline void QUrlPrivate::setQuery(const QString &value, int from, int iend)
inline void QUrlPrivate::appendHost(QString &appendTo, QUrl::FormattingOptions options) const
{
- // this is the only flag that matters
- options &= QUrl::EncodeUnicode;
+ // EncodeUnicode is the only flag that matters
+ if ((options & QUrl::FullyDecoded) == QUrl::FullyDecoded)
+ options = 0;
+ else
+ options &= QUrl::EncodeUnicode;
if (host.isEmpty())
return;
if (host.at(0).unicode() == '[') {
@@ -3249,8 +3252,8 @@ QUrl QUrl::adjusted(QUrl::FormattingOptions options) const
that.setPath(QString());
} else if (options & (StripTrailingSlash | RemoveFilename | NormalizePathSegments)) {
QString path;
- d->appendPath(path, options, QUrlPrivate::Path);
- that.setPath(path);
+ d->appendPath(path, options | FullyEncoded, QUrlPrivate::Path);
+ that.setPath(path, TolerantMode);
}
return that;
}
@@ -3964,9 +3967,9 @@ uint qHash(const QUrl &url, uint seed) Q_DECL_NOTHROW
static QUrl adjustFtpPath(QUrl url)
{
if (url.scheme() == ftpScheme()) {
- QString path = url.path();
+ QString path = url.path(QUrl::PrettyDecoded);
if (path.startsWith(QLatin1String("//")))
- url.setPath(QLatin1String("/%2F") + path.midRef(2));
+ url.setPath(QLatin1String("/%2F") + path.midRef(2), QUrl::TolerantMode);
}
return url;
}
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 457440bb89..abb7df0056 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -209,22 +209,22 @@ public:
void setUserInfo(const QString &userInfo, ParsingMode mode = TolerantMode);
QString userInfo(ComponentFormattingOptions options = PrettyDecoded) const;
- void setUserName(const QString &userName, ParsingMode mode = TolerantMode);
- QString userName(ComponentFormattingOptions options = PrettyDecoded) const;
+ void setUserName(const QString &userName, ParsingMode mode = DecodedMode);
+ QString userName(ComponentFormattingOptions options = FullyDecoded) const;
- void setPassword(const QString &password, ParsingMode mode = TolerantMode);
- QString password(ComponentFormattingOptions = PrettyDecoded) const;
+ void setPassword(const QString &password, ParsingMode mode = DecodedMode);
+ QString password(ComponentFormattingOptions = FullyDecoded) const;
- void setHost(const QString &host, ParsingMode mode = TolerantMode);
- QString host(ComponentFormattingOptions = PrettyDecoded) const;
- QString topLevelDomain(ComponentFormattingOptions options = PrettyDecoded) const;
+ void setHost(const QString &host, ParsingMode mode = DecodedMode);
+ QString host(ComponentFormattingOptions = FullyDecoded) const;
+ QString topLevelDomain(ComponentFormattingOptions options = FullyDecoded) const;
void setPort(int port);
int port(int defaultPort = -1) const;
- void setPath(const QString &path, ParsingMode mode = TolerantMode);
- QString path(ComponentFormattingOptions options = PrettyDecoded) const;
- QString fileName(ComponentFormattingOptions options = PrettyDecoded) const;
+ void setPath(const QString &path, ParsingMode mode = DecodedMode);
+ QString path(ComponentFormattingOptions options = FullyDecoded) const;
+ QString fileName(ComponentFormattingOptions options = FullyDecoded) const;
bool hasQuery() const;
void setQuery(const QString &query, ParsingMode mode = TolerantMode);
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index bee6790705..31c3f5a256 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -52,14 +52,14 @@ QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QThreadPool, theInstance)
/*
- QThread wrapper, provides synchronizitaion against a ThreadPool
+ QThread wrapper, provides synchronization against a ThreadPool
*/
class QThreadPoolThread : public QThread
{
public:
QThreadPoolThread(QThreadPoolPrivate *manager);
void run();
- void registerTheadInactive();
+ void registerThreadInactive();
QThreadPoolPrivate *manager;
QRunnable *runnable;
@@ -103,7 +103,7 @@ void QThreadPoolThread::run()
qWarning("Qt Concurrent has caught an exception thrown from a worker thread.\n"
"This is not supported, exceptions thrown in worker threads must be\n"
"caught before control returns to Qt Concurrent.");
- registerTheadInactive();
+ registerThreadInactive();
throw;
}
#endif
@@ -121,7 +121,7 @@ void QThreadPoolThread::run()
} while (r != 0);
if (manager->isExiting) {
- registerTheadInactive();
+ registerThreadInactive();
break;
}
@@ -129,7 +129,7 @@ void QThreadPoolThread::run()
bool expired = manager->tooManyThreadsActive();
if (!expired) {
++manager->waitingThreads;
- registerTheadInactive();
+ registerThreadInactive();
// wait for work, exiting after the expiry timeout is reached
expired = !manager->runnableReady.wait(locker.mutex(), manager->expiryTimeout);
++manager->activeThreads;
@@ -139,13 +139,13 @@ void QThreadPoolThread::run()
}
if (expired) {
manager->expiredThreads.enqueue(this);
- registerTheadInactive();
+ registerThreadInactive();
break;
}
}
}
-void QThreadPoolThread::registerTheadInactive()
+void QThreadPoolThread::registerThreadInactive()
{
if (--manager->activeThreads == 0)
manager->noActiveThreads.wakeAll();
@@ -223,8 +223,6 @@ void QThreadPoolPrivate::enqueueTask(QRunnable *runnable, int priority)
int QThreadPoolPrivate::activeThreadCount() const
{
- // To improve scalability this function is called without holding
- // the mutex lock -- keep it thread-safe.
return (allThreads.count()
- expiredThreads.count()
- waitingThreads
@@ -262,7 +260,7 @@ void QThreadPoolPrivate::startThread(QRunnable *runnable)
/*!
\internal
- Makes all threads exit, waits for each tread to exit and deletes it.
+ Makes all threads exit, waits for each thread to exit and deletes it.
*/
void QThreadPoolPrivate::reset()
{
@@ -322,8 +320,8 @@ void QThreadPoolPrivate::clear()
/*!
\internal
- Seaches for \a runnable in the queue, removes it from the queue and
- runs it if found. This functon does not return until the runnable
+ Searches for \a runnable in the queue, removes it from the queue and
+ runs it if found. This function does not return until the runnable
has completed.
*/
void QThreadPoolPrivate::stealRunnable(QRunnable *runnable)
@@ -485,12 +483,11 @@ bool QThreadPool::tryStart(QRunnable *runnable)
Q_D(QThreadPool);
- // To improve scalability perform a check on the thread count
- // before locking the mutex.
+ QMutexLocker locker(&d->mutex);
+
if (d->allThreads.isEmpty() == false && d->activeThreadCount() >= d->maxThreadCount)
return false;
- QMutexLocker locker(&d->mutex);
return d->tryStart(runnable);
}
@@ -564,6 +561,7 @@ void QThreadPool::setMaxThreadCount(int maxThreadCount)
int QThreadPool::activeThreadCount() const
{
Q_D(const QThreadPool);
+ QMutexLocker locker(&d->mutex);
return d->activeThreadCount();
}
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 7b99aa1e06..b47511c39c 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -2716,7 +2716,10 @@ QString QDateTime::toString(const QString& format) const
QDateTime QDateTime::addDays(qint64 ndays) const
{
- return QDateTime(d->date.addDays(ndays), d->time, timeSpec());
+ QDateTime dt(*this);
+ dt.detach();
+ dt.d->date = d->date.addDays(ndays);
+ return dt;
}
/*!
@@ -2729,7 +2732,10 @@ QDateTime QDateTime::addDays(qint64 ndays) const
QDateTime QDateTime::addMonths(int nmonths) const
{
- return QDateTime(d->date.addMonths(nmonths), d->time, timeSpec());
+ QDateTime dt(*this);
+ dt.detach();
+ dt.d->date = d->date.addMonths(nmonths);
+ return dt;
}
/*!
@@ -2742,7 +2748,10 @@ QDateTime QDateTime::addMonths(int nmonths) const
QDateTime QDateTime::addYears(int nyears) const
{
- return QDateTime(d->date.addYears(nyears), d->time, timeSpec());
+ QDateTime dt(*this);
+ dt.detach();
+ dt.d->date = d->date.addYears(nyears);
+ return dt;
}
QDateTime QDateTimePrivate::addMSecs(const QDateTime &dt, qint64 msecs)
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 25029afe1f..ce9ab33903 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -513,15 +513,10 @@ private:
bool isValidIterator(const iterator &it) const
{
#if defined(QT_DEBUG) && !defined(Q_HASH_NO_ITERATOR_DEBUG)
- union {
- QHashData *iteratorHashData;
- QHashData::Node *node;
- };
- node = it.i;
+ QHashData::Node *node = it.i;
while (node->next)
node = node->next;
-
- return (iteratorHashData == d);
+ return (static_cast<void *>(node) == d);
#else
Q_UNUSED(it);
return true;