From a71ba63b495e87bb6071207d19eebf27fca7a95e Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Fri, 20 Apr 2018 17:16:13 -0700 Subject: [PATCH] MainWindow: call cleanup code on aboutToQuit signal Address the two largest leaks detected by valgrind when simply opening and closing sdrangel with the 'X' button rather than the 'Exit' menu item. ==11533== 18,016 (24 direct, 17,992 indirect) bytes in 1 blocks are definitely lost in loss record 6,991 of 7,005 ==11533== at 0x4C2D54F: operator new(unsigned long) (vg_replace_malloc.c:334) ==11533== by 0x54C82ED: allocate (new_allocator.h:111) ==11533== by 0x54C82ED: allocate (alloc_traits.h:436) ==11533== by 0x54C82ED: _M_get_node (stl_list.h:383) ==11533== by 0x54C82ED: _M_create_node (stl_list.h:572) ==11533== by 0x54C82ED: _M_insert (stl_list.h:1801) ==11533== by 0x54C82ED: push_back (stl_list.h:1118) ==11533== by 0x54C82ED: FFTWEngine::configure(int, bool) (fftwengine.cpp:35) ==11533== by 0x4F4590B: SpectrumVis::handleConfigure(int, int, FFTWindow::Function) (spectrumvis.cpp:206) ==11533== by 0x4F45B94: SpectrumVis::SpectrumVis(float, GLSpectrum*) (spectrumvis.cpp:29) ==11533== by 0x4F46349: DeviceUISet::DeviceUISet(int, bool, QTimer&) (deviceuiset.cpp:39) ==11533== by 0x4EA890E: MainWindow::addSourceDevice(int) (mainwindow.cpp:240) ==11533== by 0x4EAC7F3: MainWindow::MainWindow(qtwebapp::LoggerWithFile*, MainParser const&, QWidget*) (mainwindow.cpp:171) ==11533== by 0x10A3B3: runQtApplication(int, char**, qtwebapp::LoggerWithFile*) (main.cpp:120) ==11533== by 0x109A78: main (main.cpp:130) ==11533== ==11533== 54,096 (112 direct, 53,984 indirect) bytes in 1 blocks are definitely lost in loss record 6,999 of 7,005 ==11533== at 0x4C2D54F: operator new(unsigned long) (vg_replace_malloc.c:334) ==11533== by 0x69E9162: QObject::QObject(QObject*) (in /usr/lib/libQt5Core.so.5.10.1) ==11533== by 0x54834E6: BasebandSampleSink::BasebandSampleSink() (basebandsamplesink.cpp:6) ==11533== by 0x4F45A29: SpectrumVis::SpectrumVis(float, GLSpectrum*) (spectrumvis.cpp:26) ==11533== by 0x4F46349: DeviceUISet::DeviceUISet(int, bool, QTimer&) (deviceuiset.cpp:39) ==11533== by 0x4EA890E: MainWindow::addSourceDevice(int) (mainwindow.cpp:240) ==11533== by 0x4EAC7F3: MainWindow::MainWindow(qtwebapp::LoggerWithFile*, MainParser const&, QWidget*) (mainwindow.cpp:171) ==11533== by 0x10A3B3: runQtApplication(int, char**, qtwebapp::LoggerWithFile*) (main.cpp:120) ==11533== by 0x109A78: main (main.cpp:130) --- app/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/app/main.cpp b/app/main.cpp index 14164fd21..f60faa79a 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -119,6 +119,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo MainWindow w(logger, parser); w.show(); + QObject::connect(&a, SIGNAL(aboutToQuit()), &w, SLOT(on_action_Exit_triggered())); return a.exec(); }