mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-15 16:39:43 -05:00
Fix duplicate icon add in export
SharedObserver did not check for already added icons add during export leading to duplicate icons in the target db.
This commit is contained in:
parent
771ecdba12
commit
05bee40f0a
5 changed files with 37 additions and 5 deletions
|
|
@ -618,8 +618,8 @@ Merger::ChangeList Merger::mergeMetadata(const MergeContext& context)
|
|||
|
||||
const auto keys = sourceMetadata->customIcons().keys();
|
||||
for (QUuid customIconId : keys) {
|
||||
QImage customIcon = sourceMetadata->customIcon(customIconId);
|
||||
if (!targetMetadata->containsCustomIcon(customIconId)) {
|
||||
QImage customIcon = sourceMetadata->customIcon(customIconId);
|
||||
targetMetadata->addCustomIcon(customIconId, customIcon);
|
||||
changes << tr("Adding missing icon %1").arg(QString::fromLatin1(customIconId.toRfc4122().toHex()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -382,10 +382,12 @@ void Metadata::addCustomIcon(const QUuid& uuid, const QImage& icon)
|
|||
Q_ASSERT(!uuid.isNull());
|
||||
Q_ASSERT(!m_customIcons.contains(uuid));
|
||||
|
||||
m_customIcons.insert(uuid, icon);
|
||||
m_customIcons[uuid] = icon;
|
||||
// reset cache in case there is also an icon with that uuid
|
||||
m_customIconCacheKeys[uuid] = QPixmapCache::Key();
|
||||
m_customIconScaledCacheKeys[uuid] = QPixmapCache::Key();
|
||||
// remove all uuids to prevent duplicates in release mode
|
||||
m_customIconsOrder.removeAll(uuid);
|
||||
m_customIconsOrder.append(uuid);
|
||||
// Associate image hash to uuid
|
||||
QByteArray hash = hashImage(icon);
|
||||
|
|
|
|||
|
|
@ -592,7 +592,8 @@ Database* ShareObserver::exportIntoContainer(const KeeShareSettings::Reference&
|
|||
{
|
||||
const auto* sourceDb = sourceRoot->database();
|
||||
auto* targetDb = new Database();
|
||||
targetDb->metadata()->setRecycleBinEnabled(false);
|
||||
auto* targetMetadata = targetDb->metadata();
|
||||
targetMetadata->setRecycleBinEnabled(false);
|
||||
auto key = QSharedPointer<CompositeKey>::create();
|
||||
key->addKey(QSharedPointer<PasswordKey>::create(reference.password));
|
||||
|
||||
|
|
@ -610,8 +611,8 @@ Database* ShareObserver::exportIntoContainer(const KeeShareSettings::Reference&
|
|||
targetEntry->setGroup(targetRoot);
|
||||
targetEntry->setUpdateTimeinfo(updateTimeinfo);
|
||||
const auto iconUuid = targetEntry->iconUuid();
|
||||
if (!iconUuid.isNull()) {
|
||||
targetDb->metadata()->addCustomIcon(iconUuid, sourceEntry->icon());
|
||||
if (!iconUuid.isNull() && !targetMetadata->containsCustomIcon(iconUuid)) {
|
||||
targetMetadata->addCustomIcon(iconUuid, sourceEntry->icon());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue