On October 31, 2009, Sebastian Kügler wrote: > I've tried different variants, a QMutex to lock access to the shared class > for example, but nothing would really help. Can anyone tell me how I can > fix this in the right way?
a few things jump out at me: * m_mediaWiki is being shared by all threads. consider two threads (T0 and T1) running like this (in chronological order): T0::match -> wait 1s on line 84 T1::match -> wait 1s on line 84 T0::match -> assign m_mediaWiki and starts query T1::match -> assigns m_mediaWiki (!) T0::match -> query is done, delete m_mediaWiki object (!!) T1::mediaWikiFinished -> m_mediaWiki is now null .. crash. my suggestion would be to put the MediaWiki object on the stack local to match() and not bother having to delete it at all. it will also help solve another potential problem: * since there is only one m_context member, whatever matches get returned, even if from an older query, will be added to the last m_context object returned. which means it is possible that matches will get added to a context which no longer actually matches. if the Context * is passed into MediaWiki, then in MediaWiki::finished( QNetworkReply *reply ) it can check context->isValid() and if it is add the matches itself. this prevents having to cache m_context in the runner. then the finished(bool) signal simply serves to exit the event loop in match() * a check for context.isValid() should be added after the waiting code on lines 83-85 to prevent queries that no longer are valid from being searched for. the same is true for mediaWikiFinished. btw, why aren't you using KIO directly in MediaWiki? -- Aaron J. Seigo humru othro a kohnu se GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43 KDE core developer sponsored by Qt Development Frameworks
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel