Refactored loading of Get/SetThreadDescription() on Windows:

These new API functions are not available on Windows 7 and on older Windows 10,
thus they are newly loaded dynamically and the functions using it retur
a bool indicating whether the functionality is supported or not.
Also the OSX variants that are not supported newly return false instead
of throwing an exception.

Fixes #4972 #4974
This commit is contained in:
Vojtech Bubnik 2020-10-26 08:09:03 +01:00
parent 493cdbd069
commit ce020781d3
3 changed files with 119 additions and 73 deletions

View file

@ -213,11 +213,12 @@ std::string AppConfig::load()
void AppConfig::save()
{
#ifndef __APPLE__
// Apple does not implement thread_getname_np() correctly.
if (get_current_thread_name() != "slic3r_main")
throw CriticalException("Calling AppConfig::save() from a worker thread!");
#endif
{
// Returns "undefined" if the thread naming functionality is not supported by the operating system.
std::optional<std::string> current_thread_name = get_current_thread_name();
if (current_thread_name && *current_thread_name != "slic3r_main")
throw CriticalException("Calling AppConfig::save() from a worker thread!");
}
// The config is first written to a file with a PID suffix and then moved
// to avoid race conditions with multiple instances of Slic3r