diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2019-03-22 10:47:29 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2019-03-25 12:28:51 +0000 |
commit | 857cfc1adecd72750cea26d4c91371f4aaf9a68f (patch) | |
tree | a0c9e9b0822efbd390a4db83957ad02ccfbb6307 /examples | |
parent | 8b701450aeceb878784879eaf65dc42d5befd3a5 (diff) | |
download | qtwebchannel-857cfc1adecd72750cea26d4c91371f4aaf9a68f.tar.gz |
Only connect to signal once per client object
We only disconnect once when all signals are disconnected, so we
should also only connect at most once per signal.
Change-Id: Ib3a866c3942bec5e06e3b301315bc83cdb972fab
Reviewed-by: Arno Rehn <a.rehn@menlosystems.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/webchannel/shared/qwebchannel.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/examples/webchannel/shared/qwebchannel.js b/examples/webchannel/shared/qwebchannel.js index d75e148..1e0d72a 100644 --- a/examples/webchannel/shared/qwebchannel.js +++ b/examples/webchannel/shared/qwebchannel.js @@ -261,9 +261,16 @@ function QObject(name, data, webChannel) object.__objectSignals__[signalIndex] = object.__objectSignals__[signalIndex] || []; object.__objectSignals__[signalIndex].push(callback); - if (!isPropertyNotifySignal && signalName !== "destroyed") { - // only required for "pure" signals, handled separately for properties in propertyUpdate - // also note that we always get notified about the destroyed signal + // only required for "pure" signals, handled separately for properties in propertyUpdate + if (isPropertyNotifySignal) + return; + + // also note that we always get notified about the destroyed signal + if (signalName === "destroyed") + return; + + // and otherwise we only need to be connected only once + if (object.__objectSignals__[signalIndex].length == 1) { webChannel.exec({ type: QWebChannelMessageTypes.connectToSignal, object: object.__id__, |