Skip to content

Commit

Permalink
Use QgsMapRendererJob::Errors instead of QList< QPair >
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jan 18, 2019
1 parent 0f3c39d commit 575d385
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 46 deletions.
5 changes: 5 additions & 0 deletions python/core/auto_generated/layout/qgslayoutitemmap.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,11 @@ in the area of the map item covered by the item.
.. versionadded:: 3.6
%End

QgsMapRendererJob::Errors renderingErrors() const;
%Docstring
renderingErrors
@return list of layer id / error message
%End

protected:

Expand Down
8 changes: 1 addition & 7 deletions src/core/layout/qgslayoutitemmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,13 +1021,7 @@ void QgsLayoutItemMap::drawMap( QPainter *painter, const QgsRectangle &extent, Q
// Raster images were not displayed - see #10599
job.renderSynchronously();

mRenderingErrors.clear();
QgsMapRendererJob::Errors e = job.errors();
QgsMapRendererJob::Errors::const_iterator eIt = e.constBegin();
for ( ; eIt != e.constEnd(); ++eIt )
{
mRenderingErrors.append( qMakePair( eIt->layerID, eIt->message ) );
}
mRenderingErrors = job.errors();
}

void QgsLayoutItemMap::recreateCachedImageInBackground()
Expand Down
4 changes: 2 additions & 2 deletions src/core/layout/qgslayoutitemmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ class CORE_EXPORT QgsLayoutItemMap : public QgsLayoutItem
* @brief renderingErrors
* @return list of layer id / error message
*/
const QList< QPair< QString, QString > > &renderingErrors() const SIP_SKIP { return mRenderingErrors; }
QgsMapRendererJob::Errors renderingErrors() const { return mRenderingErrors; }

protected:

Expand Down Expand Up @@ -733,7 +733,7 @@ class CORE_EXPORT QgsLayoutItemMap : public QgsLayoutItem
QList< QPointer< QgsLayoutItem > > mBlockingLabelItems;

//!layer id / error message
QList< QPair< QString, QString > > mRenderingErrors;
QgsMapRendererJob::Errors mRenderingErrors;

void init();

Expand Down
36 changes: 21 additions & 15 deletions src/server/qgsstorebadlayerinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,29 @@
*/
class QgsStoreBadLayerInfo: public QgsProjectBadLayerHandler
{
public:
QgsStoreBadLayerInfo();
~QgsStoreBadLayerInfo();
/**
* @brief handleBadLayers
* @param layers layer nodes
*/
void handleBadLayers( const QList<QDomNode> &layers );
public:
/*Default constructor
*/
QgsStoreBadLayerInfo();

/**
* @brief badLayers
* @return ids of bad layers
*/
QStringList badLayers() const { return mBadLayerIds; }
/*Destructor
*/
~QgsStoreBadLayerInfo();

private:
QStringList mBadLayerIds;
/**
* @brief handleBadLayers
* @param layers layer nodes
*/
void handleBadLayers( const QList<QDomNode> &layers );

/**
* @brief badLayers
* @return ids of bad layers
*/
QStringList badLayers() const { return mBadLayerIds; }

private:
QStringList mBadLayerIds;
};

#endif // QGSSTOREBADLAYERINFO_H
21 changes: 2 additions & 19 deletions src/server/services/wms/qgsmaprendererjobproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace QgsWms
*image = renderJob.renderedImage();
mPainter.reset( new QPainter( image ) );

getRenderErrors( &renderJob );
mErrors = renderJob.errors();
}
else
{
Expand All @@ -77,29 +77,12 @@ namespace QgsWms
renderJob.setFeatureFilterProvider( mFeatureFilterProvider );
#endif
renderJob.renderSynchronously();
getRenderErrors( &renderJob );
mErrors = renderJob.errors();
}
}

QPainter *QgsMapRendererJobProxy::takePainter()
{
return mPainter.release();
}

void QgsMapRendererJobProxy::getRenderErrors( const QgsMapRendererJob *job )
{
if ( !job )
{
return;
}

mErrors.clear();
QgsMapRendererJob::Errors e = job->errors();
QgsMapRendererJob::Errors::const_iterator eIt = e.constBegin();
for ( ; eIt != e.constEnd(); ++eIt )
{
mErrors.append( qMakePair( eIt->layerID, eIt->message ) );
}
}

} // namespace qgsws
9 changes: 7 additions & 2 deletions src/server/services/wms/qgsmaprendererjobproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define QGSMAPRENDERERJOBPROXY_H

#include "qgsmapsettings.h"
#include "qgsmaprendererjob.h"

class QgsFeatureFilterProvider;

Expand Down Expand Up @@ -61,7 +62,11 @@ namespace QgsWms
*/
QPainter *takePainter();

const QList< QPair< QString, QString > > &errors() const { return mErrors; }
/**
* @brief Returns reported errors
* @return error list
*/
QgsMapRendererJob::Errors errors() const { return mErrors; }

private:
bool mParallelRendering;
Expand All @@ -71,7 +76,7 @@ namespace QgsWms
void getRenderErrors( const QgsMapRendererJob *job );

//! Layer id / error message
QList< QPair< QString, QString > > mErrors;
QgsMapRendererJob::Errors mErrors;
};


Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2930,7 +2930,7 @@ namespace QgsWms
if ( !renderJob.errors().isEmpty() )
{
QString layerWMSName;
QgsMapLayer *errorLayer = mProject->mapLayer( renderJob.errors().at( 0 ).first );
QgsMapLayer *errorLayer = mProject->mapLayer( renderJob.errors().at( 0 ).layerID );
if ( errorLayer )
{
layerWMSName = layerNickname( *errorLayer );
Expand Down

0 comments on commit 575d385

Please sign in to comment.