From 4bff62e6ac8ad287f5c3ec6e93974c550e54cb0a Mon Sep 17 00:00:00 2001 From: mbkma Date: Fri, 15 Aug 2025 12:35:22 +0200 Subject: Defer reformat_separators() Using g_idle_add_once() Wrap the function to run after the current GTK event loop iteration, when it's safe to mutate the buffer. --- src/math-equation.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/math-equation.c') diff --git a/src/math-equation.c b/src/math-equation.c index c7a4ef5..aa145f5 100644 --- a/src/math-equation.c +++ b/src/math-equation.c @@ -299,7 +299,7 @@ reformat_display(MathEquation *equation) reformat_ans(equation); /* Add/remove thousands separators */ - reformat_separators(equation); + g_idle_add_once(reformat_separators, equation); g_signal_emit_by_name(equation, "display-changed"); } @@ -1901,8 +1901,8 @@ insert_text_cb(MathEquation *equation, equation->priv->state.entered_multiply = strcmp(text, "×") == 0; /* Update thousands separators */ - reformat_separators(equation); - + g_idle_add_once(reformat_separators, equation); + g_object_notify(G_OBJECT(equation), "display"); } @@ -1918,7 +1918,7 @@ delete_range_cb(MathEquation *equation, equation->priv->state.entered_multiply = FALSE; /* Update thousands separators */ - reformat_separators(equation); + g_idle_add_once(reformat_separators, equation); // FIXME: A replace will emit this both for delete-range and insert-text, can it be avoided? g_object_notify(G_OBJECT(equation), "display"); -- cgit v1.2.1