From 0fcf9d0cba7dcdd459ba0c15628f3bedcde5724f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 31 Aug 2022 18:27:04 +0200 Subject: [PATCH] Fix memory leak in LibraryCreator --- YACReaderLibrary/library_creator.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/YACReaderLibrary/library_creator.cpp b/YACReaderLibrary/library_creator.cpp index 0b2aab1f..afe15667 100644 --- a/YACReaderLibrary/library_creator.cpp +++ b/YACReaderLibrary/library_creator.cpp @@ -377,16 +377,20 @@ void LibraryCreator::update(QDir dirS) bool updated; int i, j; for (i = 0, j = 0; (i < lenghtS) || (j < lenghtD);) { - if (stopRunning) + if (stopRunning) { + qDeleteAll(listD); return; + } updated = false; if (i >= lenghtS) // finished source files/dirs { // QLOG_WARN() << "finished source files/dirs" << dirS.absolutePath(); // delete listD //from j for (; j < lenghtD; j++) { - if (stopRunning) + if (stopRunning) { + qDeleteAll(listD); return; + } DBHelper::removeFromDB(listD.at(j), (_database)); } updated = true; @@ -396,8 +400,10 @@ void LibraryCreator::update(QDir dirS) // QLOG_WARN() << "finished library files/dirs" << dirS.absolutePath(); // create listS //from i for (; i < lenghtS; i++) { - if (stopRunning) + if (stopRunning) { + qDeleteAll(listD); return; + } QFileInfo fileInfoS = listS.at(i); if (fileInfoS.isDir()) // create folder { @@ -548,4 +554,6 @@ void LibraryCreator::update(QDir dirS) } } } + + qDeleteAll(listD); }