mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	core/qtserialbluetooth.cpp: use QEventLoop for polling
The Qt docs here: https://doc.qt.io/qt-5/qbluetoothsocket.html#details and here: https://doc.qt.io/qt-5/qabstractsocket.html#waitForReadyRead say that waitForReadyRead() does not work for QBluetoothSocket and that it's flaky on Windows for the underlying QAbstractSocket. Use a QEventLoop and a QTimer to poll the readyRead() signal. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
		
							parent
							
								
									aceb8a547f
								
							
						
					
					
						commit
						e69f5c4e28
					
				
					 1 changed files with 10 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -212,7 +212,16 @@ static dc_status_t qt_serial_poll(void *io, int timeout)
 | 
			
		|||
 | 
			
		||||
	if (!device->socket)
 | 
			
		||||
		return DC_STATUS_INVALIDARGS;
 | 
			
		||||
	if (device->socket->waitForReadyRead(timeout))
 | 
			
		||||
 | 
			
		||||
	QEventLoop loop;
 | 
			
		||||
	QTimer timer;
 | 
			
		||||
	timer.setSingleShot(true);
 | 
			
		||||
	loop.connect(&timer, SIGNAL(timeout()), SLOT(quit()));
 | 
			
		||||
	loop.connect(device->socket, SIGNAL(readyRead()), SLOT(quit()));
 | 
			
		||||
	timer.start(timeout);
 | 
			
		||||
	loop.exec();
 | 
			
		||||
 | 
			
		||||
	if (!timer.isActive())
 | 
			
		||||
		return DC_STATUS_SUCCESS;
 | 
			
		||||
	return DC_STATUS_TIMEOUT;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue