Gnimuc / CImGui.jl

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

An error occurs when I use ImGuiTextFilter in a package #85

Open FaresX opened 1 year ago

FaresX commented 1 year ago

I found that when I use ImGuiTextFilter in a package, there are some issues, but it works well when I run codes with "include". Is there any way to solve this problem? I wrote some sample codes and recorded the error message as follows. Codes inside the rendering loop:

let 
    filter::Ptr{ImGuiTextFilter} = ImGuiTextFilter_ImGuiTextFilter(C_NULL)
    content = ["ajfa;", "qoe;asdjk", "xnm,d", "178250kd", "g078gyu", "awefr23"]
    global function filterbug()
        CImGui.Begin("TestBugs")
        ImGuiTextFilter_Draw(filter, "Filter contents", 16CImGui.GetFontSize())
        for s in content
            ImGuiTextFilter_PassFilter(filter, pointer(s), C_NULL) || continue
            CImGui.Text(s)
        end
        CImGui.End()
    end
end

I wrote it in a package named TestBugs with rendering function UI. when I run it through:

include("src/TestBugs.jl")
TestBugs.UI()

it works well. But when I run it through:

using Pkg; Pkg.activate(".")
using TestBugs
UI()

it will produce an error

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x7ff983700a01 -- strlen at C:\WINDOWS\System32\msvcrt.dll (unknown line)
in expression starting at none:0
strlen at C:\WINDOWS\System32\msvcrt.dll (unknown line)
_ZN5ImGui11InputTextExEPKcS1_PciRK6ImVec2iPFiP26ImGuiInputTextCallbackDataEPv at C:\Users\22112\.julia\artifacts\332c8d1e20d65e18db01d6e29164ca87a9d83cb0\bin\libcimgui.dll (unknown line)
_ZN5ImGui9InputTextEPKcPcyiPFiP26ImGuiInputTextCallbackDataEPv at C:\Users\22112\.julia\artifacts\332c8d1e20d65e18db01d6e29164ca87a9d83cb0\bin\libcimgui.dll (unknown line)
_ZN15ImGuiTextFilter4DrawEPKcf at C:\Users\22112\.julia\artifacts\332c8d1e20d65e18db01d6e29164ca87a9d83cb0\bin\libcimgui.dll (unknown line)
ImGuiTextFilter_Draw at C:\Users\22112\.julia\packages\LibCImGui\DfBwq\lib\x86_64-w64-mingw32.jl:5027 [inlined]
filterbug at C:\Users\22112\OneDrive - mails.ucas.ac.cn\鏂囨。\CODE\Julia\MyPackages\TestBugs\src\TestBugs.jl:99
macro expansion at C:\Users\22112\OneDrive - mails.ucas.ac.cn\鏂囨。\CODE\Julia\MyPackages\TestBugs\src\TestBugs.jl:57 [inlined]
#1 at .\task.jl:514
unknown function (ip: 0000028cfd649673)
jl_apply at C:/workdir/src\julia.h:1879 [inlined]
start_task at C:/workdir/src\task.c:1092
Allocations: 1947758 (Pool: 1945834; Big: 1924); GC: 3