From 148c3780e164d5bc94fa14b418e85fee72f9fd39 Mon Sep 17 00:00:00 2001
From: Merov Linden <merov@lindenlab.com>
Date: Wed, 13 Nov 2013 13:29:51 -0800
Subject: MAINT-3320 : WIP : Introduced a cleanOutbox() method to be called on
 outbox deletion

---
 indra/newview/llfloateroutbox.cpp  | 43 +++++++++++++++++++++++++++++++++-----
 indra/newview/llfloateroutbox.h    |  1 +
 indra/newview/llinventorypanel.cpp |  1 +
 3 files changed, 40 insertions(+), 5 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llfloateroutbox.cpp b/indra/newview/llfloateroutbox.cpp
index 15d078db36..f8de91715c 100755
--- a/indra/newview/llfloateroutbox.cpp
+++ b/indra/newview/llfloateroutbox.cpp
@@ -163,6 +163,38 @@ BOOL LLFloaterOutbox::postBuild()
 	return TRUE;
 }
 
+void LLFloaterOutbox::cleanOutbox()
+{
+    /*
+	// Create a new category creation observer
+	if (mCategoryAddedObserver == NULL)
+	{
+        mCategoryAddedObserver = new LLOutboxAddedObserver(this);
+        gInventory.addObserver(mCategoryAddedObserver);
+	}
+	llassert(mCategoryAddedObserver);
+	
+	// Delete the observer for outbox modifications
+	if (mCategoriesObserver)
+	{
+		gInventory.removeObserver(mCategoriesObserver);
+		delete mCategoriesObserver;
+        mCategoriesObserver = NULL;
+	}
+	llassert(!mCategoriesObserver);
+     */
+	
+	// Clear the outbox data
+    mOutboxId.setNull();
+    mOutboxItemCount = 0;
+    
+    // Note: we cannot delete the mOutboxInventoryPanel as that point
+    // as this is called through callback observers of the panel itself.
+    // Doing so crashes rapidly.
+	
+    llinfos << "Merov : cleanOutbox!" << llendl;
+}
+
 void LLFloaterOutbox::onClose(bool app_quitting)
 {
 	if (mWindowShade)
@@ -303,7 +335,7 @@ void LLFloaterOutbox::setStatusString(const std::string& statusString)
 
 void LLFloaterOutbox::updateFolderCount()
 {
-	if (mOutboxInventoryPanel.get())
+	if (mOutboxInventoryPanel.get() && mOutboxId.notNull())
 	{
         S32 item_count = 0;
 
@@ -332,7 +364,7 @@ void LLFloaterOutbox::updateFolderCount()
 
 void LLFloaterOutbox::updateFolderCountStatus()
 {
-	if (mOutboxInventoryPanel.get())
+	if (mOutboxInventoryPanel.get() && mOutboxId.notNull())
 	{
 		switch (mOutboxItemCount)
 		{
@@ -445,7 +477,8 @@ BOOL LLFloaterOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 {
 	if ((mOutboxInventoryPanel.get() == NULL) ||
 		(mWindowShade && mWindowShade->isShown()) ||
-		LLMarketplaceInventoryImporter::getInstance()->isImportInProgress())
+		LLMarketplaceInventoryImporter::getInstance()->isImportInProgress() ||
+        mOutboxId.isNull())
 	{
 		return FALSE;
 	}
@@ -516,7 +549,7 @@ void LLFloaterOutbox::onImportButtonClicked()
 
 void LLFloaterOutbox::onOutboxChanged()
 {
-	llassert(!mOutboxId.isNull());
+	//llassert(!mOutboxId.isNull());
 	LLInventoryPanel* panel = mOutboxInventoryPanel.get();
     llinfos << "Merov : onOutboxChanged!!!, panel = " << panel << ", view model = " << (panel ? panel->getFolderViewModel() : NULL) << llendl;
     LLViewerInventoryCategory* category = gInventory.getCategory(mOutboxId);
@@ -528,7 +561,7 @@ void LLFloaterOutbox::onOutboxChanged()
     else
     {
         llinfos << "Merov : onOutboxChanged!!!, the category disappeared!" << llendl;
-        //setupOutbox();
+        cleanOutbox();
     }
 }
 
diff --git a/indra/newview/llfloateroutbox.h b/indra/newview/llfloateroutbox.h
index f6a879fec5..40519c8fd2 100755
--- a/indra/newview/llfloateroutbox.h
+++ b/indra/newview/llfloateroutbox.h
@@ -71,6 +71,7 @@ public:
 
 protected:
 	void setupOutbox();
+    void cleanOutbox();
 	void fetchOutboxContents();
 
 	void importReportResults(U32 status, const LLSD& content);
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index f2c5f0aa55..63cedb6aa8 100755
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -590,6 +590,7 @@ LLUUID LLInventoryPanel::getRootFolderID()
 			}
 			else if (preferred_type != LLFolderType::FT_NONE)
 			{
+                llinfos << "Merov : getRootFolderID, name = " << mParams.start_folder.name() << ", type = " << mParams.start_folder.type << llendl;
 				root_id = gInventory.findCategoryUUIDForType(preferred_type, false);
 				if (root_id.isNull())
 				{
-- 
cgit v1.2.3