const_cast "this" instead of the member variable.

This commit is contained in:
Felix Geyer 2012-07-19 23:32:31 +02:00
parent b6d9c2e486
commit 0c1fecfb2b
2 changed files with 4 additions and 2 deletions

View File

@ -109,7 +109,7 @@ QPixmap Entry::iconPixmap() const
if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) { if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
// TODO: check if database() is 0 // TODO: check if database() is 0
pixmap = QPixmap::fromImage(database()->metadata()->customIcon(m_data.customIcon)); pixmap = QPixmap::fromImage(database()->metadata()->customIcon(m_data.customIcon));
*const_cast<QPixmapCache::Key*>(&m_pixmapCacheKey) = QPixmapCache::insert(pixmap); const_cast<Entry*>(this)->m_pixmapCacheKey = QPixmapCache::insert(pixmap);
} }
return pixmap; return pixmap;

View File

@ -37,6 +37,8 @@ Group::~Group()
{ {
cleanupParent(); cleanupParent();
this->blockSignals(true); this->blockSignals(true);
// Destroy entries and children manually so DeletedObjects can be added
// to database.
if (m_db && m_parent) { if (m_db && m_parent) {
QList<Entry*> entries = m_entries; QList<Entry*> entries = m_entries;
Q_FOREACH (Entry* entry, entries) { Q_FOREACH (Entry* entry, entries) {
@ -118,7 +120,7 @@ QPixmap Group::iconPixmap() const
if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) { if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
// TODO: check if m_db is 0 // TODO: check if m_db is 0
pixmap = QPixmap::fromImage(m_db->metadata()->customIcon(m_customIcon)); pixmap = QPixmap::fromImage(m_db->metadata()->customIcon(m_customIcon));
*const_cast<QPixmapCache::Key*>(&m_pixmapCacheKey) = QPixmapCache::insert(pixmap); const_cast<Group*>(this)->m_pixmapCacheKey = QPixmapCache::insert(pixmap);
} }
return pixmap; return pixmap;