changeset 173:68dae290d5fa Orthanc-0.2.3-Paulus

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 19 Nov 2012 13:50:19 +0100
parents da7e915202c7
children
files OrthancServer/OrthancRestApi.cpp
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi.cpp	Fri Nov 09 13:45:36 2012 +0100
+++ b/OrthancServer/OrthancRestApi.cpp	Mon Nov 19 13:50:19 2012 +0100
@@ -125,11 +125,12 @@
     // TODO: Implement a true caching mechanism!
     static boost::mutex mutex_;
     static std::string lastFileUuid_;
-    static DcmFileFormat dicomFile_;
+    static std::auto_ptr<DcmFileFormat> dicomFile_;
 
     boost::mutex::scoped_lock lock(mutex_);
 
-    if (fileUuid != lastFileUuid_)
+    if (dicomFile_.get() == NULL ||
+        fileUuid != lastFileUuid_)
     {
       LOG(INFO) << "Parsing file " << fileUuid;
       std::string content;
@@ -142,7 +143,9 @@
       }
       is.setEos();
 
-      if (!dicomFile_.read(is).good())
+      dicomFile_.reset(new DcmFileFormat);
+
+      if (!dicomFile_->read(is).good())
       {
         return false;
       }
@@ -157,7 +160,7 @@
     if (uri.size() == 3)
     {
       DicomMap dicomSummary;
-      FromDcmtkBridge::Convert(dicomSummary, *dicomFile_.getDataset());
+      FromDcmtkBridge::Convert(dicomSummary, *dicomFile_->getDataset());
 
       DicomArray a(dicomSummary);
     
@@ -191,7 +194,7 @@
       DcmTagKey tag(group, element);
       DcmElement* item = NULL;
 
-      if (dicomFile_.getDataset()->findAndGetElement(tag, item).good() && 
+      if (dicomFile_->getDataset()->findAndGetElement(tag, item).good() && 
           item != NULL)
       {
         std::string buffer;