Commits

Vadim Savchuk committed fe34d81 Merge

Merge from default branch

Comments (0)

Files changed (11)

indra/llcommon/llapr.cpp

 // File I/O
 S32 LLAPRFile::read(void *buf, S32 nbytes)
 {
-	llassert_always(mFile) ;
+	if(!mFile) 
+	{
+		llwarns << "apr mFile is removed by somebody else. Can not read." << llendl ;
+		return 0;
+	}
 	
 	apr_size_t sz = nbytes;
 	apr_status_t s = apr_file_read(mFile, buf, &sz);
 
 S32 LLAPRFile::write(const void *buf, S32 nbytes)
 {
-	llassert_always(mFile) ;
+	if(!mFile) 
+	{
+		llwarns << "apr mFile is removed by somebody else. Can not write." << llendl ;
+		return 0;
+	}
 	
 	apr_size_t sz = nbytes;
 	apr_status_t s = apr_file_write(mFile, buf, &sz);

indra/newview/llpaneloutfitedit.cpp

 			applyListViewFilter(LVIT_BODYPART);
 			break;
 		case LLAssetType::AT_CLOTHING:
-		default: 
+		default:
 			applyListViewFilter(LVIT_CLOTHING);
 			break;
 		}

indra/newview/llpanelprimmediacontrols.cpp

 
 void LLPanelPrimMediaControls::nextZoomLevel()
 {
+	LLViewerObject* objectp = getTargetObject();
+	if(objectp && objectp->isHUDAttachment())
+	{
+		// Never allow zooming on HUD attachments.
+		return;
+	}
+	
 	int index = 0;
 	while (index < kNumZoomLevels)
 	{

indra/newview/lltexturecache.cpp

 
 void LLTextureCache::closeHeaderEntriesFile()
 {
-	llassert_always(mHeaderAPRFile != NULL);
+	if(!mHeaderAPRFile)
+	{
+		return ;
+	}
+
 	delete mHeaderAPRFile;
 	mHeaderAPRFile = NULL;
 }
 }
 
 //mHeaderMutex is locked before calling this.
-void LLTextureCache::writeEntryToHeaderImmediately(S32 idx, Entry& entry, bool write_header)
+void LLTextureCache::writeEntryToHeaderImmediately(S32& idx, Entry& entry, bool write_header)
 {	
 	LLAPRFile* aprfile ;
 	S32 bytes_written ;
 	{
 		aprfile = openHeaderEntriesFile(false, 0);		
 		bytes_written = aprfile->write((U8*)&mHeaderEntriesInfo, sizeof(EntriesInfo)) ;
-		llassert_always(bytes_written == sizeof(EntriesInfo));
+		if(bytes_written != sizeof(EntriesInfo))
+		{
+			clearCorruptedCache() ; //clear the cache.
+			idx = -1 ;//mark the idx invalid.
+			return ;
+		}
+
 		mHeaderAPRFile->seek(APR_SET, offset);
 	}
 	else
 		aprfile = openHeaderEntriesFile(false, offset);
 	}
 	bytes_written = aprfile->write((void*)&entry, (S32)sizeof(Entry));
-	llassert_always(bytes_written == sizeof(Entry));
+	if(bytes_written != sizeof(Entry))
+	{
+		clearCorruptedCache() ; //clear the cache.
+		idx = -1 ;//mark the idx invalid.
+
+		return ;
+	}
+
 	closeHeaderEntriesFile();
 	mUpdatedEntryMap.erase(idx) ;
 }
 
 //mHeaderMutex is locked before calling this.
-void LLTextureCache::readEntryFromHeaderImmediately(S32 idx, Entry& entry)
+void LLTextureCache::readEntryFromHeaderImmediately(S32& idx, Entry& entry)
 {
 	S32 offset = sizeof(EntriesInfo) + idx * sizeof(Entry);
 	LLAPRFile* aprfile = openHeaderEntriesFile(true, offset);
 	S32 bytes_read = aprfile->read((void*)&entry, (S32)sizeof(Entry));
-	llassert_always(bytes_read == sizeof(Entry));			
 	closeHeaderEntriesFile();
+
+	if(bytes_read != sizeof(Entry))
+	{
+		clearCorruptedCache() ; //clear the cache.
+		idx = -1 ;//mark the idx invalid.
+	}
 }
 
 //mHeaderMutex is locked before calling this.
 }
 
 //update an existing entry, write to header file immediately.
