Commit b5ec0775 authored by Boudewijn Rempt's avatar Boudewijn Rempt

BUG: 318759

Fix loading of images with selection masks.

Selections masks call KisMask::selection() in setVisibile, which
asserts if there initSelection() hasn't been called yet. But we cannot
call initSelection at this stage of loading because we're only creating
the node hierarchy, not the binary content yet.

So, add a flag "loading" that inhibits that call & all signal emissions.
parent 1efaf2b0
......@@ -200,11 +200,13 @@ bool KisBaseNode::visible(bool recursive) const
parentNode->visible() : isVisible;
}
void KisBaseNode::setVisible(bool visible)
void KisBaseNode::setVisible(bool visible, bool loading)
{
m_d->properties.setProperty("visible", visible);
emit visibilityChanged(visible);
baseNodeChangedCallback();
if (!loading) {
emit visibilityChanged(visible);
baseNodeChangedCallback();
}
}
bool KisBaseNode::userLocked() const
......
......@@ -280,8 +280,11 @@ public:
*
* Toggling the visibility of a node will not automatically lead
* to recomposition.
*
* @param visible the new visibility state
* @param isLoading if true, the property is set during loading.
*/
virtual void setVisible(bool v);
virtual void setVisible(bool visibile, bool loading = false);
/**
* Return the locked status of this node. Locked nodes cannot be
......
......@@ -114,13 +114,15 @@ void KisSelectionMask::setSectionModelProperties(const KoDocumentSectionModel::P
setActive(properties.at(2).state.toBool());
}
void KisSelectionMask::setVisible(bool visible)
void KisSelectionMask::setVisible(bool visible, bool isLoading)
{
nodeProperties().setProperty("visible", visible);
if (selection())
selection()->setVisible(visible);
emit(visibilityChanged(visible));
if (!isLoading) {
if (selection())
selection()->setVisible(visible);
emit(visibilityChanged(visible));
}
}
bool KisSelectionMask::active() const
......
......@@ -62,7 +62,7 @@ public:
virtual KoDocumentSectionModel::PropertyList sectionModelProperties() const;
virtual void setSectionModelProperties(const KoDocumentSectionModel::PropertyList &properties);
void setVisible(bool visible);
void setVisible(bool visible, bool isLoading = false);
bool active() const;
void setActive(bool active);
......
......@@ -297,9 +297,9 @@ bool KisShapeLayer::visible(bool recursive) const
return KisExternalLayer::visible(recursive);
}
void KisShapeLayer::setVisible(bool visible)
void KisShapeLayer::setVisible(bool visible, bool isLoading)
{
KisExternalLayer::setVisible(visible);
KisExternalLayer::setVisible(visible, isLoading);
}
bool KisShapeLayer::saveLayer(KoStore * store) const
......
......@@ -99,7 +99,7 @@ public:
KUndo2Command* transform(const QTransform &transform);
bool visible(bool recursive = false) const;
void setVisible(bool visible);
void setVisible(bool visible, bool isLoading = false);
protected:
using KoShape::isVisible;
......
......@@ -456,7 +456,7 @@ KisNodeSP KisKraLoader::loadNode(const KoXmlElement& element, KisImageWSP image,
// upstream to complain to the user
if (!node) return 0;
node->setVisible(visible);
node->setVisible(visible, true);
node->setUserLocked(locked);
node->setCollapsed(collapsed);
node->setX(x);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment