# HG changeset patch # User Sebastien Jodogne # Date 1551714505 -3600 # Node ID e1b24c9a9bd863ac757cee897a63ddbda986ca1d # Parent df314d38a4e0b2a0c25c1a1df8541343a1f2f229 patch Orthanc 1.5.6 diff -r df314d38a4e0 -r e1b24c9a9bd8 CMakeLists.txt --- a/CMakeLists.txt Mon Mar 04 16:14:15 2019 +0100 +++ b/CMakeLists.txt Mon Mar 04 16:48:25 2019 +0100 @@ -26,6 +26,9 @@ else() set(ORTHANC_FRAMEWORK_VERSION "1.5.6") set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") + + # diff --new-file -urEb Orthanc-1.5.6.orig/ Orthanc-1.5.6 > orthanc-1.5.6.patch + set(ORTHANC_FRAMEWORK_PATCH "${CMAKE_SOURCE_DIR}/Resources/Patches/orthanc-1.5.6.patch") endif() @@ -55,6 +58,21 @@ include_directories(${ORTHANC_ROOT}) +# Possibly patch the Orthanc framework +if (DEFINED ORTHANC_FRAMEWORK_PATCH AND + NOT EXISTS "${ORTHANC_ROOT}/patched") + execute_process( + COMMAND ${PATCH_EXECUTABLE} -p0 -N -i ${ORTHANC_FRAMEWORK_PATCH} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + RESULT_VARIABLE Failure + ) + + if (Failure) + message(FATAL_ERROR "Error while patching a file") + endif() +endif() + + # Check that the Orthanc SDK headers are available if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK) if (ORTHANC_SDK_VERSION STREQUAL "1.4.2") diff -r df314d38a4e0 -r e1b24c9a9bd8 Resources/Patches/orthanc-1.5.6.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Patches/orthanc-1.5.6.patch Mon Mar 04 16:48:25 2019 +0100 @@ -0,0 +1,143 @@ +diff --new-file -urEb Orthanc-1.5.6.orig/patched Orthanc-1.5.6/patched +--- Orthanc-1.5.6.orig/patched 1970-01-01 01:00:00.000000000 +0100 ++++ Orthanc-1.5.6/patched 2019-03-04 16:41:37.532734849 +0100 +@@ -0,0 +1 @@ ++patched +diff --new-file -urEb Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp +--- Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp 2019-03-04 16:19:10.126165813 +0100 ++++ Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp 2019-03-04 16:19:39.330128951 +0100 +@@ -145,6 +145,13 @@ + } + + ++ void MemoryBuffer::Swap(MemoryBuffer& other) ++ { ++ std::swap(buffer_.data, other.buffer_.data); ++ std::swap(buffer_.size, other.buffer_.size); ++ } ++ ++ + OrthancPluginMemoryBuffer MemoryBuffer::Release() + { + OrthancPluginMemoryBuffer result = buffer_; +@@ -1024,11 +1031,11 @@ + { + CheckImageAvailable(); + +- OrthancPluginMemoryBuffer tmp; +- OrthancPluginCompressPngImage(GetGlobalContext(), &tmp, GetPixelFormat(), ++ OrthancPlugins::MemoryBuffer answer; ++ OrthancPluginCompressPngImage(GetGlobalContext(), *answer, GetPixelFormat(), + GetWidth(), GetHeight(), GetPitch(), GetBuffer()); + +- target.Assign(tmp); ++ target.Swap(answer); + } + + +@@ -1037,11 +1044,11 @@ + { + CheckImageAvailable(); + +- OrthancPluginMemoryBuffer tmp; +- OrthancPluginCompressJpegImage(GetGlobalContext(), &tmp, GetPixelFormat(), ++ OrthancPlugins::MemoryBuffer answer; ++ OrthancPluginCompressJpegImage(GetGlobalContext(), *answer, GetPixelFormat(), + GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality); + +- target.Assign(tmp); ++ target.Swap(answer); + } + + +@@ -1580,16 +1587,16 @@ + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); + } + +- OrthancPluginMemoryBuffer answer; ++ OrthancPlugins::MemoryBuffer answer; + uint16_t status; + OrthancPluginErrorCode code = OrthancPluginCallPeerApi +- (GetGlobalContext(), &answer, NULL, &status, peers_, ++ (GetGlobalContext(), *answer, NULL, &status, peers_, + static_cast(index), OrthancPluginHttpMethod_Get, uri.c_str(), + 0, NULL, NULL, NULL, 0, timeout_); + + if (code == OrthancPluginErrorCode_Success) + { +- target.Assign(answer); ++ target.Swap(answer); + return (status == 200); + } + else +@@ -1704,16 +1711,16 @@ + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); + } + +- OrthancPluginMemoryBuffer answer; ++ OrthancPlugins::MemoryBuffer answer; + uint16_t status; + OrthancPluginErrorCode code = OrthancPluginCallPeerApi +- (GetGlobalContext(), &answer, NULL, &status, peers_, ++ (GetGlobalContext(), *answer, NULL, &status, peers_, + static_cast(index), OrthancPluginHttpMethod_Post, uri.c_str(), + 0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_); + + if (code == OrthancPluginErrorCode_Success) + { +- target.Assign(answer); ++ target.Swap(answer); + return (status == 200); + } + else +@@ -1732,16 +1739,15 @@ + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); + } + +- OrthancPluginMemoryBuffer answer; ++ OrthancPlugins::MemoryBuffer answer; + uint16_t status; + OrthancPluginErrorCode code = OrthancPluginCallPeerApi +- (GetGlobalContext(), &answer, NULL, &status, peers_, ++ (GetGlobalContext(), *answer, NULL, &status, peers_, + static_cast(index), OrthancPluginHttpMethod_Put, uri.c_str(), + 0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_); + + if (code == OrthancPluginErrorCode_Success) + { +- OrthancPluginFreeMemoryBuffer(GetGlobalContext(), &answer); + return (status == 200); + } + else +@@ -1769,16 +1775,15 @@ + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); + } + +- OrthancPluginMemoryBuffer answer; ++ OrthancPlugins::MemoryBuffer answer; + uint16_t status; + OrthancPluginErrorCode code = OrthancPluginCallPeerApi +- (GetGlobalContext(), &answer, NULL, &status, peers_, +- static_cast(index), OrthancPluginHttpMethod_Put, uri.c_str(), ++ (GetGlobalContext(), *answer, NULL, &status, peers_, ++ static_cast(index), OrthancPluginHttpMethod_Delete, uri.c_str(), + 0, NULL, NULL, NULL, 0, timeout_); + + if (code == OrthancPluginErrorCode_Success) + { +- OrthancPluginFreeMemoryBuffer(GetGlobalContext(), &answer); + return (status == 200); + } + else +diff --new-file -urEb Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.h Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.h +--- Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.h 2019-03-04 16:19:10.126165813 +0100 ++++ Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.h 2019-03-04 16:19:42.018125583 +0100 +@@ -129,6 +129,8 @@ + // This transfers ownership from "other" to "this" + void Assign(OrthancPluginMemoryBuffer& other); + ++ void Swap(MemoryBuffer& other); ++ + OrthancPluginMemoryBuffer Release(); + + const char* GetData() const