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

Binding font to a plot axis crashes the application #2337

Open
v-ein opened this issue May 28, 2024 · 0 comments
Open

Binding font to a plot axis crashes the application #2337

v-ein opened this issue May 28, 2024 · 0 comments
Labels
state: pending not addressed yet type: bug bug

Comments

@v-ein
Copy link
Contributor

v-ein commented May 28, 2024

Version of Dear PyGui

Version: 1.11.2
Operating System: Windows

My Issue/Question

When a font is bound to dpg.plot_axis, the application immediately segfaults.

This is caused by ImGui::PopFont() in DearPyGui::draw_plot_axis, which does not have a corresponding PushFont.

To Reproduce

Steps to reproduce the behavior:

  1. Create a plot.
  2. Use dpg.bind_item_font on one of the axes.

Expected behavior

No crash. Ideally, the font should be applied to this axis' label, but if that is not possible (due to the way ImPlot renders plot elements), at least ignore the font and don't segfault.

Screenshots/Video

None.

Standalone, minimal, complete and verifiable example

from math import sin
from pathlib import Path
import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport(title="Test", width=520, height=550)

with dpg.font_registry():
    regular_font = dpg.add_font(Path(__file__).parent / "resources/fonts/RobotoMono-SemiBold.ttf", 18)

with dpg.window(pos=(0, 0), width=500, height=500):
    dpg.add_button(label="Bind font to Y axis", callback=lambda: (dpg.set_item_label("y-axis", "New Y"), dpg.bind_item_font("y-axis", regular_font)))

    x_data = [x/10 for x in range(0, 200)]
    y_data = [sin(x) for x in x_data]

    with dpg.plot(label="x=f(y)", height=-1, width=-1):
        x_axis = dpg.add_plot_axis(dpg.mvXAxis, label="x")
        with dpg.plot_axis(dpg.mvYAxis, label="y", tag="y-axis") as y_axis:
            dpg.add_line_series(y_data, x_data)

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
@v-ein v-ein added state: pending not addressed yet type: bug bug labels May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: pending not addressed yet type: bug bug
Projects
None yet
Development

No branches or pull requests

1 participant