Skip to content

Commit

Permalink
[WFS provider] Force refresh of GetCapabilities when pressing Connect
Browse files Browse the repository at this point in the history
The cached response to GetCapabilities was always used, even when
pressing Connect. Now a new request is sent over the network.

Fixes #15647
  • Loading branch information
rouault committed Oct 6, 2016
1 parent fffbf78 commit b8ff71a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/providers/wfs/qgswfscapabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ QgsWfsCapabilities::~QgsWfsCapabilities()
{
}

bool QgsWfsCapabilities::requestCapabilities( bool synchronous )
bool QgsWfsCapabilities::requestCapabilities( bool synchronous, bool forceRefresh )
{
QUrl url( baseURL() );
url.addQueryItem( "REQUEST", "GetCapabilities" );
Expand All @@ -47,7 +47,7 @@ bool QgsWfsCapabilities::requestCapabilities( bool synchronous )
else
url.addQueryItem( "VERSION", version );

if ( !sendGET( url, synchronous, false ) )
if ( !sendGET( url, synchronous, forceRefresh ) )
{
emit gotCapabilities();
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgswfscapabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class QgsWfsCapabilities : public QgsWfsRequest
virtual ~QgsWfsCapabilities();

//! start network connection to get capabilities
bool requestCapabilities( bool synchronous );
bool requestCapabilities( bool synchronous, bool forceRefresh );

//! description of a vector layer
struct FeatureType
Expand Down
4 changes: 3 additions & 1 deletion src/providers/wfs/qgswfsdataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ QVector<QgsDataItem*> QgsWfsConnectionItem::createChildren()

QgsWfsCapabilities capabilities( mUri );

capabilities.requestCapabilities( true );
const bool synchronous = true;
const bool forceRefresh = false;
capabilities.requestCapabilities( synchronous, forceRefresh );

QVector<QgsDataItem*> layers;
if ( capabilities.errorCode() == QgsWfsCapabilities::NoError )
Expand Down
4 changes: 3 additions & 1 deletion src/providers/wfs/qgswfsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,9 @@ bool QgsWFSProvider::getCapabilities()
if ( mShared->mCaps.version.isEmpty() )
{
QgsWfsCapabilities getCapabilities( mShared->mURI.uri( false ) );
if ( !getCapabilities.requestCapabilities( true ) )
const bool synchronous = true;
const bool forceRefresh = false;
if ( !getCapabilities.requestCapabilities( synchronous, forceRefresh ) )
{
QgsMessageLog::logMessage( tr( "GetCapabilities failed for url %1: %2" ).
arg( dataSourceUri() ).arg( getCapabilities.errorMessage() ), tr( "WFS" ) );
Expand Down
4 changes: 3 additions & 1 deletion src/providers/wfs/qgswfssourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ void QgsWFSSourceSelect::connectToServer()
}
if ( mCapabilities )
{
mCapabilities->requestCapabilities( false );
const bool synchronous = false;
const bool forceRefresh = true;
mCapabilities->requestCapabilities( synchronous, forceRefresh );
}
}

Expand Down

0 comments on commit b8ff71a

Please sign in to comment.