Skip to content

Commit

Permalink
Fix crash when search clears while creating new entry
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
droidmonkey committed Mar 12, 2023
1 parent 988bb9c commit d156473
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/gui/EntryPreviewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,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 {};
}
11 changes: 6 additions & 5 deletions src/gui/Icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,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);
}
Expand All @@ -275,7 +274,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);
}
Expand All @@ -299,13 +297,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(" ");
Expand Down

0 comments on commit d156473

Please sign in to comment.