Bug SS-1224
1 vote

[DEV] RegionHolder PrePainter vs Resize vs Recalculation

Created by Davide on 9/29/2014 10:57 PM Last Updated by Davide on 9/30/2014 2:53 PM
%
 (hrs)
Logged: 0   (hrs)

 Description

In the CFLabelRegion plugin I've noticed a random exception (something like "Index out of matrix limits" - in the OS language); at a first glance seems based on the execution speed (recalculation thrown before the ends of the previous calculation - or many resize triggered at once?).
 
How it works the plugin:
Inside the RegionHolder OnEvaluation(...)
 1) Get a random a string from the placeholder
 2) Check for the string size (width & height)
 3) Set the canvas size (Size = newSize)
 4) Call the RegionHolder PrePainter() (because the canvas PrePainter() doesn't adjust the region size)
 5) Call the RegionHolder Invalidate()
 
Point 4 throws the exception.
 
I've looked at the RegionHolder PrePainter(), so I've replaced in my code PrePainter() with:
this.Size = new Size(Math.Max(canv.Size.Width + 10, this.InputDataVisibility ? this.math.Size.Width : 0), this.math.Location.Y + (this.InputDataVisibility ? this.math.Size.Height : 6));
and all goes fine.
 
That's the private ENQ() function, whereas the PrePainter calls ENQ() and then base.Resize();
So I think the problem is in the baes.Resize() or in something wrong in my approach (points 3-4-5).
 
 
I attach a file that generate the issue with the previous version of the plugin (previous both on gallery & SVN)
- change the slider values repetively until the region causes the crash - use try/catch on the PrePainter to show the error

    Davide (Tuesday, September 30, 2014 2:53 PM) #

Not related with the bug.... the BTS counter is jumped from 225 to 1224 o_O