From c1e19a2ecb182ec95eb06de1a35969ac5f56ffd6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 26 Apr 2017 09:47:05 -0300 Subject: QSysInfo: Make use of the QT_WARNING_DISABLE_DEPRECATED macro We have it for a reason. Change-Id: I84e363d735b443cb9beefffd14b8f355aeb8a31c Reviewed-by: Jake Petroules --- src/corelib/global/qsysinfo.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h index f443ab4b93..6b73a17dc5 100644 --- a/src/corelib/global/qsysinfo.h +++ b/src/corelib/global/qsysinfo.h @@ -211,11 +211,7 @@ public: }; QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") -QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") -QT_WARNING_DISABLE_INTEL(1478) -QT_WARNING_DISABLE_INTEL(1786) -QT_WARNING_DISABLE_MSVC(4996) +QT_WARNING_DISABLE_DEPRECATED #if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static const WinVersion WindowsVersion; QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static WinVersion windowsVersion(); -- cgit v1.2.3 From 5106d496f3bc3a341455c660b42461430e948c09 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Fri, 28 Apr 2017 10:04:22 +0200 Subject: wrap QCoreApplication::flush with QT_DEPRECATED_SINCE ... in cpp file as well. This patch amends 41eefd7. Change-Id: Id6a4dfd3a93a600fe3bb84bb74379451ad167aa8 Reviewed-by: Marc Mutz --- src/corelib/kernel/qcoreapplication.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 4a4ad3ddf8..cc8375298d 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -714,12 +714,14 @@ QCoreApplication::QCoreApplication(QCoreApplicationPrivate &p) \sa sendPostedEvents(), processEvents(), QAbstractEventDispatcher::flush() */ +#if QT_DEPRECATED_SINCE(5, 9) void QCoreApplication::flush() { if (self && self->d_func()->eventDispatcher) self->d_func()->eventDispatcher->flush(); } #endif +#endif /*! Constructs a Qt core application. Core applications are applications without -- cgit v1.2.3 From fad814088cf050f69b05db134a465e4ca0c1c79c Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Fri, 28 Apr 2017 10:03:18 +0200 Subject: do not wrap QAbstractEventDispatcher::flush with QT_DEPRECATED_SINCE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... as this would require us to remove usage of QAbstractEventDispatcher::flush from Qt source code as well. We can not do this already in Qt 5.9 as there are few event dispatchers in Qt that actually do override the ::flush (with non empty bodies). Removing this code could result in behavior changes (not very likely) for some user code. This method will be removed in Qt6. Instead mark it with a well known "### Qt{Version}" comment. This patch amends 41eefd7. The warning was: qcoreapplication.cpp: In static member function ‘static void QCoreApplication::flush()’: qcoreapplication.cpp:733:48: warning: ‘virtual void QAbstractEventDispatcher::flush()’ is deprecated [-Wdeprecated-declarations] self->d_func()->eventDispatcher->flush(); Change-Id: I48a1c68b84ff93268956205e1205e6d4b5d48664 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qabstracteventdispatcher.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h index a256b03523..0d3e53e4a7 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.h +++ b/src/corelib/kernel/qabstracteventdispatcher.h @@ -102,9 +102,7 @@ public: virtual void wakeUp() = 0; virtual void interrupt() = 0; -#if QT_DEPRECATED_SINCE(5, 9) - QT_DEPRECATED virtual void flush() = 0; -#endif + virtual void flush() = 0; // ### Qt6: remove, mark final or make protected virtual void startingUp(); virtual void closingDown(); -- cgit v1.2.3 From 3c4c02b3f1cec8ebc0134fd05b0e51f1f771937d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 25 Apr 2017 17:16:47 -0300 Subject: Include moc of qnamespace.h in qobject.cpp Change-Id: I84e363d735b443cb9beefffd14b8bd4b39b00840 Reviewed-by: Oswald Buddenhagen Reviewed-by: Edward Welbourne Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 1b05962c07..cf6ebf0c54 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -5079,4 +5079,5 @@ bool QMetaObject::Connection::isConnected_helper() const QT_END_NAMESPACE +#include "moc_qnamespace.cpp" #include "moc_qobject.cpp" -- cgit v1.2.3 From a4192166c87fdf0aa69c759f6b0d8cfff85b6904 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 27 Apr 2017 18:17:48 +0200 Subject: Add two missing hyphens Change-Id: Ic320c96208fe7f8340c7eb9e9d068813d769056a Reviewed-by: Jesus Fernandez Reviewed-by: Thiago Macieira --- src/corelib/tools/qhash.cpp | 2 +- src/corelib/tools/qmap.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 334bd52f1e..1f9c05c0b7 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -2527,7 +2527,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW /*! \fn QMultiHash::QMultiHash(std::initializer_list > list) \since 5.1 - Constructs a multi hash with a copy of each of the elements in the + Constructs a multi-hash with a copy of each of the elements in the initializer list \a list. This function is only available if the program is being diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index 94ed47f898..29534bdeee 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -1867,7 +1867,7 @@ void QMapDataBase::freeData(QMapDataBase *d) /*! \fn QMultiMap::QMultiMap(std::initializer_list > list) \since 5.1 - Constructs a multi map with a copy of each of the elements in the + Constructs a multi-map with a copy of each of the elements in the initializer list \a list. This function is only available if the program is being -- cgit v1.2.3 From 91c1b5490e63705b5418ffbae539ff70dbdfe334 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Fri, 28 Apr 2017 18:36:04 +0300 Subject: QWindowsPipeReader: fix possible invalid invocation of ReadFileEx() If the user calls QLocalSocket::setReadBufferSize() with a value less than the current size of the pipe buffer, startAsyncRead() would call ReadFileEx() with invalid parameters: ReadFileEx(handle, nullptr, some_big_value, ...); Change-Id: I3d153e3ec34f8038dc001c1c896aeceb666a8979 Reviewed-by: Thiago Macieira --- src/corelib/io/qwindowspipereader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index b8df8e8084..827ed43b63 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -215,13 +215,13 @@ void QWindowsPipeReader::notified(DWORD errorCode, DWORD numberOfBytesRead) void QWindowsPipeReader::startAsyncRead() { const DWORD minReadBufferSize = 4096; - DWORD bytesToRead = qMax(checkPipeState(), minReadBufferSize); + qint64 bytesToRead = qMax(checkPipeState(), minReadBufferSize); if (pipeBroken) return; if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - readBuffer.size())) { bytesToRead = readBufferMaxSize - readBuffer.size(); - if (bytesToRead == 0) { + if (bytesToRead <= 0) { // Buffer is full. User must read data from the buffer // before we can read more from the pipe. return; -- cgit v1.2.3 From 705c716543f2c318dc7b455d881fe0c8a6a467bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 21 Apr 2017 16:09:05 +0200 Subject: macOS: Add auto-release pools for Q*ApplicationPrivate::init() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So that any objects autoreleased during application initialization are released. Otherwise they will end up in the root level pool and only be released when the application exits and the application goes out of scope. Change-Id: If02d24fd70098f9b4b1b0ea3218e0a15e438b9db Reviewed-by: Morten Johan Sørvig --- src/corelib/kernel/qcoreapplication.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index cc8375298d..0104ba0101 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -758,6 +758,10 @@ QCoreApplication::QCoreApplication(int &argc, char **argv void QCoreApplicationPrivate::init() { +#if defined(Q_OS_MACOS) + QMacAutoReleasePool pool; +#endif + Q_Q(QCoreApplication); initLocale(); -- cgit v1.2.3 From 124b9a6ff89da8be83a256135ec6c4d0603e9a6f Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 21 Jan 2017 18:09:11 +0200 Subject: Improve suppression of spurious socket notifications under Windows There were still two cases where spurious notifications would be possible: - user calls hasPendingDatagrams()/pendingDatagramSize() on UDP socket somewhere outside the slot connected to readyRead() signal (::WSARecvFrom posts FD_READ notification, even if a notification for incoming datagram already exists in the message queue); - a socket was registered to receive several types of event and WM_QT_ACTIVATENOTIFIERS message is located between the different events for this socket in the queue. Provided patch ensures that the message queue is synchronized with the Qt event processing mechanism and adds a way to detect spurious notifications inside the window procedure. Task-number: QTBUG-58214 Change-Id: I49609dace601f300de09875ff1653617efabd72f Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll Reviewed-by: Oliver Wolff Reviewed-by: Edward Welbourne Reviewed-by: Peter Seiderer --- src/corelib/kernel/qeventdispatcher_win.cpp | 52 ++++++++++++++++++++--------- src/corelib/kernel/qeventdispatcher_win_p.h | 3 +- 2 files changed, 38 insertions(+), 17 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 74fa2d8d50..40db5020ab 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -177,15 +177,24 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA QSNDict *dict = sn_vec[type]; QSockNot *sn = dict ? dict->value(wp) : 0; - if (sn) { - d->doWsaAsyncSelect(sn->fd, 0); - d->active_fd[sn->fd].selected = false; + if (sn == nullptr) { d->postActivateSocketNotifiers(); - if (type < 3) { - QEvent event(QEvent::SockAct); - QCoreApplication::sendEvent(sn->obj, &event); - } else { - QEvent event(QEvent::SockClose); + } else { + Q_ASSERT(d->active_fd.contains(sn->fd)); + QSockFd &sd = d->active_fd[sn->fd]; + if (sd.selected) { + Q_ASSERT(sd.mask == 0); + d->doWsaAsyncSelect(sn->fd, 0); + sd.selected = false; + } + d->postActivateSocketNotifiers(); + + // Ignore the message if a notification with the same type was + // received previously. Suppressed message is definitely spurious. + const long eventCode = WSAGETSELECTEVENT(lp); + if ((sd.mask & eventCode) != eventCode) { + sd.mask |= eventCode; + QEvent event(type < 3 ? QEvent::SockAct : QEvent::SockClose); QCoreApplication::sendEvent(sn->obj, &event); } } @@ -194,13 +203,22 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA } else if (message == WM_QT_ACTIVATENOTIFIERS) { Q_ASSERT(d != 0); - // register all socket notifiers - for (QSFDict::iterator it = d->active_fd.begin(), end = d->active_fd.end(); - it != end; ++it) { - QSockFd &sd = it.value(); - if (!sd.selected) { - d->doWsaAsyncSelect(it.key(), sd.event); - sd.selected = true; + // Postpone activation if we have unhandled socket notifier messages + // in the queue. WM_QT_ACTIVATENOTIFIERS will be posted again as a result of + // event processing. + MSG msg; + if (!PeekMessage(&msg, 0, WM_QT_SOCKETNOTIFIER, WM_QT_SOCKETNOTIFIER, PM_NOREMOVE) + && d->queuedSocketEvents.isEmpty()) { + // register all socket notifiers + for (QSFDict::iterator it = d->active_fd.begin(), end = d->active_fd.end(); + it != end; ++it) { + QSockFd &sd = it.value(); + if (!sd.selected) { + d->doWsaAsyncSelect(it.key(), sd.event); + // allow any event to be accepted + sd.mask = 0; + sd.selected = true; + } } } d->activateNotifiersPosted = false; @@ -706,7 +724,9 @@ void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier) } sd.event |= event; } else { - d->active_fd.insert(sockfd, QSockFd(event)); + // Disable the events which could be implicitly re-enabled. Next activation + // of socket notifiers will reset the mask. + d->active_fd.insert(sockfd, QSockFd(event, FD_READ | FD_ACCEPT | FD_WRITE | FD_OOB)); } d->postActivateSocketNotifiers(); diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index 423dc5b169..f6d1bffdf5 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -126,9 +126,10 @@ typedef QHash QSNDict; struct QSockFd { long event; + long mask; bool selected; - explicit inline QSockFd(long ev = 0) : event(ev), selected(false) { } + explicit inline QSockFd(long ev = 0, long ma = 0) : event(ev), mask(ma), selected(false) { } }; typedef QHash QSFDict; -- cgit v1.2.3 From 47cf309190a3cc833f935397fc0db7cfbcddbc44 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 2 May 2017 17:55:11 +0200 Subject: [doc] QSet: fix return type of insert() It's an iterator, not a const_iterator. Let QDoc figure out the correct one. Change-Id: I7ddd1568adbf811b801c170794465ba14ceed05e Reviewed-by: Edward Welbourne --- src/corelib/tools/qset.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc index 48dcc9eec0..93f157fdc5 100644 --- a/src/corelib/tools/qset.qdoc +++ b/src/corelib/tools/qset.qdoc @@ -530,7 +530,7 @@ */ /*! - \fn QSet::const_iterator QSet::insert(const T &value) + \fn QSet::insert(const T &value) Inserts item \a value into the set, if \a value isn't already in the set, and returns an iterator pointing at the inserted -- cgit v1.2.3 From 2714531aad5dd7450baf4224f9af5df313c8aadd Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 20 Apr 2017 14:07:38 +0200 Subject: Doc: correct minor link issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qobject.cpp:4288: warning: Can't link to 'Q_ENUM_NS' qobject.cpp:4314: warning: Can't link to 'Q_FLAG_NS' Change-Id: I0fa5a1d4f9b4868a1a98ce6d3b5f6bb9b34c5dd2 Reviewed-by: Venugopal Shivashankar Reviewed-by: Topi Reiniö --- src/corelib/kernel/qobject.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index cf6ebf0c54..3f50716cd7 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4292,7 +4292,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) This macro registers an enum type with the meta-object system. It must be placed after the enum declaration in a class that has the Q_OBJECT or the - Q_GADGET macro. For namespaces use \l Q_ENUM_NS instead. + Q_GADGET macro. For namespaces use \l Q_ENUM_NS() instead. For example: @@ -4319,7 +4319,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) This macro registers a single \l{QFlags}{flags type} with the meta-object system. It is typically used in a class definition to declare that values of a given enum can be used as flags and combined using the - bitwise OR operator. For namespaces use \l Q_FLAG_NS instead. + bitwise OR operator. For namespaces use \l Q_FLAG_NS() instead. The macro must be placed after the enum declaration. @@ -4340,6 +4340,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) /*! \macro Q_ENUM_NS(...) + \relates QObject \since 5.8 This macro registers an enum type with the meta-object system. @@ -4363,6 +4364,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) /*! \macro Q_FLAG_NS(...) + \relates QObject \since 5.8 This macro registers a single \l{QFlags}{flags type} with the -- cgit v1.2.3 From 979c8b746b56b8e68acf47b5af2eecf834043b50 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Thu, 27 Apr 2017 16:21:46 +0300 Subject: QCFSocketNotifier: fix registering a source in the run loop Even if a callback type is not automatically re-enabled, callbacks are implicitly enabled when the source has been added to the run loop. In this case, calling CFSocketEnableCallBacks() could produce an extra notification if there is a pending event in the queue. The bug is quite unstable and completely depends on the internal OS delays. So, it can't be tested inside Qt. Task-number: QTBUG-59930 Change-Id: I751b8b8cf99cb86b80055f2214a42a638f01abe4 Reviewed-by: Timur Pocheptsov --- src/corelib/kernel/qcfsocketnotifier.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qcfsocketnotifier.cpp b/src/corelib/kernel/qcfsocketnotifier.cpp index a079031e96..1fee2aa5fc 100644 --- a/src/corelib/kernel/qcfsocketnotifier.cpp +++ b/src/corelib/kernel/qcfsocketnotifier.cpp @@ -292,10 +292,19 @@ void QCFSocketNotifier::enableSocketNotifiers(CFRunLoopObserverRef ref, CFRunLoo continue; } - if (!socketInfo->readNotifier) + // Apple docs say: "If a callback is automatically re-enabled, + // it is called every time the condition becomes true ... If a + // callback is not automatically re-enabled, then it gets called + // exactly once, and is not called again until you manually + // re-enable that callback by calling CFSocketEnableCallBacks()". + // So, we don't need to enable callbacks on registering. + socketInfo->readEnabled = (socketInfo->readNotifier != nullptr); + if (!socketInfo->readEnabled) CFSocketDisableCallBacks(socketInfo->socket, kCFSocketReadCallBack); - if (!socketInfo->writeNotifier) + socketInfo->writeEnabled = (socketInfo->writeNotifier != nullptr); + if (!socketInfo->writeEnabled) CFSocketDisableCallBacks(socketInfo->socket, kCFSocketWriteCallBack); + continue; } if (socketInfo->readNotifier && !socketInfo->readEnabled) { -- cgit v1.2.3 From 98c1d516b7f7624f7fcd7b9046783e3903a6a42b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 28 Apr 2017 13:27:43 +0200 Subject: alloca: detect whether alloca.h exists We can't depend on QT_HAS_INCLUDE for such an important functionality in QtQml, so detect at configure time. alloca() is not a POSIX function (it apparently first appeared in Version 32V AT&T UNIX), so the actual header that defines it varies from system to system. Clearly, if alloca.h exists, that's the one, so we try it first. On most other systems that don't define it, it's in stdlib.h. The only exception is Windows, where it's actually defined in malloc.h. Task-number: QTBUG-59700 Started-by: Thiago Macieira Change-Id: Icd0e0d4b27cb4e5eb892fffd14b4b2b389a4684e Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/corelib/global/qconfig-bootstrapped.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index bda8ad7916..0b02ecc8ec 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -68,6 +68,13 @@ #define QT_CRYPTOGRAPHICHASH_ONLY_SHA1 #define QT_NO_DATASTREAM +#define QT_FEATURE_alloca 1 +#define QT_FEATURE_alloca_h -1 +#ifdef _WIN32 +# define QT_FEATURE_alloca_malloc_h 1 +#else +# define QT_FEATURE_alloca_malloc_h -1 +#endif #define QT_FEATURE_iconv -1 #define QT_FEATURE_icu -1 #define QT_FEATURE_journald -1 -- cgit v1.2.3