foxnne / pixi

Pixel art editor made with Zig.
https://foxnne.github.io/pixi/
MIT License
645 stars 20 forks source link

can accidentally end up with a file without .pixi extension, sometimes causing a crash #51

Open slimsag opened 2 months ago

slimsag commented 2 months ago

In the new file dialog:

image

if I click to select the text:

image

Then type my filename oops the warning abotu missing .pixi extension is not shown:

image

and I can hit save and end up with a file without .pixi extension. The warning seems to only appear if pressing backspace on each individual character, or if you type . and the extension is not .pixi


If I type oops. then the warning appears:

image

Clicking Ok is not possible, but if I then delete the . so I have just oops and press enter on my keyboard:

thread 246516 panic: index out of bounds: index 5, len 0
/Volumes/data/foxnne/upstream/pixi/src/editor/popups/file_setup.zig:140:45: 0x105b9237b in draw (pixi)
            if (std.mem.eql(u8, ".pixi", ext[0..5])) {
                                            ^
/Volumes/data/foxnne/upstream/pixi/src/editor/editor.zig:34:26: 0x105b0a56f in draw (pixi)
    popup_file_setup.draw();
                         ^
/Volumes/data/foxnne/upstream/pixi/src/pixi.zig:315:16: 0x105b0861b in update (pixi)
    editor.draw();
               ^
/Users/slimsag/.cache/zig/p/1220ba5472217ef81455b19d540967049bbfaf768b30d04534865707e907ee1c4aec/src/core/platform/glfw/Core.zig:582:23: 0x105a2070f in appUpdateThread__anon_89232 (pixi)
        if (app.update() catch unreachable) {
                      ^
/Users/slimsag/zig/0.12.0-dev.3180+83e578a18/files/lib/std/Thread.zig:406:13: 0x105929a0f in callFn__anon_86419 (pixi)
            @call(.auto, f, args);
            ^
/Users/slimsag/zig/0.12.0-dev.3180+83e578a18/files/lib/std/Thread.zig:674:30: 0x1058a15c3 in entryFn (pixi)
                return callFn(f, args_ptr.*);
                             ^
???:?:?: 0x187b8d033 in ??? (libsystem_pthread.dylib)
???:?:?: 0x534e000187b87e3b in ??? (???)
run
└─ run pixi failure
error: the following command terminated unexpectedly:
/Volumes/data/foxnne/upstream/pixi/zig-out/bin/pixi

The above crash is what I ran into in normal usage, because I was quickly creating a new file and forgot to add the .pixi extension, and got the crash above.