Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imviz.autogui with None in list leads to runtime error #18

Closed
mertemba opened this issue May 18, 2024 · 3 comments
Closed

imviz.autogui with None in list leads to runtime error #18

mertemba opened this issue May 18, 2024 · 3 comments

Comments

@mertemba
Copy link
Contributor

The following code leads to a runtime error:

viz.autogui([None])

The error output is:

[...]
    viz.autogui([None])
  File ".../site-packages/imviz/autogui.py", line 15, in autogui_func
    return AutoguiContext(params=params).render(obj, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/imviz/autogui.py", line 241, in render
    res = self.render(obj[i], str(i))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/imviz/autogui.py", line 96, in render
    self.call_post_header_hooks(obj, name)
  File ".../site-packages/imviz/autogui.py", line 72, in call_post_header_hooks
    h(obj, name, self)
  File ".../site-packages/imviz/autogui.py", line 22, in list_item_context
    if viz.begin_popup_context_item():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: id != 0
@mertemba
Copy link
Contributor Author

Apparently this is due to this binding:

    m.def("begin_popup_context_item", [&](std::string label) {

        return ImGui::BeginPopupContextItem(
                label.empty() ? 0 : label.c_str());
    },
    py::arg("label") = "");

And calling ImGui::BeginPopupContextItem(0) leads to the error.

Changing the line in autogui.py to if viz.begin_popup_context_item("foo"): prevents the error.

@joruof
Copy link
Owner

joruof commented May 24, 2024

Thanks for reporting that! Yeah, definitely buggy behavior.

It is not possible to get a context menu if we don't render an item before.
Since for None no item is rendered this error is triggered.
The implementation of begin_popup_context_item behaves correctly.

I've added a check in the respective autogui function. The fix will be included in 0.2.5.

@joruof joruof closed this as completed May 24, 2024
@mertemba
Copy link
Contributor Author

Awesome, thank you for the timely fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants