X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fircchannel.cpp;h=28d6c6ed46f9d0294607f4d068dc23fc71efc4b8;hp=2233861bd3f8f2d03f1e5bc4bf2bcaa929d2ad4a;hb=1956aab57bf98ce072ed86f34785e5d7abba35a0;hpb=988bcf1fc63b31947e3ce816c456c1b1a919d8ef diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index 2233861b..28d6c6ed 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -107,7 +107,10 @@ void IrcChannel::join(IrcUser *ircuser) { if(!_userModes.contains(ircuser) && ircuser) { _userModes[ircuser] = QString(); ircuser->joinChannel(name()); - // no emit here since the join is propagated by IrcUser + 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 + emit ircUserJoined(ircuser); } } @@ -119,7 +122,9 @@ void IrcChannel::part(IrcUser *ircuser) { if(isKnownUser(ircuser)) { _userModes.remove(ircuser); ircuser->partChannel(name()); - // no emit here since the part is propagated by IrcUser + // if you wonder why there is no counterpart to ircUserParted: + // the joines are propagted by the ircuser. the signal ircUserParted is only for convenience + emit ircUserParted(ircuser); } } @@ -175,10 +180,10 @@ void IrcChannel::removeUserMode(const QString &nick, const QString &mode) { // INIT SET USER MODES QVariantMap IrcChannel::initUserModes() const { QVariantMap usermodes; - QHashIterator iter(_userModes); - while(iter.hasNext()) { - iter.next(); + QHash::const_iterator iter = _userModes.constBegin(); + while(iter != _userModes.constEnd()) { usermodes[iter.key()->nick()] = iter.value(); + iter++; } return usermodes; } @@ -192,11 +197,9 @@ void IrcChannel::initSetUserModes(const QVariantMap &usermodes) { } void IrcChannel::ircUserDestroyed() { - IrcUser *ircUser = qobject_cast(sender()); - // in case this assert triggers we probably need a static_cast - // dynamic_casts seem to screw things up when using the destroyed signal + IrcUser *ircUser = static_cast(sender()); Q_ASSERT(ircUser); - part(ircUser); + _userModes.remove(ircUser); } void IrcChannel::setInitialized() {