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)) {
// TODO: check if database() is 0
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;

View File

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