diff --git a/src/contacts/contactmodifyjob.cpp b/src/contacts/contactmodifyjob.cpp --- a/src/contacts/contactmodifyjob.cpp +++ b/src/contacts/contactmodifyjob.cpp @@ -84,17 +84,6 @@ } q->enqueueRequest(request, rawData, QStringLiteral("application/atom+xml")); - - const QUrl photoUrl = ContactsService::photoUrl(q->account()->accountName(), contact->uid()); - QNetworkRequest photoRequest(photoUrl); - if (!contact->photo().isEmpty()) { - photoRequest.setHeader(QNetworkRequest::ContentTypeHeader, QLatin1String("image/*")); - pendingPhoto.first = contact->photo().rawData(); - pendingPhoto.second = contact->photo().type(); - q->enqueueRequest(photoRequest, pendingPhoto.first, QStringLiteral("modifyImage")); - } else { - q->enqueueRequest(photoRequest, QByteArray(), QStringLiteral("deleteImage")); - } } @@ -154,17 +143,27 @@ if (ct == KGAPI2::JSON) { d->lastContact = ContactsService::JSONToContact(rawData); items << d->lastContact; - d->contacts.currentProcessed(); } else if (ct == KGAPI2::XML) { d->lastContact = ContactsService::XMLToContact(rawData); items << d->lastContact; - d->contacts.currentProcessed(); } else { setError(KGAPI2::InvalidResponse); setErrorString(tr("Invalid response content type")); emitFinished(); return items; } + ContactPtr contact = d->contacts.current(); + const QUrl photoUrl = ContactsService::photoUrl(account()->accountName(), contact->uid()); + QNetworkRequest photoRequest(photoUrl); + if (!contact->photo().isEmpty()) { + photoRequest.setHeader(QNetworkRequest::ContentTypeHeader, QLatin1String("image/*")); + d->pendingPhoto.first = contact->photo().rawData(); + d->pendingPhoto.second = contact->photo().type(); + enqueueRequest(photoRequest, d->pendingPhoto.first, QStringLiteral("modifyImage")); + } else { + enqueueRequest(photoRequest, QByteArray(), QStringLiteral("deleteImage")); + } + d->contacts.currentProcessed(); } else { if (d->lastContact && !d->pendingPhoto.first.isEmpty()) { KContacts::Picture picture;