From 3439fc6d10d49edb1af23fd2f4ebb688692475d7 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Fri, 11 Jul 2008 20:56:29 +0200 Subject: [PATCH] this should hopefully fix the dreaded BR #140 (sync to core hangs) --- src/common/network.cpp | 25 +++++++++++++++++++++++++ src/common/network.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/src/common/network.cpp b/src/common/network.cpp index cfcda7de..2e10c048 100644 --- a/src/common/network.cpp +++ b/src/common/network.cpp @@ -208,6 +208,7 @@ void Network::ircUserDestroyed() { QHash::iterator ircUserIter = _ircUsers.begin(); while(ircUserIter != _ircUsers.end()) { if(ircUser == *ircUserIter) { + emit deletedIrcUserRemoved(ircUserIter.key()); ircUserIter = _ircUsers.erase(ircUserIter); break; } @@ -215,6 +216,30 @@ void Network::ircUserDestroyed() { } } +void Network::removeDeletedIrcUser(const QString &username) { + // DO NOT CALL THIS SLOT EVER!!! + + // this slots purpose is only to remove deleted users that haven't been synced yet. + // Reason: + // as a user parting a channel results in it's deletion if it is no longer in any known channel + // this action can only be communicated if the slaves are allready in sync. + // so if such a deleted user isn't synced in slave mode, we kill and remove it. + + Q_ASSERT(proxy()); + + if(!_ircUsers.contains(username)) + return; + + IrcUser *ircUser = _ircUsers[username]; + + if(ircUser->isInitialized()) + return; + + _ircUsers.remove(username); + emit ircUserRemoved(username); + emit ircUserRemoved(ircUser); +} + void Network::removeIrcUser(IrcUser *ircuser) { QString nick = _ircUsers.key(ircuser); if(nick.isNull()) diff --git a/src/common/network.h b/src/common/network.h index 3759e565..97046465 100644 --- a/src/common/network.h +++ b/src/common/network.h @@ -204,6 +204,7 @@ public slots: inline void addIrcUser(const QString &hostmask) { newIrcUser(hostmask); } inline void addIrcChannel(const QString &channel) { newIrcChannel(channel); } + void removeDeletedIrcUser(const QString &username); void removeIrcUser(const QString &nick); void removeIrcChannel(const QString &channel); @@ -274,6 +275,7 @@ signals: void ircChannelAdded(const QString &channelname); void ircChannelAdded(IrcChannel *); + void deletedIrcUserRemoved(const QString &username); void ircUserRemoved(const QString &nick); void ircChannelRemoved(const QString &channel); -- 2.20.1