Bug 395981

Summary: Merge with Layer Below in Isolate Layer mode either switches off or keeps Isolate mode randomly
Product: [Applications] krita Reporter: Nabil Maghfur usman <nmaghfurusman>
Component: Layer StackAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: antti.savo, halla, kwadraatnope
Priority: NOR    
Version: 4.1.0   
Target Milestone: ---   
Platform: Debian unstable   
OS: Linux   
Latest Commit: Version Fixed In:

Description Nabil Maghfur usman 2018-06-28 22:11:10 UTC
Fairly sure this is a pretty recent regression but can't be sure. I can't reproduce it the bug on krita-4.1.0-pre-alpha-f40feba-x86_64.appimage which I downloaded on 31st May, but on this new 4.1.0 release I can reproduce the bug 100% of the time.

Steps to Reproduce:
1. Create a new document based on template Design cinema 16:10. This document has 2 layers already.
2. Right-click on Layer 2 --> Isolate Layer
3. Layer --> Merge with Layer Below

Expected Result:
The the resulting merged layer is Layer 1

Actual Result:
Crash ("segmentation fault")
Comment 1 Antti Savolainen 2018-06-29 12:58:22 UTC
Can reproduce. https://youtu.be/d48iO9lhwn8
Build & Platform:
    krita 4.1.0-pre-alpha (git hash: ae24634)
    Xubuntu 17.10

Thread 1 "krita" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff3edb0bb in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff3edcf5d in __GI_abort () at abort.c:90
#2  0x00007ffff48b8107 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007ffff48b3357 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff6e5e8bf in KisSharedPtr<KisNode>::operator->() (this=0x7fffffffc558) at /home/managor/Sourcebuilding/krita/libs/global/kis_shared_ptr.h:180
#5  0x00007ffff6fef273 in KisNodeManager::toggleIsolateMode(bool) (this=0x55555a113a68, checked=true) at /home/managor/Sourcebuilding/krita/libs/ui/kis_node_manager.cpp:477
#6  0x00007ffff6fef76d in KisNodeManager::slotTryFinishIsolatedMode() (this=0x55555a113a68) at /home/managor/Sourcebuilding/krita/libs/ui/kis_node_manager.cpp:506
#7  0x00007ffff73ec0d1 in KisNodeManager::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=0x55555a113a68, _c=QMetaObject::InvokeMetaMethod, _id=14, _a=0x7fffffffc7c0)
    at /home/managor/Sourcebuilding/b-krita/libs/ui/kritaui_autogen/EWIEGA46WW/moc_kis_node_manager.cpp:325
#8  0x00007ffff4ad98e5 in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007ffff73ecb52 in KisNodeManager::sigNodeActivated(KisSharedPtr<KisNode>) (this=0x55555a113a68, _t1=...) at /home/managor/Sourcebuilding/b-krita/libs/ui/kritaui_autogen/EWIEGA46WW/moc_kis_node_manager.cpp:447
#10 0x00007ffff6ff0ad0 in KisNodeManager::slotSomethingActivatedNodeImpl(KisSharedPtr<KisNode>) (this=0x55555a113a68, node=...) at /home/managor/Sourcebuilding/krita/libs/ui/kis_node_manager.cpp:612
#11 0x00007ffff6ff1033 in KisNodeManager::slotUiActivatedNode(KisSharedPtr<KisNode>) (this=0x55555a113a68, node=...) at /home/managor/Sourcebuilding/krita/libs/ui/kis_node_manager.cpp:653
#12 0x00007ffff7006db9 in KisNodeSelectionAdapter::setActiveNode(KisSharedPtr<KisNode>) (this=0x55555974aea0, node=...) at /home/managor/Sourcebuilding/krita/libs/ui/kis_node_selection_adapter.cpp:46
#13 0x00007ffff7009fe4 in KisNodeModel::setData(QModelIndex const&, QVariant const&, int) (this=0x555560d5c3e0, index=..., value=..., role=257) at /home/managor/Sourcebuilding/krita/libs/ui/kis_node_model.cpp:547
#14 0x00007ffff4a6bf3a in QSortFilterProxyModel::setData(QModelIndex const&, QVariant const&, int) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#15 0x00007ffff700eba0 in KisNodeFilterProxyModel::setData(QModelIndex const&, QVariant const&, int) (this=0x555560d5cc20, index=..., value=..., role=257) at /home/managor/Sourcebuilding/krita/libs/ui/kis_node_filter_proxy_model.cpp:70
#16 0x00007ffff72ed804 in KisNodeView::currentChanged(QModelIndex const&, QModelIndex const&) (this=0x555560d50c90, current=..., previous=...) at /home/managor/Sourcebuilding/krita/libs/ui/KisNodeView.cpp:312
#17 0x00007ffff73d45ef in KisNodeView::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=0x555560d50c90, _c=QMetaObject::InvokeMetaMethod, _id=3, _a=0x7fffffffcc70)
    at /home/managor/Sourcebuilding/b-krita/libs/ui/kritaui_autogen/EWIEGA46WW/moc_KisNodeView.cpp:119
