LinuxCNC / linuxcnc

LinuxCNC controls CNC machines. It can drive milling machines, lathes, 3d printers, laser cutters, plasma cutters, robot arms, hexapods, and more.
http://linuxcnc.org/
GNU General Public License v2.0
1.78k stars 1.15k forks source link

Update glcanon.py #2792

Closed Sigma1912 closed 8 months ago

Sigma1912 commented 9 months ago

Fix overflow error when clicking on the zoomed out preview or rapidly clicking on individual lines.

andypugh commented 8 months ago

Are you sure that this is correct? The existing code attempts to double the size of the buffer on overflow (I think) whereas your new code appears to clear the buffer on any error. Should it perhaps be able to double the buffer size up to a certain limit?

Sigma1912 commented 8 months ago

I'm not certain that this is the best solution but it certainly seems to get rid of the errors while not breaking the functionality, at least in the testing I have done. As I understand it, we want the line number of the selected segment, which is the value of 'names[0]', to highlight the line in the Gcode window. The default buffer size is 100 and unless I'missing something, which is very much possible, I don't see why we would need to enlarge the buffer at all as we can only highlight the one line in the gcode.

hansu commented 8 months ago

I would suggest this:

            try:
                buffer = glRenderMode(GL_RENDER)
            except OverflowError:
                self.select_buffer_size *= 2
                continue
+           except OpenGL.error.GLError as e:
+             if e.err == GL_STACK_OVERFLOW:
+                   self.select_buffer_size *= 2
+               continue
            break
Sigma1912 commented 8 months ago

Still kind of begs the question as to why we would want to ingest hundreds or even thousands of segments to then only pick out a single one of them. The only effect this has (as far as I can tell) is that you can click on a preview that is zoomed all the way out and you will get some line in the gcode to highlight. With the original pull request you will not be able to select anything until you zoom in enough to actually be able to make a sensible selection.

andypugh commented 8 months ago

Feel free to submit a better solution, if you think of one.