[qtcontacts-sqlite] Avoid potential deadlock

Avoid deadlock that could occur by having two processes try to acquire
the two semaphores in reverse order.
[qtcontacts-sqlite] Iterate over locked data table

Ensure that a writing process does not modify the transient data while
it is being traversed by a reader.