From 33e8458abc40b7b8b71ab0b3446382b1495a1489 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Thu, 14 May 2015 20:50:57 +0200 Subject: [PATCH] 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. --- lily/translator-ctors.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 * -- 2.39.5