--- a/src/documentmanager.cpp Wed May 25 17:25:24 2022 +0300 +++ b/src/documentmanager.cpp Wed May 25 17:42:02 2022 +0300 @@ -370,10 +370,21 @@ Model* model = this->getModelById(modelId); if (model != nullptr) { - this->polygonCaches.emplace( - std::piecewise_construct, - std::forward_as_tuple(modelId), - std::forward_as_tuple(model)); + this->polygonCaches[modelId] = {}; + connect(model, &Model::dataChanged, this, &DocumentManager::modelModified); + connect(model, &Model::rowsInserted, this, &DocumentManager::modelModified); + connect(model, &Model::rowsRemoved, this, &DocumentManager::modelModified); + } +} + +void DocumentManager::modelModified() +{ + Model* model = qobject_cast<Model*>(this->sender()); + for (auto it = this->openModels.begin(); it != this->openModels.end(); ++it) { + if (model == it->second.model.get()) { + this->polygonCaches[it->second.id].needRecache = true; + break; + } } }