Simplify clean-up-on-network-disconnect handling
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 2 Mar 2014 20:19:34 +0000 (21:19 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 2 Mar 2014 20:30:09 +0000 (21:30 +0100)
commit670743897bc3b96b17a7fdad3f672637b46ea302
tree6bb0e3b6fa456bfe7ab3967182ec7711fb749469
parent05c43ed7ab8eca002538670970cff4edb66f1011
Simplify clean-up-on-network-disconnect handling

Previously, disconnecting from a network would trigger lots of unnecessary
stuff: because the NetworkModel needs to remove affected IrcChannels and
IrcUsers from its model items, we would trigger (on the core side!) an
IrcUser::quit() for every known user in that network, which would then remove
itself from all channels it's in, triggering the corresponding updates in the
related SyncableObjects, which would send lots of signals to the client which
would then perform its own cleanups per IrcUser, followed by throwing away
all IrcChannels and IrcUsers in that network anyway. By the time we reached
Network::removeChansAndUsers(), everything would actually be already all
gone triggered through syncobject updates.

Except in some rare cases when there was still something left behind, triggering
the dreaded "!_ircChannel && ircChannel" assert, that users have been reporting
for years. I still haven't figured out how that could possibly happen.

In any case, the only side effect that explicit call to IrcUser::quit() was
supposed to trigger was the removal of the relevant references in NetworkModel's
items. So now we just brutally delete all IrcUsers and IrcChannels on disconnect,
and have the NetworkModel items listen to the relevant destroyed() signals so
they can do their cleanup. This saves us from sending lots of stuff over the
network, and also should fix the assert (which we've replaced by a warning now,
just in case).

Fixes #1151 and a bunch of duplicates.
src/client/networkmodel.cpp
src/client/networkmodel.h
src/common/network.cpp