Thread-safety when calling IProject::projectItem() and IBuildSystemManager::includeDirectories()

Sandro Andrade sandro.andrade at gmail.com
Fri Apr 16 19:39:45 UTC 2010


Hi all,

I'm currently running some race conditions when calling
IProject::projectItem() and IBuildSystemManager::includeDirectories()
from different simultaneous threads, in controlglowgraph plugin.

I added a mutex to serialize these calls and apparently crashes were solved:

        KDevelop::ProjectBaseItem *project_item = 0;
        {
            QMutexLocker locker (&mutex);
            if (m_currentProject)
                project_item = m_currentProject->projectItem();
        }

            KUrl::List list;
            {
                QMutexLocker locker (&mutex);
                list = buildSystemManager->includeDirectories( project_item
);
            }

So, are really these methods not thread-safe ? Is there a better solution
than using QMutex ?
Which kdevplatform methods should I consider not thread-safe ? I'm trying
the keep the lock at a
minimum code range but I'm afraid of others not thread-safe methods which,
just being lucky,
don't caused yet a crash.

Thanks,
Sandro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20100416/2bc2f698/attachment.html>


More information about the KDevelop-devel mailing list