wookay/Poptart.jl

2nd example in readme.md throws DivideError

Opened this issue · 4 comments

hi.

the first example works like a charm. The 2nd one gives me an error despite appearing to be simpler.

reproduction

### make sure everything is setup properly

using Pkg
Pkg.add("Poptart")
Pkg.update("Poptart")
Pkg.status("Poptart")
Pkg.status("CImGui")


### copy past from readme

using Poptart.Desktop # Application Window InputText Button didClick

window1 = Window()
app = Application(windows = [window1])

input1 = InputText(label="Subject", buf="")
button1 = Button(title = "submit")
push!(window1.items, input1, button1)

didClick(button1) do event
    @info :didClick (event, input1.buf)
end

Desktop.exit_on_esc() = true
!isinteractive() && wait(app.closenotify)

output:

$ julia mve.jl 
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
  No Changes to `~/.julia/environments/v1.7/Project.toml`
  No Changes to `~/.julia/environments/v1.7/Manifest.toml`
    Updating registry at `~/.julia/registries/General.toml`
  No Changes to `~/.julia/environments/v1.7/Project.toml`
  No Changes to `~/.julia/environments/v1.7/Manifest.toml`
      Status `~/.julia/environments/v1.7/Project.toml`
  [197b51f5] Poptart v0.3.2
      Status `~/.julia/environments/v1.7/Project.toml`
  [5d785b6c] CImGui v1.79.0
┌ Error: Error in renderloop!
│   exception = DivideError: integer division error
└ @ Poptart.Desktop ~/.julia/packages/Poptart/RbjXy/src/Desktop/glfw.jl:42

Stacktrace:
 [1] div
   @ ./int.jl:284 [inlined]
 [2] divrem
   @ ./div.jl:162 [inlined]
 [3] divrem
   @ ./div.jl:158 [inlined]
 [4] rpad(s::String, n::Int64, p::Char)
   @ Base ./strings/util.jl:382
 [5] imgui_control_item(imctx::Ptr{CImGui.LibCImGui.ImGuiContext}, item::InputText)
   @ Poptart.Desktop ~/.julia/packages/Poptart/RbjXy/src/Desktop/imgui_controls.jl:29
 [6] setup_window(ctx::Ptr{CImGui.LibCImGui.ImGuiContext}, window::Window)
   @ Poptart.Desktop ~/.julia/packages/Poptart/RbjXy/src/Desktop/window.jl:67
 [7] setup_app(app::Application)
   @ Poptart.Desktop ~/.julia/packages/Poptart/RbjXy/src/Desktop/application.jl:67
 [8] runloop(glwin::GLFW.Window, ctx::Ptr{CImGui.LibCImGui.ImGuiContext}, glsl_version::Int64, push_window::typeof(Poptart.Desktop.setup_app), app::Application)
   @ Poptart.Desktop ~/.julia/packages/Poptart/RbjXy/src/Desktop/glfw.jl:28
 [9] (::Poptart.Desktop.var"#37#38"{Application, Int64, Ptr{CImGui.LibCImGui.ImGuiContext}, GLFW.Window})()
   @ Poptart.Desktop ./task.jl:423%                             

when I change remove the "null" from this line it seems to work

nullpad_buf = rpad(item.buf, item.buf_size, null)

Still happening to me in the latest version.
Status 'C:\Users\gerar\.julia\environments\v1.8\Project.toml' [197b51f5] Poptart v0.3.2

well, could you use the develop version of Poptart?

using Pkg
Pkg.develop("CImGui")
Pkg.develop("Poptart")

some problems here,
there needs to update for using CImGui_jll instead of CImGui
https://github.com/JuliaRegistries/General/blob/master/C/CImGui_jll/Versions.toml

so it should be a lot works that's based on CImGui_jll 1.82

thanks for report.

well, could you use the develop version of Poptart?

using Pkg
Pkg.develop("CImGui")
Pkg.develop("Poptart")

some problems here, there needs to update for using CImGui_jll instead of CImGui https://github.com/JuliaRegistries/General/blob/master/C/CImGui_jll/Versions.toml

so it should be a lot works that's based on CImGui_jll 1.82

thanks for report.

Seems the development version uses a different syntax
ERROR: LoadError: UndefVarError: ImGuiConfigFlags_ViewportsEnable not defined
Stacktrace:
[1] include(mod::Module, _path::String)
@ Base .\Base.jl:419
[2] include(x::String)
@ Poptart C:\Users\gerar.julia\dev\Poptart\src\Poptart.jl:1
[3] top-level scope
@ C:\Users\gerar.julia\dev\Poptart\src\Poptart.jl:4
in expression starting at C:\Users\gerar.julia\dev\Poptart\src\Desktop.jl:1
in expression starting at C:\Users\gerar.julia\dev\Poptart\src\Poptart.jl:1

ERROR: UndefVarError: Window not defined
Stacktrace:
[1] top-level scope