summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qhostinfo.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QHostInfo: fix lookupHost() signature immediatelyMarc Mutz2024-01-231-1/+4
| | | | | | | | | | | | | | | ... and not just for Qt 7. Found in API-Review. Amends dd50d58af267bd3b79d1ca31b920d72b925d5a37. [ChangeLog][QtNetwork][QHostInfo] The lookupHost() static function now takes const QObject* receivers (was: (non-const) QObject*). Pick-to: 6.7 Change-Id: I22b11e06cfba4e96975239cabed8b379cf3f4fa4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix QThreadPool::maxThreadCount() usageIvan Solovev2024-01-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | The docs claim that QThreadPool always creates at least one thread. However, the user can (usually by mistake) request zero or a negative number of threads. The maxThreadCount() function is simply returning the value, that was requested by the user. Since it's a public API, it is used in several places in QtConcurrent, where it is assumed that the value is always positive. This can lead to a crash if the user sets zero as a maxThreadCount. Update all such places with std::max(maxThreadCount(), 1). Prefer this approach over changing the return value of maxThreadCount(), because its behavior is documented and tested. Amends 885eff053797d56f2e295558d0a71b030fbb1a69. Fixes: QTBUG-120335 Pick-to: 6.7 6.6 6.5 6.2 Change-Id: Id3b2087cec7fbc7a2d42febca6586f2dacffe444 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHostInfo::lookupHost: do not violate lookupHostImpl preconditionsGiuseppe D'Angelo2023-09-081-0/+4
| | | | | | | | | | | | | lookupHostImpl requires either `receiver` or `slotObj` to be non-null. Since this code path deals with the string-based slots, `slotObj` is going to be null, therefore check that `receiver` is non-null. For completeness: also check that `member` is non-null. Emit a warning (à la QObject::connect) in case the user did something wrong. Change-Id: Ic6dcd51d7ddd977b121484369b1aef48844364c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHostInfo::abortLookup: ignore -1Giuseppe D'Angelo2023-09-071-0/+3
| | | | | | | | | | The id -1 is the one of a default-constructed QHostInfo (invalid). It's also returned by various codepaths to mean a lookup failure. Attemping to abort its lookup should simply be ignored. Change-Id: I0413dd248a890f57195e4f5b5baea011b6737102 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHostInfoResult::postResultsReady: streamline the implementationGiuseppe D'Angelo2023-09-061-28/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QHostInfo's lookup can notify a slot specified either via the string-based SLOT or via PMF/function objects. In the first case, an actual connection is established and a signal is emitted carrying the result object. In the PMF case, QHostInfo does not establish a connection and calls the slot object "directly" (using some private QObject APIs). The implementation was (and still somehow is) quite convoluted: the index of the QHostInfoResult signal to be emitted was looked up, and used to create a metacall event. However the metacall event was also intercepted in an override of event(), and from there the slot was called. But we don't need to look the signal index up at all to do that, since we are actually never emitting the signal! This can be done with a custom event. ... but I'm not doing that as that's reinventing the wheel. Instead, I'm using invokeMethod to call a private function of QHostInfoResult, and from there we can invoke the slot object. This allows us to get rid of the signal index lookup, remove the manual metacall event handling, and the copy() kludge for SlotObjUniquePtr. Change-Id: I2193acdad57788efd5250bd29f7a1c7505eed2f1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QHostInfoResult: use the same semantics as the contextless connect()Giuseppe D'Angelo2023-09-061-8/+10
| | | | | | | | | | | | | | | | | | | | | The 3-arg QObject::connect() overload (the "contextless" one) simply forwards to the 4-arg overload, using the sender object as both the sender and the receiver/context. QHostInfo does not use connect() directly in order to emit notifications that a lookup is finished. Instead, it uses some of QObject private plumbing. When handling a lookup request that specifies a function to call when done, but no context object, QHostInfo passes nullptr as context/receiver. Change QHostInfoResult's behavior to always have a "receiver": in case the caller didn't specify one, use `this` (= the sender). As a drive-by, this allows to streamline some code. Change-Id: Ic2e63ac18ba36269036950b6f6b7fecea51d0c99 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QHostInfo: add a Qt 7 noteGiuseppe D'Angelo2023-09-061-1/+1
| | | | | Change-Id: I45ee4eba1f7ded358acaccf678e4e12a006b91b6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHostInfo::lookupHostImpl: code tidiesGiuseppe D'Angelo2023-09-051-4/+9
| | | | | | | | | | | Since a non-null `member` implies a non-null `receiver`, streamline the redundant check(s). While at it, introduce a simple boolean that conveys the meaning of what we're checking for. Change-Id: Ib9be162075771de74b1a6bc4426008b7c194df3a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QHostInfo::lookupHostImpl: add another precondition checkGiuseppe D'Angelo2023-09-051-0/+1
| | | | | | | | | | If `member` is set it means that the caller wants us to connect to a slot using string-based connections. That means `receiver` must be non-null as well. Check for it. Change-Id: I6b3542855147e95fecbf4c645b556c2047a1ed69 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHostInfo: remove usused -Result and -Runnable ctorsMarc Mutz2023-08-181-7/+0
| | | | | | | | | Clean up after all users are ported to the SlotObjUniquePtr overloads. Pick-to: 6.6 6.5 Change-Id: I3e58249296ea9674c45fb412463ae3201518de72 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QHostInfo: add -Result and -Runnable ctors taking SlotObjUniquePtrMarc Mutz2023-08-181-4/+18
| | | | | | | | | | | | | | | | ... and use them around the code. Avoids the impedance mismatch between users, which .release() their SlotObjUniquePtr's into the ctors, and the ctor, which constructs its member SlotObjUniquePtr from that. The old constructors are left in on purpose and removed in a follow-up commit to facilitate cherry-picking into branches that might have additional callers. Pick-to: 6.6 6.5 Change-Id: I6f8bce317d5116296973a3a2e3f97db1451f579d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QHostInfo: port lookupHostImpl() to SlotObjUniquePtr internallyMarc Mutz2023-08-141-12/+9
| | | | | | | | | Avoids the manual deref'ing. Pick-to: 6.6 6.5 Change-Id: I1a51a468dfa704986f050b29322a424dc6fcd7b7 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHostInfo: use new QMetaCallEvent::create() overloadMarc Mutz2023-08-101-1/+1
| | | | | | | | | | Move the SlotObjUniquePtr directly into the QMetaCallEvent, without having to up and down the ref-count. Pick-to: 6.6 6.5 Change-Id: I029f71c60defce71ac8778547efe999ce0cf7b4b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QHostInfo: de-inline -Result and -Runnable dtorsMarc Mutz2023-08-071-0/+6
| | | | | | | | | | | | These classes are not exported, so we don't run into duplicate vtables here, but the header is included in a few TUs other than qhostinfo.cpp (all, when building with PCH), so make sure we compile dtors only once. Pick-to: 6.6 6.5 Change-Id: I51f6a6d27fc084ad469f82dc7aef3327bdd9a906 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QHostInfo: use SlotObjUniquePtrMårten Nordheim2023-08-061-1/+1
| | | | | | | | | Drops the direct deref'ing. Pick-to: 6.6 6.5 Change-Id: I9f159244d50572659fa8e9cabfbef47e769ac54e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QHostInfo: fix remaining slotObj leaksMarc Mutz2023-08-041-0/+4
| | | | | | | | | | | | | | | | | | | | | | | We failed to delete the slot object when lookUpHost() was called in these (exceptional) circumstances: - on a thread with no event dispatcher - after application shut-down, when the QHostInfoLookupManager Q_APPLICATION_STATIC was destroyed already Fix by adding the missing destroyIfLastRef() calls into these code paths, too. Amends ad5eb297e179a164e297a7c2eb3b9674a1196605. This would be so much easier if we had SlotObjUniquePtr... Pick-to: 6.6 6.5 6.2 5.15 Task-number: QTBUG-115263 Change-Id: Ief8bf125bc196742c0ce59c1fd87ab93242fc0da Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QHostInfo: fix leaking slot objectMårten Nordheim2023-07-191-1/+0
| | | | | | | | | | | | We were not ref'ing or deref'ing the slot object in the various places that owned it. So, if, in the end, the QHostInfoResult object didn't call the slot we would leak the slot object. Pick-to: 6.6 6.5 6.2 5.15 Fixes: QTBUG-115263 Change-Id: I45f43756c7589470045d97b59257ccfd85a325b7 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Fix documentation warningsTopi Reinio2023-04-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These warnings slipped in during a time period where documentation testing in the CI was disabled. src/network/kernel/qhostinfo.cpp:254: (qdoc) warning: clang couldn't find function when parsing \fn template<typename Functor> int QHostInfo::lookupHost(const QString &name, Functor functor) src/widgets/widgets/qcheckbox.cpp:102: (qdoc) warning: clang couldn't find function when parsing \fn void QCheckBox::stateChanged(Qt::CheckState state) src/corelib/kernel/qcoreapplication.cpp:2769: (qdoc) warning: clang couldn't find function when parsing \fn template<typename Functor> void QCoreApplication::requestPermission( const QPermission &permission, Functor functor) src/corelib/serialization/qxmlstream.cpp:3806: (qdoc) warning: clang couldn't find function when parsing \fn bool QXmlStreamAttributes::hasAttribute( const QString &qualifiedName) const src/corelib/text/qtliterals.qdoc:11: (qdoc) warning: Multiple topic commands found in comment: \namespace and \headerfile. Pick-to: 6.5 Change-Id: I38c605f358dbca1ef3e2bfe20a6424f7a4d44b4a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add helper template for metacall event creationVolker Hilsheimer2023-04-181-11/+1
| | | | | | | | | | Setting up the args and types arrays is cumbersome and error prone, and we do it at least twice in qtbase. Provide a central implementation as a variadic template function, and make it exception-safe with a unique_ptr (the destructor of QMetaCallEvent will destroy the cloned arguments). Change-Id: I5ff400467928446264eaedddb394691e9e23d22e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Apply Q_CONSTINIT where beneficialSona Kurazyan2022-09-011-1/+1
| | | | | | | | | | Applied Q_CONSTINIT to variables with static storage duration, but skipped the POD types with core constant initializers. Task-number: QTBUG-100486 Change-Id: Iaabf824e9cb0f29a405a149912200d4e4b3573c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtNetwork: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-211-1/+3
| | | | | | Task-number: QTBUG-98434 Change-Id: Ic235b92377203f7a1429ae7fd784c4a1fa893e9f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QtNetwork: sweep Q_DECLARE_METATYPE → QT_DECL_METATYPE_EXTERN [1/2]: ↵Marc Mutz2022-04-051-0/+2
| | | | | | | | | | | | | | public API It's one of our best tools to improve compile times. Can't backport to Qt 6.3 or 6.2 because this change introduces new exported symbols. Task-number: QTBUG-102206 Change-Id: I6bfa532be34ca847d3b9034d16c94efed3d602c3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtNetwork: Include moc filesMårten Nordheim2022-01-151-0/+2
| | | | | Change-Id: I227a9541bf76c1c048a694f022b8fc419c0c2544 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* wasm: implement host lookup for socket tunnelingMorten Johan Sørvig2021-12-151-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emscripten implements support for tunneling TCP and UDP sockets through a WebSockets connection. This support is implement for the BSD sockets API, which means that Qt’s existing socket classes can be used, with some adjustments. For example, the flow for making a TCP connection to example.com:1515 can look like this: 1) The application resolves “example.com”. Emscripten creates an internal mapping to a private IP and returns that IP: 172.29.1.0. 2) The application connects to 172.29.1.0:1515. Emscripten makes a WebSocket connection to example.com:1515, and forwards the TCP data over this connection 3) On example.com:1515, a WebSockify intermediate server accepts the WebScoket connection and forwards the TCP data to the target sever, as specified by the WebSockify configuration. Emscripten’s local getaddrinfo() implementation is fast, which means don’t need caching or the thread pool. Instead, special-case lookupHostImpl() for Q_OS_WASM. The implementation calls QHostInfoAgent::lookup() and then posts resultReady using QHostInfoResult. Change-Id: Iaf31efb701ae7cc11752a63cc6b8346d4f09107e Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Introduce Q_APPLICATION_STATICMike Achtelik2021-11-181-18/+2
| | | | | | | | | | | | | | QObjects must be deleted if the QCoreApplication is being destroyed. This was previously done by implementing custom code in qtbase and other modules. So unify it and introduce a Q_APPLICATION_STATIC, based on the Q_GLOBAL_STATIC, which centralises the logic. Since we still have a few remaining living QObjects, this comes in handy to fix those as well. Task-number: QTBUG-84234 Change-Id: I3040a2280ff56291f2b1c39948c06a23597865c4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Centralize RFC documentation-links in rfc.qdocLuca Di Sera2021-09-161-3/+2
| | | | | | | | | | | | | | | | | | | | In the effort of repairing broken links as per QTBUG-96127, a series of RFC links referring to `tools.ietf.org/html/*` were modified to point to the new address that the site redirected to. To simplify executing a similar task and to diminish the duplication of manually inserted urls, the already existing `rfc.qdoc` file, containing `\externalpage` commands directing to RFC locations, was enhanced with links to all RFCs that were mentioned in the current documentation, so as to aggregate this common category of links. All links pointing to a `ietf` domain inside QDoc documentation blocks were then changed to use the newly provided external-references. Task-number: QTBUG-96127 Pick-to: 6.2 Change-Id: I2a52eb6aa8c9e346f64ef1a627b039220d9f6c2a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QHostInfo: simplify assignment operatorVolker Hilsheimer2021-03-031-4/+5
| | | | | | | | | | | | | | The d_ptr is never nullptr. If it could be, then other's d_ptr could also be nullptr, and we would dereference the null pointer. Guarding against self-assignment is nevertheless a good practice. Fixes static analyzer warning 5fc3780532e30c6350a0aa1ad2188a4c. Pick-to: 6.1 Change-Id: I07ff808e4c4f5bf07b4d6663f1fb4a3301a0fec7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHostInfo: address a Qt 6 todoMårten Nordheim2020-08-241-15/+9
| | | | | | | | Merged the two functions, required adding a friend declaration Change-Id: I86265da19e4b5f53d9e2dc54de3e252f0364225b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use QMetaType in QMetaCallEventLars Knoll2020-08-241-3/+3
| | | | | | | And don't use int based type mapping anymore. Change-Id: I456e76d1933ef646a7bd39ce565886b89e938a44 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate the static int based API in QMetaTypeLars Knoll2020-08-241-3/+5
| | | | | | | | | | | | | And remove one of the type id to name mapping that still existed in QMetaType. QMetaTypeInterface can provide that, so there's no need to have a second copy of the data. qMetaTypeTypeInternal() can still map all the names of all builtin types to ids. That functionality is for now still required by moc and can't be removed yet. Change-Id: Ib4f8e9c71e1e7d99d52da9e44477c9a1f1805e57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix living QObject member after shutdown of QCoreApplicationAndré Klitzing2020-06-231-2/+19
| | | | | | | | | | | | | | QHostInfoLookupManager has a QThreadPool as member. QThreadPool is a QObject and must be deleted if the QCoreApplication is being destroyed to release the underlying ThreadData. A Q_GLOBAL_STATIC won't release any memory is not able to manually release it. Pick-to: 5.15 Task-number: QTBUG-84234 Change-Id: I96be4601c3af38fa7c753a6f7acb8273ee277a27 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QtNetwork: Delete bearer managementMårten Nordheim2020-04-051-1/+0
| | | | | | | | | | All remaining pieces are gone, configuration included. Relevant CMakeLists and configure.cmake were regenerated. Fixes: QTBUG-76502 Change-Id: I667b5da7e3802830d236d50b5e9190c2ee9c19e2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QHostInfo: Remove useless codeMårten Nordheim2020-01-151-21/+0
| | | | | | | | | This code has not been doing anything interesting since symbian times Change-Id: If652c75b85e20f631edc4f946aacdee479a19212 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-061-1/+1
|\ | | | | | | | | | | | | Conflicts: src/corelib/kernel/qvariant.h Change-Id: I8f3873e74b9795ac889e7c7ec5de2619bca92160
| * Fix some qdoc warningsFriedemann Kleint2020-01-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | src/corelib/tools/qhash.cpp:2596: (qdoc) warning: clang found diagnostics parsing \fn template <class Key, class T> template <class InputIterator> QMultiHash::QMultiHash(InputIterator begin, InputIterator end) error: 'QMultiHash' is not a class, namespace, or enumeration src/corelib/kernel/qobject.cpp:4593: (qdoc) warning: Undocumented parameter 'EXPORT_MACRO' in QObject::Q_NAMESPACE_EXPORT src/corelib/global/qfloat16.cpp:129: (qdoc) warning: Cannot tie this documentation to anything src/corelib/text/qlocale.qdoc:1204: (qdoc) warning: Overrides a previous doc src/corelib/text/qlocale.qdoc:1187: (qdoc) warning: (The previous doc is here) src/network/kernel/qhostinfo.cpp:597: (qdoc) warning: clang found diagnostics parsing \fn QHostInfo(QHostInfo &&other) src/printsupport/dialogs/qabstractprintdialog.cpp:346: (qdoc) warning: clang found diagnostics parsing \fn int QAbstractPrintDialog::exec(): error: out-of-line definition of 'exec' does not match any declaration in 'QAbstractPrintDialog' src/testlib/qsignalspy.qdoc:101: (qdoc) warning: clang found diagnostics parsing \fn QSignalSpy(const QObject *obj, const QMetaMethod &signal): error: expected unqualified-id src/testlib/doc/src/qttest-best-practices.qdoc:28: (qdoc) warning: Can't link to 'Q_VERIFY2()' src/widgets/kernel/qactiongroup.cpp:291: (qdoc) warning: Undocumented parameter 'b' in QActionGroup::setExclusive() src/widgets/kernel/qactiongroup.cpp:305: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text src/widgets/kernel/qshortcut.cpp:542: (qdoc) warning: No such parameter 'context' in QShortcut::QShortcut() src/widgets/widgets/qdatetimeedit.cpp:632: (qdoc) warning: No such parameter 'minimumTime' in QDateTimeEdit::setTimeRange() src/widgets/widgets/qdatetimeedit.cpp:632: (qdoc) warning: No such parameter 'maximumTime' in QDateTimeEdit::setTimeRange() src/widgets/widgets/qdatetimeedit.cpp:632: (qdoc) warning: No such parameter 'less' in QDateTimeEdit::setTimeRange() Change-Id: I9799b5135e84c4d811674b2d114ef27315bc12df Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-2/+2
|/ | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix some qdoc warnings in 5.14Friedemann Kleint2019-09-031-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mark QCalendarBackend as internal since it is in a private header and fix some issues in the QCalendar related classes. src/corelib/time/qcalendar.cpp:201: (qdoc) warning: clang found diagnostics parsing \fn int QCalendarBackend::daysInMonth(int month, int year) const error: incomplete type 'QCalendarBackend' named in nested name specifier (repeats) src/corelib/time/qdatetime.cpp:1426: (qdoc) warning: Unknown command '\override' (repeats) src/corelib/time/qcalendar.cpp:642: (qdoc) warning: Undocumented enum item 'Last' in QCalendar::System src/corelib/time/qcalendar.cpp:642: (qdoc) warning: Undocumented enum item 'User' in QCalendar::System src/corelib/time/qcalendar.cpp:744: (qdoc) warning: Undocumented parameter 'year' in QCalendar::isLeapYear() src/corelib/time/qcalendar.cpp:923: (qdoc) warning: Can't link to 'dateTimeString()' (repeats) src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'year' in QCalendar::partsFromDate() src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'month' in QCalendar::partsFromDate() src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'day' in QCalendar::partsFromDate() src/corelib/time/qdatetime.cpp:1425: (qdoc) warning: Undocumented parameter 'nmonths' in QDate::addMonths() src/corelib/time/qdatetime.cpp:1467: (qdoc) warning: Undocumented parameter 'nyears' in QDate::addYears() src/corelib/statemachine/qstatemachine.cpp:2522: (qdoc) warning: Undocumented enum item 'StateMachineChildModeSetToParallelError' in QStateMachine::Error src/corelib/kernel/qtimer.cpp:602: (qdoc) warning: Undocumented parameter 'connectionType' in QTimer::callOnTimeout() src/corelib/time/qcalendar.cpp:159: (qdoc) warning: Undocumented parameter 'name' in QCalendarBackend::QCalendarBackend() src/corelib/time/qcalendar.cpp:159: (qdoc) warning: Undocumented parameter 'id' in QCalendarBackend::QCalendarBackend() src/corelib/time/qcalendar.cpp:529: (qdoc) warning: Can't link to 'registerCalendar()' src/corelib/time/qcalendar.cpp:529: (qdoc) warning: Can't link to 'fromName()' src/corelib/time/qcalendar.cpp:178: (qdoc) warning: Can't link to 'QCalendar::fromEnum()' src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Undocumented parameter 'jd' in QCalendarBackend::dayOfWeek() src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Can't link to 'weekDayName()' src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Can't link to 'standaloneWeekDayName()' src/corelib/time/qcalendar.cpp:268: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:268: (qdoc) warning: Can't link to 'isLeapYear()' src/corelib/time/qcalendar.cpp:295: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isLuniSolar()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isSolar()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isLunar()' src/corelib/time/qcalendar.cpp:340: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:357: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:544: (qdoc) warning: Can't link to 'fromName()' Change-Id: Ia2fabefb917f8e4cfa361044d9b754717276f4aa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Refactor memory allocation for arguments of QMetaCallEventsVolker Hilsheimer2019-08-101-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two cases: In a BlockingQueuedConnection, QMetaCallEvent doesn't allocate memory and instead passes already existing pointers through. A QSemaphore is used to serialize data access between threads. So the constructor taking a QSemaphore can be simplified to only accept an existing arg array. In a QueuedConnection, QMetaCallEvent needs to make deep copies of the arguments, and memory needs to be allocated based on the number of arguments. The previous code put the burden of memory allocation on the code generating the event, while the memory was free'd by ~QMetaCallEvent. Instead, make it QMetaCallEvent's responsibility to allocate and free the memory as needed, and adjust the code generating QMetaCallEvents. We can allocate the memory for types and pointers to arguments in a single block, starting with the space for the array of void*, followed by the space for the array of integers to avoid byte alignment issues. By pre-allocating the space that's needed by three arguments, we can avoid all mallocs for the majority of QMetaCallEvents. Until this change has propagated through qt5.git, we need to keep the old API that is still used by QtDeclarative around. Once QtDeclarative has migrated to the new API, it can be removed. Change-Id: Id7359ffc14897237ea9672dabae9ef199a821907 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify and simplify the QHostInfo::lookupHost overloadsVolker Hilsheimer2019-08-071-86/+68
| | | | | | | | | | | | | | | | | | | | The three cases - with classic slot, with functor and context object, and with lambda - are all doing the same work, they just differ in how they signal the application code about the results. The detour through an explicitly posted QMetaCallEvent is needed if we have a functor or lambda; making sure that the temporary QHostInfoResult object lives in the right thread guarantees that the event is received in the correct thread, so we can directly call the functor (as long as the context object is still alive). Since we guarantee that the QHostInfoResult object lives in the thread of the receiver, we can simply emit the signal for old-style signal/slot connections; the regular signal/slot mechanism will do the work for us. Change-Id: I584df17df879af01c653e354490c4691dbedd3fa Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devLiang Qi2019-07-301-9/+41
|\ | | | | | | | | | | | | Conflicts: qmake/generators/win32/mingw_make.cpp Change-Id: I2f790bc8572bd22fea01edf7ca74595b29f063eb
| * Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-07-291-9/+41
| |\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qresource.cpp Change-Id: I54917f72444a621bd08aeaa15f5d17415993144d
| | * QHostInfo: Always post results through the event loop to the receiverVolker Hilsheimer2019-07-261-9/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Lookups performed via QHostInfoRunnable must not synchronously call the user-code's receiver objects, as that would execute user-code in the wrong thread. Instead, post a metacall event through the event loop of the receiver object, or the thread that initiated the lookup. This was done correctly for the trivial cases of empty host name or cached results, so the code generally existed. By moving it from a global function into a member function of QHostInfoResult, we can simply access the required data to construct and post the event. As we process that posted event, we need to check that the context object (which is already guarded via QPointer) is still alive, if we had one in the first place. If we had one, and it's deleted, then abort. [ChangeLog][QtNetwork][QHostInfo] Functors used in the lookupHost overloads are now called correctly in the thread of the context object. When used without context object, the thread that initiates the lookup will run the functor, and is required to run an event loop. Change-Id: I9b38d4f9a23cfc4d9e07bc72de2d2cefe5d0d033 Fixes: QTBUG-76276 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | | QHostInfo: un-QObject-ify QHostInfoLookupManagerMarc Mutz2019-07-191-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QObjects are not even reentrant, but this class must be thread-safe, so it's always ... icky ... to have to analyze a "thread-safe QObject", because for all intents and purposes, that's an oxymoron. The QObject-ness isn't even used, except for defining a private slot, connected to QCoreApplication::destroyed(). That slot just calls waitForDone() on QThreadPool, which is a QObject itself, so use it as the context object for the signal-slot connection, using a lambda as slot. So, strip the class of it's base class, convert the private slot to a lambda and connect to that. Finally, remove the moveToThread() call, because this new class can be destroyed from any thread, not just the main one. Change-Id: I0e33983aa7afd0ad621ece4afd10d9e4adad38c1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | | QHostInfo: remove unused QAbstractHostInfoLookupManagerMarc Mutz2019-07-191-11/+6
| | | | | | | | | | | | | | | | | | | | | | | | If it was used in the past, it no longer is, and can't be, because it's not exported. Change-Id: Ifb9c353e756add5b57bf0c5706c075bb2eb41d83 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | | QHostInfo: port from recursive to non-recursive mutexMarc Mutz2019-07-181-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out that the only reason a recursive mutex is used was because work() was locking it. But work() was only ever called from functions that already had locked the mutex themselves, and kept it locked across the call to work(). Clearly mark work() as expecting to be called with the mutex held (by renaming the function to rescheduleWithMutexHeld(), then drop the mutex locking from it. After this change, a non-recursive mutex suffices, so save the memory allocation and extra complexity involved with recursive mutexes. Looking at the non-QT_CONFIG(thread) code in rescheduleWithMutexHeld(), one might be tempted to expect a recursive mutex, since that code calls QHostInfoRunnable::run() directly, which, in turn, recurses into QHostInfoLookupManager whence control came, under mutex lock. But in non-QT_CONFIG(thread) builds, QMutex is but an empty shell, all of its operations are no-ops, so no possibility for deadlock, either. Change-Id: Ic01d90c2ed3995b66ccf946d146fdaa6f9af3d8b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | | QHostInfo: add nothrow move constructorMarc Mutz2019-07-181-3/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QHostInfo isn't implicitly shared. The more important to optimize away copies by providing a move constructor. Port from QScopedPointer to Q_DECLARE_PRIVATE, as otherwise the move ctor can't be inline, and we don't implement move ctors out-of-line in Qt. [ChangeLog][QtNetwork][QHostInfo] Added move contructor. Change-Id: I6b63a04e36f63e299205830fdc590ff7e2af338b Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-171-21/+13
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qlogging.cpp src/gui/painting/qtextureglyphcache_p.h src/gui/text/qfontengine.cpp src/widgets/widgets/qlineedit.cpp Change-Id: Ic8798538df466b7141caa8bbf1fb7605eb56be37
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-07-121-21/+13
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure.pri Also required s/solid\.color/solidColor/ in a couple of places in: src/gui/painting/qpaintengine_raster.cpp Change-Id: I29937f63e9779deb6dac7ae77e2948d06ebc0319