summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-07-06 13:52:42 +0200
committerLiang Qi <liang.qi@qt.io>2017-07-06 13:54:25 +0200
commit7f269a5db8b88fbb14ee741f78e726b1a46c7d4d (patch)
treefa63387e6f70187e656dd9e6c4f1cd1b1f96c263 /src/corelib
parent9ca3443a37284bedaf74475c26af173b00757178 (diff)
parent03b4838cb51513bd5d2edf76dccc4bc4a1181681 (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: .qmake.conf Change-Id: I43531e087bb810889d5c1fbfcdffb29b78804839
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.cpp27
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/io/qfilesystementry.cpp30
-rw-r--r--src/corelib/io/qfilesystementry_p.h3
-rw-r--r--src/corelib/mimetypes/qmimedatabase.cpp2
-rw-r--r--src/corelib/tools/qfreelist_p.h6
-rw-r--r--src/corelib/tools/qlocale_tools.cpp2
7 files changed, 51 insertions, 21 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 9c05b9650c..0e99daeb56 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -96,6 +96,12 @@
#include "archdetect.cpp"
+#ifdef qFatal
+// the qFatal in this file are just redirections from elsewhere, so
+// don't capture any context again
+# undef qFatal
+#endif
+
QT_BEGIN_NAMESPACE
#if !QT_DEPRECATED_SINCE(5, 0)
@@ -3056,13 +3062,20 @@ QString QSysInfo::machineHostName()
If this macro is used outside a function, the behavior is undefined.
*/
-/*
- The Q_CHECK_PTR macro calls this function if an allocation check
- fails.
+/*!
+ \internal
+ The Q_CHECK_PTR macro calls this function if an allocation check
+ fails.
*/
-void qt_check_pointer(const char *n, int l)
+void qt_check_pointer(const char *n, int l) Q_DECL_NOTHROW
{
- qFatal("In file %s, line %d: Out of memory", n, l);
+ // make separate printing calls so that the first one may flush;
+ // the second one could want to allocate memory (fputs prints a
+ // newline and stderr auto-flushes).
+ fputs("Out of memory", stderr);
+ fprintf(stderr, " in %s, line %d\n", n, l);
+
+ std::terminate();
}
/*
@@ -3092,7 +3105,7 @@ Q_NORETURN void qTerminate() Q_DECL_NOTHROW
*/
void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW
{
- qFatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line);
+ QMessageLogger(file, line, nullptr).fatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line);
}
/*
@@ -3100,7 +3113,7 @@ void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW
*/
void qt_assert_x(const char *where, const char *what, const char *file, int line) Q_DECL_NOTHROW
{
- qFatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line);
+ QMessageLogger(file, line, nullptr).fatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line);
}
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index dccbe52ab3..429cd63ab6 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -771,7 +771,7 @@ template <> class QStaticAssertFailure<true> {};
#define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
#endif
-Q_CORE_EXPORT void qt_check_pointer(const char *, int);
+Q_NORETURN Q_CORE_EXPORT void qt_check_pointer(const char *, int) Q_DECL_NOTHROW;
Q_CORE_EXPORT void qBadAlloc();
#ifdef QT_NO_EXCEPTIONS
diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp
index de4c852068..cbff17d0f1 100644
--- a/src/corelib/io/qfilesystementry.cpp
+++ b/src/corelib/io/qfilesystementry.cpp
@@ -297,23 +297,27 @@ bool QFileSystemEntry::isAbsolute() const
bool QFileSystemEntry::isDriveRoot() const
{
resolveFilePath();
+ return QFileSystemEntry::isDriveRootPath(m_filePath);
+}
+
+bool QFileSystemEntry::isDriveRootPath(const QString &path)
+{
#ifndef Q_OS_WINRT
- return (m_filePath.length() == 3
- && m_filePath.at(0).isLetter() && m_filePath.at(1) == QLatin1Char(':')
- && m_filePath.at(2) == QLatin1Char('/'));
+ return (path.length() == 3
+ && path.at(0).isLetter() && path.at(1) == QLatin1Char(':')
+ && path.at(2) == QLatin1Char('/'));
#else // !Q_OS_WINRT
- return m_filePath == QDir::rootPath();
+ return path == QDir::rootPath();
#endif // !Q_OS_WINRT
}
-#endif
+#endif // Q_OS_WIN
-bool QFileSystemEntry::isRoot() const
+bool QFileSystemEntry::isRootPath(const QString &path)
{
- resolveFilePath();
- if (m_filePath == QLatin1String("/")
+ if (path == QLatin1String("/")
#if defined(Q_OS_WIN)
- || isDriveRoot()
- || isUncRoot(m_filePath)
+ || isDriveRootPath(path)
+ || isUncRoot(path)
#endif
)
return true;
@@ -321,6 +325,12 @@ bool QFileSystemEntry::isRoot() const
return false;
}
+bool QFileSystemEntry::isRoot() const
+{
+ resolveFilePath();
+ return isRootPath(m_filePath);
+}
+
bool QFileSystemEntry::isEmpty() const
{
return m_filePath.isEmpty() && m_nativeFilePath.isEmpty();
diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h
index 300a375377..700696d09e 100644
--- a/src/corelib/io/qfilesystementry_p.h
+++ b/src/corelib/io/qfilesystementry_p.h
@@ -94,6 +94,7 @@ public:
#if defined(Q_OS_WIN)
bool isDriveRoot() const;
+ static bool isDriveRootPath(const QString &path);
#endif
bool isRoot() const;
@@ -103,6 +104,8 @@ public:
*this = QFileSystemEntry();
}
+ Q_CORE_EXPORT static bool isRootPath(const QString &path);
+
private:
// creates the QString version out of the bytearray version
void resolveFilePath() const;
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp
index fda9f01643..687f0b3e03 100644
--- a/src/corelib/mimetypes/qmimedatabase.cpp
+++ b/src/corelib/mimetypes/qmimedatabase.cpp
@@ -526,7 +526,7 @@ QMimeType QMimeDatabase::mimeTypeForUrl(const QUrl &url) const
if (scheme.startsWith(QLatin1String("http")) || scheme == QLatin1String("mailto"))
return mimeTypeForName(d->defaultMimeType());
- return mimeTypeForFile(url.path());
+ return mimeTypeForFile(url.path(), MatchExtension);
}
/*!
diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h
index a8d1132d06..2f98cf5cc1 100644
--- a/src/corelib/tools/qfreelist_p.h
+++ b/src/corelib/tools/qfreelist_p.h
@@ -207,7 +207,11 @@ public:
template <typename T, typename ConstantsType>
Q_DECL_CONSTEXPR inline QFreeList<T, ConstantsType>::QFreeList()
- : _next(ConstantsType::InitialNextValue)
+ :
+#if defined(Q_COMPILER_CONSTEXPR)
+ _v{}, // uniform initialization required
+#endif
+ _next(ConstantsType::InitialNextValue)
{ }
template <typename T, typename ConstantsType>
diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp
index 762f4f36dc..3e4f37501e 100644
--- a/src/corelib/tools/qlocale_tools.cpp
+++ b/src/corelib/tools/qlocale_tools.cpp
@@ -370,7 +370,7 @@ double asciiToDouble(const char *num, int numLen, bool &ok, int &processed,
// if a digit before any 'e' is not 0, then a non-zero number was intended.
ok = false;
return 0.0;
- } else if (num[i] == 'e') {
+ } else if (num[i] == 'e' || num[i] == 'E') {
break;
}
}