[contacts/ContactModifyJob] Avoid race condition
Summary:
This patch is similar to D28178: [contacts] Fix ContactCreateJob with a photo. Although uid is populated, and we can
freely dispatch both contact and photo modify requests in parallel, the
following race condition still sometimes happens:
- Contact modify request dispatched
- Contact photo modify request dispatched
- Photo reply arrives
At this point, d->lastContact is not yet populated, and we call
processNextContact(), which repeats steps 1 and 2 for the very same contact.
Which could happen again and again, if photo reply arrives first again.
Instead, I suggest to fire photo modify request only after we receive reply
for contact modify request, ensuring everything happens in the following order:
- Contact modify request dispatched
- Contact modify reply received
- Contact photo modify request dispatched
- Contact photo reply received
Test Plan:
- Modify a contact via KAddressBook
- Check logs
- (without patch) Bunch of modify requests somtimes gets fired
- (with patch) Only one modify request gets fired
Reviewers: dvratil
Reviewed By: dvratil
Subscribers: kde-pim
Tags: KDE PIM
Differential Revision: https://phabricator.kde.org/D28181