From: Nathaniel Russell Date: Sun, 31 Jul 2022 17:57:09 +0000 Subject: [PATCH] Fix function name crash f(x) if inputting new function name Fix function name crash f(x) if inputting new function name gnome-calculato[26680]: segfault at 7ffcf7b04ee8 ip 00007f132e071b4b sp 00007ffcf7b04ee0 error 6 in libc-2.35.so[7f132e028000+186000] [ 580.230200] Code: ff ff 48 8d 3d 9e cc 15 00 e8 21 39 01 00 90 41 57 41 56 41 55 41 54 55 48 89 fd 53 48 81 ec 18 05 00 00 48 8b 05 c5 92 19 00 <48> 89 74 24 08 48 89 54 24 20 89 4c 24 7c 64 8b 00 89 84 24 90 diff -urN gnome-calculator-42.2/src/math-function-popover.vala gnome-calculator-42.2.new/src/math-function-popover.vala --- gnome-calculator-42.2/src/math-function-popover.vala 2022-07-01 15:15:12.000000000 -0500 +++ gnome-calculator-42.2.new/src/math-function-popover.vala 2022-07-31 17:57:09.047423677 -0500 @@ -24,6 +24,8 @@ [GtkChild] private unowned Gtk.Entry function_name_entry; private bool function_name_entry_placeholder_reseted = false; + private ulong changed_handler; + [GtkChild] private unowned Gtk.Button add_function_button; @@ -35,6 +37,7 @@ base (equation, model, (a,b) => MathFunction.name_compare_func (a as MathFunction,b as MathFunction)); function_list.bind_model (model, (item) => make_item_row(item as MathFunction)); + changed_handler = function_name_entry.changed.connect (function_name_entry_changed_cb); add_arguments_button.set_range (1, 10); add_arguments_button.set_increments (1, 1); @@ -85,12 +88,13 @@ } */ - [GtkCallback] private void function_name_entry_changed_cb (Gtk.Editable editable) { this.function_name_entry_placeholder_reseted = true; var entry = editable as Gtk.Entry; + SignalHandler.block (entry, changed_handler); entry.text = entry.text.replace (" ", "_"); + SignalHandler.unblock (entry, changed_handler); add_function_button.sensitive = entry.text != ""; } diff -urN gnome-calculator-42.2/src/ui/math-function-popover.ui gnome-calculator-42.2.new/src/ui/math-function-popover.ui --- gnome-calculator-42.2/src/ui/math-function-popover.ui 2022-07-01 15:15:12.000000000 -0500 +++ gnome-calculator-42.2.new/src/ui/math-function-popover.ui 2022-07-31 17:55:03.768989873 -0500 @@ -26,7 +26,6 @@ New function -