@@ -238,11 +238,11 @@ QString QgsAmsProvider::metadata()
238238 return dumpVariantMap ( mServiceInfo , tr ( " Service Info" ) ) + dumpVariantMap ( mLayerInfo , tr ( " Layer Info" ) );
239239}
240240
241- QImage* QgsAmsProvider::draw ( const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight )
241+ void QgsAmsProvider::draw ( const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight )
242242{
243243 if ( !mCachedImage .isNull () && mCachedImageExtent == viewExtent )
244244 {
245- return & mCachedImage ;
245+ return ;
246246 }
247247 QgsDataSourceUri dataSource ( dataSourceUri () );
248248
@@ -269,7 +269,7 @@ QImage* QgsAmsProvider::draw( const QgsRectangle & viewExtent, int pixelWidth, i
269269 {
270270 mCachedImage = QImage ();
271271 mCachedImage .fill ( Qt::transparent );
272- return & mCachedImage ;
272+ return ;
273273 }
274274 int level = 0 ;
275275 double resolution = lodEntries.front ().toMap ()[QStringLiteral ( " resolution" )].toDouble ();
@@ -343,7 +343,7 @@ QImage* QgsAmsProvider::draw( const QgsRectangle & viewExtent, int pixelWidth, i
343343 mCachedImage = mCachedImage .convertToFormat ( QImage::Format_ARGB32 );
344344 }
345345 }
346- return & mCachedImage ;
346+ return ;
347347}
348348
349349QImage QgsAmsProvider::getLegendGraphic ( double /* scale*/ , bool forceRefresh, const QgsRectangle * /* visibleExtent*/ )
@@ -442,12 +442,11 @@ void QgsAmsProvider::readBlock( int /*bandNo*/, const QgsRectangle & viewExtent,
442442 Q_UNUSED ( feedback ); // TODO: make use of the feedback object
443443
444444 // TODO: optimize to avoid writing to QImage
445- // returned image is actually mCachedImage, no need to delete
446- QImage *image = draw ( viewExtent, width, height );
447- if ( image->width () != width || image->height () != height )
445+ draw ( viewExtent, width, height );
446+ if ( mCachedImage .width () != width || mCachedImage .height () != height )
448447 {
449448 QgsDebugMsg ( " Unexpected image size for block" );
450449 return ;
451450 }
452- std::memcpy ( data, image-> bits (), image-> bytesPerLine () * image-> height () );
451+ std::memcpy ( data, mCachedImage . constBits (), mCachedImage . bytesPerLine () * mCachedImage . height () );
453452}
0 commit comments