From: David Kastrup Date: Thu, 14 May 2015 18:50:57 +0000 (+0200) Subject: Issue 4398/2: Move the protection of global_translator_dict to Protected_scm X-Git-Tag: release/2.19.21-1~11 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=33e8458abc40b7b8b71ab0b3446382b1495a1489;p=lilypond.git Issue 4398/2: Move the protection of global_translator_dict to Protected_scm Previously, this abused the protect/unprotect mechanism only intended for temporary protection. --- diff --git a/lily/translator-ctors.cc b/lily/translator-ctors.cc index 168f1ad6de..bf39a7d96e 100644 --- a/lily/translator-ctors.cc +++ b/lily/translator-ctors.cc @@ -22,12 +22,14 @@ #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 *