summaryrefslogtreecommitdiff
path: root/src/webchannel/qwebchannel.cpp
diff options
context:
space:
mode:
authorKai Dohmen <psykai1993@googlemail.com>2016-04-28 22:08:55 +0200
committerMilian Wolff <milian.wolff@kdab.com>2016-07-21 09:04:31 +0000
commit43ff11f564d90f7818d741ae4304462938c38438 (patch)
tree2f495575f7b52c27dc3325fea9c60215f3582f82 /src/webchannel/qwebchannel.cpp
parente35346cf70598c47a456946327927643910aa277 (diff)
downloadqtwebchannel-43ff11f564d90f7818d741ae4304462938c38438.tar.gz
Remove deleted transport objects
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>
Diffstat (limited to 'src/webchannel/qwebchannel.cpp')
-rw-r--r--src/webchannel/qwebchannel.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/webchannel/qwebchannel.cpp b/src/webchannel/qwebchannel.cpp
index 1e8ed8f..b591ee1 100644
--- a/src/webchannel/qwebchannel.cpp
+++ b/src/webchannel/qwebchannel.cpp
@@ -75,9 +75,11 @@ QT_BEGIN_NAMESPACE
*/
void QWebChannelPrivate::_q_transportDestroyed(QObject *object)
{
- const int idx = transports.indexOf(static_cast<QWebChannelAbstractTransport*>(object));
+ QWebChannelAbstractTransport *transport = static_cast<QWebChannelAbstractTransport*>(object);
+ const int idx = transports.indexOf(transport);
if (idx != -1) {
transports.remove(idx);
+ publisher->transportRemoved(transport);
}
}
@@ -246,6 +248,7 @@ void QWebChannel::disconnectFrom(QWebChannelAbstractTransport *transport)
disconnect(transport, 0, this, 0);
disconnect(transport, 0, d->publisher, 0);
d->transports.remove(idx);
+ d->publisher->transportRemoved(transport);
}
}