equalsraf committed 37eb5ff

Fix event loop timer late execution

- When calling processEvents we setup a single shot timer
to call QCoreApplication::quit(), in order to enforece the
max waiting time. The problem was that it was possible for the
timer to be triggered after that particular execution of the
event loop - in +ractice this broke all modal dialogs, since it
was causing the following call to the event loop to exit
- To fix the issue I removed the call to QTimer::singleShot
and manually created a single shot timer in the stack.

  • Participants
  • Parent commits a3ae08b

Comments (0)

Files changed (1)


 		QTime t;
 		do {
-			QTimer::singleShot( wtime - t.elapsed(),
-						QApplication::instance(),
-						SLOT(quit())
-					);
+			//
+			// DONT use ::singleShot, we need to remove the timer
+			// when leaving this scope, to ensure the slot is not
+			// called after we exited.
+			QTimer timer;
+			timer.setSingleShot(true);
+			QObject::connect(&timer, SIGNAL(timeout()), QApplication::instance(), SLOT(quit()));
+			timer.start(wtime - t.elapsed());
 			QApplication::processEvents( QEventLoop::WaitForMoreEvents);
 			if ( hasPendingEvents() || !vim_is_input_buf_empty() ) {
 				goto out;