#18 0x00007ffff4ad98e5 in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#19 0x00007ffff4a56f3a in QItemSelectionModel::currentChanged(QModelIndex const&, QModelIndex const&) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#20 0x00007ffff4a5722e in QItemSelectionModel::setCurrentIndex(QModelIndex const&, QFlags<QItemSelectionModel::SelectionFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#21 0x00007ffff5a6b6f9 in QAbstractItemView::setCurrentIndex(QModelIndex const&) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#22 0x00007fffb4e15ba5 in KisLayerBox::slotAboutToRemoveRows(QModelIndex const&, int, int) (this=0x55555ed27e00, parent=..., start=1, end=1) at /home/managor/Sourcebuilding/krita/plugins/dockers/defaultdockers/kis_layer_box.cpp:862
#23 0x00007fffb4e23c06 in QtPrivate::FunctorCall<QtPrivate::IndexesList<0, 1, 2>, QtPrivate::List<QModelIndex const&, int, int>, void, void (KisLayerBox::*)(QModelIndex const&, int, int)>::call(void (KisLayerBox::*)(QModelIndex const&, int, int), KisLayerBox*, void**) (f=(void (KisLayerBox::*)(KisLayerBox * const, const QModelIndex &, int, int)) 0x7fffb4e15900 <KisLayerBox::slotAboutToRemoveRows(QModelIndex const&, int, int)>, o=0x55555ed27e00, arg=0x7fffffffcff0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:136
#24 0x00007fffb4e236a9 in QtPrivate::FunctionPointer<void (KisLayerBox::*)(QModelIndex const&, int, int)>::call<QtPrivate::List<QModelIndex const&, int, int>, void>(void (KisLayerBox::*)(QModelIndex const&, int, int), KisLayerBox*, void**) (f=
    (void (KisLayerBox::*)(KisLayerBox * const, const QModelIndex &, int, int)) 0x7fffb4e15900 <KisLayerBox::slotAboutToRemoveRows(QModelIndex const&, int, int)>, o=0x55555ed27e00, arg=0x7fffffffcff0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:169
