Fix QThread::idealThreadCount on Unix if sysconf or sysctl fails
The BSD4 code (including OS X) calls sysctl and if that fails, it sets cores to -1. Similarly, the generic Unix code calls sysconf() and assigns the returned value to cores, but sysconf can return -1 on failure. Change-Id: I9e521d366e9c42f36c2ba20a37e7a74539ddb8f4 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
1c1cce67fa
commit
80d0075588
@ -450,7 +450,8 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW
|
||||
// the rest: Linux, Solaris, AIX, Tru64
|
||||
cores = (int)sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#endif
|
||||
|
||||
if (cores == -1)
|
||||
return 1;
|
||||
return cores;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user