changeset 6753:c5173fb5f2d2

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 11 May 2026 14:26:01 +0200
parents a53e19a4ec84 (current diff) 3119f9d18393 (diff)
children a5c8b1dcfaf5 6ebd2030e5a8
files
diffstat 10 files changed, 79 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp	Mon May 11 14:25:39 2026 +0200
+++ b/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp	Mon May 11 14:26:01 2026 +0200
@@ -361,7 +361,7 @@
 #endif
       FindCallback, &payload,
       /*opt_blockMode*/ (parameters_.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
-      /*opt_dimse_timeout*/ parameters_.GetTimeout(),
+      /*opt_dimse_timeout*/ static_cast<int>(parameters_.GetTimeout()),
       &response, &statusDetail);
     
     if (statusDetail)
@@ -479,7 +479,7 @@
       &association_->GetDcmtkAssociation(), presID, &request, dataset, 
       (progressListener_ != NULL ? MoveProgressCallback : NULL), progressListener_,
       /*opt_blockMode*/ (parameters_.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
-      /*opt_dimse_timeout*/ parameters_.GetTimeout(),
+      /*opt_dimse_timeout*/ static_cast<int>(parameters_.GetTimeout()),
       &association_->GetDcmtkNetwork(), /*subOpCallback*/ NULL, NULL,
       &response, &statusDetail, &responseIdentifiers);
 
