Commit 78ea95b5 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix crash when Colorize Tool is active on closing Krita

Steps to reproduce:
1) Create a layer with colorize mask
2) Disable "Show key strokes" on the mask (important)
3) Select "Colorize Tool"
4) Click on the mask, to lazily activate key strokes
5) Close Krita -> Crash

The crash happened because of some weird update signals coming
after KisView was actually destroyed.
parent 3def70fa
......@@ -311,6 +311,8 @@ void TimelineFramesModel::slotImageContentChanged()
void TimelineFramesModel::processUpdateQueue()
{
if (!m_d->converter) return;
Q_FOREACH (KisNodeDummy *dummy, m_d->updateQueue) {
int row = m_d->converter->rowForDummy(dummy);
......
......@@ -253,7 +253,7 @@ void KisUndoModel::addImage(int idx)
const KUndo2Command* currentCommand = m_stack->command(idx-1);
if (m_stack->count() == idx && !m_imageMap.contains(currentCommand)) {
KisImageWSP historyImage = m_canvas->viewManager()->image();
KisImageWSP historyImage = m_canvas->image();
KisPaintDeviceSP paintDevice = historyImage->projection();
QImage image = paintDevice->createThumbnail(32, 32, 1,
KoColorConversionTransformation::internalRenderingIntent(),
......
......@@ -49,7 +49,7 @@ struct KisToolLazyBrush::Private
bool oldShowKeyStrokesValue = false;
bool oldShowColoringValue = false;
KisNodeSP manuallyActivatedNode;
KisNodeWSP manuallyActivatedNode;
KisSignalAutoConnectionsStore toolConnections;
};
......@@ -69,10 +69,15 @@ KisToolLazyBrush::~KisToolLazyBrush()
void KisToolLazyBrush::tryDisableKeyStrokesOnMask()
{
if (m_d->manuallyActivatedNode) {
KisLayerPropertiesIcons::setNodeProperty(m_d->manuallyActivatedNode, KisLayerPropertiesIcons::colorizeEditKeyStrokes, false, image());
m_d->manuallyActivatedNode = 0;
// upgrade to strong pointer
KisNodeSP manuallyActivatedNode = m_d->manuallyActivatedNode;
if (manuallyActivatedNode) {
KisLayerPropertiesIcons::setNodeProperty(manuallyActivatedNode, KisLayerPropertiesIcons::colorizeEditKeyStrokes, false, image());
manuallyActivatedNode = 0;
}
m_d->manuallyActivatedNode = 0;
}
......@@ -101,7 +106,10 @@ void KisToolLazyBrush::deactivate()
void KisToolLazyBrush::slotCurrentNodeChanged(KisNodeSP node)
{
if (node != m_d->manuallyActivatedNode) {
// upgrade to strong pointer
KisNodeSP manuallyActivatedNode = m_d->manuallyActivatedNode;
if (node != manuallyActivatedNode) {
tryDisableKeyStrokesOnMask();
KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(node.data());
......@@ -190,10 +198,12 @@ void KisToolLazyBrush::beginPrimaryAction(KoPointerEvent *event)
if (!colorizeMaskActive() && canCreateColorizeMask()) {
tryCreateColorizeMask();
} else if (shouldActivateKeyStrokes()) {
// upgrade to strong pointer
KisNodeSP manuallyActivatedNode = m_d->manuallyActivatedNode;
KisNodeSP node = currentNode();
KIS_SAFE_ASSERT_RECOVER_NOOP(!m_d->manuallyActivatedNode ||
m_d->manuallyActivatedNode == node);
KIS_SAFE_ASSERT_RECOVER_NOOP(!manuallyActivatedNode ||
manuallyActivatedNode == node);
KisLayerPropertiesIcons::setNodeProperty(node,
KisLayerPropertiesIcons::colorizeEditKeyStrokes,
......
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