[Bf-blender-cvs] [c5302b95de5] lanpr-under-gp: LineArt: Strict thread sync.

YimingWu noreply at git.blender.org
Fri Sep 18 17:18:16 CEST 2020


Commit: c5302b95de50c8f89ae619d39ee5cd8f8e5c2002
Author: YimingWu
Date:   Fri Sep 18 23:17:50 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rBc5302b95de50c8f89ae619d39ee5cd8f8e5c2002

LineArt: Strict thread sync.

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

M	source/blender/editors/lineart/lineart_cpu.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c

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

diff --git a/source/blender/editors/lineart/lineart_cpu.c b/source/blender/editors/lineart/lineart_cpu.c
index ee8aecbf6b6..eea6b7174a6 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -1786,6 +1786,10 @@ static void lineart_main_load_geometries(Depsgraph *depsgraph,
     int usage = ED_lineart_object_collection_usage_check(scene->master_collection, ob);
 
     lineart_geometry_object_load(ob, view, proj, rb, usage);
+
+    if (ED_lineart_calculation_flag_check(LRT_RENDER_CANCELING)) {
+      return;
+    }
   }
   DEG_OBJECT_ITER_END;
 }
@@ -3834,9 +3838,7 @@ void ED_lineart_compute_feature_lines_background(Depsgraph *dg, const int show_f
     if (G.debug_value == 4000) {
       printf("LRT: Canceling.\n");
     }
-    /* No need to lock anything as we are canceling anyway. Will there be any potential memory
-     * problem 'while' canceling? */
-    BLI_spin_unlock(&lineart_share.lock_loader);
+    /* Can't release the lock just right now, because loading function might still be canceling */
   }
 
   if (tp_read) {
@@ -4061,6 +4063,10 @@ static int lineart_gpencil_update_strokes_exec(bContext *C, wmOperator *UNUSED(o
 
   ED_lineart_compute_feature_lines_background(dg, 0);
 
+  /* Wait for loading finish */
+  BLI_spin_lock(&lineart_share.lock_loader);
+  BLI_spin_unlock(&lineart_share.lock_loader);
+
   WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
 
   return OPERATOR_FINISHED;
@@ -4100,6 +4106,11 @@ static int lineart_gpencil_bake_strokes_invoke(bContext *C,
 
     BLI_spin_lock(&lineart_share.lock_loader);
     ED_lineart_compute_feature_lines_background(dg, 0);
+
+    /* Wait for loading finish */
+    BLI_spin_lock(&lineart_share.lock_loader);
+    BLI_spin_unlock(&lineart_share.lock_loader);
+
     while (!ED_lineart_modifier_sync_flag_check(LRT_SYNC_FRESH) ||
            !ED_lineart_calculation_flag_check(LRT_RENDER_FINISHED)) {
       /* Wait till it's done. */
@@ -4296,15 +4307,15 @@ void ED_lineart_update_render_progress(int nr, const char *info)
   if (lineart_share.main_window) {
     if (nr == 100) {
       /*WM_CURSOR_DEFAULT doesn't seem to work?*/
-      WM_cursor_set(lineart_share.main_window, WM_CURSOR_NW_ARROW);
-      WM_cursor_modal_restore(lineart_share.main_window);
+      // WM_cursor_set(lineart_share.main_window, WM_CURSOR_NW_ARROW);
+      // WM_cursor_modal_restore(lineart_share.main_window);
       WM_progress_clear(lineart_share.main_window);
     }
     else {
       /* Hack: this prevents XWindow cursor error crashes when this thread and an operator is
        * setting cursor at the same time. */
       if (!G.moving) {
-        WM_cursor_time(lineart_share.main_window, nr);
+        // WM_cursor_time(lineart_share.main_window, nr);
         WM_progress_set(lineart_share.main_window, (float)nr / 100);
       }
     }
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index b7befb11eaf..c3a93208f88 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -245,6 +245,9 @@ static void bakeModifier(Main *UNUSED(bmain),
       ED_lineart_modifier_sync_flag_set(LRT_SYNC_WAITING, 1);
       BLI_spin_lock(&lineart_share.lock_loader);
       ED_lineart_compute_feature_lines_background(depsgraph, 1);
+      /* Wait for loading finish */
+      BLI_spin_lock(&lineart_share.lock_loader);
+      BLI_spin_unlock(&lineart_share.lock_loader);
     }
     while (!ED_lineart_modifier_sync_flag_check(LRT_SYNC_FRESH) ||
            !ED_lineart_calculation_flag_check(LRT_RENDER_FINISHED)) {



More information about the Bf-blender-cvs mailing list