a crash fix on one of archive corner cases
This commit is contained in:
parent
8f949277f6
commit
4c20a314f0
2 changed files with 19 additions and 10 deletions
|
@ -124,15 +124,19 @@ void Core::RosterItem::nextRequest()
|
|||
if (requestedCount != -1) {
|
||||
bool last = false;
|
||||
if (archiveState == beginning || archiveState == complete) {
|
||||
QString firstId = archive->oldestId();
|
||||
if (responseCache.size() == 0) {
|
||||
if (requestedBefore == firstId) {
|
||||
last = true;
|
||||
}
|
||||
} else {
|
||||
if (responseCache.front().getId() == firstId) {
|
||||
last = true;
|
||||
try {
|
||||
QString firstId = archive->oldestId();
|
||||
if (responseCache.size() == 0) {
|
||||
if (requestedBefore == firstId) {
|
||||
last = true;
|
||||
}
|
||||
} else {
|
||||
if (responseCache.front().getId() == firstId) {
|
||||
last = true;
|
||||
}
|
||||
}
|
||||
} catch (const Archive::Empty& e) {
|
||||
last = true;
|
||||
}
|
||||
} else if (archiveState == empty && responseCache.size() == 0) {
|
||||
last = true;
|
||||
|
@ -171,8 +175,12 @@ void Core::RosterItem::performRequest(int count, const QString& before)
|
|||
requestCache.emplace_back(requestedCount, before);
|
||||
requestedCount = -1;
|
||||
}
|
||||
Shared::Message msg = archive->newest();
|
||||
emit needHistory("", getId(msg), msg.getTime());
|
||||
try {
|
||||
Shared::Message msg = archive->newest();
|
||||
emit needHistory("", getId(msg), msg.getTime());
|
||||
} catch (const Archive::Empty& e) { //this can happen when the only message in archive is not server stored (error, for example)
|
||||
emit needHistory(before, "");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case end:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue