Skip to content

Commit

Permalink
[portfolios] don't ref/unref manually, let price-guardian unref
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Jul 27, 2023
1 parent 28b3311 commit 70ecf15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
9 changes: 2 additions & 7 deletions gnucash/report/reports/standard/advanced-portfolio.scm
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ by preventing negative stock balances.<br/>")
(if (gnc-commodity-equiv currency (gnc-price-get-commodity p))
(set! price (gnc-price-invert p))))
price-list)
(gnc-price-ref price)
(gnc:price-ref price)
(gnc-price-list-destroy price-list)
price)))

Expand Down Expand Up @@ -470,7 +470,6 @@ by preventing negative stock balances.<br/>")
(if (not (gnc-numeric-zero-p (gnc:gnc-monetary-amount trans-price)))
;; We can exchange the price from this transaction into the report currency
(begin
(if price (gnc-price-unref price))
(set! pricing-txn trans)
(set! price trans-price)
(gnc:debug "Transaction price is " (gnc:monetary->string price))
Expand Down Expand Up @@ -942,13 +941,9 @@ by preventing negative stock balances.<br/>")
row-style
activecols)

(if (and (not use-txn) price) (gnc-price-unref price))
(table-add-stock-rows-internal rest (not odd-row?))
)
(begin
(if (and (not use-txn) price) (gnc-price-unref price))
(table-add-stock-rows-internal rest odd-row?)
)
(table-add-stock-rows-internal rest odd-row?)
)
)))

Expand Down
10 changes: 4 additions & 6 deletions gnucash/report/reports/standard/portfolio.scm
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@
"number-cell" value)))
;;(display (format #f "Shares: ~6d " (gnc-numeric-to-double units)))
;;(display units) (newline)
(if price (gnc-price-unref price))
(table-add-stock-rows-internal rest (not odd-row?)))
(begin (if price (gnc-price-unref price))
(table-add-stock-rows-internal rest odd-row?))))))
(table-add-stock-rows-internal rest odd-row?)))))

(set! work-to-do (length accounts))
(table-add-stock-rows-internal accounts #t)))
Expand Down Expand Up @@ -211,7 +209,7 @@
(car price)
(gnc-price-invert (car price))))
(v (gnc-price-get-value the_price)))
(gnc-price-ref (car price))
(gnc:price-ref (car price))
(cons (car price) v))
(cons #f (gnc-numeric-zero)))))
(if price (gnc-price-list-destroy price))
Expand All @@ -223,7 +221,7 @@
(cond
((null? price) (cons #f 0))
(else (let ((p (car price)))
(gnc-price-ref p)
(gnc:price-ref p)
(gnc-price-list-destroy price)
(cons p (gnc-price-get-value p))))))))
((pricedb-nearest)
Expand All @@ -233,7 +231,7 @@
pricedb foreign (time64CanonicalDayTime date)))
(fn (if (and price (> (length price) 0))
(let* ((v (gnc-price-get-value (car price))))
(gnc-price-ref (car price))
(gnc:price-ref (car price))
(cons (car price) v))
(cons #f (gnc-numeric-zero)))))
(if price (gnc-price-list-destroy price))
Expand Down

0 comments on commit 70ecf15

Please sign in to comment.