Fix crash when search clears while creating new entry

* Fixes #7660
* Also fix code error in Icons::imageFormatsFilter. An inner loop looks for invalid characters in the code point, but erroneously calls `continue` within the inner loop when the intention was to continue in the outer loop. Fixed with a boolean test instead.
This commit is contained in:
Jonathan White 2023-03-12 00:29:09 -04:00
parent 6b51c66c68
commit 6c9078c870
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
2 changed files with 11 additions and 7 deletions

View File

@ -567,6 +567,9 @@ void EntryPreviewWidget::setTabEnabled(QTabWidget* tabWidget, QWidget* widget, b
QString EntryPreviewWidget::hierarchy(const Group* group, const QString& title)
{
QString groupList = QString("%1").arg(group->hierarchy().join(" / "));
return title.isEmpty() ? groupList : QString("%1 / %2").arg(groupList, title);
if (group) {
QString groupList = QString("%1").arg(group->hierarchy().join(" / "));
return title.isEmpty() ? groupList : QString("%1 / %2").arg(groupList, title);
}
return {};
}

View File

@ -258,7 +258,6 @@ QPixmap Icons::entryIconPixmap(const Entry* entry, IconSize size)
if (entry->iconUuid().isNull()) {
icon = databaseIcons()->icon(entry->iconNumber(), size);
} else {
Q_ASSERT(entry->database());
if (entry->database()) {
icon = Icons::customIconPixmap(entry->database(), entry->iconUuid(), size);
}
@ -277,7 +276,6 @@ QPixmap Icons::groupIconPixmap(const Group* group, IconSize size)
if (group->iconUuid().isNull()) {
icon = databaseIcons()->icon(group->iconNumber(), size);
} else {
Q_ASSERT(group->database());
if (group->database()) {
icon = Icons::customIconPixmap(group->database(), group->iconUuid(), size);
}
@ -301,13 +299,16 @@ QString Icons::imageFormatsFilter()
QStringList formatsStringList;
for (const QByteArray& format : formats) {
bool codePointClean = true;
for (char codePoint : format) {
if (!QChar(codePoint).isLetterOrNumber()) {
continue;
codePointClean = false;
break;
}
}
formatsStringList.append("*." + QString::fromLatin1(format).toLower());
if (codePointClean) {
formatsStringList.append("*." + QString::fromLatin1(format).toLower());
}
}
return formatsStringList.join(" ");