Merge commit 'master@6ed15c5a41130b55cb57a43a8a9470a91d38c3d5' into blender2.8
[blender.git] / source / blender / alembic / intern / alembic_capi.cc
index 4aa4b8d548fea6cf2e3ccf1cfd2440e5dc03da75..61b18c7112fec47cdaea395d102eb29903b2d952 100644 (file)
@@ -175,7 +175,7 @@ static bool gather_objects_paths(const IObject &object, ListBase *object_paths)
                void *abc_path_void = MEM_callocN(sizeof(AlembicObjectPath), "AlembicObjectPath");
                AlembicObjectPath *abc_path = static_cast<AlembicObjectPath *>(abc_path_void);
 
-               BLI_strncpy(abc_path->path, object.getFullName().c_str(), PATH_MAX);
+               BLI_strncpy(abc_path->path, object.getFullName().c_str(), sizeof(abc_path->path));
                BLI_addtail(object_paths, abc_path);
        }
 
@@ -377,6 +377,7 @@ bool ABC_export(
                std::swap(job->settings.frame_start, job->settings.frame_end);
        }
 
+       bool export_ok = false;
        if (as_background_job) {
                wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
                                            CTX_wm_window(C),
@@ -399,9 +400,12 @@ bool ABC_export(
 
                export_startjob(job, &stop, &do_update, &progress);
                export_endjob(job);
+               export_ok = job->export_ok;
+
+               MEM_freeN(job);
        }
 
-       return job->export_ok;
+       return export_ok;
 }
 
 /* ********************** Import file ********************** */
@@ -560,7 +564,7 @@ static std::pair<bool, AbcObjectReader *> visit_object(
 
                AlembicObjectPath *abc_path = static_cast<AlembicObjectPath *>(
                                                  MEM_callocN(sizeof(AlembicObjectPath), "AlembicObjectPath"));
-               BLI_strncpy(abc_path->path, full_name.c_str(), PATH_MAX);
+               BLI_strncpy(abc_path->path, full_name.c_str(), sizeof(abc_path->path));
                BLI_addtail(&settings.cache_file->object_paths, abc_path);
 
                /* We can now assign this reader as parent for our children. */
@@ -903,13 +907,14 @@ bool ABC_import(bContext *C, const char *filepath, float scale, bool is_sequence
 
        G.is_break = false;
 
+       bool import_ok = false;
        if (as_background_job) {
                wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
-                                                                       CTX_wm_window(C),
-                                                                       job->scene,
-                                                                       "Alembic Import",
-                                                                       WM_JOB_PROGRESS,
-                                                                       WM_JOB_TYPE_ALEMBIC);
+                                           CTX_wm_window(C),
+                                           job->scene,
+                                           "Alembic Import",
+                                           WM_JOB_PROGRESS,
+                                           WM_JOB_TYPE_ALEMBIC);
 
                /* setup job */
                WM_jobs_customdata_set(wm_job, job, import_freejob);
@@ -925,9 +930,12 @@ bool ABC_import(bContext *C, const char *filepath, float scale, bool is_sequence
 
                import_startjob(job, &stop, &do_update, &progress);
                import_endjob(job);
+               import_ok = job->import_ok;
+
+               import_freejob(job);
        }
 
-       return job->import_ok;
+       return import_ok;
 }
 
 /* ************************************************************************** */
@@ -1012,6 +1020,12 @@ void CacheReader_free(CacheReader *reader)
        }
 }
 
+void CacheReader_incref(CacheReader *reader)
+{
+       AbcObjectReader *abc_reader = reinterpret_cast<AbcObjectReader *>(reader);
+       abc_reader->incref();
+}
+
 CacheReader *CacheReader_open_alembic_object(AbcArchiveHandle *handle, CacheReader *reader, Object *object, const char *object_path)
 {
        if (object_path[0] == '\0') {