diff options
-rw-r--r-- | interchange/ord.hxx | 1 | ||||
-rw-r--r-- | ord.cxx | 11 |
2 files changed, 7 insertions, 5 deletions
diff --git a/interchange/ord.hxx b/interchange/ord.hxx index 2d18891..56bb7d3 100644 --- a/interchange/ord.hxx +++ b/interchange/ord.hxx @@ -62,6 +62,7 @@ namespace QInterchange { void addItem(Item const& item); QList<Item> items; struct interchange_ord_order* m_data; + QString profile; double m_subtotal; double m_shipping; double m_totalCost; @@ -6,6 +6,7 @@ namespace QInterchange { static Ord* ord; + static char* order_profile; Ord::Ord(struct interchange_ord_order *order, QObject* parent) : QAbstractListModel{parent}, @@ -89,16 +90,16 @@ namespace QInterchange { void Ord::setProfile(QString const& profile) { - auto orderProfile = profile.toLatin1().data(); - if (m_data->profile) free(m_data->profile); - m_data->profile = (char*)malloc(strlen(orderProfile) + 1); - strcpy(m_data->profile, orderProfile); + if (this->profile != profile) this->profile = profile; } void Ord::checkout(Member& member) { - interchange_ord_checkout(m_data, member.data(), + order_profile = (char*)malloc(profile.size() + 1); + strcpy(order_profile, profile.toLatin1().constData()); + interchange_ord_checkout(order_profile, member.data(), [](interchange_response* response) { + free(order_profile); ord->emitTransaction(QString{response->data}); interchange_free_response(response); }); |