I can not understand why I am getting this memory leak. First, here is the ouput from valgrind.
==27078== 24 bytes in 1 blocks are definitely lost in loss record 45 of 827
==27078== at 0x4A061A5: operator new(unsigned long) (vg_replace_malloc.c:167)
==27078== by 0x434B8F: ETArray::ETArray(QString const&, QWidget*) (etutils.cpp:343)
==27078== by 0x434D4E: CheckArray::CheckArray(QString const&, QString const&, QString const&, int, int, QWidget*) (etutils.cpp:430)
==27078== by 0x44B14F: SurfCntrlParams::SurfCntrlParams(QWidget*) (surfcntrlparams.cpp:111)
==27078== by 0x44B7EC: SurfCntrlParams::instance() (surfcntrlparams.cpp:23)
==27078== by 0x406F48: MetaWindow::addTab(int) (metawindow.cpp:115)
==27078== by 0x40728E: MetaWindow::setupTabs() (metawindow.cpp:99)
==27078== by 0x4579A0: MetaWindow::qt_metacall(QMetaObject::Call, int, void**) (moc_metawindow.cpp:69)
==27078== by 0x58BDA7A: QMetaObject::activate(QObject*, int, int, void**) (qobject.cpp:3001)
==27078== by 0x458D57: TramontoSim::ready() (moc_tramontosim.cpp:79)
==27078== by 0x4209AD: TramontoSim::readyEmitter() (tramontosim.cpp:70)
==27078== by 0x458DC1: TramontoSim::qt_metacall(QMetaObject::Call, int, void**) (moc_tramontosim.cpp:69)
This is the line that seems to be in question:
ETArray::ETArray(const QString &title, QWidget *parent)
:ETGroupBox(title, parent)
{
colHeadVector = new std::vector<QLabel*>(); //line 342
rowHeadVector = new std::vector<QLabel*>(); //line 343
widgetVector = new std::vector<std::vector<QWidget*>* >(); //line 344
arrayGrid = new QGridLayout(); //line 345
theGrid->addLayout(arrayGrid,1,0); //line 346
}
I don't understand why I am getting a memory leak because in the destructor I make sure to delete the vector, and all the QLabels should be deleted by QT since they all are assigned a parent widget in a different part of the program. Here's my desctructor:
ETArray::~ETArray(){
delete colHeadVector;
delete rowHeadVector;
for(int i=0; i<widgetVector->size(); i++){
delete widgetVector->at(i);
}
delete widgetVector;
}
Anyone have any ideas?