Skip to content

Commit

Permalink
Deprecate QgsFeatureRequest::(set)connectionTimeout, replace with
Browse files Browse the repository at this point in the history
more generic QgsFeatureRequest::timeout
  • Loading branch information
nyalldawson committed Aug 18, 2018
1 parent 7e24ec6 commit aa51263
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 8 deletions.
32 changes: 30 additions & 2 deletions python/core/auto_generated/qgsfeaturerequest.sip.in
Expand Up @@ -635,7 +635,7 @@ Check if a feature is accepted by this requests filter
.. versionadded:: 2.1
%End

int connectionTimeout() const;
int connectionTimeout() const /Deprecated/;
%Docstring
Returns the timeout (in milliseconds) for how long we should wait for a connection if none is available from the pool
at this moment. A negative value (which is set by default) will wait forever.
Expand All @@ -644,10 +644,12 @@ at this moment. A negative value (which is set by default) will wait forever.

Only works if the provider supports this option.

.. deprecated:: Use timeout() instead.

.. versionadded:: 3.0
%End

QgsFeatureRequest &setConnectionTimeout( int connectionTimeout );
QgsFeatureRequest &setConnectionTimeout( int connectionTimeout ) /Deprecated/;
%Docstring
Sets the timeout (in milliseconds) for how long we should wait for a connection if none is available from the pool
at this moment. A negative value (which is set by default) will wait forever.
Expand All @@ -656,7 +658,33 @@ at this moment. A negative value (which is set by default) will wait forever.

Only works if the provider supports this option.

.. deprecated:: Use setTimeout() instead.

.. versionadded:: 3.0
%End

int timeout() const;
%Docstring
Returns the timeout (in milliseconds) for the maximum time we should wait during feature requests before a
feature is returned. A negative value (which is set by default) will wait forever.

.. note::

Only works if the provider supports this option.

.. versionadded:: 3.4
%End

QgsFeatureRequest &setTimeout( int timeout );
%Docstring
Sets the ``timeout`` (in milliseconds) for the maximum time we should wait during feature requests before a
feature is returned. A negative value (which is set by default) will wait forever.

.. note::

Only works if the provider supports this option.

.. versionadded:: 3.4
%End

bool requestMayBeNested() const;
Expand Down
17 changes: 14 additions & 3 deletions src/core/qgsfeaturerequest.cpp
Expand Up @@ -85,7 +85,7 @@ QgsFeatureRequest &QgsFeatureRequest::operator=( const QgsFeatureRequest &rh )
mOrderBy = rh.mOrderBy;
mCrs = rh.mCrs;
mTransformErrorCallback = rh.mTransformErrorCallback;
mConnectionTimeout = rh.mConnectionTimeout;
mTimeout = rh.mTimeout;
mRequestMayBeNested = rh.mRequestMayBeNested;
return *this;
}
Expand Down Expand Up @@ -291,12 +291,23 @@ bool QgsFeatureRequest::acceptFeature( const QgsFeature &feature )

int QgsFeatureRequest::connectionTimeout() const
{
return mConnectionTimeout;
return mTimeout;
}

QgsFeatureRequest &QgsFeatureRequest::setConnectionTimeout( int connectionTimeout )
{
mConnectionTimeout = connectionTimeout;
mTimeout = connectionTimeout;
return *this;
}

int QgsFeatureRequest::timeout() const
{
return mTimeout;
}

QgsFeatureRequest &QgsFeatureRequest::setTimeout( int timeout )
{
mTimeout = timeout;
return *this;
}

Expand Down
28 changes: 25 additions & 3 deletions src/core/qgsfeaturerequest.h
Expand Up @@ -621,20 +621,42 @@ class CORE_EXPORT QgsFeatureRequest
* at this moment. A negative value (which is set by default) will wait forever.
*
* \note Only works if the provider supports this option.
* \deprecated Use timeout() instead.
*
* \since QGIS 3.0
*/
int connectionTimeout() const;
Q_DECL_DEPRECATED int connectionTimeout() const SIP_DEPRECATED;

/**
* Sets the timeout (in milliseconds) for how long we should wait for a connection if none is available from the pool
* at this moment. A negative value (which is set by default) will wait forever.
*
* \note Only works if the provider supports this option.
* \deprecated Use setTimeout() instead.
*
* \since QGIS 3.0
*/
QgsFeatureRequest &setConnectionTimeout( int connectionTimeout );
Q_DECL_DEPRECATED QgsFeatureRequest &setConnectionTimeout( int connectionTimeout ) SIP_DEPRECATED;

/**
* Returns the timeout (in milliseconds) for the maximum time we should wait during feature requests before a
* feature is returned. A negative value (which is set by default) will wait forever.
*
* \note Only works if the provider supports this option.
*
* \since QGIS 3.4
*/
int timeout() const;

/**
* Sets the \a timeout (in milliseconds) for the maximum time we should wait during feature requests before a
* feature is returned. A negative value (which is set by default) will wait forever.
*
* \note Only works if the provider supports this option.
*
* \since QGIS 3.4
*/
QgsFeatureRequest &setTimeout( int timeout );

/**
* In case this request may be run nested within another already running
Expand Down Expand Up @@ -681,7 +703,7 @@ class CORE_EXPORT QgsFeatureRequest
std::function< void( const QgsFeature & ) > mTransformErrorCallback;
QgsCoordinateReferenceSystem mCrs;
QgsCoordinateTransformContext mTransformContext;
int mConnectionTimeout = -1;
int mTimeout = -1;
int mRequestMayBeNested = false;
};

Expand Down

0 comments on commit aa51263

Please sign in to comment.