diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-08-19 20:57:07 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-08-20 13:26:54 +0200 |
| commit | 15d6475b8caeb169fd2c060076738db75fc527b3 (patch) | |
| tree | c50d03ac81b1e10e0d4356234757126a708e9ac1 /src/iso19111/io.cpp | |
| parent | 2c9c015a6529548f5a5d448c78bc9b565d751590 (diff) | |
| download | PROJ-15d6475b8caeb169fd2c060076738db75fc527b3.tar.gz PROJ-15d6475b8caeb169fd2c060076738db75fc527b3.zip | |
C API: add proj_context_set_autoclose_database() to automatically close database (fixes #1565)
Diffstat (limited to 'src/iso19111/io.cpp')
| -rw-r--r-- | src/iso19111/io.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
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); } // --------------------------------------------------------------------------- |
