From 65b46ac588a20699f22a742afab3134abe89715a Mon Sep 17 00:00:00 2001
From: Sergey Sharybin <sergey.vfx@gmail.com>
Date: Sat, 3 Sep 2011 11:11:01 +0000
Subject: [PATCH] Fix #28446: Moving imported object to new layer deletes it

Adding UNDO flag to import operators. Made this only for trunk addons.
---
 io_convert_image_to_mesh_img/__init__.py | 1 +
 io_curve_svg/__init__.py                 | 1 +
 io_import_scene_dxf.py                   | 1 +
 io_import_scene_mhx.py                   | 1 +
 io_import_scene_unreal_psk.py            | 1 +
 io_mesh_ply/__init__.py                  | 1 +
 io_mesh_raw/__init__.py                  | 1 +
 io_scene_3ds/__init__.py                 | 1 +
 io_scene_m3/__init__.py                  | 1 +
 io_scene_obj/__init__.py                 | 2 +-
 io_scene_x3d/__init__.py                 | 2 +-
 io_shape_mdd/__init__.py                 | 1 +
 12 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/io_convert_image_to_mesh_img/__init__.py b/io_convert_image_to_mesh_img/__init__.py
index e3309617a..99021bcd8 100644
--- a/io_convert_image_to_mesh_img/__init__.py
+++ b/io_convert_image_to_mesh_img/__init__.py
@@ -57,6 +57,7 @@ class ImportHiRISEIMGDTM(bpy.types.Operator, ImportHelper):
     '''Import a HiRISE DTM formatted as a PDS IMG file'''
     bl_idname = "import_shape.img"
     bl_label  = "Import HiRISE DTM from PDS IMG"
+    bl_options = {'UNDO'}
 
     filename_ext = ".IMG"
     filter_glob = StringProperty(default="*.IMG", options={'HIDDEN'})
diff --git a/io_curve_svg/__init__.py b/io_curve_svg/__init__.py
index 82982e76f..151fd2eb2 100644
--- a/io_curve_svg/__init__.py
+++ b/io_curve_svg/__init__.py
@@ -50,6 +50,7 @@ class ImportSVG(bpy.types.Operator, ImportHelper):
     '''Load a SVG file'''
     bl_idname = "import_curve.svg"
     bl_label = "Import SVG"
+    bl_options = {'UNDO'}
 
     filename_ext = ".svg"
     filter_glob = StringProperty(default="*.svg", options={'HIDDEN'})
diff --git a/io_import_scene_dxf.py b/io_import_scene_dxf.py
index 72bc967ed..4f7345fd8 100644
--- a/io_import_scene_dxf.py
+++ b/io_import_scene_dxf.py
@@ -2424,6 +2424,7 @@ class IMPORT_OT_autocad_dxf(bpy.types.Operator):
     bl_label = "Import DXF" +' v.'+ __version__
     bl_space_type = "PROPERTIES"
     bl_region_type = "WINDOW"
