diff libgui/src/main-window.cc @ 29000:8a05763823d1 stable

avoid possible infinite loop when default encoding is changed (bug #59331) * main-window.h, main-window.cc (main_window::notice_settings): New argument, UPDATE_BY_WORKER. If true, don't call update_default_encoding. (main_window::construct): Update settings_changed/notice_settings signal/slot connection. * qt-interpreter-events.h, qt-interpreter-events.cc (qt_interpreter_events::settings_changed): Update signature of signal to include bool parameter. (qt_interpreter_events::gui_preference_slot): Emit settings_changed with bool parameter set to TRUE.
author Torsten Lilge <ttl-octave@mailbox.org>
date Tue, 27 Oct 2020 22:28:44 +0100
parents 63167a1f1fb5
children 77494c7a9fbc 5f535fe782b3
line wrap: on
line diff
--- a/libgui/src/main-window.cc	Wed Oct 28 15:23:30 2020 +0900
+++ b/libgui/src/main-window.cc	Tue Oct 27 22:28:44 2020 +0100
@@ -838,7 +838,8 @@
                         QString::fromStdString (message));
   }
 
-  void main_window::notice_settings (const gui_settings *settings)
+  void main_window::notice_settings (const gui_settings *settings,
+                                     bool update_by_worker)
   {
     if (! settings)
       return;
@@ -927,7 +928,9 @@
     // Check whether some octave internal preferences have to be updated
     QString new_default_encoding
       = settings->value (ed_default_enc).toString ();
-    if (new_default_encoding != m_default_encoding)
+    // Do not update internal pref only if a) this update was not initiated
+    // by the worker and b) the pref has really changes
+    if (! update_by_worker && (new_default_encoding != m_default_encoding))
       update_default_encoding (new_default_encoding);
 
     // Set cursor blinking depending on the settings
@@ -2169,8 +2172,8 @@
 
     qt_interpreter_events *qt_link = interp_qobj->qt_link ();
 
-    connect (qt_link, SIGNAL (settings_changed (const gui_settings *)),
-             this, SLOT (notice_settings (const gui_settings *)));
+    connect (qt_link, SIGNAL (settings_changed (const gui_settings *, bool)),
+             this, SLOT (notice_settings (const gui_settings *, bool)));
 
     connect (qt_link, SIGNAL (apply_new_settings (void)),
              this, SLOT (request_reload_settings (void)));