Invalidate event (Repaint) can be starved with long executing actions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pinta |
New
|
Undecided
|
Unassigned |
Bug Description
In PintaCanvas (Pinta.
In the worst casse scenario, like a took that is occurring many times and in itself that it take a lot of time, i.e. gradient on a big picture, the painting of the control occurs very late.
Steps to reproduce:
- Create a new picture of 3000x3000 or any size that gradient will happen slow
- Move mouse many seconds around making gradient to be seen
Actual result:
- after releasing the mouse button, Pinta will do in the background painting of the gradients and will look like frozen
Expected result:
- just the last gradient should be executed, all "intermediary" invisible gradients should not be processed
Note: to test this behavior:
- add in Linux build Console.
I attached a patch that may address the problem (certainly fixes on my machine, I don't know side effects on other actions).
In short the fixes are:
Added an internal class (could be added to Utility class, as was added RangeEnumerator) that can store just one computation, and made one internal instance to compute that:
ToCompute _toCompute = new ToCompute();
class ToCompute
{
public delegate void ExecutedEvent();
public ExecutedEvent Executed;
public void AddEvent( ExecutedEvent ev)
Executed = null;
Executed += ev;
{
}
public void ComputeAll()
if(Executed! =null)
Executed( );
Executed = null;
{
}
}
Add the MotionEvents with AddEvent that will clear the previous motion event and will take all closures arguments using lambdas: ntArgs e) { Workspace. HasOpenDocument s) ntArgs e) {
_toCompute. AddEvent( () => { //here is the lambda Workspace. HasOpenDocument s)
GdkWindow. Invalidate( );
So previous code was:
MotionNotifyEvent += delegate (object sender, MotionNotifyEve
if (!PintaCore.
And it was replaced with:
MotionNotifyEvent += delegate (object sender, MotionNotifyEve
if (!PintaCore.
and after that is forcing a view paint:
}; //end of lambda
And at last, but not at least, added the motion event in invalidate method at start of it:
So the previous code:
if (!PintaCore. Workspace. HasOpenDocument s)
return true;
was replaced with:
if (!PintaCore. Workspace. HasOpenDocument s)
return true;