r18515 - gnucash/trunk/src/report/report-system - Don't leak a file port when saving reports.

Mike Alexander mta at code.gnucash.org
Thu Dec 17 02:33:27 EST 2009


Author: mta
Date: 2009-12-17 02:33:26 -0500 (Thu, 17 Dec 2009)
New Revision: 18515
Trac: http://svn.gnucash.org/trac/changeset/18515

Modified:
   gnucash/trunk/src/report/report-system/report.scm
Log:
Don't leak a file port when saving reports.

Modified: gnucash/trunk/src/report/report-system/report.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report.scm	2009-12-17 07:28:30 UTC (rev 18514)
+++ gnucash/trunk/src/report/report-system/report.scm	2009-12-17 07:33:26 UTC (rev 18515)
@@ -576,10 +576,9 @@
          ;; #Bug#342206.
          (save-result (eval-string saved-form)))
     (if (record? save-result)
-        (begin
-          (display saved-form
-                   (open-file conf-file-name "a"))
-          (force-output)
+        (let ((report-port (open-file conf-file-name "a")))
+          (display saved-form report-port)
+          (close report-port)
 	      (let ((report-name (gnc:report-name report)))
 		(gnc-info-dialog
 		 '()
@@ -592,11 +591,11 @@
 	  ))))
 
 (define (gnc:report-template-save-to-savefile report-template)
-  (let ((conf-file-name gnc:current-saved-reports)
-	(saved-form (gnc:report-template-generate-saved-forms report-template)))
-    (display saved-form
-	     (open-file conf-file-name "a"))
-    (force-output)))
+  (let* ((conf-file-name gnc:current-saved-reports)
+	(saved-form (gnc:report-template-generate-saved-forms report-template))
+	(report-port (open-file conf-file-name "a")))
+    (display saved-form report-port)
+    (close report-port)))
 
 ;; save all custom reports, moving the old version of the
 ;; saved-reports file aside as a backup



More information about the gnucash-changes mailing list