Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-06-22 18:53:14 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-06-22 19:10:42 +0300
commit25d2222c302acd7278b49f30a74adba6b9457012 (patch)
treebbac7004214fd7edd4a2052630b8b5fab66a4369 /source/blender/io
parentfdfe85c616d2d43c171bfd120c809e530e18dc35 (diff)
Fix T77754: Crash after any alembic import undo in an empty scene
Thanks @mont29 for this patch. This creates an explicit undo step after the Alembic importer has finished running. This is necessary when the importer runs as a background job.
Diffstat (limited to 'source/blender/io')
-rw-r--r--source/blender/io/alembic/intern/alembic_capi.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc
index 0b4b184359b..bca84b97749 100644
--- a/source/blender/io/alembic/intern/alembic_capi.cc
+++ b/source/blender/io/alembic/intern/alembic_capi.cc
@@ -51,6 +51,8 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "ED_undo.h"
+
/* SpaceType struct has a member called 'new' which obviously conflicts with C++
* so temporarily redefining the new keyword to make it compile. */
#define new extern_new
@@ -429,6 +431,7 @@ enum {
};
struct ImportJobData {
+ bContext *C;
Main *bmain;
Scene *scene;
ViewLayer *view_layer;
@@ -447,6 +450,7 @@ struct ImportJobData {
char error_code;
bool was_cancelled;
bool import_ok;
+ bool is_background_job;
};
static void import_startjob(void *user_data, short *stop, short *do_update, float *progress)
@@ -630,6 +634,12 @@ static void import_endjob(void *user_data)
DEG_id_tag_update(&data->scene->id, ID_RECALC_BASE_FLAGS);
DEG_relations_tag_update(data->bmain);
+
+ if (data->is_background_job) {
+ /* Blender already returned from the import operator, so we need to store our own extra undo
+ * step. */
+ ED_undo_push(data->C, "Alembic Import Finished");
+ }
}
for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) {
@@ -675,6 +685,7 @@ bool ABC_import(bContext *C,
{
/* Using new here since MEM_* functions do not call constructor to properly initialize data. */
ImportJobData *job = new ImportJobData();
+ job->C = C;
job->bmain = CTX_data_main(C);
job->scene = CTX_data_scene(C);
job->view_layer = CTX_data_view_layer(C);
@@ -691,6 +702,7 @@ bool ABC_import(bContext *C,
job->error_code = ABC_NO_ERROR;
job->was_cancelled = false;
job->archive = NULL;
+ job->is_background_job = as_background_job;
G.is_break = false;