]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4398/2: Move the protection of global_translator_dict to Protected_scm
authorDavid Kastrup <dak@gnu.org>
Thu, 14 May 2015 18:50:57 +0000 (20:50 +0200)
committerDavid Kastrup <dak@gnu.org>
Thu, 21 May 2015 18:29:54 +0000 (20:29 +0200)
Previously, this abused the protect/unprotect mechanism only intended
for temporary protection.

lily/translator-ctors.cc

index 168f1ad6de676f38d96f84fe8782b8c0e39c4924..bf39a7d96eec59a586f0ca68db7d947f184431c9 100644 (file)
 #include "international.hh"
 #include "scm-hash.hh"
 #include "warn.hh"
+#include "protected-scm.hh"
 
 /*
   should delete these after exit.
 */
 
 Scheme_hash_table *global_translator_dict = 0;
+Protected_scm global_translator_dict_scm;
 
 LY_DEFINE (get_all_translators, "ly:get-all-translators", 0, 0, 0, (),
            "Return a list of all translator objects that may be"
@@ -45,12 +47,13 @@ void
 add_translator (Translator *t)
 {
   if (!global_translator_dict)
-    global_translator_dict = new Scheme_hash_table;
+    {
+      global_translator_dict = new Scheme_hash_table;
+      global_translator_dict_scm = global_translator_dict->unprotect ();
+    }
 
   SCM k = ly_symbol2scm (t->class_name ());
-  global_translator_dict->set (k, t->self_scm ());
-
-  t->unprotect ();
+  global_translator_dict->set (k, t->unprotect ());
 }
 
 Translator *