aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsnowman2 <alansnow21@gmail.com>2020-08-16 19:40:00 -0500
committersnowman2 <alansnow21@gmail.com>2020-08-19 08:06:18 -0500
commit8c41cfc3a714c532183a0c3542f86609ea1bc8ac (patch)
treeabc36ab0c95a5daa57bdd319764e7f7b728f9cfa /src
parent84713021edf688c9cf157562d34388583325aa45 (diff)
downloadPROJ-8c41cfc3a714c532183a0c3542f86609ea1bc8ac.tar.gz
PROJ-8c41cfc3a714c532183a0c3542f86609ea1bc8ac.zip
Add methods to ensure safer interactions with cpp_context
Diffstat (limited to 'src')
-rw-r--r--src/ctx.cpp24
-rw-r--r--src/filemanager.cpp5
-rw-r--r--src/iso19111/c_api.cpp178
-rw-r--r--src/proj_internal.h2
4 files changed, 90 insertions, 119 deletions
diff --git a/src/ctx.cpp b/src/ctx.cpp
index 930ae9ea..c2b30644 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -113,6 +113,30 @@ projCtx_t projCtx_t::createDefault()
return ctx;
}
+/**************************************************************************/
+/* get_cpp_context() */
+/**************************************************************************/
+
+projCppContext* projCtx_t::get_cpp_context()
+{
+ if (cpp_context == nullptr) {
+ cpp_context = new projCppContext(this);
+ }
+ return cpp_context;
+}
+
+
+/**************************************************************************/
+/* safeAutoCloseDbIfNeeded() */
+/**************************************************************************/
+
+void projCtx_t::safeAutoCloseDbIfNeeded()
+{
+ if (cpp_context) {
+ cpp_context->autoCloseDbIfNeeded();
+ }
+}
+
/************************************************************************/
/* set_search_paths() */
/************************************************************************/
diff --git a/src/filemanager.cpp b/src/filemanager.cpp
index 29e85fbc..db0aa2ee 100644
--- a/src/filemanager.cpp
+++ b/src/filemanager.cpp
@@ -1627,10 +1627,7 @@ static void *pj_open_file_with_manager(projCtx ctx, const char *name,
static NS_PROJ::io::DatabaseContextPtr getDBcontext(PJ_CONTEXT *ctx) {
try {
- if (ctx->cpp_context == nullptr) {
- ctx->cpp_context = new projCppContext(ctx);
- }
- return ctx->cpp_context->getDatabaseContext().as_nullable();
+ return ctx->get_cpp_context()->getDatabaseContext().as_nullable();
} catch (const std::exception &e) {
pj_log(ctx, PJ_LOG_DEBUG, "%s", e.what());
return nullptr;
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp
index 947be058..6e07e54c 100644
--- a/src/iso19111/c_api.cpp
+++ b/src/iso19111/c_api.cpp
@@ -162,10 +162,7 @@ NS_PROJ::io::DatabaseContextNNPtr projCppContext::getDatabaseContext() {
// ---------------------------------------------------------------------------
static PROJ_NO_INLINE DatabaseContextNNPtr getDBcontext(PJ_CONTEXT *ctx) {
- if (ctx->cpp_context == nullptr) {
- ctx->cpp_context = new projCppContext(ctx);
- }
- return ctx->cpp_context->getDatabaseContext();
+ return ctx->get_cpp_context()->getDatabaseContext();
}
// ---------------------------------------------------------------------------
@@ -196,9 +193,7 @@ static PJ *pj_obj_create(PJ_CONTEXT *ctx, const IdentifiedObjectNNPtr &objIn) {
ctx->defer_grid_opening = false;
if (pj) {
pj->iso_obj = objIn;
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return pj;
}
} catch (const std::exception &) {
@@ -212,9 +207,7 @@ static PJ *pj_obj_create(PJ_CONTEXT *ctx, const IdentifiedObjectNNPtr &objIn) {
pj->descr = "ISO-19111 object";
pj->iso_obj = objIn;
}
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return pj;
}
//! @endcond
@@ -266,10 +259,7 @@ PJ_OBJ_LIST::~PJ_OBJ_LIST() = default;
*/
void proj_context_set_autoclose_database(PJ_CONTEXT *ctx, int autoclose) {
SANITIZE_CTX(ctx);
- if (ctx->cpp_context == nullptr) {
- ctx->cpp_context = new projCppContext(ctx);
- }
- ctx->cpp_context->setAutoCloseDb(autoclose != FALSE);
+ ctx->get_cpp_context()->setAutoCloseDb(autoclose != FALSE);
}
// ---------------------------------------------------------------------------
@@ -305,7 +295,7 @@ int proj_context_set_database_path(PJ_CONTEXT *ctx, const char *dbPath,
ctx, dbPath, projCppContext::toVector(auxDbPaths));
ctx->cpp_context->setAutoCloseDb(autoCloseDb);
ctx->cpp_context->getDatabaseContext();
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return true;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
@@ -333,8 +323,8 @@ const char *proj_context_get_database_path(PJ_CONTEXT *ctx) {
// temporary variable must be used as getDBcontext() might create
// ctx->cpp_context
auto osPath(getDBcontext(ctx)->getPath());
- ctx->cpp_context->lastDbPath_ = osPath;
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->get_cpp_context()->lastDbPath_ = osPath;
+ ctx->safeAutoCloseDbIfNeeded();
return ctx->cpp_context->lastDbPath_.c_str();
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
@@ -365,11 +355,11 @@ const char *proj_context_get_database_metadata(PJ_CONTEXT *ctx,
// ctx->cpp_context
auto osVal(getDBcontext(ctx)->getMetadata(key));
if (osVal == nullptr) {
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
- ctx->cpp_context->lastDbMetadataItem_ = osVal;
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->get_cpp_context()->lastDbMetadataItem_ = osVal;
+ ctx->safeAutoCloseDbIfNeeded();
return ctx->cpp_context->lastDbMetadataItem_.c_str();
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
@@ -488,9 +478,7 @@ PJ *proj_create(PJ_CONTEXT *ctx, const char *text) {
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -634,9 +622,7 @@ PJ *proj_create_from_wkt(PJ_CONTEXT *ctx, const char *wkt,
proj_log_error(ctx, __FUNCTION__, e.what());
}
}
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -697,7 +683,7 @@ PJ *proj_create_from_database(PJ_CONTEXT *ctx, const char *auth_name,
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -773,7 +759,7 @@ int proj_uom_get_info_from_database(PJ_CONTEXT *ctx, const char *auth_name,
auto factory = AuthorityFactory::create(getDBcontext(ctx), auth_name);
auto obj = factory->createUnitOfMeasure(code);
if (out_name) {
- ctx->cpp_context->lastUOMName_ = obj->name();
+ ctx->get_cpp_context()->lastUOMName_ = obj->name();
*out_name = ctx->cpp_context->lastUOMName_.c_str();
}
if (out_conv_factor) {
@@ -782,12 +768,12 @@ int proj_uom_get_info_from_database(PJ_CONTEXT *ctx, const char *auth_name,
if (out_category) {
*out_category = get_unit_category(obj->name(), obj->type());
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return true;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return false;
}
@@ -827,20 +813,20 @@ int PROJ_DLL proj_grid_get_info_from_database(
bool open_license;
bool available;
if (!db_context->lookForGridInfo(
- grid_name, false, ctx->cpp_context->lastGridFullName_,
- ctx->cpp_context->lastGridPackageName_,
- ctx->cpp_context->lastGridUrl_, direct_download, open_license,
+ grid_name, false, ctx->get_cpp_context()->lastGridFullName_,
+ ctx->get_cpp_context()->lastGridPackageName_,
+ ctx->get_cpp_context()->lastGridUrl_, direct_download, open_license,
available)) {
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return false;
}
if (out_full_name)
- *out_full_name = ctx->cpp_context->lastGridFullName_.c_str();
+ *out_full_name = ctx->get_cpp_context()->lastGridFullName_.c_str();
if (out_package_name)
- *out_package_name = ctx->cpp_context->lastGridPackageName_.c_str();
+ *out_package_name = ctx->get_cpp_context()->lastGridPackageName_.c_str();
if (out_url)
- *out_url = ctx->cpp_context->lastGridUrl_.c_str();
+ *out_url = ctx->get_cpp_context()->lastGridUrl_.c_str();
if (out_direct_download)
*out_direct_download = direct_download ? 1 : 0;
if (out_open_license)
@@ -848,12 +834,12 @@ int PROJ_DLL proj_grid_get_info_from_database(
if (out_available)
*out_available = available ? 1 : 0;
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return true;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return false;
}
@@ -888,12 +874,12 @@ PJ_OBJ_LIST *proj_query_geodetic_crs_from_datum(PJ_CONTEXT *ctx,
for (const auto &obj : res) {
objects.push_back(obj);
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return new PJ_OBJ_LIST(std::move(objects));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -1064,12 +1050,12 @@ PJ_OBJ_LIST *proj_create_from_name(PJ_CONTEXT *ctx, const char *auth_name,
for (const auto &obj : res) {
objects.push_back(obj);
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return new PJ_OBJ_LIST(std::move(objects));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -1218,12 +1204,12 @@ PJ_OBJ_LIST *proj_get_non_deprecated(PJ_CONTEXT *ctx, const PJ *obj) {
for (const auto &resObj : res) {
objects.push_back(resObj);
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return new PJ_OBJ_LIST(std::move(objects));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -1258,8 +1244,8 @@ static int proj_is_equivalent_to_internal(PJ_CONTEXT *ctx, const PJ *obj,
other->iso_obj.get(), cppCriterion,
ctx ? getDBcontextNoException(ctx, "proj_is_equivalent_to_with_ctx")
: nullptr);
- if (ctx && ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
+ if (ctx) {
+ ctx->safeAutoCloseDbIfNeeded();
}
return res;
}
@@ -1480,22 +1466,16 @@ const char *proj_as_wkt(PJ_CONTEXT *ctx, const PJ *obj, PJ_WKT_TYPE type,
std::string msg("Unknown option :");
msg += *iter;
proj_log_error(ctx, __FUNCTION__, msg.c_str());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
obj->lastWKT = obj->iso_obj->exportToWKT(formatter.get());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return obj->lastWKT.c_str();
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -1562,15 +1542,11 @@ const char *proj_as_proj_string(PJ_CONTEXT *ctx, const PJ *obj,
}
}
obj->lastPROJString = exportable->exportToPROJString(formatter.get());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return obj->lastPROJString.c_str();
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -1944,9 +1920,7 @@ PJ *proj_crs_create_bound_crs_to_WGS84(PJ_CONTEXT *ctx, const PJ *crs,
std::string msg("Unknown option :");
msg += *iter;
proj_log_error(ctx, __FUNCTION__, msg.c_str());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -1954,9 +1928,7 @@ PJ *proj_crs_create_bound_crs_to_WGS84(PJ_CONTEXT *ctx, const PJ *crs,
dbContext, allowIntermediateCRS));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -2012,9 +1984,7 @@ PJ *proj_crs_create_bound_vertical_crs(PJ_CONTEXT *ctx, const PJ *vert_crs,
BoundCRS::create(nnCRS, nnHubCRS, transformation));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -2392,14 +2362,14 @@ PJ_OBJ_LIST *proj_identify(PJ_CONTEXT *ctx, const PJ *obj,
*out_confidence = confidenceTemp;
confidenceTemp = nullptr;
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return ret.release();
} catch (const std::exception &e) {
delete[] confidenceTemp;
proj_log_error(ctx, __FUNCTION__, e.what());
}
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -2424,12 +2394,12 @@ PROJ_STRING_LIST proj_get_authorities_from_database(PJ_CONTEXT *ctx) {
SANITIZE_CTX(ctx);
try {
auto ret = to_string_list(getDBcontext(ctx)->getAuthorities());
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -2468,13 +2438,13 @@ PROJ_STRING_LIST proj_get_codes_from_database(PJ_CONTEXT *ctx,
}
auto ret = to_string_list(
factory->getAuthorityCodes(typeInternal, allow_deprecated != 0));
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -2667,7 +2637,7 @@ proj_get_crs_info_list_from_database(PJ_CONTEXT *ctx, const char *auth_name,
ret[i] = nullptr;
if (out_result_count)
*out_result_count = i;
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
@@ -2678,7 +2648,7 @@ proj_get_crs_info_list_from_database(PJ_CONTEXT *ctx, const char *auth_name,
if (out_result_count)
*out_result_count = 0;
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -2759,7 +2729,7 @@ PROJ_UNIT_INFO **proj_get_units_from_database(PJ_CONTEXT *ctx,
ret[i] = nullptr;
if (out_result_count)
*out_result_count = i;
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
@@ -2770,7 +2740,7 @@ PROJ_UNIT_INFO **proj_get_units_from_database(PJ_CONTEXT *ctx,
if (out_result_count)
*out_result_count = 0;
}
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -3062,9 +3032,7 @@ PJ *proj_create_geographic_crs(PJ_CONTEXT *ctx, const char *crs_name,
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -3107,9 +3075,7 @@ PJ *proj_create_geographic_crs_from_datum(PJ_CONTEXT *ctx, const char *crs_name,
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
@@ -3736,9 +3702,7 @@ PJ *proj_crs_promote_to_3D(PJ_CONTEXT *ctx, const char *crs_3D_name,
dbContext));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -3824,9 +3788,7 @@ PJ *proj_crs_create_projected_3D_crs_from_2D(PJ_CONTEXT *ctx,
cpp_projected_2D_crs->derivingConversion(), newCS));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
} else {
@@ -3839,9 +3801,7 @@ PJ *proj_crs_create_projected_3D_crs_from_2D(PJ_CONTEXT *ctx,
dbContext));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -3886,9 +3846,7 @@ PJ *proj_crs_demote_to_2D(PJ_CONTEXT *ctx, const char *crs_2D_name,
dbContext));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
}
@@ -6891,14 +6849,10 @@ int proj_coordoperation_is_instantiable(PJ_CONTEXT *ctx,
dbContext, proj_context_is_network_enabled(ctx) != FALSE)
? 1
: 0;
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return ret;
} catch (const std::exception &) {
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return 0;
}
}
@@ -7227,15 +7181,11 @@ int proj_coordoperation_get_grid_used_count(PJ_CONTEXT *ctx,
coordoperation->gridsNeeded.emplace_back(gridDesc);
}
}
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return static_cast<int>(coordoperation->gridsNeeded.size());
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return 0;
}
}
@@ -7363,7 +7313,7 @@ proj_create_operation_factory_context(PJ_CONTEXT *ctx, const char *authority) {
std::string(authority ? authority : ""));
auto operationContext =
CoordinateOperationContext::create(authFactory, nullptr, 0.0);
- ctx->cpp_context->autoCloseDbIfNeeded();
+ ctx->safeAutoCloseDbIfNeeded();
return new PJ_OPERATION_FACTORY_CONTEXT(
std::move(operationContext));
} else {
@@ -7375,9 +7325,7 @@ proj_create_operation_factory_context(PJ_CONTEXT *ctx, const char *authority) {
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
- if (ctx->cpp_context) {
- ctx->cpp_context->autoCloseDbIfNeeded();
- }
+ ctx->safeAutoCloseDbIfNeeded();
return nullptr;
}
diff --git a/src/proj_internal.h b/src/proj_internal.h
index 3a0db980..01da337b 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -758,6 +758,8 @@ struct projCtx_t {
projCtx_t& operator= (const projCtx_t&) = delete;
+ projCppContext* get_cpp_context();
+ void safeAutoCloseDbIfNeeded();
void set_search_paths(const std::vector<std::string>& search_paths_in);
void set_ca_bundle_path(const std::string& ca_bundle_path_in);