]> git.donarmstrong.com Git - lilypond.git/commitdiff
(lilypond-all): clear anonymous modules after
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 25 Jul 2005 11:21:56 +0000 (11:21 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 25 Jul 2005 11:21:56 +0000 (11:21 +0000)
processing files.

ChangeLog
lily/include/ly-module.hh
lily/ligature-engraver.cc
lily/ly-module.cc
scm/lily.scm

index 279501be59a91ea2f3fa0cbac4874c365acb8314..3b3b8ee17e22d4e1e8297b2f9cd6294a20694208 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-07-25  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * scm/lily.scm (lilypond-all): clear anonymous modules after
+       processing files.
+
 2005-07-24  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
        * flower/include/guile-compatibility.hh (SCM_I_CONSP): add
index 96d2e1fccfb583c5c372e58f9b39e0ed9e0387b7..a45fad64c8631731123087018f3ccde4d194b227 100644 (file)
@@ -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 */
index f773c15b1cdb3d3f5e666a66424ad79d42550b5d..115eecb66287bbc2f9c5cd30eba191c22e6456c9 100644 (file)
@@ -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,
index 7d613fcdd8ad87251ff29bacb433f05c515026c3..3890eb0ad4b78c20b46970b985f845f294a5a86f 100644 (file)
 #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;
 }
 
index a3f166477a2a128a4cb37c6dfa0261bc4cd03d6f..b68ddc450672ba5ed67ef0abc26114a717c4c6a9 100644 (file)
@@ -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)