Mercurial > jwe > octave
changeset 29138:0d8e5f890a9b
where possible, allow Qt widgets to delete their children
* main-window.cc (main_window::main_window): Make m_status_bar a child
of main_window.
(main_window::~main_window): Don't delete objects that are children of
main_window Widget.
* tab-bar.cc (tab_bar::~tab_bar): Don't delete m_context_menu, it is a
child of the tab_bar widget.
* terminal-dock-widget.cc
(terminal_dock_widget::terminal_dock_widget): Make m_terminal a child
of terminal_dock_widget instead of a child of the parent of
terminal_dock_widget.
(terminal_dock_widget::~terminal_dock_widget): Don't delete
m_terminal, it is now a child of terminal_dock_widget.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 02 Dec 2020 14:59:26 -0500 |
parents | 118b38c17805 |
children | 5f90526a9c40 |
files | libgui/src/main-window.cc libgui/src/tab-bar.cc libgui/src/terminal-dock-widget.cc |
diffstat | 3 files changed, 14 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Wed Dec 02 14:22:15 2020 -0500 +++ b/libgui/src/main-window.cc Wed Dec 02 14:59:26 2020 -0500 @@ -170,7 +170,7 @@ construct_central_widget (); - m_status_bar = new QStatusBar (); + m_status_bar = new QStatusBar (this); m_profiler_status_indicator = new led_indicator (); QLabel *text = new QLabel (tr ("Profiler")); m_status_bar->addPermanentWidget (text); @@ -254,20 +254,6 @@ main_window::~main_window (void) { - // Destroy the terminal first so that STDERR stream is redirected back - // to its original pipe to capture error messages at exit. - - delete m_editor_window; // first one for dialogs of modified editor-tabs - delete m_external_editor; - delete m_command_window; - delete m_workspace_window; - delete m_doc_browser_window; - delete m_file_browser_window; - delete m_history_window; - delete m_status_bar; - delete m_variable_editor_window; - - delete m_find_files_dlg; delete m_release_notes_window; delete m_community_news_window; } @@ -707,7 +693,11 @@ news = (tr ("The release notes file '%1' cannot be read.") . arg (QString::fromStdString (news_file))); - m_release_notes_window = new QWidget; + // We want the window manager to give the release notes window + // a title bar, so don't its parent to main_window. Do remember + // to delete in the main_window destructor. + + m_release_notes_window = new QWidget (); QTextBrowser *browser = new QTextBrowser (m_release_notes_window); browser->setText (news); @@ -785,7 +775,11 @@ { if (! m_community_news_window) { - m_community_news_window = new QWidget; + // We want the window manager to give the community news window + // a title bar, so don't its parent to main_window. Do remember + // to delete in the main_window destructor. + + m_community_news_window = new QWidget (); QTextBrowser *browser = new QTextBrowser (m_community_news_window);
--- a/libgui/src/tab-bar.cc Wed Dec 02 14:22:15 2020 -0500 +++ b/libgui/src/tab-bar.cc Wed Dec 02 14:59:26 2020 -0500 @@ -38,10 +38,7 @@ : QTabBar (p), m_context_menu (new QMenu (this)) { } - tab_bar::~tab_bar (void) - { - delete m_context_menu; - } + tab_bar::~tab_bar (void) { } // slots for tab navigation void tab_bar::switch_left_tab (void)
--- a/libgui/src/terminal-dock-widget.cc Wed Dec 02 14:22:15 2020 -0500 +++ b/libgui/src/terminal-dock-widget.cc Wed Dec 02 14:59:26 2020 -0500 @@ -44,7 +44,7 @@ terminal_dock_widget::terminal_dock_widget (QWidget *p, base_qobject& oct_qobj) : octave_dock_widget ("TerminalDockWidget", p, oct_qobj), - m_terminal (QTerminal::create (oct_qobj, p)) + m_terminal (QTerminal::create (oct_qobj, this)) { m_terminal->setObjectName ("OctaveTerminal"); m_terminal->setFocusPolicy (Qt::StrongFocus); @@ -91,10 +91,7 @@ setGeometry (0, 0, win_x, win_y); } - terminal_dock_widget::~terminal_dock_widget (void) - { - delete m_terminal; - } + terminal_dock_widget::~terminal_dock_widget (void) { } bool terminal_dock_widget::has_focus (void) const {