Merge dev into 5.12

Change-Id: I63f632b595f66d2fc93e9aa713500e3799e3df2a
bb10
Oswald Buddenhagen 2018-08-21 02:32:49 +02:00
commit 5a03b75c50
248 changed files with 4977 additions and 3724 deletions

View File

@ -1106,10 +1106,17 @@
"condition": "libs.zlib",
"output": [ "privateFeature" ]
},
"thread": {
"label": "Thread support",
"purpose": "Provides QThread and related classes.",
"section": "Kernel",
"output": [ "publicFeature" ]
},
"future": {
"label": "QFuture",
"purpose": "Provides QFuture and related classes.",
"section": "Kernel",
"condition": "features.thread",
"output": [ "publicFeature" ]
},
"concurrent": {
@ -1122,6 +1129,7 @@
"dbus": {
"label": "Qt D-Bus",
"autoDetect": "!config.uikit && !config.android && !config.winrt",
"condition": "features.thread",
"output": [ "privateFeature", "feature" ]
},
"dbus-linked": {
@ -1153,10 +1161,12 @@
},
"network": {
"label": "Qt Network",
"condition": "features.thread",
"output": [ "privateFeature" ]
},
"sql": {
"label": "Qt Sql",
"condition": "features.thread",
"output": [ "privateFeature" ]
},
"testlib": {

View File

@ -1144,6 +1144,12 @@ defineReplace(qtConfOutputPostProcess_publicPro) {
"QT_ICC_MINOR_VERSION = $$format_number($$replace(QMAKE_ICC_VER, "(..)(..)", "\\2"))" \
"QT_ICC_PATCH_VERSION = $$QMAKE_ICC_UPDATE_VER"
}
!isEmpty(QMAKE_GHS_VERSION) {
output += \
"QT_GHS_MAJOR_VERSION = $$replace(QMAKE_GHS_VERSION, "(.*)(.)(.)", "\\1")" \
"QT_GHS_MINOR_VERSION = $$replace(QMAKE_GHS_VERSION, "(.*)(.)(.)", "\\2")" \
"QT_GHS_PATCH_VERSION = $$replace(QMAKE_GHS_VERSION, "(.*)(.)(.)", "\\3")"
}
output += "QT_EDITION = $$config.input.qt_edition"
!contains(config.input.qt_edition, "(OpenSource|Preview)") {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -27,3 +27,6 @@ QMAKE_GCC_MAJOR_VERSION = __GNUC__
QMAKE_GCC_MINOR_VERSION = __GNUC_MINOR__
QMAKE_GCC_PATCH_VERSION = __GNUC_PATCHLEVEL__
#endif
#ifdef __ghs__
QMAKE_GHS_VERSION = __GHS_VERSION_NUMBER
#endif

View File

@ -996,9 +996,9 @@ defineTest(qtConfTest_compile) {
# add compiler flags, these are set for the target and should not be applied to host tests
!isEmpty(EXTRA_DEFINES): \
qmake_args += $$system_quote(DEFINES += $$val_escape(EXTRA_DEFINES))
!isEmpty(EXTRA_LIBDIR) \
!isEmpty(EXTRA_LIBDIR): \
qmake_args += $$system_quote(QMAKE_LIBDIR += $$val_escape(EXTRA_LIBDIR))
!isEmpty(EXTRA_FRAMEWORKPATH) \
!isEmpty(EXTRA_FRAMEWORKPATH): \
qmake_args += $$system_quote(QMAKE_FRAMEWORKPATH += $$val_escape(EXTRA_FRAMEWORKPATH))
!isEmpty(EXTRA_INCLUDEPATH): \
qmake_args += $$system_quote(INCLUDEPATH += $$val_escape(EXTRA_INCLUDEPATH))

View File

@ -142,6 +142,29 @@ isEmpty($${target_prefix}.INCDIRS) {
!integrity: \
error("failed to parse default search paths from compiler output")
QMAKE_DEFAULT_LIBDIRS = $$unique(QMAKE_DEFAULT_LIBDIRS)
} else: ghs {
cmd = $$QMAKE_CXX $$QMAKE_CXXFLAGS -$${LITERAL_HASH} -o /tmp/fake_output /tmp/fake_input.cpp
output = $$system("$$cmd", blob, ec)
!equals(ec, 0): qtCompilerErrror($$QMAKE_CXX, $$output)
output ~= s/\\\\\\n {8}//g
output = $$split(output, $$escape_expand(\\n))
for (line, output) {
contains(line, "^[^ ]+/ecom[^ ]+ .* /tmp/fake_input\\.cpp") {
for (parameter, $$list($$line)) {
contains(parameter, "^(-I|--include_no_mmd=|--sys_include=).*") {
parameter ~= s/^(-I|--include_no_mmd=|--sys_include=)//
QMAKE_DEFAULT_INCDIRS += $$clean_path($$parameter)
}
}
} else: contains(line, "^[^ ]+/elxr .*") {
for (parameter, $$list($$line)) {
contains(parameter, "^-L.*") {
parameter ~= s/^-L//
QMAKE_DEFAULT_LIBDIRS += $$clean_path($$parameter)
}
}
}
}
} else: msvc {
# This doesn't differentiate between host and target,
# but neither do the compilers.
@ -168,14 +191,14 @@ isEmpty($${target_prefix}.INCDIRS) {
#
defineReplace(qtVariablesFromMSVC) {
ret = $$system("$$1 -nologo -E $$2 $$system_quote($$PWD/data/macros.cpp) <NUL 2>NUL", lines, ec)
ret = $$system("$$1 -nologo -E $$2 $$system_quote($$PWD/data/macros.cpp) 2>NUL", lines, ec)
!equals(ec, 0): qtCompilerErrror($$1, $$ret)
return($$ret)
}
defineReplace(qtVariablesFromGCC) {
ret = $$system("$$1 -E $$system_quote($$PWD/data/macros.cpp) \
<$$QMAKE_SYSTEM_NULL_DEVICE 2>$$QMAKE_SYSTEM_NULL_DEVICE", lines, ec)
2>$$QMAKE_SYSTEM_NULL_DEVICE", lines, ec)
!equals(ec, 0): qtCompilerErrror($$1, $$ret)
return($$ret)
}
@ -199,11 +222,11 @@ isEmpty($${target_prefix}.COMPILER_MACROS) {
} else {
vars = $$qtVariablesFromMSVC($$QMAKE_CXX)
}
} else: gcc {
} else: gcc|ghs {
vars = $$qtVariablesFromGCC($$QMAKE_CXX)
}
for (v, vars) {
contains(v, $${LITERAL_HASH}.*)|contains(v, " *"): next()
!contains(v, "[A-Z_]+ = .*"): next()
# Set both <varname> for the outer scope ...
eval($$v)
v ~= s/ .*//
@ -245,6 +268,8 @@ QMAKE_COMPILER_DEFINES += __cplusplus=$$QT_COMPILER_STDCXX
__GNUC__=$$QMAKE_GCC_MAJOR_VERSION \
__GNUC_MINOR__=$$QMAKE_GCC_MINOR_VERSION \
__GNUC_PATCHLEVEL__=$$QMAKE_GCC_PATCH_VERSION
!isEmpty(QMAKE_GHS_VERSION): \
QMAKE_COMPILER_DEFINES += __ghs__ __GHS_VERSION_NUMBER=$$QMAKE_GHS_VERSION
QMAKE_CFLAGS += $$QMAKE_CFLAGS_MSVC_COMPAT
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_MSVC_COMPAT

View File

@ -557,6 +557,12 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool)
addFilters(tempProj, xmlFilter, "Deployment Files");
addFilters(tempProj, xmlFilter, "Distribution Files");
tempProj.ExtraCompilers.reserve(tool.ExtraCompilersFiles.size());
std::transform(tool.ExtraCompilersFiles.cbegin(), tool.ExtraCompilersFiles.cend(),
std::back_inserter(tempProj.ExtraCompilers),
[] (const VCFilter &filter) { return filter.Name; });
tempProj.ExtraCompilers.removeDuplicates();
for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x)
addFilters(tempProj, xmlFilter, tempProj.ExtraCompilers.at(x));
@ -1977,6 +1983,15 @@ bool VCXProjectWriter::outputFileConfig(OutputFilterData *d, XmlOutput &xml, Xml
return fileAdded;
}
static bool isFileClCompatible(const QString &filePath)
{
auto filePathEndsWith = [&filePath] (const QString &ext) {
return filePath.endsWith(ext, Qt::CaseInsensitive);
};
return std::any_of(Option::cpp_ext.cbegin(), Option::cpp_ext.cend(), filePathEndsWith)
|| std::any_of(Option::c_ext.cbegin(), Option::c_ext.cend(), filePathEndsWith);
}
void VCXProjectWriter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter,
const QString &filePath, const QString &filterName)
{
@ -2000,7 +2015,7 @@ void VCXProjectWriter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter,
<< attrTagS("Filter", filterName);
xml << tag("ClInclude")
<< attrTag("Include", nativeFilePath);
} else if (filePath.endsWith(".cpp")) {
} else if (isFileClCompatible(filePath)) {
xmlFilter << tag("ClCompile")
<< attrTag("Include", nativeFilePath)
<< attrTagS("Filter", filterName);

View File

@ -6,6 +6,7 @@
"Description": "xkbcommon is a keymap compiler and support library which processes a reduced subset of keymaps as defined by the XKB specification.",
"Homepage": "http://xkbcommon.org/",
"Version": "0.4.1",
"License": "MIT Licenses (with no-advertisement clause)",
"LicenseId": "MIT",
"LicenseFile": "COPYING",

View File

@ -215,9 +215,7 @@ typedef QList<QAbstractAnimation*>::ConstIterator AnimationListConstIt;
QUnifiedTimer drives animations indirectly, via QAbstractAnimationTimer.
*/
#ifndef QT_NO_THREAD
Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
#endif
QUnifiedTimer::QUnifiedTimer() :
QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
@ -234,18 +232,12 @@ QUnifiedTimer::QUnifiedTimer() :
QUnifiedTimer *QUnifiedTimer::instance(bool create)
{
QUnifiedTimer *inst;
#ifndef QT_NO_THREAD
if (create && !unifiedTimer()->hasLocalData()) {
inst = new QUnifiedTimer;
unifiedTimer()->setLocalData(inst);
} else {
inst = unifiedTimer() ? unifiedTimer()->localData() : 0;
}
#else
Q_UNUSED(create);
static QUnifiedTimer unifiedTimer;
inst = &unifiedTimer;
#endif
return inst;
}
@ -554,7 +546,7 @@ bool QUnifiedTimer::canUninstallAnimationDriver(QAnimationDriver *d)
return d == driver && driver != &defaultDriver;
}
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
Q_GLOBAL_STATIC(QThreadStorage<QAnimationTimer *>, animationTimer)
#endif
@ -569,7 +561,7 @@ QAnimationTimer::QAnimationTimer() :
QAnimationTimer *QAnimationTimer::instance(bool create)
{
QAnimationTimer *inst;
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
if (create && !animationTimer()->hasLocalData()) {
inst = new QAnimationTimer;
animationTimer()->setLocalData(inst);

View File

@ -51,7 +51,7 @@
//! [0]
class HelloWorldTask : public QRunnable
{
void run()
void run() override
{
qDebug() << "Hello world from thread" << QThread::currentThread();
}

View File

@ -52,7 +52,7 @@
class ZipEngineHandler : public QAbstractFileEngineHandler
{
public:
QAbstractFileEngine *create(const QString &fileName) const;
QAbstractFileEngine *create(const QString &fileName) const override;
};
QAbstractFileEngine *ZipEngineHandler::create(const QString &fileName) const
@ -105,12 +105,12 @@ public:
entries << "entry1" << "entry2" << "entry3";
}
bool hasNext() const
bool hasNext() const override
{
return index < entries.size() - 1;
}
QString next()
QString next() override
{
if (!hasNext())
return QString();
@ -118,7 +118,7 @@ public:
return currentFilePath();
}
QString currentFileName()
QString currentFileName() override
{
return entries.at(index);
}

View File

@ -94,7 +94,7 @@ class SandboxProcess : public QProcess
{
...
protected:
void setupChildProcess();
void setupChildProcess() override;
...
};

View File

@ -120,7 +120,7 @@ public:
...
QVariant data(const QModelIndex &index, int role)
QVariant data(const QModelIndex &index, int role) override
{
if (role != Qt::BackgroundRole)
return QSortFilterProxyModel::data(index, role);

View File

@ -101,7 +101,7 @@ public:
MainWindow();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
bool eventFilter(QObject *obj, QEvent *ev) override;
private:
QTextEdit *textEdit;
@ -147,7 +147,7 @@ public:
MyObject(QObject *parent = 0);
protected:
void timerEvent(QTimerEvent *event);
void timerEvent(QTimerEvent *event) override;
};
MyObject::MyObject(QObject *parent)
@ -215,7 +215,7 @@ class KeyPressEater : public QObject
...
protected:
bool eventFilter(QObject *obj, QEvent *event);
bool eventFilter(QObject *obj, QEvent *event) override;
};
bool KeyPressEater::eventFilter(QObject *obj, QEvent *event)
@ -508,7 +508,7 @@ public:
MyClass(QWidget *parent = 0);
~MyClass();
bool event(QEvent* ev)
bool event(QEvent* ev) override
{
if (ev->type() == QEvent::PolishRequest) {
// overwrite handling of PolishRequest if any

View File

@ -53,8 +53,8 @@
class MyException : public QException
{
public:
void raise() const { throw *this; }
MyException *clone() const { return new MyException(*this); }
void raise() const override { throw *this; }
MyException *clone() const override { return new MyException(*this); }
};
//! [0]

View File

@ -350,4 +350,11 @@ while (i.hasNext()) {
//! [30]
}
{
//! [31]
QString wildcard = QRegularExpression::wildcardToRegularExpression("*.jpeg");
// wilcard == ".*\.jpeg"
//! [31]
}
}

View File

@ -58,7 +58,7 @@ class DateFormatProxyModel : public QIdentityProxyModel
m_formatString = formatString;
}
QVariant data(const QModelIndex &index, int role) const
QVariant data(const QModelIndex &index, int role) const override
{
if (role != Qt::DisplayRole)
return QIdentityProxyModel::data(index, role);

View File

@ -59,7 +59,7 @@ class FilterObject : public QObject
public:
FilterObject(QObject *parent = 0);
bool eventFilter(QObject *object, QEvent *event);
bool eventFilter(QObject *object, QEvent *event) override;
void setFilteredObject(QObject *object);
private:

View File

@ -54,7 +54,7 @@
class MyCheckBox : public QCheckBox
{
public:
void mousePressEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event) override;
};
//! [0]
@ -72,7 +72,7 @@ void MyCheckBox::mousePressEvent(QMouseEvent *event)
class MyWidget : public QWidget
{
public:
bool event(QEvent *event);
bool event(QEvent *event) override;
};
static const int MyCustomEventType = 1099;

View File

@ -143,7 +143,7 @@ public:
void readSettings();
protected:
void closeEvent(QCloseEvent *event);
void closeEvent(QCloseEvent *event) override;
};
//! [16]

View File

@ -58,7 +58,7 @@ public:
protected:
//![0]
bool eventTest(QEvent *event)
bool eventTest(QEvent *event) override
{
if (event->type() == QEvent::Wrapped) {
QEvent *wrappedEvent = static_cast<QStateMachine::WrappedEvent *>(event)->event();
@ -71,7 +71,7 @@ protected:
}
//![0]
void onTransition(QEvent *event)
void onTransition(QEvent *event) override
{
}

View File

@ -72,7 +72,7 @@ public:
: m_value(value) {}
protected:
virtual bool eventTest(QEvent *e)
bool eventTest(QEvent *e) override
{
if (e->type() != QEvent::Type(QEvent::User+1)) // StringEvent
return false;
@ -80,7 +80,7 @@ protected:
return (m_value == se->value);
}
virtual void onTransition(QEvent *) {}
void onTransition(QEvent *) override {}
private:
QString m_value;

View File

@ -321,8 +321,8 @@
callbacks, you'd have to find five different names and keep track
of the types yourself.
\sa QLCDNumber, QObject::connect(), {Digital Clock Example}, and
{Tetrix Example}.
\sa QLCDNumber, QObject::connect(), {Digital Clock Example},
{Tetrix Example}
\section1 Signals And Slots With Default Arguments

View File

@ -98,16 +98,24 @@
#define QT_NO_QOBJECT
#define QT_FEATURE_process -1
#define QT_FEATURE_regularexpression -1
#define QT_FEATURE_renameat2 -1
#ifdef __GLIBC_PREREQ
# define QT_FEATURE_renameat2 (__GLIBC_PREREQ(2, 28) ? 1 : -1)
#else
# define QT_FEATURE_renameat2 -1
#endif
#define QT_FEATURE_settings -1
#define QT_FEATURE_sharedmemory -1
#define QT_FEATURE_slog2 -1
#define QT_FEATURE_statx -1
#ifdef __GLIBC_PREREQ
# define QT_FEATURE_statx (__GLIBC_PREREQ(2, 28) ? 1 : -1)
#else
# define QT_FEATURE_statx -1
#endif
#define QT_FEATURE_syslog -1
#define QT_NO_SYSTEMLOCALE
#define QT_FEATURE_systemsemaphore -1
#define QT_FEATURE_temporaryfile 1
#define QT_NO_THREAD
#define QT_FEATURE_thread -1
#define QT_FEATURE_timezone -1
#define QT_FEATURE_topleveldomain -1
#define QT_NO_TRANSLATION

View File

@ -432,6 +432,46 @@ QT_BEGIN_NAMESPACE
this object.
*/
/*!
\fn template <typename T> QLEInteger &QLEInteger<T>::operator++()
Performs a prefix ++ (increment) on this QLEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QLEInteger QLEInteger<T>::operator++(int)
Performs a postfix ++ (increment) on this QLEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QLEInteger &QLEInteger<T>::operator--()
Performs a prefix -- (decrement) on this QLEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QLEInteger QLEInteger<T>::operator--(int)
Performs a postfix -- (decrement) on this QLEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QLEInteger QLEInteger<T>::max()
Returns the maximum (finite) value representable by the numeric type T.
*/
/*!
\fn template <typename T> QLEInteger QLEInteger<T>::min()
Returns the minimum (finite) value representable by the numeric type T.
*/
/*!
\class QBEInteger
\inmodule QtCore
@ -551,6 +591,46 @@ QT_BEGIN_NAMESPACE
this object.
*/
/*!
\fn template <typename T> QBEInteger &QBEInteger<T>::operator++()
Performs a prefix ++ (increment) on this QBEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QBEInteger QBEInteger<T>::operator++(int)
Performs a postfix ++ (increment) on this QBEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QBEInteger &QBEInteger<T>::operator--()
Performs a prefix -- (decrement) on this QBEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QBEInteger QBEInteger<T>::operator--(int)
Performs a postfix -- (decrement) on this QBEInteger and returns a reference to
this object.
*/
/*!
\fn template <typename T> QBEInteger QBEInteger<T>::max()
Returns the maximum (finite) value representable by the numeric type T.
*/
/*!
\fn template <typename T> QBEInteger QBEInteger<T>::min()
Returns the minimum (finite) value representable by the numeric type T.
*/
/*!
\typedef quint16_le
\relates <QtEndian>

View File

@ -47,6 +47,11 @@
#include <stdlib.h>
#include <string.h>
#ifdef min // MSVC
#undef min
#undef max
#endif
QT_BEGIN_NAMESPACE
/*
@ -279,6 +284,27 @@ public:
{ return (*this = S::fromSpecial(val) & i); }
QSpecialInteger &operator ^=(T i)
{ return (*this = S::fromSpecial(val) ^ i); }
QSpecialInteger &operator ++()
{ return (*this = S::fromSpecial(val) + 1); }
QSpecialInteger &operator --()
{ return (*this = S::fromSpecial(val) - 1); }
QSpecialInteger operator ++(int)
{
QSpecialInteger<S> pre = *this;
*this += 1;
return pre;
}
QSpecialInteger operator --(int)
{
QSpecialInteger<S> pre = *this;
*this -= 1;
return pre;
}
static constexpr QSpecialInteger max()
{ return QSpecialInteger(std::numeric_limits<T>::max()); }
static constexpr QSpecialInteger min()
{ return QSpecialInteger(std::numeric_limits<T>::min()); }
};
template<typename T>
@ -316,6 +342,13 @@ public:
QLEInteger &operator |=(T i);
QLEInteger &operator &=(T i);
QLEInteger &operator ^=(T i);
QLEInteger &operator ++();
QLEInteger &operator --();
QLEInteger &operator ++(int);
QLEInteger &operator --(int);
static constexpr QLEInteger max();
static constexpr QLEInteger min();
};
template<typename T>
@ -336,6 +369,13 @@ public:
QBEInteger &operator |=(T i);
QBEInteger &operator &=(T i);
QBEInteger &operator ^=(T i);
QBEInteger &operator ++();
QBEInteger &operator --();
QBEInteger &operator ++(int);
QBEInteger &operator --(int);
static constexpr QBEInteger max();
static constexpr QBEInteger min();
};
#else

View File

@ -53,10 +53,6 @@
#include <qmutex.h>
#ifndef QT_NO_QOBJECT
#include <private/qthread_p.h>
#endif
#include <stdlib.h>
#include <limits.h>
#include <stdarg.h>
@ -2212,10 +2208,19 @@ static bool readEtcFile(QUnixOSVersion &v, const char *filename,
return true;
}
static bool readEtcOsRelease(QUnixOSVersion &v)
static bool readOsRelease(QUnixOSVersion &v)
{
return readEtcFile(v, "/etc/os-release", QByteArrayLiteral("ID="),
QByteArrayLiteral("VERSION_ID="), QByteArrayLiteral("PRETTY_NAME="));
QByteArray id = QByteArrayLiteral("ID=");
QByteArray versionId = QByteArrayLiteral("VERSION_ID=");
QByteArray prettyName = QByteArrayLiteral("PRETTY_NAME=");
// man os-release(5) says:
// The file /etc/os-release takes precedence over /usr/lib/os-release.
// Applications should check for the former, and exclusively use its data
// if it exists, and only fall back to /usr/lib/os-release if it is
// missing.
return readEtcFile(v, "/etc/os-release", id, versionId, prettyName) ||
readEtcFile(v, "/usr/lib/os-release", id, versionId, prettyName);
}
static bool readEtcLsbRelease(QUnixOSVersion &v)
@ -2297,7 +2302,7 @@ static bool readEtcDebianVersion(QUnixOSVersion &v)
static bool findUnixOsVersion(QUnixOSVersion &v)
{
if (readEtcOsRelease(v))
if (readOsRelease(v))
return true;
if (readEtcLsbRelease(v))
return true;
@ -3814,14 +3819,14 @@ bool qunsetenv(const char *varName)
Marks the UTF-8 encoded string literal \a sourceText for numerator
dependent delayed translation in the given \a context with the given
\a disambiguation.
\a comment.
The \a context is typically a class and also needs to be specified
as a string literal. The string literal \a disambiguation should be
a short semantic tag to tell apart otherwise identical strings.
The macro tells lupdate to collect the string, and expands to an
anonymous struct of the two string literals passed as \a sourceText
and \a disambiguation.
and \a comment.
Example:

View File

@ -55,7 +55,7 @@ enum GuardValues {
};
}
#if defined(QT_NO_THREAD) || defined(Q_COMPILER_THREADSAFE_STATICS)
#if !QT_CONFIG(thread) || defined(Q_COMPILER_THREADSAFE_STATICS)
// some compilers support thread-safe statics
// The IA-64 C++ ABI requires this, so we know that all GCC versions since 3.4
// support it. C++11 also requires this behavior.

View File

@ -264,7 +264,7 @@
[stmt.decl], but as of the time of this writing, only compilers based on
the IA-64 C++ ABI implemented it properly. The implementation requiring
thread-safe initialization is also used on the Qt bootstrapped tools, which
define QT_NO_THREAD.
disable the "thread" feature.
The implementation requiring thread-safe initialization from the compiler
is the simplest: it creates the \a Type object as a function-local static

View File

@ -1704,7 +1704,8 @@ public:
NoScrollPhase = 0,
ScrollBegin,
ScrollUpdate,
ScrollEnd
ScrollEnd,
ScrollMomentum
};
enum MouseEventSource {

View File

@ -1298,7 +1298,7 @@ struct QRandEngine
};
}
#if defined(QT_NO_THREAD) || defined(Q_OS_WIN)
#if defined(Q_OS_WIN)
// On Windows srand() and rand() already use Thread-Local-Storage
// to store the seed between calls
static inline QRandEngine *randTLS()

View File

@ -48,7 +48,9 @@
#include "qdiriterator.h"
#include "qdatetime.h"
#include "qstring.h"
#include "qregexp.h"
#if QT_CONFIG(regularexpression)
# include <qregularexpression.h>
#endif
#include "qvector.h"
#include "qvarlengtharray.h"
#include "qfilesystementry_p.h"
@ -1038,7 +1040,7 @@ QStringList QDir::nameFilters() const
list of filters specified by \a nameFilters.
Each name filter is a wildcard (globbing) filter that understands
\c{*} and \c{?} wildcards. (See \l{QRegExp wildcard matching}.)
\c{*} and \c{?} wildcards. (See \l{QRegularExpression wildcard matching}.)
For example, the following code sets three name filters on a QDir
to ensure that only files with extensions typically used for C++
@ -2110,7 +2112,7 @@ QString QDir::rootPath()
return QFileSystemEngine::rootPath();
}
#ifndef QT_NO_REGEXP
#if QT_CONFIG(regularexpression)
/*!
\overload
@ -2118,13 +2120,18 @@ QString QDir::rootPath()
patterns in the list of \a filters; otherwise returns \c false. The
matching is case insensitive.
\sa {QRegExp wildcard matching}, QRegExp::exactMatch(), entryList(), entryInfoList()
\sa {QRegularExpression Wildcard matching}, QRegularExpression::wildcardToRegularExpression(),
entryList(), entryInfoList()
*/
bool QDir::match(const QStringList &filters, const QString &fileName)
{
for (QStringList::ConstIterator sit = filters.constBegin(); sit != filters.constEnd(); ++sit) {
QRegExp rx(*sit, Qt::CaseInsensitive, QRegExp::Wildcard);
if (rx.exactMatch(fileName))
QString wildcard = QRegularExpression::wildcardToRegularExpression(*sit);
// Insensitive exact match
// (see Notes for QRegExp Users in QRegularExpression's documentation)
QRegularExpression rx(QRegularExpression::anchoredPattern(wildcard),
QRegularExpression::CaseInsensitiveOption);
if (rx.match(fileName).hasMatch())
return true;
}
return false;
@ -2136,13 +2143,14 @@ bool QDir::match(const QStringList &filters, const QString &fileName)
contain multiple patterns separated by spaces or semicolons.
The matching is case insensitive.
\sa {QRegExp wildcard matching}, QRegExp::exactMatch(), entryList(), entryInfoList()
\sa {QRegularExpression wildcard matching}, QRegularExpression::wildcardToRegularExpression,
entryList(), entryInfoList()
*/
bool QDir::match(const QString &filter, const QString &fileName)
{
return match(nameFiltersFromString(filter), fileName);
}
#endif // QT_NO_REGEXP
#endif // QT_CONFIG(regularexpression)
/*!
\internal

View File

@ -206,7 +206,7 @@ public:
static inline QDir temp() { return QDir(tempPath()); }
static QString tempPath();
#ifndef QT_NO_REGEXP
#if QT_CONFIG(regularexpression)
static bool match(const QStringList &filters, const QString &fileName);
static bool match(const QString &filter, const QString &fileName);
#endif

View File

@ -91,7 +91,6 @@ extern "C" NSString *NSTemporaryDirectory();
# include <sys/syscall.h>
# include <sys/sendfile.h>
# include <linux/fs.h>
# include <linux/stat.h>
// in case linux/fs.h is too old and doesn't define it:
#ifndef FICLONE
@ -112,6 +111,7 @@ static int renameat2(int oldfd, const char *oldpath, int newfd, const char *newp
# endif
# if !QT_CONFIG(statx) && defined(SYS_statx)
# include <linux/stat.h>
static int statx(int dirfd, const char *pathname, int flag, unsigned mask, struct statx *statxbuf)
{ return syscall(SYS_statx, dirfd, pathname, flag, mask, statxbuf); }
# elif !QT_CONFIG(statx) && !defined(SYS_statx)
@ -853,7 +853,7 @@ QByteArray QFileSystemEngine::id(int id)
//static
QString QFileSystemEngine::resolveUserName(uint userId)
{
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
if (size_max == -1)
size_max = 1024;
@ -862,7 +862,7 @@ QString QFileSystemEngine::resolveUserName(uint userId)
#if !defined(Q_OS_INTEGRITY)
struct passwd *pw = 0;
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS)
#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS)
struct passwd entry;
getpwuid_r(userId, &entry, buf.data(), buf.size(), &pw);
#else
@ -877,7 +877,7 @@ QString QFileSystemEngine::resolveUserName(uint userId)
//static
QString QFileSystemEngine::resolveGroupName(uint groupId)
{
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
if (size_max == -1)
size_max = 1024;
@ -886,7 +886,7 @@ QString QFileSystemEngine::resolveGroupName(uint groupId)
#if !defined(Q_OS_INTEGRITY)
struct group *gr = 0;
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID) && (__ANDROID_API__ >= 24))
#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID) && (__ANDROID_API__ >= 24))
size_max = sysconf(_SC_GETGR_R_SIZE_MAX);
if (size_max == -1)
size_max = 1024;

View File

@ -45,7 +45,6 @@
#include "qfile.h"
#include "qdir.h"
#include "private/qmutexpool_p.h"
#include "qvarlengtharray.h"
#include "qdatetime.h"
#include "qt_windows.h"

View File

@ -101,7 +101,6 @@ QT_END_NAMESPACE
#include <qdir.h>
#include <qlist.h>
#include <qmutex.h>
#include <qsemaphore.h>
#include <qsocketnotifier.h>
#include <qthread.h>
#include <qelapsedtimer.h>

View File

@ -472,16 +472,10 @@ static inline QString webDavSslTag()
return QStringLiteral("@SSL");
}
#ifdef Q_COMPILER_CLASS_ENUM
# define colon_uchar : uchar
#else
# define colon_uchar
#endif
class QUrlPrivate
{
public:
enum Section colon_uchar {
enum Section : uchar {
Scheme = 0x01,
UserName = 0x02,
Password = 0x04,
@ -496,7 +490,7 @@ public:
FullUrl = 0xff
};
enum Flags colon_uchar {
enum Flags : uchar {
IsLocalFile = 0x01
};
@ -616,7 +610,6 @@ public:
// 32-bit: 2 bytes tail padding available
// 64-bit: 6 bytes tail padding available
};
#undef colon_uchar
inline QUrlPrivate::QUrlPrivate()
: ref(1), port(-1),

View File

@ -65,7 +65,7 @@ extern Q_AUTOTEST_EXPORT int qt_urlRecode(QString &appendTo, const QChar *begin,
enum AceLeadingDot { AllowLeadingDot, ForbidLeadingDot };
enum AceOperation { ToAceOnly, NormalizeAce };
extern QString qt_ACE_do(const QString &domain, AceOperation op, AceLeadingDot dot);
extern Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from);
extern Q_AUTOTEST_EXPORT bool qt_nameprep(QString *source, int from);
extern Q_AUTOTEST_EXPORT bool qt_check_std3rules(const QChar *uc, int len);
extern Q_AUTOTEST_EXPORT void qt_punycodeEncoder(const QChar *s, int ucLength, QString *output);
extern Q_AUTOTEST_EXPORT QString qt_punycodeDecoder(const QString &pc);

View File

@ -2021,7 +2021,7 @@ static bool isBidirectionalL(uint uc)
return false;
}
Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from)
Q_AUTOTEST_EXPORT bool qt_nameprep(QString *source, int from)
{
QChar *src = source->data(); // causes a detach, so we're sure the only one using it
QChar *out = src + from;
@ -2036,7 +2036,7 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from)
}
}
if (out == e)
return; // everything was mapped easily (lowercased, actually)
return true; // everything was mapped easily (lowercased, actually)
int firstNonAscii = out - src;
// Characters unassigned in Unicode 3.2 are not allowed in "stored string" scheme
@ -2059,7 +2059,7 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from)
QChar::UnicodeVersion version = QChar::unicodeVersion(uc);
if (version == QChar::Unicode_Unassigned || version > QChar::Unicode_3_2) {
source->resize(from); // not allowed, clear the label
return;
return false;
}
}
if (!isMappedToNothing(uc)) {
@ -2086,7 +2086,7 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from)
// Strip prohibited output
if (containsProhibitedOuptut(source, firstNonAscii)) {
source->resize(from);
return;
return false;
}
// Check for valid bidirectional characters
@ -2110,9 +2110,13 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from)
}
if (containsRandALCat) {
if (containsLCat || (!isBidirectionalRorAL(src[from].unicode())
|| !isBidirectionalRorAL(e[-1].unicode())))
|| !isBidirectionalRorAL(e[-1].unicode()))) {
source->resize(from); // not allowed, clear the label
return false;
}
}
return true;
}
static const QChar *qt_find_nonstd3(const QChar *uc, int len, Qt::CaseSensitivity cs)
@ -2553,7 +2557,8 @@ QString qt_ACE_do(const QString &domain, AceOperation op, AceLeadingDot dot)
} else {
// Punycode encoding and decoding cannot be done in-place
// That means we need one or two temporaries
qt_nameprep(&result, prevLen);
if (!qt_nameprep(&result, prevLen))
return QString(); // failed
labelLength = result.length() - prevLen;
int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes
aceForm.resize(0);

View File

@ -1866,6 +1866,23 @@ bool QAbstractItemModel::setData(const QModelIndex &index, const QVariant &value
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
/*!
\since 6.0
Removes the data stored in all the roles for the given \a index.
Returns \c{true} if successful; otherwise returns \c{false}.
The dataChanged() signal should be emitted if the data was successfully
removed.
The base class implementation returns \c{false}
\sa data(), itemData(), setData(), setItemData()
*/
bool QAbstractItemModel::clearItemData(const QModelIndex &index)
{
Q_UNUSED(index);
return false;
}
#endif
/*!
\fn QVariant QAbstractItemModel::data(const QModelIndex &index, int role) const = 0

View File

@ -198,6 +198,9 @@ public:
virtual QMap<int, QVariant> itemData(const QModelIndex &index) const;
virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual bool clearItemData(const QModelIndex &index);
#endif
virtual QStringList mimeTypes() const;
virtual QMimeData *mimeData(const QModelIndexList &indexes) const;

View File

@ -43,6 +43,7 @@
#include <qdebug.h>
#include <qdatetime.h>
#include <qpair.h>
#include <qregularexpression.h>
#include <qstringlist.h>
#include <private/qabstractitemmodel_p.h>
#include <private/qabstractproxymodel_p.h>
@ -146,6 +147,133 @@ private:
int end;
};
class RegularExpressionData {
private:
enum class ExpressionType {
RegExp,
#if QT_CONFIG(regularexpression)
RegularExpression
#endif
};
public:
RegularExpressionData() :
m_type(ExpressionType::RegExp)
{}
#if QT_CONFIG(regularexpression)
QRegularExpression regularExpression() const
{
if (m_type == ExpressionType::RegularExpression)
return m_regularExpression;
return QRegularExpression();
}
void setRegularExpression(const QRegularExpression &rx)
{
m_type = ExpressionType::RegularExpression;
m_regularExpression = rx;
m_regExp = QRegExp();
}
#endif
QRegExp regExp() const
{
if (m_type == ExpressionType::RegExp)
return m_regExp;
return QRegExp();
}
void setRegExp(const QRegExp &rx)
{
m_type = ExpressionType::RegExp;
m_regExp = rx;
#if QT_CONFIG(regularexpression)
m_regularExpression = QRegularExpression();
#endif
}
bool isEmpty() const
{
bool result = true;
switch (m_type) {
case ExpressionType::RegExp:
result = m_regExp.isEmpty();
break;
#if QT_CONFIG(regularexpression)
case ExpressionType::RegularExpression:
result = m_regularExpression.pattern().isEmpty();
break;
#endif
}
return result;
}
Qt::CaseSensitivity caseSensitivity() const
{
Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive;
switch (m_type) {
case ExpressionType::RegExp:
sensitivity = m_regExp.caseSensitivity();
break;
#if QT_CONFIG(regularexpression)
case ExpressionType::RegularExpression:
{
QRegularExpression::PatternOptions options = m_regularExpression.patternOptions();
if (!(options & QRegularExpression::CaseInsensitiveOption))
sensitivity = Qt::CaseSensitive;
}
break;
#endif
}
return sensitivity;
}
void setCaseSensitivity(Qt::CaseSensitivity cs)
{
switch (m_type) {
case ExpressionType::RegExp:
m_regExp.setCaseSensitivity(cs);
break;
#if QT_CONFIG(regularexpression)
case ExpressionType::RegularExpression:
{
QRegularExpression::PatternOptions options = m_regularExpression.patternOptions();
options.setFlag(QRegularExpression::CaseInsensitiveOption, cs == Qt::CaseSensitive);
m_regularExpression.setPatternOptions(options);
}
break;
#endif
}
}
bool hasMatch(const QString &str) const
{
bool result = false;
switch (m_type) {
case ExpressionType::RegExp:
result = str.contains(m_regExp);
break;
#if QT_CONFIG(regularexpression)
case ExpressionType::RegularExpression:
result = str.contains(m_regularExpression);
break;
#endif
}
return result;
}
private:
ExpressionType m_type;
QRegExp m_regExp;
#if QT_CONFIG(regularexpression)
QRegularExpression m_regularExpression;
#endif
};
class QSortFilterProxyModelPrivate : public QAbstractProxyModelPrivate
{
Q_DECLARE_PUBLIC(QSortFilterProxyModel)
@ -171,7 +299,7 @@ public:
int filter_column;
int filter_role;
QRegExp filter_regexp;
RegularExpressionData filter_data;
QModelIndex last_top_source;
bool filter_recursive;
@ -1109,7 +1237,7 @@ void QSortFilterProxyModelPrivate::update_persistent_indexes(
*/
void QSortFilterProxyModelPrivate::filter_about_to_be_changed(const QModelIndex &source_parent)
{
if (!filter_regexp.pattern().isEmpty() &&
if (!filter_data.isEmpty() &&
source_index_mapping.constFind(source_parent) == source_index_mapping.constEnd())
create_mapping(source_parent);
}
@ -1786,9 +1914,9 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved(
If a parent item doesn't match the filter, none of its children will be
shown.
A common use case is to let the user specify the filter regexp, wildcard
pattern, or fixed string in a QLineEdit and to connect the
\l{QLineEdit::textChanged()}{textChanged()} signal to setFilterRegExp(),
A common use case is to let the user specify the filter regular expression,
wildcard pattern, or fixed string in a QLineEdit and to connect the
\l{QLineEdit::textChanged()}{textChanged()} signal to setFilterRegularExpression(),
setFilterWildcard(), or setFilterFixedString() to reapply the filter.
Custom filtering behavior can be achieved by reimplementing the
@ -1825,6 +1953,21 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved(
\note Some general guidelines for subclassing models are available in the
\l{Model Subclassing Reference}.
\note With Qt 5, regular expression support has been improved through the
QRegularExpression class. QSortFilterProxyModel dating back prior to that
class creation, it originally supported only QRegExp. Since Qt 5.12,
QRegularExpression APIs have been added. Therefore, QRegExp APIs should be
considered deprecated and the QRegularExpression version should be used in
place.
\warning Don't mix calls to the getters and setters of different regexp types
as this will lead to unexpected results. For maximum compatibility, the original
implementation has been kept. Therefore, if, for example, a call to
setFilterRegularExpression is made followed by another one to
setFilterFixedString, the first call will setup a QRegularExpression object
to use as filter while the second will setup a QRegExp in FixedString mode.
However, this is an implementation detail that might change in the future.
\sa QAbstractProxyModel, QAbstractItemModel, {Model/View Programming},
{Basic Sort/Filter Model Example}, {Custom Sort/Filter Model Example}, QIdentityProxyModel
*/
@ -2437,17 +2580,47 @@ Qt::SortOrder QSortFilterProxyModel::sortOrder() const
QRegExp QSortFilterProxyModel::filterRegExp() const
{
Q_D(const QSortFilterProxyModel);
return d->filter_regexp;
return d->filter_data.regExp();
}
void QSortFilterProxyModel::setFilterRegExp(const QRegExp &regExp)
{
Q_D(QSortFilterProxyModel);
d->filter_about_to_be_changed();
d->filter_regexp = regExp;
d->filter_data.setRegExp(regExp);
d->filter_changed();
}
#if QT_CONFIG(regularexpression)
/*!
\since 5.12
\property QSortFilterProxyModel::filterRegularExpression
\brief the QRegularExpression used to filter the contents of the source model
Setting this property overwrites the current
\l{QSortFilterProxyModel::filterCaseSensitivity}{filterCaseSensitivity}.
By default, the QRegularExpression is an empty string matching all contents.
If no QRegularExpression or an empty string is set, everything in the source
model will be accepted.
\sa filterCaseSensitivity, setFilterWildcard(), setFilterFixedString()
*/
QRegularExpression QSortFilterProxyModel::filterRegularExpression() const
{
Q_D(const QSortFilterProxyModel);
return d->filter_data.regularExpression();
}
void QSortFilterProxyModel::setFilterRegularExpression(const QRegularExpression &regularExpression)
{
Q_D(QSortFilterProxyModel);
d->filter_about_to_be_changed();
d->filter_data.setRegularExpression(regularExpression);
d->filter_changed();
}
#endif
/*!
\property QSortFilterProxyModel::filterKeyColumn
\brief the column where the key used to filter the contents of the
@ -2483,16 +2656,16 @@ void QSortFilterProxyModel::setFilterKeyColumn(int column)
Qt::CaseSensitivity QSortFilterProxyModel::filterCaseSensitivity() const
{
Q_D(const QSortFilterProxyModel);
return d->filter_regexp.caseSensitivity();
return d->filter_data.caseSensitivity();
}
void QSortFilterProxyModel::setFilterCaseSensitivity(Qt::CaseSensitivity cs)
{
Q_D(QSortFilterProxyModel);
if (cs == d->filter_regexp.caseSensitivity())
if (cs == d->filter_data.caseSensitivity())
return;
d->filter_about_to_be_changed();
d->filter_regexp.setCaseSensitivity(cs);
d->filter_data.setCaseSensitivity(cs);
d->filter_changed();
}
@ -2558,11 +2731,33 @@ void QSortFilterProxyModel::setFilterRegExp(const QString &pattern)
{
Q_D(QSortFilterProxyModel);
d->filter_about_to_be_changed();
d->filter_regexp.setPatternSyntax(QRegExp::RegExp);
d->filter_regexp.setPattern(pattern);
QRegExp rx(pattern);
d->filter_data.setRegExp(rx);
d->filter_changed();
}
#if QT_CONFIG(regularexpression)
/*!
\since 5.12
Sets the regular expression used to filter the contents
of the source model to \a pattern.
This method should be preferred for new code as it will use
QRegularExpression internally.
\sa setFilterCaseSensitivity(), setFilterWildcard(), setFilterFixedString(), filterRegularExpression()
*/
void QSortFilterProxyModel::setFilterRegularExpression(const QString &pattern)
{
Q_D(QSortFilterProxyModel);
d->filter_about_to_be_changed();
QRegularExpression rx(pattern);
d->filter_data.setRegularExpression(rx);
d->filter_changed();
}
#endif
/*!
Sets the wildcard expression used to filter the contents
of the source model to the given \a pattern.
@ -2573,8 +2768,8 @@ void QSortFilterProxyModel::setFilterWildcard(const QString &pattern)
{
Q_D(QSortFilterProxyModel);
d->filter_about_to_be_changed();
d->filter_regexp.setPatternSyntax(QRegExp::Wildcard);
d->filter_regexp.setPattern(pattern);
QRegExp rx(pattern, d->filter_data.caseSensitivity(), QRegExp::Wildcard);
d->filter_data.setRegExp(rx);
d->filter_changed();
}
@ -2588,8 +2783,8 @@ void QSortFilterProxyModel::setFilterFixedString(const QString &pattern)
{
Q_D(QSortFilterProxyModel);
d->filter_about_to_be_changed();
d->filter_regexp.setPatternSyntax(QRegExp::FixedString);
d->filter_regexp.setPattern(pattern);
QRegExp rx(pattern, d->filter_data.caseSensitivity(), QRegExp::FixedString);
d->filter_data.setRegExp(rx);
d->filter_changed();
}
@ -2814,14 +3009,15 @@ bool QSortFilterProxyModel::lessThan(const QModelIndex &source_left, const QMode
bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
Q_D(const QSortFilterProxyModel);
if (d->filter_regexp.isEmpty())
if (d->filter_data.isEmpty())
return true;
if (d->filter_column == -1) {
int column_count = d->model->columnCount(source_parent);
for (int column = 0; column < column_count; ++column) {
QModelIndex source_index = d->model->index(source_row, column, source_parent);
QString key = d->model->data(source_index, d->filter_role).toString();
if (key.contains(d->filter_regexp))
if (d->filter_data.hasMatch(key))
return true;
}
return false;
@ -2830,7 +3026,7 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
if (!source_index.isValid()) // the column may not exist
return true;
QString key = d->model->data(source_index, d->filter_role).toString();
return key.contains(d->filter_regexp);
return d->filter_data.hasMatch(key);
}
/*!

View File

@ -42,6 +42,7 @@
#include <QtCore/qabstractproxymodel.h>
#include <QtCore/qregexp.h>
#include <QtCore/qregularexpression.h>
QT_REQUIRE_CONFIG(sortfilterproxymodel);
@ -59,6 +60,9 @@ class Q_CORE_EXPORT QSortFilterProxyModel : public QAbstractProxyModel
Q_OBJECT
Q_PROPERTY(QRegExp filterRegExp READ filterRegExp WRITE setFilterRegExp)
#if QT_CONFIG(regularexpression)
Q_PROPERTY(QRegularExpression filterRegularExpression READ filterRegularExpression WRITE setFilterRegularExpression)
#endif
Q_PROPERTY(int filterKeyColumn READ filterKeyColumn WRITE setFilterKeyColumn)
Q_PROPERTY(bool dynamicSortFilter READ dynamicSortFilter WRITE setDynamicSortFilter)
Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity)
@ -83,6 +87,9 @@ public:
QRegExp filterRegExp() const;
void setFilterRegExp(const QRegExp &regExp);
QRegularExpression filterRegularExpression() const;
void setFilterRegularExpression(const QRegularExpression &regularExpression);
int filterKeyColumn() const;
void setFilterKeyColumn(int column);
@ -112,6 +119,9 @@ public:
public Q_SLOTS:
void setFilterRegExp(const QString &pattern);
#if QT_CONFIG(regularexpression)
void setFilterRegularExpression(const QString &pattern);
#endif
void setFilterWildcard(const QString &pattern);
void setFilterFixedString(const QString &pattern);
#if QT_DEPRECATED_SINCE(5, 11)

View File

@ -42,6 +42,7 @@
#include "qhash.h"
#include "qpair.h"
#include "qmutex.h"
#include "qvarlengtharray.h"
QT_BEGIN_NAMESPACE

View File

@ -58,9 +58,11 @@
#include <qtextcodec.h>
#ifndef QT_NO_QOBJECT
#include <qthread.h>
#include <qthreadpool.h>
#include <qthreadstorage.h>
#include <private/qthread_p.h>
#if QT_CONFIG(thread)
#include <qthreadpool.h>
#endif
#endif
#include <qelapsedtimer.h>
#include <qlibraryinfo.h>
@ -268,9 +270,7 @@ typedef QList<QtStartUpFunction> QStartUpFuncList;
Q_GLOBAL_STATIC(QStartUpFuncList, preRList)
typedef QList<QtCleanUpFunction> QVFuncList;
Q_GLOBAL_STATIC(QVFuncList, postRList)
#ifndef QT_NO_QOBJECT
static QBasicMutex globalRoutinesMutex;
#endif
/*!
\internal
@ -289,9 +289,7 @@ void qAddPreRoutine(QtStartUpFunction p)
// Due to C++11 parallel dynamic initialization, this can be called
// from multiple threads.
#ifndef QT_NO_THREAD
QMutexLocker locker(&globalRoutinesMutex);
#endif
list->prepend(p); // in case QCoreApplication is re-created, see qt_call_pre_routines
}
@ -300,9 +298,7 @@ void qAddPostRoutine(QtCleanUpFunction p)
QVFuncList *list = postRList();
if (!list)
return;
#ifndef QT_NO_THREAD
QMutexLocker locker(&globalRoutinesMutex);
#endif
list->prepend(p);
}
@ -311,9 +307,7 @@ void qRemovePostRoutine(QtCleanUpFunction p)
QVFuncList *list = postRList();
if (!list)
return;
#ifndef QT_NO_THREAD
QMutexLocker locker(&globalRoutinesMutex);
#endif
list->removeAll(p);
}
@ -324,9 +318,7 @@ static void qt_call_pre_routines()
QVFuncList list;
{
#ifndef QT_NO_THREAD
QMutexLocker locker(&globalRoutinesMutex);
#endif
// Unlike qt_call_post_routines, we don't empty the list, because
// Q_COREAPP_STARTUP_FUNCTION is a macro, so the user expects
// the function to be executed every time QCoreApplication is created.
@ -345,9 +337,7 @@ void Q_CORE_EXPORT qt_call_post_routines()
QVFuncList list;
{
// extract the current list and make the stored list empty
#ifndef QT_NO_THREAD
QMutexLocker locker(&globalRoutinesMutex);
#endif
qSwap(*postRList, list);
}
@ -513,7 +503,7 @@ QCoreApplicationPrivate::~QCoreApplicationPrivate()
void QCoreApplicationPrivate::cleanupThreadData()
{
if (threadData && !threadData_clean) {
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
void *data = &threadData->tls;
QThreadStorageData::finish((void **)data);
#endif
@ -888,7 +878,7 @@ QCoreApplication::~QCoreApplication()
QCoreApplicationPrivate::is_app_running = false;
#endif
#if !defined(QT_NO_THREAD)
#if QT_CONFIG(thread)
// Synchronize and stop the global thread pool threads.
QThreadPool *globalThreadPool = 0;
QT_TRY {

View File

@ -345,7 +345,6 @@ QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context)
sizeof(GIdleTimerSource)));
idleTimerSource->timerSource = timerSource;
g_source_set_can_recurse(&idleTimerSource->source, true);
g_source_set_priority(&idleTimerSource->source, G_PRIORITY_DEFAULT_IDLE);
g_source_attach(&idleTimerSource->source, mainContext);
}

View File

@ -50,7 +50,9 @@
#include <qthread.h>
#include <qvariant.h>
#include <qdebug.h>
#if QT_CONFIG(thread)
#include <qsemaphore.h>
#endif
#include "private/qobject_p.h"
#include "private/qmetaobject_p.h"
@ -1540,14 +1542,14 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase *
QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, 1, types, args));
} else if (type == Qt::BlockingQueuedConnection) {
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
if (currentThread == objectThread)
qWarning("QMetaObject::invokeMethod: Dead lock detected");
QSemaphore semaphore;
QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, 0, 0, argv, &semaphore));
semaphore.acquire();
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
} else {
qWarning("QMetaObject::invokeMethod: Unknown connection type");
return false;
@ -2272,7 +2274,7 @@ bool QMetaMethod::invoke(QObject *object,
: Qt::QueuedConnection;
}
#ifdef QT_NO_THREAD
#if !QT_CONFIG(thread)
if (connectionType == Qt::BlockingQueuedConnection) {
connectionType = Qt::DirectConnection;
}
@ -2348,7 +2350,7 @@ bool QMetaMethod::invoke(QObject *object,
QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction,
0, -1, nargs, types, args));
} else { // blocking queued connection
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
if (currentThread == objectThread) {
qWarning("QMetaMethod::invoke: Dead lock detected in "
"BlockingQueuedConnection: Receiver is %s(%p)",
@ -2359,7 +2361,7 @@ bool QMetaMethod::invoke(QObject *object,
QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction,
0, -1, 0, 0, param, &semaphore));
semaphore.acquire();
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
}
return true;
}

View File

@ -59,7 +59,9 @@
#include <qpair.h>
#include <qvarlengtharray.h>
#include <qset.h>
#if QT_CONFIG(thread)
#include <qsemaphore.h>
#endif
#include <qsharedpointer.h>
#include <private/qorderedmutexlocker_p.h>
@ -488,7 +490,7 @@ QMetaCallEvent::~QMetaCallEvent()
free(types_);
free(args_);
}
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
if (semaphore_)
semaphore_->release();
#endif
@ -3727,7 +3729,7 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i
|| (c->connectionType == Qt::QueuedConnection)) {
queued_activate(sender, signal_index, c, argv ? argv : empty_argv, locker);
continue;
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
} else if (c->connectionType == Qt::BlockingQueuedConnection) {
if (receiverInSameThread) {
qWarning("Qt: Dead lock detected while activating a BlockingQueuedConnection: "

View File

@ -112,13 +112,31 @@ namespace QtPrivate {
The Functor<Func,N> struct is the helper to call a functor of N argument.
its call function is the same as the FunctionPointer::call function.
*/
template <int...> struct IndexesList {};
template <typename IndexList, int Right> struct IndexesAppend;
template <int... Left, int Right> struct IndexesAppend<IndexesList<Left...>, Right>
{ typedef IndexesList<Left..., Right> Value; };
template <int N> struct Indexes
{ typedef typename IndexesAppend<typename Indexes<N - 1>::Value, N - 1>::Value Value; };
template <> struct Indexes<0> { typedef IndexesList<> Value; };
template<class T> using InvokeGenSeq = typename T::Type;
template<int...> struct IndexesList { using Type = IndexesList; };
template<int N, class S1, class S2> struct ConcatSeqImpl;
template<int N, int... I1, int... I2>
struct ConcatSeqImpl<N, IndexesList<I1...>, IndexesList<I2...>>
: IndexesList<I1..., (N + I2)...>{};
template<int N, class S1, class S2>
using ConcatSeq = InvokeGenSeq<ConcatSeqImpl<N, S1, S2>>;
template<int N> struct GenSeq;
template<int N> using makeIndexSequence = InvokeGenSeq<GenSeq<N>>;
template<int N>
struct GenSeq : ConcatSeq<N/2, makeIndexSequence<N/2>, makeIndexSequence<N - N/2>>{};
template<> struct GenSeq<0> : IndexesList<>{};
template<> struct GenSeq<1> : IndexesList<0>{};
template<int N>
struct Indexes { using Value = makeIndexSequence<N>; };
template<typename Func> struct FunctionPointer { enum {ArgumentCount = -1, IsPointerToMemberFunction = false}; };
template <typename, typename, typename, typename> struct FunctorCall;

View File

@ -49,7 +49,7 @@
QT_BEGIN_NAMESPACE
#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \
#if !defined(Q_OS_WIN) && QT_CONFIG(thread) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \
defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L
namespace {
// There are two incompatible versions of strerror_r:
@ -130,7 +130,7 @@ static QString standardLibraryErrorString(int errorCode)
s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
break;
default: {
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
QByteArray buf(1024, Qt::Uninitialized);
ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
#else

View File

@ -382,9 +382,12 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
// Disambiguate conflicting extensions (if magic matching found something)
if (candidateByData.isValid() && magicAccuracy > 0) {
// "for glob_match in glob_matches:"
// "if glob_match is subclass or equal to sniffed_type, use glob_match"
const QString sniffedMime = candidateByData.name();
// If the sniffedMime matches a glob match, use it
if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
*accuracyPtr = 100;
return candidateByData;
}
for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
if (inherits(m, sniffedMime)) {
// We have magic + pattern pointing to this, so it's a pretty good match

View File

@ -327,8 +327,8 @@ void QCborArray::insert(qsizetype i, QCborValue &&value)
}
/*!
\fn QCborValue QCborArray::extract(iterator it)
\fn QCborValue QCborArray::extract(const_iterator it)
\fn QCborValue QCborArray::extract(Iterator it)
\fn QCborValue QCborArray::extract(ConstIterator it)
Extracts a value from the array at the position indicated by iterator \a it
and returns the value so extracted.
@ -1048,6 +1048,7 @@ void QCborArray::detach(qsizetype reserved)
*/
/*!
\fn bool QCborArray::ConstIterator::operator==(const Iterator &other) const
\fn bool QCborArray::ConstIterator::operator==(const ConstIterator &other) const
Returns \c true if \a other points to the same entry in the array as this
@ -1067,6 +1068,7 @@ void QCborArray::detach(qsizetype reserved)
*/
/*!
\fn bool QCborArray::ConstIterator::operator<(const Iterator &other) const
\fn bool QCborArray::ConstIterator::operator<(const ConstIterator &other) const
Returns \c true if the entry in the array pointed to by this iterator
@ -1074,6 +1076,7 @@ void QCborArray::detach(qsizetype reserved)
*/
/*!
\fn bool QCborArray::ConstIterator::operator<=(const Iterator &other) const
\fn bool QCborArray::ConstIterator::operator<=(const ConstIterator &other) const
Returns \c true if the entry in the array pointed to by this iterator
@ -1082,6 +1085,7 @@ void QCborArray::detach(qsizetype reserved)
*/
/*!
\fn bool QCborArray::ConstIterator::operator>(const Iterator &other) const
\fn bool QCborArray::ConstIterator::operator>(const ConstIterator &other) const
Returns \c true if the entry in the array pointed to by this iterator
@ -1089,6 +1093,7 @@ void QCborArray::detach(qsizetype reserved)
*/
/*!
\fn bool QCborArray::ConstIterator::operator>=(const Iterator &other) const
\fn bool QCborArray::ConstIterator::operator>=(const ConstIterator &other) const
Returns \c true if the entry in the array pointed to by this iterator

View File

@ -337,7 +337,7 @@ void DiagnosticNotation::appendValue(const QCborValue &v)
high-fidelity notation of a stream, without transformation, see the \c
cbordump example.
\sa toCbor(), toJsonDocument(), QJsonDocument::toJson()
\sa toCbor(), QJsonDocument::toJson()
*/
QString QCborValue::toDiagnosticNotation(DiagnosticNotationOptions opts) const
{

View File

@ -804,6 +804,9 @@ QCborValueRef QCborMap::operator[](const QCborValue &key)
}
/*!
\fn QCborMap::iterator QCborMap::find(qint64 key)
\fn QCborMap::const_iterator QCborMap::find(qint64 key) const
Returns a map iterator to the key-value pair whose key is \a key, if the
map contains such a pair. If it doesn't, this function returns end().
@ -828,6 +831,8 @@ QCborMap::iterator QCborMap::find(qint64 key)
}
/*!
\fn QCborMap::iterator QCborMap::find(QLatin1String key)
\fn QCborMap::const_iterator QCborMap::find(QLatin1String key) const
\overload
Returns a map iterator to the key-value pair whose key is \a key, if the
@ -852,6 +857,8 @@ QCborMap::iterator QCborMap::find(QLatin1String key)
}
/*!
\fn QCborMap::iterator QCborMap::find(const QString & key)
\fn QCborMap::const_iterator QCborMap::find(const QString & key) const
\overload
Returns a map iterator to the key-value pair whose key is \a key, if the
@ -876,6 +883,8 @@ QCborMap::iterator QCborMap::find(const QString & key)
}
/*!
\fn QCborMap::iterator QCborMap::find(const QCborValue &key)
\fn QCborMap::const_iterator QCborMap::find(const QCborValue &key) const
\overload
Returns a map iterator to the key-value pair whose key is \a key, if the
@ -1100,6 +1109,9 @@ QCborMap::iterator QCborMap::erase(QCborMap::iterator it)
}
/*!
\fn QCborValue QCborMap::extract(iterator it)
\fn QCborValue QCborMap::extract(const_iterator it)
Extracts a value from the map at the position indicated by iterator \a it
and returns the value so extracted.
@ -1359,6 +1371,40 @@ void QCborMap::detach(qsizetype reserved)
\sa operator==()
*/
/*!
\fn bool QCborMap::Iterator::operator<(const Iterator& other) const
\fn bool QCborMap::Iterator::operator<(const ConstIterator& other) const
Returns \c true if the entry in the map pointed to by this iterator
occurs before the entry pointed to by the \a other iterator.
*/
/*!
\fn bool QCborMap::Iterator::operator<=(const Iterator& other) const
\fn bool QCborMap::Iterator::operator<=(const ConstIterator& other) const
Returns \c true if the entry in the map pointed to by this iterator
occurs before or is the same entry as is pointed to by the \a other
iterator.
*/
/*!
\fn bool QCborMap::Iterator::operator>(const Iterator& other) const
\fn bool QCborMap::Iterator::operator>(const ConstIterator& other) const
Returns \c true if the entry in the map pointed to by this iterator
occurs after the entry pointed to by the \a other iterator.
*/
/*!
\fn bool QCborMap::Iterator::operator>=(const Iterator& other) const
\fn bool QCborMap::Iterator::operator>=(const ConstIterator& other) const
Returns \c true if the entry in the map pointed to by this iterator
occurs after or is the same entry as is pointed to by the \a other
iterator.
*/
/*!
\fn QCborMap::Iterator &QCborMap::Iterator::operator++()
@ -1415,6 +1461,16 @@ void QCborMap::detach(qsizetype reserved)
\sa operator+()
*/
/*!
\fn qsizetype QCborMap::Iterator::operator-(QCborMap::Iterator j) const
Returns the position of the item at iterator \a j relative to the item
at this iterator. If the item at \a j is forward of this time, the returned
value is negative.
\sa operator+()
*/
/*!
\fn QCborMap::Iterator &QCborMap::Iterator::operator+=(qsizetype j)
@ -1560,6 +1616,40 @@ void QCborMap::detach(qsizetype reserved)
\sa operator==()
*/
/*!
\fn bool QCborMap::ConstIterator::operator<(const Iterator &other) const
\fn bool QCborMap::ConstIterator::operator<(const ConstIterator &other) const
Returns \c true if the entry in the map pointed to by this iterator
occurs before the entry pointed to by the \a other iterator.
*/
/*!
\fn bool QCborMap::ConstIterator::operator<=(const Iterator &other) const
\fn bool QCborMap::ConstIterator::operator<=(const ConstIterator &other) const
Returns \c true if the entry in the map pointed to by this iterator
occurs before or is the same entry as is pointed to by the \a other
iterator.
*/
/*!
\fn bool QCborMap::ConstIterator::operator>(const Iterator &other) const
\fn bool QCborMap::ConstIterator::operator>(const ConstIterator &other) const
Returns \c true if the entry in the map pointed to by this iterator
occurs after the entry pointed to by the \a other iterator.
*/
/*!
\fn bool QCborMap::ConstIterator::operator>=(const Iterator &other) const
\fn bool QCborMap::ConstIterator::operator>=(const ConstIterator &other) const
Returns \c true if the entry in the map pointed to by this iterator
occurs after or is the same entry as is pointed to by the \a other
iterator.
*/
/*!
\fn QCborMap::ConstIterator &QCborMap::ConstIterator::operator++()
@ -1616,6 +1706,16 @@ void QCborMap::detach(qsizetype reserved)
\sa operator+()
*/
/*!
\fn qsizetype QCborMap::ConstIterator::operator-(QCborMap::ConstIterator j) const
Returns the position of the item at iterator \a j relative to the item
at this iterator. If the item at \a j is forward of this time, the returned
value is negative.
\sa operator+()
*/
/*!
\fn QCborMap::ConstIterator &QCborMap::ConstIterator::operator+=(qsizetype j)

View File

@ -1044,7 +1044,7 @@ void QCborStreamWriter::append(QCborSimpleType st)
Appends the floating point number \a f to the stream, creating a CBOR 16-bit
Half-Precision Floating Point value. The following code can be used to convert
a C++ \tt float to \l qfloat16 if there's no loss of precision and append it, or
a C++ \tt float to \c qfloat16 if there's no loss of precision and append it, or
instead append the \tt float.
\code
@ -1144,7 +1144,7 @@ void QCborStreamWriter::append(double d)
QCborStreamReader::readByteArray() nor QCborValue support reading CBOR
streams with byte arrays larger than 2 GB.
\sa append(QByteArray), appendTextString(),
\sa append(), appendTextString(),
QCborStreamReader::isByteArray(), QCborStreamReader::readByteArray()
*/
void QCborStreamWriter::appendByteString(const char *data, qsizetype len)

View File

@ -2196,6 +2196,16 @@ QCborValue QCborValue::fromCbor(const QByteArray &ba, QCborParserError *error)
return result;
}
/*!
\fn QCborValue QCborValue::fromCbor(const char *data, qsizetype len, QCborParserError *error)
\fn QCborValue QCborValue::fromCbor(const quint8 *data, qsizetype len, QCborParserError *error)
\overload
Converts \a len bytes of \a data to a QByteArray and then calls the
overload of this function that accepts a QByteArray, also passing \a error,
if provided.
*/
/*!
Encodes this QCborValue object to its CBOR representation, using the
options specified in \a opt, and return the byte array containing that
@ -2213,7 +2223,7 @@ QCborValue QCborValue::fromCbor(const QByteArray &ba, QCborParserError *error)
infinities and NaN values.
Similarly, if \l{EncodingOption}{UseFloat16} is specified, this function
will try to use half-precision (\l qfloat16) floating point if the
will try to use half-precision (\c qfloat16) floating point if the
conversion to that results in no loss of precision. This is always true for
infinities and NaN.

View File

@ -1250,7 +1250,7 @@ bool QXmlStreamReaderPrivate::parse()
state_stack[tos] = 0;
return true;
} else if (act > 0) {
if (++tos == stack_size-1)
if (++tos >= stack_size-1)
reallocateStack();
Value &val = sym_stack[tos];

View File

@ -42,8 +42,6 @@
#include "qplatformdefs.h"
#include "qmutex.h"
#include <qdebug.h>
#ifndef QT_NO_THREAD
#include "qatomic.h"
#include "qelapsedtimer.h"
#include "qthread.h"
@ -739,5 +737,3 @@ QT_END_NAMESPACE
#else
# include "qmutex_unix.cpp"
#endif
#endif // QT_NO_THREAD

View File

@ -54,7 +54,7 @@ class tst_QMutex;
QT_BEGIN_NAMESPACE
#if !defined(QT_NO_THREAD) || defined(Q_CLANG_QDOC)
#if QT_CONFIG(thread) || defined(Q_CLANG_QDOC)
#ifdef Q_OS_LINUX
# define QT_MUTEX_LOCK_NOEXCEPT Q_DECL_NOTHROW
@ -250,7 +250,7 @@ private:
quintptr val;
};
#else // QT_NO_THREAD && !Q_CLANG_QDOC
#else // !QT_CONFIG(thread) && !Q_CLANG_QDOC
class Q_CORE_EXPORT QMutex
{
@ -301,7 +301,7 @@ private:
typedef QMutex QBasicMutex;
#endif // QT_NO_THREAD && !Q_CLANG_QDOC
#endif // !QT_CONFIG(thread) && !Q_CLANG_QDOC
QT_END_NAMESPACE

View File

@ -40,8 +40,6 @@
#include "qplatformdefs.h"
#include "qmutex.h"
#ifndef QT_NO_THREAD
#include "qatomic.h"
#include "qmutex_p.h"
#include "qfutex_p.h"
@ -54,7 +52,6 @@
# define FUTEX_PRIVATE_FLAG 0
#endif
QT_BEGIN_NAMESPACE
using namespace QtFutex;
@ -183,5 +180,3 @@ void QBasicMutex::unlockInternal() Q_DECL_NOTHROW
}
QT_END_NAMESPACE
#endif // QT_NO_THREAD

View File

@ -39,9 +39,6 @@
#include "qplatformdefs.h"
#include "qmutex.h"
#if !defined(QT_NO_THREAD)
#include "qmutex_p.h"
#include <mach/mach.h>
@ -89,5 +86,3 @@ void QMutexPrivate::wakeUp() Q_DECL_NOTHROW
QT_END_NAMESPACE
#endif //QT_NO_THREAD

View File

@ -42,8 +42,6 @@
#include "qmutex.h"
#include "qstring.h"
#include "qelapsedtimer.h"
#ifndef QT_NO_THREAD
#include "qatomic.h"
#include "qmutex_p.h"
#include <errno.h>
@ -159,5 +157,3 @@ void QMutexPrivate::wakeUp() Q_DECL_NOTHROW
#endif
QT_END_NAMESPACE
#endif // QT_NO_THREAD

View File

@ -40,8 +40,6 @@
#include "qatomic.h"
#include "qmutexpool_p.h"
#ifndef QT_NO_THREAD
QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive))
@ -148,5 +146,3 @@ QMutex *QMutexPool::globalInstanceGet(const void *address)
}
QT_END_NAMESPACE
#endif // QT_NO_THREAD

View File

@ -56,7 +56,7 @@
#include "QtCore/qmutex.h"
#include "QtCore/qvarlengtharray.h"
#ifndef QT_NO_THREAD
QT_REQUIRE_CONFIG(thread);
QT_BEGIN_NAMESPACE
@ -85,6 +85,4 @@ private:
QT_END_NAMESPACE
#endif // QT_NO_THREAD
#endif // QMUTEXPOOL_P_H

View File

@ -42,7 +42,6 @@
#include "qplatformdefs.h"
#include "qreadwritelock.h"
#ifndef QT_NO_THREAD
#include "qmutex.h"
#include "qthread.h"
#include "qwaitcondition.h"
@ -781,5 +780,3 @@ void QReadWriteLockPrivate::release()
*/
QT_END_NAMESPACE
#endif // QT_NO_THREAD

View File

@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
class QReadWriteLockPrivate;
@ -174,7 +174,7 @@ inline QWriteLocker::QWriteLocker(QReadWriteLock *areadWriteLock)
#pragma warning( pop )
#endif
#else // QT_NO_THREAD
#else // QT_CONFIG(thread)
class Q_CORE_EXPORT QReadWriteLock
{
@ -225,7 +225,7 @@ private:
Q_DISABLE_COPY(QWriteLocker)
};
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
QT_END_NAMESPACE

View File

@ -56,7 +56,7 @@
#include <QtCore/qhash.h>
#include <QtCore/qwaitcondition.h>
#ifndef QT_NO_THREAD
QT_REQUIRE_CONFIG(thread);
QT_BEGIN_NAMESPACE
@ -99,6 +99,4 @@ public:
QT_END_NAMESPACE
#endif // QT_NO_THREAD
#endif // QREADWRITELOCK_P_H

View File

@ -39,8 +39,6 @@
****************************************************************************/
#include "qsemaphore.h"
#ifndef QT_NO_THREAD
#include "qmutex.h"
#include "qfutex_p.h"
#include "qwaitcondition.h"
@ -646,5 +644,3 @@ bool QSemaphore::tryAcquire(int n, int timeout)
QT_END_NAMESPACE
#endif // QT_NO_THREAD

View File

@ -42,11 +42,10 @@
#include <QtCore/qglobal.h>
QT_REQUIRE_CONFIG(thread);
QT_BEGIN_NAMESPACE
#ifndef QT_NO_THREAD
class QSemaphorePrivate;
class Q_CORE_EXPORT QSemaphore
@ -113,8 +112,6 @@ private:
int m_n;
};
#endif // QT_NO_THREAD
QT_END_NAMESPACE
#endif // QSEMAPHORE_H

View File

@ -103,7 +103,7 @@ QThreadData::~QThreadData()
void QThreadData::ref()
{
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
(void) _ref.ref();
Q_ASSERT(_ref.load() != 0);
#endif
@ -111,7 +111,7 @@ void QThreadData::ref()
void QThreadData::deref()
{
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
if (!_ref.deref())
delete this;
#endif
@ -134,7 +134,7 @@ QAdoptedThread::QAdoptedThread(QThreadData *data)
{
// thread should be running and not finished for the lifetime
// of the application (even if QCoreApplication goes away)
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
d_func()->running = true;
d_func()->finished = false;
init();
@ -148,7 +148,7 @@ QAdoptedThread::~QAdoptedThread()
// fprintf(stderr, "~QAdoptedThread = %p\n", this);
}
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
void QAdoptedThread::run()
{
// this function should never be called
@ -756,7 +756,7 @@ int QThread::loopLevel() const
return d->data->eventLoops.size();
}
#else // QT_NO_THREAD
#else // QT_CONFIG(thread)
QThread::QThread(QObject *parent)
: QObject(*(new QThreadPrivate), parent)
@ -765,11 +765,80 @@ QThread::QThread(QObject *parent)
d->data->thread = this;
}
QThread::~QThread()
{
}
void QThread::run()
{
}
int QThread::exec()
{
return 0;
}
void QThread::start(Priority priority)
{
Q_D(QThread);
Q_UNUSED(priority);
d->running = true;
}
void QThread::terminate()
{
}
void QThread::quit()
{
}
bool QThread::wait(unsigned long time)
{
Q_UNUSED(time);
return false;
}
bool QThread::event(QEvent* event)
{
return QObject::event(event);
}
Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW
{
return Qt::HANDLE(currentThread());
}
QThread *QThread::currentThread()
{
return QThreadData::current()->thread;
}
int QThread::idealThreadCount() Q_DECL_NOTHROW
{
return 1;
}
void QThread::yieldCurrentThread()
{
}
bool QThread::isFinished() const
{
return false;
}
bool QThread::isRunning() const
{
Q_D(const QThread);
return d->running;
}
// No threads: so we can just use static variables
static QThreadData *data = 0;
@ -778,7 +847,9 @@ QThreadData *QThreadData::current(bool createIfNecessary)
if (!data && createIfNecessary) {
data = new QThreadData;
data->thread = new QAdoptedThread(data);
data->threadId.store(Qt::HANDLE(data->thread));
data->deref();
data->isAdopted = true;
if (!QCoreApplicationPrivate::theMainThread)
QCoreApplicationPrivate::theMainThread = data->thread.load();
}
@ -811,7 +882,7 @@ QThreadPrivate::~QThreadPrivate()
delete data;
}
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
/*!
\since 5.0
@ -848,7 +919,7 @@ void QThread::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher)
}
}
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
/*!
\reimp
@ -1013,7 +1084,7 @@ QDaemonThread::~QDaemonThread()
{
}
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
QT_END_NAMESPACE

View File

@ -66,7 +66,6 @@ class QThreadData;
class QThreadPrivate;
class QAbstractEventDispatcher;
#ifndef QT_NO_THREAD
class Q_CORE_EXPORT QThread : public QObject
{
Q_OBJECT
@ -239,36 +238,6 @@ QThread *QThread::create(Function &&f)
#endif // QT_CONFIG(cxx11_future)
#else // QT_NO_THREAD
class Q_CORE_EXPORT QThread : public QObject
{
public:
static Qt::HANDLE currentThreadId() { return Qt::HANDLE(currentThread()); }
static QThread* currentThread();
static void sleep(unsigned long);
static void msleep(unsigned long);
static void usleep(unsigned long);
QAbstractEventDispatcher *eventDispatcher() const;
void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
protected:
QThread(QThreadPrivate &dd, QObject *parent = nullptr);
private:
explicit QThread(QObject *parent = nullptr);
static QThread *instance;
friend class QCoreApplication;
friend class QThreadData;
friend class QAdoptedThread;
Q_DECLARE_PRIVATE(QThread)
};
#endif // QT_NO_THREAD
QT_END_NAMESPACE
#endif // QTHREAD_H

View File

@ -57,7 +57,9 @@
#include "QtCore/qthread.h"
#include "QtCore/qmutex.h"
#include "QtCore/qstack.h"
#if QT_CONFIG(thread)
#include "QtCore/qwaitcondition.h"
#endif
#include "QtCore/qmap.h"
#include "QtCore/qcoreapplication.h"
#include "private/qobject_p.h"
@ -141,7 +143,7 @@ private:
using QVector<QPostEvent>::insert;
};
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
class Q_CORE_EXPORT QDaemonThread : public QThread
{
@ -210,7 +212,7 @@ public:
}
};
#else // QT_NO_THREAD
#else // QT_CONFIG(thread)
class QThreadPrivate : public QObjectPrivate
{
@ -220,6 +222,7 @@ public:
mutable QMutex mutex;
QThreadData *data;
bool running = false;
static void setCurrentThread(QThread*) {}
static QThread *threadForId(int) { return QThread::currentThread(); }
@ -231,7 +234,7 @@ public:
Q_DECLARE_PUBLIC(QThread)
};
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
class QThreadData
{
@ -327,7 +330,7 @@ public:
void init();
private:
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
void run() override;
#endif
};

View File

@ -103,7 +103,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
Q_STATIC_ASSERT(sizeof(pthread_t) <= sizeof(Qt::HANDLE));
@ -270,7 +270,7 @@ extern "C" {
typedef void*(*QtThreadCallback)(void*);
}
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data)
{
@ -295,7 +295,7 @@ QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *dat
#endif
}
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
#if (defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_QNX))
static void setCurrentThreadName(const char *name)
@ -513,7 +513,7 @@ void QThread::yieldCurrentThread()
sched_yield();
}
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
static timespec makeTimespec(time_t secs, long nsecs)
{
@ -538,7 +538,7 @@ void QThread::usleep(unsigned long usecs)
qt_nanosleep(makeTimespec(usecs / 1000 / 1000, usecs % (1000*1000) * 1000));
}
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
#ifdef QT_HAS_THREAD_PRIORITY_SCHEDULING
#if defined(Q_OS_QNX)
@ -839,7 +839,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
#endif
}
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
QT_END_NAMESPACE

View File

@ -63,7 +63,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
#ifdef Q_OS_WINRT
inline DWORD qWinRTTlsAlloc() {
@ -330,7 +330,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName)
** QThreadPrivate
*************************************************************************/
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data)
{
@ -342,7 +342,7 @@ QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *dat
#endif
}
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(void *arg) Q_DECL_NOEXCEPT
{
@ -444,7 +444,7 @@ void QThread::yieldCurrentThread()
#endif
}
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
void QThread::sleep(unsigned long secs)
{
@ -461,7 +461,7 @@ void QThread::usleep(unsigned long usecs)
::Sleep((usecs / 1000) + 1);
}
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
void QThread::start(Priority priority)
{
@ -699,6 +699,6 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
}
}
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
QT_END_NAMESPACE

View File

@ -43,8 +43,6 @@
#include <algorithm>
#ifndef QT_NO_THREAD
QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QThreadPool, theInstance)
@ -730,5 +728,3 @@ void QThreadPool::cancel(QRunnable *runnable)
QT_END_NAMESPACE
#include "moc_qthreadpool.cpp"
#endif

View File

@ -45,7 +45,7 @@
#include <QtCore/qthread.h>
#include <QtCore/qrunnable.h>
#ifndef QT_NO_THREAD
QT_REQUIRE_CONFIG(thread);
QT_BEGIN_NAMESPACE
@ -97,6 +97,4 @@ public:
QT_END_NAMESPACE
#endif // QT_NO_THREAD
#endif

View File

@ -59,7 +59,7 @@
#include "QtCore/qqueue.h"
#include "private/qobject_p.h"
#ifndef QT_NO_THREAD
QT_REQUIRE_CONFIG(thread);
QT_BEGIN_NAMESPACE
@ -184,5 +184,4 @@ public:
QT_END_NAMESPACE
#endif // QT_NO_THREAD
#endif

View File

@ -39,7 +39,6 @@
#include "qthreadstorage.h"
#ifndef QT_NO_THREAD
#include "qthread.h"
#include "qthread_p.h"
#include "qmutex.h"
@ -323,6 +322,4 @@ void QThreadStorageData::finish(void **p)
\sa localData(), hasLocalData()
*/
#endif // QT_NO_THREAD
QT_END_NAMESPACE

View File

@ -42,7 +42,7 @@
#include <QtCore/qglobal.h>
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
QT_BEGIN_NAMESPACE
@ -152,6 +152,81 @@ public:
QT_END_NAMESPACE
#endif // QT_NO_THREAD
#else // !QT_CONFIG(thread)
#include <qscopedpointer.h>
#include <type_traits>
template <typename T, typename U>
inline bool qThreadStorage_hasLocalData(const QScopedPointer<T, U> &data)
{
return !!data;
}
template <typename T, typename U>
inline bool qThreadStorage_hasLocalData(const QScopedPointer<T*, U> &data)
{
return !!data ? *data != nullptr : false;
}
template <typename T>
inline void qThreadStorage_deleteLocalData(T *t)
{
delete t;
}
template <typename T>
inline void qThreadStorage_deleteLocalData(T **t)
{
delete *t;
delete t;
}
template <class T>
class QThreadStorage
{
private:
struct ScopedPointerThreadStorageDeleter
{
static inline void cleanup(T *t)
{
if (t == nullptr)
return;
qThreadStorage_deleteLocalData(t);
}
};
QScopedPointer<T, ScopedPointerThreadStorageDeleter> data;
public:
QThreadStorage() = default;
~QThreadStorage() = default;
QThreadStorage(const QThreadStorage &rhs) = delete;
QThreadStorage &operator=(const QThreadStorage &rhs) = delete;
inline bool hasLocalData() const
{
return qThreadStorage_hasLocalData(data);
}
inline T& localData()
{
if (!data)
data.reset(new T());
return *data;
}
inline T localData() const
{
return !!data ? *data : T();
}
inline void setLocalData(T t)
{
data.reset(new T(t));
}
};
#endif // QT_CONFIG(thread)
#endif // QTHREADSTORAGE_H

View File

@ -46,8 +46,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_THREAD
#if QT_CONFIG(thread)
class QDeadlineTimer;
class QWaitConditionPrivate;
@ -98,7 +97,7 @@ public:
void wakeAll() {}
};
#endif // QT_NO_THREAD
#endif // QT_CONFIG(thread)
QT_END_NAMESPACE

View File

@ -56,8 +56,6 @@
#include <sys/time.h>
#include <time.h>
#ifndef QT_NO_THREAD
QT_BEGIN_NAMESPACE
#ifdef Q_OS_ANDROID
@ -264,5 +262,3 @@ bool QWaitCondition::wait(QReadWriteLock *readWriteLock, QDeadlineTimer deadline
}
QT_END_NAMESPACE
#endif // QT_NO_THREAD

View File

@ -45,8 +45,6 @@
#include "qlist.h"
#include "qalgorithms.h"
#ifndef QT_NO_THREAD
#define Q_MUTEX_T void*
#include <private/qmutex_p.h>
#include <private/qreadwritelock_p.h>
@ -247,4 +245,3 @@ void QWaitCondition::wakeAll()
}
QT_END_NAMESPACE
#endif // QT_NO_THREAD

View File

@ -1,38 +1,66 @@
# Qt core thread module
# public headers
HEADERS += thread/qmutex.h \
thread/qrunnable.h \
thread/qreadwritelock.h \
thread/qsemaphore.h \
thread/qthread.h \
thread/qthreadpool.h \
thread/qthreadstorage.h \
thread/qwaitcondition.h \
thread/qatomic.h \
thread/qatomic_bootstrap.h \
thread/qatomic_cxx11.h \
thread/qbasicatomic.h \
thread/qgenericatomic.h
HEADERS += \
thread/qmutex.h \
thread/qreadwritelock.h \
thread/qrunnable.h \
thread/qthread.h \
thread/qthreadstorage.h \
thread/qwaitcondition.h
# private headers
HEADERS += thread/qmutex_p.h \
thread/qmutexpool_p.h \
thread/qfutex_p.h \
thread/qorderedmutexlocker_p.h \
thread/qreadwritelock_p.h \
thread/qthread_p.h \
thread/qthreadpool_p.h
SOURCES += \
thread/qrunnable.cpp \
thread/qthread.cpp
SOURCES += thread/qatomic.cpp \
thread/qmutex.cpp \
thread/qreadwritelock.cpp \
thread/qrunnable.cpp \
thread/qmutexpool.cpp \
thread/qsemaphore.cpp \
thread/qthread.cpp \
thread/qthreadpool.cpp \
thread/qthreadstorage.cpp
win32 {
HEADERS += thread/qatomic_msvc.h
SOURCES += thread/qthread_win.cpp
} else {
SOURCES += thread/qthread_unix.cpp
}
qtConfig(thread) {
HEADERS += \
thread/qatomic.h \
thread/qatomic_bootstrap.h \
thread/qatomic_cxx11.h \
thread/qbasicatomic.h \
thread/qfutex_p.h \
thread/qgenericatomic.h \
thread/qmutexpool_p.h \
thread/qmutex_p.h \
thread/qorderedmutexlocker_p.h \
thread/qreadwritelock_p.h \
thread/qsemaphore.h \
thread/qthreadpool.h \
thread/qthreadpool_p.h \
thread/qthread_p.h
SOURCES += \
thread/qatomic.cpp \
thread/qmutex.cpp \
thread/qmutexpool.cpp \
thread/qreadwritelock.cpp \
thread/qsemaphore.cpp \
thread/qthreadpool.cpp \
thread/qthreadstorage.cpp
win32 {
SOURCES += \
thread/qmutex_win.cpp \
thread/qwaitcondition_win.cpp
} else {
darwin {
SOURCES += thread/qmutex_mac.cpp
} else: linux {
SOURCES += thread/qmutex_linux.cpp
} else {
SOURCES += thread/qmutex_unix.cpp
}
SOURCES += thread/qwaitcondition_unix.cpp
}
}
qtConfig(future) {
HEADERS += \
@ -52,24 +80,4 @@ qtConfig(future) {
thread/qresultstore.cpp
}
win32 {
HEADERS += thread/qatomic_msvc.h
SOURCES += \
thread/qmutex_win.cpp \
thread/qthread_win.cpp \
thread/qwaitcondition_win.cpp
} else {
darwin {
SOURCES += thread/qmutex_mac.cpp
} else: linux {
SOURCES += thread/qmutex_linux.cpp
} else {
SOURCES += thread/qmutex_unix.cpp
}
SOURCES += \
thread/qthread_unix.cpp \
thread/qwaitcondition_unix.cpp
}
qtConfig(std-atomic64): QMAKE_USE += libatomic

View File

@ -651,6 +651,7 @@ Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW
// So it's an acceptable compromise.
#if defined(__AVX__) || defined(__SSE4_2__) || defined(__POPCNT__)
#define QALGORITHMS_USE_BUILTIN_POPCOUNT
#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW
{
return __popcnt(v);
@ -663,13 +664,15 @@ Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW
{
return __popcnt16(v);
}
#if Q_PROCESSOR_WORDSIZE == 8
#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW
{
#if Q_PROCESSOR_WORDSIZE == 8
return __popcnt64(v);
}
#else
return __popcnt(quint32(v)) + __popcnt(quint32(v >> 32));
#endif // MSVC 64bit
}
#endif // __AVX__ || __SSE4_2__ || __POPCNT__
#endif // MSVC

View File

@ -2339,7 +2339,7 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT
// localtime_r() does not have this requirement, so make an explicit call.
// The explicit call should also request the timezone info be re-parsed.
qt_tzset();
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
// Use the reentrant version of localtime() where available
// as is thread-safe and doesn't use a shared static data area
tm *res = 0;

View File

@ -83,7 +83,6 @@ public:
};
Q_GLOBAL_STATIC(QSystemLocaleSingleton, QSystemLocale_globalSystemLocale)
static QLocaleData *system_data = 0;
static QLocaleData globalLocaleData;
#endif
@ -629,8 +628,7 @@ QSystemLocale::QSystemLocale()
{
_systemLocale = this;
if (system_data)
system_data->m_language_id = 0;
globalLocaleData.m_language_id = 0;
}
/*!
@ -647,8 +645,7 @@ QSystemLocale::~QSystemLocale()
if (_systemLocale == this) {
_systemLocale = 0;
if (system_data)
system_data->m_language_id = 0;
globalLocaleData.m_language_id = 0;
}
}
@ -663,47 +660,45 @@ void QLocalePrivate::updateSystemPrivate()
{
// this function is NOT thread-safe!
const QSystemLocale *sys_locale = systemLocale();
if (!system_data)
system_data = &globalLocaleData;
// tell the object that the system locale has changed.
sys_locale->query(QSystemLocale::LocaleChanged, QVariant());
*system_data = *sys_locale->fallbackUiLocale().d->m_data;
globalLocaleData = *sys_locale->fallbackUiLocale().d->m_data;
QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant());
if (!res.isNull()) {
system_data->m_language_id = res.toInt();
system_data->m_script_id = QLocale::AnyScript; // default for compatibility
globalLocaleData.m_language_id = res.toInt();
globalLocaleData.m_script_id = QLocale::AnyScript; // default for compatibility
}
res = sys_locale->query(QSystemLocale::CountryId, QVariant());
if (!res.isNull()) {
system_data->m_country_id = res.toInt();
system_data->m_script_id = QLocale::AnyScript; // default for compatibility
globalLocaleData.m_country_id = res.toInt();
globalLocaleData.m_script_id = QLocale::AnyScript; // default for compatibility
}
res = sys_locale->query(QSystemLocale::ScriptId, QVariant());
if (!res.isNull())
system_data->m_script_id = res.toInt();
globalLocaleData.m_script_id = res.toInt();
res = sys_locale->query(QSystemLocale::DecimalPoint, QVariant());
if (!res.isNull())
system_data->m_decimal = res.toString().at(0).unicode();
globalLocaleData.m_decimal = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::GroupSeparator, QVariant());
if (!res.isNull())
system_data->m_group = res.toString().at(0).unicode();
globalLocaleData.m_group = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::ZeroDigit, QVariant());
if (!res.isNull())
system_data->m_zero = res.toString().at(0).unicode();
globalLocaleData.m_zero = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::NegativeSign, QVariant());
if (!res.isNull())
system_data->m_minus = res.toString().at(0).unicode();
globalLocaleData.m_minus = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::PositiveSign, QVariant());
if (!res.isNull())
system_data->m_plus = res.toString().at(0).unicode();
globalLocaleData.m_plus = res.toString().at(0).unicode();
}
#endif // !QT_NO_SYSTEMLOCALE
@ -719,12 +714,12 @@ static const QLocaleData *systemData()
{
static QBasicMutex systemDataMutex;
systemDataMutex.lock();
if (!system_data || system_data->m_language_id == 0)
if (globalLocaleData.m_language_id == 0)
QLocalePrivate::updateSystemPrivate();
systemDataMutex.unlock();
}
return system_data;
return &globalLocaleData;
#else
return locale_data;
#endif

View File

@ -437,19 +437,19 @@ public:
Osage = 358,
Tangut = 359,
Norwegian = NorwegianBokmal,
Afan = Oromo,
Bhutani = Dzongkha,
Byelorussian = Belarusian,
Cambodian = Khmer,
Chewa = Nyanja,
Frisian = WesternFrisian,
Kurundi = Rundi,
Moldavian = Romanian,
Norwegian = NorwegianBokmal,
RhaetoRomance = Romansh,
SerboCroatian = Serbian,
Tagalog = Filipino,
Twi = Akan,
Afan = Oromo,
Byelorussian = Belarusian,
Bhutani = Dzongkha,
Cambodian = Khmer,
Kurundi = Rundi,
RhaetoRomance = Romansh,
Chewa = Nyanja,
Frisian = WesternFrisian,
Uigur = Uighur,
LastLanguage = Tangut
@ -868,15 +868,15 @@ public:
World = 260,
Europe = 261,
Tokelau = TokelauCountry,
Tuvalu = TuvaluCountry,
DemocraticRepublicOfCongo = CongoKinshasa,
PeoplesRepublicOfCongo = CongoBrazzaville,
DemocraticRepublicOfKorea = NorthKorea,
LatinAmericaAndTheCaribbean = LatinAmerica,
PeoplesRepublicOfCongo = CongoBrazzaville,
RepublicOfKorea = SouthKorea,
RussianFederation = Russia,
SyrianArabRepublic = Syria,
LatinAmericaAndTheCaribbean = LatinAmerica,
Tokelau = TokelauCountry,
Tuvalu = TuvaluCountry,
LastCountry = Europe
};

View File

@ -568,6 +568,7 @@
\value Estonia
\value Ethiopia
\value EuropeanUnion Since Qt 5.7
\value Europe Since Qt 5.12
\value FalklandIslands
\value FaroeIslands
\value Fiji
@ -619,6 +620,8 @@
\value Kuwait
\value Kyrgyzstan
\value Laos
\value LatinAmerica
\value LatinAmericaAndTheCaribbean Obsolete, please use LatinAmerica
\value Latvia
\value Lebanon
\value Lesotho
@ -742,6 +745,7 @@
\value UnitedStatesVirginIslands
\value WallisAndFutunaIslands
\value WesternSahara
\value World Since Qt 5.12
\value Yemen
\value Zambia
\value Zimbabwe
@ -749,7 +753,6 @@
\value Serbia
\value SaintBarthelemy
\value SaintMartin
\value LatinAmericaAndTheCaribbean
\value AscensionIsland
\value AlandIslands
\value DiegoGarcia

File diff suppressed because it is too large Load Diff

View File

@ -483,6 +483,11 @@ QT_BEGIN_NAMESPACE
Note the usage of the non-capturing group in order to preserve the meaning
of the branch operator inside the pattern.
The QRegularExpression::anchoredPattern() helper method does exactly that for
you.
\sa anchoredPattern
\section3 Porting from QRegExp's Partial Matching
When using QRegExp::exactMatch(), if an exact match was not found, one
@ -516,10 +521,10 @@ QT_BEGIN_NAMESPACE
\section2 Wildcard matching
There is no equivalent of wildcard matching in QRegularExpression.
Nevertheless, rewriting a regular expression in wildcard syntax to a
Perl-compatible regular expression is a very easy task, given the fact
that wildcard syntax supported by QRegExp is very simple.
There is no direct way to do wildcard matching in QRegularExpression.
However, the wildcardToRegularExpression method is provided to translate
glob patterns into a Perl-compatible regular expression that can be used
for that purpose.
\section2 Other pattern syntaxes
@ -784,82 +789,6 @@ QT_BEGIN_NAMESPACE
Qt 5.4.
*/
namespace QtPrivate {
/*!
internal
*/
QString wildcardToRegularExpression(const QString &wildcardString)
{
const int wclen = wildcardString.length();
QString rx;
int i = 0;
bool hasNegativeBracket = false;
const QChar *wc = wildcardString.unicode();
while (i < wclen) {
const QChar c = wc[i++];
switch (c.unicode()) {
case '*':
rx += QLatin1String(".*");
break;
case '?':
rx += QLatin1Char('.');
break;
case '$':
case '(':
case ')':
case '+':
case '.':
case '^':
case '{':
case '|':
case '}':
rx += QLatin1Char('\\');
rx += c;
break;
case '[':
// Support for the [!abc] or [!a-c] syntax
// Implements a negative look-behind for one char.
if (wc[i] == QLatin1Char(']')) {
rx += c;
rx += wc[i++];
} else if (wc[i] == QLatin1Char('!')) {
rx += QLatin1String(".(?<");
rx += wc[i++];
rx += c;
hasNegativeBracket = true;
} else {
rx += c;
}
if (i < wclen) {
if (rx[i] == QLatin1Char(']'))
rx += wc[i++];
while (i < wclen && wc[i] != QLatin1Char(']')) {
if (wc[i] == QLatin1Char('\\'))
rx += QLatin1Char('\\');
rx += wc[i++];
}
}
break;
case ']':
rx += c;
// Closes the negative look-behind expression.
if (hasNegativeBracket) {
rx += QLatin1Char(')');
hasNegativeBracket = false;
}
break;
default:
rx += c;
break;
}
}
return rx;
}
}
/*!
\internal
*/
@ -1582,47 +1511,6 @@ void QRegularExpression::setPattern(const QString &pattern)
d->pattern = pattern;
}
/*!
\since 5.12
Sets the pattern string of the regular expression to \a wildcard pattern.
The pattern options are left unchanged.
\warning Unlike QRegExp, this implementation follows closely the definition
of wildcard for glob patterns:
\table
\row \li \b{c}
\li Any character represents itself apart from those mentioned
below. Thus \b{c} matches the character \e c.
\row \li \b{?}
\li Matches any single character. It is the same as
\b{.} in full regexps.
\row \li \b{*}
\li Matches zero or more of any characters. It is the
same as \b{.*} in full regexps.
\row \li \b{[abc]}
\li Matches one character given in the bracket.
\row \li \b{[a-c]}
\li Matches one character from the range given in the bracket.
\row \li \b{[!abc]}
\li Matches one character that is not given in the bracket.
\row \li \b{[!a-c]}
\li matches one character that is not from the range given in the
bracket.
\endtable
\note This function generates a regular expression that will act following
the wildcard pattern given. However the content of the regular expression
will not be the same as the one set.
\sa pattern(), setPattern()
*/
void QRegularExpression::setWildcardPattern(const QString &pattern)
{
setPattern(QtPrivate::wildcardToRegularExpression(pattern));
}
/*!
Returns the pattern options for the regular expression.
@ -1987,6 +1875,141 @@ QString QRegularExpression::escape(const QString &str)
return result;
}
/*!
\since 5.12
Returns a regular expression representation of the given glob \a pattern.
The transformation is targeting file path globbing, which means in particular
that path separators receive special treatment. This implies that it is not
just a basic translation from "*" to ".*".
\snippet code/src_corelib_tools_qregularexpression.cpp 31
\warning Unlike QRegExp, this implementation follows closely the definition
of wildcard for glob patterns:
\table
\row \li \b{c}
\li Any character represents itself apart from those mentioned
below. Thus \b{c} matches the character \e c.
\row \li \b{?}
\li Matches any single character. It is the same as
\b{.} in full regexps.
\row \li \b{*}
\li Matches zero or more of any characters. It is the
same as \b{.*} in full regexps.
\row \li \b{[abc]}
\li Matches one character given in the bracket.
\row \li \b{[a-c]}
\li Matches one character from the range given in the bracket.
\row \li \b{[!abc]}
\li Matches one character that is not given in the bracket. It is the
same as \b{[^abc]} in full regexp.
\row \li \b{[!a-c]}
\li Matches one character that is not from the range given in the
bracket. It is the same as \b{[^a-c]} in full regexp.
\endtable
\note The backslash (\\) character is \e not an escape char in this context.
In order to match one of the special characters, place it in square brackets
(for example, "[?]").
More information about the implementation can be found in:
\list
\li \l {https://en.wikipedia.org/wiki/Glob_(programming)} {The Wikipedia Glob article}
\li \c man 7 glob
\endlist
\sa escape()
*/
QString QRegularExpression::wildcardToRegularExpression(const QString &pattern)
{
const int wclen = pattern.length();
QString rx;
rx.reserve(wclen + wclen / 16);
int i = 0;
const QChar *wc = pattern.unicode();
#ifdef Q_OS_WIN
const QLatin1Char nativePathSeparator('\\');
const QLatin1String starEscape("[^/\\\\]*");
const QLatin1String questionMarkEscape("[^/\\\\]");
#else
const QLatin1Char nativePathSeparator('/');
const QLatin1String starEscape("[^/]*");
const QLatin1String questionMarkEscape("[^/]");
#endif
while (i < wclen) {
const QChar c = wc[i++];
switch (c.unicode()) {
case '*':
rx += starEscape;
break;
case '?':
rx += questionMarkEscape;
break;
case '\\':
#ifdef Q_OS_WIN
case '/':
rx += QLatin1String("[/\\\\]");
break;
#endif
case '$':
case '(':
case ')':
case '+':
case '.':
case '^':
case '{':
case '|':
case '}':
rx += QLatin1Char('\\');
rx += c;
break;
case '[':
rx += c;
// Support for the [!abc] or [!a-c] syntax
if (i < wclen) {
if (wc[i] == QLatin1Char('!')) {
rx += QLatin1Char('^');
++i;
}
if (i < wclen && wc[i] == QLatin1Char(']'))
rx += wc[i++];
while (i < wclen && wc[i] != QLatin1Char(']')) {
// The '/' appearing in a character class invalidates the
// regular expression parsing. It also concerns '\\' on
// Windows OS types.
if (wc[i] == QLatin1Char('/') || wc[i] == nativePathSeparator)
return rx;
if (wc[i] == QLatin1Char('\\'))
rx += QLatin1Char('\\');
rx += wc[i++];
}
}
break;
default:
rx += c;
break;
}
}
return rx;
}
/*!
\fn QRegularExpression::anchoredPattern(const QString &expression)
\since 5.12
Returns the expression wrapped between the \c{\A} and \c{\z} anchors to be
used for exact matching.
\sa {Porting from QRegExp's Exact Matching}
*/
/*!
\since 5.1

View File

@ -96,7 +96,6 @@ public:
QString pattern() const;
void setPattern(const QString &pattern);
void setWildcardPattern(const QString &pattern);
bool isValid() const;
int patternErrorOffset() const;
@ -142,6 +141,13 @@ public:
void optimize() const;
static QString escape(const QString &str);
static QString wildcardToRegularExpression(const QString &str);
static inline QString anchoredPattern(const QString &expression)
{
return QLatin1String("\\A(?:")
+ expression
+ QLatin1String(")\\z");
}
bool operator==(const QRegularExpression &re) const;
inline bool operator!=(const QRegularExpression &re) const { return !operator==(re); }

View File

@ -1,70 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2018 Samuel Gaist <samuel.gaist@edeltech.ch>
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QREGULAREXPRESSION_P_H
#define QREGULAREXPRESSION_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <private/qglobal_p.h>
#include <qregularexpression.h>
#include <qstring.h>
QT_REQUIRE_CONFIG(regularexpression);
QT_BEGIN_NAMESPACE
namespace QtPrivate {
QString wildcardToRegularExpression(const QString &expression);
}
QT_END_NAMESPACE
#endif

View File

@ -692,7 +692,7 @@ int QtPrivate::QStringList_indexOf(const QStringList *that, const QRegularExpres
if (from < 0)
from = qMax(from + that->size(), 0);
QString exactPattern = QLatin1String("\\A(?:") + re.pattern() + QLatin1String(")\\z");
QString exactPattern = QRegularExpression::anchoredPattern(re.pattern());
QRegularExpression exactRe(exactPattern, re.patternOptions());
for (int i = from; i < that->size(); ++i) {
@ -722,7 +722,7 @@ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegularEx
else if (from >= that->size())
from = that->size() - 1;
QString exactPattern = QLatin1String("\\A(?:") + re.pattern() + QLatin1String(")\\z");
QString exactPattern = QRegularExpression::anchoredPattern(re.pattern());
QRegularExpression exactRe(exactPattern, re.patternOptions());
for (int i = from; i >= 0; --i) {

View File

@ -260,6 +260,8 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
const qint64 sixteenHoursInMSecs(16 * 3600 * 1000);
Q_STATIC_ASSERT(-sixteenHoursInMSecs / 1000 < QTimeZone::MinUtcOffsetSecs
&& sixteenHoursInMSecs / 1000 > QTimeZone::MaxUtcOffsetSecs);
const qint64 recent = forLocalMSecs - sixteenHoursInMSecs;
const qint64 imminent = forLocalMSecs + sixteenHoursInMSecs;
/*
Offsets are Local - UTC, positive to the east of Greenwich, negative to
the west; DST offset always exceeds standard offset, when DST applies.
@ -327,7 +329,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
// Get a transition definitely before the local MSecs; usually all we need.
// Only around the transition times might we need another.
Data tran = previousTransition(forLocalMSecs - sixteenHoursInMSecs);
Data tran = previousTransition(recent);
Q_ASSERT(forLocalMSecs < 0 || // Pre-epoch TZ info may be unavailable
forLocalMSecs - tran.offsetFromUtc * 1000 >= tran.atMSecsSinceEpoch);
Data nextTran = nextTransition(tran.atMSecsSinceEpoch);
@ -343,8 +345,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
&& forLocalMSecs > nextTran.atMSecsSinceEpoch + nextTran.offsetFromUtc * 1000) {
Data newTran = nextTransition(nextTran.atMSecsSinceEpoch);
if (newTran.atMSecsSinceEpoch == invalidMSecs()
|| newTran.atMSecsSinceEpoch + newTran.offsetFromUtc * 1000
> forLocalMSecs + sixteenHoursInMSecs) {
|| newTran.atMSecsSinceEpoch + newTran.offsetFromUtc * 1000 > imminent) {
// Definitely not a relevant tansition: too far in the future.
break;
}
@ -357,10 +358,10 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
/*
So now tran is definitely before and nextTran is either after or only
slightly before. The one with the larger offset is in DST; the other in
standard time. Our hint tells us which of those to use (defaulting to
standard if no hint): try it first; if that fails, try the other; if both
fail life's tricky.
slightly before. One is standard time; we interpret the other as DST
(although the transition might in fact by a change in standard offset). Our
hint tells us which of those to use (defaulting to standard if no hint): try
it first; if that fails, try the other; if both fail, life's tricky.
*/
Q_ASSERT(forLocalMSecs < 0
|| forLocalMSecs - tran.offsetFromUtc * 1000 > tran.atMSecsSinceEpoch);
@ -369,7 +370,9 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
nextTran.atMSecsSinceEpoch = forLocalMSecs - nextTran.offsetFromUtc * 1000;
tran.atMSecsSinceEpoch = forLocalMSecs - tran.offsetFromUtc * 1000;
const bool nextIsDst = tran.offsetFromUtc < nextTran.offsetFromUtc;
// If both or neither have zero DST, treat the one with lower offset as standard:
const bool nextIsDst = !nextTran.daylightTimeOffset == !tran.daylightTimeOffset
? tran.offsetFromUtc < nextTran.offsetFromUtc : nextTran.daylightTimeOffset;
// If that agrees with hint > 0, our first guess is to use nextTran; else tran.
const bool nextFirst = nextIsDst == (hint > 0) && nextStart != invalidMSecs();
for (int i = 0; i < 2; i++) {
@ -399,7 +402,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
0 < tran.atMSecsSinceEpoch - nextTran.atMSecsSinceEpoch
= (nextTran.offsetFromUtc - tran.offsetFromUtc) * 1000
*/
int dstStep = nextTran.offsetFromUtc - tran.offsetFromUtc;
int dstStep = (nextTran.offsetFromUtc - tran.offsetFromUtc) * 1000;
Q_ASSERT(dstStep > 0); // How else could we get here ?
if (nextFirst) { // hint thought we needed nextTran, so use tran
tran.atMSecsSinceEpoch -= dstStep;
@ -415,8 +418,8 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
/* Bracket and refine to discover offset. */
qint64 utcEpochMSecs;
int early = offsetFromUtc(forLocalMSecs - sixteenHoursInMSecs);
int late = offsetFromUtc(forLocalMSecs + sixteenHoursInMSecs);
int early = offsetFromUtc(recent);
int late = offsetFromUtc(imminent);
if (Q_LIKELY(early == late)) { // > 99% of the time
utcEpochMSecs = forLocalMSecs - early * 1000;
} else {
@ -437,9 +440,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
utcEpochMSecs = forStd;
} else {
// Invalid forLocalMSecs: in spring-forward gap.
const int dstStep = daylightTimeOffset(early < late ?
forLocalMSecs + sixteenHoursInMSecs :
forLocalMSecs - sixteenHoursInMSecs);
const int dstStep = daylightTimeOffset(early < late ? imminent : recent);
Q_ASSERT(dstStep); // There can't be a transition without it !
utcEpochMSecs = (hint > 0) ? forStd - dstStep : forDst + dstStep;
}

View File

@ -227,7 +227,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::nextTransition(qint64 afterMSecsSinc
QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const
{
// The native API only lets us search forward, so we need to find an early-enough start:
const NSTimeInterval lowerBound = std::numeric_limits<NSTimeInterval>::min();
const NSTimeInterval lowerBound = std::numeric_limits<NSTimeInterval>::lowest();
const qint64 endSecs = beforeMSecsSinceEpoch / 1000;
const int year = 366 * 24 * 3600; // a (long) year, in seconds
NSTimeInterval prevSecs = endSecs; // sentinel for later check

View File

@ -878,14 +878,17 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
}
// Otherwise is strange sequence, so work backwards through trans looking for first match, if any
for (int i = m_tranTimes.size() - 1; i >= 0; --i) {
if (m_tranTimes.at(i).atMSecsSinceEpoch <= currentMSecs) {
tran = dataForTzTransition(m_tranTimes.at(i));
if ((timeType == QTimeZone::DaylightTime && tran.daylightTimeOffset != 0)
|| (timeType == QTimeZone::StandardTime && tran.daylightTimeOffset == 0)) {
return tran.abbreviation;
}
}
auto it = std::partition_point(m_tranTimes.cbegin(), m_tranTimes.cend(),
[currentMSecs](const QTzTransitionTime &at) {
return at.atMSecsSinceEpoch <= currentMSecs;
});
while (it != m_tranTimes.cbegin()) {
--it;
tran = dataForTzTransition(*it);
int offset = tran.daylightTimeOffset;
if ((timeType == QTimeZone::DaylightTime) != (offset == 0))
return tran.abbreviation;
}
// Otherwise if no match use current data
@ -900,7 +903,7 @@ QString QTzTimeZonePrivate::abbreviation(qint64 atMSecsSinceEpoch) const
int QTzTimeZonePrivate::offsetFromUtc(qint64 atMSecsSinceEpoch) const
{
const QTimeZonePrivate::Data tran = data(atMSecsSinceEpoch);
return tran.standardTimeOffset + tran.daylightTimeOffset;
return tran.offsetFromUtc; // == tran.standardTimeOffset + tran.daylightTimeOffset
}
int QTzTimeZonePrivate::standardTimeOffset(qint64 atMSecsSinceEpoch) const
@ -942,40 +945,38 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::dataForTzTransition(QTzTransitionTime
QTimeZonePrivate::Data QTzTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const
{
// If we have no rules (so probably an invalid tz), return invalid data:
if (!m_tranTimes.size())
return invalidData();
// If the required time is after the last transition and we have a POSIX rule then use it
if (m_tranTimes.size() > 0 && m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch
if (m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch
&& !m_posixRule.isEmpty() && forMSecsSinceEpoch >= 0) {
const int year = QDateTime::fromMSecsSinceEpoch(forMSecsSinceEpoch, Qt::UTC).date().year();
QVector<QTimeZonePrivate::Data> posixTrans =
calculatePosixTransitions(m_posixRule, year - 1, year + 1,
m_tranTimes.last().atMSecsSinceEpoch);
for (int i = posixTrans.size() - 1; i >= 0; --i) {
if (posixTrans.at(i).atMSecsSinceEpoch <= forMSecsSinceEpoch) {
QTimeZonePrivate::Data data = posixTrans.at(i);
data.atMSecsSinceEpoch = forMSecsSinceEpoch;
return data;
}
}
}
// Otherwise if we can find a valid tran then use its rule
for (int i = m_tranTimes.size() - 1; i >= 0; --i) {
if (m_tranTimes.at(i).atMSecsSinceEpoch <= forMSecsSinceEpoch) {
Data data = dataForTzTransition(m_tranTimes.at(i));
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;
data.atMSecsSinceEpoch = forMSecsSinceEpoch;
return data;
}
}
// Otherwise use the earliest transition we have
if (m_tranTimes.size() > 0) {
Data data = dataForTzTransition(m_tranTimes.at(0));
data.atMSecsSinceEpoch = forMSecsSinceEpoch;
return data;
}
// Otherwise we have no rules, so probably an invalid tz, so return invalid data
return invalidData();
// Otherwise, if we can find a valid tran, then use its rule:
auto last = std::partition_point(m_tranTimes.cbegin(), m_tranTimes.cend(),
[forMSecsSinceEpoch] (const QTzTransitionTime &at) {
return at.atMSecsSinceEpoch <= forMSecsSinceEpoch;
});
if (last > m_tranTimes.cbegin())
--last;
Data data = dataForTzTransition(*last);
data.atMSecsSinceEpoch = forMSecsSinceEpoch;
return data;
}
bool QTzTimeZonePrivate::hasTransitions() const
@ -992,21 +993,20 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSince
QVector<QTimeZonePrivate::Data> posixTrans =
calculatePosixTransitions(m_posixRule, year - 1, year + 1,
m_tranTimes.last().atMSecsSinceEpoch);
for (int i = 0; i < posixTrans.size(); ++i) {
if (posixTrans.at(i).atMSecsSinceEpoch > afterMSecsSinceEpoch)
return posixTrans.at(i);
}
auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(),
[afterMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) {
return at.atMSecsSinceEpoch <= afterMSecsSinceEpoch;
});
return it == posixTrans.cend() ? invalidData() : *it;
}
// Otherwise if we can find a valid tran then use its rule
for (int i = 0; i < m_tranTimes.size(); ++i) {
if (m_tranTimes.at(i).atMSecsSinceEpoch > afterMSecsSinceEpoch) {
return dataForTzTransition(m_tranTimes.at(i));
}
}
// Otherwise we have no rule, or there is no next transition, so return invalid data
return invalidData();
// Otherwise, if we can find a valid tran, use its rule:
auto last = std::partition_point(m_tranTimes.cbegin(), m_tranTimes.cend(),
[afterMSecsSinceEpoch] (const QTzTransitionTime &at) {
return at.atMSecsSinceEpoch <= afterMSecsSinceEpoch;
});
return last != m_tranTimes.cend() ? dataForTzTransition(*last) : invalidData();
}
QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const
@ -1018,21 +1018,20 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecs
QVector<QTimeZonePrivate::Data> posixTrans =
calculatePosixTransitions(m_posixRule, year - 1, year + 1,
m_tranTimes.last().atMSecsSinceEpoch);
for (int i = posixTrans.size() - 1; i >= 0; --i) {
if (posixTrans.at(i).atMSecsSinceEpoch < beforeMSecsSinceEpoch)
return posixTrans.at(i);
}
auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(),
[beforeMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) {
return at.atMSecsSinceEpoch < beforeMSecsSinceEpoch;
});
Q_ASSERT(it > posixTrans.cbegin());
return *--it;
}
// Otherwise if we can find a valid tran then use its rule
for (int i = m_tranTimes.size() - 1; i >= 0; --i) {
if (m_tranTimes.at(i).atMSecsSinceEpoch < beforeMSecsSinceEpoch) {
return dataForTzTransition(m_tranTimes.at(i));
}
}
// Otherwise we have no rule, so return invalid data
return invalidData();
auto last = std::partition_point(m_tranTimes.cbegin(), m_tranTimes.cend(),
[beforeMSecsSinceEpoch] (const QTzTransitionTime &at) {
return at.atMSecsSinceEpoch < beforeMSecsSinceEpoch;
});
return last > m_tranTimes.cbegin() ? dataForTzTransition(*--last) : invalidData();
}
// TODO Could cache the value and monitor the required files for any changes

View File

@ -183,8 +183,7 @@ qtConfig(regularexpression) {
QMAKE_USE_PRIVATE += pcre2
HEADERS += \
tools/qregularexpression.h \
tools/qregularexpression_p.h
tools/qregularexpression.h
SOURCES += tools/qregularexpression.cpp
}

View File

@ -79,10 +79,8 @@ bool qdbus_loadLibDBus()
#endif
static bool triedToLoadLibrary = false;
#ifndef QT_NO_THREAD
static QBasicMutex mutex;
QMutexLocker locker(&mutex);
#endif
QLibrary *&lib = qdbus_libdbus;
if (triedToLoadLibrary)

View File

@ -979,7 +979,7 @@
},
"evdev": {
"label": "evdev",
"condition": "tests.evdev",
"condition": "features.thread && tests.evdev",
"output": [ "privateFeature" ]
},
"freetype": {
@ -1170,7 +1170,7 @@
},
"egl_x11": {
"label": "EGL on X11",
"condition": "features.egl && tests.egl-x11",
"condition": "features.thread && features.egl && tests.egl-x11",
"output": [ "privateFeature" ]
},
"eglfs": {
@ -1300,7 +1300,7 @@
"section": "Platform plugins",
"autoDetect": "!config.darwin",
"enable": "input.xcb == 'system' || input.xcb == 'qt' || input.xcb == 'yes'",
"condition": "libs.xcb",
"condition": "features.thread && libs.xcb",
"output": [ "privateFeature" ]
},
"system-xcb": {

Some files were not shown because too many files have changed in this diff Show More