28 QMutexLocker lock( &mMutex );
32 void QgsMapRendererCache::clearInternal()
38 const auto constMConnectedLayers = mConnectedLayers;
47 mCachedImages.clear();
48 mConnectedLayers.clear();
51 void QgsMapRendererCache::dropUnusedConnections()
54 QSet< QgsWeakMapLayerPointer > disconnects = mConnectedLayers.subtract( stillDepends );
55 const auto constDisconnects = disconnects;
65 mConnectedLayers = stillDepends;
70 QSet< QgsWeakMapLayerPointer > result;
71 QMap<QString, CacheParameters>::const_iterator it = mCachedImages.constBegin();
72 for ( ; it != mCachedImages.constEnd(); ++it )
86 QMutexLocker lock( &mMutex );
89 if ( extent == mExtent &&
104 QMutexLocker lock( &mMutex );
106 CacheParameters params;
107 params.cachedImage = image;
110 const auto constDependentLayers = dependentLayers;
115 params.dependentLayers << layer;
120 mConnectedLayers << layer;
125 mCachedImages[cacheKey] = params;
130 return mCachedImages.contains( cacheKey );
135 QMutexLocker lock( &mMutex );
136 return mCachedImages.value( cacheKey ).cachedImage;
141 if ( mCachedImages.contains( cacheKey ) )
143 return _qgis_listQPointerToRaw( mCachedImages.value( cacheKey ).dependentLayers );
145 return QList< QgsMapLayer * >();
149 void QgsMapRendererCache::layerRequestedRepaint()
151 QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( sender() );
160 QMutexLocker lock( &mMutex );
163 QMap<QString, CacheParameters>::iterator it = mCachedImages.begin();
164 for ( ; it != mCachedImages.end(); )
166 if ( !it.value().dependentLayers.contains( layer ) )
172 it = mCachedImages.erase( it );
174 dropUnusedConnections();
179 QMutexLocker lock( &mMutex );
181 mCachedImages.remove( cacheKey );
182 dropUnusedConnections();