[Gate-users] core dumps

Mojca Miklavec mojca.miklavec.lists at gmail.com
Fri Jul 5 18:47:28 CEST 2013


On Fri, Jul 5, 2013 at 8:14 AM, David Sarrut wrote:
>
> Regarding you strange issue with material.db files (I cannot reproduce it),
> it may be related to qt. I remember that qt use/provide some specific
> behavior for reading decimal number according to the user locale. Maybe the
> '.' (dot) is not the character used by your locale (for example in French,
> the '.' is replaced in some software by a ','). If it works everytime
> without qt, try to play with the locale (altough, to be honnest I could
> hardly see the link between qt and the classes that read material) ...

This looks like the answer to me:
    http://stackoverflow.com/questions/7333442/weird-strtod-behaviour
As soon as Qt is loaded, strtod starts being locale-dependent. Line
129 of GateMDBFieldDecoder.cc:
    G4double fieldValue = strtod(fieldAfterPrefix.c_str(),&conversionEndPtr) ;

This fixes the problem:

diff --git a/source/geometry/src/GateMDBFieldDecoder.cc
b/source/geometry/src/GateMDBFieldDecoder.cc
index 96a185a..faa6a73 100755
--- a/source/geometry/src/GateMDBFieldDecoder.cc
+++ b/source/geometry/src/GateMDBFieldDecoder.cc
@@ -126,6 +126,7 @@ G4double
GateMDBFieldDecoder::DecodeFieldFloatingValue(const G4String&
elementNa

   // Convert the string to a double
   char* conversionEndPtr;
+  setlocale(LC_NUMERIC, "C");
   G4double fieldValue = strtod(fieldAfterPrefix.c_str(),&conversionEndPtr) ;
   if (conversionEndPtr==fieldAfterPrefix.c_str())
     DecodingException(elementName,"\tI couldn't find any numerical
value for the " + fieldName + " field\n");

but I'm sure that there is some better place for patching this
(somewhere close to Gate initialisation).

Mojca


More information about the Gate-users mailing list