this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

vxfw(TextField): fix freeing of previous_val

+7 -9
+7 -9
src/vxfw/TextField.zig
··· 124 124 } 125 125 126 126 fn checkChanged(self: *TextField, ctx: *vxfw.EventContext) anyerror!void { 127 + ctx.consumeAndRedraw(); 128 + const onChange = self.onChange orelse return; 127 129 const new = try self.buf.dupe(); 128 - if (std.mem.eql(u8, new, self.previous_val)) { 129 - self.buf.allocator.free(new); 130 - return ctx.consumeAndRedraw(); 131 - } 132 - self.buf.allocator.free(self.previous_val); 133 - self.previous_val = new; 134 - if (self.onChange) |onChange| { 135 - try onChange(self.userdata, ctx, new); 130 + defer { 131 + self.buf.allocator.free(self.previous_val); 132 + self.previous_val = new; 136 133 } 137 - ctx.consumeAndRedraw(); 134 + if (std.mem.eql(u8, new, self.previous_val)) return; 135 + try onChange(self.userdata, ctx, new); 138 136 } 139 137 140 138 /// insert text at the cursor position