summaryrefslogtreecommitdiff
path: root/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2021-03-02 21:41:37 +0200
committerAndrey Lihatskiy <alihatskiy@productengine.com>2021-03-02 21:41:37 +0200
commit135d54a4ff46c7e3230b8baeedaee886cb2f11c4 (patch)
tree4f55540281efcc3007d73ff95e6e19aa7ba2390c /indra/newview/llpreviewscript.cpp
parent4add069cae879a626c284ea13aeb1b42b3ca5dfc (diff)
parent2b385841f3031d599bdb226f0f859e51b09870f8 (diff)
Merge branch 'master' into DRTVWR-516-maint
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rw-r--r--indra/newview/llpreviewscript.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 9c87df0fa9..fd510b5303 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -51,7 +51,7 @@
#include "llsdserialize.h"
#include "llslider.h"
#include "lltooldraganddrop.h"
-#include "llvfile.h"
+#include "llfilesystem.h"
#include "llagent.h"
#include "llmenugl.h"
@@ -1711,8 +1711,11 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/)
{
std::string buffer(mScriptEd->mEditor->getText());
+ LLUUID old_asset_id = inv_item->getAssetUUID().isNull() ? mScriptEd->getAssetID() : inv_item->getAssetUUID();
+
LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(mItemUUID, buffer,
- [](LLUUID itemId, LLUUID, LLUUID, LLSD response) {
+ [old_asset_id](LLUUID itemId, LLUUID, LLUUID, LLSD response) {
+ LLFileSystem::removeFile(old_asset_id, LLAssetType::AT_LSL_TEXT);
LLPreviewLSL::finishedLSLUpload(itemId, response);
}));
@@ -1722,8 +1725,8 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/)
}
// static
-void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAssetType::EType type,
- void* user_data, S32 status, LLExtStat ext_status)
+void LLPreviewLSL::onLoadComplete(const LLUUID& asset_uuid, LLAssetType::EType type,
+ void* user_data, S32 status, LLExtStat ext_status)
{
LL_DEBUGS() << "LLPreviewLSL::onLoadComplete: got uuid " << asset_uuid
<< LL_ENDL;
@@ -1733,7 +1736,7 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset
{
if(0 == status)
{
- LLVFile file(vfs, asset_uuid, type);
+ LLFileSystem file(asset_uuid, type);
S32 file_length = file.getSize();
std::vector<char> buffer(file_length+1);
@@ -1760,6 +1763,7 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset
}
preview->mScriptEd->setScriptName(script_name);
preview->mScriptEd->setEnableEditing(is_modifiable);
+ preview->mScriptEd->setAssetID(asset_uuid);
preview->mAssetStatus = PREVIEW_ASSET_LOADED;
}
else
@@ -1996,7 +2000,7 @@ void LLLiveLSLEditor::loadAsset()
}
// static
-void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id,
+void LLLiveLSLEditor::onLoadComplete(const LLUUID& asset_id,
LLAssetType::EType type,
void* user_data, S32 status, LLExtStat ext_status)
{
@@ -2010,9 +2014,10 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id,
{
if( LL_ERR_NOERR == status )
{
- instance->loadScriptText(vfs, asset_id, type);
+ instance->loadScriptText(asset_id, type);
instance->mScriptEd->setEnableEditing(TRUE);
instance->mAssetStatus = PREVIEW_ASSET_LOADED;
+ instance->mScriptEd->setAssetID(asset_id);
}
else
{
@@ -2036,9 +2041,9 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id,
delete floater_key;
}
-void LLLiveLSLEditor::loadScriptText(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type)
+void LLLiveLSLEditor::loadScriptText(const LLUUID &uuid, LLAssetType::EType type)
{
- LLVFile file(vfs, uuid, type);
+ LLFileSystem file(uuid, type);
S32 file_length = file.getSize();
std::vector<char> buffer(file_length + 1);
file.read((U8*)&buffer[0], file_length);
@@ -2192,6 +2197,7 @@ void LLLiveLSLEditor::finishLSLUpload(LLUUID itemId, LLUUID taskId, LLUUID newAs
if (preview)
{
preview->mItem->setAssetUUID(newAssetId);
+ preview->mScriptEd->setAssetID(newAssetId);
// Bytecode save completed
if (response["compiled"])
@@ -2262,12 +2268,14 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
if (!url.empty())
{
std::string buffer(mScriptEd->mEditor->getText());
+ LLUUID old_asset_id = mScriptEd->getAssetID();
LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(mObjectUUID, mItemUUID,
monoChecked() ? LLScriptAssetUpload::MONO : LLScriptAssetUpload::LSL2,
isRunning, mScriptEd->getAssociatedExperience(), buffer,
- [isRunning](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) {
- LLLiveLSLEditor::finishLSLUpload(itemId, taskId, newAssetId, response, isRunning);
+ [isRunning, old_asset_id](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) {
+ LLFileSystem::removeFile(old_asset_id, LLAssetType::AT_LSL_TEXT);
+ LLLiveLSLEditor::finishLSLUpload(itemId, taskId, newAssetId, response, isRunning);
}));
LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);