KoColorProfileStorage.cpp (krita-5.1.3.tar.xz) | : | KoColorProfileStorage.cpp (krita-5.1.4.tar.xz) | ||
---|---|---|---|---|
skipping to change at line 15 | skipping to change at line 15 | |||
*/ | */ | |||
#include "KoColorProfileStorage.h" | #include "KoColorProfileStorage.h" | |||
#include <cmath> | #include <cmath> | |||
#include <QHash> | #include <QHash> | |||
#include <QReadWriteLock> | #include <QReadWriteLock> | |||
#include <QString> | #include <QString> | |||
#include "DebugPigment.h" | ||||
#include "KoColorSpaceFactory.h" | #include "KoColorSpaceFactory.h" | |||
#include "KoColorProfile.h" | #include "KoColorProfile.h" | |||
#include "kis_assert.h" | #include "kis_assert.h" | |||
struct KoColorProfileStorage::Private { | struct KoColorProfileStorage::Private { | |||
QHash<QString, KoColorProfile * > profileMap; | QHash<QString, KoColorProfile * > profileMap; | |||
QHash<QByteArray, KoColorProfile * > profileUniqueIdMap; | QHash<QByteArray, KoColorProfile * > profileUniqueIdMap; | |||
QList<KoColorProfile *> duplicates; | ||||
QHash<QString, QString> profileAlias; | QHash<QString, QString> profileAlias; | |||
QReadWriteLock lock; | QReadWriteLock lock; | |||
void populateUniqueIdMap(); | void populateUniqueIdMap(); | |||
~Private() | ~Private() | |||
{ | { | |||
Q_FOREACH (KoColorProfile *p, profileMap) { | Q_FOREACH (KoColorProfile *p, profileMap) { | |||
profileUniqueIdMap.remove(p->uniqueId()); | ||||
delete p; | delete p; | |||
} | } | |||
profileMap.clear(); | profileMap.clear(); | |||
Q_FOREACH (KoColorProfile *p, profileUniqueIdMap) { | ||||
delete p; | ||||
} | ||||
profileUniqueIdMap.clear(); | profileUniqueIdMap.clear(); | |||
Q_FOREACH(KoColorProfile *p, duplicates) { | ||||
delete p; | ||||
} | ||||
duplicates.clear(); | ||||
} | } | |||
}; | }; | |||
KoColorProfileStorage::KoColorProfileStorage() | KoColorProfileStorage::KoColorProfileStorage() | |||
: d(new Private) | : d(new Private) | |||
{ | { | |||
} | } | |||
KoColorProfileStorage::~KoColorProfileStorage() | KoColorProfileStorage::~KoColorProfileStorage() | |||
{ | { | |||
} | } | |||
void KoColorProfileStorage::addProfile(KoColorProfile *profile) | void KoColorProfileStorage::addProfile(KoColorProfile *profile) | |||
{ | { | |||
QWriteLocker locker(&d->lock); | QWriteLocker locker(&d->lock); | |||
if (profile->valid()) { | if (profile->valid()) { | |||
d->profileMap[profile->name()] = profile; | d->profileMap[profile->name()] = profile; | |||
if (d->profileUniqueIdMap.contains(profile->uniqueId())) { | if (!d->profileUniqueIdMap.isEmpty()) { | |||
warnPigment << "Duplicated profile" << profile->name() << profile->f | d->profileUniqueIdMap.insert(profile->uniqueId(), profile); | |||
ileName() << d->profileUniqueIdMap[profile->uniqueId()]->fileName(); | ||||
d->duplicates.append(d->profileUniqueIdMap[profile->uniqueId()]); | ||||
} | } | |||
d->profileUniqueIdMap.insert(profile->uniqueId(), profile); | ||||
} | } | |||
} | } | |||
void KoColorProfileStorage::removeProfile(KoColorProfile *profile) | void KoColorProfileStorage::removeProfile(KoColorProfile *profile) | |||
{ | { | |||
QWriteLocker locker(&d->lock); | QWriteLocker locker(&d->lock); | |||
d->profileMap.remove(profile->name()); | d->profileMap.remove(profile->name()); | |||
if (!d->profileUniqueIdMap.isEmpty()) { | if (!d->profileUniqueIdMap.isEmpty()) { | |||
d->profileUniqueIdMap.remove(profile->uniqueId()); | d->profileUniqueIdMap.remove(profile->uniqueId()); | |||
End of changes. 7 change blocks. | ||||
15 lines changed or deleted | 2 lines changed or added |