Merge branch 'DRTVWR-516-maint' of https://bitbucket.org/lindenlab/viewer

meow-7.2.2
Ansariel 2020-09-29 11:41:06 +02:00
commit 0e75268007
4 changed files with 68 additions and 29 deletions

View File

@ -115,17 +115,11 @@ LLLandmark* LLLandmark::constructFromString(const char *buffer, const S32 buffer
// read version
count = sscanf( buffer, "Landmark version %u\n%n", &version, &chars_read );
if (count != 1)
{
bad_block = true;
}
chars_read_total += chars_read;
if (chars_read_total >= buffer_size)
if (count != 1
|| chars_read_total >= buffer_size)
{
// either file was truncated or data in file was damaged
bad_block = true;
}
@ -155,19 +149,29 @@ LLLandmark* LLLandmark::constructFromString(const char *buffer, const S32 buffer
// scanf call below.
char region_id_str[MAX_STRING];
LLVector3 pos;
LLUUID region_id;
count = sscanf( buffer + chars_read_total,
"region_id %254s\n%n",
region_id_str,
&chars_read);
if (count != 1)
{
bad_block = true;
}
chars_read_total += chars_read;
if (chars_read_total >= buffer_size)
if (count != 1
|| chars_read_total >= buffer_size
|| !LLUUID::validate(region_id_str))
{
bad_block = true;
}
if (!bad_block)
{
region_id.set(region_id_str);
if (region_id.isNull())
{
bad_block = true;
}
}
if (!bad_block)
{
count = sscanf(buffer + chars_read_total, "local_pos %f %f %f\n%n", pos.mV + VX, pos.mV + VY, pos.mV + VZ, &chars_read);
@ -178,7 +182,7 @@ LLLandmark* LLLandmark::constructFromString(const char *buffer, const S32 buffer
else
{
result = new LLLandmark;
result->mRegionID.set(region_id_str);
result->mRegionID = region_id;
result->mRegionPos = pos;
}
}

View File

@ -67,6 +67,7 @@ LLOutfitGallery::LLOutfitGallery(const LLOutfitGallery::Params& p)
mOutfitsObserver(NULL),
mScrollPanel(NULL),
mGalleryPanel(NULL),
mLastRowPanel(NULL),
mGalleryCreated(false),
mRowCount(0),
mItemsAddedCount(0),
@ -242,7 +243,15 @@ void LLOutfitGallery::removeLastRow()
mGalleryPanel->removeChild(mLastRowPanel);
mUnusedRowPanels.push_back(mLastRowPanel);
mRowPanels.pop_back();
mLastRowPanel = mRowPanels.back();
if (mRowPanels.size() > 0)
{
// Just removed last row
mLastRowPanel = mRowPanels.back();
}
else
{
mLastRowPanel = NULL;
}
}
LLPanel* LLOutfitGallery::addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item, int pos, int hgap)

View File

@ -1098,14 +1098,17 @@ bool LLScriptEdCore::writeToFile(const std::string& filename, bool unprocessed)
void LLScriptEdCore::sync()
{
// Sync with external editor.
std::string tmp_file = mContainer->getTmpFileName();
llstat s;
if (LLFile::stat(tmp_file, &s) == 0) // file exists
{
if (mLiveFile) mLiveFile->ignoreNextUpdate();
writeToFile(tmp_file,gSavedSettings.getBOOL("_NACL_LSLPreprocessor"));
}
// Sync with external editor.
if (mLiveFile)
{
std::string tmp_file = mLiveFile->filename();
llstat s;
if (LLFile::stat(tmp_file, &s) == 0) // file exists
{
mLiveFile->ignoreNextUpdate();
writeToFile(tmp_file, gSavedSettings.getBOOL("_NACL_LSLPreprocessor"));
}
}
}
bool LLScriptEdCore::hasChanged()
@ -1565,9 +1568,25 @@ void LLScriptEdCore::openInExternalEditor()
// from above).
delete mLiveFile; // deletes file
// Save the script to a temporary file.
std::string filename = mContainer->getTmpFileName();
writeToFile(filename,gSavedSettings.getBOOL("_NACL_LSLPreprocessor"));
// Generate a suitable filename
std::string script_name = mScriptName;
std::string forbidden_chars = "<>:\"\\/|?*";
for (std::string::iterator c = forbidden_chars.begin(); c != forbidden_chars.end(); c++)
{
script_name.erase(std::remove(script_name.begin(), script_name.end(), *c), script_name.end());
}
std::string filename = mContainer->getTmpFileName(script_name);
// Save the script to a temporary file.
if (!writeToFile(filename))
{
// In case some characters from script name are forbidden
// and not accounted for, name is too long or some other issue,
// try file that doesn't include script name
script_name.clear();
filename = mContainer->getTmpFileName(script_name);
writeToFile(filename);
}
// Start watching file changes.
mLiveFile = new LLLiveLSLFile(filename, boost::bind(&LLScriptEdContainer::onExternalChange, mContainer, _1));
@ -2045,7 +2064,7 @@ std::string LLScriptEdContainer::getBackupFileName() const
}
// [/SL:KB]
std::string LLScriptEdContainer::getTmpFileName()
std::string LLScriptEdContainer::getTmpFileName(const std::string& script_name)
{
// Take script inventory item id (within the object inventory)
// to consideration so that it's possible to edit multiple scripts
@ -2057,7 +2076,14 @@ std::string LLScriptEdContainer::getTmpFileName()
LLMD5 script_id_hash((const U8 *)script_id.c_str());
script_id_hash.hex_digest(script_id_hash_str);
return std::string(LLFile::tmpdir()) + "sl_script_" + script_id_hash_str + ".lsl";
if (script_name.empty())
{
return std::string(LLFile::tmpdir()) + "sl_script_" + script_id_hash_str + ".lsl";
}
else
{
return std::string(LLFile::tmpdir()) + "sl_script_" + script_name + "_" + script_id_hash_str + ".lsl";
}
}
bool LLScriptEdContainer::onExternalChange(const std::string& filename)

View File

@ -282,7 +282,7 @@ public:
void updateStyle();
protected:
std::string getTmpFileName();
std::string getTmpFileName(const std::string& script_name);
// [SL:KB] - Patch: Build-ScriptRecover | Checked: 2011-11-23 (Catznip-3.2.0) | Added: Catznip-3.2.0
virtual std::string getBackupFileName() const;
bool onBackupTimer();