Skip to content

Commit

Permalink
settings: Fix saving a new theme getting incorrect name
Browse files Browse the repository at this point in the history
  • Loading branch information
foxnne committed Jan 29, 2025
1 parent a6ed98c commit 6d99d3c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/editor/Settings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ pub fn save(settings: *Settings, allocator: std.mem.Allocator) !void {
}

pub fn deinit(settings: *Settings, allocator: std.mem.Allocator) void {
if (parsed) |p| {
p.deinit();
parsed = null;
} else allocator.free(settings.theme);
defer parsed = null;
if (parsed) |p| p.deinit() else allocator.free(settings.theme);
}
6 changes: 2 additions & 4 deletions src/editor/Theme.zig
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,8 @@ pub fn pop(theme: *Theme) void {
}

pub fn deinit(theme: *Theme, allocator: std.mem.Allocator) void {
if (parsed) |p| {
p.deinit();
parsed = null;
} else allocator.free(theme.name);
defer parsed = null;
if (parsed) |p| p.deinit() else allocator.free(theme.name);
}

pub const StyleColorButton = struct {
Expand Down
3 changes: 3 additions & 0 deletions src/editor/explorer/settings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ pub fn draw(core: *Core, editor: *Editor) !void {

if (editor.popups.file_dialog_response) |response| {
if (response.type == .export_theme) {
editor.theme.deinit(pixi.app.allocator);
editor.theme.name = try pixi.app.allocator.dupeZ(u8, std.fs.path.basename(response.path));

try editor.theme.save(response.path);

editor.theme.deinit(pixi.app.allocator);
Expand Down

0 comments on commit 6d99d3c

Please sign in to comment.