mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Fix OSCAR crash when session not found in Journal file
While preparing bookmark HTML for right sidebar, OSCAR was trying to obtain the first MT_JOURNAL session, but was finding a null pointer and then not checking that the pointer was null. However, I don't know under what conditions this situation could happen in the database. At least now it won't crash OSCAR.
This commit is contained in:
parent
d4c2b74afb
commit
5e75fe8836
@ -1197,38 +1197,40 @@ void MainWindow::updateFavourites()
|
|||||||
if (journal) {
|
if (journal) {
|
||||||
if (journal->size() > 0) {
|
if (journal->size() > 0) {
|
||||||
Session *sess = journal->firstSession(MT_JOURNAL);
|
Session *sess = journal->firstSession(MT_JOURNAL);
|
||||||
QString tmp;
|
if (sess) {
|
||||||
bool filtered = !bookmarkFilter.isEmpty();
|
QString tmp;
|
||||||
bool found = !filtered;
|
bool filtered = !bookmarkFilter.isEmpty();
|
||||||
|
bool found = !filtered;
|
||||||
|
|
||||||
if (sess->settings.contains(Bookmark_Start)) {
|
if (sess->settings.contains(Bookmark_Start)) {
|
||||||
//QVariantList start=sess->settings[Bookmark_Start].toList();
|
//QVariantList start=sess->settings[Bookmark_Start].toList();
|
||||||
//QVariantList end=sess->settings[Bookmark_End].toList();
|
//QVariantList end=sess->settings[Bookmark_End].toList();
|
||||||
QStringList notes = sess->settings[Bookmark_Notes].toStringList();
|
QStringList notes = sess->settings[Bookmark_Notes].toStringList();
|
||||||
|
|
||||||
if (notes.size() > 0) {
|
if (notes.size() > 0) {
|
||||||
tmp += QString("<tr><td><b><a href='daily=%1'>%2</a></b><br/>")
|
tmp += QString("<tr><td><b><a href='daily=%1'>%2</a></b><br/>")
|
||||||
.arg(date.toString(Qt::ISODate))
|
.arg(date.toString(Qt::ISODate))
|
||||||
.arg(date.toString(MedDateFormat));
|
.arg(date.toString(MedDateFormat));
|
||||||
|
|
||||||
tmp += "<list>";
|
tmp += "<list>";
|
||||||
|
|
||||||
for (int i = 0; i < notes.size(); i++) {
|
for (int i = 0; i < notes.size(); i++) {
|
||||||
//QDate d=start[i].toDate();
|
//QDate d=start[i].toDate();
|
||||||
QString note = notes[i];
|
QString note = notes[i];
|
||||||
|
|
||||||
if (filtered && note.contains(bookmarkFilter, Qt::CaseInsensitive)) {
|
if (filtered && note.contains(bookmarkFilter, Qt::CaseInsensitive)) {
|
||||||
found = true;
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp += "<li>" + note + "</li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp += "<li>" + note + "</li>";
|
tmp += "</list></td>";
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp += "</list></td>";
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (found) { html += tmp; }
|
if (found) { html += tmp; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user