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:19:34 +0000 (21:19 +0100)
commit44212b2131e958c40ca26b9f49289590d8f83145
treeab5a71891a8fabd722dc276a388cf44e920bcb97
parenta6c419727506abd19f41d8de6e02de015a7aa8e5
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