@@ -627,7 +627,7 @@
 
         OFCondition result = DIMSE_receiveCommand(&(association_->GetDcmtkAssociation()),
                                                   (parameters_.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
-                                                  parameters_.GetTimeout(),
+                                                  static_cast<int>(parameters_.GetTimeout()),
                                                   &cmdPresId,
                                                   &rsp,
                                                   NULL /* statusDetail */,
@@ -694,7 +694,7 @@
           // Receive dataset
           result = DIMSE_receiveDataSetInMemory(&(association_->GetDcmtkAssociation()),
                                                   (parameters_.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
-                                                  parameters_.GetTimeout(),
+                                                  static_cast<int>(parameters_.GetTimeout()),
                                                   &cmdPresId,
                                                   &dataObjectRawPtr,
                                                   NULL, NULL);
@@ -713,39 +713,39 @@
             {
               desiredCStoreReturnStatus = instanceReceivedCallback(callbackContext, *dataObject, remoteAet, remoteIp, calledAet);
             }
-
-            // send the Store response
-            T_DIMSE_Message storeResponse;
-            memset(reinterpret_cast<void*>(&storeResponse), 0, sizeof(storeResponse));
-            storeResponse.CommandField         = DIMSE_C_STORE_RSP;
+          }
 
-            T_DIMSE_C_StoreRSP& storeRsp       = storeResponse.msg.CStoreRSP;
-            storeRsp.MessageIDBeingRespondedTo = storeRequest->MessageID;
-            storeRsp.DimseStatus               = desiredCStoreReturnStatus;
-            storeRsp.DataSetType               = DIMSE_DATASET_NULL;
+          // send the Store response
+          T_DIMSE_Message storeResponse;
+          memset(reinterpret_cast<void*>(&storeResponse), 0, sizeof(storeResponse));
+          storeResponse.CommandField         = DIMSE_C_STORE_RSP;
 
-            OFStandard::strlcpy(
-                storeRsp.AffectedSOPClassUID, storeRequest->AffectedSOPClassUID, sizeof(storeRsp.AffectedSOPClassUID));
-            OFStandard::strlcpy(
-                storeRsp.AffectedSOPInstanceUID, storeRequest->AffectedSOPInstanceUID, sizeof(storeRsp.AffectedSOPInstanceUID));
-            storeRsp.opts = O_STORE_AFFECTEDSOPCLASSUID | O_STORE_AFFECTEDSOPINSTANCEUID;
+          T_DIMSE_C_StoreRSP& storeRsp       = storeResponse.msg.CStoreRSP;
+          storeRsp.MessageIDBeingRespondedTo = storeRequest->MessageID;
+          storeRsp.DimseStatus               = desiredCStoreReturnStatus;
+          storeRsp.DataSetType               = DIMSE_DATASET_NULL;
 
-            result = DIMSE_sendMessageUsingMemoryData(&(association_->GetDcmtkAssociation()), 
-                                                      cmdPresId, 
-                                                      &storeResponse, NULL /* statusDetail */, NULL /* dataObject */,
-                                                      NULL, NULL, NULL /* commandSet */);
-            if (result.bad())
-            {
-              throw OrthancException(ErrorCode_NetworkProtocol, "C-GET SCU to AET \"" +
-                                     parameters_.GetRemoteModality().GetApplicationEntityTitle() +
-                                     "\" has failed to send response message");
-            }
-            else
-            {
-              OFString tempStr;
-              CLOG(TRACE, DICOM) << "Sent C-STORE Response: " << std::endl
-                << DIMSE_dumpMessage(tempStr, storeResponse, DIMSE_OUTGOING, NULL, cmdPresId);
-            }
+          OFStandard::strlcpy(
+              storeRsp.AffectedSOPClassUID, storeRequest->AffectedSOPClassUID, sizeof(storeRsp.AffectedSOPClassUID));
+          OFStandard::strlcpy(
+              storeRsp.AffectedSOPInstanceUID, storeRequest->AffectedSOPInstanceUID, sizeof(storeRsp.AffectedSOPInstanceUID));
+          storeRsp.opts = O_STORE_AFFECTEDSOPCLASSUID | O_STORE_AFFECTEDSOPINSTANCEUID;
+
+          result = DIMSE_sendMessageUsingMemoryData(&(association_->GetDcmtkAssociation()), 
+                                                    cmdPresId, 
+                                                    &storeResponse, NULL /* statusDetail */, NULL /* dataObject */,
+                                                    NULL, NULL, NULL /* commandSet */);
+          if (result.bad())
+          {
+            throw OrthancException(ErrorCode_NetworkProtocol, "C-GET SCU to AET \"" +
+                                    parameters_.GetRemoteModality().GetApplicationEntityTitle() +
+                                    "\" has failed to send response message");
+          }
+          else
+          {
+            OFString tempStr;
+            CLOG(TRACE, DICOM) << "Sent C-STORE Response: " << std::endl
+              << DIMSE_dumpMessage(tempStr, storeResponse, DIMSE_OUTGOING, NULL, cmdPresId);
           }
         }
         // Handle other DIMSE command (error since other command than GET/STORE not expected)
@@ -806,7 +806,7 @@
       DIMSE_echoUser(&association_->GetDcmtkAssociation(),
                      association_->GetDcmtkAssociation().nextMsgID++, 
                      /*opt_blockMode*/ (parameters_.HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
-                     /*opt_dimse_timeout*/ parameters_.GetTimeout(),
+                     /*opt_dimse_timeout*/ static_cast<int>(parameters_.GetTimeout()),
                      &status, NULL),
       parameters_, "C-ECHO");
       
--- a/OrthancFramework/Sources/DicomNetworking/Internals/CommandDispatcher.cpp	Mon May 11 14:25:39 2026 +0200
+++ b/OrthancFramework/Sources/DicomNetworking/Internals/CommandDispatcher.cpp	Mon May 11 14:26:01 2026 +0200
@@ -375,8 +375,8 @@
 
         cond = ASC_acceptContextsWithPreferredTransferSyntaxes(
           assoc->params,
-          &knownAbstractSyntaxes[0], knownAbstractSyntaxes.size(),
-          &genericTransferSyntaxes[0], genericTransferSyntaxes.size());
+          &knownAbstractSyntaxes[0], static_cast<int>(knownAbstractSyntaxes.size()),
+          &genericTransferSyntaxes[0], static_cast<int>(genericTransferSyntaxes.size()));
         if (cond.bad())
         {
           CLOG(INFO, DICOM) << cond.text();
@@ -396,7 +396,7 @@
           const char* as[1] = { UID_StorageCommitmentPushModelSOPClass }; 
           cond = ASC_acceptContextsWithPreferredTransferSyntaxes(
             assoc->params, as, 1,
-            &genericTransferSyntaxes[0], genericTransferSyntaxes.size(), ASC_SC_ROLE_SCUSCP);
+            &genericTransferSyntaxes[0], static_cast<int>(genericTransferSyntaxes.size()), ASC_SC_ROLE_SCUSCP);
           if (cond.bad())
           {
             CLOG(INFO, DICOM) << cond.text();
@@ -488,8 +488,8 @@
             // This branch exactly corresponds to Orthanc <= 1.6.1 (in
             // which C-GET SCP was not supported)
             cond = ASC_acceptContextsWithPreferredTransferSyntaxes(
-              assoc->params, dcmAllStorageSOPClassUIDs, count,
-              &storageTransferSyntaxesC[0], storageTransferSyntaxesC.size());
+              assoc->params, dcmAllStorageSOPClassUIDs, static_cast<int>(count),
+              &storageTransferSyntaxesC[0], static_cast<int>(storageTransferSyntaxesC.size()));
             if (cond.bad())
             {
               CLOG(INFO, DICOM) << cond.text();
@@ -563,7 +563,7 @@
              * to be a storage SOP class.
              **/
             cond = acceptUnknownContextsWithPreferredTransferSyntaxes(
-              assoc->params, &storageTransferSyntaxesC[0], storageTransferSyntaxesC.size(), ASC_SC_ROLE_DEFAULT);
+              assoc->params, &storageTransferSyntaxesC[0], static_cast<int>(storageTransferSyntaxesC.size()), ASC_SC_ROLE_DEFAULT);
             if (cond.bad())
             {
               CLOG(INFO, DICOM) << cond.text();
@@ -861,7 +861,7 @@
 
                 if (handler.get() != NULL)
                 {
-                  cond = Internals::storeScp(assoc_, &msg, presID, *handler, remoteIp_, associationTimeout_);
+                  cond = Internals::storeScp(assoc_, &msg, presID, *handler, remoteIp_, static_cast<int>(associationTimeout_));
                 }
               }
               break;
