mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 16:04:06 +00:00
fix startdict index file reading caused by wrong order of reading
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run
partially revert https://github.com/xiaoyifang/goldendict-ng/pull/1972
This commit is contained in:
parent
5b70a7e081
commit
3c5b76f77a
|
@ -122,7 +122,7 @@ class StardictDictionary: public BtreeIndexing::BtreeDictionary
|
||||||
File::Index idx;
|
File::Index idx;
|
||||||
IdxHeader idxHeader;
|
IdxHeader idxHeader;
|
||||||
string sameTypeSequence;
|
string sameTypeSequence;
|
||||||
ChunkedStorage::Reader chunks;
|
std::unique_ptr< ChunkedStorage::Reader > chunks;
|
||||||
QMutex dzMutex;
|
QMutex dzMutex;
|
||||||
dictData * dz;
|
dictData * dz;
|
||||||
QMutex resourceZipMutex;
|
QMutex resourceZipMutex;
|
||||||
|
@ -215,12 +215,14 @@ StardictDictionary::StardictDictionary( string const & id,
|
||||||
string const & indexFile,
|
string const & indexFile,
|
||||||
vector< string > const & dictionaryFiles ):
|
vector< string > const & dictionaryFiles ):
|
||||||
BtreeDictionary( id, dictionaryFiles ),
|
BtreeDictionary( id, dictionaryFiles ),
|
||||||
idx( indexFile, QIODevice::ReadOnly ),
|
idx( indexFile, QIODevice::ReadOnly )
|
||||||
idxHeader( idx.read< IdxHeader >() ),
|
|
||||||
sameTypeSequence( loadString( idxHeader.sameTypeSequenceSize ) ),
|
|
||||||
chunks( idx, idxHeader.chunksOffset )
|
|
||||||
{
|
{
|
||||||
dictionaryName = loadString( idxHeader.bookNameSize );
|
// reading headers, note that reading order matters
|
||||||
|
idxHeader = idx.read< IdxHeader >();
|
||||||
|
dictionaryName = loadString( idxHeader.bookNameSize );
|
||||||
|
sameTypeSequence = loadString( idxHeader.sameTypeSequenceSize );
|
||||||
|
chunks = std::make_unique< ChunkedStorage::Reader >( idx, idxHeader.chunksOffset );
|
||||||
|
|
||||||
// Open the .dict file
|
// Open the .dict file
|
||||||
|
|
||||||
DZ_ERRORS error;
|
DZ_ERRORS error;
|
||||||
|
@ -301,7 +303,7 @@ void StardictDictionary::getArticleProps( uint32_t articleAddress,
|
||||||
|
|
||||||
QMutexLocker _( &idxMutex );
|
QMutexLocker _( &idxMutex );
|
||||||
|
|
||||||
char * articleData = chunks.getBlock( articleAddress, chunk );
|
char * articleData = chunks->getBlock( articleAddress, chunk );
|
||||||
|
|
||||||
memcpy( &offset, articleData, sizeof( uint32_t ) );
|
memcpy( &offset, articleData, sizeof( uint32_t ) );
|
||||||
articleData += sizeof( uint32_t );
|
articleData += sizeof( uint32_t );
|
||||||
|
|
Loading…
Reference in a new issue