mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Fix some data races (issue #1218)
This commit is contained in:
parent
1cef1a8733
commit
d54e0ca9fd
1
gls.cc
1
gls.cc
|
@ -1535,6 +1535,7 @@ void GlsResourceRequest::run()
|
|||
memcpy( &data.front(), bytes.constData(), bytes.size() );
|
||||
}
|
||||
|
||||
Mutex::Lock _( dataMutex );
|
||||
hasAnyData = true;
|
||||
}
|
||||
catch( std::exception &ex )
|
||||
|
|
4
mdx.cc
4
mdx.cc
|
@ -697,13 +697,13 @@ void MdxArticleRequest::run()
|
|||
"</i></i></i></i></i></i></i></i>"
|
||||
"</a></a></a></a></a></a></a></a>";
|
||||
articleText += "<div class=\"mdict\">" + articleBody + cleaner + "</div>\n";
|
||||
hasAnyData = true;
|
||||
}
|
||||
|
||||
if ( hasAnyData )
|
||||
if ( !articleText.empty() )
|
||||
{
|
||||
Mutex::Lock _( dataMutex );
|
||||
data.insert( data.end(), articleText.begin(), articleText.end() );
|
||||
hasAnyData = true;
|
||||
}
|
||||
|
||||
finish();
|
||||
|
|
3
slob.cc
3
slob.cc
|
@ -1624,6 +1624,8 @@ void SlobResourceRequest::run()
|
|||
QString css = QString::fromUtf8( resource.data(), resource.size() );
|
||||
dict.isolateCSS( css, ".slobdict" );
|
||||
QByteArray bytes = css.toUtf8();
|
||||
|
||||
Mutex::Lock _( dataMutex );
|
||||
data.resize( bytes.size() );
|
||||
memcpy( &data.front(), bytes.constData(), bytes.size() );
|
||||
}
|
||||
|
@ -1666,6 +1668,7 @@ void SlobResourceRequest::run()
|
|||
memcpy( &data.front(), resource.data(), data.size() );
|
||||
}
|
||||
|
||||
Mutex::Lock _( dataMutex );
|
||||
hasAnyData = true;
|
||||
}
|
||||
catch( std::exception &ex )
|
||||
|
|
|
@ -1905,6 +1905,7 @@ void StardictResourceRequest::run()
|
|||
memcpy( &data.front(), bytes.constData(), bytes.size() );
|
||||
}
|
||||
|
||||
Mutex::Lock _( dataMutex );
|
||||
hasAnyData = true;
|
||||
}
|
||||
catch( std::exception &ex )
|
||||
|
|
3
zim.cc
3
zim.cc
|
@ -1446,6 +1446,8 @@ void ZimResourceRequest::run()
|
|||
QString css = QString::fromUtf8( resource.data(), resource.size() );
|
||||
dict.isolateCSS( css, ".zimdict" );
|
||||
QByteArray bytes = css.toUtf8();
|
||||
|
||||
Mutex::Lock _( dataMutex );
|
||||
data.resize( bytes.size() );
|
||||
memcpy( &data.front(), bytes.constData(), bytes.size() );
|
||||
}
|
||||
|
@ -1488,6 +1490,7 @@ void ZimResourceRequest::run()
|
|||
memcpy( &data.front(), resource.data(), data.size() );
|
||||
}
|
||||
|
||||
Mutex::Lock _( dataMutex );
|
||||
hasAnyData = true;
|
||||
}
|
||||
catch( std::exception &ex )
|
||||
|
|
Loading…
Reference in a new issue