From 15d6475b8caeb169fd2c060076738db75fc527b3 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 19 Aug 2019 20:57:07 +0200 Subject: C API: add proj_context_set_autoclose_database() to automatically close database (fixes #1565) --- src/iso19111/io.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/iso19111/io.cpp') diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 5ccd9642..cbf5e150 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -5881,11 +5881,14 @@ BaseObjectNNPtr createFromUserInput(const std::string &text, * @throw ParsingException */ BaseObjectNNPtr createFromUserInput(const std::string &text, PJ_CONTEXT *ctx) { - return createFromUserInput( - text, ctx != nullptr && ctx->cpp_context - ? ctx->cpp_context->databaseContext.as_nullable() - : nullptr, - false, ctx); + DatabaseContextPtr dbContext; + try { + if (ctx != nullptr && ctx->cpp_context) { + dbContext = ctx->cpp_context->getDatabaseContext().as_nullable(); + } + } catch (const std::exception &) { + } + return createFromUserInput(text, dbContext, false, ctx); } // --------------------------------------------------------------------------- -- cgit v1.2.3