Skip to content

Commit 4bff62e

Browse files
committed
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.
1 parent ff3858a commit 4bff62e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/math-equation.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ reformat_display(MathEquation *equation)
299299
reformat_ans(equation);
300300

301301
/* Add/remove thousands separators */
302-
reformat_separators(equation);
302+
g_idle_add_once(reformat_separators, equation);
303303

304304
g_signal_emit_by_name(equation, "display-changed");
305305
}
@@ -1901,8 +1901,8 @@ insert_text_cb(MathEquation *equation,
19011901
equation->priv->state.entered_multiply = strcmp(text, "×") == 0;
19021902

19031903
/* Update thousands separators */
1904-
reformat_separators(equation);
1905-
1904+
g_idle_add_once(reformat_separators, equation);
1905+
19061906
g_object_notify(G_OBJECT(equation), "display");
19071907
}
19081908

@@ -1918,7 +1918,7 @@ delete_range_cb(MathEquation *equation,
19181918
equation->priv->state.entered_multiply = FALSE;
19191919

19201920
/* Update thousands separators */
1921-
reformat_separators(equation);
1921+
g_idle_add_once(reformat_separators, equation);
19221922

19231923
// FIXME: A replace will emit this both for delete-range and insert-text, can it be avoided?
19241924
g_object_notify(G_OBJECT(equation), "display");

0 commit comments

Comments
 (0)