changeset 16448:47fe533ec85b

avoid using new for status bar and workspace_model objects * main-window.h, main-window.cc (main_window::status_bar): Rename from _status_bar. Don't use use a pointer. Change all uses. (main_window::main_window): Initialize it. (main_window::~main_window): Don't delete _status_bar. (main_window::_workspace_model): Don't use use a pointer. Change all uses. (main_window::main_window): Initialize it. (main_window::~main_window): Don't delete _workspace_model.
author John W. Eaton <jwe@octave.org>
date Sat, 06 Apr 2013 17:31:19 -0400
parents e3b33a7530bc
children c129a8b73d25
files libgui/src/main-window.cc libgui/src/main-window.h
diffstat 2 files changed, 13 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/main-window.cc	Sat Apr 06 16:46:14 2013 -0400
+++ b/libgui/src/main-window.cc	Sat Apr 06 17:31:19 2013 -0400
@@ -56,7 +56,8 @@
 #include "oct-env.h"
 
 main_window::main_window (QWidget *p)
-  : QMainWindow (p), command_window (this), history_window (this)
+  : QMainWindow (p), _workspace_model (), status_bar (),
+    command_window (this), history_window (this)
 {
   // We have to set up all our windows, before we finally launch octave.
   construct ();
@@ -79,16 +80,12 @@
     delete _file_editor;
 #endif
 
-  if (_status_bar)
-    delete _status_bar;
-
   if (_documentation_dock_widget)
     delete _documentation_dock_widget;
 
   if (_files_dock_widget)
     delete _files_dock_widget;
 
-  delete _workspace_model;
   delete _workspace_view;
 }
 
@@ -119,7 +116,7 @@
 void
 main_window::report_status_message (const QString& statusMessage)
 {
-  _status_bar->showMessage (statusMessage, 1000);
+  status_bar.showMessage (statusMessage, 1000);
 }
 
 void
@@ -622,23 +619,19 @@
   _closing = false;   // flag for editor files when closed
   setWindowIcon (QIcon(":/actions/icons/logo.png"));
 
-  // Create a new workspace model.
-  _workspace_model = new workspace_model ();
-
   // Setup dockable widgets and the status bar.
   _workspace_view           = new workspace_view (this);
 
-  _workspace_view->setModel (_workspace_model);
+  _workspace_view->setModel (&_workspace_model);
   _workspace_view->setStatusTip (tr ("View the variables in the active workspace."));
 
-  connect (_workspace_model, SIGNAL (model_changed ()),
+  connect (&_workspace_model, SIGNAL (model_changed ()),
            _workspace_view, SLOT (model_changed ()));
 
   _files_dock_widget        = new files_dock_widget (this);
   _files_dock_widget->setStatusTip (tr ("Browse your files."));
   _documentation_dock_widget= new documentation_dock_widget (this);
   _documentation_dock_widget->setStatusTip (tr ("See the documentation for help."));
-  _status_bar               = new QStatusBar (this);
 
   _current_directory_line_edit = new QLineEdit (this);
   _current_directory_combo_box = new QComboBox (this);
@@ -1105,7 +1098,7 @@
     win_y = 720;
   setGeometry (0,0,win_x,win_y);
 
-  setStatusBar (_status_bar);
+  setStatusBar (&status_bar);
 
   _octave_qt_event_listener = new octave_qt_event_listener ();
 
--- a/libgui/src/main-window.h	Sat Apr 06 16:46:14 2013 -0400
+++ b/libgui/src/main-window.h	Sat Apr 06 17:31:19 2013 -0400
@@ -155,8 +155,14 @@
 
   void exit_callback (void);
 
+  // Data models.
+  workspace_model _workspace_model;
+
+  // Toolbars.
+  QStatusBar status_bar;
+
+  // Subwindows.
   terminal_dock_widget command_window;
-
   history_dock_widget history_window;
 
 #ifdef HAVE_QSCINTILLA
@@ -170,16 +176,12 @@
   QAction *                 _debug_step_out;
   QAction *                 _debug_quit;
 
-  // Data models.
-  workspace_model *         _workspace_model;
-
   // Dock widgets.
   workspace_view *          _workspace_view;
   files_dock_widget *       _files_dock_widget;
   documentation_dock_widget*_documentation_dock_widget;
 
   // Toolbars.
-  QStatusBar *              _status_bar;
   QComboBox *               _current_directory_combo_box;
   static const int        current_directory_width       = 300;
   static const int        current_directory_max_visible = 16;