Skip to content

Commit

Permalink
ErrorDialog: Clear messages on close instead of hide
Browse files Browse the repository at this point in the history
Fixes an issue where the error dialog is cleared because the hide event gets triggered.
  • Loading branch information
jonaski committed Aug 7, 2023
1 parent d1b4736 commit bfb95d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/dialogs/errordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
#include <QStyle>
#include <QLabel>
#include <QTextEdit>
#include <QCloseEvent>

#include "errordialog.h"
#include "ui_errordialog.h"

class QHideEvent;

ErrorDialog::ErrorDialog(QWidget *parent)
: QDialog(parent),
ui_(new Ui_ErrorDialog) {
Expand Down Expand Up @@ -68,9 +67,13 @@ void ErrorDialog::ShowMessage(const QString &message) {

}

void ErrorDialog::hideEvent(QHideEvent *) {
void ErrorDialog::closeEvent(QCloseEvent *e) {

current_messages_.clear();
UpdateContent();

QDialog::closeEvent(e);

}

void ErrorDialog::UpdateContent() {
Expand Down
4 changes: 2 additions & 2 deletions src/dialogs/errordialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <QString>
#include <QStringList>

class QHideEvent;
class QCloseEvent;
class Ui_ErrorDialog;

class ErrorDialog : public QDialog {
Expand All @@ -43,7 +43,7 @@ class ErrorDialog : public QDialog {
void ShowMessage(const QString &message);

protected:
void hideEvent(QHideEvent*) override;
void closeEvent(QCloseEvent *e) override;

private:
void UpdateContent();
Expand Down
4 changes: 2 additions & 2 deletions src/dialogs/errordialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<sender>buttonbox</sender>
<signal>accepted()</signal>
<receiver>ErrorDialog</receiver>
<slot>accept()</slot>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>299</x>
Expand All @@ -91,7 +91,7 @@
<sender>buttonbox</sender>
<signal>rejected()</signal>
<receiver>ErrorDialog</receiver>
<slot>reject()</slot>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>299</x>
Expand Down

0 comments on commit bfb95d5

Please sign in to comment.