[PATCH amarok 1.4] fix threading issues around QImage

Dirk Mueller mueller at kde.org
Mon Sep 24 15:50:18 CEST 2007


Hi, 

for a long time at SUSE we got crash reports about amarok that were difficult 
to reproduce, but always happened in heavily multithreaded environments. 
Looking at those with threadchecker, there are many obvious problems: 

a) QImage::load is neither reentrant nor threadsafe, and must not be used in 
threads. amarok 1.4 makes heavy use of QImage::load in threads, and this does 
not work because QImage::load uses unsafe iterators and uses a shared 
QRegexp. QRegexp however is not thread-safe (it is reentrant though), which 
causes amarok to crash randomly during playing, whenever one of the new cover 
images is loaded. I`m currently working around that by taking the global 
QApplication: lock, which is the only option I see. 

b) KStandardDirs usage in subthreads and GUI thread. I`ve fixed those by 
caching the locate() result in the object and qdeepcopy`ing it before the 
thread is started. 

below is the patch, comments etc apprecciated. the diff in 
enginecontroller.cpp is unrelated, please ignore that part. 

Thanks,
Dirk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: amarok.diff
Type: text/x-diff
Size: 7491 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/amarok-devel/attachments/20070924/bc897012/attachment.bin 


More information about the Amarok-devel mailing list