#25 0x00007fffb4e2258b in QtPrivate::QSlotObject<void (KisLayerBox::*)(QModelIndex const&, int, int), QtPrivate::List<QModelIndex const&, int, int>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, this_=0x555560d7f970, r=0x55555ed27e00, a=0x7fffffffcff0, ret=0x0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobject_impl.h:120
#26 0x00007ffff4ad99ff in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#27 0x00007ffff4a462be in QAbstractItemModel::rowsAboutToBeRemoved(QModelIndex const&, int, int, QAbstractItemModel::QPrivateSignal) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#28 0x00007ffff4a4d21b in QAbstractItemModel::beginRemoveRows(QModelIndex const&, int, int) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#29 0x00007ffff4a71b65 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#30 0x00007ffff4a71d03 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#31 0x00007ffff4a74358 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#32 0x00007ffff4ad98e5 in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#33 0x00007ffff4a462be in QAbstractItemModel::rowsAboutToBeRemoved(QModelIndex const&, int, int, QAbstractItemModel::QPrivateSignal) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#34 0x00007ffff4a4d21b in QAbstractItemModel::beginRemoveRows(QModelIndex const&, int, int) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#35 0x00007ffff7008b2e in KisNodeModel::slotBeginRemoveDummy(KisNodeDummy*) (this=0x555560d5c3e0, dummy=0x555561a53fc0) at /home/managor/Sourcebuilding/krita/libs/ui/kis_node_model.cpp:348
#36 0x00007ffff73ecdc5 in KisNodeModel::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=0x555560d5c3e0, _c=QMetaObject::InvokeMetaMethod, _id=4, _a=0x7fffffffd5f0)
    at /home/managor/Sourcebuilding/b-krita/libs/ui/kritaui_autogen/EWIEGA46WW/moc_kis_node_model.cpp:124
#37 0x00007ffff4ad98e5 in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#38 0x00007ffff73e20f4 in KisDummiesFacadeBase::sigBeginRemoveDummy(KisNodeDummy*) (this=0x5555619fee00, _t1=0x555561a53fc0) at /home/managor/Sourcebuilding/b-krita/libs/ui/kritaui_autogen/QUY67KCZCL/moc_kis_dummies_facade_base.cpp:281
#39 0x00007ffff6f49b64 in KisDummiesFacadeBase::slotContinueRemoveNode(KisSharedPtr<KisNode>) (this=0x5555619fee00, node=...) at /home/managor/Sourcebuilding/krita/libs/ui/flake/kis_dummies_facade_base.cpp:153
#40 0x00007ffff73e1943 in KisDummiesFacadeBase::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=0x5555619fee00, _c=QMetaObject::InvokeMetaMethod, _id=14, _a=0x7fff9002e200)
    at /home/managor/Sourcebuilding/b-krita/libs/ui/kritaui_autogen/QUY67KCZCL/moc_kis_dummies_facade_base.cpp:148
#41 0x00007ffff4ada452 in QObject::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#42 0x00007ffff582546c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#43 0x00007ffff582cd34 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#44 0x00007ffff72ca7a7 in KisApplication::notify(QObject*, QEvent*) (this=0x7fffffffde20, receiver=0x5555619fee00, event=0x7fff9002edb0) at /home/managor/Sourcebuilding/krita/libs/ui/KisApplication.cpp:626
#45 0x00007ffff4aaade8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#46 0x00007ffff4aad55d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#47 0x00007ffff4b03e53 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#48 0x00007fffec03bfb7 in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#49 0x00007fffec03c1f0 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#50 0x00007fffec03c27c in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#51 0x00007ffff4b0347f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#52 0x00007ffff4aa8e3a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#53 0x00007ffff4ab1da4 in QCoreApplication::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#54 0x0000555555e903cc in main(int, char**) (argc=1, argv=0x7fffffffdf88) at /home/managor/Sourcebuilding/krita/krita/main.cc:419
Comment 2 Halla Rempt 2018-06-30 09:21:15 UTC
Dmitry, can you take a look? It's not simply the check for the node types that is broken -- there's something really fishy going on since there's no active node at this point.
Comment 3 Antti Savolainen 2018-07-03 20:16:40 UTC
*** Bug 396134 has been marked as a duplicate of this bug. ***
Comment 4 Dmitry Kazakov 2018-07-04 08:55:49 UTC
Update bug category to a crash
Comment 5 Dmitry Kazakov 2018-07-04 09:50:43 UTC
Git commit ecfc956daa5464aa92a77eb30cd9849ef6529c69 by Dmitry Kazakov.
Committed on 04/07/2018 at 09:50.
Pushed by dkazakov into branch 'master'.

Avoid a crash when merging layers in isolated mode

