Skip to content

Commit 3d9fca4

Browse files
author
mhugent
committed
prevent crash in QgsRasterLayer::drawMultiBandColor
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5227 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 4e8221d commit 3d9fca4

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/raster/qgsrasterlayer.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -2466,12 +2466,13 @@ void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter, QgsRasterViewPor
24662466

24672467
#ifdef QGISDEBUG
24682468
QPixmap* pm = dynamic_cast<QPixmap*>(theQPainter->device());
2469-
QgsDebugMsg("QgsRasterLayer::drawMultiBandColor: theQPainter stats: ");
2470-
QgsDebugMsg("width = " + QString::number(pm->width()));
2471-
QgsDebugMsg("height = " + QString::number(pm->height()));
2472-
2473-
pm->save("/tmp/qgis-rasterlayer-drawmultibandcolor-test-a.png", "PNG");
2474-
2469+
if(pm)
2470+
{
2471+
QgsDebugMsg("QgsRasterLayer::drawMultiBandColor: theQPainter stats: ");
2472+
QgsDebugMsg("width = " + QString::number(pm->width()));
2473+
QgsDebugMsg("height = " + QString::number(pm->height()));
2474+
pm->save("/tmp/qgis-rasterlayer-drawmultibandcolor-test-a.png", "PNG");
2475+
}
24752476
#endif
24762477

24772478
// \/\/\/ - added to handle zoomed-in rasters
@@ -2514,8 +2515,10 @@ QgsDebugMsg("QgsRasterLayer::drawSingleBandGray: painting image to canvas from s
25142515

25152516
#ifdef QGISDEBUG
25162517
QgsDebugMsg("QgsRasterLayer::drawMultiBandColor: theQPainter->drawImage.");
2517-
pm->save("/tmp/qgis-rasterlayer-drawmultibandcolor-test-b.png", "PNG");
2518-
2518+
if(pm)
2519+
{
2520+
pm->save("/tmp/qgis-rasterlayer-drawmultibandcolor-test-b.png", "PNG");
2521+
}
25192522
#endif
25202523

25212524
//free the scanline memory

0 commit comments

Comments
 (0)