Index out of range exception after loading/printing gcode
- Issue MatterHackers/MCCentral#5152
This commit is contained in:
parent
fe52da9cdc
commit
6dda83eaa4
2 changed files with 7 additions and 3 deletions
|
|
@ -275,7 +275,7 @@ namespace MatterControl.Printing
|
|||
|
||||
public override double Ratio0to1IntoContainedLayer(int instructionIndex)
|
||||
{
|
||||
if (ByteCount != 0)
|
||||
if (ByteCount > 0)
|
||||
{
|
||||
return BytePosition / (double)ByteCount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -460,10 +460,14 @@ namespace MatterControl.Printing
|
|||
}
|
||||
|
||||
int deltaFromStart = Math.Max(0, instructionIndex - startIndex);
|
||||
return deltaFromStart / (double)(endIndex - startIndex);
|
||||
var length = endIndex - startIndex;
|
||||
if (length > 0)
|
||||
{
|
||||
return deltaFromStart / (double)(length);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void Save(string dest)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue