[chronojump] ForceSensor paintPoints interpolate path fix crashes on resizing window



commit ed2d27386efb35f6b1dabfb01418dee8300b0651
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue May 25 11:35:20 2021 +0200

    ForceSensor paintPoints interpolate path fix crashes on resizing window

 src/gui/app1/forceSensor.cs | 9 ++++++---
 src/utilGtk.cs              | 4 ++++
 2 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/gui/app1/forceSensor.cs b/src/gui/app1/forceSensor.cs
index 7452f2317..04cfea02a 100644
--- a/src/gui/app1/forceSensor.cs
+++ b/src/gui/app1/forceSensor.cs
@@ -1785,8 +1785,8 @@ LogB.Information(" fs R ");
                        //find the start of the interpolated_l position
                        ratioInterpolatedVsSamplesAtStart += toDraw * ratioInterpolatedVsSamples; //maybe 
this do not need to be called the first time
 
-                       //fix it if needed
-                       if(Convert.ToInt32(ratioInterpolatedVsSamplesAtStart) >= interpolate_l.Count)
+                       //fix it if needed (this while is helpful on resize window)
+                       while(Convert.ToInt32(ratioInterpolatedVsSamplesAtStart) >= interpolate_l.Count)
                                ratioInterpolatedVsSamplesAtStart -= interpolate_l.Count;
 
                        //initialize count
@@ -1812,7 +1812,7 @@ LogB.Information(" fs R ");
                                                                ));
 
                                        ratioInterpolatedVsSamplesCount += ratioInterpolatedVsSamples;
-                                       if(Convert.ToInt32(ratioInterpolatedVsSamplesCount) >= 
interpolate_l.Count)
+                                       while(Convert.ToInt32(ratioInterpolatedVsSamplesCount) >= 
interpolate_l.Count)
                                                ratioInterpolatedVsSamplesCount -= interpolate_l.Count;
                                }
                        }
@@ -1837,6 +1837,9 @@ LogB.Information(" fs R ");
                        {
                                List<Gdk.Point> paintPointsInterpolateEachSampleHead = new List<Gdk.Point>();
                                int start = Convert.ToInt32(paintPointsInterpolateEachSample.Count - (toDraw 
* ratioInterpolatedVsSamples));
+                               //precaution on resize screen
+                               if(start < 0)
+                                       start = 0;
 
                                for(int i = start; i < paintPointsInterpolateEachSample.Count; i ++)
                                        
paintPointsInterpolateEachSampleHead.Add(paintPointsInterpolateEachSample[i]);
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index bb1449d9a..d21a51ced 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -768,6 +768,10 @@ public class UtilGtk
 
        public static void GetPixelsInOutOfPath (Gdk.Point [] points, int start, Gdk.Pixmap pixmap, ref int 
inPath, ref int outPath, bool methodSafeMemory)
        {
+               //on resize screen, start is < 0
+               if(start < 0)
+                       start = 0;
+
                if(methodSafeMemory)
                        getPixelsInOutOfPathSafeMemory (points, start, pixmap, ref inPath, ref outPath);
                else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]