MAINT-1514 Viewer crashes while user trying to invite all friends to the group

* Enforce 100 max invites at the 'add to list' stage instead of only at 'sent to server'
* Cache the IDs in the list locally to avoid horrible performance pattern
meow-7.2.2
Kelly Washington 2013-01-17 10:54:01 -08:00
parent 3c08dccd5c
commit c0566aad4f
1 changed files with 21 additions and 14 deletions

View File

@ -85,6 +85,7 @@ public:
std::string mAlreadyInGroup;
std::string mTooManySelected;
bool mConfirmedOwnerInvite;
std::set<LLUUID> mInviteeIDs;
void (*mCloseCallback)(void* data);
@ -110,31 +111,30 @@ LLPanelGroupInvite::impl::~impl()
{
}
const S32 MAX_GROUP_INVITES = 100; // Max invites per request. 100 to match server cap.
void LLPanelGroupInvite::impl::addUsers(const std::vector<std::string>& names,
const uuid_vec_t& agent_ids)
{
std::string name;
LLUUID id;
if (names.size() + mInviteeIDs.size() > MAX_GROUP_INVITES)
{
// Fail! Show a warning and don't add any names.
LLSD msg;
msg["MESSAGE"] = mTooManySelected;
LLNotificationsUtil::add("GenericAlert", msg);
return;
}
for (S32 i = 0; i < (S32)names.size(); i++)
{
name = names[i];
id = agent_ids[i];
// Make sure this agent isn't already in the list.
bool already_in_list = false;
std::vector<LLScrollListItem*> items = mInvitees->getAllData();
for (std::vector<LLScrollListItem*>::iterator iter = items.begin();
iter != items.end(); ++iter)
{
LLScrollListItem* item = *iter;
if (item->getUUID() == id)
{
already_in_list = true;
break;
}
}
if (already_in_list)
if (mInviteeIDs.find(id) != mInviteeIDs.end())
{
continue;
}
@ -145,6 +145,7 @@ void LLPanelGroupInvite::impl::addUsers(const std::vector<std::string>& names,
row["columns"][0]["value"] = name;
mInvitees->addElement(row);
mInviteeIDs.insert(id);
}
}
@ -186,7 +187,6 @@ void LLPanelGroupInvite::impl::submitInvitations()
role_member_pairs[item->getUUID()] = role_id;
}
const S32 MAX_GROUP_INVITES = 100; // Max invites per request. 100 to match server cap.
if (role_member_pairs.size() > MAX_GROUP_INVITES)
{
// Fail!
@ -325,6 +325,12 @@ void LLPanelGroupInvite::impl::handleRemove()
mInvitees->getAllSelected();
if (selection.empty()) return;
std::vector<LLScrollListItem*>::iterator iter;
for(iter = selection.begin(); iter != selection.end(); ++iter)
{
mInviteeIDs.erase( (*iter)->getUUID() );
}
// Remove all selected invitees.
mInvitees->deleteSelectedItems();
mRemoveButton->setEnabled(FALSE);
@ -430,6 +436,7 @@ void LLPanelGroupInvite::clear()
mImplementation->mRoleNames->clear();
mImplementation->mRoleNames->removeall();
mImplementation->mOKButton->setEnabled(FALSE);
mImplementation->mInviteeIDs.clear();
}
void LLPanelGroupInvite::addUsers(uuid_vec_t& agent_ids)