diff --git a/src/items/item.cpp b/src/items/item.cpp index 6f88544..7f350a2 100644 --- a/src/items/item.cpp +++ b/src/items/item.cpp @@ -161,26 +161,34 @@ Item& Item::operator=(const ItemData& other) void Item::requestUpdate(ItemUpdateRequest update) { - if(!hasChanged(update.payload)) + assert(update.type != ITEM_UPDATE_INVALID); + if(update.type != ITEM_UPDATE_LOADED && value_ == update.payload.getValue()) return; if(update.type == ITEM_UPDATE_ACTOR && override_) return; - if(update.type != ITEM_UPDATE_LOADED - && (programMode == PROGRAM_MODE_PRIMARY || programMode == PROGRAM_MODE_HEADLESS_PRIMARY)) + qDebug()<<"Item Update Request for"<& actor : update.newActors) addActor(actor); } - + update.payload = *this; updated(update); } @@ -286,6 +294,7 @@ ItemUpdateRequest Item::createValueUpdateRequest(uint8_t value, bool withActors) { ItemUpdateRequest update; + update.type = type; update.payload = *this; update.payload.setValueData(value); if(withActors) diff --git a/src/items/item.h b/src/items/item.h index f88b8cf..d461006 100644 --- a/src/items/item.h +++ b/src/items/item.h @@ -19,7 +19,8 @@ typedef enum { ITEM_UPDATE_ACTOR, ITEM_UPDATE_REMOTE, ITEM_UPDATE_LOADED, - ITEM_UPDATE_BACKEND + ITEM_UPDATE_BACKEND, + ITEM_UPDATE_INVALID } item_update_type_t; class ItemData @@ -67,7 +68,7 @@ public: struct ItemUpdateRequest { - item_update_type_t type; + item_update_type_t type = ITEM_UPDATE_INVALID; ItemData payload; std::vector > newActors; }; diff --git a/src/items/itemstore.cpp b/src/items/itemstore.cpp index a14ae6f..232d319 100644 --- a/src/items/itemstore.cpp +++ b/src/items/itemstore.cpp @@ -29,6 +29,7 @@ void ItemStore::addItem(const std::shared_ptr& item, item_update_type_t up ItemUpdateRequest request = item->createValueUpdateRequest(item->getValue(), updateType, updateType == ITEM_UPDATE_LOADED); + request.newActors = item->getActors(); updateItem(request); } } @@ -56,6 +57,7 @@ void ItemStore::removeItem(const ItemData& item) void ItemStore::replaceItems(const std::vector>& items) { + qDebug()<<__func__; addItems(items, ITEM_UPDATE_LOADED); std::vector deletedItems; for(std::shared_ptr item : items_) @@ -86,7 +88,6 @@ void ItemStore::updateItem(const ItemUpdateRequest& update) if(items_[i]->operator==(update.payload)) { items_[i]->requestUpdate(update); - qDebug() << "Item" << items_[i]->getName() << "updated"; itemUpdated(update); } } @@ -106,7 +107,6 @@ void ItemStore::store(QJsonObject& json) void ItemStore::itemUpdateSlot(ItemUpdateRequest update) { - qDebug() << "Item" << update.payload.getName() << "updated from update slot"; itemUpdated(update); }