aboutsummaryrefslogtreecommitdiffstats
path: root/src/webchannel/signalhandler_p.h
Commit message (Collapse)AuthorAgeFilesLines
* SignalHandler: eradicate the last two Q_FOREACH in the classMarc Mutz2023-08-041-4/+4
| | | | | | | | | | | | | | | Use a "consume-loop" over m_connectionsCounter to insulate the loops from potenial re-entry into the class (disconnectNotify() calls unknown code). Yes, this sheds the QHash's capacity(). If this becomes a problem, it can be fixed by moving oldConnectionsCounter back into m_connectionsCounter, after clear()ing it. Sister change to 485727b41ed777ee9392be8aa770adb1b4415aa6. Change-Id: I73f8a16356258b8af210a8b3e7b00c523ca169e4 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Fix overly generic header include guard nameMarc Mutz2023-08-041-3/+3
| | | | | | | | | | SIGNALHANDLER_H is too generic (and missing _P). Prepend QTWEBCHANNEL_ and add the _P. Pick-to: 6.6 6.5 6.2 5.15 Change-Id: I991eb77fd0279cbf064dde6418b1c9a3e609b7fe Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Fix project structure and auto registryMichal Klocek2023-02-031-1/+0
| | | | | | | | | | | | | | | | | | | Create QtWebChannelQuick and move the required sources, so auto registry works and qml types files and friends are auto generated. This makes things inline what other modules do. This change has a side effect as qqmlwebchannel.h will change its module, however this is semi-pulibc header, hopefully only used by QtWebEngine. [ChangeLog] Created new QtWebChannelQuick which holds qml sources. Task-number: QTBUG-110795 Fixes: QTBUG-99959 Change-Id: Ic8aa72f070d6a9e23d918a1210f4df62df739397 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* SignalHandler: optimize remove(QObject*)Marc Mutz2022-12-251-5/+5
| | | | | | | | | | | | | | | | | | | Don't look up the object in m_connectionCounter three times (contains(), value(), remove()). Instead, use find() to find it once, and std::move(it.value()) + erase() as a take() that can report whether the element existed in the container prior to extraction. This also means we can port the foreach loop to a ranged for loop now without hesitation: by erasing the element from the container before iterating over the QObject::disconnect() calls, we ensure immunity against a potential reentrance into the object (disconnectNotify() calls unknown code) that changes m_connectionsCounter, which the foreach loop was immune against (d/t taking a copy of the container under iteration). Change-Id: I6cf36c729f488bf1334fd344ddd0191db101d103 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Arno Rehn <a.rehn@menlosystems.com>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-2/+2
| | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), 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', with the extended set of container classes recognized. Change-Id: I34d5ddf6742eda92ae291d2fd0ced98fcee92b7b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-101-38/+2
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: Id704376bd7d5a127ad3e9bf09f9abedcf2b0f498 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Make sure all private headers include at least one otherThiago Macieira2022-03-081-1/+2
| | | | | | | | | | See script in qtbase/util/includeprivate for the rules. Since these files are being touched anyway, I also ran the updatecopyright.pl script too. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Handle signals in the registered object's threadMilian Wolff2021-04-161-0/+3
| | | | | | | | | | | | | | | | | | | | | Do not call `sender()` from a different thread. As the API documentation indicates, that is not supported and can lead to crashes as experienced on the CI frequently. Instead, we now have per-thread SignalHandlers and use those to get notified about signals and metacall events. Moving a registered object into a different thread isn't supported once it was registered. But the object can be deregistered, moved, and then re-registered. [ChangeLog] Signals from objects living in a different thread than the QWebChannel are now handled correctly. Task-number: QTBUG-51366 Change-Id: I1edb0694b946a494b6c0d4a8a6dc6b452dcb2c7a Reviewed-by: Arno Rehn <a.rehn@menlosystems.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Use QVariant(QMetaType, const void *) constructorJüri Valdmann2020-09-101-1/+1
| | | | | | | | | The deprecated QVariant(int, const void *) constructor has been removed in qtbase. The QVariant(QMetaType, const void *) constructor should be used instead. Change-Id: I01a22e1334d0e8ae74be7d9c055cb092ac3d1cf6 Reviewed-by: Arno Rehn <a.rehn@menlosystems.com>
* Use QList instead of QVectorJarek Kobus2020-06-291-6/+6
| | | | | | Task-number: QTBUG-84469 Change-Id: Ide3fa7a558b456354703dd7fd5ee414647e24934 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Replace Q_DECL_OVERRIDE with overrideKevin Funk2017-09-211-1/+1
| | | | | Change-Id: I8661063408d17c80a04433beda595061e89b5ba8 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-10-011-1/+1
|\ | | | | | | Change-Id: Ib8b5300d27583018bc7582be41140dfda0ab5309
| * Fix asynchronous signals from QObjects in different threadsDave Andrews2016-09-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switches the signal listener in QWebChannel from using Qt::DirectConnection to Qt::AutoConnection to relay signals from QObjects in different affinities than the QWebChannel. Also adds a unit test in testAsyncObject() to verify that QWebChannel no longer crashes when receiving such a signal, and that such objects can be added and removed dynamically. Task-number: QTBUG-51366 Change-Id: I51a4886286fec9257a21ea95360c1ea8889a584a Reviewed-by: Dave Andrews <jetdog330@hotmail.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7v5.7.0-alpha1Liang Qi2016-02-151-0/+11
|\| | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: I42bfb38e5a9bf03b43636309fe9e29e8d772bb06
| * Add the "We mean it" warning to private headersv5.6.0-rc1v5.6.0Sergio Martins2016-02-091-0/+11
| | | | | | | | | | Change-Id: I34bcf2e4a2d66c9cb126c2edae79a45064b82a67 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | Updated license headersAntti Kokko2016-01-201-14/+20
|/ | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I2fe282e6b9d52f9635cd69e3e8de53724cbb8b0a Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Update copyright headersv5.5.0-alpha1Antti Kokko2015-02-171-6/+6
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: Iebed549451f58a9fbdd86adf5d0340412d7766d7 Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com>
* Fix crash on signal after deregistrationLutz Schönemann2014-12-031-9/+16
| | | | | | | | | | | | | | | Implemented a remove method in SignalHandler that allows us to remove and disconnect an object from SignalHandler w/o decrementing the connection counter until it hits zero or deleting the object That same functionality was used to remove an object from internal lists when receiving a destroyed signal from an object. In case of deregistering an object we haven't received a destoryed signal but simulated reception of that signal and so that code was not called in that case. Change-Id: Ie20cf628a2de028375f5d29f913682e25ebf8d44 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Update license headers and add new licensesJani Heikkinen2014-08-261-18/+10
| | | | | | | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Furthermore we need to update the sync.profile to not point to the dev branch in order to integrate this patch in the CI. Change-Id: I06b5496b5d865e2da4808532362616429c969658 Reviewed-by: Sergio Ahumada <sahumada@blackberry.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Fix compilation when building with namespaced Qt.Milian Wolff2014-01-311-0/+4
| | | | | | | | Wrap everything in the QtWebChannel module with the Qt namespace or use the Qt namespace where appropriate. Change-Id: I1ef2b2f5eb22ec5e04ca76c034ef8ebf4043b899 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fixup license headers of the files written by me.Milian Wolff2014-01-161-3/+2
| | | | | | | | | | | | Some tests referenced Nokia in their license even though that was never the case. The tests where written completely by me after Qt Nokia times. What is missing are the examples which are still mostly original work by Noam back then in Nokia times. The rest was (re-)written by me completely since then anyways. Change-Id: Ib423fb3459bcc1f7464a02de4fd82ddfd614d282 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Simplify usage of QWebChannel on the server side.Milian Wolff2014-01-081-1/+1
| | | | | | | | | | | This is achieved by hiding the MetaObjectPublisher completely as private API. The QWebChannel is the only publisher API and now handles both the socket as well as the publisher internally. This now allows us to create a proper QML api in the new QmlWebChannel. Change-Id: I3096364af8485353ca9bc19df4a81a8e4552c3d7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix assertion at shutdown or on QObject destruction.Milian Wolff2014-01-081-28/+35
| | | | | | | | | | When handling the destroyed signal of a QObject, the QMetaObject of the sender() will point to the global static QObject meta object. Thus, we also cache its signal argument types. This way, we are able to properly handle the destroyed signal with minimum effort. Change-Id: Iba1a3fc94d55adad178302cc847fd4285815e689 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Optimize SignalHandler by obsoleting the call to senderSignalIndex.Milian Wolff2013-12-271-17/+16
| | | | | | | | | This method is quite slow, and can be compared to two calls of sender(). We now encode the signal index in the methodId and thus do not have to call it anymore. The performance gain is about 27% (9.2 vs. 12.7ms). Change-Id: Iaa75efa27a54a21e27e62994de25cafd8136159d Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
* Cleanup and optimize code a bit by calling senderSignalIndex less.Milian Wolff2013-12-271-6/+10
| | | | | | | | | | | | | | Profiling shows that sender() and senderSignalIndex(), which again calls sender() internally, are the hotspots in benchPropertyUpdates. To speed things up a bit, call senderSignalIndex only once whenever a signal is emitted. The performance gain is about 27% (16ms vs. 22ms). While at it, also re-use the global s_destroyedSignalIndex static and also call sender() only once even when assertions are enabled. Change-Id: I90cd1a2b453e5c40d0f41276968f4545b42076bc Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
* Port MetaObjectPublisher benchmarks to C++.Milian Wolff2013-12-271-0/+2
| | | | | | | | | | | This allows us to remove the public API for the tests and allows for more tests and benchmarks in the future. To achieve this, we re-use the new qmetaobjectpublisher_p.h, which then also must be exported. Change-Id: I3c33b2f5be6cc674cd3092667151dd8da2263cf5 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
* Restructure sources and assimilate to Qt module structure.Milian Wolff2013-12-121-0/+278
This module can hopefully be done in time for 5.3. This commit changes the source structure and QMake files to adapt to typical Qt modules. With this in place, we can now use QT += webchannel in qmake files to link against the pure Qt/C++ QtWebChannel library. The QML plugin is separated from it and can be loaded optionally, if the quick module could be found. Also added is now a qmlplugindump for tooling integration. Note that the Qt.labs namespace is removed. The test file structure is also adapted to how its done in the QtDeclarative module. Note that this setup apparently does not support to run tests without running make install first. Change-Id: I1c15d72e7ab5f525d5a6f651f4e965ef86bc17bd Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>