X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fircchannel.cpp;h=387a2702fbec4fc37c008ef4aa760d49adbf4f4c;hp=976375d6769ab9b79469e0de2b7d7b4d28821ea3;hb=a5dfcc8ecf8b81025d24b3c5c816169e3e030ea4;hpb=70ed7f4b13ab21a9b3dcb61386b56ad324ed697d diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index 976375d6..387a2702 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -43,6 +43,9 @@ IrcChannel::IrcChannel(const QString &channelname, Network *network) setObjectName(QString::number(network->networkId().toInt()) + "/" + channelname); } +IrcChannel::~IrcChannel() { +} + // ==================== // PUBLIC: // ==================== @@ -137,14 +140,15 @@ void IrcChannel::joinIrcUsers(const QList &users, const QStringList & IrcUser *ircuser; for(int i = 0; i < users.count(); i++) { ircuser = users[i]; - if(!ircuser || _userModes.contains(ircuser)) + if(!ircuser || _userModes.contains(ircuser)) { + addUserMode(ircuser, modes[i]); continue; + } _userModes[ircuser] = modes[i]; ircuser->joinChannel(this); - //qDebug() << "JOIN" << name() << ircuser->nick() << ircUsers().count(); connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickSet(QString))); - connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); + // connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); // if you wonder why there is no counterpart to ircUserJoined: // the joines are propagted by the ircuser. the signal ircUserJoined is only for convenience @@ -183,13 +187,23 @@ void IrcChannel::part(IrcUser *ircuser) { if(isKnownUser(ircuser)) { _userModes.remove(ircuser); ircuser->partChannel(this); - //qDebug() << "PART" << name() << ircuser->nick() << ircUsers().count(); // if you wonder why there is no counterpart to ircUserParted: // the joines are propagted by the ircuser. the signal ircUserParted is only for convenience disconnect(ircuser, 0, this, 0); emit ircUserParted(ircuser); - if(network->isMe(ircuser)) - deleteLater(); + + if(network->isMe(ircuser) || _userModes.isEmpty()) { + // in either case we're no longer in the channel + // -> clean up the channel and destroy it + QList users = _userModes.keys(); + _userModes.clear(); + foreach(IrcUser *user, users) { + disconnect(user, 0, this, 0); + user->partChannel(this); + } + emit parted(); + network->removeIrcChannel(this); + } } } @@ -429,7 +443,7 @@ void IrcChannel::removeChannelMode(const QChar &mode, const QString &value) { return; case Network::A_CHANMODE: if(_A_channelModes.contains(mode)) - _A_channelModes[mode].removeOne(value); + _A_channelModes[mode].removeAll(value); break; case Network::B_CHANMODE: