changeset 31617:1f57ea5dfd4a

don't allow settings file name to be changed * resource-manager.h, resource-manager.cc (resource_manger::check_settings): Rename from set_settings and declare as private funtion. Eliminate file name argument. Change all uses. (resource_manger::resource_manger): Also check settings here.
author John W. Eaton <jwe@octave.org>
date Fri, 02 Dec 2022 10:36:13 -0500
parents 726d2628752c
children cd833a9baaa7
files libgui/src/resource-manager.cc libgui/src/resource-manager.h
diffstat 2 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/resource-manager.cc	Fri Dec 02 10:10:19 2022 -0500
+++ b/libgui/src/resource-manager.cc	Fri Dec 02 10:36:13 2022 -0500
@@ -72,6 +72,8 @@
 
     m_settings = new gui_settings ();
 
+    check_settings ();
+
     m_settings_file = m_settings->fileName ();
 
     QFileInfo sfile (m_settings_file);
@@ -313,7 +315,7 @@
           custom_editor = QString::fromStdString (env_default_editor);
       }
 
-    set_settings (m_settings_file);
+    check_settings ();
 
     // Write some settings that were dynamically determined at first startup
     if (m_settings)
@@ -434,11 +436,8 @@
   }
 #endif
 
-  void resource_manager::set_settings (const QString& file)
+  void resource_manager::check_settings (void)
   {
-    delete m_settings;
-    m_settings = new gui_settings (file, QSettings::IniFormat);
-
     if (m_settings->status () == QSettings::NoError)
       {
         // Test usability (force file to be really created)
--- a/libgui/src/resource-manager.h	Fri Dec 02 10:10:19 2022 -0500
+++ b/libgui/src/resource-manager.h	Fri Dec 02 10:36:13 2022 -0500
@@ -87,8 +87,6 @@
                               int mode = 0, int def = 0);
 #endif
 
-    void set_settings (const QString& file);
-
     bool update_settings_key (const QString& new_key, const QString& old_key);
 
     bool is_first_run (void) const;
@@ -104,6 +102,8 @@
 
   private:
 
+    void check_settings (void);
+
     /*!
      * Copys the attributes bold, italic and underline from QFont
      * @p attr to the font @p base and returns the result without