X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fnetwork.cpp;h=fa87a30bbd8d8542afb7debb85a48b633341623c;hb=0268b7f62826dc48155866f7f27b2987449a29f5;hp=8f5680be1a6d21c5599842bbcdc51c0b653f2311;hpb=e2e5327ccade6baf433598b1b25dfe99cb360028;p=quassel.git diff --git a/src/common/network.cpp b/src/common/network.cpp index 8f5680be..fa87a30b 100644 --- a/src/common/network.cpp +++ b/src/common/network.cpp @@ -218,7 +218,6 @@ IrcUser *Network::newIrcUser(const QString &hostmask) { connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickChanged(QString))); connect(ircuser, SIGNAL(initDone()), this, SLOT(ircUserInitDone())); - connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); _ircUsers[nick] = ircuser; emit ircUserAdded(hostmask); emit ircUserAdded(ircuser); @@ -242,7 +241,18 @@ void Network::removeIrcUser(IrcUser *ircuser) { ircuser->deleteLater(); } -void Network::removeIrcUser(QString nick) { +void Network::removeChansAndUsers() { + QList users = ircUsers(); + foreach(IrcUser *user, users) { + removeIrcUser(user); + } + QList channels = ircChannels(); + foreach(IrcChannel *channel, channels) { + removeIrcChannel(channel); + } +} + +void Network::removeIrcUser(const QString &nick) { IrcUser *ircuser; if((ircuser = ircUser(nick)) != 0) removeIrcUser(ircuser); @@ -368,6 +378,8 @@ void Network::setCurrentServer(const QString ¤tServer) { void Network::setConnected(bool connected) { _connected = connected; + if(!connected) + removeChansAndUsers(); emit connectedSet(connected); } @@ -498,17 +510,29 @@ void Network::ircChannelInitDone() { emit ircChannelInitDone(ircchannel); } -void Network::ircUserDestroyed() { - IrcUser *ircuser = static_cast(sender()); - Q_ASSERT(ircuser); - removeIrcUser(ircuser); +void Network::removeIrcChannel(IrcChannel *channel) { + QString chanName = _ircChannels.key(channel); + if(chanName.isNull()) + return; + + _ircChannels.remove(chanName); + disconnect(channel, 0, this, 0); + emit ircChannelRemoved(chanName); + emit ircChannelRemoved(channel); + channel->deleteLater(); +} + +void Network::removeIrcChannel(const QString &channel) { + IrcChannel *chan; + if((chan = ircChannel(channel)) != 0) + removeIrcChannel(chan); } void Network::channelDestroyed() { IrcChannel *channel = static_cast(sender()); Q_ASSERT(channel); - emit ircChannelRemoved(sender()); _ircChannels.remove(_ircChannels.key(channel)); + emit ircChannelRemoved(channel); } void Network::requestConnect() const {