Gnimuc / CImGui.jl

Julia wrapper for cimgui
https://github.com/cimgui/cimgui
MIT License
253 stars 25 forks source link

Help / About Dear ImGui / Config/Build information throws an error #123

Closed scls19fr closed 2 months ago

scls19fr commented 2 months ago

Hello,

demo.jl example Help / About Dear ImGui / Config/Build information throws an error

julia> using CImGui

julia> include(joinpath(pathof(CImGui), "..", "..", "examples", "demo.jl"))
┌ Error: Error in renderloop!
│   exception = TypeError: non-boolean (Ptr{Int8}) used in boolean context
└ @ Main C:\Users\Admin\.julia\packages\CImGui\heNEs\examples\demo.jl:123

Stacktrace:
  [1] ShowAboutWindow(p_open::Base.RefValue{Bool})
    @ Main C:\Users\Admin\.julia\packages\CImGui\heNEs\examples\demo_helper.jl:66
  [2] ShowJuliaDemoWindow(p_open::Base.RefValue{Bool})
    @ Main C:\Users\Admin\.julia\packages\CImGui\heNEs\examples\demo_window.jl:78
  [3] top-level scope
    @ C:\Users\Admin\.julia\packages\CImGui\heNEs\examples\demo.jl:89
  [4] include(fname::String)
    @ Base.MainInclude .\client.jl:489
  [5] top-level scope
    @ REPL[2]:1
  [6] eval
    @ .\boot.jl:385 [inlined]
  [7] eval_user_input(ast::Any, backend::REPL.REPLBackend, mod::Module)
    @ REPL C:\Users\Admin\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:150
  [8] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
    @ REPL C:\Users\Admin\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:246
  [9] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
    @ REPL C:\Users\Admin\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:231
 [10] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
    @ REPL C:\Users\Admin\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:389
 [11] run_repl(repl::REPL.AbstractREPL, consumer::Any)
    @ REPL C:\Users\Admin\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:375
 [12] (::Base.var"#1013#1015"{Bool, Bool, Bool})(REPL::Module)
    @ Base .\client.jl:432
 [13] #invokelatest#2
    @ .\essentials.jl:892 [inlined]
 [14] invokelatest
    @ .\essentials.jl:889 [inlined]
 [15] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
    @ Base .\client.jl:416
 [16] exec_options(opts::Base.JLOptions)
    @ Base .\client.jl:333
 [17] _start()
    @ Base .\client.jl:552

It works correctly with

julia> include(joinpath(pathof(CImGui), "..", "..", "demo", "demo.jl"))

Tools / About Dear ImGui / Config/Build information

Thanks @Gnimuc @JamesWrigley and others for the great work on this lib.

Kind regards

JamesWrigley commented 2 months ago

Thanks for the report, I believe the issue is that on line 66 (and 67) we're trying to check the truthiness of a pointer: https://github.com/Gnimuc/CImGui.jl/blob/master/examples/demo_helper.jl#L66

What those ternaries should be checking is probably unsafe_load(io.BackendPlatformName) == C_NULL. I'm a bit busy with the update to 1.90.8 and the test engine wrapper so I probably won't be able to get to this for a week or so (but feel free to take a stab at it if you like :) ).