[Kde-pim] KABC::ResourceCached thread-safety concern

Dmitry Savenko dsavenko at gmail.com
Tue Aug 10 12:27:12 BST 2010


Hello!
I'm developing a CardDAV connector based on KABC::ResourceCached. It's
unclear for me how to use the class with threads safely.
Consider the following case:

1. asyncLoad() is called.
2. A new thread is created, a slot is connected to its finished()
signal. loadingFinished() (or loadingError()) will be emitted from
this slot.
3. asyncLoad() returns, the thread is working.
4. The thread downloaded vcards from the server and parsed them. Now
it needs to insert addressees to the resource (insertAddressee()
method);
5.1. Kontact decides to read the resource during the process of
inserting new addressees. Crash.
 or
5.2. A user adds a new contact during the process of inserting new
addressees. Crash.

Is this scenario possible? I mean I don't see how to protect
insertAddressee() call in multi-threaded environment. May be, I've
missed something?

Best regards,
Dmitry.
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list