Skip to content

Update glcanon.py#2792

Merged
andypugh merged 1 commit intoLinuxCNC:2.9from
Sigma1912:patch-5
Jan 7, 2024
Merged

Update glcanon.py#2792
andypugh merged 1 commit intoLinuxCNC:2.9from
Sigma1912:patch-5

Conversation

@Sigma1912
Copy link
Copy Markdown
Contributor

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

Fix overflow error when clicking on the zoomed out preview or rapidly clicking on individual lines.
@andypugh
Copy link
Copy Markdown
Collaborator

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
Copy link
Copy Markdown
Contributor Author

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
Copy link
Copy Markdown
Member

hansu commented Dec 30, 2023

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
Copy link
Copy Markdown
Contributor Author

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 andypugh merged commit 15bf151 into LinuxCNC:2.9 Jan 7, 2024
@andypugh
Copy link
Copy Markdown
Collaborator

andypugh commented Jan 7, 2024

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

@Sigma1912 Sigma1912 deleted the patch-5 branch March 4, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants