Skip to content
Permalink
Browse files
do not render when map settings are invalid
  • Loading branch information
vcloarec authored and nyalldawson committed May 31, 2021
1 parent 09b5ba4 commit 3d31477750e59e3ce734b886f8ee9168c61acc4a
@@ -58,8 +58,6 @@ platforms).
QgsMapRendererCustomPainterJob( const QgsMapSettings &settings, QPainter *painter );
~QgsMapRendererCustomPainterJob();

virtual void start();

virtual void cancel();

virtual void cancelWithoutBlocking();
@@ -125,6 +123,7 @@ and an alternative to :py:func:`~QgsMapRendererCustomPainterJob.renderSynchronou
.. versionadded:: 3.10
%End


};


@@ -49,7 +49,7 @@ The following subclasses are available:

QgsMapRendererJob( const QgsMapSettings &settings );

virtual void start() = 0;
void start();
%Docstring
Start the rendering job and immediately return.
Does nothing if the rendering is already in progress.
@@ -26,8 +26,6 @@ It is safe to call that function while rendering is active to see preview of the
QgsMapRendererParallelJob( const QgsMapSettings &settings );
~QgsMapRendererParallelJob();

virtual void start();

virtual void cancel();

virtual void cancelWithoutBlocking();
@@ -27,8 +27,6 @@ It is safe to call that function while rendering is active to see preview of the
QgsMapRendererSequentialJob( const QgsMapSettings &settings );
~QgsMapRendererSequentialJob();

virtual void start();

virtual void cancel();

virtual void cancelWithoutBlocking();
@@ -75,7 +75,7 @@ QgsMapRendererCustomPainterJob::~QgsMapRendererCustomPainterJob()
//cancel();
}

void QgsMapRendererCustomPainterJob::start()
void QgsMapRendererCustomPainterJob::startPrivate()
{
if ( isActive() )
return;
@@ -67,7 +67,6 @@ class CORE_EXPORT QgsMapRendererCustomPainterJob : public QgsMapRendererAbstract
QgsMapRendererCustomPainterJob( const QgsMapSettings &settings, QPainter *painter );
~QgsMapRendererCustomPainterJob() override;

void start() override;
void cancel() override;
void cancelWithoutBlocking() override;
void waitForFinished() override;
@@ -128,12 +127,15 @@ class CORE_EXPORT QgsMapRendererCustomPainterJob : public QgsMapRendererAbstract
*/
void renderPrepared();


private slots:
void futureFinished();

private:
static void staticRender( QgsMapRendererCustomPainterJob *self ); // function to be used within the thread

void startPrivate() override;

// these methods are called within worker thread
void doRender();

@@ -70,11 +70,19 @@ bool LayerRenderJob::imageCanBeComposed() const

QgsMapRendererJob::QgsMapRendererJob( const QgsMapSettings &settings )
: mSettings( settings )
{}

void QgsMapRendererJob::start()
{
if ( mSettings.hasValidSettings() )
startPrivate();
else
{
mErrors.append( QgsMapRendererJob::Error( QString(), tr( "Invalid map settings" ) ) );
emit finished();
}
}


QgsMapRendererQImageJob::QgsMapRendererQImageJob( const QgsMapSettings &settings )
: QgsMapRendererJob( settings )
{
@@ -221,7 +221,7 @@ class CORE_EXPORT QgsMapRendererJob : public QObject
* Start the rendering job and immediately return.
* Does nothing if the rendering is already in progress.
*/
virtual void start() = 0;
void start();

/**
* Stop the rendering job - does not return until the job has terminated.
@@ -490,6 +490,14 @@ class CORE_EXPORT QgsMapRendererJob : public QObject

//! Convenient method to allocate a new image and a new QPainter on this image
QPainter *allocateImageAndPainter( QString layerId, QImage *&image );

/**
* This virtual method has to be implemented in derived class for starting the rendering.
* This method is called in start() method after ckecking if the map can be rendered.
* \since QGIS 3.20
*/
virtual void startPrivate() {};

};


@@ -40,7 +40,7 @@ QgsMapRendererParallelJob::~QgsMapRendererParallelJob()
}
}

void QgsMapRendererParallelJob::start()
void QgsMapRendererParallelJob::startPrivate()
{
if ( isActive() )
return;
@@ -36,7 +36,6 @@ class CORE_EXPORT QgsMapRendererParallelJob : public QgsMapRendererQImageJob
QgsMapRendererParallelJob( const QgsMapSettings &settings );
~QgsMapRendererParallelJob() override;

void start() override;
void cancel() override;
void cancelWithoutBlocking() override;
void waitForFinished() override;
@@ -63,6 +62,8 @@ class CORE_EXPORT QgsMapRendererParallelJob : public QgsMapRendererQImageJob
//! \note not available in Python bindings
static void renderLabelsStatic( QgsMapRendererParallelJob *self ) SIP_SKIP;

void startPrivate() override;

QImage mFinalImage;

//! \note not available in Python bindings
@@ -47,7 +47,7 @@ QgsMapRendererSequentialJob::~QgsMapRendererSequentialJob()
}


void QgsMapRendererSequentialJob::start()
void QgsMapRendererSequentialJob::startPrivate()
{
if ( isActive() )
return; // do nothing if we are already running
@@ -37,7 +37,6 @@ class CORE_EXPORT QgsMapRendererSequentialJob : public QgsMapRendererQImageJob
QgsMapRendererSequentialJob( const QgsMapSettings &settings );
~QgsMapRendererSequentialJob() override;

void start() override;
void cancel() override;
void cancelWithoutBlocking() override;
void waitForFinished() override;
@@ -55,6 +54,8 @@ class CORE_EXPORT QgsMapRendererSequentialJob : public QgsMapRendererQImageJob

private:

void startPrivate() override;

QgsMapRendererCustomPainterJob *mInternalJob = nullptr;
QImage mImage;
QPainter *mPainter = nullptr;
@@ -36,7 +36,7 @@ QgsMapRendererStagedRenderJob::~QgsMapRendererStagedRenderJob()
}


void QgsMapRendererStagedRenderJob::start()
void QgsMapRendererStagedRenderJob::startPrivate()
{
mRenderingStart.start();
mErrors.clear();
@@ -62,7 +62,6 @@ class CORE_EXPORT QgsMapRendererStagedRenderJob : public QgsMapRendererAbstractC
QgsMapRendererStagedRenderJob( const QgsMapSettings &settings, Flags flags = Flags() );
~QgsMapRendererStagedRenderJob() override;

void start() override;
void cancel() override;
void cancelWithoutBlocking() override;
void waitForFinished() override;
@@ -116,6 +115,8 @@ class CORE_EXPORT QgsMapRendererStagedRenderJob : public QgsMapRendererAbstractC

private:

void startPrivate() override;

std::unique_ptr< QgsLabelingEngine > mLabelingEngineV2;

LayerRenderJobs mLayerJobs;

0 comments on commit 3d31477

Please sign in to comment.