# HG changeset patch # User Alain Mazy # Date 1659955368 -7200 # Node ID e69a3ff39bc5fb3c3e62b6e4c8d3e9cc78652375 # Parent 5c997c72603c713fef9cc5bb64bdb4b90f48dc5c fix reuse of DicomAsJson between lookup and answers diff -r 5c997c72603c -r e69a3ff39bc5 OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Mon Aug 08 09:59:07 2022 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Mon Aug 08 12:42:48 2022 +0200 @@ -131,7 +131,7 @@ const std::list& resources, const std::map& instancesIds, // optional: the id of an instance for each found resource. const std::map >& resourcesMainDicomTags, // optional: all tags read from DB for a resource (current level and upper levels) - const std::map& resourcesDicomAsJson, // optional: the dicom-as-json for each resource + const std::map >& resourcesDicomAsJson, // optional: the dicom-as-json for each resource ResourceType level, bool expand, DicomToJsonFormat format, @@ -152,12 +152,12 @@ { // reuse data already collected before (e.g during lookup) std::map >::const_iterator mainDicomTags = resourcesMainDicomTags.find(*resource); - std::map::const_iterator dicomAsJson = resourcesDicomAsJson.find(*resource); + std::map >::const_iterator dicomAsJson = resourcesDicomAsJson.find(*resource); context.ExpandResource(expanded, *resource, *(mainDicomTags->second.get()), instanceId->second, - dicomAsJson->second, + dicomAsJson->second.get(), level, format, requestedTags, allowStorageAccess); } else @@ -191,7 +191,7 @@ { std::map unusedInstancesIds; std::map > unusedResourcesMainDicomTags; - std::map unusedResourcesDicomAsJson; + std::map > unusedResourcesDicomAsJson; AnswerListOfResources(output, context, resources, unusedInstancesIds, unusedResourcesMainDicomTags, unusedResourcesDicomAsJson, level, expand, format, requestedTags, allowStorageAccess); } @@ -2875,7 +2875,7 @@ // cache the data we used during lookup and that we could reuse when building the answers std::map instancesIds_; // the id of an instance for each found resource. std::map > resourcesMainDicomTags_; // all tags read from DB for a resource (current level and upper levels) - std::map resourcesDicomAsJson_; // the dicom-as-json for a resource + std::map > resourcesDicomAsJson_; // the dicom-as-json for a resource DicomToJsonFormat format_; @@ -2905,7 +2905,14 @@ resources_.push_back(publicId); instancesIds_[publicId] = instanceId; resourcesMainDicomTags_[publicId].reset(mainDicomTags.Clone()); - resourcesDicomAsJson_[publicId] = dicomAsJson; + if (dicomAsJson != NULL) + { + resourcesDicomAsJson_[publicId].reset(new Json::Value(*dicomAsJson)); // keep our own copy because we might reuse it between lookup and answers + } + else + { + resourcesDicomAsJson_[publicId] = boost::shared_ptr(); + } } void Answer(RestApiOutput& output, diff -r 5c997c72603c -r e69a3ff39bc5 OrthancServer/Sources/ServerContext.cpp --- a/OrthancServer/Sources/ServerContext.cpp Mon Aug 08 09:59:07 2022 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Mon Aug 08 12:42:48 2022 +0200 @@ -2348,7 +2348,7 @@ const std::string& publicId, const DicomMap& mainDicomTags, // optional: the main dicom tags for the resource (if already available) const std::string& instanceId, // optional: the id of an instance for the resource (if already available) - const Json::Value* dicomAsJson, // optional: the dicom-as-json for the resource (if already available) + const Json::Value* dicomAsJson, // optional: the dicom-as-json for the resource (if already available) ResourceType level, DicomToJsonFormat format, const std::set& requestedTags,