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

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