lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master d73dd4a 4/4: Use AutoScale() for new as well


From: Greg Chicares
Subject: [lmi-commits] [lmi] master d73dd4a 4/4: Use AutoScale() for new as well as old PDF code
Date: Thu, 1 Mar 2018 13:33:05 -0500 (EST)

branch: master
commit d73dd4a7d846c89a8423d0c397cdaa1ec5de7a5c
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Use AutoScale() for new as well as old PDF code
    
    Fixed the problem described here:
      https://lists.nongnu.org/archive/html/lmi/2018-03/msg00000.html
---
 ledger_pdf.cpp | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/ledger_pdf.cpp b/ledger_pdf.cpp
index df1dbc6..8d5ff98 100644
--- a/ledger_pdf.cpp
+++ b/ledger_pdf.cpp
@@ -33,7 +33,18 @@
 
 #include <iostream>                     // cerr // PDF !! expunge
 
-/// Write ledger as pdf.
+/// Write a scaled copy of the ledger to a PDF file.
+///
+/// PDF !! Does the following block comment actually apply here? and
+/// is it time to address the comment about shared_ptr members in
+/// class ledger?
+///
+/// The original ledger must not be modified because scaling is not
+/// reentrant. However, copying does not prevent that problem here,
+/// because what is scaled is actually not copied due to use of
+/// shared_ptr; see comment on
+///   https://savannah.nongnu.org/bugs/index.php?13599
+/// in the ledger-class implementation.
 
 std::string write_ledger_as_pdf(Ledger const& ledger, fs::path const& filepath)
 {
@@ -75,8 +86,10 @@ std::string write_ledger_as_pdf(Ledger const& ledger, 
fs::path const& filepath)
     // use should be reconsidered everywhere else.
     fs::path pdf_out_file = unique_filepath(print_dir / filepath, ".pdf");
 
+    Ledger scaled_ledger(ledger);
+    scaled_ledger.AutoScale();
     auto const pdf = ledger_pdf_generator::create();
-    pdf->write(ledger, pdf_out_file);
+    pdf->write(scaled_ledger, pdf_out_file);
 
     return pdf_out_file.string();
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]