changeset 27649:91d43a00620d

eliminate static instance variable from octave_qobject class * octave-qobject.h, octave-qobject.cc (base_qobject::s_instance): Delete static variable and all uses. (base_qobject::the_octave_qobject): Delete static function. * resource-manager.h, resource-manager.cc (__get_octave_qobject__, __get_resource_manager__): Delete functions and all uses.
author John W. Eaton <jwe@octave.org>
date Wed, 06 Nov 2019 14:34:32 -0500
parents 2952471e29a7
children 2c8fc292ff2c
files libgui/src/octave-qobject.cc libgui/src/octave-qobject.h libgui/src/resource-manager.cc libgui/src/resource-manager.h
diffstat 4 files changed, 4 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/octave-qobject.cc	Wed Nov 06 14:29:42 2019 -0500
+++ b/libgui/src/octave-qobject.cc	Wed Nov 06 14:34:32 2019 -0500
@@ -152,8 +152,6 @@
   // we can handle forward Octave interpreter exceptions from the GUI
   // thread to the interpreter thread.
 
-  base_qobject *base_qobject::s_instance = nullptr;
-
   base_qobject::base_qobject (qt_application& app_context)
     : QObject (), m_app_context (app_context),
       m_argc (m_app_context.sys_argc ()),
@@ -166,12 +164,6 @@
       m_interpreter_qobj (new interpreter_qobject (*this)),
       m_main_thread (new QThread ())
   {
-    if (s_instance)
-      throw std::runtime_error
-        ("only one octave_qobject object may be active");
-
-    s_instance = this;
-
     std::string show_gui_msgs =
       sys::env::getenv ("OCTAVE_SHOW_GUI_MESSAGES");
 
--- a/libgui/src/octave-qobject.h	Wed Nov 06 14:29:42 2019 -0500
+++ b/libgui/src/octave-qobject.h	Wed Nov 06 14:34:32 2019 -0500
@@ -135,8 +135,6 @@
 
     void copy_image_to_clipboard (const QString& file, bool remove_file);
 
-    static base_qobject * the_octave_qobject (void) { return s_instance; }
-
   protected:
 
     qt_application& m_app_context;
@@ -164,8 +162,6 @@
     interpreter_qobject *m_interpreter_qobj;
 
     QThread *m_main_thread;
-
-    static base_qobject *s_instance;
   };
 
   //! This object provides a command-line interface to Octave that may
--- a/libgui/src/resource-manager.cc	Wed Nov 06 14:29:42 2019 -0500
+++ b/libgui/src/resource-manager.cc	Wed Nov 06 14:34:32 2019 -0500
@@ -53,26 +53,6 @@
 
 namespace octave
 {
-  base_qobject& __get_octave_qobject__ (const std::string& who)
-  {
-    base_qobject *oct_qobj = base_qobject::the_octave_qobject ();
-
-    if (! oct_qobj)
-      {
-        abort ();
-        error ("%s: octave_qobject context missing", who.c_str ());
-      }
-
-    return *oct_qobj;
-  }
-
-  resource_manager& __get_resource_manager__ (const std::string& who)
-  {
-    base_qobject& oct_qobj = __get_octave_qobject__ (who);
-
-    return oct_qobj.get_resource_manager ();
-  }
-
   static QString
   default_qt_settings_file (void)
   {
@@ -169,13 +149,13 @@
 
     QString language = "SYSTEM";  // take system language per default
 
-    resource_manager& rmgr = __get_resource_manager__ ("");
-    gui_settings *settings = rmgr.get_settings ();
+    // FIXME: can we somehow ensure that the settings object will always
+    // be initialize and valid?
 
-    if (settings)
+    if (m_settings)
       {
         // get the locale from the settings if already available
-        language = settings->value ("language", "SYSTEM").toString ();
+        language = m_settings->value ("language", "SYSTEM").toString ();
       }
 
     // load the translations depending on the settings
--- a/libgui/src/resource-manager.h	Wed Nov 06 14:29:42 2019 -0500
+++ b/libgui/src/resource-manager.h	Wed Nov 06 14:34:32 2019 -0500
@@ -33,10 +33,6 @@
 
 namespace octave
 {
-  class resource_manager;
-
-  extern resource_manager& __get_resource_manager__ (const std::string& who);
-
   class resource_manager : public QObject
   {
     Q_OBJECT