kotlin-graphics / imgui

Bloat-free Immediate Mode Graphical User interface for JVM with minimal dependencies (rewrite of dear imgui)
MIT License
604 stars 36 forks source link

MainMenuBar causes NullPointerException when clicking on free space #177

Open KrykiZZ opened 2 years ago

KrykiZZ commented 2 years ago

Workspace used:

After opening menu from MainMenuBar and clicking on empty space of the screen - menu disappears and rendering starts to spam following exception

java.lang.NullPointerException
    at imgui.internal.api.PopupsModalsTooltips$DefaultImpls.closePopupsOverWindow(PopupsModalsTooltips.kt:174)
    at imgui.ImGui.closePopupsOverWindow(imgui.kt:156)
    at imgui.api.main$DefaultImpls.newFrame(main.kt:219)
    at imgui.ImGui.newFrame(imgui.kt:156)
    at dev.kirakun.monke.clickgui.screens.ImguiScreen.render(ImguiScreen.kt:119)
    at net.minecraft.client.render.GameRenderer.render(GameRenderer.java:875)
    at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1117)
    at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:733)
    at net.minecraft.client.main.Main.main(Main.java:238)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:608)
    at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:77)
    at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
    at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)

Code:

implGl3?.newFrame();
implGlfw?.newFrame();
imgui.newFrame();

if (imgui.beginMainMenuBar())
{
    if (imgui.beginMenu("Debug"))
    {
        imgui.checkbox("Reload ICraftable", ActionExecutor.instance::craftable);
        imgui.checkbox("Reload ISmeltable", ActionExecutor.instance::smeltable);
        imgui.checkbox("Reload everything", ActionExecutor.instance::everything);
        imgui.checkbox("Reload everything (lazy)", ActionExecutor.instance::everythingLazy);
        imgui.endMenu()
    }
    imgui.endMainMenuBar()
}

imgui.render();
Objects.requireNonNull(imgui.drawData)?.let { implGl3?.renderDrawData(it) };

Recording: rec

KrykiZZ commented 2 years ago

Found additional information - before the exception in STDOUT writes [00029] OpenPopupEx(0x181EE2BD).