浏览代码

Fixed crash when evaluator received command execution context but wanted the parameter of the command execution context

CPKreuz 1 年之前
父节点
当前提交
aa119a58ac
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      src/PixiEditor/Models/Commands/CommandController.cs

+ 5 - 0
src/PixiEditor/Models/Commands/CommandController.cs

@@ -422,8 +422,13 @@ internal class CommandController
     {
         object CastParameter(object input, Type target)
         {
+            var commandExecutionType = typeof(CommandExecutionContext);
+            if (input is CommandExecutionContext context && !target.IsAssignableTo(commandExecutionType))
+                input = context.Parameter;
+
             if (target == typeof(object) || target == input?.GetType())
                 return input;
+            
             return Convert.ChangeType(input, target);
         }