Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix layer activation issue when opening multiple documents

Dmitry Kazakov3b5891816897
diff --git a/plugins/dockers/layerdocker/LayerBox.cpp b/plugins/dockers/layerdocker/LayerBox.cpp
index d561c7904f..326c06910c 100644
--- a/plugins/dockers/layerdocker/LayerBox.cpp
+++ b/plugins/dockers/layerdocker/LayerBox.cpp
@@ -742,6 +742,20 @@ void LayerBox::updateUI()
*/
void LayerBox::setCurrentNode(KisNodeSP node)
{
+ /**
+ * setCanvas() calls to node managed and layer box are coming out-of-sync,
+ * so it might happen that setCurrentNode() call will arrive with a node
+ * from a different image. We should check that and ignore such calls.
+ *
+ * TODO: make bootstrapping of layers-related structures a bit more
+ * straight-forward. We need to have a single source of truth for the
+ * "active layer", and all the initialization should happen in one
+ * direction without cycles.
+ */
+ if (node && m_image && node->graphListener() != m_image.data()) {
+ return;
+ }
+
m_filteringModel->setActiveNode(node);
QModelIndex index = node ? m_filteringModel->indexFromNode(node) : QModelIndex();