summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-03-23 22:51:35 -0400
committerpommicket <pommicket@gmail.com>2025-03-23 22:51:35 -0400
commitb6011b08209f1b41c2fc2fe8b1a1c43fe5c08486 (patch)
tree8b19e3eb3dffd962b49e16b956075679cd4ea70a
parent309822238b9fb17e68b002c26157077de29ddb23 (diff)
Fix crash when closing node due to invalid settings pointer
-rw-r--r--node.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/node.c b/node.c
index 4ea724a..12ff261 100644
--- a/node.c
+++ b/node.c
@@ -297,11 +297,10 @@ bool node_pixels_to_buffer_pos(Node *node, vec2 wpos, TextBuffer **pbuffer, Buff
}
void node_frame(Ted *ted, Node *node, Rect r) {
- const Settings *settings = ted_active_settings(ted);
if (node->tabs) {
bool is_active = node == ted->active_node;
Font *font = ted->font;
- const float border_thickness = settings->border_thickness;
+ const float border_thickness = ted_active_settings(ted)->border_thickness;
const float char_height = text_font_char_height(font);
float tab_bar_height = char_height + 2 * border_thickness;
@@ -402,6 +401,9 @@ void node_frame(Ted *ted, Node *node, Rect r) {
vec2_sub(ted_mouse_pos(ted), ted->dragging_tab_origin));
}
+ // IMPORTANT: don't just move this to the top of the function.
+ // - settings may be invalidated if we close a buffer.
+ const Settings *settings = ted_active_settings(ted);
// tab border
gl_geometry_rect_border(tab_rect, border_thickness, settings_color(settings, COLOR_BORDER));
rect_shrink(&tab_rect, border_thickness);
@@ -462,6 +464,7 @@ void node_frame(Ted *ted, Node *node, Rect r) {
buffer_rect.size.y -= tab_bar_height;
buffer_render(buffer, buffer_rect);
} else {
+ const Settings *settings = ted_active_settings(ted);
float padding = settings->padding;
// this node is a split
Node *a = node->split_a, *b = node->split_b;