+    bl_options = {'UNDO'}
 
     filepath = StringProperty(
             name="File Path",
diff --git a/io_import_scene_mhx.py b/io_import_scene_mhx.py
index eb31353a7..a395de215 100644
--- a/io_import_scene_mhx.py
+++ b/io_import_scene_mhx.py
@@ -2883,6 +2883,7 @@ def copyConstraint(cns1, pb1, pb2, mhx, rigify):
 class OBJECT_OT_RigifyMhxButton(bpy.types.Operator):
     bl_idname = "mhxrig.rigify_mhx"
     bl_label = "Rigify MHX rig"
+    bl_options = {'UNDO'}
 
     def execute(self, context):
         rigifyMhx(context, context.object.name)
diff --git a/io_import_scene_unreal_psk.py b/io_import_scene_unreal_psk.py
index fe4b4e754..d58fc96cb 100644
--- a/io_import_scene_unreal_psk.py
+++ b/io_import_scene_unreal_psk.py
@@ -744,6 +744,7 @@ class IMPORT_OT_psk(bpy.types.Operator):
     bl_label = "Import PSK"
     bl_space_type = "PROPERTIES"
     bl_region_type = "WINDOW"
+    bl_options = {'UNDO'}
 
     # List of operator properties, the attributes will be assigned
     # to the class instance from the operator settings before calling.
diff --git a/io_mesh_ply/__init__.py b/io_mesh_ply/__init__.py
index 17449a4a4..ab245ed76 100644
--- a/io_mesh_ply/__init__.py
+++ b/io_mesh_ply/__init__.py
@@ -52,6 +52,7 @@ class ImportPLY(bpy.types.Operator, ImportHelper):
     '''Load a PLY geometry file'''
     bl_idname = "import_mesh.ply"
     bl_label = "Import PLY"
+    bl_options = {'UNDO'}
 
     files = CollectionProperty(name="File Path",
                           description="File path used for importing "
diff --git a/io_mesh_raw/__init__.py b/io_mesh_raw/__init__.py
index 76257f98f..70780b36e 100644
--- a/io_mesh_raw/__init__.py
+++ b/io_mesh_raw/__init__.py
@@ -50,6 +50,7 @@ class RawImporter(bpy.types.Operator):
     '''Load Raw triangle mesh data'''
     bl_idname = "import_mesh.raw"
     bl_label = "Import RAW"
+    bl_options = {'UNDO'}
 
     filepath = StringProperty(name="File Path", description="Filepath used for importing the RAW file", maxlen=1024, default="", subtype='FILE_PATH')
     filter_glob = StringProperty(default="*.raw", options={'HIDDEN'})
diff --git a/io_scene_3ds/__init__.py b/io_scene_3ds/__init__.py
index 54015cc18..52289c37b 100644
--- a/io_scene_3ds/__init__.py
+++ b/io_scene_3ds/__init__.py
@@ -54,6 +54,7 @@ class Import3DS(bpy.types.Operator, ImportHelper):
     '''Import from 3DS file format (.3ds)'''
     bl_idname = "import_scene.autodesk_3ds"
     bl_label = 'Import 3DS'
+    bl_options = {'UNDO'}
 
     filename_ext = ".3ds"
     filter_glob = StringProperty(default="*.3ds", options={'HIDDEN'})
diff --git a/io_scene_m3/__init__.py b/io_scene_m3/__init__.py
index d3501c87c..2fd2b2989 100644
--- a/io_scene_m3/__init__.py
+++ b/io_scene_m3/__init__.py
@@ -54,6 +54,7 @@ class ImportM3(bpy.types.Operator, ImportHelper):
     '''Import from M3 file format (.m3)'''
     bl_idname = 'import_scene.blizzard_m3'
     bl_label = 'Import M3'
+    bl_options = {'UNDO'}
 
     filename_ext = '.m3'
     filter_glob = StringProperty(default='*.m3', options={'HIDDEN'})
diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index 55a11b6bc..2ea405c7d 100644
--- a/io_scene_obj/__init__.py
+++ b/io_scene_obj/__init__.py
@@ -58,7 +58,7 @@ class ImportOBJ(bpy.types.Operator, ImportHelper):
     '''Load a Wavefront OBJ File'''
     bl_idname = "import_scene.obj"
     bl_label = "Import OBJ"
-    bl_options = {'PRESET'}
+    bl_options = {'PRESET', 'UNDO'}
 
     filename_ext = ".obj"
     filter_glob = StringProperty(
diff --git a/io_scene_x3d/__init__.py b/io_scene_x3d/__init__.py
index 05c7a6af8..d859dc699 100644
--- a/io_scene_x3d/__init__.py
+++ b/io_scene_x3d/__init__.py
@@ -57,7 +57,7 @@ class ImportX3D(bpy.types.Operator, ImportHelper):
     '''Import and X3D or VRML file'''
     bl_idname = "import_scene.x3d"
     bl_label = "Import X3D/VRML"
-    bl_options = {'PRESET'}
+    bl_options = {'PRESET', 'UNDO'}
 
     filename_ext = ".x3d"
     filter_glob = StringProperty(default="*.x3d;*.wrl", options={'HIDDEN'})
diff --git a/io_shape_mdd/__init__.py b/io_shape_mdd/__init__.py
index e7eea70a1..e7340750c 100644
--- a/io_shape_mdd/__init__.py
+++ b/io_shape_mdd/__init__.py
@@ -49,6 +49,7 @@ class ImportMDD(bpy.types.Operator, ImportHelper):
     '''Import MDD vertex keyframe file to shape keys'''
     bl_idname = "import_shape.mdd"
     bl_label = "Import MDD"
+    bl_options = {'UNDO'}
 
     filename_ext = ".mdd"
 
-- 
GitLab