# HG changeset patch # User Sebastien Jodogne # Date 1779810854 -7200 # Node ID ff73909042f23474a7fccf366241e65dae3f7aa8 # Parent 4bd9dd9e3b9c8898bd276bd2477d3413fc5212f9 refactoring constructor of StorageAreaDataSource::Range diff -r 4bd9dd9e3b9c -r ff73909042f2 OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp --- a/OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp Tue May 26 16:22:09 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp Tue May 26 17:54:14 2026 +0200 @@ -301,7 +301,7 @@ } - StorageAreaDataSource::Range::Range(IMemoryBuffer* buffer /* takes ownership */) : + StorageAreaDataSource::Range::Range(IMemoryBuffer* buffer) : buffer_(buffer) { if (buffer == NULL) @@ -318,6 +318,25 @@ { throw OrthancException(ErrorCode_NullPointer); } + + const Identifier& id = dynamic_cast(item->GetId()); + + if (id.HasPostProcessing()) + { + const Value& value = dynamic_cast(*item->GetValue()); + std::unique_ptr postProcessed(id.GetPostProcessing().Apply(value)); + + if (postProcessed.get() != NULL) + { + // In this case, the backpressure on the source "item" is released + item_.reset(NULL); + buffer_.reset(postProcessed.release()); + } + else + { + // No postprocessing was applied, keep backpressure on "item" + } + } } @@ -417,32 +436,7 @@ } else { - std::unique_ptr item(reader.ReadSingle(request)); - - const Identifier& id = dynamic_cast(item->GetId()); - - std::unique_ptr range; - - if (id.HasPostProcessing()) - { - const Value& value = dynamic_cast(*item->GetValue()); - std::unique_ptr postProcessed(id.GetPostProcessing().Apply(value)); - - if (postProcessed.get() != NULL) - { - range.reset(new Range(postProcessed.release())); - } - } - - if (range.get() == NULL) // No postprocessing was applied - { - return new Range(item.release()); // Keep backpressure on "item" - } - else - { - // In this case, the backporessure on the source "item" is released - return range.release(); - } + return new Range(reader.ReadSingle(request)); } } }