anthonyfieroni added inline comments.

INLINE COMMENTS

> kpropertiesdialog.cpp:2795-2805
> +    std::function<QString(QCryptographicHash::Algorithm)> mapper = 
> [this](QCryptographicHash::Algorithm alg) {
> +        const QString cache = cachedChecksum(alg);
> +        if (!cache.isEmpty()) {
> +            return cache;
> +        }
>  
> +        const QString checksum = computeChecksum(alg, 
> properties->item().localPath());

Better get localPath before concurrent function and you should use mutex as 
well, simultaneously read/write is data race  i.e.

  const auto itemPath = properties->item().localPath();
  std::function<QString(QCryptographicHash::Algorithm)> mapper = [itemPath, 
this](QCryptographicHash::Algorithm alg) {
      QMutexLocker locker(&d->mutex);

> kpropertiesdialog.cpp:3015
>  {
> -    switch (algorithm) {
> -    case QCryptographicHash::Md5:
> -        d->m_md5 = checksum;
> -        break;
> -    case QCryptographicHash::Sha1:
> -        d->m_sha1 = checksum;
> -        break;
> -    case QCryptographicHash::Sha256:
> -        d->m_sha256 = checksum;
> -        break;
> -    default:
> -        return;
> -    }
> +    QMutexLocker locker(&d->mutex);
> +    d->cache.insert(algorithm, checksum);

Mutex is not needed here.

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D8536

To: petermajchrak, elvisangelaccio, #vdg, colomar
Cc: colomar, anthonyfieroni, bcooksley, alexeymin, ngraham, elvisangelaccio, 
#frameworks

Reply via email to