File tree Expand file tree Collapse file tree 2 files changed +29
-10
lines changed
Expand file tree Collapse file tree 2 files changed +29
-10
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,8 @@ class CPL_DLL GDALPamDataset : public GDALDataset
137137 public:
138138 ~GDALPamDataset () override ;
139139
140+ CPLErr Close () override ;
141+
140142 CPLErr FlushCache (bool bAtClosing) override ;
141143
142144 const OGRSpatialReference *GetSpatialRef () const override ;
Original file line number Diff line number Diff line change @@ -148,20 +148,37 @@ GDALPamDataset::GDALPamDataset()
148148GDALPamDataset::~GDALPamDataset ()
149149
150150{
151- if (IsMarkedSuppressOnClose ())
152- {
153- if (psPam && psPam->pszPamFilename != nullptr )
154- VSIUnlink (psPam->pszPamFilename );
155- }
156- else if (nPamFlags & GPF_DIRTY)
157- {
158- CPLDebug (" GDALPamDataset" , " In destructor with dirty metadata." );
159- GDALPamDataset::TrySaveXML ();
160- }
151+ GDALPamDataset::Close ();
161152
162153 PamClear ();
163154}
164155
156+ /* ***********************************************************************/
157+ /* Close() */
158+ /* ***********************************************************************/
159+
160+ CPLErr GDALPamDataset::Close ()
161+ {
162+ CPLErr eErr = CE_None;
163+ if (nOpenFlags != OPEN_FLAGS_CLOSED)
164+ {
165+ if (IsMarkedSuppressOnClose ())
166+ {
167+ if (psPam && psPam->pszPamFilename != nullptr )
168+ VSIUnlink (psPam->pszPamFilename );
169+ }
170+ else if (nPamFlags & GPF_DIRTY)
171+ {
172+ CPLDebug (" GDALPamDataset" , " In Close() with dirty metadata." );
173+ eErr = GDALPamDataset::TrySaveXML ();
174+ }
175+
176+ if (GDALDataset::Close () != CE_None)
177+ eErr = CE_Failure;
178+ }
179+ return eErr;
180+ }
181+
165182/* ***********************************************************************/
166183/* FlushCache() */
167184/* ***********************************************************************/
You can’t perform that action at this time.
0 commit comments