QtCore: use new qEnvironmentVariableIs{Set,Empty}()

In particular, qEmergencyOut() is now completely exception-free.

Incidentally, this patch shows that Qt isn't consistent in how it
treats empty environment variables used as flags, but that is something
for a separate commit. This patch aims to be behaviour-preserving,
except in exceptional circumstances, of course.

Change-Id: Ie106e7b430e1ab086c40c81cc1e56cd0e5400cb4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2012-08-07 00:10:11 +02:00 committed by Qt by Nokia
parent 11b5825fa0
commit 0bd21a8111
6 changed files with 8 additions and 8 deletions

View File

@ -126,7 +126,7 @@ static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap) Q_DECL
if (msgType == QtFatalMsg if (msgType == QtFatalMsg
|| (msgType == QtWarningMsg || (msgType == QtWarningMsg
&& (!qgetenv("QT_FATAL_WARNINGS").isNull())) ) { && qEnvironmentVariableIsSet("QT_FATAL_WARNINGS"))) {
#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) #if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
// get the current report mode // get the current report mode
int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW); int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW);
@ -679,7 +679,7 @@ void qt_message_output(QtMsgType msgType, const QMessageLogContext &context, con
if (msgType == QtFatalMsg if (msgType == QtFatalMsg
|| (msgType == QtWarningMsg || (msgType == QtWarningMsg
&& (!qgetenv("QT_FATAL_WARNINGS").isNull())) ) { && qEnvironmentVariableIsSet("QT_FATAL_WARNINGS")) ) {
#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) #if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
// get the current report mode // get the current report mode

View File

@ -350,7 +350,7 @@ void QCoreApplicationPrivate::createEventDispatcher()
eventDispatcher = new QEventDispatcherBlackberry(q); eventDispatcher = new QEventDispatcherBlackberry(q);
# else # else
# if !defined(QT_NO_GLIB) # if !defined(QT_NO_GLIB)
if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported()) if (qEnvironmentVariableIsEmpty("QT_NO_GLIB") && QEventDispatcherGlib::versionSupported())
eventDispatcher = new QEventDispatcherGlib(q); eventDispatcher = new QEventDispatcherGlib(q);
else else
# endif # endif

View File

@ -293,7 +293,7 @@ static GSourceFuncs postEventSourceFuncs = {
QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context) QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context)
: mainContext(context) : mainContext(context)
{ {
if (qgetenv("QT_NO_THREADED_GLIB").isEmpty()) { if (qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB")) {
static QBasicMutex mutex; static QBasicMutex mutex;
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
if (!g_thread_supported()) if (!g_thread_supported())

View File

@ -188,7 +188,7 @@ enum {
bool QMimeBinaryProvider::isValid() bool QMimeBinaryProvider::isValid()
{ {
#if defined(QT_USE_MMAP) #if defined(QT_USE_MMAP)
if (!qgetenv("QT_NO_MIME_CACHE").isEmpty()) if (!qEnvironmentVariableIsEmpty("QT_NO_MIME_CACHE"))
return false; return false;
Q_ASSERT(m_cacheFiles.isEmpty()); // this method is only ever called once Q_ASSERT(m_cacheFiles.isEmpty()); // this method is only ever called once

View File

@ -256,8 +256,8 @@ void QThreadPrivate::createEventDispatcher(QThreadData *data)
data->eventDispatcher = new QEventDispatcherBlackberry; data->eventDispatcher = new QEventDispatcherBlackberry;
#else #else
#if !defined(QT_NO_GLIB) #if !defined(QT_NO_GLIB)
if (qgetenv("QT_NO_GLIB").isEmpty() if (qEnvironmentVariableIsEmpty("QT_NO_GLIB")
&& qgetenv("QT_NO_THREADED_GLIB").isEmpty() && qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB")
&& QEventDispatcherGlib::versionSupported()) && QEventDispatcherGlib::versionSupported())
data->eventDispatcher = new QEventDispatcherGlib; data->eventDispatcher = new QEventDispatcherGlib;
else else

View File

@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
class QAbstractEventDispatcher *createUnixEventDispatcher() class QAbstractEventDispatcher *createUnixEventDispatcher()
{ {
#if !defined(QT_NO_GLIB) && !defined(Q_OS_WIN) #if !defined(QT_NO_GLIB) && !defined(Q_OS_WIN)
if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported()) if (qEnvironmentVariableIsEmpty("QT_NO_GLIB") && QEventDispatcherGlib::versionSupported())
return new QPAEventDispatcherGlib(); return new QPAEventDispatcherGlib();
else else
#endif #endif