From acacca859c3416e525599c4162292dd2a5e78fb7 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 22 Jan 2017 00:18:58 +0100 Subject: Doc: update QStringList doc with missing QRegularExpression reference The documentation of QStringList is missing some mention of QRegularExpression as well as still using QRegExp in some sample code. This patch fixes that. Change-Id: I4a7c9fe8e5ae7c73497192bb71d1fa66ee864bd2 Reviewed-by: Sze Howe Koh --- src/corelib/doc/snippets/qstringlist/main.cpp | 2 +- src/corelib/tools/qstringlist.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/doc/snippets/qstringlist/main.cpp b/src/corelib/doc/snippets/qstringlist/main.cpp index 7e7d55ca30..4d9c015747 100644 --- a/src/corelib/doc/snippets/qstringlist/main.cpp +++ b/src/corelib/doc/snippets/qstringlist/main.cpp @@ -97,7 +97,7 @@ Widget::Widget(QWidget *parent) //! [6] //! [7] - QStringList monospacedFonts = fonts.filter(QRegExp("Courier|Fixed")); + QStringList monospacedFonts = fonts.filter(QRegularExpression("Courier|Fixed")); //! [7] //! [8] diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index a0b65ea554..88ceae20b9 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -143,8 +143,8 @@ QT_BEGIN_NAMESPACE \snippet qstringlist/main.cpp 6 - The argument to split can be a single character, a string, or a - QRegExp. + The argument to split can be a single character, a string, a + QRegularExpression or a (deprecated) QRegExp. In addition, the \l {QStringList::operator+()}{operator+()} function allows you to concatenate two string lists into one. To -- cgit v1.2.3 From cbd7dea83ed5d1f8876759e44d589b0e4c90c5f3 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 22 Jan 2017 00:08:16 +0100 Subject: Doc: updated QString::fromRawData documentation to QRegularExpression QString::fromRawData code sample still shows the use of QRegExp. This patch updates it for QRegularExpression and cleans the code. Change-Id: Iff0f736cdbdd7d35c65fde1496ce9f838a8f5c6d Reviewed-by: Thiago Macieira --- src/corelib/doc/snippets/qstring/main.cpp | 4 ++-- src/corelib/tools/qstring.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp index 5871026f95..41ee5a9cef 100644 --- a/src/corelib/doc/snippets/qstring/main.cpp +++ b/src/corelib/doc/snippets/qstring/main.cpp @@ -380,14 +380,14 @@ void Widget::fillFunction() void Widget::fromRawDataFunction() { //! [22] - QRegExp pattern; + QRegularExpression pattern("\u00A4"); static const QChar unicode[] = { 0x005A, 0x007F, 0x00A4, 0x0060, 0x1009, 0x0020, 0x0020}; int size = sizeof(unicode) / sizeof(QChar); QString str = QString::fromRawData(unicode, size); - if (str.contains(QRegExp(pattern))) { + if (str.contains(pattern) { // ... //! [22] //! [23] } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 8888eced87..9a3c05ac85 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -8144,7 +8144,7 @@ bool QString::isRightToLeft() const to create a deep copy of the data, ensuring that the raw data isn't modified. - Here's an example of how we can use a QRegExp on raw data in + Here's an example of how we can use a QRegularExpression on raw data in memory without requiring to copy the data into a QString: \snippet qstring/main.cpp 22 -- cgit v1.2.3 From b0649df7d69a3db1538c62c624eda42a6326110b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 23 Jan 2017 09:57:46 +0100 Subject: Fix MIPS32 processor detection Gcc defines neither _MIPS_ARCH_MIPS32 nor __mips32 on MIPS32 architectures, instead __mips is defined to 32. This fix exposed bit-rot in qdrawhelper where qt_memfill32 was set as a function pointer despite not being one since Qt4. Change-Id: I87461823e54fa3166223ebf97175fd05d2f2fd16 Reviewed-by: Thiago Macieira --- src/corelib/global/qprocessordetection.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index 566d76d3d2..55fcb37093 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -231,9 +231,6 @@ # if defined(_MIPS_ARCH_MIPS2) || (defined(__mips) && __mips - 0 >= 2) # define Q_PROCESSOR_MIPS_II # endif -# if defined(_MIPS_ARCH_MIPS32) || defined(__mips32) -# define Q_PROCESSOR_MIPS_32 -# endif # if defined(_MIPS_ARCH_MIPS3) || (defined(__mips) && __mips - 0 >= 3) # define Q_PROCESSOR_MIPS_III # endif @@ -243,6 +240,9 @@ # if defined(_MIPS_ARCH_MIPS5) || (defined(__mips) && __mips - 0 >= 5) # define Q_PROCESSOR_MIPS_V # endif +# if defined(_MIPS_ARCH_MIPS32) || defined(__mips32) || (defined(__mips) && __mips - 0 >= 32) +# define Q_PROCESSOR_MIPS_32 +# endif # if defined(_MIPS_ARCH_MIPS64) || defined(__mips64) # define Q_PROCESSOR_MIPS_64 # define Q_PROCESSOR_WORDSIZE 8 -- cgit v1.2.3 From 6a3e728e9b60f0201b0319b4b8de52ac5e282091 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Mon, 23 Jan 2017 22:12:59 +0100 Subject: Fix possible loss of data warning warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data while compiling class template member function 'QVarLengthArray::QVarLengthArray(std::initializer_list)' Change-Id: I36f5ef65ec1f511eac7f3ad1a4717d18f7dc9ce4 Reviewed-by: Timur Pocheptsov --- src/corelib/tools/qvarlengtharray.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 1530299303..bb5ae78d2b 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -77,7 +77,7 @@ public: : a(Prealloc), s(0), ptr(reinterpret_cast(array)) { if (args.size()) - append(args.begin(), args.size()); + append(args.begin(), int(args.size())); } #endif -- cgit v1.2.3 From 9170cf9f1d57b6c31d58511b04759942d640b57c Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 22 Jan 2017 17:33:45 +0100 Subject: Remove use of deprecated QRegExp from QLibraryInfo This patch replaces QRegExp by QString search and replace. Change-Id: I11165afa45f8f9a856e6fb9b64929e4bdacb913d Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qlibraryinfo.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 0de8b50900..03ee0730db 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -530,14 +530,24 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) } #endif - // expand environment variables in the form $(ENVVAR) - int rep; - QRegExp reg_var(QLatin1String("\\$\\(.*\\)")); - reg_var.setMinimal(true); - while((rep = reg_var.indexIn(ret)) != -1) { - ret.replace(rep, reg_var.matchedLength(), - QString::fromLocal8Bit(qgetenv(ret.midRef(rep + 2, - reg_var.matchedLength() - 3).toLatin1().constData()).constData())); + int startIndex = 0; + forever { + startIndex = ret.indexOf(QLatin1Char('$'), startIndex); + if (startIndex < 0) + break; + if (ret.length() < startIndex + 3) + break; + if (ret.at(startIndex + 1) != QLatin1Char('(')) { + startIndex++; + continue; + } + int endIndex = ret.indexOf(QLatin1Char(')'), startIndex + 2); + if (endIndex < 0) + break; + QStringRef envVarName = ret.midRef(startIndex + 2, endIndex - startIndex - 2); + QString value = QString::fromLocal8Bit(qgetenv(envVarName.toLocal8Bit().constData())); + ret.replace(startIndex, endIndex - startIndex + 1, value); + startIndex += value.length(); } config->endGroup(); -- cgit v1.2.3 From 64e977cfac2fbe93fc234d3e134d126591d4c821 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 21 Jan 2017 00:29:28 +0900 Subject: Fix build without features.temporaryfile Change-Id: I3f26f122a20aa8e59baaf3f33b89cc776865ff8b Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qsettings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 8c67d97afa..e12da68671 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1460,7 +1460,7 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo) ensureAllSectionsParsed(confFile); ParsedSettingsMap mergedKeys = confFile->mergedKeyMap(); -#ifndef QT_BOOTSTRAPPED +#if !defined(QT_BOOTSTRAPPED) && QT_CONFIG(temporaryfile) QSaveFile sf(confFile->name); #else QFile sf(confFile->name); @@ -1488,7 +1488,7 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo) ok = writeFunc(sf, tempOriginalKeys); } -#ifndef QT_BOOTSTRAPPED +#if !defined(QT_BOOTSTRAPPED) && QT_CONFIG(temporaryfile) if (ok) ok = sf.commit(); #endif -- cgit v1.2.3 From f823af43f243b1848fd4a838847317d0ff6d4fdf Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 10 Nov 2016 14:57:04 +0100 Subject: QVariant of nullptr should always be null Implements isNull for QVariants of a nullptr so they always return true to isNull(), instead of depending on how they were constructed. Task-number: QTBUG-58296 Change-Id: Ibddec795cdadedef7e17d22c265c29e752d8f99f Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qvariant_p.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index bf88def438..487949431c 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -177,6 +177,26 @@ inline void v_clear(QVariant::Private *d, T* = 0) } +template +struct PrimitiveIsNull +{ +public: + static bool isNull(const QVariant::Private *d) + { + return d->is_null; + } +}; + +template <> +struct PrimitiveIsNull +{ +public: + static bool isNull(const QVariant::Private *) + { + return true; + } +}; + template class QVariantComparator { template::IsAccepted> @@ -268,7 +288,7 @@ class QVariantIsNull { static bool isNull(const QVariant::Private *d) { - return d->is_null; + return PrimitiveIsNull::isNull(d); } }; -- cgit v1.2.3 From deef2d4e70c54ffe71304575e56095dd25cd55eb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Jan 2017 14:04:14 -0800 Subject: Fix warning about not calling the base class copy constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit error: base class ‘class QBasicAtomicPointer’ should be explicitly initialized in the copy constructor [-Werror=extra] Change-Id: I2bc52f3c7a574209b213fffd149b4b71f3006be5 Reviewed-by: Marc Mutz --- src/corelib/thread/qatomic.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index bbfc11f6c0..f9eacbf6f0 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -176,6 +176,9 @@ public: } #endif inline QAtomicPointer(const QAtomicPointer &other) Q_DECL_NOTHROW +#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS + : QBasicAtomicPointer() +#endif { this->storeRelease(other.loadAcquire()); } -- cgit v1.2.3 From dfd7a0e41153315625883619a4abe84db1d29769 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 19 Dec 2016 11:28:40 -0800 Subject: Doc: add a note that UniqueConnection does not work for lambdas Task-number: QTBUG-52438 Change-Id: I3e4e5051937c40319d6efffd1491bef6feb6776e Reviewed-by: Martin Smith Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 63b02d2c0c..c44e4b16b1 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2614,6 +2614,9 @@ static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaM (exact same signal to the exact same slot on the same objects), the connection will fail and connect will return an invalid QMetaObject::Connection. + \note Qt::UniqueConnections do not work for lambdas, non-member functions + and functors; they only apply to connecting to member functions. + The optional \a type parameter describes the type of connection to establish. In particular, it determines whether a particular signal is delivered to a slot immediately or queued for delivery @@ -4665,7 +4668,10 @@ void qDeleteInEventHandler(QObject *o) Creates a connection of a given \a type from \a signal in \a sender object to \a functor to be placed in a specific event - loop of \a context, and returns a handle to the connection + loop of \a context, and returns a handle to the connection. + + \note Qt::UniqueConnections do not work for lambdas, non-member functions + and functors; they only apply to connecting to member functions. The signal must be a function declared as a signal in the header. The slot function can be any function or functor that can be connected -- cgit v1.2.3 From 3b8f3fb327fd80217e1caf7fbb8d2d41576edc3b Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Wed, 25 Jan 2017 20:19:43 +0200 Subject: QEventDispatcherWin32: remove tailings of Windows CE code It was automatically merged from 5.6 branch. Qt 5.8 does not support Windows CE. Change-Id: I6968f50ef568035c224851d595d6c057128491a7 Reviewed-by: Friedemann Kleint --- src/corelib/kernel/qeventdispatcher_win.cpp | 22 ---------------------- src/corelib/kernel/qeventdispatcher_win_p.h | 2 -- 2 files changed, 24 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 1a0efae2dc..88dbe8e4f7 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -96,9 +96,7 @@ QEventDispatcherWin32Private::QEventDispatcherWin32Private() : threadId(GetCurrentThreadId()), interrupt(false), closingDown(false), internalHwnd(0), getMessageHook(0), serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0), wakeUps(0) -#ifndef Q_OS_WINCE , activateNotifiersPosted(false) -#endif { } @@ -179,11 +177,9 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA QSockNot *sn = dict ? dict->value(wp) : 0; if (sn) { -#ifndef Q_OS_WINCE d->doWsaAsyncSelect(sn->fd, 0); d->active_fd[sn->fd].selected = false; d->postActivateSocketNotifiers(); -#endif if (type < 3) { QEvent event(QEvent::SockAct); QCoreApplication::sendEvent(sn->obj, &event); @@ -194,7 +190,6 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA } } return 0; -#ifndef Q_OS_WINCE } else if (message == WM_QT_ACTIVATENOTIFIERS) { Q_ASSERT(d != 0); @@ -209,7 +204,6 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA } d->activateNotifiersPosted = false; return 0; -#endif // !Q_OS_WINCE } else if (message == WM_QT_SENDPOSTEDEVENTS // we also use a Windows timer to send posted events when the message queue is full || (message == WM_TIMER @@ -444,13 +438,11 @@ void QEventDispatcherWin32Private::doWsaAsyncSelect(int socket, long event) WSAAsyncSelect(socket, internalHwnd, event ? int(WM_QT_SOCKETNOTIFIER) : 0, event); } -#ifndef Q_OS_WINCE void QEventDispatcherWin32Private::postActivateSocketNotifiers() { if (!activateNotifiersPosted) activateNotifiersPosted = PostMessage(internalHwnd, WM_QT_ACTIVATENOTIFIERS, 0, 0); } -#endif // !Q_OS_WINCE void QEventDispatcherWin32::createInternalHwnd() { @@ -704,22 +696,16 @@ void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier) QSFDict::iterator it = d->active_fd.find(sockfd); if (it != d->active_fd.end()) { QSockFd &sd = it.value(); -#ifndef Q_OS_WINCE if (sd.selected) { d->doWsaAsyncSelect(sockfd, 0); sd.selected = false; } -#endif // !Q_OS_WINCE sd.event |= event; } else { d->active_fd.insert(sockfd, QSockFd(event)); } -#ifndef Q_OS_WINCE d->postActivateSocketNotifiers(); -#else - d->doWsaAsyncSelect(sockfd, event); -#endif } void QEventDispatcherWin32::unregisterSocketNotifier(QSocketNotifier *notifier) @@ -748,7 +734,6 @@ void QEventDispatcherWin32::doUnregisterSocketNotifier(QSocketNotifier *notifier QSFDict::iterator it = d->active_fd.find(sockfd); if (it != d->active_fd.end()) { QSockFd &sd = it.value(); -#ifndef Q_OS_WINCE if (sd.selected) d->doWsaAsyncSelect(sockfd, 0); const long event[3] = { FD_READ | FD_CLOSE | FD_ACCEPT, FD_WRITE | FD_CONNECT, FD_OOB }; @@ -759,13 +744,6 @@ void QEventDispatcherWin32::doUnregisterSocketNotifier(QSocketNotifier *notifier sd.selected = false; d->postActivateSocketNotifiers(); } -#else - const long event[3] = { FD_READ | FD_CLOSE | FD_ACCEPT, FD_WRITE | FD_CONNECT, FD_OOB }; - sd.event ^= event[type]; - d->doWsaAsyncSelect(sockfd, sd.event); - if (sd.event == 0) - d->active_fd.erase(it); -#endif // !Q_OS_WINCE } QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except }; diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index 773315c04f..df1513a43a 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -185,10 +185,8 @@ public: QSNDict sn_write; QSNDict sn_except; QSFDict active_fd; -#ifndef Q_OS_WINCE bool activateNotifiersPosted; void postActivateSocketNotifiers(); -#endif void doWsaAsyncSelect(int socket, long event); QList winEventNotifierList; -- cgit v1.2.3