Negative SubPath length

Lots of documents from my clients have negative SubPath lengths, causing all sorts of trouble. Seems the problem can quite easily be reproduced (see below).

Any ideas around this? Known bug? Any fix?



[TestMethod] public void SubPath_length_becomes_negative() {     Module.CorelApp.ActiveDocument.Unit = Corel.Interop.VGCore.cdrUnit.cdrInch;     var c1 = Module.CorelApp.ActiveDocument.CreateCurve();     var sp1 = c1.CreateSubPath(0, 0);     sp1.AppendLineSegment(10000, 0);     // This fails. Length is not 10000 but -8454.6600314960633.     sp1.Length.Should().Be(10000); }
Parents
No Data
Reply
  • Fredrik, 

    I enjoyed figuring this one out. :-) It's a bug as you can tell. 

    It is breaking if the curve length is greater than 2147483647 micrometers or as CorelDRAW refers to them cdrTenthMicron. 

    If you convert 2147483648 micrometers to inches you get 84546.600314961 inches which is the number you are seeing.The number goes negative because it knows something is wrong. :-)

    Now, why would it break at that number, because 2147483647 is the max value you can have for an Integer and if you go over it, things go wrong.

    You have found a good workaround to total the value yourself. I was not able to come up with anything better. 

    -Shelby 

Children