-bool LLTextureCache::updateEntry(S32 idx, Entry& entry, S32 new_image_size, S32 new_data_size)
+bool LLTextureCache::updateEntry(S32& idx, Entry& entry, S32 new_image_size, S32 new_data_size)
 {
 	S32 new_body_size = llmax(0, new_data_size - TEXTURE_CACHE_ENTRY_SIZE) ;
 	
 	{
 		aprfile = openHeaderEntriesFile(false, 0);
 		updatedHeaderEntriesFile() ;
+		if(!aprfile)
+		{
+			return 0;
+		}
 		aprfile->seek(APR_SET, (S32)sizeof(EntriesInfo));
 	}
 	for (U32 idx=0; idx<num_entries; idx++)
 		for (S32 idx=0; idx<num_entries; idx++)
 		{
 			S32 bytes_written = aprfile->write((void*)(&entries[idx]), (S32)sizeof(Entry));
-			llassert_always(bytes_written == sizeof(Entry));
+			if(bytes_written != sizeof(Entry))
+			{
+				clearCorruptedCache() ; //clear the cache.
+				return ;
+			}
 		}
 		closeHeaderEntriesFile();
 	}
 		//entriesInfo
 		mHeaderAPRFile->seek(APR_SET, 0);
 		S32 bytes_written = mHeaderAPRFile->write((U8*)&mHeaderEntriesInfo, sizeof(EntriesInfo)) ;
-		llassert_always(bytes_written == sizeof(EntriesInfo));
+		if(bytes_written != sizeof(EntriesInfo))
+		{
+			clearCorruptedCache() ; //clear the cache.
+			return ;
+		}
 		
 		//write each updated entry
 		S32 entry_size = (S32)sizeof(Entry) ;
 			}
 			
 			bytes_written = mHeaderAPRFile->write((void*)(&iter->second), entry_size);
-			llassert_always(bytes_written == entry_size);
+			if(bytes_written != entry_size)
+			{
+				clearCorruptedCache() ; //clear the cache.
+				return ;
+			}
 		}
 		mUpdatedEntryMap.clear() ;
 	}
 
 //////////////////////////////////////////////////////////////////////////////
 
+//the header mutex is locked before calling this.
+void LLTextureCache::clearCorruptedCache()
+{
+	llwarns << "the texture cache is corrupted, need to be cleared." << llendl ;
+
+	closeHeaderEntriesFile();//close possible file handler
+	purgeAllTextures(false) ; //clear the cache.
+	
+	if (!mReadOnly) //regenerate the directory tree if not exists.
+	{
+		LLFile::mkdir(mTexturesDirName);
+		
+		const char* subdirs = "0123456789abcdef";
+		for (S32 i=0; i<16; i++)
+		{
+			std::string dirname = mTexturesDirName + gDirUtilp->getDirDelimiter() + subdirs[i];
+			LLFile::mkdir(dirname);
+		}
+	}
+
+	return ;
+}
+
 void LLTextureCache::purgeAllTextures(bool purge_directories)
 {
 	if (!mReadOnly)
 	mTexturesSizeTotal = 0;
 	mFreeList.clear();
 	mTexturesSizeTotal = 0;
+	mUpdatedEntryMap.clear();
 
 	// Info with 0 entries
 	mHeaderEntriesInfo.mVersion = sHeaderCacheVersion;
 	mHeaderEntriesInfo.mEntries = 0;
 	writeEntriesHeader();
+
+	llinfos << "The entire texture cache is cleared." << llendl ;
 }
 
 void LLTextureCache::purgeTextures(bool validate)
 	{
 		updateEntry(idx, entry, imagesize, datasize);				
 	}
