Skip to content

Commit

Permalink
VRT: complementary fix for refs OSGeo#2018
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Nov 15, 2019
1 parent e9627bf commit 1552310
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 @@ -1867,7 +1867,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 @@ -1950,8 +1951,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 @@ -952,6 +952,7 @@ class CPL_DLL VRTSimpleSource CPL_NON_FINAL: 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 1552310

Please sign in to comment.