Changeset View
Changeset View
Standalone View
Standalone View
src/core/changerecorder_p.cpp
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 69 | { | |||
---|---|---|---|---|---|
126 | } | 126 | } | ||
127 | notificationsLoaded(); | 127 | notificationsLoaded(); | ||
128 | } | 128 | } | ||
129 | 129 | | |||
130 | static const quint64 s_currentVersion = Q_UINT64_C(0x000500000000); | 130 | static const quint64 s_currentVersion = Q_UINT64_C(0x000500000000); | ||
131 | static const quint64 s_versionMask = Q_UINT64_C(0xFFFF00000000); | 131 | static const quint64 s_versionMask = Q_UINT64_C(0xFFFF00000000); | ||
132 | static const quint64 s_sizeMask = Q_UINT64_C(0x0000FFFFFFFF); | 132 | static const quint64 s_sizeMask = Q_UINT64_C(0x0000FFFFFFFF); | ||
133 | 133 | | |||
134 | QQueue<Protocol::ChangeNotification> ChangeRecorderPrivate::loadFrom(QIODevice *device, bool &needsFullSave) const | 134 | QQueue<Protocol::ChangeNotification> ChangeRecorderPrivate::loadFrom(QFile *device, bool &needsFullSave) const | ||
135 | { | 135 | { | ||
136 | QDataStream stream(device); | 136 | QDataStream stream(device); | ||
137 | stream.setVersion(QDataStream::Qt_4_6); | 137 | stream.setVersion(QDataStream::Qt_4_6); | ||
138 | 138 | | |||
139 | QByteArray sessionId; | 139 | QByteArray sessionId; | ||
140 | int type; | 140 | int type; | ||
141 | 141 | | |||
142 | QQueue<Protocol::ChangeNotification> list; | 142 | QQueue<Protocol::ChangeNotification> list; | ||
Show All 13 Lines | |||||
156 | // Also, if the file is old, it needs to be rewritten. | 156 | // Also, if the file is old, it needs to be rewritten. | ||
157 | needsFullSave = startOffset > 0 || version == 0; | 157 | needsFullSave = startOffset > 0 || version == 0; | ||
158 | 158 | | |||
159 | for (quint64 i = 0; i < size && !stream.atEnd(); ++i) { | 159 | for (quint64 i = 0; i < size && !stream.atEnd(); ++i) { | ||
160 | Protocol::ChangeNotification msg; | 160 | Protocol::ChangeNotification msg; | ||
161 | stream >> sessionId; | 161 | stream >> sessionId; | ||
162 | stream >> type; | 162 | stream >> type; | ||
163 | 163 | | |||
164 | if (stream.status() != QDataStream::Ok) { | ||||
165 | qWarning() << "Error reading saved notifications! Aborting. Corrupt file:" << device->fileName(); | ||||
mlaurent: I can't speak about code but could you use qCWarning(....) here (and replace other qWarning… | |||||
166 | break; | ||||
167 | } | ||||
168 | | ||||
164 | switch (static_cast<LegacyType>(type)) { | 169 | switch (static_cast<LegacyType>(type)) { | ||
165 | case Item: | 170 | case Item: | ||
166 | msg = loadItemNotification(stream, version); | 171 | msg = loadItemNotification(stream, version); | ||
167 | break; | 172 | break; | ||
168 | case Collection: | 173 | case Collection: | ||
169 | msg = loadCollectionNotification(stream, version); | 174 | msg = loadCollectionNotification(stream, version); | ||
170 | break; | 175 | break; | ||
171 | case Tag: | 176 | case Tag: | ||
▲ Show 20 Lines • Show All 286 Lines • ▼ Show 20 Line(s) | 442 | { | |||
458 | } else if (version >= 2) { | 463 | } else if (version >= 2) { | ||
459 | stream >> operation; | 464 | stream >> operation; | ||
460 | stream >> entityCnt; | 465 | stream >> entityCnt; | ||
461 | for (int j = 0; j < entityCnt; ++j) { | 466 | for (int j = 0; j < entityCnt; ++j) { | ||
462 | stream >> uid; | 467 | stream >> uid; | ||
463 | stream >> remoteId; | 468 | stream >> remoteId; | ||
464 | stream >> remoteRevision; | 469 | stream >> remoteRevision; | ||
465 | stream >> mimeType; | 470 | stream >> mimeType; | ||
471 | if (stream.status() != QDataStream::Ok) { | ||||
472 | qWarning() << "Error reading saved notifications! Aborting"; | ||||
473 | return msg; | ||||
474 | } | ||||
466 | msg.addItem(uid, remoteId, remoteRevision, mimeType); | 475 | msg.addItem(uid, remoteId, remoteRevision, mimeType); | ||
467 | } | 476 | } | ||
468 | stream >> resource; | 477 | stream >> resource; | ||
469 | stream >> destinationResource; | 478 | stream >> destinationResource; | ||
470 | stream >> parentCollection; | 479 | stream >> parentCollection; | ||
471 | stream >> parentDestCollection; | 480 | stream >> parentDestCollection; | ||
472 | stream >> itemParts; | 481 | stream >> itemParts; | ||
473 | stream >> addedFlags; | 482 | stream >> addedFlags; | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 540 | { | |||
553 | } else if (version >= 2) { | 562 | } else if (version >= 2) { | ||
554 | stream >> operation; | 563 | stream >> operation; | ||
555 | stream >> entityCnt; | 564 | stream >> entityCnt; | ||
556 | for (int j = 0; j < entityCnt; ++j) { | 565 | for (int j = 0; j < entityCnt; ++j) { | ||
557 | stream >> uid; | 566 | stream >> uid; | ||
558 | stream >> remoteId; | 567 | stream >> remoteId; | ||
559 | stream >> remoteRevision; | 568 | stream >> remoteRevision; | ||
560 | stream >> dummyString; | 569 | stream >> dummyString; | ||
570 | if (stream.status() != QDataStream::Ok) { | ||||
571 | qWarning() << "Error reading saved notifications! Aborting"; | ||||
572 | return msg; | ||||
573 | } | ||||
561 | msg.setId(uid); | 574 | msg.setId(uid); | ||
562 | msg.setRemoteId(remoteId); | 575 | msg.setRemoteId(remoteId); | ||
563 | msg.setRemoteRevision(remoteRevision); | 576 | msg.setRemoteRevision(remoteRevision); | ||
564 | } | 577 | } | ||
565 | stream >> resource; | 578 | stream >> resource; | ||
566 | stream >> destinationResource; | 579 | stream >> destinationResource; | ||
567 | stream >> parentCollection; | 580 | stream >> parentCollection; | ||
568 | stream >> parentDestCollection; | 581 | stream >> parentDestCollection; | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 623 | { | |||
632 | } else if (version >= 2) { | 645 | } else if (version >= 2) { | ||
633 | stream >> operation; | 646 | stream >> operation; | ||
634 | stream >> entityCnt; | 647 | stream >> entityCnt; | ||
635 | for (int j = 0; j < entityCnt; ++j) { | 648 | for (int j = 0; j < entityCnt; ++j) { | ||
636 | stream >> uid; | 649 | stream >> uid; | ||
637 | stream >> remoteId; | 650 | stream >> remoteId; | ||
638 | stream >> dummyString; | 651 | stream >> dummyString; | ||
639 | stream >> dummyString; | 652 | stream >> dummyString; | ||
653 | if (stream.status() != QDataStream::Ok) { | ||||
654 | qWarning() << "Error reading saved notifications! Aborting"; | ||||
655 | return msg; | ||||
656 | } | ||||
640 | msg.setId(uid); | 657 | msg.setId(uid); | ||
641 | msg.setRemoteId(remoteId); | 658 | msg.setRemoteId(remoteId); | ||
642 | } | 659 | } | ||
643 | stream >> resource; | 660 | stream >> resource; | ||
644 | stream >> dummyBa; | 661 | stream >> dummyBa; | ||
645 | stream >> dummyI; | 662 | stream >> dummyI; | ||
646 | stream >> dummyI; | 663 | stream >> dummyI; | ||
647 | stream >> dummyBaV; | 664 | stream >> dummyBaV; | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 701 | { | |||
697 | } else if (version >= 2) { | 714 | } else if (version >= 2) { | ||
698 | stream >> operation; | 715 | stream >> operation; | ||
699 | stream >> entityCnt; | 716 | stream >> entityCnt; | ||
700 | for (int j = 0; j < entityCnt; ++j) { | 717 | for (int j = 0; j < entityCnt; ++j) { | ||
701 | stream >> dummyI; | 718 | stream >> dummyI; | ||
702 | stream >> dummyString; | 719 | stream >> dummyString; | ||
703 | stream >> dummyString; | 720 | stream >> dummyString; | ||
704 | stream >> dummyString; | 721 | stream >> dummyString; | ||
722 | if (stream.status() != QDataStream::Ok) { | ||||
723 | qWarning() << "Error reading saved notifications! Aborting"; | ||||
724 | return msg; | ||||
725 | } | ||||
705 | } | 726 | } | ||
706 | stream >> dummyBa; | 727 | stream >> dummyBa; | ||
707 | stream >> dummyBa; | 728 | stream >> dummyBa; | ||
708 | stream >> dummyI; | 729 | stream >> dummyI; | ||
709 | stream >> dummyI; | 730 | stream >> dummyI; | ||
710 | stream >> itemParts; | 731 | stream >> itemParts; | ||
711 | stream >> dummyBaV; | 732 | stream >> dummyBaV; | ||
712 | stream >> dummyBaV; | 733 | stream >> dummyBaV; | ||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |
I can't speak about code but could you use qCWarning(....) here (and replace other qWarning too) please :)
thanks