Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RFC 91 text: GDALDataset::Close() method #7108

Merged
merged 3 commits into from Jan 30, 2023
Merged

Conversation

rouault
Copy link
Member

@rouault rouault commented Jan 20, 2023

@jjimenezshaw
Copy link
Contributor

Thanks @rouault . I was one of those that used the ugly hacky error detection.

Copy link
Member

@schwehr schwehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! Some minor suggestions that are just polish.

doc/source/development/rfc/rfc91_dataset_close.rst Outdated Show resolved Hide resolved
doc/source/development/rfc/rfc91_dataset_close.rst Outdated Show resolved Hide resolved
doc/source/development/rfc/rfc91_dataset_close.rst Outdated Show resolved Hide resolved
doc/source/development/rfc/rfc91_dataset_close.rst Outdated Show resolved Hide resolved
doc/source/development/rfc/rfc91_dataset_close.rst Outdated Show resolved Hide resolved
-------------

The destructor of gdal.Dataset is modified to test the return value of GDALClose()
and emits a CPLError(CE_Failure, ...) if the error state is clean (normally
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is clean -> is not clean ??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the current formulation is intended. See commit rouault@c3c37ea
This is to make sure that the gdal.UseExceptions() mode throws an exception. It needs CPLGetLastErrorType() == CE_Failure, so if GDALClose() != CE_None and CPLGetLastErrorType() == CE_None, we issue a CPLError(CE_Failure, ...)

doc/source/development/rfc/rfc91_dataset_close.rst Outdated Show resolved Hide resolved
doc/source/development/rfc/rfc91_dataset_close.rst Outdated Show resolved Hide resolved
@mloskot
Copy link
Member

mloskot commented Jan 21, 2023

It looks good to me.

A minor addition to the example to push it to safer side

MyDataset::~MyDataset()
{
   try {
      MyDataset::Close();
   } catch (...) {
      // swallow error, optionally log it but ensure the action never throws
   }
}

@rouault
Copy link
Member Author

rouault commented Jan 21, 2023

A minor addition to the example to push it to safer side

added

@rouault rouault merged commit e70164a into OSGeo:master Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants