summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlli Salli <ollisal@gmail.com>2010-12-19 20:28:55 +0200
committerOlli Salli <ollisal@gmail.com>2010-12-19 20:28:57 +0200
commit113c4d08568a26938f95627266f6ec0236888bc2 (patch)
tree3f0fc0eafcff5e8c401d652c4d7bb33497c77469
parent2d034940507e6f722e15a95fd7bf6e5040f4e3c0 (diff)
parent9d93f12e06074dfea65960a7f41c21c631e30418 (diff)
Merge branch 'avoid-useless-cache-drop'
Reviewed-by: Andre Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk>
-rw-r--r--TelepathyQt4/dbus-proxy-factory.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/TelepathyQt4/dbus-proxy-factory.cpp b/TelepathyQt4/dbus-proxy-factory.cpp
index 4554f9a3..5a0e94f5 100644
--- a/TelepathyQt4/dbus-proxy-factory.cpp
+++ b/TelepathyQt4/dbus-proxy-factory.cpp
@@ -248,6 +248,24 @@ void DBusProxyFactory::Cache::put(const DBusProxyPtr &proxy)
DBusProxyPtr existingProxy(proxies.value(key));
if (!existingProxy || existingProxy != proxy) {
+ // Disconnect the invalidated signal from the proxy we're replacing, so it won't uselessly
+ // cause the new (hopefully valid) proxy to be dropped from the cache if it arrives late.
+ //
+ // The window in which this makes a difference is very slim but existent; namely, somebody
+ // must request a proxy from the factory in the same mainloop iteration as an otherwise
+ // matching proxy has invalidated itself. The invalidation signal would be delivered and
+ // processed only during the next mainloop iteration.
+ if (existingProxy) {
+ Q_ASSERT(!existingProxy->isValid());
+ existingProxy->disconnect(
+ SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
+ this,
+ SLOT(onProxyInvalidated(Tp::DBusProxy*)));
+
+ debug() << "Replacing invalidated proxy" << existingProxy.data() << "in cache for name"
+ << existingProxy->busName() << ',' << existingProxy->objectPath();
+ }
+
connect(proxy.data(),
SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
SLOT(onProxyInvalidated(Tp::DBusProxy*)));