File tree Expand file tree Collapse file tree 5 files changed +24
-13
lines changed Expand file tree Collapse file tree 5 files changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -142,12 +142,6 @@ List of errors that happened during the rendering job - available when the rende
142
142
:rtype: int
143
143
%End
144
144
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
151
145
152
146
const QgsMapSettings &mapSettings() const;
153
147
%Docstring
Original file line number Diff line number Diff line change @@ -64,6 +64,17 @@ void QgsMapRendererJob::setCache( QgsMapRendererCache *cache )
64
64
mCache = cache;
65
65
}
66
66
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
+
67
78
const QgsMapSettings &QgsMapRendererJob::mapSettings () const
68
79
{
69
80
return mSettings ;
@@ -414,7 +425,7 @@ void QgsMapRendererJob::cleanupJobs( LayerRenderJobs &jobs )
414
425
}
415
426
416
427
if ( job.layer )
417
- mPerLayerRenderingTime .insert ( job.layer -> id () , job.renderingTime );
428
+ mPerLayerRenderingTime .insert ( job.layer , job.renderingTime );
418
429
}
419
430
420
431
jobs.clear ();
Original file line number Diff line number Diff line change @@ -206,10 +206,11 @@ class CORE_EXPORT QgsMapRendererJob : public QObject
206
206
int renderingTime () const { return mRenderingTime ; }
207
207
208
208
/* *
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.
210
211
* \since QGIS 3.0
211
212
*/
212
- QMap< QString , int > perLayerRenderingTime () const { return mPerLayerRenderingTime ; }
213
+ QHash< QgsMapLayer * , int > perLayerRenderingTime () const SIP_SKIP;
213
214
214
215
/* *
215
216
* Return map settings with which this job was started.
@@ -249,7 +250,7 @@ class CORE_EXPORT QgsMapRendererJob : public QObject
249
250
int mRenderingTime = 0 ;
250
251
251
252
// ! Render time (in ms) per layer, by layer ID
252
- QMap< QString , int > mPerLayerRenderingTime ;
253
+ QHash< QgsWeakMapLayerPointer , int > mPerLayerRenderingTime ;
253
254
254
255
/* *
255
256
* Prepares the cache for storing the result of labeling. Returns false if
Original file line number Diff line number Diff line change @@ -612,7 +612,12 @@ void QgsMapCanvas::rendererJobFinished()
612
612
613
613
mMap ->setContent ( img, imageRect ( img, mSettings ) );
614
614
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
+ }
616
621
if ( mUsePreviewJobs )
617
622
startPreviewJobs ();
618
623
}
@@ -2284,7 +2289,7 @@ void QgsMapCanvas::startPreviewJob( int number )
2284
2289
context.maxRenderingTimeMs = MAXIMUM_LAYER_PREVIEW_TIME_MS;
2285
2290
for ( QgsMapLayer *layer : layers )
2286
2291
{
2287
- context.lastRenderingTimeMs = mLastLayerRenderTime .value ( layer->id () );
2292
+ context.lastRenderingTimeMs = mLastLayerRenderTime .value ( layer->id (), 0 );
2288
2293
if ( !layer->dataProvider ()->renderInPreview ( context ) )
2289
2294
{
2290
2295
QgsDebugMsgLevel ( QString ( " Layer %1 not rendered because it does not match the renderInPreview criterion %2" ).arg ( layer->id () ).arg ( mLastLayerRenderTime .value ( layer->id () ) ), 3 );
Original file line number Diff line number Diff line change @@ -1000,7 +1000,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
1000
1000
1001
1001
bool mUsePreviewJobs = false ;
1002
1002
1003
- QMap < QString, int > mLastLayerRenderTime ;
1003
+ QHash < QString, int > mLastLayerRenderTime ;
1004
1004
1005
1005
/* *
1006
1006
* Force a resize of the map canvas item
You can’t perform that action at this time.
0 commit comments