@@ -28,7 +28,7 @@
2828
2929
3030// The observer callback for the package we are watching.
31−static void observer(PayPackage* /* package */, const char* /*itemid*/, PayPackageItemStatus status, void* user_data) {
31+static void observer(PayPackage* /* package */, const char* itemid, PayPackageItemStatus status, void* user_data) {
3232 // This function is called in libpay's thread, so be careful what you call
3333 // Emitting signals should be fine as long as they use Queued or Auto
3434 // connections (the default)
@@ -36,6 +36,11 @@ static void observer(PayPackage* /* package */, const char* /*itemid*/, PayPacka
3636
3737 Payments *self = static_cast<Payments*>(user_data);
3838
39+ // If the item ID is different, ignore it.
40+ if (itemid != self->storeItemId()) {
41+ return;
42+ }
43+
3944 // FIXME: No error reporting from libpay, but we need to show some
4045 // types of errors to the user. https://launchpad.net/bugs/1333403
4146 switch (status) {
@@ -51,11 +56,13 @@ Payments::Payments(QObject *parent)
5156 : QObject(parent)
5257{
5358 m_package = pay_package_new("click-scope");
59+ pay_package_item_observer_install(m_package, observer, this);
5460}
5561
5662Payments::~Payments()
5763{
5864 pay_package_item_observer_uninstall(m_package, observer, this);
65+ pay_package_delete(m_package);
5966}
6067
6168QString Payments::currency() const
@@ -108,8 +115,6 @@ void Payments::setStoreItemId(const QString &store_item_id)
108115 return;
109116 }
110117
111− pay_package_item_observer_uninstall(m_package, observer, this);
112− pay_package_item_observer_install(m_package, observer, this);
113118 pay_package_item_start_verification(m_package,
114119 m_store_item_id.toLocal8Bit().data());
115120}