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

cast from GDALDatasetH to OGRDataSourceH required when constructing gdal::ogr_datasource_unique_ptr #52052

Closed
1 of 2 tasks
justinbb opened this issue Feb 28, 2023 · 0 comments
Closed
1 of 2 tasks
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Build/Install Related to compiling or installing QGIS macOS

Comments

@justinbb
Copy link
Contributor

What is the bug or the crash?

As a result of the GDAL/OGR Unification, GDALOpenEx() is used in a few places in QGIS to obtain an OGRDataSourceH in order to construct an instance of gdal::ogr_datasource_unique_ptr. However, the function's return type is GDALDatasetH. Both are typedefs of void *. Very fussy compilers (e.g. clang on macOS 13 Ventura) do not like this, failing with
qgsspatialiteproviderconnection.cpp:481:35: error: no matching constructor for initialization of 'gdal::ogr_datasource_unique_ptr' (aka 'unique_ptr<OGRDataSourceHS, gdal::OGRDataSourceDeleter>') :info:build gdal::ogr_datasource_unique_ptr hDS( GDALOpenEx( pathFromUri().toUtf8().constData(), GDAL_OF_VECTOR | GDAL_OF_UPDATE, nullptr, nullptr, nullptr ) ); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk/usr/include/c++/v1/__memory/unique_ptr.h:121:59: note: candidate constructor (the implicit copy constructor) not viable: cannot convert argument of incomplete type 'GDALDatasetH' (aka 'void *') to 'const std::unique_ptr<OGRDataSourceHS, gdal::OGRDataSourceDeleter>' for 1st argument

One way of fixing the problem is to cast the return value of GDALOpenEx() to OGRDataSourceH in the following files:
src/core/providers/ogr/qgsgeopackagedataitems.cpp
src/core/providers/ogr/qgsogrproviderconnection.cpp
src/providers/spatialite/qgsspatialiteproviderconnection.cpp

There may be a better way: I am not particularly familiar with the code.

Steps to reproduce the issue

This is a compile-time error.

Versions

3.28.3 (and previous)

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

Using MacPorts to compile and install.
macOS 13.2.1 Ventura, Xcode 14.2, clang 14.0.0, macOS 13 SDK

@justinbb justinbb added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Feb 28, 2023
@elpaso elpaso added the macOS label Mar 1, 2023
@agiudiceandrea agiudiceandrea added the Build/Install Related to compiling or installing QGIS label Mar 1, 2023
@rouault rouault self-assigned this Mar 10, 2023
rouault added a commit to rouault/QGIS that referenced this issue Mar 10, 2023
…gis#52052)

This avoids an implicit case from OGRDataSourceH to GDALDatasetH, that
doesn't work with all compilers
rouault added a commit to rouault/QGIS that referenced this issue Mar 10, 2023
…gis#52052)

This avoids an implicit case from OGRDataSourceH to GDALDatasetH, that
doesn't work with all compilers
qgis-bot pushed a commit that referenced this issue Mar 13, 2023
…52052)

This avoids an implicit case from OGRDataSourceH to GDALDatasetH, that
doesn't work with all compilers
rouault added a commit to rouault/QGIS that referenced this issue Mar 13, 2023
…gis#52052)

This avoids an implicit case from OGRDataSourceH to GDALDatasetH, that
doesn't work with all compilers
nyalldawson pushed a commit that referenced this issue Mar 13, 2023
…52052)

This avoids an implicit case from OGRDataSourceH to GDALDatasetH, that
doesn't work with all compilers
nyalldawson pushed a commit that referenced this issue Mar 13, 2023
…52052)

This avoids an implicit case from OGRDataSourceH to GDALDatasetH, that
doesn't work with all compilers
m-kuhn pushed a commit to m-kuhn/QGIS that referenced this issue Mar 31, 2023
…gis#52052)

This avoids an implicit case from OGRDataSourceH to GDALDatasetH, that
doesn't work with all compilers
nyalldawson pushed a commit that referenced this issue Apr 1, 2023
…52052)

This avoids an implicit case from OGRDataSourceH to GDALDatasetH, that
doesn't work with all compilers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Build/Install Related to compiling or installing QGIS macOS
Projects
None yet
Development

No branches or pull requests

4 participants