that way threads will not fail if it is less than the minimum, the warning
from QThread::start() is basically invisible to GUI users unless
application is started from terminal which is far from ideal. one has
to install own message handler via qInstallMsgHandler() to make such
warnings noticable to GUI users, possible via QErrorMessage, which should
be errors in fact and printed via qCritical() but making such changes is
beyond the scope of this commit
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
#include "qcoreapplication_p.h"
#include "qscopedpointer.h"
+#include <limits.h> // for PTHREAD_STACK_MIN
+
QT_BEGIN_NAMESPACE
/*
QMutexLocker locker(&d->mutex);
Q_ASSERT_X(!d->running, "QThread::setStackSize",
"cannot change stack size while the thread is running");
+#ifdef PTHREAD_STACK_MIN
+ int stack_min = sysconf(_SC_THREAD_STACK_MIN);
+ if (stack_min == -1)
+ stack_min = PTHREAD_STACK_MIN;
+ if (Q_UNLIKELY(stackSize < stack_min)) {
+ qWarning("QThread::setStackSize: %u is less than the minimum %u", stackSize, stack_min);
+ stackSize = stack_min;
+ }
+#endif
d->stackSize = stackSize;
}