From: Han-Wen Nienhuys Date: Mon, 25 Jul 2005 11:21:56 +0000 (+0000) Subject: (lilypond-all): clear anonymous modules after X-Git-Tag: release/2.7.3~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2fa83cb202267f58cdfd8ad1496851f3d0816ddd;p=lilypond.git (lilypond-all): clear anonymous modules after processing files. --- diff --git a/ChangeLog b/ChangeLog index 279501be59..3b3b8ee17e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-07-25 Han-Wen Nienhuys + + * scm/lily.scm (lilypond-all): clear anonymous modules after + processing files. + 2005-07-24 Han-Wen Nienhuys * flower/include/guile-compatibility.hh (SCM_I_CONSP): add diff --git a/lily/include/ly-module.hh b/lily/include/ly-module.hh index 96d2e1fccf..a45fad64c8 100644 --- a/lily/include/ly-module.hh +++ b/lily/include/ly-module.hh @@ -18,7 +18,7 @@ SCM ly_modules_lookup (SCM modules, SCM sym, SCM); SCM ly_module_symbols (SCM mod); void ly_reexport_module (SCM mod); inline bool ly_is_module (SCM x) { return SCM_MODULEP (x); } -void ly_clear_anonymous_modules (); +SCM ly_clear_anonymous_modules (); SCM ly_use_module (SCM mod, SCM used); #endif /* LY_MODULE_HH */ diff --git a/lily/ligature-engraver.cc b/lily/ligature-engraver.cc index f773c15b1c..115eecb662 100644 --- a/lily/ligature-engraver.cc +++ b/lily/ligature-engraver.cc @@ -15,6 +15,8 @@ #include "warn.hh" #include "context.hh" +#include "translator.icc" + /* * This abstract class provides the general framework for ligatures of * any kind. It cares for handling start/stop ligatures events and @@ -278,15 +280,16 @@ Ligature_engraver::acknowledge_note_head (Grob_info info) void Ligature_engraver::acknowledge_rest (Grob_info info) { - info.music_cause ()->origin ()->warning (_ ("ignoring rest: ligature may not contain rest")); - prev_start_event_->origin ()->warning (_ ("ligature was started here")); - // TODO: maybe better should stop ligature here rather than - // ignoring the rest? + if (ligature_) + { + info.music_cause ()->origin ()->warning (_ ("ignoring rest: ligature may not contain rest")); + prev_start_event_->origin ()->warning (_ ("ligature was started here")); + // TODO: maybe better should stop ligature here rather than + // ignoring the rest? + } } -#include "translator.icc" - ADD_ACKNOWLEDGER(Ligature_engraver, rest); ADD_ACKNOWLEDGER(Ligature_engraver, note_head); ADD_TRANSLATOR (Ligature_engraver, diff --git a/lily/ly-module.cc b/lily/ly-module.cc index 7d613fcdd8..3890eb0ad4 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -10,9 +10,43 @@ #include "warn.hh" #include "main.hh" #include "string.hh" +#include "protected-scm.hh" + +#define MODULE_GC_KLUDGE #define FUNC_NAME __FUNCTION__ +Protected_scm anonymous_modules = SCM_EOL; + +LY_DEFINE(ly_clear_anonymous_modules, "ly:clear-anonymous-modules", + 0,0,0,(), + "Plug a GUILE 1.6 and 1.7 memory leak by breaking a weak reference " + "pointer cycle explicitly." + ) +{ +#ifdef MODULE_GC_KLUDGE + for (SCM s = anonymous_modules; + scm_is_pair (s); + s = scm_cdr (s)) + { + SCM module = scm_car (s); + SCM closure = SCM_MODULE_EVAL_CLOSURE(module); + SCM prop = scm_procedure_property (closure, ly_symbol2scm ("module")); + + if (ly_is_module (prop)) + { + scm_set_procedure_property_x (closure, ly_symbol2scm ("module"), + SCM_BOOL_F); + } + } + + anonymous_modules = SCM_EOL; + +#endif + + return SCM_UNSPECIFIED; +} + SCM ly_make_anonymous_module (bool safe) { @@ -35,6 +69,11 @@ ly_make_anonymous_module (bool safe) SCM proc = ly_lily_module_constant ("make-safe-lilypond-module"); mod = scm_call_0 (proc); } + +#ifdef MODULE_GC_KLUDGE + anonymous_modules = scm_cons (mod, anonymous_modules); +#endif + return mod; } diff --git a/scm/lily.scm b/scm/lily.scm index a3f166477a..b68ddc4506 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -374,8 +374,11 @@ The syntax is the same as `define*-public'." (let* ((failed '()) (handler (lambda (key failed-file) (set! failed (append (list failed-file) failed))))) - ;;(handler (lambda (key . arg) (set! failed (append arg failed))))) - (for-each (lambda (x) (lilypond-file handler x)) files) + (for-each + (lambda (x) + (lilypond-file handler x) + (ly:clear-anonymous-modules)) + files) failed)) (define (lilypond-file handler file-name)