diff Core/DicomParsing/DicomDirWriter.cpp @ 2571:a84ce82fd55b

Fix generation of DICOMDIR if PatientID is empty
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 May 2018 20:48:49 +0200
parents 8cc3ca64a534
children d386abc18133
line wrap: on
line diff
--- a/Core/DicomParsing/DicomDirWriter.cpp	Fri May 04 10:31:27 2018 +0200
+++ b/Core/DicomParsing/DicomDirWriter.cpp	Tue May 08 20:48:49 2018 +0200
@@ -164,20 +164,23 @@
                                 const DcmTagKey& key)
     {
       DcmElement* element = NULL;
+      result.clear();
 
       if (source.findAndGetElement(key, element).good())
       {
         char* s = NULL;
         if (element->isLeaf() &&
-            element->getString(s).good() &&
-            s != NULL)
+            element->getString(s).good())
         {
-          result = Toolbox::ConvertToUtf8(s, encoding);
+          if (s != NULL)
+          {
+            result = Toolbox::ConvertToUtf8(s, encoding);
+          }
+          
           return true;
         }
       }
 
-      result.clear();
       return false;
     }