Skip to content

Commit fd62005

Browse files
RipleyTomu-235
authored andcommitted
Fix Dict serialization
1 parent c1ecc61 commit fd62005

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

lib/libebook/helper_search_index.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "helper_search_index.h"
3636

3737

38-
static const int DICT_VERSION = 5;
38+
static const int DICT_VERSION = 6;
3939

4040
namespace QtAs
4141
{
@@ -335,6 +335,9 @@ bool Index::parseDocumentToStringlist( EBook* chmFile, const QUrl& filename, QSt
335335

336336
void Index::writeDict( QDataStream& stream )
337337
{
338+
// Set a fixed stream version for compatibility
339+
stream.setVersion( QDataStream::Qt_5_5 );
340+
338341
stream << DICT_VERSION;
339342
stream << m_charssplit;
340343
stream << m_charsword;
@@ -346,7 +349,6 @@ void Index::writeDict( QDataStream& stream )
346349
for ( QHash<QString, Entry*>::ConstIterator it = dict.begin(); it != dict.end(); ++it )
347350
{
348351
stream << it.key();
349-
stream << it.value()->documents.count();
350352
stream << it.value()->documents;
351353
}
352354
}
@@ -357,7 +359,10 @@ bool Index::readDict( QDataStream& stream )
357359
docList.clear();
358360

359361
QString key;
360-
int version, numOfDocs;
362+
int version;
363+
364+
// Set a fixed stream version for compatibility
365+
stream.setVersion( QDataStream::Qt_5_5 );
361366

362367
stream >> version;
363368

@@ -373,9 +378,8 @@ bool Index::readDict( QDataStream& stream )
373378
while ( !stream.atEnd() )
374379
{
375380
stream >> key;
376-
stream >> numOfDocs;
377381

378-
QVector<Document> docs( numOfDocs );
382+
QVector<Document> docs;
379383

380384
stream >> docs;
381385
dict.insert( key, new Entry( docs ) );

0 commit comments

Comments
 (0)