Login  Register

Re: RS_Painter::toGui crashes

Posted by dxli on Mar 19, 2025; 8:20pm
URL: https://forum.librecad.org/RS-Painter-toGui-crashes-tp5726734p5726741.html

The key point I wanted to make was to follow C++ Core Guidelines.

To show the new version I added is indeed equivalent, I added an assertion to compare the result coordinates the ULP tolerance.

Using ULP in comparison is the mistake here:

The two versions are equivalent, but not at the binary level; For Example:
Original version: y = -y + Height - yOffset;
New version:      y = y + yOffset;  y = Height - y;
                  i.e.: y = - y - yOffset  + Height;


If we modify the original version to: y = - y - yOffset  + Height; (from - y  + Height - yOffset ;), those two versions are equivalent at the binary level.