diff --git a/src/app/qgspythondialog.cpp b/src/app/qgspythondialog.cpp index 8e4f9a76fda..e2a2be8ba0b 100644 --- a/src/app/qgspythondialog.cpp +++ b/src/app/qgspythondialog.cpp @@ -17,6 +17,8 @@ #include "qgspythondialog.h" #include "qgspythonutils.h" +#include + QgsPythonDialog::QgsPythonDialog(QgisInterface* pIface, QWidget *parent) : QDialog(parent) { @@ -28,7 +30,6 @@ QgsPythonDialog::QgsPythonDialog(QgisInterface* pIface, QWidget *parent) QgsPythonDialog::~QgsPythonDialog() { - QgsPythonUtils::uninstallConsoleHooks(); } QString QgsPythonDialog::escapeHtml(QString text) @@ -72,3 +73,10 @@ void QgsPythonDialog::on_edtCmdLine_returnPressed() txtHistory->moveCursor(QTextCursor::End); txtHistory->ensureCursorVisible(); } + +void QgsPythonDialog::closeEvent(QCloseEvent* event) +{ + QgsPythonUtils::uninstallConsoleHooks(); + + QDialog::closeEvent(event); +} diff --git a/src/app/qgspythondialog.h b/src/app/qgspythondialog.h index 546d28a0e12..5dd12206f0f 100644 --- a/src/app/qgspythondialog.h +++ b/src/app/qgspythondialog.h @@ -20,6 +20,7 @@ #include "ui_qgspythondialog.h" class QgisInterface; +class QCloseEvent; class QgsPythonDialog : public QDialog, private Ui::QgsPythonDialog { @@ -36,6 +37,10 @@ class QgsPythonDialog : public QDialog, private Ui::QgsPythonDialog void on_edtCmdLine_returnPressed(); + protected: + + void closeEvent(QCloseEvent* event); + private: QgisInterface* mIface; diff --git a/src/app/qgspythonutils.cpp b/src/app/qgspythonutils.cpp index d1307819d34..f803f10c8ff 100644 --- a/src/app/qgspythonutils.cpp +++ b/src/app/qgspythonutils.cpp @@ -150,10 +150,6 @@ void QgsPythonUtils::uninstallConsoleHooks() { runString("sys.displayhook = sys.__displayhook__"); runString("sys.stdout = _old_stdout"); - - // TODO: uninstalling stdout redirection doesn't work - - //installErrorHook(); }