From 3125190184fbf82e89627fabf1ff3c11d1d58a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Tue, 27 Aug 2013 19:22:24 +0200 Subject: [PATCH] fixed memory leak in CompressedArchive --- YACReader/comic.cpp | 6 +----- YACReader/render.cpp | 2 +- compressed_archive/compressed_archive.cpp | 12 ++++++------ compressed_archive/extract_callbacks.h | 2 ++ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/YACReader/comic.cpp b/YACReader/comic.cpp index a80135b9..7191920a 100644 --- a/YACReader/comic.cpp +++ b/YACReader/comic.cpp @@ -406,10 +406,6 @@ QList > FileComic::getSections(int & sectionIndex) void FileComic::process() { - QTime myTimer; - myTimer.start(); - // do something.. - CompressedArchive archive(_path); //se filtran para obtener sólo los formatos soportados _order = archive.getFileNames(); @@ -459,7 +455,7 @@ void FileComic::process() }*/ emit imagesLoaded(); - moveToThread(QApplication::instance()->thread()); + //moveToThread(QApplication::instance()->thread()); } diff --git a/YACReader/render.cpp b/YACReader/render.cpp index 88468adc..110628de 100644 --- a/YACReader/render.cpp +++ b/YACReader/render.cpp @@ -642,7 +642,7 @@ void Render::createComic(const QString & path) { if(comic!=0) { - comic->moveToThread(QApplication::instance()->thread()); + //comic->moveToThread(QApplication::instance()->thread()); comic->disconnect(); comic->deleteLater(); } diff --git a/compressed_archive/compressed_archive.cpp b/compressed_archive/compressed_archive.cpp index 72679655..a7ffb623 100644 --- a/compressed_archive/compressed_archive.cpp +++ b/compressed_archive/compressed_archive.cpp @@ -101,7 +101,9 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) CompressedArchive::~CompressedArchive() { - //TODO + //szInterface->fileSpec->Release(); + delete szInterface; + delete sevenzLib; } void CompressedArchive::loadFunctions() @@ -185,7 +187,7 @@ QList CompressedArchive::getAllData(const QVector & indexes { qDebug() << "Extract Error" << endl; } - + return extractCallbackSpec->allFiles; } @@ -205,10 +207,8 @@ QByteArray CompressedArchive::getRawDataAtIndex(int index) { qDebug() << "Extract Error" << endl; } - - QByteArray rawData((char *)extractCallbackSpec->data,extractCallbackSpec->newFileSize); - - return rawData; + + return QByteArray((char *)extractCallbackSpec->data,extractCallbackSpec->newFileSize); } return QByteArray(); } \ No newline at end of file diff --git a/compressed_archive/extract_callbacks.h b/compressed_archive/extract_callbacks.h index f74867f0..998b8734 100644 --- a/compressed_archive/extract_callbacks.h +++ b/compressed_archive/extract_callbacks.h @@ -92,6 +92,7 @@ public: UInt64 newFileSize; CArchiveExtractCallback(bool c = false,ExtractDelegate * d = 0) : PasswordIsDefined(false),all(c),delegate(d) {} + ~CArchiveExtractCallback() {MidFree(data);} }; void CArchiveExtractCallback::Init(IInArchive *archiveHandler, const UString &directoryPath) @@ -259,6 +260,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult) { QByteArray rawData((char *)data,newFileSize); MidFree(data); + data = 0; if(delegate != 0) delegate->fileExtracted(_index,rawData); else