From cd23d0d8a01583b7a5289821c27372ef9f6443e1 Mon Sep 17 00:00:00 2001 From: Tobias Markmann <tm@ayena.de> Date: Tue, 28 Mar 2017 16:13:00 +0200 Subject: Remove nullptr checks that are not needed One must pass a valid AvatarManager instance to the MUCController. Asserted the fact at the beginning of the actor. Coverity raised this issue. Test-Information: All unit tests pass on macOS 10.12.4 and Swift client can join MUC conversations without crashing or other noticeable issues. Change-Id: Ibc643f907a31fd1253c63c9a4cef79407d1f96ec diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index b673bfd..e65bfa6 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -7,6 +7,7 @@ #include <Swift/Controllers/Chat/MUCController.h> #include <algorithm> +#include <cassert> #include <memory> #include <boost/bind.hpp> @@ -99,6 +100,8 @@ MUCController::MUCController ( VCardManager* vcardManager, MUCBookmarkManager* mucBookmarkManager) : ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, muc->getJID(), nickResolver, presenceOracle, avatarManager, useDelayForLatency, uiEventStream, eventController, timerFactory, entityCapsProvider, historyController, mucRegistry, highlightManager, chatMessageParser, autoAcceptMUCInviteDecider), muc_(muc), nick_(nick), desiredNick_(nick), password_(password), renameCounter_(0), isImpromptu_(isImpromptu), isImpromptuAlreadyConfigured_(false), clientBlockListManager_(clientBlockListManager), mucBookmarkManager_(mucBookmarkManager) { + assert(avatarManager_); + parting_ = true; joined_ = false; lastWasPresence_ = false; @@ -156,9 +159,8 @@ MUCController::MUCController ( if (stanzaChannel->isAvailable()) { MUCController::setOnline(true); } - if (avatarManager_ != nullptr) { - avatarChangedConnection_ = (avatarManager_->onAvatarChanged.connect(boost::bind(&MUCController::handleAvatarChanged, this, _1))); - } + avatarChangedConnection_ = (avatarManager_->onAvatarChanged.connect(boost::bind(&MUCController::handleAvatarChanged, this, _1))); + MUCController::handleBareJIDCapsChanged(muc->getJID()); eventStream_->onUIEvent.connect(boost::bind(&MUCController::handleUIEvent, this, _1)); @@ -465,9 +467,7 @@ void MUCController::handleOccupantJoined(const MUCOccupant& occupant) { onActivity(""); } } - if (avatarManager_ != nullptr) { - handleAvatarChanged(jid); - } + handleAvatarChanged(jid); } void MUCController::addPresenceMessage(const std::string& message) { @@ -796,9 +796,7 @@ void MUCController::handleOccupantNicknameChanged(const std::string& oldNickname std::string groupName(roleToGroupName(role)); roster_->addContact(newJID, realJID, newNickname, groupName, avatarManager_->getAvatarPath(newJID)); roster_->applyOnItems(SetMUC(newJID, role, affiliation)); - if (avatarManager_ != nullptr) { - handleAvatarChanged(newJID); - } + handleAvatarChanged(newJID); clearPresenceQueue(); onUserNicknameChanged(oldNickname, newNickname); -- cgit v0.10.2-6-g49f6