Bug 329192

Summary: Brush stroke does not paint anything if it follows Undo very quickly.
Product: [Applications] krita Reporter: Tyson Tan <tysontanx>
Component: Brush enginesAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73
Priority: NOR    
Version: 2.9 Beta   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Tyson Tan 2013-12-24 12:28:49 UTC
Probably after revision 76cb684c, a brush stroke that follows very quickly after an Undo operation does not paint anything on the canvas.

Some details:
1. A brush stroke must follow very quickly after the Undo operation. About 0.5s or less.
2. I'm using just 'Z' for Undo, 'Y' for redo. But it happens to the default Ctrl-Z, too.
3. I'm using a Wacom tablet.
4. OpenGL is ON.

I think Krita might have recognized the two successive operations -- (1) Undo, (2) Brush stroke -- as events that happen simultaneously. When the brush stroke did not paint, it looks exactly the same of what happens when I was pressing Z and apply a brush stroke at the same time.

This might not be a serious problem if the shortcut for Undo is set to the default Ctrl-Z. Because when you have to release two keys after undoing, you would slow down. Setting the Undo as 'Z' and Redo as 'Y' are habits from Mypaint. It enables me to do Undos and Redos quicker and feels less disruptive. Sometimes I undo the previously painted lines and then draw a new one quickly. I switch back and forth in very quick pace until I'm satisfied. Such behavior would trigger this bug very easily.

As far as I can remember, I have never encounter this bug until the last few days.

Reproducible: Always

Steps to Reproduce:
1. Set shortcut got Undo to Z, Redo to Y
2. Draw a few strokes
3. Do multiple Undos while quickly follow up with brush stroke.
Actual Results:  
Brush stroke does not paint anything if it follows Undo very quickly.

Expected Results:  
Brush stroke should paint normally even if it follows Undo very quickly.
Comment 1 Dmitry Kazakov 2013-12-25 11:36:21 UTC
Hi, Tyson!

Could you tell the size of the image, color depth and the size of the image?

The problem is I cannot reproduce the exact bug you are describing. That is the stroke after 'Z' always starts painting for me. But I have a bit different 'issue': if you press 'Z' too fast after the stroke (when it is not finished in the background yet), then the Undo will not happen. Probably, that is the problem you are describing?
Comment 2 Dmitry Kazakov 2013-12-25 14:23:35 UTC
Git commit 51a83b3f68d8eec465e1b750c0b3ab2e8ef3cc97 by Dmitry Kazakov.
Committed on 25/12/2013 at 14:23.
Pushed by dkazakov into branch 'master'.

Allow painting when no shortcuts have passed to current combination of keys

This patch does two things:
1) Changes the formula of the priority in the way that the
   shortcuts with left mouse button would have higher priority
   than ones with middle and right one
2) Add a tag to KisAbstractInputAction::canIgnoreModifiers(), which
   shows that the action can be run with any particular modifier
   (the default action).

M  +5    -0    krita/ui/input/kis_abstract_input_action.cpp
M  +7    -0    krita/ui/input/kis_abstract_input_action.h
M  +1    -1    krita/ui/input/kis_input_manager.cpp
M  +0    -7    krita/ui/input/kis_shortcut_matcher.cpp
M  +0    -1    krita/ui/input/kis_shortcut_matcher.h
M  +11   -3    krita/ui/input/kis_stroke_shortcut.cpp
M  +6    -1    krita/ui/input/kis_tool_invocation_action.cpp
M  +1    -0    krita/ui/input/kis_tool_invocation_action.h
M  +0    -3    krita/ui/tests/kis_input_manager_test.cpp

http://commits.kde.org/calligra/51a83b3f68d8eec465e1b750c0b3ab2e8ef3cc97
Comment 3 Tyson Tan 2013-12-26 19:14:41 UTC
Hi Dmitry, what I meant was exactly what I said, my operating sequence was like:
1) Brush stroke
2) Undo
3) Very quick new brush stroke
4) Operation in 3) doe not paint anything

I could reproduce this bug on any resolution and color depth before commit 51a83b3f68d8eec465e1b750c0b3ab2e8ef3cc97. Even though you said could not reproduce my description, with this new commit, I actually can't reproduce this bug any more. So thank you very much!

HOWEVER, AFTER the same commit, I actually encountered the exact same problem you described in comment1:
1) Brush stroke
2) Very quick Undo
3) Undo in 2) does not undo

I think this is because when I clicked Undo very quickly after a brush stroke, the brush stroke either had not yet finished painting on the canvas, or my hand had not finished drawing the last bit, as my thought was faster than my hand.

My suggestion is that in addition to you new commit, you might want to add something like this: Whenever a user use Undo, the current operation will be interrupted immediately and the unfinished part on the canvas will be reverted as well. Currently, it seems to me that an brush stroke must be completed before an Undo command can be accepted by Krita.
Comment 4 Dmitry Kazakov 2013-12-28 14:57:11 UTC
Git commit cef9ba1d309a2025d5f017ae692ca7e696f30b4b by Dmitry Kazakov.
Committed on 25/12/2013 at 14:23.
Pushed by dkazakov into branch 'calligra/2.8'.

Allow painting when no shortcuts have passed to current combination of keys

This patch does two things:
1) Changes the formula of the priority in the way that the
   shortcuts with left mouse button would have higher priority
   than ones with middle and right one
2) Add a tag to KisAbstractInputAction::canIgnoreModifiers(), which
   shows that the action can be run with any particular modifier
   (the default action).

M  +5    -0    krita/ui/input/kis_abstract_input_action.cpp
M  +7    -0    krita/ui/input/kis_abstract_input_action.h
M  +1    -1    krita/ui/input/kis_input_manager.cpp
M  +0    -7    krita/ui/input/kis_shortcut_matcher.cpp
M  +0    -1    krita/ui/input/kis_shortcut_matcher.h
M  +11   -3    krita/ui/input/kis_stroke_shortcut.cpp
M  +6    -1    krita/ui/input/kis_tool_invocation_action.cpp
M  +1    -0    krita/ui/input/kis_tool_invocation_action.h
M  +0    -3    krita/ui/tests/kis_input_manager_test.cpp

http://commits.kde.org/calligra/cef9ba1d309a2025d5f017ae692ca7e696f30b4b