diff options
author | Thiago Macieira <thiago@macieira.org> | 2013-11-30 09:18:04 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-30 09:28:42 -0800 |
commit | b22f1da59e37ff4ba871fb2d6c72ee3ec87b4c5b (patch) | |
tree | 6548f4639be3261e2db66657b50a6fd095d3a577 /qt-ui/simplewidgets.cpp | |
parent | bd7ded88940995ebbb46fc6983ba9cfd179e55e0 (diff) | |
download | subsurface-b22f1da59e37ff4ba871fb2d6c72ee3ec87b4c5b.tar.gz |
Fix all leak-at-exit from singletons in Subsurface
Subsurface creates a lot of singleton instances on demand, but nothing
ever deleted them. Since they are singletons, these memory allocations
are technically not leaks. However, they clutter the output in valgrind
and other memory analysers, hiding the real issues.
The solution is to delete these items at exit. For the models and for
gettextFromC, the solution is to use a QScopedPointer, which will delete
its payload when it gets destroyed. For the dialogs and other widgets,
we can't do that: they need to be deleted before QApplication exits, so
we just set the parent in all of them to the main window.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/simplewidgets.cpp')
-rw-r--r-- | qt-ui/simplewidgets.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 006e790bf..4f2b27702 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -106,7 +106,7 @@ void MinMaxAvgWidget::setMinimum(const QString& minimum) RenumberDialog* RenumberDialog::instance() { - static RenumberDialog* self = new RenumberDialog(); + static RenumberDialog* self = new RenumberDialog(mainWindow()); return self; } @@ -118,7 +118,7 @@ void RenumberDialog::buttonClicked(QAbstractButton* button) } } -RenumberDialog::RenumberDialog(): QDialog() +RenumberDialog::RenumberDialog(QWidget *parent): QDialog(parent) { ui.setupUi(this); connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); @@ -126,7 +126,7 @@ RenumberDialog::RenumberDialog(): QDialog() ShiftTimesDialog* ShiftTimesDialog::instance() { - static ShiftTimesDialog* self = new ShiftTimesDialog(); + static ShiftTimesDialog* self = new ShiftTimesDialog(mainWindow()); return self; } @@ -150,7 +150,7 @@ void ShiftTimesDialog::buttonClicked(QAbstractButton* button) } } -ShiftTimesDialog::ShiftTimesDialog(): QDialog() +ShiftTimesDialog::ShiftTimesDialog(QWidget *parent): QDialog(parent) { ui.setupUi(this); connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); |