From a5db4f6c3d1f6804c20b3095b39203887728d3a6 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Tue, 19 Nov 2013 09:28:58 -0500
Subject: [PATCH] add documentation to LLAgent::addRegionChangedCallback and
 improve logging

---
 indra/newview/llagent.cpp |  6 +++---
 indra/newview/llagent.h   | 19 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index da29aaff508..5302ae26361 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -261,9 +261,7 @@ bool handleSlowMotionAnimation(const LLSD& newvalue)
 
 void LLAgent::setCanEditParcel() // called via mParcelChangedSignal
 {
-	LL_DEBUGS("AgentLocation") << LL_ENDL;
 	bool can_edit = LLToolMgr::getInstance()->canEdit();
-
 	gAgent.mCanEditParcel = can_edit;
 }
 
@@ -837,7 +835,7 @@ void LLAgent::handleServerBakeRegionTransition(const LLUUID& region_id)
 
 void LLAgent::changeParcels()
 {
-	LL_DEBUGS("AgentLocation") << LL_ENDL;
+	LL_DEBUGS("AgentLocation") << "Calling ParcelChanged callbacks" << LL_ENDL;
 	// Notify anything that wants to know about parcel changes
 	mParcelChangedSignal();
 }
@@ -920,6 +918,8 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
 	}
 	mRegionp = regionp;
 
+	// TODO - most of what follows probably should be moved into callbacks
+
 	// Pass the region host to LLUrlEntryParcel to resolve parcel name
 	// with a server request.
 	LLUrlEntryParcel::setRegionHost(getRegionHost());
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index fafa166efda..0662be897a3 100755
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -253,7 +253,24 @@ class LLAgent : public LLOldEvents::LLObservable
 	LLHost			getRegionHost() const;
 	BOOL			inPrelude();
 
-	// Register a boost callback to be called when the agent changes regions
+	/**
+	 * Register a boost callback to be called when the agent changes regions
+	 * Note that if you need to access a capability for the region, you may need to wait
+	 * for the capabilities to be received, since in some cases your region changed
+	 * callback will be called before the capabilities have been received.  Your callback
+	 * may need to look something like:
+	 *
+	 * 	 LLViewerRegion* region = gAgent.getRegion();
+	 * 	 if (region->capabilitiesReceived())
+	 * 	 {
+	 *       useCapability(region);
+	 * 	 }
+	 * 	 else // Need to handle via callback after caps arrive.
+	 * 	 {
+	 *       region->setCapabilitiesReceivedCallback(boost::bind(&useCapability,region,_1));
+	 *       // you may or may not want to remove that callback
+	 * 	 }
+	 */
 	typedef boost::function<void()> region_changed_callback_t;
 	boost::signals2::connection     addRegionChangedCallback(region_changed_callback_t);
 
-- 
GitLab