From 32ac661d0e2ad8b99a49b0548072fc32b67906f4 Mon Sep 17 00:00:00 2001 From: Sergei Ilinykh Date: Sun, 13 Oct 2024 01:57:41 +0300 Subject: [PATCH] Don't detach iconsets some iconsets always have ref count=2. so we had undesireiable detaches. for example in avatars cache --- src/avatars.cpp | 1 + src/tools/iconset/iconset.cpp | 19 ++++++++++++------- src/tools/iconset/iconset.h | 9 ++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/avatars.cpp b/src/avatars.cpp index eacd462d1..7e78bbb65 100644 --- a/src/avatars.cpp +++ b/src/avatars.cpp @@ -577,6 +577,7 @@ class AvatarCache : public FileCache { AvatarCache() : FileCache(AvatarFactory::getCacheDir()) { // Register iconset + iconset_.setName(QLatin1String("Avatars")); iconset_.addToFactory(); // the factory will own the iconset updateJids(); diff --git a/src/tools/iconset/iconset.cpp b/src/tools/iconset/iconset.cpp index 26908a437..e96db1a0c 100644 --- a/src/tools/iconset/iconset.cpp +++ b/src/tools/iconset/iconset.cpp @@ -1530,14 +1530,14 @@ Iconset &Iconset::operator=(const Iconset &from) // return is; // } -void Iconset::detach() { d.detach(); } +// void Iconset::detach() { d.detach(); } /** * Appends icons from Iconset \a from to this Iconset. */ Iconset &Iconset::operator+=(const Iconset &i) { - detach(); + // detach(); QListIterator it(i.d->list); while (it.hasNext()) { @@ -1553,7 +1553,7 @@ Iconset &Iconset::operator+=(const Iconset &i) */ void Iconset::clear() { - detach(); + // detach(); d->clear(); } @@ -1576,7 +1576,7 @@ bool Iconset::load(const QString &dir, Format format) } Q_ASSERT(!dir.isEmpty()); - detach(); + // detach(); // make it run okay on windows 9.x (where the pixmap memory is limited) // QPixmap::Optimization optimization = QPixmap::defaultOptimization(); @@ -1642,7 +1642,7 @@ const PsiIcon *Iconset::icon(const QString &name) const */ void Iconset::setIcon(const QString &name, const PsiIcon &icon) { - detach(); + // detach(); PsiIcon *newIcon = new PsiIcon(icon); @@ -1655,7 +1655,7 @@ void Iconset::setIcon(const QString &name, const PsiIcon &icon) */ void Iconset::removeIcon(const QString &name) { - detach(); + // detach(); d->remove(name); } @@ -1670,6 +1670,11 @@ const QString &Iconset::id() const { return d->id; } */ const QString &Iconset::name() const { return d->name; } +/** + * Sets Iconset name (used for dynamic iconsets). + */ +void Iconset::setName(const QString &name) { d->name = name; } + /** * Returns the icons size from Iconset. */ @@ -1725,7 +1730,7 @@ void Iconset::setFileName(const QString &f) { d->filename = f; } */ void Iconset::setInformation(const Iconset &from) { - detach(); + // detach(); d->setInformation(*(from.d)); } diff --git a/src/tools/iconset/iconset.h b/src/tools/iconset/iconset.h index 4435e07dd..51db4e59f 100644 --- a/src/tools/iconset/iconset.h +++ b/src/tools/iconset/iconset.h @@ -203,8 +203,11 @@ class Iconset { void setIcon(const QString &, const PsiIcon &); void removeIcon(const QString &); - const QString &id() const; - const QString &name() const; + const QString &id() const; + + const QString &name() const; + void setName(const QString &name); + const QString &version() const; const QString &description() const; const QStringList &authors() const; @@ -231,7 +234,7 @@ class Iconset { static void setSoundPrefs(QString unpackPath, QObject *receiver, const char *slot); // Iconset copy() const; - void detach(); + // void detach(); private: class Private;