diff options
Diffstat (limited to 'src/corelib/global/qglobal.cpp')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 94 |
1 files changed, 88 insertions, 6 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index b30d690025..a369bbe490 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -53,10 +53,6 @@ #include <qmutex.h> -#ifndef QT_NO_QOBJECT -#include <private/qthread_p.h> -#endif - #include <stdlib.h> #include <limits.h> #include <stdarg.h> @@ -650,7 +646,8 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value)); The remaining macros are convenience macros for larger operations: The QT_TR_NOOP(), QT_TRANSLATE_NOOP(), and QT_TRANSLATE_NOOP3() macros provide the possibility of marking strings for delayed - translation. + translation. QT_TR_N_NOOP(), QT_TRANSLATE_N_NOOP(), and + QT_TRANSLATE_N_NOOP3() are numerator dependent variants of these. The Q_ASSERT() and Q_ASSERT_X() enables warning messages of various level of refinement. The Q_FOREACH() and foreach() macros implement Qt's foreach loop. @@ -3450,7 +3447,27 @@ int qEnvironmentVariableIntValue(const char *varName, bool *ok) Q_DECL_NOEXCEPT bool ok_ = true; const char *endptr; const qlonglong value = qstrtoll(buffer, &endptr, 0, &ok_); - if (int(value) != value || *endptr != '\0') { // this is the check in QByteArray::toInt(), keep it in sync + + // Keep the following checks in sync with QByteArray::toInt() + if (!ok_) { + if (ok) + *ok = false; + return 0; + } + + if (*endptr != '\0') { + while (ascii_isspace(*endptr)) + ++endptr; + } + + if (*endptr != '\0') { + // we stopped at a non-digit character after converting some digits + if (ok) + *ok = false; + return 0; + } + + if (int(value) != value) { if (ok) *ok = false; return 0; @@ -3755,6 +3772,71 @@ bool qunsetenv(const char *varName) */ /*! + \macro QT_TR_N_NOOP(sourceText) + \relates <QtGlobal> + \since 5.12 + + Marks the UTF-8 encoded string literal \a sourceText for numerator + dependent delayed translation in the current context (class). + + The macro tells lupdate to collect the string, and expands to + \a sourceText itself. + + The macro expands to \a sourceText. + + Example: + + \snippet code/src_corelib_global_qglobal.cpp qttrnnoop + + \sa QT_TR_NOOP, {Internationalization with Qt} +*/ + +/*! + \macro QT_TRANSLATE_N_NOOP(context, sourceText) + \relates <QtGlobal> + \since 5.12 + + Marks the UTF-8 encoded string literal \a sourceText for numerator + dependent delayed translation in the given \a context. + The \a context is typically a class name and also needs to be + specified as a string literal. + + The macro tells lupdate to collect the string, and expands to + \a sourceText itself. + + Example: + + \snippet code/src_corelib_global_qglobal.cpp qttranslatennoop + + \sa QT_TRANSLATE_NOOP(), QT_TRANSLATE_N_NOOP3(), + {Internationalization with Qt} +*/ + +/*! + \macro QT_TRANSLATE_N_NOOP3(context, sourceText, comment) + \relates <QtGlobal> + \since 5.12 + + Marks the UTF-8 encoded string literal \a sourceText for numerator + dependent delayed translation in the given \a context with the given + \a comment. + The \a context is typically a class and also needs to be specified + as a string literal. The string literal \a disambiguation should be + a short semantic tag to tell apart otherwise identical strings. + + The macro tells lupdate to collect the string, and expands to an + anonymous struct of the two string literals passed as \a sourceText + and \a comment. + + Example: + + \snippet code/src_corelib_global_qglobal.cpp qttranslatennoop3 + + \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), QT_TRANSLATE_NOOP3(), + {Internationalization with Qt} +*/ + +/*! \fn QString qtTrId(const char *id, int n = -1) \relates <QtGlobal> \reentrant |