Skip to content
Permalink
Browse files
Merge pull request #46786 from nirvn/geonode_fixes
Fix a geonode provider layers fetching crasher
  • Loading branch information
elpaso committed Jan 12, 2022
2 parents 66b481a + 2c6bede commit 33f4f1cba26bf019e72c6b3537585186095eef3a
Showing with 16 additions and 11 deletions.
  1. +15 −11 src/core/geocms/geonode/qgsgeonoderequest.cpp
  2. +1 −0 src/core/geocms/geonode/qgsgeonoderequest.h
@@ -54,18 +54,22 @@ void QgsGeoNodeRequest::abort()
void QgsGeoNodeRequest::fetchLayers()
{
request( QStringLiteral( "/api/layers/" ) );
QObject *obj = new QObject( this );

QObject *obj = new QObject( this );
connect( this, &QgsGeoNodeRequest::requestFinished, obj, [obj, this ]
{
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers;
if ( mError.isEmpty() )
if ( !mParsingLayers )
{
layers = parseLayers( this->lastResponse() );
mParsingLayers = true;
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers;
if ( mError.isEmpty() )
{
layers = parseLayers( lastResponse() );
}
emit layersFetched( layers );
mParsingLayers = false;
obj->deleteLater();
}
emit layersFetched( layers );

obj->deleteLater();
} );
}

@@ -74,11 +78,11 @@ QList<QgsGeoNodeRequest::ServiceLayerDetail> QgsGeoNodeRequest::fetchLayersBlock
QList<QgsGeoNodeRequest::ServiceLayerDetail> layers;

QEventLoop loop;
connect( this, &QgsGeoNodeRequest::requestFinished, &loop, &QEventLoop::quit );
QObject *obj = new QObject( this );
connect( this, &QgsGeoNodeRequest::layersFetched, obj, [&]( const QList<QgsGeoNodeRequest::ServiceLayerDetail> &fetched )
{
layers = fetched;
loop.exit();
} );
fetchLayers();
loop.exec( QEventLoop::ExcludeUserInputEvents );
@@ -293,7 +297,7 @@ QList<QgsGeoNodeRequest::ServiceLayerDetail> QgsGeoNodeRequest::parseLayers( con
{
if ( wmsURLFormat.isEmpty() && wfsURLFormat.isEmpty() && wcsURLFormat.isEmpty() && xyzURLFormat.isEmpty() )
{
bool success = requestBlocking( QStringLiteral( "/api/layers/" ) + layerStruct.id );
bool success = requestBlocking( QStringLiteral( "/api/layers/%1/" ).arg( layerStruct.id ) );
if ( success )
{
const QJsonDocument resourceUriDocument = QJsonDocument::fromJson( this->lastResponse() );
@@ -546,10 +550,10 @@ void QgsGeoNodeRequest::request( const QString &endPoint )

bool QgsGeoNodeRequest::requestBlocking( const QString &endPoint )
{
request( endPoint );

QEventLoop loop;
connect( this, &QgsGeoNodeRequest::requestFinished, &loop, &QEventLoop::quit );

request( endPoint );
loop.exec( QEventLoop::ExcludeUserInputEvents );

return mError.isEmpty();
@@ -284,6 +284,7 @@ class CORE_EXPORT QgsGeoNodeRequest : public QObject

bool mIsAborted = false;
bool mForceRefresh = false;
bool mParsingLayers = false;

QList<QgsGeoNodeRequest::ServiceLayerDetail> parseLayers( const QByteArray &layerResponse );
QgsGeoNodeStyle retrieveStyle( const QString &styleUrl );

0 comments on commit 33f4f1c

Please sign in to comment.