mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-26 01:11:16 -05: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);
|
return databaseIcons()->icon(m_data.iconNumber);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO: check if database() is 0
|
Q_ASSERT(database());
|
||||||
return database()->metadata()->customIcon(m_data.customIcon);
|
|
||||||
|
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);
|
return databaseIcons()->iconPixmap(m_data.iconNumber);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Q_ASSERT(database());
|
||||||
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
if (database() && !QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||||
// TODO: check if database() is 0
|
|
||||||
pixmap = QPixmap::fromImage(database()->metadata()->customIcon(m_data.customIcon));
|
pixmap = QPixmap::fromImage(database()->metadata()->customIcon(m_data.customIcon));
|
||||||
m_pixmapCacheKey = QPixmapCache::insert(pixmap);
|
m_pixmapCacheKey = QPixmapCache::insert(pixmap);
|
||||||
}
|
}
|
||||||
|
@ -115,8 +115,14 @@ QImage Group::icon() const
|
|||||||
return databaseIcons()->icon(m_data.iconNumber);
|
return databaseIcons()->icon(m_data.iconNumber);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO: check if m_db is 0
|
Q_ASSERT(m_db);
|
||||||
return m_db->metadata()->customIcon(m_data.customIcon);
|
|
||||||
|
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);
|
return databaseIcons()->iconPixmap(m_data.iconNumber);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Q_ASSERT(m_db);
|
||||||
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
if (m_db && !QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||||
// TODO: check if m_db is 0
|
|
||||||
pixmap = QPixmap::fromImage(m_db->metadata()->customIcon(m_data.customIcon));
|
pixmap = QPixmap::fromImage(m_db->metadata()->customIcon(m_data.customIcon));
|
||||||
m_pixmapCacheKey = QPixmapCache::insert(pixmap);
|
m_pixmapCacheKey = QPixmapCache::insert(pixmap);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user