-	else // retry
+
+	if(idx < 0) // retry
 	{
 		readHeaderCache(); // We couldn't write an entry, so refresh the LRU
 	

indra/newview/lltexturecache.h

 private:
 	void setDirNames(ELLPath location);
 	void readHeaderCache();
+	void clearCorruptedCache();
 	void purgeAllTextures(bool purge_directories);
 	void purgeTextures(bool validate);
 	LLAPRFile* openHeaderEntriesFile(bool readonly, S32 offset);
 	void readEntriesHeader();
 	void writeEntriesHeader();
 	S32 openAndReadEntry(const LLUUID& id, Entry& entry, bool create);
-	bool updateEntry(S32 idx, Entry& entry, S32 new_image_size, S32 new_body_size);
+	bool updateEntry(S32& idx, Entry& entry, S32 new_image_size, S32 new_body_size);
 	void updateEntryTimeStamp(S32 idx, Entry& entry) ;
 	U32 openAndReadEntries(std::vector<Entry>& entries);
 	void writeEntriesAndClose(const std::vector<Entry>& entries);
-	void readEntryFromHeaderImmediately(S32 idx, Entry& entry) ;
-	void writeEntryToHeaderImmediately(S32 idx, Entry& entry, bool write_header = false) ;
+	void readEntryFromHeaderImmediately(S32& idx, Entry& entry) ;
+	void writeEntryToHeaderImmediately(S32& idx, Entry& entry, bool write_header = false) ;
 	void removeEntry(S32 idx, Entry& entry, std::string& filename);
 	void removeCachedTexture(const LLUUID& id) ;
 	S32 getHeaderCacheEntry(const LLUUID& id, Entry& entry);

indra/newview/lltoolpie.cpp

 
 	if (!parcel ||
 		objectp.isNull() ||
-		objectp->isHUDAttachment() ||
 		pick.mObjectFace < 0 || 
 		pick.mObjectFace >= objectp->getNumTEs()) 
 	{

indra/newview/llviewermedia.cpp

 	
 	// Calculate distance from the avatar, for use in the proximity calculation.
 	mProximityDistance = 0.0f;
+	mProximityCamera = 0.0f;
 	if(!mObjectList.empty())
 	{
 		// Just use the first object in the list.  We could go through the list and find the closest object, but this should work well enough.
 		std::list< LLVOVolume* >::iterator iter = mObjectList.begin() ;
 		LLVOVolume* objp = *iter ;
 		llassert_always(objp != NULL) ;
-
-		LLVector3d obj_global = objp->getPositionGlobal() ;
-		LLVector3d agent_global = gAgent.getPositionGlobal() ;
-		LLVector3d global_delta = agent_global - obj_global ;
-		mProximityDistance = global_delta.magVecSquared();  // use distance-squared because it's cheaper and sorts the same.
-
-		LLVector3d camera_delta = gAgentCamera.getCameraPositionGlobal() - obj_global;
-		mProximityCamera = camera_delta.magVec();
+		
+		// The distance calculation is invalid for HUD attachments -- leave both mProximityDistance and mProximityCamera at 0 for them.
+		if(!objp->isHUDAttachment())
+		{
+			LLVector3d obj_global = objp->getPositionGlobal() ;
+			LLVector3d agent_global = gAgent.getPositionGlobal() ;
+			LLVector3d global_delta = agent_global - obj_global ;
+			mProximityDistance = global_delta.magVecSquared();  // use distance-squared because it's cheaper and sorts the same.
+
+			LLVector3d camera_delta = gAgentCamera.getCameraPositionGlobal() - obj_global;
+			mProximityCamera = camera_delta.magVec();
+		}
 	}
 	
 	if(mNeedsMuteCheck)

indra/newview/llvoavatar.cpp

 				if (motionp->getName().empty())
 				{
 					output = llformat("%s - %d",
-									  motionp->getID().asString().c_str(),
-									  (U32)motionp->getPriority());
+							  gAgent.isGodlikeWithoutAdminMenuFakery() ?
+							  motionp->getID().asString().c_str() :
+							  LLUUID::null.asString().c_str(),
+							  (U32)motionp->getPriority());
 				}
 				else
 				{
 					output = llformat("%s - %d",
-									  motionp->getName().c_str(),
-									  (U32)motionp->getPriority());
+							  motionp->getName().c_str(),
+							  (U32)motionp->getPriority());
 				}
 				addDebugText(output);
 			}

indra/newview/skins/default/xui/fr/floater_preview_gesture.xml

 		Attendre :
 	</floater.string>
 	<floater.string name="stop_txt">
-		Stop
+		Arrêter
 	</floater.string>
 	<floater.string name="preview_txt">
 		Prévisualiser
 	</floater.string>
 	<floater.string name="none_text">
-		-- Aucune --
+		- Aucun choix -
 	</floater.string>
 	<floater.string name="Title">
 		Geste : [NAME]

indra/newview/skins/default/xui/fr/menu_gesture_gear.xml

 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <menu name="menu_gesture_gear">
-	<menu_item_call label="Ajouter/Supprimer des Favoris" name="activate"/>
+	<menu_item_call label="Ajouter/Supprimer des favoris" name="activate"/>
 	<menu_item_call label="Copier" name="copy_gesture"/>
 	<menu_item_call label="Coller" name="paste"/>
 	<menu_item_call label="Copier l&apos;UUID" name="copy_uuid"/>

indra/newview/skins/default/xui/fr/panel_nearby_media.xml

 			Médias proches
 		</text>
 		<text name="show_text">
-			Afficher :
+			Voir :
 		</text>
 		<combo_box name="show_combo">
 			<combo_box.item label="Tout" name="All"/>