Skip to content

Commit

Permalink
VRT: complementary fix for refs #2018
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Nov 15, 2019
1 parent 71ce9ef commit f80e9b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gdal/frmts/vrt/vrtdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,8 @@ void VRTDataset::BuildVirtualOverviews()
if( !EQUAL(poSource->GetType(), "SimpleSource") &&
!EQUAL(poSource->GetType(), "ComplexSource") )
return false;
GDALRasterBand* poSrcBand = poSource->GetBand();
GDALRasterBand* poSrcBand =
poBand->GetBand() == 0 ? poSource->GetMaskBandMainBand() : poSource->GetBand();
if( poSrcBand == nullptr )
return false;

Expand Down Expand Up @@ -1864,8 +1865,13 @@ void VRTDataset::BuildVirtualOverviews()
}
if( poNewSource )
{
if( poNewSource->GetBand()->GetDataset() )
poNewSource->GetBand()->GetDataset()->Reference();
auto poNewSourceBand = poBand->GetBand() == 0 ?
poNewSource->GetMaskBandMainBand() :
poNewSource->GetBand();
CPLAssert(poNewSourceBand);
auto poNewSourceBandDS = poNewSourceBand->GetDataset();
if( poNewSourceBandDS )
poNewSourceBandDS->Reference();
poOvrVRTBand->AddSource(poNewSource);
}

Expand Down
1 change: 1 addition & 0 deletions gdal/frmts/vrt/vrtdataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ class CPL_DLL VRTSimpleSource : public VRTSource
virtual CPLErr FlushCache() override;

GDALRasterBand* GetBand();
GDALRasterBand* GetMaskBandMainBand() { return m_poMaskBandMainBand; }
int IsSameExceptBandNumber( VRTSimpleSource* poOtherSource );
CPLErr DatasetRasterIO(
GDALDataType eBandDataType,
Expand Down

0 comments on commit f80e9b8

Please sign in to comment.