Changeset View
Changeset View
Standalone View
Standalone View
source/blender/alembic/intern/alembic_capi.cc
| Show First 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | static void export_endjob(void *customdata) | ||||
| ExportJobData *data = static_cast<ExportJobData *>(customdata); | ExportJobData *data = static_cast<ExportJobData *>(customdata); | ||||
| if (data->was_canceled && BLI_exists(data->filename)) { | if (data->was_canceled && BLI_exists(data->filename)) { | ||||
| BLI_delete(data->filename, false, false); | BLI_delete(data->filename, false, false); | ||||
| } | } | ||||
| if (!data->settings.logger.empty()) { | if (!data->settings.logger.empty()) { | ||||
| std::cerr << data->settings.logger; | std::cerr << data->settings.logger; | ||||
| WM_report(RPT_ERROR, "Errors occured during the export, look in the console to know more..."); | WM_report(RPT_ERROR, "Errors occurred during the export, look in the console to know more..."); | ||||
| } | } | ||||
| G.is_rendering = false; | G.is_rendering = false; | ||||
| BKE_spacedata_draw_locks(false); | BKE_spacedata_draw_locks(false); | ||||
| } | } | ||||
| bool ABC_export( | bool ABC_export( | ||||
| Scene *scene, | Scene *scene, | ||||
| bContext *C, | bContext *C, | ||||
| const char *filepath, | const char *filepath, | ||||
| const struct AlembicExportParams *params, | const struct AlembicExportParams *params, | ||||
| bool as_background_job) | bool as_background_job) | ||||
| { | { | ||||
| ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData")); | ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData")); | ||||
| job->scene = scene; | job->scene = scene; | ||||
| job->bmain = CTX_data_main(C); | job->bmain = CTX_data_main(C); | ||||
| job->export_ok = false; | job->export_ok = false; | ||||
| BLI_strncpy(job->filename, filepath, 1024); | BLI_strncpy(job->filename, filepath, 1024); | ||||
| /* Alright, alright, alright.... | /* Alright, alright, alright.... | ||||
| * | * | ||||
| * ExportJobData contains an ExportSettings containing a SimpleLogger. | * ExportJobData contains an ExportSettings containing a SimpleLogger. | ||||
| * | * | ||||
| * Since ExportJobData is a C-style struct dynamically allocated with | * Since ExportJobData is a C-style struct dynamically allocated with | ||||
| * MEM_mallocN (see above), its construtor is never called, therefore the | * MEM_mallocN (see above), its constructor is never called, therefore the | ||||
| * ExportSettings constructor is not called which implies that the | * ExportSettings constructor is not called which implies that the | ||||
| * SimpleLogger one is not called either. SimpleLogger in turn does not call | * SimpleLogger one is not called either. SimpleLogger in turn does not call | ||||
| * the constructor of its data members which ultimately means that its | * the constructor of its data members which ultimately means that its | ||||
| * std::ostringstream member has a NULL pointer. To be able to properly use | * std::ostringstream member has a NULL pointer. To be able to properly use | ||||
| * the stream's operator<<, the pointer needs to be set, therefore we have | * the stream's operator<<, the pointer needs to be set, therefore we have | ||||
| * to properly construct everything. And this is done using the placement | * to properly construct everything. And this is done using the placement | ||||
| * new operator as here below. It seems hackish, but I'm too lazy to | * new operator as here below. It seems hackish, but I'm too lazy to | ||||
| * do bigger refactor and maybe there is a better way which does not involve | * do bigger refactor and maybe there is a better way which does not involve | ||||
| ▲ Show 20 Lines • Show All 462 Lines • ▼ Show 20 Lines | static void import_endjob(void *user_data) | ||||
| std::vector<AbcObjectReader *>::iterator iter; | std::vector<AbcObjectReader *>::iterator iter; | ||||
| /* Delete objects on cancelation. */ | /* Delete objects on cancelation. */ | ||||
| if (data->was_cancelled) { | if (data->was_cancelled) { | ||||
| for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) { | for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) { | ||||
| Object *ob = (*iter)->object(); | Object *ob = (*iter)->object(); | ||||
| /* It's possible that cancellation occured between the creation of | /* It's possible that cancellation occurred between the creation of | ||||
| * the reader and the creation of the Blender object. */ | * the reader and the creation of the Blender object. */ | ||||
| if (ob == NULL) continue; | if (ob == NULL) continue; | ||||
| BKE_libblock_free_us(data->bmain, ob); | BKE_libblock_free_us(data->bmain, ob); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Add object to scene. */ | /* Add object to scene. */ | ||||
| ▲ Show 20 Lines • Show All 193 Lines • Show Last 20 Lines | |||||