diff Framework/Plugins/DatabaseBackendAdapterV3.cpp @ 373:be7de633695c db-protobuf

started DatabaseBackendAdapterV4
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 28 Mar 2023 12:47:54 +0200
parents 16aac0287485
children 4a3985088723
line wrap: on
line diff
--- a/Framework/Plugins/DatabaseBackendAdapterV3.cpp	Tue Mar 28 11:40:07 2023 +0200
+++ b/Framework/Plugins/DatabaseBackendAdapterV3.cpp	Tue Mar 28 12:47:54 2023 +0200
@@ -1988,6 +1988,8 @@
                                           size_t countConnections,
                                           unsigned int maxDatabaseRetries)
   {
+    std::unique_ptr<IndexBackend> protection(backend);
+    
     if (isBackendInUse_)
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
@@ -2071,12 +2073,13 @@
     params.setProtectedPatient = SetProtectedPatient;
     params.setResourcesContent = SetResourcesContent;
 
-    OrthancPluginContext* context = backend->GetContext();
+    OrthancPluginContext* context = protection->GetContext();
  
     if (OrthancPluginRegisterDatabaseBackendV3(
           context, &params, sizeof(params), maxDatabaseRetries,
-          new Adapter(backend, countConnections)) != OrthancPluginErrorCode_Success)
+          new Adapter(protection.release(), countConnections)) != OrthancPluginErrorCode_Success)
     {
+      delete backend;
       throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Unable to register the database backend");
     }