Mercurial > hg > octave-lojdl
changeset 16484:fa842e78f491
Restore STDERR stream pipe before exit to capture error messages.
* QUnixTerminalImpl.cpp, QUnixTerminalImpl.h
(QUnixTerminalImpl::fdstderr): New member variable.
(QUnixTerminalImpl::connectToPty): Duplicate STDERR_FILENO file
descriptor.
(QUnixTerminalImpl::~QUnixTerminalImpl): Duplicate-2 the stored
descriptor back to STDERR_FILENO.
* main-window.cc (main_window::~main_window): Delete terminal window
first.
author | Daniel J Sebald <daniel.sebald@ieee.org> |
---|---|
date | Tue, 09 Apr 2013 23:08:21 -0400 |
parents | fcf1b0b52083 |
children | 8b783661e03f |
files | libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h libgui/src/main-window.cc |
diffstat | 3 files changed, 17 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp +++ b/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp @@ -75,6 +75,10 @@ void QUnixTerminalImpl::connectToPty() { + // Store the file descriptor associated with the STDERR stream onto + // another temporary file descriptor for reconnect in the destructor. + fdstderr = dup (STDERR_FILENO); + int fds = m_kpty->slaveFd(); dup2 (fds, STDIN_FILENO); @@ -96,6 +100,9 @@ QUnixTerminalImpl::~QUnixTerminalImpl() { + // Restore stderr so that any errors at exit might appear somewhere. + dup2 (fdstderr, STDERR_FILENO); + emit destroyed(); }
--- a/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h +++ b/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h @@ -30,10 +30,13 @@ class QUnixTerminalImpl : public QTerminalInterface { Q_OBJECT + + int fdstderr; + public: QUnixTerminalImpl(QWidget *parent = 0); virtual ~QUnixTerminalImpl(); - + void setTerminalFont(const QFont &font); void setSize(int h, int v); void sendText(const QString& text); @@ -43,12 +46,12 @@ public slots: void copyClipboard(); void pasteClipboard(); - + protected: void focusInEvent(QFocusEvent *focusEvent); void showEvent(QShowEvent *); virtual void resizeEvent(QResizeEvent *); - + private: void initialize(); void connectToPty();
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -78,9 +78,12 @@ 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 command_window; delete _workspace_model; delete status_bar; - delete command_window; delete history_window; delete file_browser_window; delete doc_browser_window;