This patch fixes the crash, bit doesn't fix the entire
problem. Now after the merge the isolated mode may either
stay activated or not depending on random conditions.

M  +5    -5    libs/ui/kis_node_manager.cpp
M  +1    -1    libs/ui/kis_node_manager.h

https://commits.kde.org/krita/ecfc956daa5464aa92a77eb30cd9849ef6529c69
Comment 6 Dmitry Kazakov 2018-07-04 09:52:09 UTC
Git commit 3eaa8b2c47ebd7bb5fb860aa61e950e8a3d8c81a by Dmitry Kazakov.
Committed on 04/07/2018 at 09:51.
Pushed by dkazakov into branch 'krita/4.1'.

Avoid a crash when merging layers in isolated mode

This patch fixes the crash, bit doesn't fix the entire
problem. Now after the merge the isolated mode may either
stay activated or not depending on random conditions.

M  +5    -5    libs/ui/kis_node_manager.cpp
M  +1    -1    libs/ui/kis_node_manager.h

https://commits.kde.org/krita/3eaa8b2c47ebd7bb5fb860aa61e950e8a3d8c81a
Comment 7 Bollebib 2018-07-21 10:35:35 UTC
disabling isolate layer randomly is a bit inconsistant but its better then random crash! thnx
Comment 8 Dmitry Kazakov 2019-04-02 16:43:00 UTC
Git commit 759ecacbacdf1a6f62880604a51bdf52ea46f4ab by Dmitry Kazakov.
Committed on 02/04/2019 at 16:42.
Pushed by dkazakov into branch 'master'.

Fix activation of Isolate Mode when merging the layers down

When merging layers down, a null layer is activated for a short
period of time. It happens because the following:

1) When we remove the top layer, LayerBox adjusts the currently
selected index to the lower node. And tries to activate it.

2) The activated node is passed further by the signals chain,
and then in KisNodeManager::slotNonUiActivatedNode() we find
out that this node has also been removed from the node graph.
Therefore we pass 0 to the lower-level code.

3) Isolate mode code sees that there is no layer selected and
stops the isolated mode.

The patch fixes the issue by storing a separate flag, marking
marking the presence of isolated mode. Even when there is no
layer to isolate, we still save the sate and try to activate
it when a valid node comes.

M  +7    -1    libs/ui/kis_node_manager.cpp

https://commits.kde.org/krita/759ecacbacdf1a6f62880604a51bdf52ea46f4ab
Comment 9 Dmitry Kazakov 2019-04-02 16:50:36 UTC
Sorry, the patch was reverted.
Comment 10 Dmitry Kazakov 2019-04-03 09:41:13 UTC
Git commit 5215befc243d69de120506e67bd63b08cb5052c3 by Dmitry Kazakov.
Committed on 03/04/2019 at 09:41.
Pushed by dkazakov into branch 'master'.

Fix activation of Isolate Mode when merging the layers down

When merging layers down, a null layer is activated for a short
period of time. It happens because the following:

1) When we remove the top layer, LayerBox adjusts the currently
selected index to the lower node. And tries to activate it.

2) The activated node is passed further by the signals chain,
and then in KisNodeManager::slotNonUiActivatedNode() we find
out that this node has also been removed from the node graph.
Therefore we pass 0 to the lower-level code.

3) Isolate mode code sees that there is no layer selected and
stops the isolated mode.

The patch fixes the issue by storing a separate flag, marking
marking the presence of isolated mode. Even when there is no
layer to isolate, we still save the sate and try to activate
it when a valid node comes.

The patch also disables automated switch-off of the isolated mode
hen adding/removing. The mode will continue until the user switches
it off manually (or something really weird happens)

M  +3    -6    libs/image/kis_image.cc
M  +19   -2    libs/ui/kis_node_manager.cpp
M  +1    -0    libs/ui/kis_node_manager.h

https://commits.kde.org/krita/5215befc243d69de120506e67bd63b08cb5052c3