[Bf-blender-cvs] [03bf84db86b] master: Fix T66373: Strange translation text behaviour.

Bastien Montagne noreply at git.blender.org
Tue Aug 13 15:37:20 CEST 2019


Commit: 03bf84db86bc023cfad501b1b4764cecb6435422
Author: Bastien Montagne
Date:   Tue Aug 13 12:56:27 2019 +0200
Branches: master
https://developer.blender.org/rB03bf84db86bc023cfad501b1b4764cecb6435422

Fix T66373: Strange translation text behaviour.

i18n code does not work from threads on some plaforms, so it is disabled
in Blender when called from non-main thread.

Means that we have to go to a slightly different approach, with dirty
tag and generating string on request for UI.

Note: Also had to update the `info` string size, to fit with expensive
asiatic scripts in utf-8... Using mem for that kind of runtime data is
not really nice, but for now it will have to do.

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

M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/makesdna/DNA_object_force_types.h
M	source/blender/makesrna/intern/rna_object_force.c

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

diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 90ae512074d..2d42406520d 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -3337,7 +3337,7 @@ int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra)
     cache->cached_frames[cfra - cache->startframe] = 1;
   }
 
-  BKE_ptcache_update_info(pid);
+  cache->flag |= PTCACHE_FLAG_INFO_DIRTY;
 
   return !error;
 }
@@ -3500,8 +3500,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
       break;
   }
 
-  BKE_ptcache_update_info(pid);
+  pid->cache->flag |= PTCACHE_FLAG_INFO_DIRTY;
 }
+
 int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
 {
   if (!pid->cache) {
@@ -4288,7 +4289,7 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid)
 
   BKE_ptcache_id_time(pid, NULL, 0.0f, NULL, NULL, NULL);
 
-  BKE_ptcache_update_info(pid);
+  cache->flag |= PTCACHE_FLAG_INFO_DIRTY;
 
   if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
     if (cache->index) {
@@ -4461,7 +4462,8 @@ void BKE_ptcache_load_external(PTCacheID *pid)
     cache->cached_frames = NULL;
     cache->cached_frames_len = 0;
   }
-  BKE_ptcache_update_info(pid);
+
+  cache->flag |= PTCACHE_FLAG_INFO_DIRTY;
 }
 
 void BKE_ptcache_update_info(PTCacheID *pid)
@@ -4469,7 +4471,9 @@ void BKE_ptcache_update_info(PTCacheID *pid)
   PointCache *cache = pid->cache;
   PTCacheExtra *extra = NULL;
   int totframes = 0;
-  char mem_info[64];
+  char mem_info[sizeof(((PointCache *)0)->info) / sizeof(*(((PointCache *)0)->info))];
+
+  cache->flag &= ~PTCACHE_FLAG_INFO_DIRTY;
 
   if (cache->flag & PTCACHE_EXTERNAL) {
     int cfra = cache->startframe;
diff --git a/source/blender/makesdna/DNA_object_force_types.h b/source/blender/makesdna/DNA_object_force_types.h
index 2207e08558d..34a1b6d3e0b 100644
--- a/source/blender/makesdna/DNA_object_force_types.h
+++ b/source/blender/makesdna/DNA_object_force_types.h
@@ -271,7 +271,7 @@ typedef struct PointCache {
 
   char name[64];
   char prev_name[64];
-  char info[64];
+  char info[128];
   /** File path, 1024 = FILE_MAX. */
   char path[1024];
 
@@ -497,6 +497,8 @@ typedef struct SoftBody {
 #define PTCACHE_FAKE_SMOKE (1 << 12)
 #define PTCACHE_IGNORE_CLEAR (1 << 13)
 
+#define PTCACHE_FLAG_INFO_DIRTY (1 << 14)
+
 /* PTCACHE_OUTDATED + PTCACHE_FRAMES_SKIPPED */
 #define PTCACHE_REDO_NEEDED 258
 
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index ab6cffe615d..066e350ab3e 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -140,7 +140,7 @@ static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
     if (pid.type == PTCACHE_TYPE_SMOKE_DOMAIN) {
       cache->step = 1;
     }
-    BKE_ptcache_update_info(&pid);
+    cache->flag |= PTCACHE_FLAG_INFO_DIRTY;
   }
 }
 
@@ -292,6 +292,24 @@ static void rna_PointCache_frame_step_range(
   }
 }
 
+int rna_Cache_info_length(PointerRNA *ptr)
+{
+  PointCache *cache = (PointCache *)ptr->data;
+  Object *ob = (Object *)ptr->id.data;
+
+  if (!ob) {
+    return 0;
+  }
+
+  PTCacheID pid = BKE_ptcache_id_find(ob, NULL, cache);
+
+  if (cache->flag & PTCACHE_FLAG_INFO_DIRTY) {
+    BKE_ptcache_update_info(&pid);
+  }
+
+  return (int)strlen(cache->info);
+}
+
 static char *rna_CollisionSettings_path(PointerRNA *UNUSED(ptr))
 {
   /* both methods work ok, but return the shorter path */
@@ -870,6 +888,11 @@ static void rna_def_pointcache_common(StructRNA *srna)
   prop = RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
   RNA_def_property_string_sdna(prop, NULL, "info");
   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+  /* Note that we do not actually need a getter here, `rna_Cache_info_length` will upate the info
+   * string just as well. */
+  RNA_def_property_string_funcs(prop, NULL, "rna_Cache_info_length", NULL);
+  RNA_def_property_string_maxlength(
+      prop, sizeof(((PointCache *)0)->info) / sizeof(*(((PointCache *)0)->info)));
   RNA_def_property_ui_text(prop, "Cache Info", "Info on current cache status");
 
   prop = RNA_def_property(srna, "use_external", PROP_BOOLEAN, PROP_NONE);



More information about the Bf-blender-cvs mailing list