mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Make sure icon() and iconPixmap() never crash.
This commit is contained in:
parent
755241df5c
commit
1f47033835
@ -94,8 +94,14 @@ QImage Entry::icon() const
|
||||
return databaseIcons()->icon(m_data.iconNumber);
|
||||
}
|
||||
else {
|
||||
// TODO: check if database() is 0
|
||||
return database()->metadata()->customIcon(m_data.customIcon);
|
||||
Q_ASSERT(database());
|
||||
|
||||
if (database()) {
|
||||
return database()->metadata()->customIcon(m_data.customIcon);
|
||||
}
|
||||
else {
|
||||
return QImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,9 +111,10 @@ QPixmap Entry::iconPixmap() const
|
||||
return databaseIcons()->iconPixmap(m_data.iconNumber);
|
||||
}
|
||||
else {
|
||||
Q_ASSERT(database());
|
||||
|
||||
QPixmap pixmap;
|
||||
if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||
// TODO: check if database() is 0
|
||||
if (database() && !QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||
pixmap = QPixmap::fromImage(database()->metadata()->customIcon(m_data.customIcon));
|
||||
m_pixmapCacheKey = QPixmapCache::insert(pixmap);
|
||||
}
|
||||
|
@ -115,8 +115,14 @@ QImage Group::icon() const
|
||||
return databaseIcons()->icon(m_data.iconNumber);
|
||||
}
|
||||
else {
|
||||
// TODO: check if m_db is 0
|
||||
return m_db->metadata()->customIcon(m_data.customIcon);
|
||||
Q_ASSERT(m_db);
|
||||
|
||||
if (m_db) {
|
||||
return m_db->metadata()->customIcon(m_data.customIcon);
|
||||
}
|
||||
else {
|
||||
return QImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,9 +132,10 @@ QPixmap Group::iconPixmap() const
|
||||
return databaseIcons()->iconPixmap(m_data.iconNumber);
|
||||
}
|
||||
else {
|
||||
Q_ASSERT(m_db);
|
||||
|
||||
QPixmap pixmap;
|
||||
if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||
// TODO: check if m_db is 0
|
||||
if (m_db && !QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||
pixmap = QPixmap::fromImage(m_db->metadata()->customIcon(m_data.customIcon));
|
||||
m_pixmapCacheKey = QPixmapCache::insert(pixmap);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user