diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/codecs/qgb18030codec.cpp | 4 | ||||
-rw-r--r-- | src/corelib/configure.json | 1 | ||||
-rw-r--r-- | src/corelib/global/qoperatingsystemversion.cpp | 11 | ||||
-rw-r--r-- | src/corelib/global/qoperatingsystemversion.h | 4 | ||||
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 46 | ||||
-rw-r--r-- | src/corelib/io/qurl.cpp | 4 | ||||
-rw-r--r-- | src/corelib/thread/qsemaphore.cpp | 25 | ||||
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/tools.pri | 2 |
9 files changed, 53 insertions, 48 deletions
diff --git a/src/corelib/codecs/qgb18030codec.cpp b/src/corelib/codecs/qgb18030codec.cpp index 9899d47c23..04e4bef4cd 100644 --- a/src/corelib/codecs/qgb18030codec.cpp +++ b/src/corelib/codecs/qgb18030codec.cpp @@ -317,7 +317,7 @@ QList<QByteArray> QGbkCodec::_aliases() QString QGbkCodec::convertToUnicode(const char* chars, int len, ConverterState *state) const { - uchar buf[2]; + uchar buf[2] = {0, 0}; int nbuf = 0; ushort replacement = QChar::ReplacementCharacter; if (state) { @@ -467,7 +467,7 @@ QByteArray QGb2312Codec::_name() QString QGb2312Codec::convertToUnicode(const char* chars, int len, ConverterState *state) const { - uchar buf[2]; + uchar buf[2] = {0, 0}; int nbuf = 0; ushort replacement = QChar::ReplacementCharacter; if (state) { diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 5e2cb025d3..c32354c771 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -44,7 +44,6 @@ }, "icu": { "label": "ICU", - "export": "", "test": "unix/icu", "sources": [ { diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp index 244f294312..83ba6e69ee 100644 --- a/src/corelib/global/qoperatingsystemversion.cpp +++ b/src/corelib/global/qoperatingsystemversion.cpp @@ -175,7 +175,10 @@ QOperatingSystemVersion QOperatingSystemVersion::current() version.m_major = -1; version.m_minor = -1; - static const int versions[][2] = { + static const struct { + uint major : 4; + uint minor : 4; + } versions[] = { { 1, 0 }, // API level 1 { 1, 1 }, // API level 2 { 1, 5 }, // API level 3 @@ -207,8 +210,8 @@ QOperatingSystemVersion QOperatingSystemVersion::current() const size_t versionIdx = size_t(QJNIObjectPrivate::getStaticField<jint>( "android/os/Build$VERSION", "SDK_INT")) - 1; if (versionIdx < sizeof(versions) / sizeof(versions[0])) { - version.m_major = versions[versionIdx][0]; - version.m_minor = versions[versionIdx][1]; + version.m_major = versions[versionIdx].major; + version.m_minor = versions[versionIdx].minor; } // API level 6 was exactly version 2.0.1 @@ -333,6 +336,7 @@ QString QOperatingSystemVersion::name() const } } +#ifdef Q_COMPILER_INITIALIZER_LISTS /*! \fn bool QOperatingSystemVersion::isAnyOfType(std::initializer_list<OSType> types) const @@ -347,6 +351,7 @@ bool QOperatingSystemVersion::isAnyOfType(std::initializer_list<OSType> types) c } return false; } +#endif /*! \variable QOperatingSystemVersion::Windows7 diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h index 295365aad1..2e319e66d5 100644 --- a/src/corelib/global/qoperatingsystemversion.h +++ b/src/corelib/global/qoperatingsystemversion.h @@ -81,7 +81,6 @@ public: static const QOperatingSystemVersion AndroidNougat; static const QOperatingSystemVersion AndroidNougat_MR1; - QOperatingSystemVersion(const QOperatingSystemVersion &other) = default; Q_DECL_CONSTEXPR QOperatingSystemVersion(OSType osType, int vmajor, int vminor = -1, int vmicro = -1) : m_os(osType), @@ -99,7 +98,9 @@ public: Q_DECL_CONSTEXPR int segmentCount() const { return m_micro >= 0 ? 3 : m_minor >= 0 ? 2 : m_major >= 0 ? 1 : 0; } +#ifdef Q_COMPILER_INITIALIZER_LISTS bool isAnyOfType(std::initializer_list<OSType> types) const; +#endif Q_DECL_CONSTEXPR OSType type() const { return m_os; } QString name() const; @@ -124,6 +125,7 @@ private: static int compare(const QOperatingSystemVersion &v1, const QOperatingSystemVersion &v2); }; +Q_DECLARE_TYPEINFO(QOperatingSystemVersion, QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ? Q_RELOCATABLE_TYPE : Q_PRIMITIVE_TYPE); QT_END_NAMESPACE diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 35bb44fed4..cf9d38097a 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -147,10 +147,6 @@ QProcessEnvironment QProcessEnvironment::systemEnvironment() #if QT_CONFIG(process) -// POSIX requires PIPE_BUF to be 512 or larger -// so we will use 512 -static const int errorBufferMax = 512; - namespace { struct QProcessPoller { @@ -530,11 +526,18 @@ void QProcessPrivate::startProcess() } } +struct ChildError +{ + int code; + char function[8]; +}; + void QProcessPrivate::execChild(const char *workingDir, char **argv, char **envp) { ::signal(SIGPIPE, SIG_DFL); // reset the signal that we ignored Q_Q(QProcess); + ChildError error = { 0, {} }; // force zeroing of function[8] // copy the stdin socket if asked to (without closing on exec) if (inputChannelMode != QProcess::ForwardedInputChannel) @@ -557,9 +560,9 @@ void QProcessPrivate::execChild(const char *workingDir, char **argv, char **envp qt_safe_close(childStartedPipe[0]); // enter the working directory - const char *callthatfailed = "chdir: "; if (workingDir && QT_CHDIR(workingDir) == -1) { // failed, stop the process + strcpy(error.function, "chdir"); goto report_errno; } @@ -569,39 +572,28 @@ void QProcessPrivate::execChild(const char *workingDir, char **argv, char **envp // execute the process if (!envp) { qt_safe_execv(argv[0], argv); - callthatfailed = "execv: "; + strcpy(error.function, "execvp"); } else { #if defined (QPROCESS_DEBUG) fprintf(stderr, "QProcessPrivate::execChild() starting %s\n", argv[0]); #endif qt_safe_execve(argv[0], argv, envp); - callthatfailed = "execve: "; + strcpy(error.function, "execve"); } // notify failure - // we're running in the child process, so we don't need to be thread-safe; - // we can use strerror + // don't use strerror or any other routines that may allocate memory, since + // some buggy libc versions can deadlock on locked mutexes. report_errno: - const char *msg = strerror(errno); -#if defined (QPROCESS_DEBUG) - fprintf(stderr, "QProcessPrivate::execChild() failed (%s), notifying parent process\n", msg); -#endif - qt_safe_write(childStartedPipe[1], callthatfailed, strlen(callthatfailed)); - qt_safe_write(childStartedPipe[1], msg, strlen(msg)); - qt_safe_close(childStartedPipe[1]); + error.code = errno; + qt_safe_write(childStartedPipe[1], &error, sizeof(error)); childStartedPipe[1] = -1; } bool QProcessPrivate::processStarted(QString *errorMessage) { - char buf[errorBufferMax]; - int i = 0; - int ret; - do { - ret = qt_safe_read(childStartedPipe[0], buf + i, sizeof buf - i); - if (ret > 0) - i += ret; - } while (ret > 0 && i < int(sizeof buf)); + ChildError buf; + int ret = qt_safe_read(childStartedPipe[0], &buf, sizeof(buf)); if (startupSocketNotifier) { startupSocketNotifier->setEnabled(false); @@ -616,10 +608,10 @@ bool QProcessPrivate::processStarted(QString *errorMessage) #endif // did we read an error message? - if ((i > 0) && errorMessage) - *errorMessage = QString::fromLocal8Bit(buf, i); + if (ret > 0 && errorMessage) + *errorMessage = QLatin1String(buf.function) + QLatin1String(": ") + qt_error_string(buf.code); - return i <= 0; + return ret <= 0; } qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *channel) const diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 9663235a67..ac694a464a 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3440,6 +3440,10 @@ QUrl QUrl::fromEncoded(const QByteArray &input, ParsingMode mode) /*! Returns a decoded copy of \a input. \a input is first decoded from percent encoding, then converted from UTF-8 to unicode. + + \note Given invalid input (such as a string containing the sequence "%G5", + which is not a valid hexadecimal number) the output will be invalid as + well. As an example: the sequence "%G5" could be decoded to 'W'. */ QString QUrl::fromPercentEncoding(const QByteArray &input) { diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 397d6203aa..96c031eec6 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -42,7 +42,7 @@ #ifndef QT_NO_THREAD #include "qmutex.h" #include "qwaitcondition.h" -#include "qelapsedtimer.h" +#include "qdeadlinetimer.h" #include "qdatetime.h" QT_BEGIN_NAMESPACE @@ -217,20 +217,19 @@ bool QSemaphore::tryAcquire(int n) bool QSemaphore::tryAcquire(int n, int timeout) { Q_ASSERT_X(n >= 0, "QSemaphore::tryAcquire", "parameter 'n' must be non-negative"); + if (timeout < 0) + return tryAcquire(n); + + QDeadlineTimer timer(timeout); QMutexLocker locker(&d->mutex); - if (timeout < 0) { - while (n > d->avail) - d->cond.wait(locker.mutex()); - } else { - QElapsedTimer timer; - timer.start(); - while (n > d->avail) { - const qint64 elapsed = timer.elapsed(); - if (timeout - elapsed <= 0 - || !d->cond.wait(locker.mutex(), timeout - elapsed)) - return false; - } + qint64 remainingTime = timer.remainingTime(); + while (n > d->avail && remainingTime > 0) { + if (!d->cond.wait(locker.mutex(), remainingTime)) + return false; + remainingTime = timer.remainingTime(); } + if (n > d->avail) + return false; d->avail -= n; return true; diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 19c27d9ff8..bbac058f2f 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -4563,6 +4563,10 @@ void q_fromPercentEncoding(QByteArray *ba) text.data(); // returns "Qt is great!" \endcode + \note Given invalid input (such as a string containing the sequence "%G5", + which is not a valid hexadecimal number) the output will be invalid as + well. As an example: the sequence "%G5" could be decoded to 'W'. + \sa toPercentEncoding(), QUrl::fromPercentEncoding() */ QByteArray QByteArray::fromPercentEncoding(const QByteArray &input, char percent) diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 3d6cc97205..aa545497a2 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -141,7 +141,7 @@ qtConfig(system-zlib) { } qtConfig(icu) { - include($$PWD/../../3rdparty/icu_dependency.pri) + QMAKE_USE_PRIVATE += icu SOURCES += tools/qlocale_icu.cpp \ tools/qcollator_icu.cpp |