FIRE-4702; Prevent crash due to race condition of llfolderciew being destroyed while still used in a callback.

Nicky 2012-05-29 01:06:07 +02:00
parent bc2d733109
commit eb9d34f65e
2 changed files with 45 additions and 1 deletions

View File

@ -282,11 +282,18 @@ LLFolderView::LLFolderView(const Params& p)
mPopupMenuHandle = menu->getHandle();
mListener->openItem();
mFolderviewProxy = 0; // <FS:ND> FIRE-4702;
}
// Destroys the object
LLFolderView::~LLFolderView( void )
{
// <FS:ND> FIRE-4702;
if( mFolderviewProxy )
mFolderviewProxy->mFolderview = 0;
// </FS:ND>
closeRenamer();
// The release focus call can potentially call the
@ -995,7 +1002,15 @@ void LLFolderView::removeSelectedItems( void )
if (mSelectedItems.empty()) return;
LLSD args;
args["QUESTION"] = LLTrans::getString(mSelectedItems.size() > 1 ? "DeleteItems" : "DeleteItem");
LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLFolderView::onItemsRemovalConfirmation, this, _1, _2));
// <FS:ND> FIRE-4702;
// LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLFolderView::onItemsRemovalConfirmation, this, _1, _2));
mFolderviewProxy = new FolderviewProxy();
mFolderviewProxy->mFolderview = this;
LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&FolderviewProxy::onItemsRemovalConfirmation, mFolderviewProxy, _1, _2));
// </FS:ND>
}
bool isDescendantOfASelectedItem(LLFolderViewItem* item, const std::vector<LLFolderViewItem*>& selectedItems)
@ -2647,3 +2662,16 @@ void properties_selected_items(void* user_data)
fv->propertiesSelectedItems();
}
}
// <FS:ND> FIRE-4702;
void LLFolderView::FolderviewProxy::onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response)
{
if( mFolderview )
{
mFolderview->mFolderviewProxy = 0;
mFolderview->onItemsRemovalConfirmation( notification, response);
}
delete this;
}
// </FS:ND>

View File

@ -341,6 +341,22 @@ public:
static F32 sAutoOpenTime;
LLTextBox* mStatusTextBox;
// <FS:ND> FIRE-4702; When displaying a confirmation dialog to delete items, don't pass
// this, but instead a new proxy objects. this can be destroyed if there is a
// race condition between displaying the confirmation dialog and this folderview
// being populated at the same time.
private:
struct FolderviewProxy
{
void onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response);
LLFolderView *mFolderview;
};
friend struct FolderviewProxy;
FolderviewProxy *mFolderviewProxy;
// </FS:ND>
};
bool sort_item_name(LLFolderViewItem* a, LLFolderViewItem* b);