Commits

Vadim Savchuk committed 6378d83

STORM-1543 WIP More cleanup and comments.

  • Participants
  • Parent commits a7669bd

Comments (0)

Files changed (2)

indra/newview/llappviewer.cpp

  * Tasks added to this list will be executed in the next LLAppViewer::idle() iteration.
  * All tasks are executed only once.
  */
-class LLDeferredTaskList:
-	public LLSingleton<LLDeferredTaskList>,
-	private LLDestroyClass<LLDeferredTaskList>
+class LLDeferredTaskList: public LLSingleton<LLDeferredTaskList>
 {
 	LOG_CLASS(LLDeferredTaskList);
+
 	friend class LLAppViewer;
-	friend class LLDestroyClass<LLDeferredTaskList>;
 	typedef boost::signals2::signal<void()> signal_t;
 
 	void addTask(const signal_t::slot_type& cb)
 
 	void run()
 	{
-		if (mSignal.empty()) return;
-
-		mSignal();
-		mSignal.disconnect_all_slots();
-	}
-
-	static void destroyClass()
-	{
-		instance().mSignal.disconnect_all_slots();
+		if (!mSignal.empty())
+		{
+			mSignal();
+			mSignal.disconnect_all_slots();
+		}
 	}
 
 	signal_t mSignal;
 		}
 	}
 
+	// Execute deferred tasks.
 	LLDeferredTaskList::instance().run();
 	
 	// Handle shutdown process, for example, 

indra/newview/llviewermessage.cpp

 	{
 		LL_DEBUGS("Messaging") << "LLDiscardAgentOffer::done()" << LL_ENDL;
 
+		// We're invoked from LLInventoryModel::notifyObservers().
+		// If we now try to remove the inventory item, it will cause a nested
+		// notifyObservers() call, which won't work.
+		// So defer moving the item to trash until viewer gets idle (in a moment).
 		LLAppViewer::instance()->addOnIdleCallback(boost::bind(&LLInventoryModel::removeItem, &gInventory, mObjectID));
 		gInventory.removeObserver(this);
 		delete this;