fix(tui): reset drag context when invalidating the widget tree
This prevents a segfault if dragging and navigating at the same time.
This commit is contained in:
parent
ce9c5ea23d
commit
3ea039f41c
2 changed files with 8 additions and 0 deletions
|
@ -166,6 +166,7 @@ const cmds = struct {
|
|||
}
|
||||
|
||||
pub fn navigate(self: *Self, ctx: Ctx) tp.result {
|
||||
tui.reset_drag_context();
|
||||
const frame = tracy.initZone(@src(), .{ .name = "navigate" });
|
||||
defer frame.deinit();
|
||||
var file: ?[]const u8 = null;
|
||||
|
@ -231,6 +232,7 @@ const cmds = struct {
|
|||
}
|
||||
|
||||
pub fn open_help(self: *Self, _: Ctx) tp.result {
|
||||
tui.reset_drag_context();
|
||||
try self.create_editor();
|
||||
try command.executeName("open_scratch_buffer", command.fmt(.{ "help.md", @embedFile("help.md") }));
|
||||
tui.need_render();
|
||||
|
@ -426,6 +428,7 @@ fn show_home_async(_: *Self) void {
|
|||
}
|
||||
|
||||
fn create_home(self: *Self) tp.result {
|
||||
tui.reset_drag_context();
|
||||
if (self.editor) |_| return;
|
||||
var home_widget = home.create(self.a, Widget.to(self)) catch |e| return tp.exit_error(e);
|
||||
errdefer home_widget.deinit(self.a);
|
||||
|
|
|
@ -664,6 +664,11 @@ pub fn get_mode() []const u8 {
|
|||
return if (current().input_mode) |m| m.name else "INI";
|
||||
}
|
||||
|
||||
pub fn reset_drag_context() void {
|
||||
const self = current();
|
||||
self.drag_source = null;
|
||||
}
|
||||
|
||||
pub fn need_render() void {
|
||||
const self = current();
|
||||
if (!(self.render_pending or self.frame_clock_running)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue