mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-20 11:48:30 -06:00
Don't use boost::optional for gnc_commodity pointers
These pointers can simply be checked for null to determine whether they are set or not.
This commit is contained in:
parent
9384308b05
commit
4737665289
@ -267,10 +267,8 @@ void GncPreTrans::set (GncTransPropType prop_type, const std::string& value)
|
||||
break;
|
||||
|
||||
case GncTransPropType::COMMODITY:
|
||||
m_commodity = boost::none;
|
||||
comm = parse_commodity (value); // Throws if parsing fails
|
||||
if (comm)
|
||||
m_commodity = comm;
|
||||
m_currency = nullptr;
|
||||
m_currency = parse_commodity (value);
|
||||
break;
|
||||
|
||||
case GncTransPropType::VOID_REASON:
|
||||
@ -337,8 +335,8 @@ std::shared_ptr<DraftTransaction> GncPreTrans::create_trans (QofBook* book, gnc_
|
||||
auto trans = xaccMallocTransaction (book);
|
||||
xaccTransBeginEdit (trans);
|
||||
|
||||
if (m_commodity && gnc_commodity_is_currency(*m_commodity))
|
||||
xaccTransSetCurrency (trans, *m_commodity);
|
||||
if (gnc_commodity_is_currency(m_currency))
|
||||
xaccTransSetCurrency (trans, m_currency);
|
||||
else
|
||||
xaccTransSetCurrency (trans, currency);
|
||||
xaccTransSetDatePostedSecsNormalized (trans,
|
||||
@ -367,7 +365,7 @@ bool GncPreTrans::is_part_of (std::shared_ptr<GncPreTrans> parent)
|
||||
(!m_num || m_num == parent->m_num) &&
|
||||
(!m_desc || m_desc == parent->m_desc) &&
|
||||
(!m_notes || m_notes == parent->m_notes) &&
|
||||
(!m_commodity || m_commodity == parent->m_commodity) &&
|
||||
(!m_currency || m_currency == parent->m_currency) &&
|
||||
(!m_void_reason || m_void_reason == parent->m_void_reason) &&
|
||||
parent->m_errors.empty(); // A GncPreTrans with errors can never be a parent
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ struct DraftTransaction
|
||||
boost::optional<std::string> void_reason;
|
||||
};
|
||||
|
||||
struct GncPreTrans
|
||||
class GncPreTrans
|
||||
{
|
||||
public:
|
||||
GncPreTrans(int date_format, bool multi_split)
|
||||
@ -186,14 +186,14 @@ private:
|
||||
boost::optional<std::string> m_num;
|
||||
boost::optional<std::string> m_desc;
|
||||
boost::optional<std::string> m_notes;
|
||||
boost::optional<gnc_commodity*> m_commodity;
|
||||
gnc_commodity *m_currency;
|
||||
boost::optional<std::string> m_void_reason;
|
||||
bool created = false;
|
||||
|
||||
ErrMap m_errors;
|
||||
};
|
||||
|
||||
struct GncPreSplit
|
||||
class GncPreSplit
|
||||
{
|
||||
public:
|
||||
GncPreSplit (int date_format, int currency_format) : m_date_format{date_format},
|
||||
|
Loading…
Reference in New Issue
Block a user