File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ class GDALVectorPipelineReadOutputDataset final : public GDALDataset
4949
5050 public:
5151 explicit GDALVectorPipelineReadOutputDataset (GDALDataset &oSrcDS);
52+ ~GDALVectorPipelineReadOutputDataset () override ;
5253
5354 void AddLayer (OGRLayer &oSrcLayer);
5455
@@ -74,10 +75,20 @@ GDALVectorPipelineReadOutputDataset::GDALVectorPipelineReadOutputDataset(
7475 GDALDataset &srcDS)
7576 : m_srcDS(srcDS)
7677{
78+ m_srcDS.Reference ();
7779 SetDescription (m_srcDS.GetDescription ());
7880 poDriver = m_srcDS.GetDriver ();
7981}
8082
83+ /* ***********************************************************************/
84+ /* GDALVectorPipelineReadOutputDataset() */
85+ /* ***********************************************************************/
86+
87+ GDALVectorPipelineReadOutputDataset::~GDALVectorPipelineReadOutputDataset ()
88+ {
89+ m_srcDS.ReleaseRef ();
90+ }
91+
8192/* ***********************************************************************/
8293/* GDALVectorPipelineReadOutputDataset::AddLayer() */
8394/* ***********************************************************************/
Original file line number Diff line number Diff line change @@ -1080,3 +1080,14 @@ def test_gdalalg_vector_pipeline_decorated_ds_take_ref(tmp_vsimem):
10801080 ds = ogr .Open (f"{ tmp_vsimem } /out.shp" )
10811081 lyr = ds .GetLayer (0 )
10821082 assert lyr .GetFeatureCount () == 1
1083+
1084+
1085+ def test_gdalalg_vector_pipeline_read_ds_take_ref (tmp_vsimem ):
1086+
1087+ gdal .alg .vector .pipeline (
1088+ pipeline = f'read ../ogr/data/poly.shp ! read --layer poly ! sql --sql "select * from poly" ! write { tmp_vsimem } /out.shp'
1089+ )
1090+
1091+ ds = ogr .Open (f"{ tmp_vsimem } /out.shp" )
1092+ lyr = ds .GetLayer (0 )
1093+ assert lyr .GetFeatureCount () == 10
You can’t perform that action at this time.
0 commit comments