diff --git a/libcockatrice_card/libcockatrice/card/card_info.cpp b/libcockatrice_card/libcockatrice/card/card_info.cpp index 5302a4bd2..786e17950 100644 --- a/libcockatrice_card/libcockatrice/card/card_info.cpp +++ b/libcockatrice_card/libcockatrice/card/card_info.cpp @@ -25,7 +25,11 @@ const QHash &CardInfo::getPropertiesHash() const void CardInfo::setProperty(const QString &_name, const QString &_value) { - properties.insert(_name, _value); + bool changed = properties.insert(_name, _value); + if (!changed) { + return; + } + emit cardInfoChanged(smartThis); } diff --git a/libcockatrice_card/libcockatrice/card/lazy_properties_hash.cpp b/libcockatrice_card/libcockatrice/card/lazy_properties_hash.cpp index dfbcf1b06..4d903a3bd 100644 --- a/libcockatrice_card/libcockatrice/card/lazy_properties_hash.cpp +++ b/libcockatrice_card/libcockatrice/card/lazy_properties_hash.cpp @@ -76,10 +76,16 @@ QString LazyPropertiesHash::value(const QString &key) const return properties.value(key); } -void LazyPropertiesHash::insert(const QString &key, const QString &value) +bool LazyPropertiesHash::insert(const QString &key, const QString &value) { ensureMaterialized(); + + if (value == properties.value(key)) { + return false; + } + properties.insert(key, value); + return true; } const QHash &LazyPropertiesHash::getProperties() const diff --git a/libcockatrice_card/libcockatrice/card/lazy_properties_hash.h b/libcockatrice_card/libcockatrice/card/lazy_properties_hash.h index 5d07070a7..0ed8c215b 100644 --- a/libcockatrice_card/libcockatrice/card/lazy_properties_hash.h +++ b/libcockatrice_card/libcockatrice/card/lazy_properties_hash.h @@ -60,8 +60,9 @@ public: * @brief Inserts a value into the materialized properties hash * @param key The key * @param value The value to insert + * @return True if a new value was inserted; false if the new value is the same as the existing value */ - void insert(const QString &key, const QString &value); + bool insert(const QString &key, const QString &value); /** * @brief Gets a view of the materialized properties hash.