RoomList: do not blindly dereference RoomState (#232)

This can happen when a new room is being created from a different client and thus is created
with no known state to the local client.
This commit is contained in:
William Pitcock 2018-02-11 06:39:06 -06:00 committed by mujx
parent ba8faa357f
commit 0be787f1e4

View file

@ -199,12 +199,15 @@ RoomList::sync(const std::map<QString, QSharedPointer<RoomState>> &states,
addRoom(settings.at(state.first), state.second, state.first);
auto room = rooms_[state.first];
auto room_state = room->state();
auto current_avatar = room->state()->getAvatar();
if (room_state) {
auto current_avatar = room_state->getAvatar();
auto new_avatar = state.second->getAvatar();
if (current_avatar != new_avatar && !new_avatar.toString().isEmpty())
updateAvatar(state.first, new_avatar.toString());
}
room->setState(state.second);
}