1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-03 07:21:14 -05:00
sdrangel/app/main.cpp
Jason Gerecke a71ba63b49 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<FFTWEngine::Plan* const&> (stl_list.h:572)
==11533==    by 0x54C82ED: _M_insert<FFTWEngine::Plan* const&> (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)
2018-04-21 18:56:06 -07:00

135 lines
4.8 KiB
C++

///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QApplication>
#include <QTextCodec>
#include <QProxyStyle>
#include <QStyleFactory>
#include <QFontDatabase>
#include <QSysInfo>
#include "loggerwithfile.h"
#include "mainwindow.h"
#include "dsp/dsptypes.h"
static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *logger)
{
QApplication a(argc, argv);
/*
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
*/
QCoreApplication::setOrganizationName("f4exb");
QCoreApplication::setApplicationName("SDRangel");
QCoreApplication::setApplicationVersion("3.14.3");
#if 1
qApp->setStyle(QStyleFactory::create("fusion"));
QPalette palette;
palette.setColor(QPalette::Window, QColor(53,53,53));
palette.setColor(QPalette::WindowText, Qt::white);
palette.setColor(QPalette::Base, QColor(25,25,25));
palette.setColor(QPalette::AlternateBase, QColor(53,53,53));
palette.setColor(QPalette::ToolTipBase, Qt::white);
palette.setColor(QPalette::ToolTipText, Qt::black);
palette.setColor(QPalette::Text, Qt::white);
palette.setColor(QPalette::Button, QColor(0x40, 0x40, 0x40));
palette.setColor(QPalette::ButtonText, Qt::white);
palette.setColor(QPalette::BrightText, Qt::red);
palette.setColor(QPalette::Light, QColor(53,53,53).lighter(125).lighter());
palette.setColor(QPalette::Mid, QColor(53,53,53).lighter(125));
palette.setColor(QPalette::Dark, QColor(53,53,53).lighter(125).darker());
palette.setColor(QPalette::Link, QColor(0,0xa0,0xa0));
palette.setColor(QPalette::LinkVisited, QColor(0,0xa0,0xa0).lighter());
palette.setColor(QPalette::Highlight, QColor(0xff, 0x8c, 0x00));
palette.setColor(QPalette::HighlightedText, Qt::black);
qApp->setPalette(palette);
#if 0
if(QFontDatabase::addApplicationFont("/tmp/Cuprum.otf") >= 0) {
QFont font("CuprumFFU");
font.setPointSize(10);
qApp->setFont(font);
}
#endif
#if 0
if(QFontDatabase::addApplicationFont("/tmp/PTN57F.ttf") >= 0) {
QFont font("PT Sans Narrow");
font.setPointSize(10);
qApp->setFont(font);
}
#endif
#if 0
if(QFontDatabase::addApplicationFont("/tmp/PTS55F.ttf") >= 0) {
QFont font("PT Sans");
font.setPointSize(10);
qApp->setFont(font);
}
#endif
#if 0
{
QFont font("Ubuntu Condensed");
font.setPointSize(10);
qApp->setFont(font);
}
#endif
#endif
MainParser parser;
parser.parse(*qApp);
#if QT_VERSION >= 0x050400
qInfo("%s %s Qt %s %db %s %s DSP Rx:%db Tx:%db PID %lld",
qPrintable(qApp->applicationName()),
qPrintable(qApp->applicationVersion()),
qPrintable(QString(QT_VERSION_STR)),
QT_POINTER_SIZE*8,
qPrintable(QSysInfo::currentCpuArchitecture()),
qPrintable(QSysInfo::prettyProductName()),
SDR_RX_SAMP_SZ,
SDR_TX_SAMP_SZ,
qApp->applicationPid());
#else
qInfo("%s %s Qt %s %db DSP Rx:%db Tx:%db PID: %lld",
qPrintable(qApp->applicationName()),
qPrintable((qApp->applicationVersion()),
qPrintable(QString(QT_VERSION_STR)),
QT_POINTER_SIZE*8,
SDR_RX_SAMP_SZ,
SDR_TX_SAMP_SZ,
applicationPid);
#endif
MainWindow w(logger, parser);
w.show();
QObject::connect(&a, SIGNAL(aboutToQuit()), &w, SLOT(on_action_Exit_triggered()));
return a.exec();
}
int main(int argc, char* argv[])
{
qtwebapp::LoggerWithFile *logger = new qtwebapp::LoggerWithFile(qApp);
logger->installMsgHandler();
int res = runQtApplication(argc, argv, logger);
qWarning("SDRangel quit.");
return res;
}