tread_pool: create it on the heap, because creating it static generate a DTOR issue on mingw.

When built with mingw, the tread_pool DTOR is probably called too late, and treads are
not cleaned correctly, and the application hangs on exit.
This commit is contained in:
jean-pierre charras 2022-07-08 19:07:21 +02:00
parent 7036c30384
commit d90a2cc6b5
2 changed files with 7 additions and 5 deletions

View File

@ -397,8 +397,6 @@ bool PGM_BASE::InitPgm( bool aHeadless, bool aSkipPyInit )
}
#endif
GetKiCadThreadPool();
// Init KiCad environment
// the environment variable KICAD (if exists) gives the kicad path:
// something like set KICAD=d:\kicad

View File

@ -24,10 +24,14 @@
#include <thread_pool.h>
// Under mingw, there is a problem with the destructor when creating a static instance
// of a thread_pool: probably the DTOR is called too late, and the application hangs.
// so we create it on the heap.
static thread_pool* tp = nullptr;
thread_pool& GetKiCadThreadPool()
{
static thread_pool tp;
return tp;
}
if( !tp ) tp = new thread_pool;
return *tp;
}