Skip to content

Commit 38cca6c

Browse files
committedDec 4, 2017
Tweak API
1 parent be95458 commit 38cca6c

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed
 

‎python/core/qgsmaprendererjob.sip

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,6 @@ List of errors that happened during the rendering job - available when the rende
142142
:rtype: int
143143
%End
144144

145-
QMap< QString, int > perLayerRenderingTime() const;
146-
%Docstring
147-
Returns the render time (in ms) per layer, by layer ID.
148-
.. versionadded:: 3.0
149-
:rtype: QMap< str, int >
150-
%End
151145

152146
const QgsMapSettings &mapSettings() const;
153147
%Docstring

‎src/core/qgsmaprendererjob.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ void QgsMapRendererJob::setCache( QgsMapRendererCache *cache )
6464
mCache = cache;
6565
}
6666

67+
QHash<QgsMapLayer *, int> QgsMapRendererJob::perLayerRenderingTime() const
68+
{
69+
QHash<QgsMapLayer *, int> result;
70+
for ( auto it = mPerLayerRenderingTime.constBegin(); it != mPerLayerRenderingTime.constEnd(); ++it )
71+
{
72+
if ( it.key() )
73+
result.insert( it.key(), it.value() );
74+
}
75+
return result;
76+
}
77+
6778
const QgsMapSettings &QgsMapRendererJob::mapSettings() const
6879
{
6980
return mSettings;
@@ -414,7 +425,7 @@ void QgsMapRendererJob::cleanupJobs( LayerRenderJobs &jobs )
414425
}
415426

416427
if ( job.layer )
417-
mPerLayerRenderingTime.insert( job.layer->id(), job.renderingTime );
428+
mPerLayerRenderingTime.insert( job.layer, job.renderingTime );
418429
}
419430

420431
jobs.clear();

‎src/core/qgsmaprendererjob.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,11 @@ class CORE_EXPORT QgsMapRendererJob : public QObject
206206
int renderingTime() const { return mRenderingTime; }
207207

208208
/**
209-
* Returns the render time (in ms) per layer, by layer ID.
209+
* Returns the render time (in ms) per layer.
210+
* \note Not available in Python bindings.
210211
* \since QGIS 3.0
211212
*/
212-
QMap< QString, int > perLayerRenderingTime() const { return mPerLayerRenderingTime; }
213+
QHash< QgsMapLayer *, int > perLayerRenderingTime() const SIP_SKIP;
213214

214215
/**
215216
* Return map settings with which this job was started.
@@ -249,7 +250,7 @@ class CORE_EXPORT QgsMapRendererJob : public QObject
249250
int mRenderingTime = 0;
250251

251252
//! Render time (in ms) per layer, by layer ID
252-
QMap< QString, int > mPerLayerRenderingTime;
253+
QHash< QgsWeakMapLayerPointer, int > mPerLayerRenderingTime;
253254

254255
/**
255256
* Prepares the cache for storing the result of labeling. Returns false if

‎src/gui/qgsmapcanvas.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,12 @@ void QgsMapCanvas::rendererJobFinished()
612612

613613
mMap->setContent( img, imageRect( img, mSettings ) );
614614

615-
mLastLayerRenderTime = mJob->perLayerRenderingTime();
615+
mLastLayerRenderTime.clear();
616+
const auto times = mJob->perLayerRenderingTime();
617+
for ( auto it = times.constBegin(); it != times.constEnd(); ++it )
618+
{
619+
mLastLayerRenderTime.insert( it.key()->id(), it.value() );
620+
}
616621
if ( mUsePreviewJobs )
617622
startPreviewJobs();
618623
}
@@ -2284,7 +2289,7 @@ void QgsMapCanvas::startPreviewJob( int number )
22842289
context.maxRenderingTimeMs = MAXIMUM_LAYER_PREVIEW_TIME_MS;
22852290
for ( QgsMapLayer *layer : layers )
22862291
{
2287-
context.lastRenderingTimeMs = mLastLayerRenderTime.value( layer->id() );
2292+
context.lastRenderingTimeMs = mLastLayerRenderTime.value( layer->id(), 0 );
22882293
if ( !layer->dataProvider()->renderInPreview( context ) )
22892294
{
22902295
QgsDebugMsgLevel( QString( "Layer %1 not rendered because it does not match the renderInPreview criterion %2" ).arg( layer->id() ).arg( mLastLayerRenderTime.value( layer->id() ) ), 3 );

‎src/gui/qgsmapcanvas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
10001000

10011001
bool mUsePreviewJobs = false;
10021002

1003-
QMap< QString, int > mLastLayerRenderTime;
1003+
QHash< QString, int > mLastLayerRenderTime;
10041004

10051005
/**
10061006
* Force a resize of the map canvas item

0 commit comments

Comments
 (0)
Please sign in to comment.