summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in6
-rw-r--r--src/corelib/corelib.pro3
-rw-r--r--src/corelib/doc/qtcore.qdocconf2
-rw-r--r--src/corelib/global/qfeatures.txt8
-rw-r--r--src/corelib/global/qglobal.cpp8
-rw-r--r--src/corelib/global/qglobal.h4
-rw-r--r--src/corelib/io/qdir.cpp4
-rw-r--r--src/corelib/io/qdir_p.h8
-rw-r--r--src/corelib/io/qfiledevice.cpp6
-rw-r--r--src/corelib/io/qfiledevice_p.h13
-rw-r--r--src/corelib/io/qprocess_win.cpp70
-rw-r--r--src/corelib/io/qsettings_mac.cpp3
-rw-r--r--src/corelib/io/qtemporarydir.cpp39
-rw-r--r--src/corelib/io/qtextstream_p.h63
-rw-r--r--src/corelib/json/qjsonobject.cpp2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp66
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h4
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder.cpp52
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder_p.h5
-rw-r--r--src/corelib/kernel/qmetatype.h6
-rw-r--r--src/corelib/kernel/qobject.cpp10
-rw-r--r--src/corelib/kernel/qsystemsemaphore.cpp3
-rw-r--r--src/corelib/kernel/qsystemsemaphore_p.h5
-rw-r--r--src/corelib/kernel/qsystemsemaphore_unix.cpp1
-rw-r--r--src/corelib/kernel/qsystemsemaphore_win.cpp1
-rw-r--r--src/corelib/plugin/qplugin.qdoc2
-rw-r--r--src/corelib/thread/qthread_win.cpp2
-rw-r--r--src/corelib/tools/qcommandlineoption.cpp17
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp53
-rw-r--r--src/corelib/tools/qeasingcurve.cpp8
-rw-r--r--src/corelib/tools/qlocale_blackberry.cpp40
-rw-r--r--src/corelib/tools/qlocale_p.h4
-rw-r--r--src/corelib/tools/qregexp.cpp4
-rw-r--r--src/corelib/tools/qregularexpression.cpp7
-rw-r--r--src/corelib/tools/qsimd_p.h6
-rw-r--r--src/corelib/tools/qtimeline.cpp10
-rw-r--r--src/corelib/tools/qtimezoneprivate.cpp14
-rw-r--r--src/corelib/tools/qtimezoneprivate_p.h4
38 files changed, 372 insertions, 191 deletions
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 1e00c74aa6..9bda70ec07 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -81,6 +81,12 @@ list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE)
set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE)
!!ENDIF
+!!IF !isEmpty(CMAKE_DISABLED_FEATURES)
+set(Qt5_DISABLED_FEATURES
+ $$CMAKE_DISABLED_FEATURES
+)
+!!ENDIF
+
set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
!!IF contains(QT_CONFIG, reduce_exports)
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 2e4181efb1..b513149e7c 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -79,6 +79,9 @@ cmake_umbrella_config_version_file.input = $$PWD/../../mkspecs/features/data/cma
cmake_umbrella_config_version_file.output = $$DESTDIR/cmake/Qt5/Qt5ConfigVersion.cmake
load(cmake_functions)
+load(qfeatures)
+
+CMAKE_DISABLED_FEATURES = $$join(QT_DISABLED_FEATURES, "$$escape_expand(\\n) ")
CMAKE_HOST_DATA_DIR = $$cmakeRelativePath($$[QT_HOST_DATA/src], $$[QT_INSTALL_PREFIX])
contains(CMAKE_HOST_DATA_DIR, "^\\.\\./.*"):!isEmpty(CMAKE_HOST_DATA_DIR) {
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index 9ab66c6645..fa5afb033c 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -26,7 +26,7 @@ qhp.QtCore.subprojects.classes.sortPages = true
tagfile = ../../../doc/qtcore/qtcore.tags
-depends += qtgui qtwidgets qtnetwork qtdoc qtquick qtlinguist qtdesigner qtconcurrent qtxml
+depends += qtgui qtwidgets qtnetwork qtdoc qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake
headerdirs += ..
diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt
index 3e9fc88eba..fb6e56ec7d 100644
--- a/src/corelib/global/qfeatures.txt
+++ b/src/corelib/global/qfeatures.txt
@@ -476,6 +476,12 @@ Section: Widgets
Requires: GRAPHICSVIEW PRINTER MAINWINDOW
Name: QPrintPreviewWidget
+Feature: KEYSEQUENCEEDIT
+Description: Provides a widget for editing QKeySequences
+Section: Widgets
+Requires: LINEEDIT SHORTCUT
+Name: QKeySequenceEdit
+
# Dialogs
Feature: MESSAGEBOX
@@ -742,7 +748,7 @@ Name: QPdf
Feature: PRINTER
Description: Supports printing
Section: Painting
-Requires: PICTURE TEMPORARYFILE
+Requires: PICTURE TEMPORARYFILE PDF
Name: QPrinter
Feature: CUPS
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 279ba20a4f..6644d6d101 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -76,7 +76,7 @@
#include <CoreServices/CoreServices.h>
#endif
-#if defined(Q_OS_ANDROID)
+#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
#include <private/qjni_p.h>
#endif
@@ -2385,7 +2385,7 @@ typedef uint SeedStorageType;
typedef QThreadStorage<SeedStorageType *> SeedStorage;
Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value
-#elif defined(Q_OS_ANDROID)
+#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
typedef QThreadStorage<QJNIObjectPrivate> AndroidRandomStorage;
Q_GLOBAL_STATIC(AndroidRandomStorage, randomTLS)
#endif
@@ -2421,7 +2421,7 @@ void qsrand(uint seed)
//global static object, fallback to srand(seed)
srand(seed);
}
-#elif defined(Q_OS_ANDROID)
+#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
if (randomTLS->hasLocalData()) {
randomTLS->localData().callMethod<void>("setSeed", "(J)V", jlong(seed));
return;
@@ -2477,7 +2477,7 @@ int qrand()
//global static object, fallback to rand()
return rand();
}
-#elif defined(Q_OS_ANDROID)
+#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
AndroidRandomStorage *randomStorage = randomTLS();
if (!randomStorage)
return rand();
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 6d0500f08d..3c3d35e373 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -45,11 +45,11 @@
#include <stddef.h>
-#define QT_VERSION_STR "5.2.0"
+#define QT_VERSION_STR "5.2.1"
/*
QT_VERSION is (major << 16) + (minor << 8) + patch.
*/
-#define QT_VERSION 0x050200
+#define QT_VERSION 0x050201
/*
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
*/
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index db27bed9d6..43db2ec1fe 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -85,10 +85,10 @@ static QString driveSpec(const QString &path)
//************* QDirPrivate
QDirPrivate::QDirPrivate(const QString &path, const QStringList &nameFilters_, QDir::SortFlags sort_, QDir::Filters filters_)
: QSharedData()
+ , fileListsInitialized(false)
, nameFilters(nameFilters_)
, sort(sort_)
, filters(filters_)
- , fileListsInitialized(false)
{
setPath(path.isEmpty() ? QString::fromLatin1(".") : path);
@@ -108,10 +108,10 @@ QDirPrivate::QDirPrivate(const QString &path, const QStringList &nameFilters_, Q
QDirPrivate::QDirPrivate(const QDirPrivate &copy)
: QSharedData(copy)
+ , fileListsInitialized(false)
, nameFilters(copy.nameFilters)
, sort(copy.sort)
, filters(copy.filters)
- , fileListsInitialized(false)
, dirEntry(copy.dirEntry)
, metaData(copy.metaData)
{
diff --git a/src/corelib/io/qdir_p.h b/src/corelib/io/qdir_p.h
index efcac439cd..bf7726db2f 100644
--- a/src/corelib/io/qdir_p.h
+++ b/src/corelib/io/qdir_p.h
@@ -73,16 +73,16 @@ public:
void resolveAbsoluteEntry() const;
+ mutable bool fileListsInitialized;
+ mutable QStringList files;
+ mutable QFileInfoList fileInfos;
+
QStringList nameFilters;
QDir::SortFlags sort;
QDir::Filters filters;
QScopedPointer<QAbstractFileEngine> fileEngine;
- mutable bool fileListsInitialized;
- mutable QStringList files;
- mutable QFileInfoList fileInfos;
-
QFileSystemEntry dirEntry;
mutable QFileSystemEntry absoluteDirEntry;
mutable QFileSystemMetaData metaData;
diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp
index f25933816a..d2c8d37d4a 100644
--- a/src/corelib/io/qfiledevice.cpp
+++ b/src/corelib/io/qfiledevice.cpp
@@ -53,9 +53,9 @@ QT_BEGIN_NAMESPACE
static const int QFILE_WRITEBUFFER_SIZE = 16384;
QFileDevicePrivate::QFileDevicePrivate()
- : fileEngine(0), lastWasWrite(false),
- writeBuffer(QFILE_WRITEBUFFER_SIZE), error(QFile::NoError),
- cachedSize(0)
+ : fileEngine(0),
+ writeBuffer(QFILE_WRITEBUFFER_SIZE), cachedSize(0),
+ error(QFile::NoError), lastWasWrite(false)
{
}
diff --git a/src/corelib/io/qfiledevice_p.h b/src/corelib/io/qfiledevice_p.h
index 4c9cf7b627..79d8427c0d 100644
--- a/src/corelib/io/qfiledevice_p.h
+++ b/src/corelib/io/qfiledevice_p.h
@@ -70,21 +70,22 @@ protected:
virtual QAbstractFileEngine *engine() const;
- QFileDevice::FileHandleFlags handleFlags;
-
- mutable QAbstractFileEngine *fileEngine;
- bool lastWasWrite;
- QRingBuffer writeBuffer;
inline bool ensureFlushed() const;
bool putCharHelper(char c);
- QFileDevice::FileError error;
void setError(QFileDevice::FileError err);
void setError(QFileDevice::FileError err, const QString &errorString);
void setError(QFileDevice::FileError err, int errNum);
+ mutable QAbstractFileEngine *fileEngine;
+ QRingBuffer writeBuffer;
mutable qint64 cachedSize;
+
+ QFileDevice::FileHandleFlags handleFlags;
+ QFileDevice::FileError error;
+
+ bool lastWasWrite;
};
inline bool QFileDevicePrivate::ensureFlushed() const
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index dba9f62b98..fc2adb783e 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -73,10 +73,11 @@ static void qt_create_pipe(Q_PIPE *pipe, bool isInputPipe)
// Anomymous pipes do not support asynchronous I/O. Thus we
// create named pipes for redirecting stdout, stderr and stdin.
+ // The write handle must be non-inheritable for input pipes.
+ // The read handle must be non-inheritable for output pipes.
SECURITY_ATTRIBUTES secAtt = { sizeof(SECURITY_ATTRIBUTES), 0, false };
- secAtt.bInheritHandle = isInputPipe; // The read handle must be non-inheritable for output pipes.
- HANDLE hRead;
+ HANDLE hServer;
wchar_t pipeName[256];
unsigned int attempts = 1000;
forever {
@@ -85,19 +86,29 @@ static void qt_create_pipe(Q_PIPE *pipe, bool isInputPipe)
_snwprintf(pipeName, sizeof(pipeName) / sizeof(pipeName[0]),
L"\\\\.\\pipe\\qt-%X", qrand());
+ DWORD dwOpenMode = FILE_FLAG_OVERLAPPED;
+ DWORD dwOutputBufferSize = 0;
+ DWORD dwInputBufferSize = 0;
+ const DWORD dwPipeBufferSize = 1024 * 1024;
+ if (isInputPipe) {
+ dwOpenMode |= PIPE_ACCESS_OUTBOUND;
+ dwOutputBufferSize = dwPipeBufferSize;
+ } else {
+ dwOpenMode |= PIPE_ACCESS_INBOUND;
+ dwInputBufferSize = dwPipeBufferSize;
+ }
DWORD dwPipeFlags = PIPE_TYPE_BYTE | PIPE_WAIT;
if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
dwPipeFlags |= PIPE_REJECT_REMOTE_CLIENTS;
- const DWORD dwPipeBufferSize = 1024 * 1024;
- hRead = CreateNamedPipe(pipeName,
- PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,
- dwPipeFlags,
- 1, // only one pipe instance
- 0, // output buffer size
- dwPipeBufferSize, // input buffer size
- 0,
- &secAtt);
- if (hRead != INVALID_HANDLE_VALUE)
+ hServer = CreateNamedPipe(pipeName,
+ dwOpenMode,
+ dwPipeFlags,
+ 1, // only one pipe instance
+ dwOutputBufferSize,
+ dwInputBufferSize,
+ 0,
+ &secAtt);
+ if (hServer != INVALID_HANDLE_VALUE)
break;
DWORD dwError = GetLastError();
if (dwError != ERROR_PIPE_BUSY || !--attempts) {
@@ -106,28 +117,31 @@ static void qt_create_pipe(Q_PIPE *pipe, bool isInputPipe)
}
}
- // The write handle must be non-inheritable for input pipes.
- secAtt.bInheritHandle = !isInputPipe;
-
- HANDLE hWrite = INVALID_HANDLE_VALUE;
- hWrite = CreateFile(pipeName,
- GENERIC_WRITE,
- 0,
- &secAtt,
- OPEN_EXISTING,
- FILE_FLAG_OVERLAPPED,
- NULL);
- if (hWrite == INVALID_HANDLE_VALUE) {
+ secAtt.bInheritHandle = TRUE;
+ const HANDLE hClient = CreateFile(pipeName,
+ (isInputPipe ? (GENERIC_READ | FILE_WRITE_ATTRIBUTES)
+ : GENERIC_WRITE),
+ 0,
+ &secAtt,
+ OPEN_EXISTING,
+ FILE_FLAG_OVERLAPPED,
+ NULL);
+ if (hClient == INVALID_HANDLE_VALUE) {
qErrnoWarning("QProcess: CreateFile failed.");
- CloseHandle(hRead);
+ CloseHandle(hServer);
return;
}
// Wait until connection is in place.
- ConnectNamedPipe(hRead, NULL);
+ ConnectNamedPipe(hServer, NULL);
- pipe[0] = hRead;
- pipe[1] = hWrite;
+ if (isInputPipe) {
+ pipe[0] = hClient;
+ pipe[1] = hServer;
+ } else {
+ pipe[0] = hServer;
+ pipe[1] = hClient;
+ }
}
static void duplicateStdWriteChannel(Q_PIPE *pipe, DWORD nStdHandle)
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index f6b14c3027..23cff6af27 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -691,7 +691,8 @@ bool QConfFileSettingsPrivate::writePlistFile(const QString &fileName,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
- QCFType<CFDataRef> xmlData = CFPropertyListCreateXMLData(kCFAllocatorDefault, propertyList);
+ QCFType<CFDataRef> xmlData = CFPropertyListCreateData(
+ kCFAllocatorDefault, propertyList, kCFPropertyListXMLFormat_v1_0, 0, 0);
SInt32 code;
return CFURLWriteDataAndPropertiesToResource(urlFromFileName(fileName), xmlData, 0, &code);
diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp
index 483a76fa82..2c526847b4 100644
--- a/src/corelib/io/qtemporarydir.cpp
+++ b/src/corelib/io/qtemporarydir.cpp
@@ -94,9 +94,19 @@ static QString defaultTemplateName()
return QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String("-XXXXXX");
}
+#if defined(Q_OS_QNX ) || defined(Q_OS_WIN) || defined(Q_OS_ANDROID)
+
+static int nextRand(int &v)
+{
+ int r = v % 62;
+ v /= 62;
+ if (v < 62)
+ v = qrand();
+ return r;
+}
+
static char *q_mkdtemp(char *templateName)
{
-#if defined(Q_OS_QNX ) || defined(Q_OS_WIN) || defined(Q_OS_ANDROID)
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const size_t length = strlen(templateName);
@@ -110,16 +120,11 @@ static char *q_mkdtemp(char *templateName)
int v = qrand();
/* Fill in the random bits. */
- XXXXXX[0] = letters[v % 62];
- v /= 62;
- XXXXXX[1] = letters[v % 62];
- v /= 62;
- XXXXXX[2] = letters[v % 62];
- v /= 62;
- XXXXXX[3] = letters[v % 62];
- v /= 62;
- XXXXXX[4] = letters[v % 62];
- v /= 62;
+ XXXXXX[0] = letters[nextRand(v)];
+ XXXXXX[1] = letters[nextRand(v)];
+ XXXXXX[2] = letters[nextRand(v)];
+ XXXXXX[3] = letters[nextRand(v)];
+ XXXXXX[4] = letters[nextRand(v)];
XXXXXX[5] = letters[v % 62];
QString templateNameStr = QFile::decodeName(templateName);
@@ -137,11 +142,17 @@ static char *q_mkdtemp(char *templateName)
}
}
return 0;
-#else
- return mkdtemp(templateName);
-#endif
}
+#else // defined(Q_OS_QNX ) || defined(Q_OS_WIN) || defined(Q_OS_ANDROID)
+
+static char *q_mkdtemp(char *templateName)
+{
+ return mkdtemp(templateName);
+}
+
+#endif
+
void QTemporaryDirPrivate::create(const QString &templateName)
{
QByteArray buffer = QFile::encodeName(templateName);
diff --git a/src/corelib/io/qtextstream_p.h b/src/corelib/io/qtextstream_p.h
index d5d5288426..ac6529e195 100644
--- a/src/corelib/io/qtextstream_p.h
+++ b/src/corelib/io/qtextstream_p.h
@@ -88,6 +88,21 @@ class QTextStreamPrivate
{
Q_DECLARE_PUBLIC(QTextStream)
public:
+ // streaming parameters
+ class Params
+ {
+ public:
+ void reset();
+
+ int realNumberPrecision;
+ int integerBase;
+ int fieldWidth;
+ QChar padChar;
+ QTextStream::FieldAlignment fieldAlignment;
+ QTextStream::RealNumberNotation realNumberNotation;
+ QTextStream::NumberFlags numberFlags;
+ };
+
QTextStreamPrivate(QTextStream *q_ptr);
~QTextStreamPrivate();
void reset();
@@ -97,7 +112,6 @@ public:
#ifndef QT_NO_QOBJECT
QDeviceClosedNotifier deviceClosedNotifier;
#endif
- bool deleteDevice;
// string
QString *string;
@@ -110,6 +124,24 @@ public:
QTextCodec::ConverterState readConverterState;
QTextCodec::ConverterState writeConverterState;
QTextCodec::ConverterState *readConverterSavedState;
+#endif
+
+ QString writeBuffer;
+ QString readBuffer;
+ int readBufferOffset;
+ int readConverterSavedStateOffset; //the offset between readBufferStartDevicePos and that start of the buffer
+ qint64 readBufferStartDevicePos;
+
+ Params params;
+
+ // status
+ QTextStream::Status status;
+ QLocale locale;
+ QTextStream *q_ptr;
+
+ int lastTokenSize;
+ bool deleteDevice;
+#ifndef QT_NO_TEXTCODEC
bool autoDetectUnicode;
#endif
@@ -128,7 +160,6 @@ public:
inline void consume(int nchars);
void saveConverterState(qint64 newPos);
void restoreToSavedConverterState();
- int lastTokenSize;
// Return value type for getNumber()
enum NumberParsingStatus {
@@ -150,34 +181,6 @@ public:
bool fillReadBuffer(qint64 maxBytes = -1);
void resetReadBuffer();
void flushWriteBuffer();
- QString writeBuffer;
- QString readBuffer;
- int readBufferOffset;
- int readConverterSavedStateOffset; //the offset between readBufferStartDevicePos and that start of the buffer
- qint64 readBufferStartDevicePos;
-
- // streaming parameters
- class Params
- {
- public:
- void reset();
-
- int realNumberPrecision;
- int integerBase;
- int fieldWidth;
- QChar padChar;
- QTextStream::FieldAlignment fieldAlignment;
- QTextStream::RealNumberNotation realNumberNotation;
- QTextStream::NumberFlags numberFlags;
- };
- Params params;
-
- // status
- QTextStream::Status status;
-
- QLocale locale;
-
- QTextStream *q_ptr;
};
QT_END_NAMESPACE
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index afc0d5f71f..27e51cf4ac 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -783,6 +783,8 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
/*!
\class QJsonObject::const_iterator
\inmodule QtCore
+ \ingroup json
+ \since 5.0
\brief The QJsonObject::const_iterator class provides an STL-style const iterator for QJsonObject.
QJsonObject::const_iterator allows you to iterate over a QJsonObject.
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 43c64b7b2c..e77d6894d0 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -160,6 +160,8 @@ QString QCoreApplicationPrivate::appName() const
}
#endif
+QString *QCoreApplicationPrivate::cachedApplicationFilePath = 0;
+
bool QCoreApplicationPrivate::checkInstance(const char *function)
{
bool b = (QCoreApplication::self != 0);
@@ -425,6 +427,7 @@ QCoreApplicationPrivate::~QCoreApplicationPrivate()
#ifdef Q_OS_WIN
delete [] origArgv;
#endif
+ QCoreApplicationPrivate::clearApplicationFilePath();
}
#ifndef QT_NO_QOBJECT
@@ -1884,6 +1887,20 @@ QString QCoreApplication::translate(const char *context, const char *sourceText,
#endif //QT_NO_TRANSLATE
+// Makes it possible to point QCoreApplication to a custom location to ensure
+// the directory is added to the patch, and qt.conf and deployed plugins are
+// found from there. This is for use cases in which QGuiApplication is
+// instantiated by a library and not by an application executable, for example,
+// Active X servers.
+
+void QCoreApplicationPrivate::setApplicationFilePath(const QString &path)
+{
+ if (QCoreApplicationPrivate::cachedApplicationFilePath)
+ *QCoreApplicationPrivate::cachedApplicationFilePath = path;
+ else
+ QCoreApplicationPrivate::cachedApplicationFilePath = new QString(path);
+}
+
/*!
Returns the directory that contains the application executable.
@@ -1939,20 +1956,28 @@ QString QCoreApplication::applicationFilePath()
}
QCoreApplicationPrivate *d = self->d_func();
- if (!d->cachedApplicationFilePath.isNull())
- return d->cachedApplicationFilePath;
+
+ static char *procName = d->argv[0];
+ if (qstrcmp(procName, d->argv[0]) != 0) {
+ // clear the cache if the procname changes, so we reprocess it.
+ QCoreApplicationPrivate::clearApplicationFilePath();
+ procName = d->argv[0];
+ }
+
+ if (QCoreApplicationPrivate::cachedApplicationFilePath)
+ return *QCoreApplicationPrivate::cachedApplicationFilePath;
#if defined(Q_OS_WIN)
- d->cachedApplicationFilePath = QFileInfo(qAppFileName()).filePath();
- return d->cachedApplicationFilePath;
+ QCoreApplicationPrivate::setApplicationFilePath(QFileInfo(qAppFileName()).filePath());
+ return *QCoreApplicationPrivate::cachedApplicationFilePath;
#elif defined(Q_OS_BLACKBERRY)
if (!arguments().isEmpty()) { // args is never empty, but the navigator can change behaviour some day
QFileInfo fileInfo(arguments().at(0));
const bool zygotized = fileInfo.exists();
if (zygotized) {
// Handle the zygotized case:
- d->cachedApplicationFilePath = QDir::cleanPath(fileInfo.absoluteFilePath());
- return d->cachedApplicationFilePath;
+ QCoreApplicationPrivate::setApplicationFilePath(QDir::cleanPath(fileInfo.absoluteFilePath()));
+ return *QCoreApplicationPrivate::cachedApplicationFilePath;
}
}
@@ -1960,7 +1985,7 @@ QString QCoreApplication::applicationFilePath()
const size_t maximum_path = static_cast<size_t>(pathconf("/",_PC_PATH_MAX));
char buff[maximum_path+1];
if (_cmdname(buff)) {
- d->cachedApplicationFilePath = QDir::cleanPath(QString::fromLocal8Bit(buff));
+ QCoreApplicationPrivate::setApplicationFilePath(QDir::cleanPath(QString::fromLocal8Bit(buff)));
} else {
qWarning("QCoreApplication::applicationFilePath: _cmdname() failed");
// _cmdname() won't fail, but just in case, fallback to the old method
@@ -1968,18 +1993,19 @@ QString QCoreApplication::applicationFilePath()
QStringList executables = dir.entryList(QDir::Executable | QDir::Files);
if (!executables.empty()) {
//We assume that there is only one executable in the folder
- d->cachedApplicationFilePath = dir.absoluteFilePath(executables.first());
- } else {
- d->cachedApplicationFilePath = QString();
+ QCoreApplicationPrivate::setApplicationFilePath(dir.absoluteFilePath(executables.first()));
}
}
- return d->cachedApplicationFilePath;
+ return *QCoreApplicationPrivate::cachedApplicationFilePath;
#elif defined(Q_OS_MAC)
QString qAppFileName_str = qAppFileName();
if(!qAppFileName_str.isEmpty()) {
QFileInfo fi(qAppFileName_str);
- d->cachedApplicationFilePath = fi.exists() ? fi.canonicalFilePath() : QString();
- return d->cachedApplicationFilePath;
+ if (fi.exists()) {
+ QCoreApplicationPrivate::setApplicationFilePath(fi.canonicalFilePath());
+ return *QCoreApplicationPrivate::cachedApplicationFilePath;
+ }
+ return QString();
}
#endif
#if defined( Q_OS_UNIX )
@@ -1988,8 +2014,8 @@ QString QCoreApplication::applicationFilePath()
// the absolute path of the executable
QFileInfo pfi(QString::fromLatin1("/proc/%1/exe").arg(getpid()));
if (pfi.exists() && pfi.isSymLink()) {
- d->cachedApplicationFilePath = pfi.canonicalFilePath();
- return d->cachedApplicationFilePath;
+ QCoreApplicationPrivate::setApplicationFilePath(pfi.canonicalFilePath());
+ return *QCoreApplicationPrivate::cachedApplicationFilePath;
}
# endif
if (!arguments().isEmpty()) {
@@ -2019,13 +2045,15 @@ QString QCoreApplication::applicationFilePath()
absPath = QDir::cleanPath(absPath);
QFileInfo fi(absPath);
- d->cachedApplicationFilePath = fi.exists() ? fi.canonicalFilePath() : QString();
- } else {
- d->cachedApplicationFilePath = QString();
+ if (fi.exists()) {
+ QCoreApplicationPrivate::setApplicationFilePath(fi.canonicalFilePath());
+ return *QCoreApplicationPrivate::cachedApplicationFilePath;
+ }
}
- return d->cachedApplicationFilePath;
+ return QString();
#endif
+ Q_UNREACHABLE();
}
/*!
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index ad0449f02c..0c00f396b5 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -139,7 +139,9 @@ public:
QCoreApplicationPrivate::Type application_type;
QString cachedApplicationDirPath;
- QString cachedApplicationFilePath;
+ static QString *cachedApplicationFilePath;
+ static void setApplicationFilePath(const QString &path);
+ static inline void clearApplicationFilePath() { delete cachedApplicationFilePath; cachedApplicationFilePath = 0; }
#ifndef QT_NO_QOBJECT
bool in_exec;
diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp
index 4518d702cd..11ab39af1a 100644
--- a/src/corelib/kernel/qmetaobjectbuilder.cpp
+++ b/src/corelib/kernel/qmetaobjectbuilder.cpp
@@ -1075,8 +1075,14 @@ int QMetaObjectBuilder::indexOfClassInfo(const QByteArray& name)
\brief The QMetaStringTable class can generate a meta-object string table at runtime.
*/
-QMetaStringTable::QMetaStringTable()
- : m_index(0) {}
+QMetaStringTable::QMetaStringTable(const QByteArray &className)
+ : m_index(0)
+ , m_className(className)
+{
+ const int index = enter(m_className);
+ Q_ASSERT(index == 0);
+ Q_UNUSED(index);
+}
// Enters the given value into the string table (if it hasn't already been
// entered). Returns the index of the string.
@@ -1106,30 +1112,45 @@ int QMetaStringTable::blobSize() const
return size;
}
+static void writeString(char *out, int i, const QByteArray &str,
+ const int offsetOfStringdataMember, int &stringdataOffset)
+{
+ int size = str.size();
+ qptrdiff offset = offsetOfStringdataMember + stringdataOffset
+ - i * sizeof(QByteArrayData);
+ const QByteArrayData data =
+ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset);
+
+ memcpy(out + i * sizeof(QByteArrayData), &data, sizeof(QByteArrayData));
+
+ memcpy(out + offsetOfStringdataMember + stringdataOffset, str.constData(), size);
+ out[offsetOfStringdataMember + stringdataOffset + size] = '\0';
+
+ stringdataOffset += size + 1;
+}
+
// Writes strings to string data struct.
// The struct consists of an array of QByteArrayData, followed by a char array
// containing the actual strings. This format must match the one produced by
// moc (see generator.cpp).
-void QMetaStringTable::writeBlob(char *out)
+void QMetaStringTable::writeBlob(char *out) const
{
Q_ASSERT(!(reinterpret_cast<quintptr>(out) & (preferredAlignment()-1)));
int offsetOfStringdataMember = m_entries.size() * sizeof(QByteArrayData);
int stringdataOffset = 0;
- for (int i = 0; i < m_entries.size(); ++i) {
- const QByteArray &str = m_entries.key(i);
- int size = str.size();
- qptrdiff offset = offsetOfStringdataMember + stringdataOffset
- - i * sizeof(QByteArrayData);
- const QByteArrayData data =
- Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset);
- memcpy(out + i * sizeof(QByteArrayData), &data, sizeof(QByteArrayData));
+ // qt_metacast expects the first string in the string table to be the class name.
+ writeString(out, /*index*/0, m_className, offsetOfStringdataMember, stringdataOffset);
- memcpy(out + offsetOfStringdataMember + stringdataOffset, str.constData(), size);
- out[offsetOfStringdataMember + stringdataOffset + size] = '\0';
+ for (Entries::ConstIterator it = m_entries.constBegin(), end = m_entries.constEnd();
+ it != end; ++it) {
+ const int i = it.value();
+ if (i == 0)
+ continue;
+ const QByteArray &str = it.key();
- stringdataOffset += size + 1;
+ writeString(out, i, str, offsetOfStringdataMember, stringdataOffset);
}
}
@@ -1270,8 +1291,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
// Reset the current data position to just past the QMetaObjectPrivate.
dataIndex = MetaObjectPrivateFieldCount;
- QMetaStringTable strings;
- strings.enter(d->className);
+ QMetaStringTable strings(d->className);
// Output the class infos,
Q_ASSERT(!buf || dataIndex == pmeta->classInfoData);
diff --git a/src/corelib/kernel/qmetaobjectbuilder_p.h b/src/corelib/kernel/qmetaobjectbuilder_p.h
index f79ce2f2f1..3a1b43c3ed 100644
--- a/src/corelib/kernel/qmetaobjectbuilder_p.h
+++ b/src/corelib/kernel/qmetaobjectbuilder_p.h
@@ -323,18 +323,19 @@ private:
class Q_CORE_EXPORT QMetaStringTable
{
public:
- QMetaStringTable();
+ explicit QMetaStringTable(const QByteArray &className);
int enter(const QByteArray &value);
static int preferredAlignment();
int blobSize() const;
- void writeBlob(char *out);
+ void writeBlob(char *out) const;
private:
typedef QHash<QByteArray, int> Entries; // string --> index mapping
Entries m_entries;
int m_index;
+ QByteArray m_className;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::AddMembers)
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 4ccfc7b7f0..a2e6960949 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -1741,7 +1741,7 @@ struct QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \
return id; \
const char *tName = QMetaType::typeName(qMetaTypeId<T>()); \
Q_ASSERT(tName); \
- const int tNameLen = qstrlen(tName); \
+ const int tNameLen = int(qstrlen(tName)); \
QByteArray typeName; \
typeName.reserve(int(sizeof(#SINGLE_ARG_TEMPLATE)) + 1 + tNameLen + 1 + 1); \
typeName.append(#SINGLE_ARG_TEMPLATE, int(sizeof(#SINGLE_ARG_TEMPLATE)) - 1) \
@@ -1782,8 +1782,8 @@ struct QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \
const char *uName = QMetaType::typeName(qMetaTypeId<U>()); \
Q_ASSERT(tName); \
Q_ASSERT(uName); \
- const int tNameLen = qstrlen(tName); \
- const int uNameLen = qstrlen(uName); \
+ const int tNameLen = int(qstrlen(tName)); \
+ const int uNameLen = int(qstrlen(uName)); \
QByteArray typeName; \
typeName.reserve(int(sizeof(#DOUBLE_ARG_TEMPLATE)) + 1 + tNameLen + 1 + uNameLen + 1 + 1); \
typeName.append(#DOUBLE_ARG_TEMPLATE, int(sizeof(#DOUBLE_ARG_TEMPLATE)) - 1) \
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 7e06e2c261..f1351f5a07 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -194,9 +194,15 @@ QMetaObject *QObjectData::dynamicMetaObject() const
QObjectPrivate::QObjectPrivate(int version)
: threadData(0), connectionLists(0), senders(0), currentSender(0), currentChildBeingDeleted(0)
{
+#ifdef QT_BUILD_INTERNAL
+ // Don't check the version parameter in internal builds.
+ // This allows incompatible versions to be loaded, possibly for testing.
+ Q_UNUSED(version);
+#else
if (version != QObjectPrivateVersion)
qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)",
version, QObjectPrivateVersion);
+#endif
// QObjectData initialization
q_ptr = 0;
@@ -4173,7 +4179,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
\macro Q_INVOKABLE
\relates QObject
- Apply this macro to definitions of member functions to allow them to
+ Apply this macro to declarations of member functions to allow them to
be invoked via the meta-object system. The macro is written before
the return type, as shown in the following example:
@@ -4190,7 +4196,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
\macro Q_REVISION
\relates QObject
- Apply this macro to definitions of member functions to tag them with a
+ Apply this macro to declarations of member functions to tag them with a
revision number in the meta-object system. The macro is written before
the return type, as shown in the following example:
diff --git a/src/corelib/kernel/qsystemsemaphore.cpp b/src/corelib/kernel/qsystemsemaphore.cpp
index 6f0e5ee011..82e14e6f3f 100644
--- a/src/corelib/kernel/qsystemsemaphore.cpp
+++ b/src/corelib/kernel/qsystemsemaphore.cpp
@@ -229,8 +229,7 @@ void QSystemSemaphore::setKey(const QString &key, int initialValue, AccessMode m
{
if (key == d->key && mode == Open)
return;
- d->error = NoError;
- d->errorString = QString();
+ d->clearError();
#if !defined(Q_OS_WIN)
// optimization to not destroy/create the file & semaphore
if (key == d->key && mode == Create && d->createdSemaphore && d->createdFile) {
diff --git a/src/corelib/kernel/qsystemsemaphore_p.h b/src/corelib/kernel/qsystemsemaphore_p.h
index c809ba58c1..b34ec1b9a7 100644
--- a/src/corelib/kernel/qsystemsemaphore_p.h
+++ b/src/corelib/kernel/qsystemsemaphore_p.h
@@ -75,6 +75,11 @@ public:
return QSharedMemoryPrivate::makePlatformSafeKey(key, QLatin1String("qipc_systemsem_"));
}
+ inline void setError(QSystemSemaphore::SystemSemaphoreError e, const QString &message)
+ { error = e; errorString = message; }
+ inline void clearError()
+ { setError(QSystemSemaphore::NoError, QString()); }
+
#ifdef Q_OS_WIN
Qt::HANDLE handle(QSystemSemaphore::AccessMode mode = QSystemSemaphore::Open);
void setErrorString(const QString &function);
diff --git a/src/corelib/kernel/qsystemsemaphore_unix.cpp b/src/corelib/kernel/qsystemsemaphore_unix.cpp
index 073bd020ba..8f439c94a0 100644
--- a/src/corelib/kernel/qsystemsemaphore_unix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_unix.cpp
@@ -229,6 +229,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
return false;
}
+ clearError();
return true;
}
diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp
index 55df20b24e..edf90a31ac 100644
--- a/src/corelib/kernel/qsystemsemaphore_win.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_win.cpp
@@ -136,6 +136,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
}
}
+ clearError();
return true;
}
diff --git a/src/corelib/plugin/qplugin.qdoc b/src/corelib/plugin/qplugin.qdoc
index eacfe995ae..0a94077d95 100644
--- a/src/corelib/plugin/qplugin.qdoc
+++ b/src/corelib/plugin/qplugin.qdoc
@@ -109,6 +109,6 @@
the required plugins to your build. For example:
\snippet code/doc_src_qplugin.pro 3
+ \sa {Static Plugins}, {How to Create Qt Plugins}, {qmake-getting-started}{Getting Started with qmake}
- \sa {Static Plugins}, {How to Create Qt Plugins}, {Using qmake}
*/
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index d49a6a9a8e..9d90583a28 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -182,7 +182,7 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)
qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup);
}
- CreateThread(0, 0, qt_adopted_thread_watcher_function, 0, 0, &qt_adopted_thread_watcher_id);
+ CloseHandle(CreateThread(0, 0, qt_adopted_thread_watcher_function, 0, 0, &qt_adopted_thread_watcher_id));
} else {
SetEvent(qt_adopted_thread_wakeup);
}
diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp
index 9827547c56..86f087674b 100644
--- a/src/corelib/tools/qcommandlineoption.cpp
+++ b/src/corelib/tools/qcommandlineoption.cpp
@@ -199,7 +199,8 @@ QStringList QCommandLineOption::names() const
void QCommandLineOptionPrivate::setNames(const QStringList &nameList)
{
- names.clear();
+ QStringList newNames;
+ newNames.reserve(nameList.size());
if (nameList.isEmpty())
qWarning("QCommandLineOption: Options must have at least one name");
foreach (const QString &name, nameList) {
@@ -214,9 +215,11 @@ void QCommandLineOptionPrivate::setNames(const QStringList &nameList)
else if (name.contains(QLatin1Char('=')))
qWarning("QCommandLineOption: Option names cannot contain a '='");
else
- names.append(name);
+ newNames.append(name);
}
}
+ // commit
+ names.swap(newNames);
}
/*!
@@ -288,9 +291,13 @@ QString QCommandLineOption::description() const
*/
void QCommandLineOption::setDefaultValue(const QString &defaultValue)
{
- d->defaultValues.clear();
- if (!defaultValue.isEmpty())
- d->defaultValues << defaultValue;
+ QStringList newDefaultValues;
+ if (!defaultValue.isEmpty()) {
+ newDefaultValues.reserve(1);
+ newDefaultValues << defaultValue;
+ }
+ // commit:
+ d->defaultValues.swap(newDefaultValues);
}
/*!
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index 8054542333..db4c2961f0 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -280,9 +280,9 @@ bool QCommandLineParser::addOption(const QCommandLineOption &option)
*/
QCommandLineOption QCommandLineParser::addVersionOption()
{
- d->builtinVersionOption = true;
QCommandLineOption opt(QStringList() << QStringLiteral("v") << QStringLiteral("version"), tr("Displays version information."));
addOption(opt);
+ d->builtinVersionOption = true;
return opt;
}
@@ -300,7 +300,6 @@ QCommandLineOption QCommandLineParser::addVersionOption()
*/
QCommandLineOption QCommandLineParser::addHelpOption()
{
- d->builtinHelpOption = true;
QCommandLineOption opt(QStringList()
#ifdef Q_OS_WIN
<< QStringLiteral("?")
@@ -308,6 +307,7 @@ QCommandLineOption QCommandLineParser::addHelpOption()
<< QStringLiteral("h")
<< QStringLiteral("help"), tr("Displays this help."));
addOption(opt);
+ d->builtinHelpOption = true;
return opt;
}
@@ -845,11 +845,50 @@ static QString wrapText(const QString &names, int longestOptionNameString, const
{
const QLatin1Char nl('\n');
QString text = QStringLiteral(" ") + names.leftJustified(longestOptionNameString) + QLatin1Char(' ');
- const int leftColumnWidth = text.length();
- const int rightColumnWidth = 79 - leftColumnWidth;
- text += description.left(rightColumnWidth) + nl;
- for (int n = rightColumnWidth; n < description.length(); n += rightColumnWidth)
- text += QStringLiteral(" ").repeated(leftColumnWidth) + description.mid(n, rightColumnWidth) + nl;
+ const int indent = text.length();
+ int lineStart = 0;
+ int lastBreakable = -1;
+ const int max = 79 - indent;
+ int x = 0;
+ const int len = description.length();
+
+ for (int i = 0; i < len; ++i) {
+ ++x;
+ const QChar c = description.at(i);
+ if (c.isSpace())
+ lastBreakable = i;
+
+ int breakAt = -1;
+ int nextLineStart = -1;
+ if (x > max && lastBreakable != -1) {
+ // time to break and we know where
+ breakAt = lastBreakable;
+ nextLineStart = lastBreakable + 1;
+ } else if ((x > max - 1 && lastBreakable == -1) || i == len - 1) {
+ // time to break but found nowhere [-> break here], or end of last line
+ breakAt = i + 1;
+ nextLineStart = breakAt;
+ } else if (c == nl) {
+ // forced break
+ breakAt = i;
+ nextLineStart = i + 1;
+ }
+
+ if (breakAt != -1) {
+ const int numChars = breakAt - lineStart;
+ //qDebug() << "breakAt=" << description.at(breakAt) << "breakAtSpace=" << breakAtSpace << lineStart << "to" << breakAt << description.mid(lineStart, numChars);
+ if (lineStart > 0)
+ text += QString(indent, QLatin1Char(' '));
+ text += description.midRef(lineStart, numChars) + nl;
+ x = 0;
+ lastBreakable = -1;
+ lineStart = nextLineStart;
+ if (lineStart < len && description.at(lineStart).isSpace())
+ ++lineStart; // don't start a line with a space
+ i = lineStart;
+ }
+ }
+
return text;
}
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 5daf067c71..2708901866 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -432,14 +432,14 @@ struct BezierEase : public QEasingCurveFunction
qreal p3x, p3y;
};
- bool _init;
- bool _valid;
QVector<SingleCubicBezier> _curves;
- int _curveCount;
QVector<qreal> _intervals;
+ int _curveCount;
+ bool _init;
+ bool _valid;
BezierEase()
- : QEasingCurveFunction(InOut), _init(false), _valid(false), _curves(10), _intervals(10)
+ : QEasingCurveFunction(InOut), _curves(10), _intervals(10), _init(false), _valid(false)
{ }
void init()
diff --git a/src/corelib/tools/qlocale_blackberry.cpp b/src/corelib/tools/qlocale_blackberry.cpp
index e2dfa6c801..c2c3476b0a 100644
--- a/src/corelib/tools/qlocale_blackberry.cpp
+++ b/src/corelib/tools/qlocale_blackberry.cpp
@@ -60,7 +60,7 @@ static const char ppsRegionLocalePath[] = "/pps/services/locale/settings";
static const char ppsLanguageLocalePath[] = "/pps/services/confstr/_CS_LOCALE";
static const char ppsHourFormatPath[] = "/pps/system/settings";
-static const size_t ppsBufferSize = 256;
+static const int MAX_PPS_SIZE = 16000;
QBBSystemLocaleData::QBBSystemLocaleData()
: languageNotifier(0)
@@ -68,17 +68,20 @@ QBBSystemLocaleData::QBBSystemLocaleData()
, measurementNotifier(0)
, hourNotifier(0)
{
+ // Do not use qWarning to log warnings if qt_safe_open fails to open the pps file
+ // since the user code may install a message handler that invokes QLocale API again
+ // (i.e QDate, QDateTime, ...) which will cause a deadlock.
if ((measurementFd = qt_safe_open(ppsUomPath, O_RDONLY)) == -1)
- qWarning("Failed to open uom pps, errno=%d", errno);
+ fprintf(stderr, "Failed to open uom pps, errno=%d\n", errno);
if ((regionFd = qt_safe_open(ppsRegionLocalePath, O_RDONLY)) == -1)
- qWarning("Failed to open region pps, errno=%d", errno);
+ fprintf(stderr, "Failed to open region pps, errno=%d\n", errno);
if ((languageFd = qt_safe_open(ppsLanguageLocalePath, O_RDONLY)) == -1)
- qWarning("Failed to open language pps, errno=%d", errno);
+ fprintf(stderr, "Failed to open language pps, errno=%d\n", errno);
if ((hourFd = qt_safe_open(ppsHourFormatPath, O_RDONLY)) == -1)
- qWarning("Failed to open hour format pps, errno=%d", errno);
+ fprintf(stderr, "Failed to open hour format pps, errno=%d\n", errno);
// we cannot call this directly, because by the time this constructor is
// called, the event dispatcher has not yet been created, causing the
@@ -183,11 +186,30 @@ QByteArray QBBSystemLocaleData::readPpsValue(const char *ppsObject, int ppsFd)
if (!ppsObject || ppsFd == -1)
return result;
- char buffer[ppsBufferSize];
+ // PPS objects are of unknown size, but must be read all at once.
+ // Relying on the file size may not be a good idea since the size may change before reading.
+ // Let's try with an initial size (512), and if the buffer is too small try with bigger one,
+ // until we succeed or until other non buffer-size-related error occurs.
+ // Using QVarLengthArray means the first try (of size == 512) uses a buffer on the stack - no allocation necessary.
+ // Hopefully that covers most use cases.
+ int bytes;
+ QVarLengthArray<char, 512> buffer;
+ for (;;) {
+ errno = 0;
+ bytes = qt_safe_read(ppsFd, buffer.data(), buffer.capacity() - 1);
+ const bool bufferIsTooSmall = (bytes == -1 && errno == EMSGSIZE && buffer.capacity() < MAX_PPS_SIZE);
+ if (!bufferIsTooSmall)
+ break;
+
+ buffer.resize(qMin(buffer.capacity()*2, MAX_PPS_SIZE));
+ }
- int bytes = qt_safe_read(ppsFd, buffer, ppsBufferSize - 1);
+ // This method is called in the ctor(), so do not use qWarning to log warnings
+ // if qt_safe_read fails to read the pps file
+ // since the user code may install a message handler that invokes QLocale API again
+ // (i.e QDate, QDateTime, ...) which will cause a deadlock.
if (bytes == -1) {
- qWarning("Failed to read Locale pps, errno=%d", errno);
+ fprintf(stderr, "Failed to read pps object:%s, errno=%d\n", ppsObject, errno);
return result;
}
// ensure data is null terminated
@@ -195,7 +217,7 @@ QByteArray QBBSystemLocaleData::readPpsValue(const char *ppsObject, int ppsFd)
pps_decoder_t ppsDecoder;
pps_decoder_initialize(&ppsDecoder, 0);
- if (pps_decoder_parse_pps_str(&ppsDecoder, buffer) == PPS_DECODER_OK) {
+ if (pps_decoder_parse_pps_str(&ppsDecoder, buffer.data()) == PPS_DECODER_OK) {
pps_decoder_push(&ppsDecoder, 0);
const char *ppsBuff;
if (pps_decoder_get_string(&ppsDecoder, ppsObject, &ppsBuff) == PPS_DECODER_OK) {
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index 4b4606ffab..581a12e0c7 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -360,10 +360,10 @@ inline char QLocalePrivate::digitToCLocale(QChar in) const
if (in.unicode() >= '0' && in.unicode() <= '9')
return in.toLatin1();
- if (in == plus())
+ if (in == plus() || in == QLatin1Char('+'))
return '+';
- if (in == minus())
+ if (in == minus() || in == QLatin1Char('-') || in == QChar(0x2212))
return '-';
if (in == decimal())
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 88499ad9d9..d2b5adc974 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -1045,12 +1045,12 @@ public:
#endif
private:
- uint c; // character classes
QVector<QRegExpCharClassRange> r; // character ranges
- bool n; // negative?
#ifndef QT_NO_REGEXP_OPTIM
QVector<int> occ1; // first-occurrence array
#endif
+ uint c; // character classes
+ bool n; // negative?
};
#else
struct QRegExpCharClass
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index d5bd1dff00..e1cf82bb8c 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -813,8 +813,9 @@ struct QRegularExpressionPrivate : QSharedData
int captureIndexForName(const QString &name) const;
- QString pattern;
+ // sizeof(QSharedData) == 4, so start our members with an enum
QRegularExpression::PatternOptions patternOptions;
+ QString pattern;
// *All* of the following members are set managed while holding this mutex,
// except for isDirty which is set to true by QRegularExpression setters
@@ -889,7 +890,7 @@ QRegularExpression::QRegularExpression(QRegularExpressionPrivate &dd)
\internal
*/
QRegularExpressionPrivate::QRegularExpressionPrivate()
- : pattern(), patternOptions(0),
+ : patternOptions(0), pattern(),
mutex(),
compiledPattern(0), studyData(0),
errorString(0), errorOffset(-1),
@@ -919,7 +920,7 @@ QRegularExpressionPrivate::~QRegularExpressionPrivate()
*/
QRegularExpressionPrivate::QRegularExpressionPrivate(const QRegularExpressionPrivate &other)
: QSharedData(other),
- pattern(other.pattern), patternOptions(other.patternOptions),
+ patternOptions(other.patternOptions), pattern(other.pattern),
mutex(),
compiledPattern(0), studyData(0),
errorString(0),
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 98eb473da0..b01c47d4ce 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -239,11 +239,7 @@ static inline uint qCpuFeatures()
return uint(features);
}
-static inline uint qCpuHasFeature(CPUFeatures feature)
-{
- return qCompilerCpuFeatures & feature || qCpuFeatures() & feature;
-}
-
+#define qCpuHasFeature(feature) ((qCompilerCpuFeatures & (feature)) || (qCpuFeatures() & (feature)))
#define ALIGNMENT_PROLOGUE_16BYTES(ptr, i, length) \
for (; i < static_cast<int>(qMin(static_cast<quintptr>(length), ((4 - ((reinterpret_cast<quintptr>(ptr) >> 2) & 0x3)) & 0x3))); ++i)
diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp
index 976c03aef4..3619c9e986 100644
--- a/src/corelib/tools/qtimeline.cpp
+++ b/src/corelib/tools/qtimeline.cpp
@@ -53,13 +53,17 @@ class QTimeLinePrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QTimeLine)
public:
inline QTimeLinePrivate()
- : startTime(0), duration(1000), startFrame(0), endFrame(0),
+ : easingCurve(QEasingCurve::InOutSine),
+ startTime(0), duration(1000), startFrame(0), endFrame(0),
updateInterval(1000 / 25),
totalLoopCount(1), currentLoopCount(0), currentTime(0), timerId(0),
- direction(QTimeLine::Forward), easingCurve(QEasingCurve::InOutSine),
+ direction(QTimeLine::Forward),
state(QTimeLine::NotRunning)
{ }
+ QElapsedTimer timer;
+ QEasingCurve easingCurve;
+
int startTime;
int duration;
int startFrame;
@@ -70,10 +74,8 @@ public:
int currentTime;
int timerId;
- QElapsedTimer timer;
QTimeLine::Direction direction;
- QEasingCurve easingCurve;
QTimeLine::State state;
inline void setState(QTimeLine::State newState)
{
diff --git a/src/corelib/tools/qtimezoneprivate.cpp b/src/corelib/tools/qtimezoneprivate.cpp
index 08a5ce0861..dffb20b7cf 100644
--- a/src/corelib/tools/qtimezoneprivate.cpp
+++ b/src/corelib/tools/qtimezoneprivate.cpp
@@ -453,9 +453,9 @@ bool QTimeZonePrivate::isValidId(const QByteArray &olsenId)
// Aliases such as "Etc/GMT+7" and "SystemV/EST5EDT" are valid so we need to accept digits
if (olsenId.contains(' '))
return false;
- QList<QByteArray> parts = olsenId.split('\\');
+ QList<QByteArray> parts = olsenId.split('/');
foreach (const QByteArray &part, parts) {
- if (part.size() > 14)
+ if (part.size() > 14 || part.size() < 1)
return false;
if (part.at(0) == '-')
return false;
@@ -466,6 +466,8 @@ bool QTimeZonePrivate::isValidId(const QByteArray &olsenId)
&& !(ch == '_')
&& !(ch >= '0' && ch <= '9')
&& !(ch == '-')
+ && !(ch == '+')
+ && !(ch == ':')
&& !(ch == '.'))
return false;
}
@@ -596,9 +598,11 @@ QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QByteArray &zoneId, int offsetSec
}
QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QUtcTimeZonePrivate &other)
- : QTimeZonePrivate(other), m_offsetFromUtc(other.m_offsetFromUtc), m_name(other.m_name),
- m_abbreviation(other.m_abbreviation), m_country(other.m_country),
- m_comment(other.m_comment)
+ : QTimeZonePrivate(other), m_name(other.m_name),
+ m_abbreviation(other.m_abbreviation),
+ m_comment(other.m_comment),
+ m_country(other.m_country),
+ m_offsetFromUtc(other.m_offsetFromUtc)
{
}
diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h
index 108aec2654..4fbb3ff6e0 100644
--- a/src/corelib/tools/qtimezoneprivate_p.h
+++ b/src/corelib/tools/qtimezoneprivate_p.h
@@ -203,11 +203,11 @@ private:
const QString &abbreviation, QLocale::Country country,
const QString &comment);
- int m_offsetFromUtc;
QString m_name;
QString m_abbreviation;
- QLocale::Country m_country;
QString m_comment;
+ QLocale::Country m_country;
+ int m_offsetFromUtc;
};
#ifdef QT_USE_ICU