summaryrefslogtreecommitdiff
path: root/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rw-r--r--indra/newview/llpreviewscript.cpp41
1 files changed, 32 insertions, 9 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 57a6069aff..4e456b0a65 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -1643,7 +1643,6 @@ LLLiveLSLEditor::LLLiveLSLEditor(const std::string& name,
setTitle(title);
-
}
LLLiveLSLEditor::~LLLiveLSLEditor()
@@ -1695,9 +1694,8 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
{
// HACK! we "know" that mItemID refers to a LLViewerInventoryItem...
LLViewerInventoryItem* item = (LLViewerInventoryItem*)object->getInventoryObject(mItemID);
- if(item
- && (gAgent.allowOperation(PERM_COPY, item->getPermissions(),
- GP_OBJECT_MANIPULATE)
+ if(item
+ && (gAgent.allowOperation(PERM_COPY, item->getPermissions(), GP_OBJECT_MANIPULATE)
|| gAgent.isGodlike()))
{
mItem = new LLViewerInventoryItem(item);
@@ -1706,12 +1704,10 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
if(!gAgent.isGodlike()
&& (item
- && (!gAgent.allowOperation(PERM_COPY, item->getPermissions(),
- GP_OBJECT_MANIPULATE)
- || !gAgent.allowOperation(PERM_MODIFY,
- item->getPermissions(), GP_OBJECT_MANIPULATE))))
-
+ && (!gAgent.allowOperation(PERM_COPY, item->getPermissions(), GP_OBJECT_MANIPULATE)
+ || !gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE))))
{
+ mItem = new LLViewerInventoryItem(item);
mScriptEd->mEditor->setText("You are not allowed to view this script.");
mScriptEd->mEditor->makePristine();
mScriptEd->mEditor->setEnabled(FALSE);
@@ -1769,6 +1765,20 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
gMessageSystem->sendReliable(host);
*/
}
+
+ // Initialization of the asset failed. Probably the result
+ // of a bug somewhere else. Set up this editor in a no-go mode.
+ if(mItem.isNull())
+ {
+ // Set the inventory item to an incomplete item.
+ // This may be better than having a accessible null pointer around,
+ // though this newly allocated object will most likely be replaced.
+ mItem = new LLViewerInventoryItem();
+ mScriptEd->mEditor->setText("");
+ mScriptEd->mEditor->makePristine();
+ mScriptEd->mEditor->setEnabled(FALSE);
+ mAssetStatus = PREVIEW_ASSET_LOADED;
+ }
}
else
{
@@ -2016,6 +2026,14 @@ void LLLiveLSLEditor::saveIfNeeded()
return;
}
+ if(mItem.isNull() || !mItem->isComplete())
+ {
+ // $NOTE: While the error message may not be exactly correct,
+ // it's pretty close.
+ gViewerWindow->alertXml("SaveScriptFailObjectNotFound");
+ return;
+ }
+
// get the latest info about it. We used to be losing the script
// name on save, because the viewer object version of the item,
// and the editor version would get out of synch. Here's a good
@@ -2279,6 +2297,11 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use
delete data;
}
+void LLLiveLSLEditor::open()
+{
+ LLFloater::open(); /*Flawfinder: ignore*/
+}
+
BOOL LLLiveLSLEditor::canClose()
{
return (mScriptEd->canClose());