@@ -874,7 +874,7 @@
 
                 if (handler.get() != NULL)
                 {
-                  cond = Internals::moveScp(assoc_, &msg, presID, *handler, remoteIp_, remoteAet_, calledAet_, associationTimeout_);
+                  cond = Internals::moveScp(assoc_, &msg, presID, *handler, remoteIp_, remoteAet_, calledAet_, static_cast<int>(associationTimeout_));
                 }
               }
               break;
@@ -887,7 +887,7 @@
                 
                 if (handler.get() != NULL)
                 {
-                  cond = Internals::getScp(assoc_, &msg, presID, *handler, remoteIp_, remoteAet_, calledAet_, associationTimeout_);
+                  cond = Internals::getScp(assoc_, &msg, presID, *handler, remoteIp_, remoteAet_, calledAet_, static_cast<int>(associationTimeout_));
                 }
               }
               break;
@@ -910,7 +910,7 @@
                 }
 
                 cond = Internals::findScp(assoc_, &msg, presID, findHandler.get(), worklistHandler.get(),
-                                          remoteIp_, remoteAet_, calledAet_, associationTimeout_);
+                                          remoteIp_, remoteAet_, calledAet_, static_cast<int>(associationTimeout_));
               }
               break;
 
@@ -1141,7 +1141,7 @@
        **/
       
       std::unique_ptr<DcmDataset> dataset(
-        ReadDataset(assoc_, "Cannot read the dataset in N-ACTION SCP", associationTimeout_));
+        ReadDataset(assoc_, "Cannot read the dataset in N-ACTION SCP", static_cast<int>(associationTimeout_)));
       assert(dataset.get() != NULL);
 
       {
@@ -1278,7 +1278,7 @@
        **/
       
       std::unique_ptr<DcmDataset> dataset(
-        ReadDataset(assoc_, "Cannot read the dataset in N-EVENT-REPORT SCP", associationTimeout_));
+        ReadDataset(assoc_, "Cannot read the dataset in N-EVENT-REPORT SCP", static_cast<int>(associationTimeout_)));
       assert(dataset.get() != NULL);
 
       {
--- a/OrthancFramework/Sources/HttpServer/HttpContentNegociation.cpp	Mon May 11 14:25:39 2026 +0200
+++ b/OrthancFramework/Sources/HttpServer/HttpContentNegociation.cpp	Mon May 11 14:26:01 2026 +0200
@@ -28,6 +28,7 @@
 #include "../Logging.h"
 #include "../OrthancException.h"
 #include "../Toolbox.h"
+#include "../SerializationToolbox.h"
 
 #include <boost/lexical_cast.hpp>
 
@@ -78,13 +79,9 @@
         float quality;
         bool ok = false;
 
-        try
+        if (SerializationToolbox::ParseFloat(quality, found->second))
         {
-          quality = boost::lexical_cast<float>(found->second);
-          ok = (quality >= 0.0f && quality <= 1.0f);
-        }
-        catch (boost::bad_lexical_cast&)
-        {
+          ok = quality >= 0.0f && quality <= 1.0f;
         }
 
         if (ok)
--- a/OrthancFramework/Sources/Images/Font.cpp	Mon May 11 14:25:39 2026 +0200
+++ b/OrthancFramework/Sources/Images/Font.cpp	Mon May 11 14:26:01 2026 +0200
@@ -289,7 +289,7 @@
       {
         // Go to the next line
         a = x;
-        y += maxHeight_ + 1;
+        y += static_cast<int>(maxHeight_) + 1;
       }
       else
       {
@@ -297,7 +297,7 @@
         if (c != characters_.end())
         {
           DrawCharacter(target, *c->second, a, y + static_cast<int>(c->second->top_), color);
-          a += c->second->advance_;
+          a += static_cast<int>(c->second->advance_);
         }
       }
     }
