Browse Source

fix random hangs in the event loop

Calling QCoreApplication::processEvents with QEventLoop::WaitForMoreEvents
can sometimes cause it to hang waiting for more events. Also, calling
QCoreApplication::sendPostedEvents is recommended for the deleteLater()
calls to be processed correctly [1] so that memory leaks do not occur.

Thanks to @bgra and @DanielCeregatti, fixes #2254 and #1977 and #1706
and possibly many other issues.

[1] http://doc.qt.io/qt-4.8/qcoreapplication.html#processEvents
Ashish Kulkarni 10 years ago
parent
commit
9fa4695ace
2 changed files with 5 additions and 2 deletions
  1. 1 0
      CHANGELOG.md
  2. 4 2
      src/lib/converter.cc

+ 1 - 0
CHANGELOG.md

@@ -5,6 +5,7 @@ v0.12.3 (unreleased)
 * downgrade libpng to 1.2.53
 * **#2104**: renamed COPYING to LICENSE
 * **#2190**: do not depend on ICU even if it is already installed
+* **#2254**: fix random hangs in the event loop
 * **#2280**: do not allow data URIs for --header-html or --footer-html
 * **#2322**: fix broken debug builds with MSVC
 

+ 4 - 2
src/lib/converter.cc

@@ -90,8 +90,10 @@ void ConverterPrivate::cancel() {
 bool ConverterPrivate::convert() {
 	convertionDone=false;
 	beginConvert();
-	while (!convertionDone)
-		qApp->processEvents(QEventLoop::WaitForMoreEvents | QEventLoop::AllEvents);
+	while (!convertionDone) {
+		QCoreApplication::processEvents();
+		QCoreApplication::sendPostedEvents();
+	}
 	return !error;
 }