From 3ed8e8754557fc5c336f95141e0c7998f87ac6de Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Tue, 5 Aug 2014 13:35:39 +0200 Subject: [PATCH] iOS: Don't modify an NSMutableArray while iterating it Now we create a list of items to be removed and then remove them after iterating the array. Task-number: QTBUG-39839 Change-Id: I144023770f76b125bc64ee60c111482f71bfff9a --- src/purchasing/inapppurchase/ios/qiosinapppurchasebackend.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/purchasing/inapppurchase/ios/qiosinapppurchasebackend.mm b/src/purchasing/inapppurchase/ios/qiosinapppurchasebackend.mm index fda6c0d..e9487de 100644 --- a/src/purchasing/inapppurchase/ios/qiosinapppurchasebackend.mm +++ b/src/purchasing/inapppurchase/ios/qiosinapppurchasebackend.mm @@ -65,6 +65,8 @@ -(void)processPendingTransactions { + NSMutableArray *registeredTransactions = [NSMutableArray array]; + for (SKPaymentTransaction *transaction in pendingTransactions) { QInAppTransaction::TransactionStatus status = [InAppPurchaseManager statusFromTransaction:transaction]; @@ -73,10 +75,13 @@ if (product) { //It is possible that the product doesn't exist yet (because of previous restores). QIosInAppPurchaseTransaction *qtTransaction = new QIosInAppPurchaseTransaction(transaction, status, product, backend); - [pendingTransactions removeObject:transaction]; + [registeredTransactions addObject:transaction]; QMetaObject::invokeMethod(backend, "registerTransaction", Qt::AutoConnection, Q_ARG(QIosInAppPurchaseTransaction*, qtTransaction)); } } + + //Remove registeredTransactions from pendingTransactions + [pendingTransactions removeObjectsInArray:registeredTransactions]; } -- 1.8.5.2 (Apple Git-48)