Merge pull request #732 from ikbenkous/fixdoublefree

Fix double free in mainwindow.cpp (#726)
This commit is contained in:
ea4k 2024-08-12 23:07:37 +02:00 committed by GitHub
commit 51438b48a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 9 deletions

View File

@ -192,8 +192,7 @@ MainWindow::MainWindow(const QString &tversion)
mainWidget = new QWidget(this);
//qDebug() << Q_FUNC_INFO << ": 60 " << QTime::currentTime().toString("hh:mm:ss") ;
dateTime = new QDateTime();
dateTimeTemp = new QDateTime();
dateTime = std::make_unique<QDateTime>();
// UI DX
infoLabel2 = new QLabel(tr("DX Entity"));
loggWinAct = new QAction(tr("&Log Window"), this);
@ -251,8 +250,7 @@ MainWindow::~MainWindow()
delete(locator);
delete(qso);
delete(backupQSO);
delete(dateTime);
delete(dateTimeTemp);
dateTime.reset();
delete(awards);
delete(softUpdate);
delete(filemanager);
@ -2219,7 +2217,6 @@ void MainWindow::slotClearButtonClicked(const QString &_func)
setModifying(false);
currentEntity = -1;
dateTimeTemp = dateTime;
modifyingQSO = -1;
QSOTabWidget->setRSTToMode(mainQSOEntryWidget->getMode(), readingTheUI);
@ -4687,8 +4684,6 @@ void MainWindow::qsoToEdit (const int _qso)
mainQSOEntryWidget->setDateTime(qsoE.getDateTimeOn());
dateTimeTemp->setDate(qsoE.getDate());
mainQSOEntryWidget->setBand(qsoE.getBand());
//qDebug() << Q_FUNC_INFO << " - RST" ;

View File

@ -81,6 +81,8 @@
#include "updatesettings.h"
#include "klogdefinitions.h"
#include <memory>
class QTimer;
class QDateTime;
@ -627,7 +629,7 @@ private:
// </UI>
int infoTimeout; // timeout that temporary info will stay in the infobars
QTimer *timer, *timerInfoBars;
QDateTime *dateTime, *dateTimeTemp;
std::unique_ptr<QDateTime> dateTime;
bool yearChangedDuringModification;
QString infoLabel1T, infoLabel2T;

View File

@ -156,7 +156,6 @@ void tst_MainWindow::test_Constructor()
QVERIFY2(mainWindow->qso, "qso not created");
//QVERIFY2(mainWindow->debugFile, "debugFile not created");
QVERIFY2(mainWindow->dateTime, "dateTime not created");
QVERIFY2(mainWindow->dateTimeTemp, "dateTimeTemp not created");
QVERIFY2(mainWindow->awards, "awards not created");
QVERIFY2(mainWindow->softUpdate, "softUpdate not created");
QVERIFY2(mainWindow->filemanager, "filemanager not created");