Merge pull request #233 from fastolfe/zone-marker-overflow
Fix marker-out-of-bounds crash when defining zone pointspull/230/merge
commit
4565068093
src
|
@ -956,12 +956,16 @@ int Zone::Load( Monitor *monitor, Zone **&zones )
|
||||||
|
|
||||||
Debug( 5, "Parsing polygon %s", Coords );
|
Debug( 5, "Parsing polygon %s", Coords );
|
||||||
Polygon polygon;
|
Polygon polygon;
|
||||||
if ( !ParsePolygonString( Coords, polygon ) )
|
if ( !ParsePolygonString( Coords, polygon ) ) {
|
||||||
Panic( "Unable to parse polygon string '%s' for zone %d/%s for monitor %s", Coords, Id, Name, monitor->Name() );
|
Error( "Unable to parse polygon string '%s' for zone %d/%s for monitor %s, ignoring", Coords, Id, Name, monitor->Name() );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ( polygon.LoX() < 0 || polygon.HiX() >= (int)monitor->Width()
|
if ( polygon.LoX() < 0 || polygon.HiX() >= (int)monitor->Width()
|
||||||
|| polygon.LoY() < 0 || polygon.HiY() >= (int)monitor->Height() )
|
|| polygon.LoY() < 0 || polygon.HiY() >= (int)monitor->Height() ) {
|
||||||
Panic( "Zone %d/%s for monitor %s extends outside of image dimensions, %d, %d, %d, %d", Id, Name, monitor->Name(), polygon.LoX(), polygon.LoY(), polygon.HiX(), polygon.HiY() );
|
Error( "Zone %d/%s for monitor %s extends outside of image dimensions, (%d,%d), (%d,%d), ignoring", Id, Name, monitor->Name(), polygon.LoX(), polygon.LoY(), polygon.HiX(), polygon.HiY() );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ( false && !strcmp( Units, "Percent" ) )
|
if ( false && !strcmp( Units, "Percent" ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,9 +33,13 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* NB: The size of the imageFrame determines the area within which the markers
|
||||||
|
* may be moved. When adjusting the padding and margins of the imageFrame and
|
||||||
|
* the DIVs within it, test that the markers behave sensibly when dragged to
|
||||||
|
* the extreme edges of the imageFrame. */
|
||||||
#imageFrame {
|
#imageFrame {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 0 6px 6px 0; /* Double margin of points below */
|
padding: 0 3px 3px 0; /* Compensate for negative margins in the markers just below. */
|
||||||
}
|
}
|
||||||
|
|
||||||
#imageFrame div {
|
#imageFrame div {
|
||||||
|
|
|
@ -255,30 +255,13 @@ function applyZoneUnits()
|
||||||
|
|
||||||
function limitRange( field, minValue, maxValue )
|
function limitRange( field, minValue, maxValue )
|
||||||
{
|
{
|
||||||
if ( parseInt(field.value) < parseInt(minValue) )
|
field.value = constrainValue( parseInt(field.value), parseInt(minValue), parseInt(maxValue) );
|
||||||
{
|
|
||||||
field.value = minValue;
|
|
||||||
}
|
|
||||||
else if ( parseInt(field.value) > parseInt(maxValue) )
|
|
||||||
{
|
|
||||||
field.value = maxValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function limitFilter( field )
|
function limitFilter( field )
|
||||||
{
|
{
|
||||||
var minValue = 3;
|
|
||||||
var maxValue = 15;
|
|
||||||
|
|
||||||
field.value = (Math.floor((field.value-1)/2)*2) + 1;
|
field.value = (Math.floor((field.value-1)/2)*2) + 1;
|
||||||
if ( parseInt(field.value) < minValue )
|
field.value = constrainValue(parseInt(field.value), 3, 15);
|
||||||
{
|
|
||||||
field.value = minValue;
|
|
||||||
}
|
|
||||||
if ( parseInt(field.value) > maxValue )
|
|
||||||
{
|
|
||||||
field.value = maxValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function limitArea( field )
|
function limitArea( field )
|
||||||
|
@ -352,11 +335,22 @@ function fixActivePoint( index )
|
||||||
updateZoneImage();
|
updateZoneImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function constrainValue( value, loVal, hiVal )
|
||||||
|
{
|
||||||
|
if ( value < loVal ) {
|
||||||
|
return loVal;
|
||||||
|
}
|
||||||
|
if ( value > hiVal ) {
|
||||||
|
return hiVal;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
function updateActivePoint( index )
|
function updateActivePoint( index )
|
||||||
{
|
{
|
||||||
var point = $('point'+index);
|
var point = $('point'+index);
|
||||||
var x = point.getStyle( 'left' ).toInt();
|
var x = constrainValue( point.getStyle( 'left' ).toInt(), 0, maxX );
|
||||||
var y = point.getStyle( 'top' ).toInt();
|
var y = constrainValue( point.getStyle( 'top' ).toInt(), 0, maxY );
|
||||||
|
|
||||||
$('newZone[Points]['+index+'][x]').value = x;
|
$('newZone[Points]['+index+'][x]').value = x;
|
||||||
$('newZone[Points]['+index+'][y]').value = y;
|
$('newZone[Points]['+index+'][y]').value = y;
|
||||||
|
@ -387,10 +381,7 @@ function delPoint( index )
|
||||||
|
|
||||||
function limitPointValue( point, loVal, hiVal )
|
function limitPointValue( point, loVal, hiVal )
|
||||||
{
|
{
|
||||||
if ( point.value < loVal )
|
point.value = constrainValue(point.value, loVal, hiVal)
|
||||||
point.value = 0;
|
|
||||||
else if ( point.value > hiVal )
|
|
||||||
point.value = hiVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateX( index )
|
function updateX( index )
|
||||||
|
|
Loading…
Reference in New Issue