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

View File

@ -184,7 +184,7 @@ void Comic::updateBookmarkImage(int index)
bm->setBookmark(index,p);
emit bookmarksUpdated();
//emit bookmarksLoaded(*bm);
}
if(bm->getLastPage() == index)
{
@ -237,7 +237,7 @@ QList<QString> Comic::findValidComicFiles(const QList<QUrl> &list)
QLOG_DEBUG() << "-findValidComicFiles-";
QList<QString> validComicFiles;
QString currentPath;
foreach (QUrl url, list)
foreach (QUrl url, list)
{
currentPath = url.toLocalFile();
if(Comic::fileIsComic(currentPath))
@ -267,7 +267,7 @@ QList<QString> Comic::findValidComicFilesInFolder(const QString &path)
QFileInfoList folderContent = folder.entryInfoList();
QString currentPath;
foreach (QFileInfo info, folderContent)
foreach (QFileInfo info, folderContent)
{
currentPath = info.absoluteFilePath();
if(info.isDir())
@ -353,7 +353,7 @@ bool FileComic::load(const QString & path, const ComicDB & comic)
else
{
//QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
emit errorOpening();
return false;
}
@ -442,7 +442,7 @@ QList<QVector<quint32> > FileComic::getSections(int & sectionIndex)
unsigned int realIdx;
foreach(quint32 i, sortedIndexes)
{
if(_firstPage == idx)
{
sectionIndex = sectionCount;
@ -497,7 +497,7 @@ QList<QVector<quint32> > FileComic::getSections(int & sectionIndex)
idx++;
}
if(sectionIndex == sectionCount) //found
{
if(section.indexOf(realIdx)!=0)
@ -540,14 +540,14 @@ void FileComic::process()
CompressedArchive archive(_path);
if(!archive.toolsLoaded())
{
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
emit errorOpening(tr("7z not found"));
return;
}
if(!archive.isValid())
{
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
emit errorOpening(tr("Format not supported"));
return;
}
@ -559,7 +559,7 @@ void FileComic::process()
if(_fileNames.size()==0)
{
//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();
return;
}
@ -599,7 +599,7 @@ void FileComic::process()
{
if(_invalidated)
{
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
return;
}
archive.getAllData(sections.at(i),this);
@ -608,7 +608,7 @@ void FileComic::process()
{
if(_invalidated)
{
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
return;
}
archive.getAllData(sections.at(i),this);
@ -623,7 +623,7 @@ void FileComic::process()
emit imageLoaded(sortedIndex);
emit imageLoaded(sortedIndex,_pages[sortedIndex]);
}*/
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
emit imagesLoaded();
}
@ -683,7 +683,7 @@ void FolderComic::process()
{
//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"));
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
emit errorOpening();
}
else
@ -712,7 +712,7 @@ void FolderComic::process()
{
if(_invalidated)
{
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
return;
}
@ -729,7 +729,7 @@ void FolderComic::process()
count++;
}
}
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
emit imagesLoaded();
}
@ -757,7 +757,7 @@ PDFComic::~PDFComic()
}
bool PDFComic::load(const QString & path, int atPage)
{
{
QFileInfo fi(path);
if(fi.exists())
@ -774,7 +774,7 @@ bool PDFComic::load(const QString & path, int atPage)
}
else
{
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
emit errorOpening();
return false;
}
@ -799,7 +799,7 @@ bool PDFComic::load(const QString & path, const ComicDB & comic)
else
{
//QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
emit errorOpening();
return false;
}
@ -829,13 +829,13 @@ void PDFComic::process()
{
//delete pdfComic;
//pdfComic = 0;
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
emit errorOpening();
return;
}
if (pdfComic->isLocked())
{
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
emit errorOpening();
return;
}
@ -874,7 +874,7 @@ void PDFComic::process()
if(_invalidated)
{
delete pdfComic;
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
return;
}
@ -885,14 +885,14 @@ void PDFComic::process()
if(_invalidated)
{
delete pdfComic;
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
return;
}
renderPage(i);
}
delete pdfComic;
//moveToThread(QCoreApplication::instance()->thread());
moveToThread(QCoreApplication::instance()->thread());
emit imagesLoaded();
}
@ -931,7 +931,7 @@ Comic * FactoryComic::newComic(const QString & path)
if(fi.exists())
{
if(fi.isFile())
{
{
#ifndef NO_PDF
if(fi.suffix().compare("pdf",Qt::CaseInsensitive) == 0)
{
@ -1113,7 +1113,7 @@ QList<QString> merge_pages(QList<QString> & singlePageNames, QList<QString> & do
{
pageNames.append(doublePageNames.at(j++));
}
return pageNames;
}
@ -1141,7 +1141,7 @@ void comic_pages_sort(QList<QString> & pageNames, YACReaderPageSortingMode sorti
}
}
break;
case YACReaderAlphabeticalSorting:
std::sort(pageNames.begin(), pageNames.end());
break;