Skip to content

Commit

Permalink
Use smart pointers for Iconset everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Oct 7, 2024
1 parent fb5ac2c commit c86b138
Show file tree
Hide file tree
Showing 14 changed files with 269 additions and 327 deletions.
23 changes: 11 additions & 12 deletions src/avatars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class AvatarCache : public FileCache {
#ifdef AVATAR_EDBUG
qDebug() << "remove from iconset and emit avatarChanged on itemPublished" << jidFull;
#endif
iconset_->removeIcon(QString(QLatin1String("avatars/%1")).arg(jidFull));
iconset_.removeIcon(QString(QLatin1String("avatars/%1")).arg(jidFull));
emit avatarChanged(jidFull);
}
}
Expand All @@ -263,7 +263,7 @@ class AvatarCache : public FileCache {
qDebug() << "remove from iconset and emit avatarChanged. ensureVCardUpdated hash=" << hash.toHex()
<< fullJid;
#endif
iconset_->removeIcon(QString(QLatin1String("avatars/%1")).arg(fullJid));
iconset_.removeIcon(QString(QLatin1String("avatars/%1")).arg(fullJid));
emit avatarChanged(fullJid);
}

Expand All @@ -280,7 +280,7 @@ class AvatarCache : public FileCache {
#ifdef AVATAR_EDBUG
qDebug() << "remove from iconset and emit avatarChanged. importManualAvatar" << j.bare();
#endif
iconset_->removeIcon(QString(QLatin1String("avatars/%1")).arg(j.bare()));
iconset_.removeIcon(QString(QLatin1String("avatars/%1")).arg(j.bare()));
emit avatarChanged(j);
}

Expand All @@ -290,7 +290,7 @@ class AvatarCache : public FileCache {
#ifdef AVATAR_EDBUG
qDebug() << "remove from iconset and emit avatarChanged. removeManualAvatar" << j.bare();
#endif
iconset_->removeIcon(QString(QLatin1String("avatars/%1")).arg(j.bare()));
iconset_.removeIcon(QString(QLatin1String("avatars/%1")).arg(j.bare()));
emit avatarChanged(j);
}
}
Expand All @@ -299,7 +299,7 @@ class AvatarCache : public FileCache {
{
QString bareJid = _jid.bare();
QString iconName = QString("avatars/%1").arg(bareJid);
auto iconp = iconset_->icon(iconName);
auto iconp = iconset_.icon(iconName);
if (iconp) {
#ifdef AVATAR_EDBUG
qDebug() << "return icons" << iconName << "from iconset for jid" << bareJid;
Expand Down Expand Up @@ -353,7 +353,7 @@ class AvatarCache : public FileCache {
#ifdef AVATAR_EDBUG
qDebug() << "setting icon to iconset " << iconName << "=" << pm;
#endif
iconset_->setIcon(iconName, icon);
iconset_.setIcon(iconName, icon);

return pm;
}
Expand All @@ -363,7 +363,7 @@ class AvatarCache : public FileCache {
QString fullJid = _jid.full();

QString iconName = QString("avatars/%1").arg(fullJid);
auto iconp = iconset_->icon(iconName);
auto iconp = iconset_.icon(iconName);
if (iconp) {
return iconp->pixmap();
}
Expand Down Expand Up @@ -400,7 +400,7 @@ class AvatarCache : public FileCache {
#ifdef AVATAR_EDBUG
qDebug() << "setting icon " << QString("avatars/%1").arg(fullJid) << "=" << pm;
#endif
iconset_->setIcon(QString("avatars/%1").arg(fullJid), icon); // FIXME do we ever release it?
iconset_.setIcon(QString("avatars/%1").arg(fullJid), icon); // FIXME do we ever release it?

return pm;
}
Expand Down Expand Up @@ -577,8 +577,7 @@ class AvatarCache : public FileCache {
AvatarCache() : FileCache(AvatarFactory::getCacheDir())
{
// Register iconset
iconset_ = new Iconset();
iconset_->addToFactory(); // the factory will own the iconset
iconset_.addToFactory(); // the factory will own the iconset
updateJids();

connect(VCardFactory::instance(), &VCardFactory::vcardChanged, this,
Expand Down Expand Up @@ -611,7 +610,7 @@ class AvatarCache : public FileCache {
#ifdef AVATAR_EDBUG
qDebug() << "removing icon from iconset:" << QString(QLatin1String("avatars/%1")).arg(fullJid);
#endif
iconset_->removeIcon(QString(QLatin1String("avatars/%1")).arg(fullJid));
iconset_.removeIcon(QString(QLatin1String("avatars/%1")).arg(fullJid));
emit avatarChanged(j);
}
});
Expand Down Expand Up @@ -858,7 +857,7 @@ class AvatarCache : public FileCache {

QHash<QString, JidIcons> jidToIcons;
QHash<Jid, QByteArray> jid2hash;
Iconset *iconset_;
Iconset iconset_;

static AvatarCache *_instance;
};
Expand Down
2 changes: 1 addition & 1 deletion src/contactlistviewdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ ContactListViewDelegate::Private::Private(ContactListViewDelegate *parent, Conta

statusIconSize_ = PsiIconset::instance()
->roster.value(PsiOptions::instance()->getOption(statusIconsetOptionPath).toString())
->iconSize();
.iconSize();

optionChanged("*");
colorOptionChanged("*");
Expand Down
Loading

0 comments on commit c86b138

Please sign in to comment.