[Bf-blender-cvs] [edc59cefb66] universal-scene-description: USD import: fix prim_path_mask storage.

Michael Kowalski noreply at git.blender.org
Wed Dec 14 18:19:02 CET 2022


Commit: edc59cefb66542d2f9cf11496d15ab2cff419b2b
Author: Michael Kowalski
Date:   Wed Dec 14 12:18:08 2022 -0500
Branches: universal-scene-description
https://developer.blender.org/rBedc59cefb66542d2f9cf11496d15ab2cff419b2b

USD import: fix prim_path_mask storage.

Now accessing the prm_path_mask string property as
an allocated string, as the string is of arbitrary
length.

===================================================================

M	source/blender/editors/io/io_usd.c
M	source/blender/io/usd/intern/usd_capi_import.cc
M	source/blender/io/usd/usd.h

===================================================================

diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c
index 0e26d6e8820..b1b511affa0 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -1119,8 +1119,7 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
 
   const bool create_collection = RNA_boolean_get(op->ptr, "create_collection");
 
-  char prim_path_mask[1024];
-  RNA_string_get(op->ptr, "prim_path_mask", prim_path_mask);
+  char *prim_path_mask = RNA_string_get_alloc(op->ptr, "prim_path_mask", NULL, 0, NULL);
 
   const bool import_guide = RNA_boolean_get(op->ptr, "import_guide");
   const bool import_proxy = RNA_boolean_get(op->ptr, "import_proxy");
@@ -1198,8 +1197,6 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
                                    .import_shapes = import_shapes,
                                    .import_defined_only = import_defined_only};
 
-  STRNCPY(params.prim_path_mask, prim_path_mask);
-
   const bool ok = USD_import(C, filename, &params, as_background_job);
 
   return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
diff --git a/source/blender/io/usd/intern/usd_capi_import.cc b/source/blender/io/usd/intern/usd_capi_import.cc
index e26e2d36adb..b0913db3d0f 100644
--- a/source/blender/io/usd/intern/usd_capi_import.cc
+++ b/source/blender/io/usd/intern/usd_capi_import.cc
@@ -648,6 +648,8 @@ static void import_endjob(void *customdata)
       break;
   }
 
+  MEM_freeN(data->params.prim_path_mask);
+
   WM_main_add_notifier(NC_SCENE | ND_FRAME, data->scene);
   report_job_duration(data);
 }
diff --git a/source/blender/io/usd/usd.h b/source/blender/io/usd/usd.h
index 097740db87a..714fb3069a5 100644
--- a/source/blender/io/usd/usd.h
+++ b/source/blender/io/usd/usd.h
@@ -167,7 +167,7 @@ struct USDImportParams {
   bool import_blendshapes;
   bool import_volumes;
   bool import_skeletons;
-  char prim_path_mask[1024];
+  char *prim_path_mask;
   bool import_subdiv;
   bool import_instance_proxies;
   bool create_collection;



More information about the Bf-blender-cvs mailing list