Skip to content

Commit fef5618

Browse files
committed
Workaround bug in Qt > 5.8 causing crashes in connection pools
tryAcquire is broken on Qt > 5.8 with negative timeouts - see: http://bugreports.qt.io/browse/QTBUG-64413 https://lists.osgeo.org/pipermail/qgis-developer/2017-November/050456.html
1 parent 4c78526 commit fef5618

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/core/qgsconnectionpool.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,19 @@ class QgsConnectionPoolGroup
9595
T acquire( int timeout )
9696
{
9797
// we are going to acquire a resource - if no resource is available, we will block here
98-
if ( !sem.tryAcquire( 1, timeout ) )
99-
return nullptr;
98+
if ( timeout >= 0 )
99+
{
100+
if ( !sem.tryAcquire( 1, timeout ) )
101+
return nullptr;
102+
}
103+
else
104+
{
105+
// we should still be able to use tryAcquire with a negative timeout here, but
106+
// tryAcquire is broken on Qt > 5.8 with negative timeouts - see
107+
// https://bugreports.qt.io/browse/QTBUG-64413
108+
// https://lists.osgeo.org/pipermail/qgis-developer/2017-November/050456.html
109+
sem.acquire( 1 );
110+
}
100111

101112
// quick (preferred) way - use cached connection
102113
{

0 commit comments

Comments
 (0)