Page MenuHomePhabricator

Make tbssview locale independent
Closed, ResolvedPublic

Description

In an effort to make mitk locale independent we have taken a look at the
following files:

mitk/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssView.cpp

It seems, that floats are written to a stream or gotten from a stream without
specifying the used locale. This can lead to problems if a file is written on a
system with e.g. german locale and read on a system with an english locale or
vice versa. To prevent this kind of problematic behaviour it is suggested to
specify the locale used.

This can be done similar to the following code snippet:

// ... create stream here

// define standard locale
std::locale C("C");

get previous locale of the stream and save it
(especially important in case of cout and cin)
std::locale originalLocale = stream.getloc();

// switch the stream to standard locale
stream.imbue(C);

// ... write your data to file here

// switch back to the previous locale

stream.imbue( originalLocale )

Remember to take care of possible exceptions, by switching back to the original
locale [ stream.imbue( originalLocale ) ] within the exception handling.

Event Timeline

[SVN revision 29204]
FIX (#6661): removed tbss part from open source part

[SVN revision 29205]
FIX (#6661): removed tbss part from open source part