Browse Source

Fixed crash when pasting while using transform

CPKreuz 2 years ago
parent
commit
2a99580953

+ 9 - 3
src/PixiEditor/Models/Controllers/ClipboardController.cs

@@ -79,9 +79,15 @@ internal static class ClipboardController
         {
         {
             if (pasteAsNew)
             if (pasteAsNew)
             {
             {
-                var guid = document.Operations.CreateStructureMember(StructureMemberType.Layer, "New Layer", false).Value;
-                document.Operations.SetSelectedMember(guid);
-                document.Operations.PasteImageWithTransform(images[0].image, VecI.Zero, guid, false);
+                var guid = document.Operations.CreateStructureMember(StructureMemberType.Layer, "New Layer", false);
+
+                if (guid == null)
+                {
+                    return false;
+                }
+                
+                document.Operations.SetSelectedMember(guid.Value);
+                document.Operations.PasteImageWithTransform(images[0].image, VecI.Zero, guid.Value, false);
             }
             }
             else
             else
             {
             {

+ 1 - 1
src/PixiEditor/Models/DocumentModels/Public/DocumentOperationsModule.cs

@@ -130,7 +130,7 @@ internal class DocumentOperationsModule
     /// </summary>
     /// </summary>
     /// <param name="type">The type of the member</param>
     /// <param name="type">The type of the member</param>
     /// <param name="name">The name of the member</param>
     /// <param name="name">The name of the member</param>
-    /// <returns>The Guid of the new structure member</returns>
+    /// <returns>The Guid of the new structure member or null if there is already an active change</returns>
     public Guid? CreateStructureMember(StructureMemberType type, string? name = null, bool finish = true)
     public Guid? CreateStructureMember(StructureMemberType type, string? name = null, bool finish = true)
     {
     {
         if (Internals.ChangeController.IsChangeActive)
         if (Internals.ChangeController.IsChangeActive)