Browse Source

Take fix from AngelScript WIP version to fix temp variable corruption. Remove now unnecessary fix from Editor script code. Closes #1850.

Lasse Öörni 8 years ago
parent
commit
48a1f3dcdd

+ 15 - 2
Source/ThirdParty/AngelScript/source/as_compiler.cpp

@@ -1,6 +1,6 @@
 /*
    AngelCode Scripting Library
-   Copyright (c) 2003-2016 Andreas Jonsson
+   Copyright (c) 2003-2017 Andreas Jonsson
 
    This software is provided 'as-is', without any express or implied
    warranty. In no event will the authors be held liable for any
@@ -11197,6 +11197,8 @@ int asCCompiler::FindPropertyAccessor(const asCString &name, asCExprContext *ctx
 		ctx->property_get = getId;
 		ctx->property_set = setId;
 
+		bool isHandleSafe = ctx->type.isHandleSafe;
+
 		if( ctx->type.dataType.IsObject() )
 		{
 			// If the object is read-only then we need to remember that
@@ -11228,6 +11230,10 @@ int asCCompiler::FindPropertyAccessor(const asCString &name, asCExprContext *ctx
 		ctx->type.isTemporary = isTemp;
 		ctx->exprNode = node;
 
+		// Remember if the object is safe, so the invocation of the property
+		// accessor doesn't needlessly make a safe copy of the handle
+		ctx->type.isHandleSafe = isHandleSafe;
+
 		// Store the argument for later use
 		if( arg )
 		{
@@ -12534,9 +12540,16 @@ int asCCompiler::CompileOverloadedDualOperator2(asCScriptNode *node, const char
 		// Did we find an operator?
 		if( ops.GetLength() == 1 )
 		{
+			// Reserve the variables used in the right expression so the new temporary
+			// variable allocated for the left operand isn't accidentally overwritten.
+			int l = int(reservedVariables.GetLength());
+			rctx->bc.GetVarsUsed(reservedVariables);
+
 			// Process the lctx expression as get accessor
 			ProcessPropertyGetAccessor(lctx, node);
 
+			reservedVariables.SetLength(l);
+
 			asCExprContext tmpCtx(engine);
 			if (leftToRight)
 			{
@@ -12546,7 +12559,7 @@ int asCCompiler::CompileOverloadedDualOperator2(asCScriptNode *node, const char
 				{
 					// Reserve the variables used in the right expression so the new temporary
 					// variable allocated for the left operand isn't accidentally overwritten.
-					int l = int(reservedVariables.GetLength());
+					l = int(reservedVariables.GetLength());
 					rctx->bc.GetVarsUsed(reservedVariables);
 
 					if (lctx->type.dataType.SupportHandles())

+ 1 - 1
bin/Data/Scripts/Editor/EditorResourceBrowser.as

@@ -838,7 +838,7 @@ void HandleResourceBrowserFileListSelectionChange(StringHash eventType, VariantM
                 if (boxes[i].size.length > biggestBox.size.length)
                     biggestBox = boxes[i];
             }
-            resourcePreviewCameraNode.position = camPosition * biggestBox.size.length + biggestBox.center;
+            resourcePreviewCameraNode.position = biggestBox.center + camPosition * biggestBox.size.length;
         }
 
         resourcePreviewScene.AddChild(resourcePreviewNode);