diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-06-04 05:56:06 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2015-06-04 05:56:06 +0000 |
commit | ccad00121d0a9d703cf715c54347b32bfc33bbfc (patch) | |
tree | 8e492f00f9ea81d87ae9126ad06c3dbc21fee3a3 /src/corelib/global | |
parent | dc2617f35be61b4827b8e3d192c85e2feacf7f6a (diff) | |
parent | e2f66f921594b7be4af4a058c959557489e86879 (diff) |
Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 86 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 5 | ||||
-rw-r--r-- | src/corelib/global/qlogging.cpp | 6 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.h | 9 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 18 | ||||
-rw-r--r-- | src/corelib/global/qtypetraits.h | 21 |
6 files changed, 120 insertions, 25 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 4f611bddbc..91e8699472 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2124,9 +2124,9 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion() # define USE_ETC_OS_RELEASE struct QUnixOSVersion { - // from /etc/os-release older /etc/lsb-release - QString productType; // $ID $DISTRIB_ID - QString productVersion; // $VERSION_ID $DISTRIB_RELEASE + // from /etc/os-release older /etc/lsb-release // redhat /etc/redhat-release // debian /etc/debian_version + QString productType; // $ID $DISTRIB_ID // single line file containing: // Debian + QString productVersion; // $VERSION_ID $DISTRIB_RELEASE // <Vendor_ID release Version_ID> // single line file <Release_ID/sid> QString prettyName; // $PRETTY_NAME $DISTRIB_DESCRIPTION }; @@ -2138,24 +2138,32 @@ static QString unquote(const char *begin, const char *end) } return QString::fromLatin1(begin, end - begin); } - -static bool readEtcFile(QUnixOSVersion &v, const char *filename, - const QByteArray &idKey, const QByteArray &versionKey, const QByteArray &prettyNameKey) +static QByteArray getEtcFileContent(const char *filename) { // we're avoiding QFile here int fd = qt_safe_open(filename, O_RDONLY); if (fd == -1) - return false; + return QByteArray(); QT_STATBUF sbuf; if (QT_FSTAT(fd, &sbuf) == -1) { qt_safe_close(fd); - return false; + return QByteArray(); } QByteArray buffer(sbuf.st_size, Qt::Uninitialized); buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size)); qt_safe_close(fd); + return buffer; +} + +static bool readEtcFile(QUnixOSVersion &v, const char *filename, + const QByteArray &idKey, const QByteArray &versionKey, const QByteArray &prettyNameKey) +{ + + QByteArray buffer = getEtcFileContent(filename); + if (buffer.isEmpty()) + return false; const char *ptr = buffer.constData(); const char *end = buffer.constEnd(); @@ -2219,14 +2227,72 @@ static bool readEtcLsbRelease(QUnixOSVersion &v) } } - return ok; + // some distributions have a /etc/lsb-release file that does not provide the values + // we are looking for, i.e. DISTRIB_ID, DISTRIB_RELEASE and DISTRIB_DESCRIPTION. + // Assuming that neither DISTRIB_ID nor DISTRIB_RELEASE were found, or contained valid values, + // returning false for readEtcLsbRelease will allow further /etc/<lowercasename>-release parsing. + return ok && !(v.productType.isEmpty() && v.productVersion.isEmpty()); } +#if defined(Q_OS_LINUX) +static QByteArray getEtcFileFirstLine(const char *fileName) +{ + QByteArray buffer = getEtcFileContent(fileName); + if (buffer.isEmpty()) + return QByteArray(); + + const char *ptr = buffer.constData(); + int eol = buffer.indexOf("\n"); + return QByteArray(ptr, eol).trimmed(); +} + +static bool readEtcRedHatRelease(QUnixOSVersion &v) +{ + // /etc/redhat-release analysed should be a one line file + // the format of its content is <Vendor_ID release Version> + // i.e. "Red Hat Enterprise Linux Workstation release 6.5 (Santiago)" + QByteArray line = getEtcFileFirstLine("/etc/redhat-release"); + if (line.isEmpty()) + return false; + + v.prettyName = QString::fromLatin1(line); + + const char keyword[] = "release "; + int releaseIndex = line.indexOf(keyword); + v.productType = QString::fromLatin1(line.mid(0, releaseIndex)).remove(QLatin1Char(' ')); + int spaceIndex = line.indexOf(' ', releaseIndex + strlen(keyword)); + v.productVersion = QString::fromLatin1(line.mid(releaseIndex + strlen(keyword), spaceIndex > -1 ? spaceIndex - releaseIndex - strlen(keyword) : -1)); + return true; +} + +static bool readEtcDebianVersion(QUnixOSVersion &v) +{ + // /etc/debian_version analysed should be a one line file + // the format of its content is <Release_ID/sid> + // i.e. "jessie/sid" + QByteArray line = getEtcFileFirstLine("/etc/debian_version"); + if (line.isEmpty()) + return false; + + v.productType = QStringLiteral("Debian"); + v.productVersion = QString::fromLatin1(line); + return true; +} +#endif + static bool findUnixOsVersion(QUnixOSVersion &v) { if (readEtcOsRelease(v)) return true; - return readEtcLsbRelease(v); + if (readEtcLsbRelease(v)) + return true; +#if defined(Q_OS_LINUX) + if (readEtcRedHatRelease(v)) + return true; + if (readEtcDebianVersion(v)) + return true; +#endif + return false; } # endif // USE_ETC_OS_RELEASE #endif // Q_OS_UNIX diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 55aa34223e..4eeee0fef4 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1090,9 +1090,10 @@ Q_CORE_EXPORT int qrand(); #define QT_MODULE(x) -#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__) +#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && \ + (!defined(__PIC__) || (defined(__PIE__) && defined(Q_CC_GNU) && Q_CC_GNU >= 500)) # error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\ - "Compile your code with -fPIC or -fPIE." + "Compile your code with -fPIC (-fPIE is not enough)." #endif namespace QtPrivate { diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index d9d21c535c..88882bbe8f 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -972,8 +972,8 @@ struct QMessagePattern { QElapsedTimer timer; #endif #ifdef QLOGGING_HAVE_BACKTRACE - int backtraceDepth; QString backtraceSeparator; + int backtraceDepth; #endif bool fromEnvironment; @@ -986,8 +986,8 @@ QMessagePattern::QMessagePattern() : literals(0) , tokens(0) #ifdef QLOGGING_HAVE_BACKTRACE - , backtraceDepth(5) , backtraceSeparator(QLatin1Char('|')) + , backtraceDepth(5) #endif , fromEnvironment(false) { @@ -1737,7 +1737,7 @@ void qErrnoWarning(int code, const char *msg, ...) Example: \code - QT_MESSAGE_PATTERN="[%{time yyyyMMdd h:mm:ss.zzz t} %{if-debug}D{%endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}" + QT_MESSAGE_PATTERN="[%{time yyyyMMdd h:mm:ss.zzz t} %{if-debug}D%{endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}" \endcode The default \a pattern is "%{if-category}%{category}: %{endif}%{message}". diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index c6465ed087..fc5207fa25 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -294,10 +294,13 @@ public: WindowCloseButtonHint = 0x08000000, MacWindowToolBarButtonHint = 0x10000000, BypassGraphicsProxyWidget = 0x20000000, - WindowOkButtonHint = 0x00080000, - WindowCancelButtonHint = 0x00100000, NoDropShadowWindowHint = 0x40000000, - WindowFullscreenButtonHint = 0x80000000 + WindowFullscreenButtonHint = 0x80000000, + + // The following enums have overlapping values with other enums. + // This was not intentional, but it's too late to change now. + WindowOkButtonHint = 0x00080000, // WindowTransparentForInput + WindowCancelButtonHint = 0x00100000 // WindowOverridesSystemGestures }; Q_DECLARE_FLAGS(WindowFlags, WindowType) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index b981fed500..970e1b1f42 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2956,15 +2956,19 @@ \enum Qt::NativeGestureType \since 5.2 - \value BeginNativeGesture - \value EndNativeGesture - \value PanNativeGesture - \value ZoomNativeGesture - \value SmartZoomNativeGesture - \value RotateNativeGesture - \value SwipeNativeGesture + This enum returns the gesture type. + + \value BeginNativeGesture Sent before gesture event stream. + \value EndNativeGesture Sent after gesture event stream. + \value PanNativeGesture Sent after a panning gesture. + Similar to a click-and-drag mouse movement. + \value ZoomNativeGesture Specifies the magnification delta in percent. + \value SmartZoomNativeGesture Boolean magnification state. + \value RotateNativeGesture Rotation delta in degrees. + \value SwipeNativeGesture Sent after a swipe movements. */ + /*! \enum Qt::NavigationMode \since 4.6 diff --git a/src/corelib/global/qtypetraits.h b/src/corelib/global/qtypetraits.h index 3a305713e6..488e257e0f 100644 --- a/src/corelib/global/qtypetraits.h +++ b/src/corelib/global/qtypetraits.h @@ -506,6 +506,27 @@ Q_STATIC_ASSERT((!is_unsigned<qint64>::value)); Q_STATIC_ASSERT((!is_signed<quint64>::value)); Q_STATIC_ASSERT(( is_signed<qint64>::value)); +template<class T = void> struct is_default_constructible; + +template<> struct is_default_constructible<void> +{ +protected: + template<bool> struct test { typedef char type; }; +public: + static bool const value = false; +}; +template<> struct is_default_constructible<>::test<true> { typedef double type; }; + +template<class T> struct is_default_constructible : is_default_constructible<> +{ +private: + template<class U> static typename test<!!sizeof(::new U())>::type sfinae(U*); + template<class U> static char sfinae(...); +public: + static bool const value = sizeof(sfinae<T>(0)) > 1; +}; + + } // namespace QtPrivate QT_END_NAMESPACE |