aboutsummaryrefslogtreecommitdiffstats
path: root/src/webchannel
Commit message (Collapse)AuthorAgeFilesLines
* Regenerate projectswip/cmakeAlexandru Croitor2019-11-251-6/+5
| | | | | | | Change-Id: Ibdadef34b1b7d4ea98140feed171c409eb8bafde Reviewed-by: Qt CMake Build Bot Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add cmake supportJüri Valdmann2019-09-232-0/+67
| | | | | | | Fixes: QTBUG-78190 Change-Id: Ibdfbcb479ce1af6370b9148516cef6f64e7c1abb Reviewed-by: Qt CMake Build Bot Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Bump Qt version to Qt 6Alexandru Croitor2019-07-111-1/+1
| | | | | | | Also fix usage of text stream operators. Change-Id: I5cca2a07a8f95d4449a528aa0e8ca98c94dda40c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devMilian Wolff2019-05-281-1/+4
|\ | | | | | | | | | | | | Conflicts: src/webchannel/qmetaobjectpublisher.cpp Change-Id: I853b8fc7270847c1a9cdd862dff278ddb2533e92
| * Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-05-181-1/+4
| |\ | | | | | | | | | Change-Id: I182d51367aed4518f5bbc247e4e517af09028f7a
| | * Fix generic conversion of list-like values to JSON arraysArno Rehn2019-05-151-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, QVariant::toList() was used to convert a QVariant to a QVariantList. This only works for actual QVariantLists and QStringList, however. This patch uses QVariant::value<QVariantList>() which works in all cases. A better approach would be to extract a QSequentialIterable, but QTBUG-42016 currently prevents this. Change-Id: I732cc88a6db2ec5d990760364a9db98a52521f6b Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-04-132-7/+7
|\| | | | | | | | | | | Change-Id: I8b70f062015311e0e3827fe001155d6ce1e146d2
| * | Automatically register the latest import versionv5.13.0-beta3Kai Koehne2019-04-122-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This follows what was done in d28c9f6a for Qt Quick Controls 2. The latest import version (e.g. 1.14 in Qt 5.14) will automatically be registered whenever the Qt version is bumped. This avoids needing to wait until a new type is added (or a new revision is added to an existing type) before being able to use the newest Qt Quick version. Change-Id: I2570c2bc50c629101adb763e5e5f90bc3ded8bac Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-03-301-2/+2
|\| | | | | | | | | | | Change-Id: Ida698daaae6d184137358ee49fa2d27b6654d8b3
| * | Doc: Fix some qdoc errorsNico Vertriest2019-03-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | - add documentation to parameter \a objects - correct link to example code Change-Id: Idedfd749dad01315ee0073ca5a87399b9fa30d70 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | | Implement actual overload resolutionArno Rehn2019-03-293-14/+227
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements host-side overload resolution. If a client invokes a method by its name instead of its id, the overload resolution tries to find the best match for the given arguments. The JavaScript client implementation now defaults to invocation-by-name, except when a method is invoked by its full signature. In that case, the invocation is still performed by method id. Change-Id: I09f12bdbfee2e84ff66a1454608468113f96e3ed Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | | Always rebuild the class info for wrapped objectsMilian Wolff2019-03-252-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a new transport is accessing a previously wrapped object, we used to send potentially outdated property values. [ChangeLog][QWebChannel][General] Send current property values when another transport is accessing a previously wrapped object. Fixes: QTBUG-62388 Change-Id: I5cd5772b42c3cb9860e945bb85f77f0e3b6d6ea0 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | | Publish overloaded methods and signals to JavaScriptMilian Wolff2019-03-252-13/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we only published the first method or signal of any given name. We keep this behavior for the nice JavaScript notation that looks like a normal JavaScript method call `foo.bar(...)`. When you need to call a different overloaded method, this patch offers you to specify the explicit signature on the JavaScript side. I.e. when we have an object with `foo(int i)` and `foo(const QString &str, int i)`, then on the JavaScript a call to `obj.foo(...)` will always call the first method like before. But now you can specify the full QMetaMethod signature and call matching methods explicitly via `obj["foo(int)"]` or `obj["foo(QString,int)"]`. Automatic overload resolution on the C++ side for the nice notation cannot easily be implemented: We need to know the return value of the called function, otherwise we cannot construct a valid QGenericReturnArgument. Furthermore, we wouldn't be able to differentiate between e.g. any numeric types on the C++ side, since JavaScript only has a single `double` type internally. [ChangeLog][QWebChannel][General] It is now possible to explicitly call overloaded methods or connect to overloaded signals by specifying the full method or signal signature in string form on the JavaScript side. Fixes: QTBUG-73010 Change-Id: I4645edee97af56fd8d126e77d70dc33ed3513deb Reviewed-by: Arno Rehn <a.rehn@menlosystems.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-02-261-0/+3
|\| | | | | | | | | | | Change-Id: Ife028425ea8c14d972c2df59071a9333352af7d1
| * | Merge remote-tracking branch 'origin/5.12' into 5.13v5.13.0-beta1Liang Qi2019-02-251-0/+3
| |\| | | | | | | | | | | | | | | | | | | | | | Conflicts: src/webchannel/qmetaobjectpublisher.cpp Done-With: Arno Rehn <a.rehn@menlosystems.com> Change-Id: I763a76cf055547c5c5e59511ded51c467d6c7526
| | * Also add already wrapped objects to the transport-to-objects mapArno Rehn2019-02-041-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes a crash: Previously, when a connection was closed, the transport was not removed from the list of transports of a wrapped objects. This was because the transport was not added to the transport-to-object map in the first place. When a property update was pushed, the now dangling pointer to the "old" transport caused a crash. Change-Id: Ib980f0b874851f8f85f7a3d76d51a2c884504b96 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
| | * Correctly unwrap registered objectsArno Rehn2019-02-041-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, only implicitly wrapped objects have been successfully unwrapped. "Officially" registered objects were not, and thus could not be passed to properties or as method arguments. Change-Id: I6b8644ed3be8db3a66c2c1d5bc167fc33a0b4165 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | | Convert QObjects in QVariantMapsAndrew Webster2019-02-062-0/+20
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QObjects that are present in an array are already converted to an object identifier. This does the same for variant maps, which end up as ECMAScript objects. This allows QObjects put into a QVariantMap to be properly deserialized. For example, if a property is declared as such: Q_PROPERTY(QVariantMap propName READ propName CONSTANT) And propName is: QVariantMap propName() const { QVariantMap map; map.insert("theProperty", QVariant::fromValue(someQObject)); return map; } The "theProperty" property will now properly refer to the object. Change-Id: I3c6e71b860f6825a31eb337aeffa55302287c8ff Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | Merge remote-tracking branch 'origin/5.12' into 5.13v5.13.0-alpha1Qt Forward Merge Bot2019-02-021-5/+34
|\| | | | | | | Change-Id: I6b83cc26dddfafe3bebe1bfb3640e2daf2d9a8fb
| * Correctly convert enums and QFlags from and to JSONArno Rehn2019-01-311-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, enums declared with Q_ENUM were stringified in the conversion to JSON and QFlags did not work at all. The conversion of QJsonValue(int) to enum worked fine, however. This patch implements some extra logic for detecting enums and QFlags, thus correctly converting to and from integers. [ChangeLog] Enum values and QFlags are now correctly converted to and from integers in the JS interface Fixes: QTBUG-72924 Change-Id: I23d4a1120b805201c8d450edbd990aad5ad258a2 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
| * Remove warning when the notify signal has more than one argumentArno Rehn2019-01-231-5/+0
| | | | | | | | | | | | | | | | | | The warning was not meaningful, since nothing depends on the notify signal having only zero or one argument(s). Removing this decreases warning noise in some applications. Change-Id: Ieb716ad9ac51296a1e17899018d4e6190043b8d5 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Prevent crashes by fixing mapping of transport to wrapped objectsMilian Wolff2018-10-251-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an already-wrapped object was used by a secondary transport, the mapping was not updated. This could then lead to crashes when the transport was destroyed. [ChangeLog][General] Fix crash when wrapped objects are shared across multiple transports. Task-number: QTBUG-62388 Change-Id: I3c3b7302205e10f04695f1a202325704d90950d2 Reviewed-by: Kai Dohmen <psykai1993@googlemail.com> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | Fix UBSAN warning when downcasting partially destroyed objectMilian Wolff2018-10-251-4/+6
|/ | | | | | | | | | | This patch fixes the runtime warning cought by UBSAN: src/webchannel/qwebchannel.cpp:84:96: runtime error: downcast of address 0x6030001b1570 which does not point to an object of type 'QWebChannelAbst Change-Id: I9c78f94bc97961ef69b71ecca8a9301d81feaf3a Reviewed-by: Kai Dohmen <psykai1993@googlemail.com> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Use FDL license for all .qdoc filesKai Koehne2018-05-231-21/+9
| | | | | Change-Id: I039e3a47ca2c3889c3272f81fafb3997777881f6 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Doc: Add license details to index pageKai Koehne2018-05-141-0/+9
| | | | | Change-Id: I7ef0f2d7c760fcb4016e925ae5cd94fc158b53a6 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Merge remote-tracking branch 'origin/5.10' into devLiang Qi2018-01-201-3/+9
|\ | | | | | | | | | | | | Conflicts: tests/auto/webchannel/tst_webchannel.h Change-Id: I454c1bbab153405541e7fc41d1389a810b94f2db
| * Allow deleting a channel during method invocationJüri Valdmann2018-01-081-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | A real-life use case is the session restore page in KDE Falkon or, more generally, any kind of closeTab() method exposed to JS in a QWebEnginePage. The approach taken in this patch will only work if the transport can also deal with deletion during a messageReceived signal emission. Alternatively, method invocation could be delayed via the event loop, but this would come with an obvious performance penalty. Change-Id: I2940f61e07c77365f6e3e7cd29463d4cb5b525a6 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | Merge remote-tracking branch 'origin/5.10' into devLiang Qi2017-11-204-12/+12
|\| | | | | | | Change-Id: I5fb1c52b54156c53719734fae7625dd7e1941fed
| * Fix outdated FDL headerKai Koehne2017-09-294-12/+12
| | | | | | | | | | Change-Id: I5a200b078a6d3485cd6277f79902aca8021b6770 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | Merge remote-tracking branch 'origin/5.10' into devLiang Qi2017-09-223-428/+3
|\| | | | | | | Change-Id: I0b7d3d5789c0c3ef11d96c83c3f61d0de65f3593
| * Highlight standalone exampleKai Koehne2017-09-141-0/+2
| | | | | | | | | | | | | | | | Highlighted examples will show up prominently in the Qt Creator Welcome screen. Change-Id: I59f55ff9e3e7ff737dcbe22b9265eb7149588358 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
| * Allow examples to be built without module sourcesKai Koehne2017-09-062-428/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qwebchannel.js is used by examples, which so far tried to copy it directly from the library source directory. However, in the case of an installed prefix build of Qt, the library sources are not available. This patches therefore moves the qwebchannel.js file to the examples directory, which is installed including sources. The obvious alternative would be copying the file inside the source tree, but that causes code duplication and a maintenance burden that we want to avoid. Another alternative would have been to install qwebchannel.js into QT_INSTALL_DATA, or extract the file at build time from the Qt library. However, this requires bigger changes, and is also dubious because the use case are in particular applications _not_ using Qt. Task-number: QTBUG-57654 Change-Id: I96bc93b6e3d248e4b4facdd582d9fa53ae562924 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | Replace Q_DECL_OVERRIDE with overrideKevin Funk2017-09-212-2/+2
|/ | | | | Change-Id: I8661063408d17c80a04433beda595061e89b5ba8 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Do not crash on non-QVariant return typesMilian Wolff2017-08-081-2/+2
| | | | | | | | | | | | | Patch e354bdc5 introduced a regression that triggers a crash in Qt 5.9 when returning a type that is not implicitly convertible to QVariant, such as a QJsonValue, from an invoked method/slot. This patch fixes this situation and adds proper unit test coverage. Change-Id: Ib8cb0c96e7496bc8dc9a628245d7a44e4234aff0 Task-number: QTBUG-62045 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> Reviewed-by: Kai Dohmen <psykai1993@googlemail.com>
* Gracefully handle early deregistration of objectsMilian Wolff2017-05-151-2/+6
| | | | | | | | | | | When an object is deregistered before the signal handler got initializated, we asserted. Now, we check for this case and skip the signal handler removal when it wasn't set up yet. Change-Id: I7abad204cbab72be7729d42f58ce63babd2310d8 Task-number: QTBUG-60250 Reviewed-by: Kai Dohmen <psykai1993@googlemail.com> Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
* Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-11-262-11/+15
|\ | | | | | | Change-Id: I09a494a9b94ce169d60e77f4bffa8845db01293a
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-10-012-11/+15
| |\ | | | | | | | | | 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>
| | * Fix asynchronous method calls on QObjects in different threadsDave Andrews2016-09-291-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use QMetaMethod::invoke without a return for void method calls, which allows making asynchronous method calls onto QObjects in different affinities than the QWebChannel that's emitting them. Also adds a unit test called testAsyncObject that intentionally places a QObject in a different affinity and then tests calls into it from the QWebChannel's synchronous publisher. Task-number: QTBUG-47678 Change-Id: I6c35ee54f764c0fc1b0431fb0774aa7e75039abf Reviewed-by: Dave Andrews <jetdog330@hotmail.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-013-1/+35
| |\| | | | | | | | | | Change-Id: If2a4f50d03fccc2654b8336d9e40daea85d6adca
| | * Remove deleted transport objectsKai Dohmen2016-07-213-1/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a QMultiHash which maps transport objects to wrapped object ids. transportRemoved iterates over all matching wrapped objects and removes the passed transport object from their transports-vector. If the transports-vector is empty after removing the passed transport object the objectDestroyed will be called on the wrapped object. transportRemoved will be called either on the transports destoryed signal or on disconnecting the webchannel from it. Without this changes the QMetaObjectPublisher::wrappedObjects and ::registeredObjectIds would only be cleaned up if the website calls deleteLater on QObjects but not on website reloads. Task-number: QTBUG-50074 Change-Id: If294564fee2406edd7fb578852aeb269cac23a92 Reviewed-by: Milian Wolff <milian.wolff@kdab.com> (cherry picked from commit fa2374d7c4dedea907e2df26fdad28bdee73b122) Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* | | Merge remote-tracking branch 'origin/5.7' into devEdward Welbourne2016-07-2111-57/+196
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/webchannel/doc/src/index.qdoc src/webchannel/qwebchannelabstracttransport.cpp Overlapping changes to documentation; constructed hybrid. src/webchannel/qmetaobjectpublisher.cpp tests/auto/webchannel/tst_webchannel.cpp tests/auto/webchannel/tst_webchannel.h Both sides made additions; in the same place. Change-Id: Iff12970978b70946dc3e1290841aca2d35c9c1d0
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Edward Welbourne2016-07-158-54/+134
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Alleged Conflicts: examples/webchannel/chatclient-html/doc/src/chatclient-html.qdoc examples/webchannel/chatclient-qml/doc/src/chatclient-qml.qdoc examples/webchannel/chatserver-cpp/doc/src/chatserver-cpp.qdoc In each case, the two sides agreed byte-for-byte. Not quite sure what git thought the conflict was ! Change-Id: I5da9695b667f4112848c520b630ab1304d61cea3
| | * Properly unwrap QObject signal parameters on the JavaScript side.Milian Wolff2016-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This enables you to pass `QObject*` parameters via signals to the JavaScript side. The object will be serialized and then unwrapped as needed now. Task-number: QTBUG-54243 Change-Id: Ie8a6d14eb1351f14f1855d242ceb3b3f8262152d Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com>
| | * Make passing objects from website to server possibleKai Dohmen2016-06-213-27/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you get an object from the server and want to pass it back to the server via a function the id of the object is passed instead of the whole json object. On the server side QMetaObjectPublisher::invokeMethod now looks up the object in QMetaObjectPublisher::wrappedObjects by the passed object-id. Task-number: QTBUG-50075 Change-Id: Id0df2dfaa79bcba12ca48391ae7537ac1a086898 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
| | * Doc: Fix linking to methods and properties within the typeLeena Miettinen2016-06-011-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | You don't need the type name for linking within the type docs. Also, the convention in QML and Qt Quick is to use a period and not a double colon. Change-Id: Ic93bae51e766ef782f089ce69dc4e54a712445c6 Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
| | * Doc: Use 3rd person singular verb form to begin method docsLeena Miettinen2016-06-011-4/+5
| | | | | | | | | | | | | | | | | | | | | And fix a typo "connectect". Change-Id: I14c4b249af3cad142a5f6042b2059f653a9c3eae Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
| | * Doc: Use standard verb form to start function docsLeena Miettinen2016-05-312-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | For consistency, the first verb should be in 3rd person singular form. Change-Id: I5e24ecbbac1b1ab85e737f127b021f24a55c8dd4 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
| | * Doc: Fix links to other modulesLeena Miettinen2016-05-313-13/+11
| | | | | | | | | | | | | | | | | | | | | -Remove references to Qt WebKit Change-Id: I0bd184021b1a87828e93f5783c38b9ba97f37763 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
| | * Doc: Edit the index pageLeena Miettinen2016-05-311-8/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove reference to Qt WebKit - Add Getting Started section - Use standard section titles for API Reference and Examples Change-Id: Ie5e3ac792a109f680132a79e86d5e1065f4c3829 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>