mirror of
				https://github.com/YACReader/yacreader
				synced 2025-10-30 15:54:27 -04:00 
			
		
		
		
	Fix huge memleak in server code caused by thread pingpong fix.
Stopped QThreads don't process events, so cleanup signals get lost. Prevent this from happening by keeping the threads alive and the comic inside the thread (as we already do in the viewer). Cleanup happens by connecting the comic's destroyed() signal to the thread's quit() slot.
This commit is contained in:
		
				
					committed by
					
						 Luis Ángel San Martín
						Luis Ángel San Martín
					
				
			
			
				
	
			
			
			
						parent
						
							cc71f419cc
						
					
				
				
					commit
					be547081f2
				
			| @ -57,9 +57,10 @@ void ComicController::service(HttpRequest &request, HttpResponse &response) | ||||
|  | ||||
|         comicFile->moveToThread(thread); | ||||
|  | ||||
|         connect(comicFile, SIGNAL(errorOpening()), thread, SLOT(quit())); | ||||
|         connect(comicFile, SIGNAL(errorOpening(QString)), thread, SLOT(quit())); | ||||
|         connect(comicFile, SIGNAL(imagesLoaded()), thread, SLOT(quit())); | ||||
|         //connect(comicFile, SIGNAL(errorOpening()), thread, SLOT(quit())); | ||||
|         //connect(comicFile, SIGNAL(errorOpening(QString)), thread, SLOT(quit())); | ||||
|         //connect(comicFile, SIGNAL(imagesLoaded()), thread, SLOT(quit())); | ||||
|         connect(comicFile, SIGNAL(destroyed()), thread, SLOT(quit())); | ||||
|         connect(thread, SIGNAL(started()), comicFile, SLOT(process())); | ||||
|         connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); | ||||
|  | ||||
|  | ||||
| @ -53,23 +53,21 @@ void ComicControllerV2::service(HttpRequest &request, HttpResponse &response) | ||||
|  | ||||
|     Comic *comicFile = FactoryComic::newComic(libraries.getPath(libraryId) + comic.path); | ||||
|  | ||||
|     if (comicFile != nullptr) { | ||||
|         QThread *thread = nullptr; | ||||
|  | ||||
|         thread = new QThread(); | ||||
|     if (comicFile != NULL) { | ||||
|         QThread *thread = new QThread(); | ||||
|  | ||||
|         comicFile->moveToThread(thread); | ||||
|  | ||||
|         connect(comicFile, SIGNAL(errorOpening()), thread, SLOT(quit())); | ||||
|         connect(comicFile, SIGNAL(errorOpening(QString)), thread, SLOT(quit())); | ||||
|         connect(comicFile, SIGNAL(imagesLoaded()), thread, SLOT(quit())); | ||||
|         //connect(comicFile, SIGNAL(errorOpening()), thread, SLOT(quit())); | ||||
|         //connect(comicFile, SIGNAL(errorOpening(QString)), thread, SLOT(quit())); | ||||
|         //connect(comicFile, SIGNAL(imagesLoaded()), thread, SLOT(quit())); | ||||
|         connect(comicFile, SIGNAL(destroyed()), thread, SLOT(quit())); | ||||
|         connect(thread, SIGNAL(started()), comicFile, SLOT(process())); | ||||
|         connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); | ||||
|  | ||||
|         comicFile->load(libraries.getPath(libraryId) + comic.path); | ||||
|  | ||||
|         if (thread != nullptr) | ||||
|             thread->start(); | ||||
|         thread->start(); | ||||
|  | ||||
|         if (remoteComic) { | ||||
|             QLOG_TRACE() << "remote comic requested"; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user