stone_linden avatar stone_linden committed e05b696

STORM-1368 Code more defensively around notecard upload.

Comments (0)

Files changed (1)

indra/newview/llpreviewnotecard.cpp

 
 bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
 {
-	if(!gAssetStorage)
+	LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor");
+
+	if(!editor)
 	{
-		llwarns << "Not connected to an asset storage system." << llendl;
+		llwarns << "Cannot get handle to the notecard editor." << llendl;
 		return false;
 	}
 
-	
-	LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor");
-
 	if(!editor->isPristine())
 	{
 		// We need to update the asset information
 		// save it out to database
 		if (item)
 		{			
-			std::string agent_url = gAgent.getRegion()->getCapability("UpdateNotecardAgentInventory");
-			std::string task_url = gAgent.getRegion()->getCapability("UpdateNotecardTaskInventory");
+			const LLViewerRegion* region = gAgent.getRegion();
+			if (!region)
+			{
+				llwarns << "Not connected to a region, cannot save notecard." << llendl;
+				return false;
+			}
+			std::string agent_url = region->getCapability("UpdateNotecardAgentInventory");
+			std::string task_url = region->getCapability("UpdateNotecardTaskInventory");
+
 			if (mObjectUUID.isNull() && !agent_url.empty())
 			{
 				// Saving into agent inventory
 												(void*)info,
 												FALSE);
 			}
+			else // !gAssetStorage
+			{
+				llwarns << "Not connected to an asset storage system." << llendl;
+				return false;
+			}
 		}
 	}
 	return true;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.