--- a/OrthancFramework/Sources/Images/ImageProcessing.cpp	Mon May 11 14:25:39 2026 +0200
+++ b/OrthancFramework/Sources/Images/ImageProcessing.cpp	Mon May 11 14:26:01 2026 +0200
@@ -2348,7 +2348,7 @@
       }
       else if (sourceX >= static_cast<int>(sourceWidth))
       {
-        sourceX = sourceWidth - 1;
+        sourceX = static_cast<int>(sourceWidth) - 1;
       }
 
       lookupX[x] = static_cast<unsigned int>(sourceX);
@@ -2365,7 +2365,7 @@
       }
       else if (sourceY >= static_cast<int>(sourceHeight))
       {
-        sourceY = sourceHeight - 1;
+        sourceY = static_cast<int>(sourceHeight) - 1;
       }
 
       lookupY[y] = static_cast<unsigned int>(sourceY);
@@ -3171,8 +3171,8 @@
         // Use the full dynamic range of the image
         int64_t minValue, maxValue;
         GetMinMaxIntegerValue(minValue, maxValue, source);
-        double minRescaled = info.ApplyRescale(minValue);
-        double maxRescaled = info.ApplyRescale(maxValue);
+        double minRescaled = info.ApplyRescale(static_cast<double>(minValue));
+        double maxRescaled = info.ApplyRescale(static_cast<double>(maxValue));
         info.ComputeRenderingTransform(offset, scaling, Window::FromBounds(minRescaled, maxRescaled));
       }
 
--- a/OrthancFramework/Sources/MultiThreading/SharedMessageQueue.cpp	Mon May 11 14:25:39 2026 +0200
+++ b/OrthancFramework/Sources/MultiThreading/SharedMessageQueue.cpp	Mon May 11 14:26:01 2026 +0200
@@ -108,7 +108,7 @@
   }
 
 
-  IDynamicObject* SharedMessageQueue::Dequeue(int32_t millisecondsTimeout)
+  IDynamicObject* SharedMessageQueue::Dequeue(unsigned int millisecondsTimeout)
   {
     boost::mutex::scoped_lock lock(mutex_);
 
@@ -143,7 +143,7 @@
 
 
 
-  bool SharedMessageQueue::WaitEmpty(int32_t millisecondsTimeout)
+  bool SharedMessageQueue::WaitEmpty(unsigned int millisecondsTimeout)
   {
     boost::mutex::scoped_lock lock(mutex_);
     
--- a/OrthancFramework/Sources/MultiThreading/SharedMessageQueue.h	Mon May 11 14:25:39 2026 +0200
+++ b/OrthancFramework/Sources/MultiThreading/SharedMessageQueue.h	Mon May 11 14:26:01 2026 +0200
@@ -53,9 +53,9 @@
     void Enqueue(IDynamicObject* message);
 
     // The caller is responsible to delete the dequeued message!
-    IDynamicObject* Dequeue(int32_t millisecondsTimeout);
+    IDynamicObject* Dequeue(unsigned int millisecondsTimeout);
 
-    bool WaitEmpty(int32_t millisecondsTimeout);
+    bool WaitEmpty(unsigned int millisecondsTimeout);
 
     bool IsFifoPolicy() const;
 
--- a/OrthancServer/Plugins/Engine/PluginsJob.cpp	Mon May 11 14:25:39 2026 +0200
+++ b/OrthancServer/Plugins/Engine/PluginsJob.cpp	Mon May 11 14:26:01 2026 +0200
@@ -55,7 +55,11 @@
         parameters_.stop == NULL ||
         parameters_.reset == NULL)
     {
-      parameters_.finalize(parameters_.job);
+      if (parameters_.finalize != NULL)
+      {
+        parameters_.finalize(parameters_.job);
+      }
+      
       throw OrthancException(ErrorCode_NullPointer);
     }
 
--- a/OrthancServer/Sources/ServerContext.cpp	Mon May 11 14:25:39 2026 +0200
+++ b/OrthancServer/Sources/ServerContext.cpp	Mon May 11 14:26:01 2026 +0200
@@ -39,6 +39,7 @@
 #include "../../OrthancFramework/Sources/Logging.h"
 #include "../../OrthancFramework/Sources/MallocMemoryBuffer.h"
 #include "../../OrthancFramework/Sources/MetricsRegistry.h"
+#include "../../OrthancFramework/Sources/SerializationToolbox.h"
 #include "../Plugins/Engine/OrthancPlugins.h"
 
 #include "DicomInstanceToStore.h"
@@ -1278,25 +1279,16 @@
        * been computed for this instance.
        **/
     
-      bool hasPixelDataOffset;
+      bool hasPixelDataOffset = false;
       uint64_t pixelDataOffset = 0;  // dummy initialization
 
       {
         std::string s;
-        if (LookupMetadata(s, MetadataType_Instance_PixelDataOffset, instanceMetadata))
+        if (LookupMetadata(s, MetadataType_Instance_PixelDataOffset, instanceMetadata)) // This instance was created by a version of Orthanc > 1.9.0
         {
-          hasPixelDataOffset = false;
-
           if (!s.empty())
           {
-            try
-            {
-              pixelDataOffset = boost::lexical_cast<uint64_t>(s);
-              hasPixelDataOffset = true;
-            }
-            catch (boost::bad_lexical_cast&)
-            {
-            }
+            hasPixelDataOffset = SerializationToolbox::ParseUnsignedInteger64(pixelDataOffset, s);
           }
 
           if (!hasPixelDataOffset)
@@ -1304,14 +1296,8 @@
             LOG(ERROR) << "Metadata \"PixelDataOffset\" is corrupted for instance: " << instancePublicId;
           }
         }
-        else
-        {
-          // This instance was created by a version of Orthanc <= 1.9.0
-          hasPixelDataOffset = false;
-        }
       }
 
