bonsai-rx / bonsai

The compiler, IDE, and standard library for the Bonsai visual programming language for reactive systems
https://bonsai-rx.org
MIT License
137 stars 29 forks source link

`ObjectTextVisualizer` attempts to Dequeue empty buffer #1875

Closed bruno-f-cruz closed 2 months ago

bruno-f-cruz commented 3 months ago

To reproduce:

Use the following workflow and layout file. Ensure the tabcontrol visualizer is active at startup. src.zip

After attaching the process to VS it seems the error is thrown by this line:

https://github.com/bonsai-rx/bonsai/blob/82448b97a414291b71007e0b564f031ad91b7e8e/Bonsai.Design/ObjectTextVisualizer.cs#L40-L41

I believe that due to the small size of the window, the following line returns 0: bufferSize = (int)((textBox.ClientSize.Height - 2) / lineHeight);

and the while condition evaluates to true.

The fix should be to change the while condition to also check if the size is not 0

PathogenDavid commented 3 months ago

Ah good catch, I foolishly relied on the fact that the visualizer window has a minimum height but didn't consider the case of it being in a table layout panel (which apparently has no minimum height.)

TableLayoutPanel and TabControl should probably honor the size constraints of their children, but this should be prevented as well.

PathogenDavid commented 3 months ago

Might not be an actual concern for TabControl, even when the window is flattened the actual visualizer control still has an appropriate height.

Here's a slightly more minimal repro: 1875-minimal.zip

The TabControl is fine being squished but the TableLayoutPanel is not.