diff options
-rw-r--r-- | src/libslic3r/Print.cpp | 2 | ||||
-rw-r--r-- | src/libslic3r/SLAPrint.cpp | 2 | ||||
-rw-r--r-- | src/libslic3r/Thread.cpp | 18 | ||||
-rw-r--r-- | src/libslic3r/Thread.hpp | 3 | ||||
-rw-r--r-- | src/slic3r/GUI/BackgroundSlicingProcess.cpp | 4 |
5 files changed, 23 insertions, 6 deletions
diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 06052a62f..27dca8243 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -812,7 +812,7 @@ void Print::auto_assign_extruders(ModelObject* model_object) const // Slicing process, running at a background thread. void Print::process() { - name_tbb_thread_pool_threads(); + name_tbb_thread_pool_threads_set_locale(); BOOST_LOG_TRIVIAL(info) << "Starting the slicing process." << log_memory_info(); for (PrintObject *obj : m_objects) diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 0b9dde122..61ff908d3 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -693,7 +693,7 @@ void SLAPrint::process() if (m_objects.empty()) return; - name_tbb_thread_pool_threads(); + name_tbb_thread_pool_threads_set_locale(); // Assumption: at this point the print objects should be populated only with // the model objects we have to process and the instances are also filtered diff --git a/src/libslic3r/Thread.cpp b/src/libslic3r/Thread.cpp index 25c29d273..106da4a78 100644 --- a/src/libslic3r/Thread.cpp +++ b/src/libslic3r/Thread.cpp @@ -188,7 +188,8 @@ std::optional<std::string> get_current_thread_name() #endif // _WIN32 // Spawn (n - 1) worker threads on Intel TBB thread pool and name them by an index and a system thread ID. -void name_tbb_thread_pool_threads() +// Also it sets locale of the worker threads to "C" for the G-code generator to produce "." as a decimal separator. +void name_tbb_thread_pool_threads_set_locale() { static bool initialized = false; if (initialized) @@ -233,6 +234,21 @@ void name_tbb_thread_pool_threads() std::ostringstream name; name << "slic3r_tbb_" << range.begin(); set_current_thread_name(name.str().c_str()); + // Set locales of the worker thread to "C". +#ifdef _WIN32 + _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); + std::setlocale(LC_ALL, "C"); +#else + // We are leaking some memory here, because the newlocale() produced memory will never be released. + // This is not a problem though, as there will be a maximum one worker thread created per physical thread. + uselocale(newlocale( +#ifdef __APPLE__ + LC_ALL_MASK +#else // some Unix / Linux / BSD + LC_ALL +#endif + , "C", nullptr)); +#endif } }); } diff --git a/src/libslic3r/Thread.hpp b/src/libslic3r/Thread.hpp index a86123796..9afe13b42 100644 --- a/src/libslic3r/Thread.hpp +++ b/src/libslic3r/Thread.hpp @@ -33,7 +33,8 @@ std::optional<std::string> get_current_thread_name(); // To be called somewhere before the TBB threads are spinned for the first time, to // give them names recognizible in the debugger. -void name_tbb_thread_pool_threads(); +// Also it sets locale of the worker threads to "C" for the G-code generator to produce "." as a decimal separator. +void name_tbb_thread_pool_threads_set_locale(); template<class Fn> inline boost::thread create_thread(boost::thread::attributes &attrs, Fn &&fn) diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index b4de4a509..e93f32b03 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -209,8 +209,8 @@ void BackgroundSlicingProcess::process_sla() void BackgroundSlicingProcess::thread_proc() { - set_current_thread_name("slic3r_BgSlcPcs"); - name_tbb_thread_pool_threads(); + set_current_thread_name("slic3r_BgSlcPcs"); + name_tbb_thread_pool_threads_set_locale(); assert(m_print != nullptr); assert(m_print == m_fff_print || m_print == m_sla_print); |