Skip to content
Permalink
Browse files

Use QgsMapRendererJob::Errors instead of QList< QPair >

  • Loading branch information
mhugent committed Jan 18, 2019
1 parent 0f3c39d commit 575d385e57647b0419f32f1ef9affe3d417b7594
@@ -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:

@@ -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()
@@ -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:

@@ -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();

@@ -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
@@ -67,7 +67,7 @@ namespace QgsWms
*image = renderJob.renderedImage();
mPainter.reset( new QPainter( image ) );

getRenderErrors( &renderJob );
mErrors = renderJob.errors();
}
else
{
@@ -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
@@ -19,6 +19,7 @@
#define QGSMAPRENDERERJOBPROXY_H

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

class QgsFeatureFilterProvider;

@@ -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;
@@ -71,7 +76,7 @@ namespace QgsWms
void getRenderErrors( const QgsMapRendererJob *job );

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


@@ -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 );

0 comments on commit 575d385

Please sign in to comment.
You can’t perform that action at this time.