Fixed potential crash if RelationInfo should not exist, which I saw

once while a decline was in progress), started some minor refactoring.
This commit is contained in:
hiker 2014-03-18 07:48:52 +11:00
parent ce12ebe9ce
commit e9367dd1c9
2 changed files with 25 additions and 3 deletions

View File

@ -278,6 +278,24 @@ void UserInfoDialog::declineFriendRequest()
} // declineFriendRequest
// -----------------------------------------------------------------------------
/** Removes an existing friend.
*/
void UserInfoDialog::removeExistingFriend()
{
CurrentUser::get()->requestRemoveFriend(m_profile->getID());
} // removeExistingFriend
// -----------------------------------------------------------------------------
/** Removes a pending friend request.
*/
void UserInfoDialog::removePendingFriend()
{
CurrentUser::get()->requestCancelFriend(m_profile->getID());
} // removePendingFriend
// -----------------------------------------------------------------------------
GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& eventSource)
{
@ -304,10 +322,12 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
}
else if(selection == m_remove_widget->m_properties[PROP_ID])
{
if(m_profile->getRelationInfo()->isPending())
CurrentUser::get()->requestCancelFriend(m_profile->getID());
if (m_profile->getRelationInfo() &&
m_profile->getRelationInfo()->isPending() )
removePendingFriend();
else
CurrentUser::get()->requestRemoveFriend(m_profile->getID());
removeExistingFriend();
m_processing = true;
m_options_widget->setDeactivated();
return GUIEngine::EVENT_BLOCK;

View File

@ -63,6 +63,8 @@ private:
void sendFriendRequest();
void acceptFriendRequest();
void declineFriendRequest();
void removeExistingFriend();
void removePendingFriend();
public:
UserInfoDialog(uint32_t showing_id, const core::stringw info = "", bool error = false, bool from_queue = false);