Here's the patch.

Regards,

--
Raphaël Halimi
Description: Fix infinite loop when switching battery charge modes
 When toggling from "Preserve Battery Health" to "Maximize Charge" on
 systems with multiple batteries, the UI hangs. This patch fixes that.
Author: Markus Rothe
Reviewed-by: Felipe Borges
Origin: https://gitlab.gnome.org/GNOME/gnome-control-center/-/commit/c3d0aefcabfd58120d33150390547329b6334b70
Bug: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/3422
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1129242
Last-Update: 2025-12-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -345,6 +345,12 @@
 
   if (charge_threshold_supported)
     {
+      /* Block the signal handler to prevent infinite feedback loop when
+       * updating UI state on systems with multiple batteries */
+      g_signal_handlers_block_by_func (self->preserve_battery_radio,
+                                       battery_health_radio_changed_cb,
+                                       self);
+
       if (charge_threshold_enabled)
         {
           gtk_check_button_set_active (self->preserve_battery_radio, TRUE);
@@ -353,6 +359,11 @@
         {
           gtk_check_button_set_active (self->maximize_charge_radio, TRUE);
         }
+
+      g_signal_handlers_unblock_by_func (self->preserve_battery_radio,
+                                         battery_health_radio_changed_cb,
+                                         self);
+
       gtk_widget_set_visible (GTK_WIDGET (self->battery_charging_section), TRUE);
     }
 

Reply via email to