Prevent segfault when no bands are selected for the histogram.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@3034 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2005-03-26 09:47:58 +00:00
parent 27ce9003cf
commit 205628a09a

View File

@ -909,6 +909,30 @@ void QgsRasterLayerProperties::pbnHistRefresh_clicked()
#ifdef QGISDEBUG
std::cout << "QgsRasterLayerProperties::pbnHistRefresh_clicked" << std::endl;
#endif
int myBandCountInt = rasterLayer->getBandCount();
//
// Find out how many bands are selected and short circuit out clearing the image
// if needed
int mySelectionCount=0;
for (int myIteratorInt = 1;
myIteratorInt <= myBandCountInt;
++myIteratorInt)
{
RasterBandStats myRasterBandStats = rasterLayer->getRasterBandStats(myIteratorInt);
QListBoxItem *myItem = lstHistogramLabels->item( myIteratorInt-1 );
if ( myItem->isSelected() )
{
mySelectionCount++;
}
}
if (mySelectionCount==0)
{
int myImageWidth = pixHistogram->width();
int myImageHeight = pixHistogram->height();
QPixmap myPixmap(myImageWidth,myImageHeight);
myPixmap.fill(Qt::white);
pixHistogram->setPixmap(myPixmap);
}
// Explanation:
// We use the gdal histogram creation routine is called for each selected
@ -926,7 +950,6 @@ void QgsRasterLayerProperties::pbnHistRefresh_clicked()
bool myIgnoreOutOfRangeFlag = chkHistIgnoreOutOfRange->isChecked();
bool myThoroughBandScanFlag = chkHistAllowApproximation->isChecked();
int myBandCountInt = rasterLayer->getBandCount();
long myCellCount = rasterLayer->getRasterXDim() * rasterLayer->getRasterYDim();