Fix memory leak, comics need to be in the right thread before deleting them.

This commit is contained in:
Luis Ángel San Martín 2018-04-24 21:01:38 +02:00
commit 932910d0a9
2 changed files with 29 additions and 29 deletions

View File

@ -417,7 +417,7 @@ Render::~Render()
{ {
if(comic!=0) if(comic!=0)
{ {
//comic->moveToThread(QApplication::instance()->thread()); comic->moveToThread(QApplication::instance()->thread());
comic->deleteLater(); comic->deleteLater();
} }
@ -679,7 +679,7 @@ void Render::setComic(Comic * c)
{ {
if(comic !=0) if(comic !=0)
{ {
//comic->moveToThread(QApplication::instance()->thread()); comic->moveToThread(QApplication::instance()->thread());
comic->disconnect(); comic->disconnect();
comic->deleteLater(); comic->deleteLater();
} }

View File

@ -353,7 +353,7 @@ bool FileComic::load(const QString & path, const ComicDB & comic)
else else
{ {
//QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path); //QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit errorOpening(); emit errorOpening();
return false; return false;
} }
@ -540,14 +540,14 @@ void FileComic::process()
CompressedArchive archive(_path); CompressedArchive archive(_path);
if(!archive.toolsLoaded()) if(!archive.toolsLoaded())
{ {
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit errorOpening(tr("7z not found")); emit errorOpening(tr("7z not found"));
return; return;
} }
if(!archive.isValid()) if(!archive.isValid())
{ {
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit errorOpening(tr("Format not supported")); emit errorOpening(tr("Format not supported"));
return; return;
} }
@ -559,7 +559,7 @@ void FileComic::process()
if(_fileNames.size()==0) if(_fileNames.size()==0)
{ {
//QMessageBox::critical(NULL,tr("File error"),tr("File not found or not images in file")); //QMessageBox::critical(NULL,tr("File error"),tr("File not found or not images in file"));
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit errorOpening(); emit errorOpening();
return; return;
} }
@ -599,7 +599,7 @@ void FileComic::process()
{ {
if(_invalidated) if(_invalidated)
{ {
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
return; return;
} }
archive.getAllData(sections.at(i),this); archive.getAllData(sections.at(i),this);
@ -608,7 +608,7 @@ void FileComic::process()
{ {
if(_invalidated) if(_invalidated)
{ {
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
return; return;
} }
archive.getAllData(sections.at(i),this); archive.getAllData(sections.at(i),this);
@ -623,7 +623,7 @@ void FileComic::process()
emit imageLoaded(sortedIndex); emit imageLoaded(sortedIndex);
emit imageLoaded(sortedIndex,_pages[sortedIndex]); emit imageLoaded(sortedIndex,_pages[sortedIndex]);
}*/ }*/
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit imagesLoaded(); emit imagesLoaded();
} }
@ -683,7 +683,7 @@ void FolderComic::process()
{ {
//TODO emitir este mensaje en otro sitio //TODO emitir este mensaje en otro sitio
//QMessageBox::critical(NULL,QObject::tr("No images found"),QObject::tr("There are not images on the selected folder")); //QMessageBox::critical(NULL,QObject::tr("No images found"),QObject::tr("There are not images on the selected folder"));
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit errorOpening(); emit errorOpening();
} }
else else
@ -712,7 +712,7 @@ void FolderComic::process()
{ {
if(_invalidated) if(_invalidated)
{ {
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
return; return;
} }
@ -729,7 +729,7 @@ void FolderComic::process()
count++; count++;
} }
} }
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit imagesLoaded(); emit imagesLoaded();
} }
@ -774,7 +774,7 @@ bool PDFComic::load(const QString & path, int atPage)
} }
else else
{ {
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit errorOpening(); emit errorOpening();
return false; return false;
} }
@ -799,7 +799,7 @@ bool PDFComic::load(const QString & path, const ComicDB & comic)
else else
{ {
//QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path); //QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit errorOpening(); emit errorOpening();
return false; return false;
} }
@ -829,13 +829,13 @@ void PDFComic::process()
{ {
//delete pdfComic; //delete pdfComic;
//pdfComic = 0; //pdfComic = 0;
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit errorOpening(); emit errorOpening();
return; return;
} }
if (pdfComic->isLocked()) if (pdfComic->isLocked())
{ {
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit errorOpening(); emit errorOpening();
return; return;
} }
@ -874,7 +874,7 @@ void PDFComic::process()
if(_invalidated) if(_invalidated)
{ {
delete pdfComic; delete pdfComic;
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
return; return;
} }
@ -885,14 +885,14 @@ void PDFComic::process()
if(_invalidated) if(_invalidated)
{ {
delete pdfComic; delete pdfComic;
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
return; return;
} }
renderPage(i); renderPage(i);
} }
delete pdfComic; delete pdfComic;
//moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());
emit imagesLoaded(); emit imagesLoaded();
} }