-
       if (hasPixelDataOffset &&
           area_.HasEfficientReadRange() &&
           LookupAttachment(attachment, FileContentType_Dicom, instanceAttachments) &&
@@ -1484,10 +1470,10 @@
                               MetadataType_Instance_PixelDataOffset) &&
         !s.empty())
     {
-      try
+      uint64_t pixelDataOffset = 0;
+
+      if (SerializationToolbox::ParseUnsignedInteger64(pixelDataOffset, s))
       {
-        uint64_t pixelDataOffset = boost::lexical_cast<uint64_t>(s);
-
         StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
 
         accessor.ReadStartRange(dicom, attachment, pixelDataOffset);
@@ -1495,7 +1481,7 @@
         
         return true;   // Success
       }
-      catch (boost::bad_lexical_cast&)
+      else
       {
         LOG(ERROR) << "Metadata \"PixelDataOffset\" is corrupted for instance: " << instancePublicId;
       }
@@ -1583,7 +1569,7 @@
       {
         context_.dicomCache_.Acquire(instancePublicId_, dicom_.release(), dicomSize_);
       }
-      catch (OrthancException&)
+      catch (OrthancException&) // NOLINT(bugprone-empty-catch)
       {
       }
     }
@@ -1962,7 +1948,7 @@
           return decoded.release();
         }
       }
-      catch (const OrthancException&)
+      catch (const OrthancException&) // NOLINT(bugprone-empty-catch)
       { // ignore, we'll try other alternatives
       }
     }
@@ -1975,7 +1961,7 @@
       {
         decoded.reset(GetPlugins().Decode(buffer, size, frameIndex));
       }
-      catch (const OrthancException&)
+      catch (const OrthancException&) // NOLINT(bugprone-empty-catch)
       {
       }
       
--- a/OrthancServer/UnitTestsSources/PluginsTests.cpp	Mon May 11 14:25:39 2026 +0200
+++ b/OrthancServer/UnitTestsSources/PluginsTests.cpp	Mon May 11 14:26:01 2026 +0200
@@ -94,7 +94,7 @@
     ASSERT_FALSE(l.HasFunction("world"));
     return;  // Success
   }
-  catch (OrthancException&)
+  catch (OrthancException&) // NOLINT(bugprone-empty-catch)
   {
   }
   
@@ -107,7 +107,7 @@
     ASSERT_FALSE(l.HasFunction("world"));
     return;  // Success
   }
-  catch (OrthancException&)
+  catch (OrthancException&) // NOLINT(bugprone-empty-catch)
   {
   }
   
@@ -120,7 +120,7 @@
     ASSERT_FALSE(l.HasFunction("world"));
     return;  // Success
   }
-  catch (OrthancException&)
+  catch (OrthancException&) // NOLINT(bugprone-empty-catch)
   {
   }