summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-03-03 13:37:38 +0100
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-03-03 13:37:38 +0100
commitc0a5e8c9d77aefd6c403af39908e56414a921522 (patch)
treec07b28deb9abc9789386f1b10585f1c661bfcba5 /src
parent4fd8513475222ee0afb6f18ec90ba384ffb03bc4 (diff)
parent2b5982aac8ad103443e33379fe5654f5bd419c87 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/plugins/platforms/xcb/qxcbscreen.cpp Change-Id: Ie42931791a849b34b63d814d2eb5ac653986d868
Diffstat (limited to 'src')
-rw-r--r--src/corelib/codecs/qsimplecodec.cpp2
-rw-r--r--src/corelib/doc/src/containers.qdoc2
-rw-r--r--src/corelib/global/qglobal.cpp89
-rw-r--r--src/corelib/global/qlibraryinfo.cpp6
-rw-r--r--src/corelib/io/qdebug.cpp16
-rw-r--r--src/corelib/io/qdebug.h14
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp2
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp9
-rw-r--r--src/corelib/kernel/qmetatype.cpp2
-rw-r--r--src/corelib/kernel/qsharedmemory_posix.cpp1
-rw-r--r--src/corelib/kernel/qsharedmemory_unix.cpp2
-rw-r--r--src/corelib/kernel/qsystemsemaphore_posix.cpp2
-rw-r--r--src/corelib/kernel/qsystemsemaphore_unix.cpp2
-rw-r--r--src/corelib/kernel/qvariant.cpp4
-rw-r--r--src/corelib/plugin/qplugin.qdoc2
-rw-r--r--src/corelib/plugin/qpluginloader.cpp2
-rw-r--r--src/corelib/tools/qlocale_mac.mm13
-rw-r--r--src/corelib/tools/qsimd.cpp4
-rw-r--r--src/dbus/qdbusconnection.cpp2
-rw-r--r--src/dbus/qdbusintrospection.cpp8
-rw-r--r--src/gui/image/qimage.cpp2
-rw-r--r--src/gui/kernel/qguiapplication.cpp40
-rw-r--r--src/gui/kernel/qguiapplication_p.h4
-rw-r--r--src/gui/kernel/qplatforminputcontext.cpp10
-rw-r--r--src/gui/kernel/qplatformintegration.cpp10
-rw-r--r--src/gui/kernel/qplatformintegration.h3
-rw-r--r--src/gui/kernel/qsimpledrag.cpp8
-rw-r--r--src/gui/kernel/qstylehints.cpp5
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp6
-rw-r--r--src/gui/kernel/qtouchdevice.cpp3
-rw-r--r--src/gui/kernel/qtouchdevice.h3
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp50
-rw-r--r--src/gui/math3d/qquaternion.cpp73
-rw-r--r--src/gui/math3d/qquaternion.h17
-rw-r--r--src/gui/math3d/qvector3d.cpp2
-rw-r--r--src/gui/opengl/qopenglpaintengine.cpp7
-rw-r--r--src/gui/opengl/qopenglshaderprogram.cpp2
-rw-r--r--src/gui/painting/qbezier.cpp3
-rw-r--r--src/gui/painting/qdrawhelper.cpp7
-rw-r--r--src/gui/painting/qdrawhelper_p.h7
-rw-r--r--src/gui/painting/qdrawingprimitive_sse2_p.h3
-rw-r--r--src/gui/painting/qmath_p.h7
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp3
-rw-r--r--src/gui/painting/qpainter.cpp2
-rw-r--r--src/gui/painting/qstroker.cpp3
-rw-r--r--src/gui/text/qdistancefield.cpp11
-rw-r--r--src/gui/text/qdistancefield_p.h1
-rw-r--r--src/gui/text/qtextdocument.cpp2
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp39
-rw-r--r--src/gui/text/qtextengine.cpp2
-rw-r--r--src/network/ssl/qsslcontext_openssl.cpp9
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp7
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp2
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm14
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm15
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm1
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemsettings.mm3
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm2
-rw-r--r--src/plugins/platforms/ios/qiosmenu.mm8
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp5
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.h3
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp24
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp28
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.h6
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp7
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp3
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.cpp2
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp94
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h3
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp11
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h5
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp10
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp66
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h9
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp2
-rw-r--r--src/testlib/qtestcase.cpp2
-rw-r--r--src/tools/qdoc/cppcodeparser.cpp85
-rw-r--r--src/tools/qdoc/cppcodeparser.h2
-rw-r--r--src/tools/qdoc/node.cpp11
-rw-r--r--src/tools/qdoc/node.h16
-rw-r--r--src/tools/qdoc/qdocdatabase.cpp1
-rw-r--r--src/tools/qdoc/tree.cpp26
-rw-r--r--src/tools/qdoc/tree.h1
-rw-r--r--src/widgets/doc/src/modelview.qdoc2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp8
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp59
-rw-r--r--src/widgets/kernel/qapplication.h4
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp42
-rw-r--r--src/widgets/kernel/qwidget_p.h2
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp2
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm19
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp2
-rw-r--r--src/widgets/widgets/qcombobox.cpp2
-rw-r--r--src/widgets/widgets/qlineedit.cpp2
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp4
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp2
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h4
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp8
110 files changed, 779 insertions, 421 deletions
diff --git a/src/corelib/codecs/qsimplecodec.cpp b/src/corelib/codecs/qsimplecodec.cpp
index c0c1d6d906..9defa3d015 100644
--- a/src/corelib/codecs/qsimplecodec.cpp
+++ b/src/corelib/codecs/qsimplecodec.cpp
@@ -507,7 +507,7 @@ static const struct {
0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF} },
- { "macintosh", { "Apple Roman", "MacRoman", 0 }, -168,
+ { "macintosh", { "Apple Roman", "MacRoman", 0 }, 2027,
{ 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3,
diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc
index 58c7569964..1979c45e17 100644
--- a/src/corelib/doc/src/containers.qdoc
+++ b/src/corelib/doc/src/containers.qdoc
@@ -465,7 +465,7 @@
imaginary item one position past the last item in the container.
\l {QList::end()}{end()} marks an invalid position; it must never be dereferenced.
It is typically used in a loop's break condition. If the list is
- empty, \l{QList::begin}{begin()} equals \l{QList:end()}{end()}, so we never execute the loop.
+ empty, \l{QList::begin}{begin()} equals \l{QList::end()}{end()}, so we never execute the loop.
The diagram below shows the valid iterator positions as red
arrows for a vector containing four items:
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 712e84185c..7913af3103 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Copyright (C) 2014 Intel Corporation
+** Copyright (C) 2015 Intel Corporation
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -2120,10 +2120,10 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
# define USE_ETC_OS_RELEASE
struct QUnixOSVersion
{
- // from /etc/os-release
- QString productType; // $ID
- QString productVersion; // $VERSION_ID
- QString prettyName; // $PRETTY_NAME
+ // from /etc/os-release older /etc/lsb-release
+ QString productType; // $ID $DISTRIB_ID
+ QString productVersion; // $VERSION_ID $DISTRIB_RELEASE
+ QString prettyName; // $PRETTY_NAME $DISTRIB_DESCRIPTION
};
static QString unquote(const char *begin, const char *end)
@@ -2135,10 +2135,11 @@ static QString unquote(const char *begin, const char *end)
return QString::fromLatin1(begin, end - begin);
}
-static bool readEtcOsRelease(QUnixOSVersion &v)
+static bool readEtcFile(QUnixOSVersion &v, const char *filename,
+ const QByteArray &idKey, const QByteArray &versionKey, const QByteArray &prettyNameKey)
{
// we're avoiding QFile here
- int fd = qt_safe_open("/etc/os-release", O_RDONLY);
+ int fd = qt_safe_open(filename, O_RDONLY);
if (fd == -1)
return false;
@@ -2155,41 +2156,28 @@ static bool readEtcOsRelease(QUnixOSVersion &v)
const char *ptr = buffer.constData();
const char *end = buffer.constEnd();
const char *eol;
+ QByteArray line;
for ( ; ptr != end; ptr = eol + 1) {
- static const char idString[] = "ID=";
- static const char prettyNameString[] = "PRETTY_NAME=";
- static const char versionIdString[] = "VERSION_ID=";
-
// find the end of the line after ptr
eol = static_cast<const char *>(memchr(ptr, '\n', end - ptr));
if (!eol)
eol = end - 1;
+ line.setRawData(ptr, eol - ptr);
- // note: we're doing a binary search here, so comparison
- // must always be sorted
- int cmp = strncmp(ptr, idString, strlen(idString));
- if (cmp < 0)
- continue;
- if (cmp == 0) {
- ptr += strlen(idString);
+ if (line.startsWith(idKey)) {
+ ptr += idKey.length();
v.productType = unquote(ptr, eol);
continue;
}
- cmp = strncmp(ptr, prettyNameString, strlen(prettyNameString));
- if (cmp < 0)
- continue;
- if (cmp == 0) {
- ptr += strlen(prettyNameString);
+ if (line.startsWith(prettyNameKey)) {
+ ptr += prettyNameKey.length();
v.prettyName = unquote(ptr, eol);
continue;
}
- cmp = strncmp(ptr, versionIdString, strlen(versionIdString));
- if (cmp < 0)
- continue;
- if (cmp == 0) {
- ptr += strlen(versionIdString);
+ if (line.startsWith(versionKey)) {
+ ptr += versionKey.length();
v.productVersion = unquote(ptr, eol);
continue;
}
@@ -2197,6 +2185,45 @@ static bool readEtcOsRelease(QUnixOSVersion &v)
return true;
}
+
+static bool readEtcOsRelease(QUnixOSVersion &v)
+{
+ return readEtcFile(v, "/etc/os-release", QByteArrayLiteral("ID="),
+ QByteArrayLiteral("VERSION_ID="), QByteArrayLiteral("PRETTY_NAME="));
+}
+
+static bool readEtcLsbRelease(QUnixOSVersion &v)
+{
+ bool ok = readEtcFile(v, "/etc/lsb-release", QByteArrayLiteral("DISTRIB_ID="),
+ QByteArrayLiteral("DISTRIB_RELEASE="), QByteArrayLiteral("DISTRIB_DESCRIPTION="));
+ if (ok && (v.prettyName.isEmpty() || v.prettyName == v.productType)) {
+ // some distributions have redundant information for the pretty name,
+ // so try /etc/<lowercasename>-release
+
+ // we're still avoiding QFile here
+ QByteArray distrorelease = "/etc/" + v.productType.toLatin1().toLower() + "-release";
+ int fd = qt_safe_open(distrorelease, O_RDONLY);
+ if (fd != -1) {
+ QT_STATBUF sbuf;
+ if (QT_FSTAT(fd, &sbuf) != -1 && sbuf.st_size > v.prettyName.length()) {
+ // file apparently contains interesting information
+ QByteArray buffer(sbuf.st_size, Qt::Uninitialized);
+ buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size));
+ v.prettyName = QString::fromLatin1(buffer.trimmed());
+ }
+ qt_safe_close(fd);
+ }
+ }
+
+ return ok;
+}
+
+static bool findUnixOsVersion(QUnixOSVersion &v)
+{
+ if (readEtcOsRelease(v))
+ return true;
+ return readEtcLsbRelease(v);
+}
# endif // USE_ETC_OS_RELEASE
#endif // Q_OS_UNIX
@@ -2531,7 +2558,7 @@ QString QSysInfo::productType()
#elif defined(USE_ETC_OS_RELEASE) // Q_OS_UNIX
QUnixOSVersion unixOsVersion;
- readEtcOsRelease(unixOsVersion);
+ findUnixOsVersion(unixOsVersion);
if (!unixOsVersion.productType.isEmpty())
return unixOsVersion.productType;
#endif
@@ -2587,7 +2614,7 @@ QString QSysInfo::productVersion()
}
#elif defined(USE_ETC_OS_RELEASE) // Q_OS_UNIX
QUnixOSVersion unixOsVersion;
- readEtcOsRelease(unixOsVersion);
+ findUnixOsVersion(unixOsVersion);
if (!unixOsVersion.productVersion.isEmpty())
return unixOsVersion.productVersion;
#endif
@@ -2664,7 +2691,7 @@ QString QSysInfo::prettyProductName()
#elif defined(Q_OS_UNIX)
# ifdef USE_ETC_OS_RELEASE
QUnixOSVersion unixOsVersion;
- readEtcOsRelease(unixOsVersion);
+ findUnixOsVersion(unixOsVersion);
if (!unixOsVersion.prettyName.isEmpty())
return unixOsVersion.prettyName;
# endif
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 9211ce17e8..322fc2f651 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -230,7 +230,7 @@ QLibraryInfo::licensedProducts()
/*!
\since 4.6
\deprecated
- This function used to return the the installation date for this build of Qt, but now returns an a constant date.
+ This function used to return the installation date for this build of Qt, but now returns a constant date.
*/
#ifndef QT_NO_DATESTRING
#if QT_DEPRECATED_SINCE(5, 5)
@@ -457,8 +457,10 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
defaultValue = QLatin1String(qtConfEntries[loc].value);
}
#ifndef Q_OS_WIN // On Windows we use the registry
- else if (loc == SettingsPath)
+ else if (loc == SettingsPath) {
key = QLatin1String("Settings");
+ defaultValue = QLatin1String(".");
+ }
#endif
if(!key.isNull()) {
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index f55f68f9b3..357d63137c 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -661,6 +661,20 @@ QDebug qt_QMetaEnum_debugOperator(QDebug &dbg, int value, const QMetaObject *met
dbg << ')';
return dbg;
}
-#endif
+
+QDebug qt_QMetaEnum_flagDebugOperator(QDebug &debug, quint64 value, const QMetaObject *meta, const char *name)
+{
+ QDebugStateSaver saver(debug);
+ debug.resetFormat();
+ debug.noquote();
+ debug.nospace();
+ debug << "QFlags<";
+ const QMetaEnum me = meta->enumerator(meta->indexOfEnumerator(name));
+ if (const char *scope = me.scope())
+ debug << scope << "::";
+ debug << me.name() << ">(" << me.valueToKeys(value) << ')';
+ return debug;
+}
+#endif // !QT_NO_QOBJECT
QT_END_NAMESPACE
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index 435e7450c7..7f1cb82f3a 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -263,6 +263,7 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache<T> &cache)
#ifndef QT_NO_QOBJECT
Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaObject *meta, const char *name);
+Q_CORE_EXPORT QDebug qt_QMetaEnum_flagDebugOperator(QDebug &dbg, quint64 value, const QMetaObject *meta, const char *name);
template<typename T>
typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type
@@ -272,10 +273,21 @@ operator<<(QDebug dbg, T value)
const char *name = qt_getEnumName(value);
return qt_QMetaEnum_debugOperator(dbg, typename QFlags<T>::Int(value), obj, name);
}
-#endif
template <class T>
+inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type operator<<(QDebug debug, const QFlags<T> &flags)
+{
+ const QMetaObject *obj = qt_getEnumMetaObject(T());
+ const char *name = qt_getEnumName(T());
+ return qt_QMetaEnum_flagDebugOperator(debug, quint64(flags), obj, name);
+}
+
+template <class T>
+inline typename QtPrivate::QEnableIf<!QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type operator<<(QDebug debug, const QFlags<T> &flags)
+#else // !QT_NO_QOBJECT
+template <class T>
inline QDebug operator<<(QDebug debug, const QFlags<T> &flags)
+#endif
{
QDebugStateSaver saver(debug);
debug.resetFormat();
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index a1a00016fd..5b18a85dd4 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -544,7 +544,7 @@ bool QFSFileEngine::renameOverwrite(const QString &newName)
bool ret = ::DeleteAndRenameFile((wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16(),
(wchar_t*)d->fileEntry.nativeFilePath().utf16()) != 0;
if (!ret) {
- ret = ::DeleteFile((wchar_t*)d->fileEntry.nativeFilePath().utf16()) != 0;
+ ret = ::DeleteFile((wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0;
if (ret)
ret = ::MoveFile((wchar_t*)d->fileEntry.nativeFilePath().utf16(),
(wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0;
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index 7e23709f1b..3882da30a7 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -1200,7 +1200,7 @@ void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::
\fn void QItemSelectionModel::modelChanged(QAbstractItemModel *model)
\since 5.5
- This signal is emitted when the model is successfully set with setModel().
+ This signal is emitted when the \a model is successfully set with setModel().
\sa model(), setModel()
*/
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 4baf09167b..e89b914227 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -2665,20 +2665,21 @@ QByteArray QMetaEnum::valueToKeys(int value) const
int count = mobj->d.data[handle + 2];
int data = mobj->d.data[handle + 3];
int v = value;
- for(int i = 0; i < count; i++) {
+ // reverse iterate to ensure values like Qt::Dialog=0x2|Qt::Window are processed first.
+ for (int i = count - 1; i >= 0; --i) {
int k = mobj->d.data[data + 2*i + 1];
if ((k != 0 && (v & k) == k ) || (k == value)) {
v = v & ~k;
if (!keys.isEmpty())
- keys += '|';
- keys += stringData(mobj, mobj->d.data[data + 2*i]);
+ keys.prepend('|');
+ keys.prepend(stringData(mobj, mobj->d.data[data + 2*i]));
}
}
return keys;
}
/*!
- \fn QMetaEnum QMetaEnum::fromType() const
+ \fn QMetaEnum QMetaEnum::fromType()
\since 5.5
Returns the QMetaEnum corresponding to the type in the template parameter.
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 8adb4a4903..305e998818 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -1117,7 +1117,7 @@ bool QMetaType::isRegistered(int type)
}
/*!
- \fn int qMetaTypeTypeImpl(const char *typeName)
+ \fn int qMetaTypeTypeImpl(const char *typeName, int length)
\internal
Implementation of QMetaType::type().
diff --git a/src/corelib/kernel/qsharedmemory_posix.cpp b/src/corelib/kernel/qsharedmemory_posix.cpp
index 4f9b3b1429..74f98a158a 100644
--- a/src/corelib/kernel/qsharedmemory_posix.cpp
+++ b/src/corelib/kernel/qsharedmemory_posix.cpp
@@ -46,7 +46,6 @@
#ifndef QT_NO_SHAREDMEMORY
#include <sys/types.h>
-#include <sys/ipc.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp
index 4f55e523e3..92184a619b 100644
--- a/src/corelib/kernel/qsharedmemory_unix.cpp
+++ b/src/corelib/kernel/qsharedmemory_unix.cpp
@@ -42,8 +42,8 @@
#ifndef QT_NO_SHAREDMEMORY
#include <sys/types.h>
-#include <sys/ipc.h>
#ifndef QT_POSIX_IPC
+#include <sys/ipc.h>
#include <sys/shm.h>
#else
#include <sys/mman.h>
diff --git a/src/corelib/kernel/qsystemsemaphore_posix.cpp b/src/corelib/kernel/qsystemsemaphore_posix.cpp
index abe3cc7e8c..5a8e5941b7 100644
--- a/src/corelib/kernel/qsystemsemaphore_posix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_posix.cpp
@@ -45,8 +45,6 @@
#ifndef QT_NO_SYSTEMSEMAPHORE
#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
#include <fcntl.h>
#include <errno.h>
diff --git a/src/corelib/kernel/qsystemsemaphore_unix.cpp b/src/corelib/kernel/qsystemsemaphore_unix.cpp
index cb34b8aeff..d1ec39ea40 100644
--- a/src/corelib/kernel/qsystemsemaphore_unix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_unix.cpp
@@ -40,8 +40,8 @@
#ifndef QT_NO_SYSTEMSEMAPHORE
#include <sys/types.h>
-#include <sys/ipc.h>
#ifndef QT_POSIX_IPC
+#include <sys/ipc.h>
#include <sys/sem.h>
#endif
#include <fcntl.h>
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 3dc0805dd1..b14c9ed167 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -460,7 +460,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
{
QMetaEnum en = metaEnumFromType(d->type);
if (en.isValid()) {
- *str = QString::fromUtf8(en.valueToKeys(qConvertToNumber(d, ok)));
+ *str = QString::fromUtf8(en.valueToKey(qConvertToNumber(d, ok)));
return *ok;
}
}
@@ -637,7 +637,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
{
QMetaEnum en = metaEnumFromType(d->type);
if (en.isValid()) {
- *ba = en.valueToKeys(qConvertToNumber(d, ok));
+ *ba = en.valueToKey(qConvertToNumber(d, ok));
return *ok;
}
}
diff --git a/src/corelib/plugin/qplugin.qdoc b/src/corelib/plugin/qplugin.qdoc
index 35dd52218a..81be1df518 100644
--- a/src/corelib/plugin/qplugin.qdoc
+++ b/src/corelib/plugin/qplugin.qdoc
@@ -44,7 +44,7 @@
to the interface class called \a ClassName. The \a Identifier must
be unique. For example:
- \snippet plugins/interfaces.h 3
+ \snippet code/doc_src_qplugin.cpp 0
This macro is normally used right after the class definition for
\a ClassName, in a header file. See the
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index 2151108bb7..2800656c13 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -428,7 +428,7 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin plugin)
/*!
Returns a list of static plugin instances (root components) held
by the plugin loader.
- \sa staticPlugin()
+ \sa staticPlugins()
*/
QObjectList QPluginLoader::staticInstances()
{
diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm
index b581e33aef..37a63a2ca4 100644
--- a/src/corelib/tools/qlocale_mac.mm
+++ b/src/corelib/tools/qlocale_mac.mm
@@ -44,6 +44,18 @@
QT_BEGIN_NAMESPACE
+namespace {
+class AutoReleasePool
+{
+public:
+ AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
+ ~AutoReleasePool() { [pool release]; }
+
+private:
+ NSAutoreleasePool *pool;
+};
+}
+
/******************************************************************************
** Wrappers for Mac locale system functions
*/
@@ -414,6 +426,7 @@ QLocale QSystemLocale::fallbackUiLocale() const
QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
{
+ AutoReleasePool pool;
switch(type) {
// case Name:
// return getMacLocaleName();
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index a031080fdb..52ffc161bf 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -512,7 +512,9 @@ int ffs(int i)
#endif
}
#endif
-#endif // Q_OS_WIN
+#elif defined(Q_OS_ANDROID)
+# define ffs __builtin_ffs
+#endif
QBasicAtomicInt qt_cpu_features = Q_BASIC_ATOMIC_INITIALIZER(0);
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index ff897faab6..5dc18fe908 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -1110,7 +1110,7 @@ QDBusConnection QDBusConnection::systemBus()
\deprecated
Always returns a disconnected, invalid QDBusConnection object. For the old
- functionality of determining the sender connection, please use \ref QDBusContext.
+ functionality of determining the sender connection, please use QDBusContext.
\sa QDBusContext
*/
diff --git a/src/dbus/qdbusintrospection.cpp b/src/dbus/qdbusintrospection.cpp
index e7daa4afda..2190066953 100644
--- a/src/dbus/qdbusintrospection.cpp
+++ b/src/dbus/qdbusintrospection.cpp
@@ -267,14 +267,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \variable QDBusIntrospection::Object::introspection
- The XML document fragment describing this object, its interfaces and sub-objects at the time
- of the parsing.
-
- The result of parseObject with this XML data should be the same as the Object struct.
-*/
-
-/*!
\variable QDBusIntrospection::Object::interfaces
The list of interface names in this object.
*/
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index e6f86fceaa..e33ab24243 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -4596,7 +4596,7 @@ bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFla
return true;
// No in-place conversion if we have to detach
- if (ref.load() > 1)
+ if (ref.load() > 1 || ro_data)
return false;
const InPlace_Image_Converter *const converterPtr = &qimage_inplace_converter_map[format][newFormat];
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 0d5a130dfd..b60ef4b8c1 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -105,6 +105,14 @@
QT_BEGIN_NAMESPACE
+// Helper macro for static functions to check on the existence of the application class.
+#define CHECK_QAPP_INSTANCE(...) \
+ if (Q_LIKELY(QCoreApplication::instance())) { \
+ } else { \
+ qWarning("Must construct a QGuiApplication first."); \
+ return __VA_ARGS__; \
+ }
+
Q_GUI_EXPORT bool qt_is_gui_used = true;
Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton;
@@ -163,6 +171,7 @@ QWindow *QGuiApplicationPrivate::focus_window = 0;
static QBasicMutex applicationFontMutex;
QFont *QGuiApplicationPrivate::app_font = 0;
+QStyleHints *QGuiApplicationPrivate::styleHints = Q_NULLPTR;
bool QGuiApplicationPrivate::obey_desktop_settings = true;
QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = 0;
@@ -595,7 +604,6 @@ QGuiApplication::~QGuiApplication()
QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags)
: QCoreApplicationPrivate(argc, argv, flags),
- styleHints(0),
inputMethod(0),
lastTouchType(QEvent::TouchEnd),
ownGlobalShareContext(false)
@@ -648,6 +656,7 @@ QString QGuiApplication::applicationDisplayName()
*/
QWindow *QGuiApplication::modalWindow()
{
+ CHECK_QAPP_INSTANCE(Q_NULLPTR)
if (QGuiApplicationPrivate::self->modalWindowList.isEmpty())
return 0;
return QGuiApplicationPrivate::self->modalWindowList.first();
@@ -788,12 +797,6 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking
return false;
}
-bool QGuiApplicationPrivate::synthesizeMouseFromTouchEventsEnabled()
-{
- return QCoreApplication::testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)
- && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool();
-}
-
/*!
Returns the QWindow that receives events tied to focus,
such as key events.
@@ -1355,7 +1358,8 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate()
cleanupThreadData();
- delete styleHints;
+ delete QGuiApplicationPrivate::styleHints;
+ QGuiApplicationPrivate::styleHints = Q_NULLPTR;
delete inputMethod;
qt_cleanupFontDatabase();
@@ -1435,6 +1439,7 @@ Qt::KeyboardModifiers QGuiApplication::keyboardModifiers()
*/
Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers()
{
+ CHECK_QAPP_INSTANCE(Qt::KeyboardModifiers(0))
QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
return pi->queryKeyboardModifiers();
}
@@ -1723,7 +1728,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
}
mouse_buttons = buttons = e->buttons;
if (button & e->buttons) {
- ulong doubleClickInterval = static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval());
+ ulong doubleClickInterval = static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval());
doubleClick = e->timestamp - mousePressTime < doubleClickInterval && button == mousePressButton;
type = frameStrut ? QEvent::NonClientAreaMouseButtonPress : QEvent::MouseButtonPress;
mousePressTime = e->timestamp;
@@ -2423,9 +2428,9 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
}
QGuiApplication::sendSpontaneousEvent(w, &touchEvent);
- if (!e->synthetic() && !touchEvent.isAccepted() && synthesizeMouseFromTouchEventsEnabled()) {
- // exclude touchpads as those generate their own mouse events
- if (touchEvent.device()->type() != QTouchDevice::TouchPad) {
+ if (!e->synthetic() && !touchEvent.isAccepted() && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) {
+ // exclude devices which generate their own mouse events
+ if (!(touchEvent.device()->capabilities() & QTouchDevice::MouseEmulation)) {
Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton;
if (b == Qt::NoButton)
self->synthesizedMousePoints.clear();
@@ -3172,6 +3177,7 @@ Qt::LayoutDirection QGuiApplication::layoutDirection()
#ifndef QT_NO_CURSOR
QCursor *QGuiApplication::overrideCursor()
{
+ CHECK_QAPP_INSTANCE(Q_NULLPTR)
return qGuiApp->d_func()->cursor_list.isEmpty() ? 0 : &qGuiApp->d_func()->cursor_list.first();
}
@@ -3185,6 +3191,7 @@ QCursor *QGuiApplication::overrideCursor()
*/
void QGuiApplication::changeOverrideCursor(const QCursor &cursor)
{
+ CHECK_QAPP_INSTANCE()
if (qGuiApp->d_func()->cursor_list.isEmpty())
return;
qGuiApp->d_func()->cursor_list.removeFirst();
@@ -3259,6 +3266,7 @@ static inline void applyWindowCursor(const QList<QWindow *> &l)
*/
void QGuiApplication::setOverrideCursor(const QCursor &cursor)
{
+ CHECK_QAPP_INSTANCE()
qGuiApp->d_func()->cursor_list.prepend(cursor);
applyCursor(QGuiApplicationPrivate::window_list, cursor);
}
@@ -3276,6 +3284,7 @@ void QGuiApplication::setOverrideCursor(const QCursor &cursor)
*/
void QGuiApplication::restoreOverrideCursor()
{
+ CHECK_QAPP_INSTANCE()
if (qGuiApp->d_func()->cursor_list.isEmpty())
return;
qGuiApp->d_func()->cursor_list.removeFirst();
@@ -3300,9 +3309,9 @@ void QGuiApplication::restoreOverrideCursor()
*/
QStyleHints *QGuiApplication::styleHints()
{
- if (!qGuiApp->d_func()->styleHints)
- qGuiApp->d_func()->styleHints = new QStyleHints();
- return qGuiApp->d_func()->styleHints;
+ if (!QGuiApplicationPrivate::styleHints)
+ QGuiApplicationPrivate::styleHints = new QStyleHints();
+ return QGuiApplicationPrivate::styleHints;
}
/*!
@@ -3343,6 +3352,7 @@ bool QGuiApplication::desktopSettingsAware()
*/
QInputMethod *QGuiApplication::inputMethod()
{
+ CHECK_QAPP_INSTANCE(Q_NULLPTR)
if (!qGuiApp->d_func()->inputMethod)
qGuiApp->d_func()->inputMethod = new QInputMethod();
return qGuiApp->d_func()->inputMethod;
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index d29ebf5f10..0c00e06499 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -190,8 +190,6 @@ public:
static void updateBlockedStatus(QWindow *window);
virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const;
- static bool synthesizeMouseFromTouchEventsEnabled();
-
static Qt::MouseButtons buttons;
static ulong mousePressTime;
static Qt::MouseButton mousePressButton;
@@ -220,7 +218,7 @@ public:
static QFont *app_font;
- QStyleHints *styleHints;
+ static QStyleHints *styleHints;
static bool obey_desktop_settings;
QInputMethod *inputMethod;
diff --git a/src/gui/kernel/qplatforminputcontext.cpp b/src/gui/kernel/qplatforminputcontext.cpp
index e983ded20b..f9ff1d36d9 100644
--- a/src/gui/kernel/qplatforminputcontext.cpp
+++ b/src/gui/kernel/qplatforminputcontext.cpp
@@ -163,7 +163,7 @@ QRectF QPlatformInputContext::keyboardRect() const
*/
void QPlatformInputContext::emitKeyboardRectChanged()
{
- emit qApp->inputMethod()->keyboardRectangleChanged();
+ emit QGuiApplication::inputMethod()->keyboardRectangleChanged();
}
/*!
@@ -182,7 +182,7 @@ bool QPlatformInputContext::isAnimating() const
*/
void QPlatformInputContext::emitAnimatingChanged()
{
- emit qApp->inputMethod()->animatingChanged();
+ emit QGuiApplication::inputMethod()->animatingChanged();
}
/*!
@@ -214,7 +214,7 @@ bool QPlatformInputContext::isInputPanelVisible() const
*/
void QPlatformInputContext::emitInputPanelVisibleChanged()
{
- emit qApp->inputMethod()->visibleChanged();
+ emit QGuiApplication::inputMethod()->visibleChanged();
}
QLocale QPlatformInputContext::locale() const
@@ -224,7 +224,7 @@ QLocale QPlatformInputContext::locale() const
void QPlatformInputContext::emitLocaleChanged()
{
- emit qApp->inputMethod()->localeChanged();
+ emit QGuiApplication::inputMethod()->localeChanged();
}
Qt::LayoutDirection QPlatformInputContext::inputDirection() const
@@ -234,7 +234,7 @@ Qt::LayoutDirection QPlatformInputContext::inputDirection() const
void QPlatformInputContext::emitInputDirectionChanged(Qt::LayoutDirection newDirection)
{
- emit qApp->inputMethod()->inputDirectionChanged(newDirection);
+ emit QGuiApplication::inputMethod()->inputDirectionChanged(newDirection);
}
/*!
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index d2db6af52b..6147a2a53a 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -386,8 +386,6 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return QPlatformTheme::defaultThemeHint(QPlatformTheme::StartDragVelocity);
case UseRtlExtensions:
return QVariant(false);
- case SynthesizeMouseFromTouchEvents:
- return true;
case SetFocusOnTouchRelease:
return QVariant(false);
case MousePressAndHoldInterval:
@@ -443,11 +441,15 @@ QList<int> QPlatformIntegration::possibleKeys(const QKeyEvent *) const
The screen should be deleted by calling QPlatformIntegration::destroyScreen().
*/
-void QPlatformIntegration::screenAdded(QPlatformScreen *ps)
+void QPlatformIntegration::screenAdded(QPlatformScreen *ps, bool isPrimary)
{
QScreen *screen = new QScreen(ps);
ps->d_func()->screen = screen;
- QGuiApplicationPrivate::screen_list << screen;
+ if (isPrimary) {
+ QGuiApplicationPrivate::screen_list.prepend(screen);
+ } else {
+ QGuiApplicationPrivate::screen_list.append(screen);
+ }
emit qGuiApp->screenAdded(screen);
}
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index a0756a4992..24e19f68e6 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -141,7 +141,6 @@ public:
FontSmoothingGamma,
StartDragVelocity,
UseRtlExtensions,
- SynthesizeMouseFromTouchEvents,
PasswordMaskCharacter,
SetFocusOnTouchRelease,
ShowIsMaximized,
@@ -171,7 +170,7 @@ public:
#endif
protected:
- void screenAdded(QPlatformScreen *screen);
+ void screenAdded(QPlatformScreen *screen, bool isPrimary = false);
void destroyScreen(QPlatformScreen *screen);
};
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index b3dc6e915d..090e88c118 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -255,18 +255,18 @@ void QBasicDrag::updateCursor(Qt::DropAction action)
}
}
- QCursor *cursor = qApp->overrideCursor();
+ QCursor *cursor = QGuiApplication::overrideCursor();
QPixmap pixmap = m_drag->dragCursor(action);
if (!cursor) {
- qApp->changeOverrideCursor((pixmap.isNull()) ? QCursor(cursorShape) : QCursor(pixmap));
+ QGuiApplication::changeOverrideCursor((pixmap.isNull()) ? QCursor(cursorShape) : QCursor(pixmap));
} else {
if (!pixmap.isNull()) {
if ((cursor->pixmap().cacheKey() != pixmap.cacheKey())) {
- qApp->changeOverrideCursor(QCursor(pixmap));
+ QGuiApplication::changeOverrideCursor(QCursor(pixmap));
}
} else {
if (cursorShape != cursor->shape()) {
- qApp->changeOverrideCursor(QCursor(cursorShape));
+ QGuiApplication::changeOverrideCursor(QCursor(cursorShape));
}
}
}
diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp
index a0f98383ff..b7af2e759f 100644
--- a/src/gui/kernel/qstylehints.cpp
+++ b/src/gui/kernel/qstylehints.cpp
@@ -35,6 +35,7 @@
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformtheme.h>
#include <private/qguiapplication_p.h>
+#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -46,6 +47,10 @@ static inline QVariant hint(QPlatformIntegration::StyleHint h)
static inline QVariant themeableHint(QPlatformTheme::ThemeHint th,
QPlatformIntegration::StyleHint ih)
{
+ if (!QCoreApplication::instance()) {
+ qWarning() << "Must construct a QGuiApplication before accessing a platform theme hint.";
+ return QVariant();
+ }
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
const QVariant themeHint = theme->themeHint(th);
if (themeHint.isValid())
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index 2fdfa3baf1..6ec13e92a1 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -747,6 +747,12 @@ Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format)
and surfaces, even the ones created internally by Qt, will use the same
format.
+ \note When setting Qt::AA_ShareOpenGLContexts, it is strongly recommended to
+ place the call to this function before the construction of the
+ QGuiApplication or QApplication. Otherwise \a format will not be applied to
+ the global share context and therefore issues may arise with context sharing
+ afterwards.
+
\since 5.4
\sa defaultFormat()
*/
diff --git a/src/gui/kernel/qtouchdevice.cpp b/src/gui/kernel/qtouchdevice.cpp
index cbba171276..8737825de0 100644
--- a/src/gui/kernel/qtouchdevice.cpp
+++ b/src/gui/kernel/qtouchdevice.cpp
@@ -96,6 +96,9 @@ QT_BEGIN_NAMESPACE
\value NormalizedPosition Indicates that the normalized position is available, meaning that normalizedPos()
returns a valid value.
+
+ \value MouseEmulation Indicates that the device synthesizes mouse events.
+ This enum value has been introduced in Qt 5.5.
*/
/*!
diff --git a/src/gui/kernel/qtouchdevice.h b/src/gui/kernel/qtouchdevice.h
index 4a2d05a7b9..f2157ce2d6 100644
--- a/src/gui/kernel/qtouchdevice.h
+++ b/src/gui/kernel/qtouchdevice.h
@@ -55,7 +55,8 @@ public:
Pressure = 0x0004,
Velocity = 0x0008,
RawPositions = 0x0010,
- NormalizedPosition = 0x0020
+ NormalizedPosition = 0x0020,
+ MouseEmulation = 0x0040
};
Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index c196f7cff8..19d1fe6a8c 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -1322,27 +1322,33 @@ void QMatrix4x4::rotate(const QQuaternion& quaternion)
{
// Algorithm from:
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54
- QMatrix4x4 m(1);
- float xx = quaternion.x() * quaternion.x();
- float xy = quaternion.x() * quaternion.y();
- float xz = quaternion.x() * quaternion.z();
- float xw = quaternion.x() * quaternion.scalar();
- float yy = quaternion.y() * quaternion.y();
- float yz = quaternion.y() * quaternion.z();
- float yw = quaternion.y() * quaternion.scalar();
- float zz = quaternion.z() * quaternion.z();
- float zw = quaternion.z() * quaternion.scalar();
- m.m[0][0] = 1.0f - 2 * (yy + zz);
- m.m[1][0] = 2 * (xy - zw);
- m.m[2][0] = 2 * (xz + yw);
+
+ QMatrix4x4 m(Qt::Uninitialized);
+
+ const float f2x = quaternion.x() + quaternion.x();
+ const float f2y = quaternion.y() + quaternion.y();
+ const float f2z = quaternion.z() + quaternion.z();
+ const float f2xw = f2x * quaternion.scalar();
+ const float f2yw = f2y * quaternion.scalar();
+ const float f2zw = f2z * quaternion.scalar();
+ const float f2xx = f2x * quaternion.x();
+ const float f2xy = f2x * quaternion.y();
+ const float f2xz = f2x * quaternion.z();
+ const float f2yy = f2y * quaternion.y();
+ const float f2yz = f2y * quaternion.z();
+ const float f2zz = f2z * quaternion.z();
+
+ m.m[0][0] = 1.0f - (f2yy + f2zz);
+ m.m[1][0] = f2xy - f2zw;
+ m.m[2][0] = f2xz + f2yw;
m.m[3][0] = 0.0f;
- m.m[0][1] = 2 * (xy + zw);
- m.m[1][1] = 1.0f - 2 * (xx + zz);
- m.m[2][1] = 2 * (yz - xw);
+ m.m[0][1] = f2xy + f2zw;
+ m.m[1][1] = 1.0f - (f2xx + f2zz);
+ m.m[2][1] = f2yz - f2xw;
m.m[3][1] = 0.0f;
- m.m[0][2] = 2 * (xz - yw);
- m.m[1][2] = 2 * (yz + xw);
- m.m[2][2] = 1.0f - 2 * (xx + yy);
+ m.m[0][2] = f2xz - f2yw;
+ m.m[1][2] = f2yz + f2xw;
+ m.m[2][2] = 1.0f - (f2xx + f2yy);
m.m[3][2] = 0.0f;
m.m[0][3] = 0.0f;
m.m[1][3] = 0.0f;
@@ -1524,7 +1530,11 @@ void QMatrix4x4::perspective(float verticalAngle, float aspectRatio, float nearP
*/
void QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up)
{
- QVector3D forward = (center - eye).normalized();
+ QVector3D forward = center - eye;
+ if (qFuzzyIsNull(forward.x()) && qFuzzyIsNull(forward.y()) && qFuzzyIsNull(forward.z()))
+ return;
+
+ forward.normalize();
QVector3D side = QVector3D::crossProduct(forward, up).normalized();
QVector3D upVector = QVector3D::crossProduct(side, forward);
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index f2e79cb834..4f07d82a25 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -363,7 +363,7 @@ QVector3D QQuaternion::rotatedVector(const QVector3D& vector) const
#ifndef QT_NO_VECTOR3D
/*!
- \fn void QQuaternion::toAxisAndAngle(QVector3D *axis, float *angle) const
+ \fn void QQuaternion::getAxisAndAngle(QVector3D *axis, float *angle) const
\since 5.5
\overload
@@ -377,7 +377,7 @@ QVector3D QQuaternion::rotatedVector(const QVector3D& vector) const
Creates a normalized quaternion that corresponds to rotating through
\a angle degrees about the specified 3D \a axis.
- \sa toAxisAndAngle()
+ \sa getAxisAndAngle()
*/
QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, float angle)
{
@@ -402,7 +402,7 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, float angle)
\sa fromAxisAndAngle()
*/
-void QQuaternion::toAxisAndAngle(float *x, float *y, float *z, float *angle) const
+void QQuaternion::getAxisAndAngle(float *x, float *y, float *z, float *angle) const
{
Q_ASSERT(x && y && z && angle);
@@ -433,7 +433,7 @@ void QQuaternion::toAxisAndAngle(float *x, float *y, float *z, float *angle) con
Creates a normalized quaternion that corresponds to rotating through
\a angle degrees about the 3D axis (\a x, \a y, \a z).
- \sa toAxisAndAngle()
+ \sa getAxisAndAngle()
*/
QQuaternion QQuaternion::fromAxisAndAngle
(float x, float y, float z, float angle)
@@ -457,7 +457,7 @@ QQuaternion QQuaternion::fromAxisAndAngle
\since 5.5
\overload
- Calculates \a roll, \a pitch, and \a yaw Euler angles (in degrees)
+ Calculates roll, pitch, and yaw Euler angles (in degrees)
that corresponds to this quaternion.
\sa fromEulerAngles()
@@ -468,9 +468,9 @@ QQuaternion QQuaternion::fromAxisAndAngle
\since 5.5
\overload
- Creates a quaternion that corresponds to a rotation of
- \a eulerAngles.z() degrees around the z axis, \a eulerAngles.x() degrees around the x axis,
- and \a eulerAngles.y() degrees around the y axis (in that order).
+ Creates a quaternion that corresponds to a rotation of \a eulerAngles:
+ eulerAngles.z() degrees around the z axis, eulerAngles.x() degrees around the x axis,
+ and eulerAngles.y() degrees around the y axis (in that order).
\sa toEulerAngles()
*/
@@ -485,7 +485,7 @@ QQuaternion QQuaternion::fromAxisAndAngle
\sa fromEulerAngles()
*/
-void QQuaternion::toEulerAngles(float *pitch, float *yaw, float *roll) const
+void QQuaternion::getEulerAngles(float *pitch, float *yaw, float *roll) const
{
Q_ASSERT(pitch && yaw && roll);
@@ -543,7 +543,7 @@ void QQuaternion::toEulerAngles(float *pitch, float *yaw, float *roll) const
\a roll degrees around the z axis, \a pitch degrees around the x axis,
and \a yaw degrees around the y axis (in that order).
- \sa toEulerAngles()
+ \sa getEulerAngles()
*/
QQuaternion QQuaternion::fromEulerAngles(float pitch, float yaw, float roll)
{
@@ -592,25 +592,28 @@ QMatrix3x3 QQuaternion::toRotationMatrix() const
QMatrix3x3 rot3x3(Qt::Uninitialized);
- const float xx = xp * xp;
- const float xy = xp * yp;
- const float xz = xp * zp;
- const float xw = xp * wp;
- const float yy = yp * yp;
- const float yz = yp * zp;
- const float yw = yp * wp;
- const float zz = zp * zp;
- const float zw = zp * wp;
-
- rot3x3(0, 0) = 1.0f - 2.0f * (yy + zz);
- rot3x3(0, 1) = 2.0f * (xy - zw);
- rot3x3(0, 2) = 2.0f * (xz + yw);
- rot3x3(1, 0) = 2.0f * (xy + zw);
- rot3x3(1, 1) = 1.0f - 2.0f * (xx + zz);
- rot3x3(1, 2) = 2.0f * (yz - xw);
- rot3x3(2, 0) = 2.0f * (xz - yw);
- rot3x3(2, 1) = 2.0f * (yz + xw);
- rot3x3(2, 2) = 1.0f - 2.0f * (xx + yy);
+ const float f2x = xp + xp;
+ const float f2y = yp + yp;
+ const float f2z = zp + zp;
+ const float f2xw = f2x * wp;
+ const float f2yw = f2y * wp;
+ const float f2zw = f2z * wp;
+ const float f2xx = f2x * xp;
+ const float f2xy = f2x * yp;
+ const float f2xz = f2x * zp;
+ const float f2yy = f2y * yp;
+ const float f2yz = f2y * zp;
+ const float f2zz = f2z * zp;
+
+ rot3x3(0, 0) = 1.0f - (f2yy + f2zz);
+ rot3x3(0, 1) = f2xy - f2zw;
+ rot3x3(0, 2) = f2xz + f2yw;
+ rot3x3(1, 0) = f2xy + f2zw;
+ rot3x3(1, 1) = 1.0f - (f2xx + f2zz);
+ rot3x3(1, 2) = f2yz - f2xw;
+ rot3x3(2, 0) = f2xz - f2yw;
+ rot3x3(2, 1) = f2yz + f2xw;
+ rot3x3(2, 2) = 1.0f - (f2xx + f2yy);
return rot3x3;
}
@@ -748,6 +751,18 @@ QQuaternion QQuaternion::fromRotationMatrix(const QMatrix3x3 &rot3x3)
\sa QQuaternion::operator/=()
*/
+#ifndef QT_NO_VECTOR3D
+
+/*!
+ \fn QVector3D operator*(const QQuaternion &quaternion, const QVector3D &vec)
+ \since 5.5
+ \relates QQuaternion
+
+ Rotates a vector \a vec with a quaternion \a quaternion to produce a new vector in 3D space.
+*/
+
+#endif
+
/*!
\fn bool qFuzzyCompare(const QQuaternion& q1, const QQuaternion& q2)
\relates QQuaternion
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index 4a87b63d25..a02c37ce1d 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -115,10 +115,10 @@ public:
operator QVariant() const;
#ifndef QT_NO_VECTOR3D
- inline void toAxisAndAngle(QVector3D *axis, float *angle) const;
+ inline void getAxisAndAngle(QVector3D *axis, float *angle) const;
static QQuaternion fromAxisAndAngle(const QVector3D& axis, float angle);
#endif
- void toAxisAndAngle(float *x, float *y, float *z, float *angle) const;
+ void getAxisAndAngle(float *x, float *y, float *z, float *angle) const;
static QQuaternion fromAxisAndAngle
(float x, float y, float z, float angle);
@@ -126,7 +126,7 @@ public:
inline QVector3D toEulerAngles() const;
static inline QQuaternion fromEulerAngles(const QVector3D &eulerAngles);
#endif
- void toEulerAngles(float *pitch, float *yaw, float *roll) const;
+ void getEulerAngles(float *pitch, float *yaw, float *roll) const;
static QQuaternion fromEulerAngles(float pitch, float yaw, float roll);
QMatrix3x3 toRotationMatrix() const;
@@ -308,17 +308,22 @@ inline QVector3D QQuaternion::vector() const
return QVector3D(xp, yp, zp);
}
-inline void QQuaternion::toAxisAndAngle(QVector3D *axis, float *angle) const
+inline QVector3D operator*(const QQuaternion &quaternion, const QVector3D &vec)
+{
+ return quaternion.rotatedVector(vec);
+}
+
+inline void QQuaternion::getAxisAndAngle(QVector3D *axis, float *angle) const
{
float aX, aY, aZ;
- toAxisAndAngle(&aX, &aY, &aZ, angle);
+ getAxisAndAngle(&aX, &aY, &aZ, angle);
*axis = QVector3D(aX, aY, aZ);
}
inline QVector3D QQuaternion::toEulerAngles() const
{
float pitch, yaw, roll;
- toEulerAngles(&pitch, &yaw, &roll);
+ getEulerAngles(&pitch, &yaw, &roll);
return QVector3D(pitch, yaw, roll);
}
diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp
index a93d994a70..ced4ac9d73 100644
--- a/src/gui/math3d/qvector3d.cpp
+++ b/src/gui/math3d/qvector3d.cpp
@@ -420,7 +420,7 @@ QVector3D QVector3D::project(const QMatrix4x4 &modelView, const QMatrix4x4 &proj
component of the vector components takes place. To prevent dividing by 0 if
w equals to 0, it is set to 1.
- \note y coordinates in \a point should use OpenGL orientation. OpenGL
+ \note y coordinates in \a viewport should use OpenGL orientation. OpenGL
expects the bottom to be 0 whereas for Qt top is 0.
\sa project()
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
index 576558022e..e87f7bfcef 100644
--- a/src/gui/opengl/qopenglpaintengine.cpp
+++ b/src/gui/opengl/qopenglpaintengine.cpp
@@ -67,7 +67,6 @@
#include <private/qopengl_p.h>
#include <private/qopenglcontext_p.h>
#include <private/qopenglextensions_p.h>
-#include <private/qmath_p.h>
#include <private/qpaintengineex_p.h>
#include <QPaintEngine>
#include <private/qpainter_p.h>
@@ -350,7 +349,7 @@ void QOpenGL2PaintEngineExPrivate::updateBrushUniforms()
const QConicalGradient *g = static_cast<const QConicalGradient *>(currentBrush.gradient());
translationPoint = g->center();
- GLfloat angle = -(g->angle() * 2 * Q_PI) / 360.0;
+ GLfloat angle = -qDegreesToRadians(g->angle());
shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::Angle), angle);
@@ -2010,8 +2009,8 @@ void QOpenGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFra
qreal s = 0;
qreal c = 1;
if (fragments[i].rotation != 0) {
- s = qFastSin(fragments[i].rotation * Q_PI / 180);
- c = qFastCos(fragments[i].rotation * Q_PI / 180);
+ s = qFastSin(qDegreesToRadians(fragments[i].rotation));
+ c = qFastCos(qDegreesToRadians(fragments[i].rotation));
}
qreal right = 0.5 * fragments[i].scaleX * fragments[i].width;
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
index 8a7a1285a8..5de79c9e1e 100644
--- a/src/gui/opengl/qopenglshaderprogram.cpp
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
@@ -2760,7 +2760,7 @@ void QOpenGLShaderProgram::setUniformValueArray
should be used when setting an array of sampler values.
\note This function is not aware of unsigned int support in modern OpenGL
- versions and therefore treats \a value as a GLint and calls glUniform1iv.
+ versions and therefore treats \a values as a GLint and calls glUniform1iv.
\sa setAttributeValue()
*/
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp
index fac5f4de3c..e5c9e8d773 100644
--- a/src/gui/painting/qbezier.cpp
+++ b/src/gui/painting/qbezier.cpp
@@ -40,7 +40,6 @@
#include <qmath.h>
#include <private/qnumeric_p.h>
-#include <private/qmath_p.h>
QT_BEGIN_NAMESPACE
@@ -363,7 +362,7 @@ static bool addCircle(const QBezier *b, qreal offset, QBezier *o)
cos_a = 1.;
if (cos_a < -1.)
cos_a = -1;
- angles[i] = qAcos(cos_a)/Q_PI;
+ angles[i] = qAcos(cos_a) * qreal(M_1_PI);
}
if (angles[0] + angles[1] > 1.) {
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 84063eb692..20fd41e0ae 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -50,7 +50,6 @@
#if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) || defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2)
#include <private/qdrawhelper_mips_dsp_p.h>
#endif
-#include <private/qmath_p.h>
#include <private/qguiapplication_p.h>
#include <qmath.h>
@@ -2689,6 +2688,8 @@ static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Op
+ data->dy + data->m12 * (x + qreal(0.5));
bool affine = !data->m13 && !data->m23;
+ const qreal inv2pi = M_1_PI / 2.0;
+
const uint *end = buffer + length;
if (affine) {
rx -= data->gradient.conical.center.x;
@@ -2696,7 +2697,7 @@ static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Op
while (buffer < end) {
qreal angle = qAtan2(ry, rx) + data->gradient.conical.angle;
- *buffer = qt_gradient_pixel(&data->gradient, 1 - angle / (2*Q_PI));
+ *buffer = qt_gradient_pixel(&data->gradient, 1 - angle * inv2pi);
rx += data->m11;
ry += data->m12;
@@ -2712,7 +2713,7 @@ static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Op
rx/rw - data->gradient.conical.center.y)
+ data->gradient.conical.angle;
- *buffer = qt_gradient_pixel(&data->gradient, 1. - angle / (2*Q_PI));
+ *buffer = qt_gradient_pixel(&data->gradient, 1 - angle * inv2pi);
rx += data->m11;
ry += data->m12;
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index a86d48cf7a..08bc0776f7 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -46,6 +46,7 @@
//
#include "QtCore/qglobal.h"
+#include "QtCore/qmath.h"
#include "QtGui/qcolor.h"
#include "QtGui/qpainter.h"
#include "QtGui/qimage.h"
@@ -55,7 +56,6 @@
#endif
#include "private/qrasterdefs_p.h"
#include <private/qsimd_p.h>
-#include <private/qmath_p.h>
QT_BEGIN_NAMESPACE
@@ -666,11 +666,6 @@ static Q_ALWAYS_INLINE uint qAlphaRgb30(uint c)
return a;
}
-
-// FIXME: Remove when all Qt modules have stopped using PREMUL and INV_PREMUL
-#define PREMUL(x) qPremultiply(x)
-#define INV_PREMUL(p) qUnpremultiply(p)
-
struct quint24 {
quint24(uint value);
operator uint() const;
diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h
index 22d1205074..aded999cdd 100644
--- a/src/gui/painting/qdrawingprimitive_sse2_p.h
+++ b/src/gui/painting/qdrawingprimitive_sse2_p.h
@@ -245,8 +245,7 @@ inline QRgb qUnpremultiply_sse4(QRgb p)
const uint invAlpha = qt_inv_premul_factor[alpha];
const __m128i via = _mm_set1_epi32(invAlpha);
const __m128i vr = _mm_set1_epi32(0x8000);
- __m128i vl = _mm_unpacklo_epi8(_mm_cvtsi32_si128(p), _mm_setzero_si128());
- vl = _mm_unpacklo_epi16(vl, _mm_setzero_si128());
+ __m128i vl = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(p));
vl = _mm_mullo_epi32(vl, via);
vl = _mm_add_epi32(vl, vr);
vl = _mm_srai_epi32(vl, 16);
diff --git a/src/gui/painting/qmath_p.h b/src/gui/painting/qmath_p.h
index 9cb64a46cb..13f82a82bb 100644
--- a/src/gui/painting/qmath_p.h
+++ b/src/gui/painting/qmath_p.h
@@ -50,15 +50,8 @@
QT_BEGIN_NAMESPACE
static const qreal Q_PI = qreal(M_PI); // pi
-static const qreal Q_2PI = qreal(2 * M_PI); // 2*pi
-static const qreal Q_PI2 = qreal(M_PI_2); // pi/2
static const qreal Q_MM_PER_INCH = 25.4;
-inline int qIntSqrtInt(int v)
-{
- return static_cast<int>(qSqrt(static_cast<qreal>(v)));
-}
-
QT_END_NAMESPACE
#endif // QMATH_P_H
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 5f4df7db62..1a1f63844c 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -48,7 +48,6 @@
// #include <private/qdatabuffer_p.h>
// #include <private/qpainter_p.h>
-#include <private/qmath_p.h>
#include <private/qtextengine_p.h>
#include <private/qfontengine_p.h>
#include <private/qpixmap_raster_p.h>
@@ -4466,7 +4465,7 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
QPointF center = g->center();
conicalData.center.x = center.x();
conicalData.center.y = center.y();
- conicalData.angle = g->angle() * 2 * Q_PI / 360.0;
+ conicalData.angle = qDegreesToRadians(g->angle());
}
break;
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 01f9904798..bdbb49ff51 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -6215,7 +6215,7 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const
pen.setWidthF(fe->lineThickness().toReal());
pen.setCapStyle(Qt::FlatCap);
- QLineF line(pos.x(), pos.y(), pos.x() + width, pos.y());
+ QLineF line(qFloor(pos.x()), pos.y(), qFloor(pos.x() + width), pos.y());
bool wasCompatiblePainting = painter->renderHints()
& QPainter::Qt4CompatiblePainting;
diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp
index 07e38bfa3b..fc344dc3ac 100644
--- a/src/gui/painting/qstroker.cpp
+++ b/src/gui/painting/qstroker.cpp
@@ -33,7 +33,6 @@
#include "private/qstroker_p.h"
#include "private/qbezier_p.h"
-#include "private/qmath_p.h"
#include "qline.h"
#include "qtransform.h"
#include <qmath.h>
@@ -793,7 +792,7 @@ qreal qt_t_for_arc_angle(qreal angle)
if (qFuzzyCompare(angle, qreal(90)))
return 1;
- qreal radians = Q_PI * angle / 180;
+ qreal radians = qDegreesToRadians(angle);
qreal cosAngle = qCos(radians);
qreal sinAngle = qSin(radians);
diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp
index 471a39a6e1..4d189786a1 100644
--- a/src/gui/text/qdistancefield.cpp
+++ b/src/gui/text/qdistancefield.cpp
@@ -833,6 +833,17 @@ QDistanceField::QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doub
setGlyph(fontEngine, glyph, doubleResolution);
}
+QDistanceField::QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution)
+{
+ QPainterPath dfPath = path;
+ dfPath.translate(-dfPath.boundingRect().topLeft());
+ dfPath.setFillRule(Qt::WindingFill);
+
+ d = QDistanceFieldData::create(dfPath, doubleResolution);
+ d->glyph = glyph;
+}
+
+
QDistanceField::QDistanceField(QDistanceFieldData *data)
: d(data)
{
diff --git a/src/gui/text/qdistancefield_p.h b/src/gui/text/qdistancefield_p.h
index 95bb3b11c7..c376e93abe 100644
--- a/src/gui/text/qdistancefield_p.h
+++ b/src/gui/text/qdistancefield_p.h
@@ -97,6 +97,7 @@ public:
QDistanceField(int width, int height);
QDistanceField(const QRawFont &font, glyph_t glyph, bool doubleResolution = false);
QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false);
+ QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution = false);
QDistanceField(const QDistanceField &other);
bool isNull() const;
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index d243cf0b13..e8dd663354 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1453,7 +1453,7 @@ QTextCursor QTextDocument::find(const QRegExp & expr, int from, FindFlags option
\overload
Finds the next occurrence, matching the regular expression, \a expr, in the document.
- The search starts at the position of the given \a from cursor, and proceeds
+ The search starts at the position of the given from \a cursor, and proceeds
forwards through the document unless specified otherwise in the search
options. The \a options control the type of search performed. The FindCaseSensitively
option is ignored for this overload, use QRegExp::caseSensitivity instead.
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index a00dac61fb..3a86a454ac 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1115,6 +1115,13 @@ void QTextDocumentLayoutPrivate::drawTableCell(const QRectF &cellRect, QPainter
const QFixed leftPadding = td->leftPadding(fmt);
const QFixed topPadding = td->topPadding(fmt);
+ qreal topMargin = (td->effectiveTopMargin + td->cellSpacing + td->border).toReal();
+ qreal bottomMargin = (td->effectiveBottomMargin + td->cellSpacing + td->border).toReal();
+
+ const int headerRowCount = qMin(table->format().headerRowCount(), table->rows() - 1);
+ if (r >= headerRowCount)
+ topMargin += td->headerHeight.toReal();
+
if (td->border != 0) {
const QBrush oldBrush = painter->brush();
const QPen oldPen = painter->pen();
@@ -1142,13 +1149,6 @@ void QTextDocumentLayoutPrivate::drawTableCell(const QRectF &cellRect, QPainter
break;
}
- qreal topMargin = (td->effectiveTopMargin + td->cellSpacing + td->border).toReal();
- qreal bottomMargin = (td->effectiveBottomMargin + td->cellSpacing + td->border).toReal();
-
- const int headerRowCount = qMin(table->format().headerRowCount(), table->rows() - 1);
- if (r >= headerRowCount)
- topMargin += td->headerHeight.toReal();
-
drawBorder(painter, borderRect, topMargin, bottomMargin,
border, table->format().borderBrush(), cellBorder);
@@ -1159,7 +1159,30 @@ void QTextDocumentLayoutPrivate::drawTableCell(const QRectF &cellRect, QPainter
const QBrush bg = cell.format().background();
const QPointF brushOrigin = painter->brushOrigin();
if (bg.style() != Qt::NoBrush) {
- fillBackground(painter, cellRect, bg, cellRect.topLeft());
+ const qreal pageHeight = document->pageSize().height();
+ const int topPage = pageHeight > 0 ? static_cast<int>(cellRect.top() / pageHeight) : 0;
+ const int bottomPage = pageHeight > 0 ? static_cast<int>((cellRect.bottom()) / pageHeight) : 0;
+
+ if (topPage == bottomPage)
+ fillBackground(painter, cellRect, bg, cellRect.topLeft());
+ else {
+ for (int i = topPage; i <= bottomPage; ++i) {
+ QRectF clipped = cellRect.toRect();
+
+ if (topPage != bottomPage) {
+ const qreal top = qMax(i * pageHeight + topMargin, cell_context.clip.top());
+ const qreal bottom = qMin((i + 1) * pageHeight - bottomMargin, cell_context.clip.bottom());
+
+ clipped.setTop(qMax(clipped.top(), top));
+ clipped.setBottom(qMin(clipped.bottom(), bottom));
+
+ if (clipped.bottom() <= clipped.top())
+ continue;
+
+ fillBackground(painter, clipped, bg, cellRect.topLeft());
+ }
+ }
+ }
if (bg.style() > Qt::SolidPattern)
painter->setBrushOrigin(cellRect.topLeft());
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 0dd8442a71..076b6bbde4 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1707,7 +1707,7 @@ bool QTextEngine::isRightToLeft() const
itemize();
// this places the cursor in the right position depending on the keyboard layout
if (layoutData->string.isEmpty())
- return qApp ? qApp->inputMethod()->inputDirection() == Qt::RightToLeft : false;
+ return QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft;
return layoutData->string.isRightToLeft();
}
diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp
index f30f77d206..a7295933b5 100644
--- a/src/network/ssl/qsslcontext_openssl.cpp
+++ b/src/network/ssl/qsslcontext_openssl.cpp
@@ -86,6 +86,11 @@ QSslContext::~QSslContext()
q_SSL_SESSION_free(session);
}
+static inline QString msgErrorSettingEllipticCurves(const QString &why)
+{
+ return QSslSocket::tr("Error when setting the elliptic curves (%1)").arg(why);
+}
+
QSslContext* QSslContext::fromConfiguration(QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading)
{
QSslContext *sslContext = new QSslContext();
@@ -342,7 +347,7 @@ init_context:
SSL_CTRL_SET_CURVES,
qcurves.size(),
const_cast<int *>(reinterpret_cast<const int *>(qcurves.data())))) {
- sslContext->errorStr = QSslSocket::tr("Error when setting the elliptic curves (%1)").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
+ sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocketBackendPrivate::getErrorsFromOpenSsl());
sslContext->errorCode = QSslError::UnspecifiedError;
return sslContext;
}
@@ -350,7 +355,7 @@ init_context:
#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
{
// specific curves requested, but not possible to set -> error
- sslContext->errorStr = QSslSocket::tr("Error when setting the elliptic curves (OpenSSL version too old, need at least v1.0.2)");
+ sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version too old, need at least v1.0.2"));
sslContext->errorCode = QSslError::UnspecifiedError;
return sslContext;
}
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index e461dd0fd4..e049f53fac 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -63,7 +63,6 @@
#include <qmath.h>
#include <private/qgl_p.h>
-#include <private/qmath_p.h>
#include <private/qpaintengineex_p.h>
#include <QPaintEngine>
#include <private/qpainter_p.h>
@@ -288,7 +287,7 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
const QConicalGradient *g = static_cast<const QConicalGradient *>(currentBrush.gradient());
translationPoint = g->center();
- GLfloat angle = -(g->angle() * 2 * Q_PI) / 360.0;
+ GLfloat angle = -qDegreesToRadians(g->angle());
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Angle), angle);
@@ -1945,8 +1944,8 @@ void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragmen
qreal s = 0;
qreal c = 1;
if (fragments[i].rotation != 0) {
- s = qFastSin(fragments[i].rotation * Q_PI / 180);
- c = qFastCos(fragments[i].rotation * Q_PI / 180);
+ s = qFastSin(qDegreesToRadians(fragments[i].rotation));
+ c = qFastCos(qDegreesToRadians(fragments[i].rotation));
}
qreal right = 0.5 * fragments[i].scaleX * fragments[i].width;
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 17e9d07787..bd22a8fce5 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -279,7 +279,7 @@ static const char *openType[] = {
"deva", // Devanagari
"beng", // Bengali
"guru", // Gurmukhi
- "gurj", // Gujarati
+ "gujr", // Gujarati
"orya", // Oriya
"taml", // Tamil
"telu", // Telugu
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index f7165bec91..a022587e11 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -48,6 +48,18 @@
QT_BEGIN_NAMESPACE
+namespace {
+class AutoReleasePool
+{
+public:
+ AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
+ ~AutoReleasePool() { [pool release]; }
+
+private:
+ NSAutoreleasePool *pool;
+};
+}
+
// this could become a list of all languages used for each writing
// system, instead of using the single most common language.
static const char *languageForWritingSystem[] = {
@@ -439,6 +451,8 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
Q_UNUSED(style);
Q_UNUSED(script);
+ AutoReleasePool pool;
+
static QHash<QString, QStringList> fallbackLists;
if (!family.isEmpty()) {
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h
index 15445faca0..d012ede5f9 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.h
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h
@@ -58,7 +58,6 @@ public:
private:
QImage m_qImage;
- CGImageRef m_cgImage;
QSize m_requestedSize;
};
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index a90db00d42..cddb960197 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -39,14 +39,11 @@ QT_BEGIN_NAMESPACE
QCocoaBackingStore::QCocoaBackingStore(QWindow *window)
: QPlatformBackingStore(window)
- , m_cgImage(0)
{
}
QCocoaBackingStore::~QCocoaBackingStore()
{
- CGImageRelease(m_cgImage);
- m_cgImage = 0;
}
QPaintDevice *QCocoaBackingStore::paintDevice()
@@ -58,9 +55,6 @@ QPaintDevice *QCocoaBackingStore::paintDevice()
// either due to a window resize or devicePixelRatio change.
QSize effectiveBufferSize = m_requestedSize * windowDevicePixelRatio;
if (m_qImage.size() != effectiveBufferSize) {
- CGImageRelease(m_cgImage);
- m_cgImage = 0;
-
QImage::Format format = (window()->format().hasAlpha() || cocoaWindow->m_drawContentBorderGradient)
? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
m_qImage = QImage(effectiveBufferSize, format);
@@ -73,15 +67,6 @@ QPaintDevice *QCocoaBackingStore::paintDevice()
void QCocoaBackingStore::flush(QWindow *win, const QRegion &region, const QPoint &offset)
{
- // A flush means that qImage has changed. Since CGImages are seen as
- // immutable, CoreImage fails to pick up this change for m_cgImage
- // (since it usually cached), so we must recreate it. We await doing this
- // until one of the views needs it, since, together with calling
- // "setNeedsDisplayInRect" instead of "displayRect" we will, in most
- // cases, get away with doing this once for every repaint. Also note that
- // m_cgImage is only a reference to the data inside m_qImage, it is not a copy.
- CGImageRelease(m_cgImage);
- m_cgImage = 0;
if (!m_qImage.isNull()) {
if (QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(win->handle()))
[cocoaWindow->m_qtView flushBackingStore:this region:region offset:offset];
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index ac43ee6d31..a84c0c0f2a 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -630,6 +630,7 @@ QString qt_mac_applicationName()
int qt_mac_mainScreenHeight()
{
+ QCocoaAutoReleasePool pool;
// The first screen in the screens array is documented
// to have the (0,0) origin.
NSRect screenFrame = [[[NSScreen screens] firstObject] frame];
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index d3071be636..881b23cd6f 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -33,6 +33,7 @@
#include "qcocoaintegration.h"
+#include "qcocoaautoreleasepool.h"
#include "qcocoawindow.h"
#include "qcocoabackingstore.h"
#include "qcocoanativeinterface.h"
@@ -136,6 +137,7 @@ void QCocoaScreen::updateGeometry()
qreal QCocoaScreen::devicePixelRatio() const
{
+ QCocoaAutoReleasePool pool;
NSScreen * screen = osScreen();
return qreal(screen ? [screen backingScaleFactor] : 1.0);
}
@@ -505,8 +507,6 @@ QVariant QCocoaIntegration::styleHint(StyleHint hint) const
{
if (hint == QPlatformIntegration::FontSmoothingGamma)
return 2.0;
- if (hint == QPlatformIntegration::SynthesizeMouseFromTouchEvents)
- return false;
return QPlatformIntegration::styleHint(hint);
}
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index e6a3ac9c01..fb11efb689 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -217,6 +217,8 @@ QCocoaMenu::QCocoaMenu() :
m_menuBar(0),
m_containingMenuItem(0)
{
+ QCocoaAutoReleasePool pool;
+
m_delegate = [[QCocoaMenuDelegate alloc] initWithMenu:this];
m_nativeItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
m_nativeMenu = [[NSMenu alloc] initWithTitle:@"Untitled"];
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index c68f083a34..5d8082d347 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -145,6 +145,8 @@ void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu)
void QCocoaMenuBar::syncMenu(QPlatformMenu *menu)
{
+ QCocoaAutoReleasePool pool;
+
QCocoaMenu *cocoaMenu = static_cast<QCocoaMenu *>(menu);
Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items())
cocoaMenu->syncMenuItem(item);
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
index 603d5c9910..d6813749a4 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -99,6 +99,8 @@ QCocoaMenuItem::QCocoaMenuItem() :
QCocoaMenuItem::~QCocoaMenuItem()
{
+ QCocoaAutoReleasePool pool;
+
if (m_menu && COCOA_MENU_ANCESTOR(m_menu) == this)
SET_COCOA_MENU_ANCESTOR(m_menu, 0);
if (m_merged) {
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index cd885796f5..205a49d25a 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -234,6 +234,7 @@ void QCocoaNativeInterface::registerDraggedTypes(const QStringList &types)
void QCocoaNativeInterface::setDockMenu(QPlatformMenu *platformMenu)
{
+ QCocoaAutoReleasePool pool;
QCocoaMenu *cocoaPlatformMenu = static_cast<QCocoaMenu *>(platformMenu);
NSMenu *menu = cocoaPlatformMenu->nsMenu();
[NSApp QT_MANGLE_NAMESPACE(qt_setDockMenu): menu];
diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
index 4ef9000d67..65cc9bc38b 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
@@ -33,6 +33,7 @@
#include "qcocoasystemsettings.h"
+#include "qcocoaautoreleasepool.h"
#include "qcocoahelpers.h"
#include <QtCore/private/qcore_mac_p.h>
@@ -44,6 +45,8 @@ QT_BEGIN_NAMESPACE
QColor qt_mac_colorForTheme(ThemeBrush brush)
{
+ QCocoaAutoReleasePool pool;
+
QCFType<CGColorRef> cgClr = 0;
HIThemeBrushCreateCGColor(brush, &cgClr);
return qt_mac_toQColor(cgClr);
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 5625d19ed7..cfd2eeb837 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -157,7 +157,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
if (!touchDevice) {
touchDevice = new QTouchDevice;
touchDevice->setType(QTouchDevice::TouchPad);
- touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::NormalizedPosition);
+ touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::NormalizedPosition | QTouchDevice::MouseEmulation);
QWindowSystemInterface::registerTouchDevice(touchDevice);
}
}
diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm
index 40f0082b9d..992668805f 100644
--- a/src/plugins/platforms/ios/qiosmenu.mm
+++ b/src/plugins/platforms/ios/qiosmenu.mm
@@ -131,16 +131,16 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
self.toolbar = [[[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 100, 44)] autorelease];
self.toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- UIBarButtonItem *doneButton = [[[UIBarButtonItem alloc]
- initWithBarButtonSystemItem:UIBarButtonSystemItemDone
- target:self action:@selector(closeMenu)] autorelease];
UIBarButtonItem *spaceButton = [[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:self action:@selector(closeMenu)] autorelease];
UIBarButtonItem *cancelButton = [[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self action:@selector(cancelMenu)] autorelease];
- [self.toolbar setItems:[NSArray arrayWithObjects:doneButton, spaceButton, cancelButton, nil]];
+ UIBarButtonItem *doneButton = [[[UIBarButtonItem alloc]
+ initWithBarButtonSystemItem:UIBarButtonSystemItemDone
+ target:self action:@selector(closeMenu)] autorelease];
+ [self.toolbar setItems:[NSArray arrayWithObjects:cancelButton, spaceButton, doneButton, nil]];
[self setDelegate:self];
[self setDataSource:self];
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index b397b12311..ebd41d482b 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -1235,6 +1235,11 @@ void QWindowsContext::setAsyncExpose(bool value)
d->m_asyncExpose = value;
}
+QTouchDevice *QWindowsContext::touchDevice() const
+{
+ return d->m_mouseHandler.touchDevice();
+}
+
/*!
\brief Windows functions for actual windows.
diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h
index 7c88ee14ba..870a42946d 100644
--- a/src/plugins/platforms/windows/qwindowscontext.h
+++ b/src/plugins/platforms/windows/qwindowscontext.h
@@ -67,6 +67,7 @@ struct QWindowCreationContext;
struct QWindowsContextPrivate;
class QPoint;
class QKeyEvent;
+class QTouchDevice;
#ifndef Q_OS_WINCE
struct QWindowsUser32DLL
@@ -219,6 +220,8 @@ public:
bool asyncExpose() const;
void setAsyncExpose(bool value);
+ QTouchDevice *touchDevice() const;
+
private:
void handleFocusEvent(QtWindows::WindowsEventType et, QWindowsWindow *w);
#ifndef QT_NO_CONTEXTMENU
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
index 56adae8ffb..287ee4c46e 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
@@ -836,7 +836,8 @@ error:
static bool addFontToDatabase(const QString &familyName, uchar charSet,
const TEXTMETRIC *textmetric,
const FONTSIGNATURE *signature,
- int type)
+ int type,
+ bool registerAlias)
{
// the "@family" fonts are just the same as "family". Ignore them.
if (familyName.isEmpty() || familyName.at(0) == QLatin1Char('@') || familyName.startsWith(QLatin1String("WST_")))
@@ -873,7 +874,7 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
#endif
QString englishName;
- if (ttf && localizedName(familyName))
+ if (registerAlias && ttf && localizedName(familyName))
englishName = getEnglishName(familyName);
QSupportedWritingSystems writingSystems;
@@ -942,7 +943,7 @@ static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetr
// NEWTEXTMETRICEX is a NEWTEXTMETRIC, which according to the documentation is
// identical to a TEXTMETRIC except for the last four members, which we don't use
// anyway
- addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type);
+ addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type, false);
// keep on enumerating
return 1;
@@ -977,7 +978,7 @@ struct PopulateFamiliesContext
};
} // namespace
-static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *, int, LPARAM lparam)
+static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *tm, int, LPARAM lparam)
{
// the "@family" fonts are just the same as "family". Ignore them.
const wchar_t *faceNameW = f->elfLogFont.lfFaceName;
@@ -987,6 +988,19 @@ static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICE
PopulateFamiliesContext *context = reinterpret_cast<PopulateFamiliesContext *>(lparam);
if (!context->seenSystemDefaultFont && faceName == context->systemDefaultFont)
context->seenSystemDefaultFont = true;
+
+ // Register current font's english name as alias
+ const bool ttf = (tm->ntmTm.tmPitchAndFamily & TMPF_TRUETYPE);
+ if (ttf && localizedName(faceName)) {
+ const QString englishName = getEnglishName(faceName);
+ if (!englishName.isEmpty()) {
+ QPlatformFontDatabase::registerAliasToFontFamily(faceName, englishName);
+ // Check whether the system default font name is an alias of the current font family name,
+ // as on Chinese Windows, where the system font "SimSun" is an alias to a font registered under a local name
+ if (!context->seenSystemDefaultFont && englishName == context->systemDefaultFont)
+ context->seenSystemDefaultFont = true;
+ }
+ }
}
return 1; // continue
}
@@ -1344,7 +1358,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
GetTextMetrics(hdc, &textMetrics);
addFontToDatabase(familyName, lf.lfCharSet, &textMetrics, &signatures.at(j),
- TRUETYPE_FONTTYPE);
+ TRUETYPE_FONTTYPE, true);
SelectObject(hdc, oldobj);
DeleteObject(hfont);
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index b8cc28cedc..689e06281f 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -361,7 +361,7 @@ bool QWindowsInputContext::startComposition(HWND hwnd)
if (!fo)
return false;
// This should always match the object.
- QWindow *window = qApp->focusWindow();
+ QWindow *window = QGuiApplication::focusWindow();
if (!window)
return false;
qCDebug(lcQpaInputMethods) << __FUNCTION__ << fo << window;
@@ -561,7 +561,7 @@ bool QWindowsInputContext::handleIME_Request(WPARAM wParam,
int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv)
{
- QObject *fo = qApp->focusObject();
+ QObject *fo = QGuiApplication::focusObject();
if (!fo)
return false;
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index d9d0e26b80..af7ecd5834 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -227,6 +227,18 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList &paramL
qCDebug(lcQpaWindows)
<< __FUNCTION__ << "DpiAwareness=" << dpiAwareness <<",Scaling="
<< QWindowsScaling::factor();
+
+ QTouchDevice *touchDevice = m_context.touchDevice();
+ if (touchDevice) {
+#ifdef Q_OS_WINCE
+ touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation);
+#else
+ if (!(m_options & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch)) {
+ touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation);
+ }
+#endif
+ QWindowSystemInterface::registerTouchDevice(touchDevice);
+ }
}
QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate()
@@ -235,9 +247,12 @@ QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate()
delete m_fontDatabase;
}
+QWindowsIntegration *QWindowsIntegration::m_instance = Q_NULLPTR;
+
QWindowsIntegration::QWindowsIntegration(const QStringList &paramList) :
d(new QWindowsIntegrationPrivate(paramList))
{
+ m_instance = this;
#ifndef QT_NO_CLIPBOARD
d->m_clipboard.registerViewer();
#endif
@@ -246,6 +261,7 @@ QWindowsIntegration::QWindowsIntegration(const QStringList &paramList) :
QWindowsIntegration::~QWindowsIntegration()
{
+ m_instance = Q_NULLPTR;
}
void QWindowsIntegration::initialize()
@@ -492,13 +508,6 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co
break;
case QPlatformIntegration::UseRtlExtensions:
return QVariant(d->m_context.useRTLExtensions());
- case QPlatformIntegration::SynthesizeMouseFromTouchEvents:
-#ifdef Q_OS_WINCE
- // We do not want Qt to synthesize mouse events as Windows also does that.
- return false;
-#else // Q_OS_WINCE
- return QVariant(bool(d->m_options & DontPassOsMouseEventsSynthesizedFromTouch));
-#endif // !Q_OS_WINCE
default:
break;
}
@@ -540,11 +549,6 @@ QPlatformAccessibility *QWindowsIntegration::accessibility() const
}
#endif
-QWindowsIntegration *QWindowsIntegration::instance()
-{
- return static_cast<QWindowsIntegration *>(QGuiApplicationPrivate::platformIntegration());
-}
-
unsigned QWindowsIntegration::options() const
{
return d->m_options;
diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h
index 65816b5590..8a2d14f172 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.h
+++ b/src/plugins/platforms/windows/qwindowsintegration.h
@@ -91,9 +91,9 @@ public:
Qt::KeyboardModifiers queryKeyboardModifiers() const Q_DECL_OVERRIDE;
QList<int> possibleKeys(const QKeyEvent *e) const Q_DECL_OVERRIDE;
- static QWindowsIntegration *instance();
+ static QWindowsIntegration *instance() { return m_instance; }
- inline void emitScreenAdded(QPlatformScreen *s) { screenAdded(s); }
+ inline void emitScreenAdded(QPlatformScreen *s, bool isPrimary = false) { screenAdded(s, isPrimary); }
inline void emitDestroyScreen(QPlatformScreen *s) { destroyScreen(s); }
unsigned options() const;
@@ -104,6 +104,8 @@ public:
private:
QScopedPointer<QWindowsIntegrationPrivate> d;
+
+ static QWindowsIntegration *m_instance;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index b940dcd62c..b1ced95a71 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -128,7 +128,10 @@ static inline QTouchDevice *createTouchDevice()
QTouchDevice *result = new QTouchDevice;
result->setType(digitizers & QT_NID_INTEGRATED_TOUCH
? QTouchDevice::TouchScreen : QTouchDevice::TouchPad);
- result->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition);
+ QTouchDevice::Capabilities capabilities = QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition;
+ if (result->type() == QTouchDevice::TouchPad)
+ capabilities |= QTouchDevice::MouseEmulation;
+ result->setCapabilities(capabilities);
result->setMaximumTouchPoints(maxTouchPoints);
return result;
}
@@ -150,8 +153,6 @@ QWindowsMouseHandler::QWindowsMouseHandler() :
m_leftButtonDown(false),
m_previousCaptureWindow(0)
{
- if (m_touchDevice)
- QWindowSystemInterface::registerTouchDevice(m_touchDevice);
}
Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons()
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index 059ebf19f6..4ab4ac352e 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -514,7 +514,8 @@ bool QWindowsScreenManager::handleScreenChanges()
} else {
QWindowsScreen *newScreen = new QWindowsScreen(newData);
m_screens.push_back(newScreen);
- QWindowsIntegration::instance()->emitScreenAdded(newScreen);
+ QWindowsIntegration::instance()->emitScreenAdded(newScreen,
+ newData.flags & QWindowsScreenData::PrimaryScreen);
qCDebug(lcQpaWindows) << "New Monitor: " << newData;
} // exists
} // for new screens.
diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp
index f33e07901a..c42368cc87 100644
--- a/src/plugins/platforms/winrt/qwinrttheme.cpp
+++ b/src/plugins/platforms/winrt/qwinrttheme.cpp
@@ -224,8 +224,6 @@ QVariant QWinRTTheme::styleHint(QPlatformIntegration::StyleHint hint)
return defaultThemeHint(StartDragVelocity);
case QPlatformIntegration::UseRtlExtensions:
return false;
- case QPlatformIntegration::SynthesizeMouseFromTouchEvents:
- return true;
case QPlatformIntegration::PasswordMaskCharacter:
return defaultThemeHint(PasswordMaskCharacter);
case QPlatformIntegration::SetFocusOnTouchRelease:
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp
index 891f187238..562b5c154f 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp
@@ -100,7 +100,7 @@ QPlatformNativeInterface::NativeResourceForWindowFunction QXcbEglNativeInterface
void *QXcbEglNativeInterfaceHandler::eglDisplay()
{
- QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QXcbIntegration *integration = QXcbIntegration::instance();
QXcbEglIntegration *eglIntegration = static_cast<QXcbEglIntegration *>(integration->defaultConnection()->glIntegration());
return eglIntegration->eglDisplay();
}
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 3870c104a4..57dcdc8f9c 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -80,6 +80,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaXInput, "qt.qpa.input")
Q_LOGGING_CATEGORY(lcQpaXInputDevices, "qt.qpa.input.devices")
+Q_LOGGING_CATEGORY(lcQpaScreen, "qt.qpa.screen")
#ifdef XCB_USE_XLIB
static const char * const xcbConnectionErrors[] = {
@@ -143,9 +144,8 @@ QXcbScreen* QXcbConnection::findOrCreateScreen(QList<QXcbScreen *>& newScreens,
void QXcbConnection::updateScreens()
{
xcb_screen_iterator_t it = xcb_setup_roots_iterator(m_setup);
- int screenNumber = 0; // index of this QScreen in QGuiApplication::screens()
int xcbScreenNumber = 0; // screen number in the xcb sense
- QSet<QXcbScreen *> activeScreens;
+ QList<QXcbScreen *> activeScreens;
QList<QXcbScreen *> newScreens;
QXcbScreen* primaryScreen = NULL;
while (it.rem) {
@@ -156,6 +156,7 @@ void QXcbConnection::updateScreens()
xcb_screen_t *xcbScreen = it.data;
QList<QPlatformScreen *> siblings;
int outputCount = 0;
+ int connectedOutputCount = 0;
if (has_randr_extension) {
xcb_generic_error_t *error = NULL;
xcb_randr_get_output_primary_cookie_t primaryCookie =
@@ -185,22 +186,18 @@ void QXcbConnection::updateScreens()
if (output == NULL)
continue;
-#ifdef Q_XCB_DEBUG
- QString outputName = QString::fromUtf8((const char*)xcb_randr_get_output_info_name(output),
- xcb_randr_get_output_info_name_length(output));
-#endif
if (output->crtc == XCB_NONE) {
-#ifdef Q_XCB_DEBUG
- qDebug("Screen output %s is not connected", qPrintable(outputName));
-#endif
+ qCDebug(lcQpaScreen, "output %s is not connected", qPrintable(
+ QString::fromUtf8((const char*)xcb_randr_get_output_info_name(output),
+ xcb_randr_get_output_info_name_length(output))));
continue;
}
QXcbScreen *screen = findOrCreateScreen(newScreens, xcbScreenNumber, xcbScreen, output);
siblings << screen;
activeScreens << screen;
- ++screenNumber;
+ ++connectedOutputCount;
// There can be multiple outputs per screen, use either
// the first or an exact match. An exact match isn't
// always available if primary->output is XCB_NONE
@@ -209,9 +206,6 @@ void QXcbConnection::updateScreens()
if (!primaryScreen || (primary && outputs[i] == primary->output)) {
primaryScreen = screen;
siblings.prepend(siblings.takeLast());
-#ifdef Q_XCB_DEBUG
- qDebug("Primary output is %d: %s", primary->output, qPrintable(outputName));
-#endif
}
}
free(output);
@@ -223,16 +217,13 @@ void QXcbConnection::updateScreens()
}
// If there's no randr extension, or there was some error above, or the screen
// doesn't have outputs for some other reason (e.g. on VNC or ssh -X), just assume there is one screen.
- if (outputCount == 0) {
-#ifdef Q_XCB_DEBUG
- qDebug("Found a screen with zero outputs");
-#endif
+ if (connectedOutputCount == 0) {
+ qCDebug(lcQpaScreen, "found a screen with zero outputs");
QXcbScreen *screen = findOrCreateScreen(newScreens, xcbScreenNumber, xcbScreen);
siblings << screen;
activeScreens << screen;
if (!primaryScreen)
primaryScreen = screen;
- ++screenNumber;
}
foreach (QPlatformScreen* s, siblings)
((QXcbScreen*)s)->setVirtualSiblings(siblings);
@@ -240,29 +231,57 @@ void QXcbConnection::updateScreens()
++xcbScreenNumber;
} // for each xcb screen
- QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
- // Now activeScreens is the complete set of screens which are active at this time.
- // Delete any existing screens which are not in activeScreens
+ QXcbIntegration *integration = QXcbIntegration::instance();
+
+ // Rebuild screen list, ensuring primary screen is always in front,
+ // both in the QXcbConnection::m_screens list as well as in the
+ // QGuiApplicationPrivate::screen_list list, which gets updated via
+ // - screen added: integration->screenAdded()
+ // - screen removed: integration->destroyScreen
+
+ // Gather screens to delete
+ QList<QXcbScreen*> screensToDelete;
for (int i = m_screens.count() - 1; i >= 0; --i) {
if (!activeScreens.contains(m_screens[i])) {
- integration->destroyScreen(m_screens.at(i));
- m_screens.removeAt(i);
+ screensToDelete.append(m_screens.takeAt(i));
}
}
- // Add any new screens, and make sure the primary screen comes first
- // since it is used by QGuiApplication::primaryScreen()
+ // If there is a new primary screen, add that one first
+ if (newScreens.contains(primaryScreen)) {
+ newScreens.removeOne(primaryScreen);
+ m_screens.prepend(primaryScreen);
+ qCDebug(lcQpaScreen) << "adding as primary" << primaryScreen;
+ integration->screenAdded(primaryScreen, true);
+ }
+
+ // Add the remaining new screens
foreach (QXcbScreen* screen, newScreens) {
- if (screen == primaryScreen)
- m_screens.prepend(screen);
- else
- m_screens.append(screen);
+ m_screens.append(screen);
+ qCDebug(lcQpaScreen) << "adding" << screen;
+ integration->screenAdded(screen);
}
- // Now that they are in the right order, emit the added signals for new screens only
- foreach (QXcbScreen* screen, m_screens)
- if (newScreens.contains(screen))
- integration->screenAdded(screen);
+ // Delete the old screens, now that the new ones were added
+ // and we are sure that there is at least one screen available
+ foreach (QXcbScreen* screen, screensToDelete) {
+ qCDebug(lcQpaScreen) << "removing" << screen;
+ integration->destroyScreen(screen);
+ }
+
+ // Ensure that the primary screen is first in m_screens too
+ // (in case the assignment of primary was the only change,
+ // without adding or removing screens)
+ if (primaryScreen) {
+ Q_ASSERT(!m_screens.isEmpty());
+ if (m_screens.first() != primaryScreen) {
+ m_screens.removeOne(primaryScreen);
+ m_screens.prepend(primaryScreen);
+ }
+ }
+
+ if (!m_screens.isEmpty())
+ qCDebug(lcQpaScreen) << "primary output is" << m_screens.first()->name();
}
QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, const char *displayName)
@@ -280,7 +299,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
, has_shape_extension(false)
, has_randr_extension(false)
, has_input_shape(false)
- , has_touch_without_mouse_emulation(false)
, has_xkb(false)
, m_buttons(0)
, m_focusWindow(0)
@@ -404,7 +422,7 @@ QXcbConnection::~QXcbConnection()
delete m_reader;
- QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QXcbIntegration *integration = QXcbIntegration::instance();
// Delete screens in reverse order to avoid crash in case of multiple screens
while (!m_screens.isEmpty())
integration->destroyScreen(m_screens.takeLast());
@@ -794,8 +812,10 @@ void QXcbConnection::handleMotionNotify(xcb_generic_event_t *ev)
xcb_motion_notify_event_t *event = (xcb_motion_notify_event_t *)ev;
m_buttons = (m_buttons & ~0x7) | translateMouseButtons(event->state);
- if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
- qDebug("xcb: moved mouse to %4d, %4d; button state %X", event->event_x, event->event_y, static_cast<unsigned int>(m_buttons));
+#ifdef Q_XCB_DEBUG
+ qCDebug(lcQpaXInput, "xcb: moved mouse to %4d, %4d; button state %X",
+ event->event_x, event->event_y, static_cast<unsigned int>(m_buttons));
+#endif
}
#ifndef QT_NO_XKB
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 585ff95c19..97c2590708 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -77,6 +77,7 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcQpaXInput)
Q_DECLARE_LOGGING_CATEGORY(lcQpaXInputDevices)
+Q_DECLARE_LOGGING_CATEGORY(lcQpaScreen)
class QXcbScreen;
class QXcbWindow;
@@ -441,7 +442,6 @@ public:
bool hasXShape() const { return has_shape_extension; }
bool hasXRandr() const { return has_randr_extension; }
bool hasInputShape() const { return has_input_shape; }
- bool hasTouchWithoutMouseEmulation() const { return has_touch_without_mouse_emulation; }
bool hasXKB() const { return has_xkb; }
bool supportsThreadedRendering() const { return m_reader->isRunning(); }
@@ -611,7 +611,6 @@ private:
bool has_shape_extension;
bool has_randr_extension;
bool has_input_shape;
- bool has_touch_without_mouse_emulation;
bool has_xkb;
Qt::MouseButtons m_buttons;
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index e9fb47dabd..d1b3ead11c 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -282,14 +282,14 @@ void QXcbConnection::xi2Select(xcb_window_t window)
mask.mask_len = sizeof(bitMask);
mask.mask = xiBitMask;
if (!m_touchDevices.isEmpty()) {
- mask.deviceid = XIAllMasterDevices;
- Status result = XISelectEvents(xDisplay, window, &mask, 1);
// If we select for touch events on the master pointer, XInput2
// will not synthesize mouse events. This means Qt must do it,
// which is also preferable, since Qt can control better when
// to do so.
- if (result == Success)
- has_touch_without_mouse_emulation = true;
+ mask.deviceid = XIAllMasterDevices;
+ Status result = XISelectEvents(xDisplay, window, &mask, 1);
+ if (result != Success)
+ qCDebug(lcQpaXInput, "XInput 2.2: failed to select touch events, window %x, result %d", window, result);
}
}
#endif // XCB_USE_XINPUT22
@@ -424,6 +424,9 @@ XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
dev->size.width() > 10000 || dev->size.height() > 10000)
dev->size = QSizeF(130, 110);
}
+ if (!isUsingXInput22() || type == QTouchDevice::TouchPad)
+ caps |= QTouchDevice::MouseEmulation;
+
if (type >= QTouchDevice::TouchScreen && type <= QTouchDevice::TouchPad) {
dev->qtTouchDevice = new QTouchDevice;
dev->qtTouchDevice->setName(QString::fromUtf8(dev->xiDeviceInfo->name));
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 2e9ba0e8c5..258359d20f 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -110,11 +110,15 @@ static bool runningUnderDebugger()
#endif
}
+QXcbIntegration *QXcbIntegration::m_instance = Q_NULLPTR;
+
QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char **argv)
: m_services(new QGenericUnixServices)
, m_instanceName(0)
, m_canGrab(true)
{
+ m_instance = this;
+
qRegisterMetaType<QXcbWindow*>();
#ifdef XCB_USE_XLIB
XInitThreads();
@@ -166,9 +170,7 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char
m_connections << new QXcbConnection(m_nativeInterface.data(), m_canGrab, displayName);
for (int i = 0; i < parameters.size() - 1; i += 2) {
-#ifdef Q_XCB_DEBUG
- qDebug() << "QXcbIntegration: Connecting to additional display: " << parameters.at(i) << parameters.at(i+1);
-#endif
+ qCDebug(lcQpaScreen) << "connecting to additional display: " << parameters.at(i) << parameters.at(i+1);
QString display = parameters.at(i) + QLatin1Char(':') + parameters.at(i+1);
m_connections << new QXcbConnection(m_nativeInterface.data(), m_canGrab, display.toLatin1().constData());
}
@@ -179,6 +181,7 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char
QXcbIntegration::~QXcbIntegration()
{
qDeleteAll(m_connections);
+ m_instance = Q_NULLPTR;
}
QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const
@@ -371,9 +374,6 @@ QVariant QXcbIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
// X11 always has support for windows, but the
// window manager could prevent it (e.g. matchbox)
return false;
- case QPlatformIntegration::SynthesizeMouseFromTouchEvents:
- // We do not want Qt to synthesize mouse events if X11 already does it.
- return m_connections.at(0)->hasTouchWithoutMouseEmulation();
default:
break;
}
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
index 0af9df55aa..4212d53810 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.h
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -101,6 +101,9 @@ public:
#endif
void sync() Q_DECL_OVERRIDE;
+
+ static QXcbIntegration *instance() { return m_instance; }
+
private:
QList<QXcbConnection *> m_connections;
@@ -120,6 +123,8 @@ private:
mutable QByteArray m_wmClass;
const char *m_instanceName;
bool m_canGrab;
+
+ static QXcbIntegration *m_instance;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 701ca91b37..6cb238228f 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -363,7 +363,7 @@ void *QXcbNativeInterface::getTimestamp(const QXcbScreen *screen)
void *QXcbNativeInterface::startupId()
{
- QXcbIntegration* integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QXcbIntegration* integration = QXcbIntegration::instance();
QXcbConnection *defaultConnection = integration->defaultConnection();
if (defaultConnection)
return reinterpret_cast<void *>(const_cast<char *>(defaultConnection->startupId().constData()));
@@ -372,7 +372,7 @@ void *QXcbNativeInterface::startupId()
void *QXcbNativeInterface::x11Screen()
{
- QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QXcbIntegration *integration = QXcbIntegration::instance();
QXcbConnection *defaultConnection = integration->defaultConnection();
if (defaultConnection)
return reinterpret_cast<void *>(defaultConnection->primaryScreenNumber());
@@ -381,7 +381,7 @@ void *QXcbNativeInterface::x11Screen()
void *QXcbNativeInterface::rootWindow()
{
- QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QXcbIntegration *integration = QXcbIntegration::instance();
QXcbConnection *defaultConnection = integration->defaultConnection();
if (defaultConnection)
return reinterpret_cast<void *>(defaultConnection->rootWindow());
@@ -391,7 +391,7 @@ void *QXcbNativeInterface::rootWindow()
void *QXcbNativeInterface::display()
{
#ifdef XCB_USE_XLIB
- QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QXcbIntegration *integration = QXcbIntegration::instance();
QXcbConnection *defaultConnection = integration->defaultConnection();
return defaultConnection->xlib_display();
#else
@@ -412,7 +412,7 @@ void QXcbNativeInterface::setAppUserTime(QScreen* screen, xcb_timestamp_t time)
void QXcbNativeInterface::setStartupId(const char *data)
{
QByteArray startupId(data);
- QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QXcbIntegration *integration = QXcbIntegration::instance();
QXcbConnection *defaultConnection = integration->defaultConnection();
if (defaultConnection)
defaultConnection->setStartupId(startupId);
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 57a777b682..58a364848a 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -93,25 +93,6 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr,
if (dpr_scaling_enabled)
m_noFontHinting = true;
-#ifdef Q_XCB_DEBUG
- qDebug();
- qDebug("Screen output %s of xcb screen %d:", m_outputName.toUtf8().constData(), m_number);
- qDebug(" width..........: %lf", m_sizeMillimeters.width());
- qDebug(" height.........: %lf", m_sizeMillimeters.height());
- qDebug(" geometry.......: %d x %d +%d +%d", m_geometry.width(), m_geometry.height(), m_geometry.x(), m_geometry.y());
- qDebug(" virtual width..: %lf", m_virtualSizeMillimeters.width());
- qDebug(" virtual height.: %lf", m_virtualSizeMillimeters.height());
- qDebug(" virtual geom...: %d x %d", m_virtualSize.width(), m_virtualSize.height());
- qDebug(" avail virt geom: %d x %d +%d +%d", m_availableGeometry.width(), m_availableGeometry.height(), m_availableGeometry.x(), m_availableGeometry.y());
- qDebug(" orientation....: %d", m_orientation);
- qDebug(" pixel ratio....: %d", m_devicePixelRatio);
- qDebug(" depth..........: %d", screen()->root_depth);
- qDebug(" white pixel....: %x", screen()->white_pixel);
- qDebug(" black pixel....: %x", screen()->black_pixel);
- qDebug(" refresh rate...: %d", m_refreshRate);
- qDebug(" root ID........: %x", screen()->root);
-#endif
-
QScopedPointer<xcb_get_window_attributes_reply_t, QScopedPointerPodDeleter> rootAttribs(
xcb_get_window_attributes_reply(xcb_connection(),
xcb_get_window_attributes_unchecked(xcb_connection(), screen()->root), NULL));
@@ -146,10 +127,6 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr,
atom(QXcbAtom::UTF8_STRING), 0, 1024), NULL);
if (windowManagerReply && windowManagerReply->format == 8 && windowManagerReply->type == atom(QXcbAtom::UTF8_STRING)) {
m_windowManagerName = QString::fromUtf8((const char *)xcb_get_property_value(windowManagerReply), xcb_get_property_value_length(windowManagerReply));
-#ifdef Q_XCB_DEBUG
- qDebug(" window manager.: %s", qPrintable(m_windowManagerName));
- qDebug();
-#endif
}
free(windowManagerReply);
@@ -710,4 +687,47 @@ QXcbXSettings *QXcbScreen::xSettings() const
return m_xSettings;
}
+static inline void formatRect(QDebug &debug, const QRect r)
+{
+ debug << r.width() << 'x' << r.height()
+ << forcesign << r.x() << r.y() << noforcesign;
+}
+
+static inline void formatSizeF(QDebug &debug, const QSizeF s)
+{
+ debug << s.width() << 'x' << s.height() << "mm";
+}
+
+Q_XCB_EXPORT QDebug operator<<(QDebug debug, const QXcbScreen *screen)
+{
+ const QDebugStateSaver saver(debug);
+ debug.nospace();
+ debug << "QXcbScreen(" << (void *)screen;
+ if (screen) {
+ debug << fixed << qSetRealNumberPrecision(1);
+ debug << ", name=" << screen->name();
+ debug << ", geometry=";
+ formatRect(debug, screen->geometry());
+ debug << ", availableGeometry=";
+ formatRect(debug, screen->availableGeometry());
+ debug << ", devicePixelRatio=" << screen->devicePixelRatio();
+ debug << ", logicalDpi=" << screen->logicalDpi();
+ debug << ", physicalSize=";
+ formatSizeF(debug, screen->physicalSize());
+ // TODO 5.6 if (debug.verbosity() > 2) {
+ debug << ", screenNumber=" << screen->screenNumber();
+ debug << ", virtualSize=" << screen->virtualSize().width() << "x" << screen->virtualSize().height() << " (";
+ formatSizeF(debug, screen->virtualSize());
+ debug << "), nativeGeometry=";
+ formatRect(debug, screen->nativeGeometry());
+ debug << ", orientation=" << screen->orientation();
+ debug << ", depth=" << screen->depth();
+ debug << ", refreshRate=" << screen->refreshRate();
+ debug << ", root=" << hex << screen->root();
+ debug << ", windowManagerName=" << screen->windowManagerName();
+ }
+ debug << ')';
+ return debug;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index f327eb31b0..53ad413541 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -50,6 +50,9 @@ QT_BEGIN_NAMESPACE
class QXcbConnection;
class QXcbCursor;
class QXcbXSettings;
+#ifndef QT_NO_DEBUG_STREAM
+class QDebug;
+#endif
class Q_XCB_EXPORT QXcbScreen : public QXcbObject, public QPlatformScreen
{
@@ -68,6 +71,8 @@ public:
int depth() const Q_DECL_OVERRIDE { return m_screen->root_depth; }
QImage::Format format() const Q_DECL_OVERRIDE;
QSizeF physicalSize() const Q_DECL_OVERRIDE { return m_sizeMillimeters; }
+ QSize virtualSize() const { return m_virtualSize; }
+ QSizeF physicalVirtualSize() const { return m_virtualSizeMillimeters; }
QDpi logicalDpi() const Q_DECL_OVERRIDE;
qreal devicePixelRatio() const Q_DECL_OVERRIDE;
QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
@@ -140,6 +145,10 @@ private:
QXcbXSettings *m_xSettings;
};
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug, const QXcbScreen *);
+#endif
+
QT_END_NAMESPACE
#endif
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 2253dfecef..222f6c1170 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -462,7 +462,7 @@ void QXcbWindow::create()
m_syncValue.hi = 0;
m_syncValue.lo = 0;
- const QByteArray wmClass = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration())->wmClass();
+ const QByteArray wmClass = QXcbIntegration::instance()->wmClass();
if (!wmClass.isEmpty()) {
Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE,
m_window, atom(QXcbAtom::WM_CLASS),
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index acac632410..fa2080fe69 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -2757,7 +2757,7 @@ static inline bool isWindowsBuildDirectory(const QString &dirName)
}
#endif
-/* !
+/*!
Extract a directory from resources to disk. The content is extracted
recursively to a temporary folder. The extracted content is not removed
automatically.
diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp
index 405be6f500..6cb86a7515 100644
--- a/src/tools/qdoc/cppcodeparser.cpp
+++ b/src/tools/qdoc/cppcodeparser.cpp
@@ -1692,35 +1692,76 @@ bool CppCodeParser::matchNamespaceDecl(InnerNode *parent)
return matched && match(Tok_RightBrace);
}
-bool CppCodeParser::matchUsingDecl()
+/*!
+ Match a C++ \c using clause. Return \c true if the match
+ is successful. Otherwise false.
+
+ If the \c using clause is for a namespace, an open namespace
+ <is inserted for qdoc to look in to find things.
+
+ If the \c using clause is a base class member function, the
+ member function is added to \a parent as an unresolved
+ \c using clause.
+ */
+bool CppCodeParser::matchUsingDecl(InnerNode* parent)
{
+ bool usingNamespace = false;
readToken(); // skip 'using'
- // 'namespace'
- if (tok != Tok_namespace)
- return false;
-
- readToken();
- // identifier
- if (tok != Tok_Ident)
- return false;
+ if (tok == Tok_namespace) {
+ usingNamespace = true;
+ readToken();
+ }
+ int openLeftAngles = 0;
+ int openLeftParens = 0;
+ bool usingOperator = false;
QString name;
- while (tok == Tok_Ident) {
+ while (tok != Tok_Semicolon) {
+ if ((tok != Tok_Ident) && (tok != Tok_Gulbrandsen)) {
+ if (tok == Tok_LeftAngle) {
+ ++openLeftAngles;
+ }
+ else if (tok == Tok_RightAngle) {
+ if (openLeftAngles <= 0)
+ return false;
+ --openLeftAngles;
+ }
+ else if (tok == Tok_Comma) {
+ if (openLeftAngles <= 0)
+ return false;
+ }
+ else if (tok == Tok_operator) {
+ usingOperator = true;
+ }
+ else if (tok == Tok_SomeOperator) {
+ if (!usingOperator)
+ return false;
+ }
+ else if (tok == Tok_LeftParen) {
+ ++openLeftParens;
+ }
+ else if (tok == Tok_RightParen) {
+ if (openLeftParens <= 0)
+ return false;
+ --openLeftParens;
+ }
+ else {
+ return false;
+ }
+ }
name += lexeme();
readToken();
- if (tok == Tok_Semicolon)
- break;
- else if (tok != Tok_Gulbrandsen)
- return false;
- name += "::";
- readToken();
}
- /*
- So far, so good. We have 'using namespace Foo;'.
- */
- qdb_->insertOpenNamespace(name);
+ if (usingNamespace) {
+ // 'using namespace Foo;'.
+ qdb_->insertOpenNamespace(name);
+ }
+ else if (parent && parent->isClass()) {
+ ClassNode* cn = static_cast<ClassNode*>(parent);
+ cn->addUnresolvedUsingClause(name);
+ }
return true;
}
@@ -1961,7 +2002,7 @@ bool CppCodeParser::matchDeclList(InnerNode *parent)
matchNamespaceDecl(parent);
break;
case Tok_using:
- matchUsingDecl();
+ matchUsingDecl(parent);
break;
case Tok_template:
{
@@ -2221,7 +2262,7 @@ bool CppCodeParser::matchDocsAndStuff()
}
}
else if (tok == Tok_using) {
- matchUsingDecl();
+ matchUsingDecl(0);
}
else {
QStringList parentPath;
diff --git a/src/tools/qdoc/cppcodeparser.h b/src/tools/qdoc/cppcodeparser.h
index dc5c8ca8bd..f9ddcab88c 100644
--- a/src/tools/qdoc/cppcodeparser.h
+++ b/src/tools/qdoc/cppcodeparser.h
@@ -127,7 +127,7 @@ protected:
bool matchClassDecl(InnerNode *parent,
const QString &templateStuff = QString());
bool matchNamespaceDecl(InnerNode *parent);
- bool matchUsingDecl();
+ bool matchUsingDecl(InnerNode* parent);
bool matchEnumItem(InnerNode *parent, EnumNode *enume);
bool matchEnumDecl(InnerNode *parent);
bool matchTypedefDecl(InnerNode *parent);
diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp
index f65b4ec942..e14ca4af3e 100644
--- a/src/tools/qdoc/node.cpp
+++ b/src/tools/qdoc/node.cpp
@@ -1415,6 +1415,17 @@ void ClassNode::addUnresolvedBaseClass(Access access,
}
/*!
+ Add an unresolved \c using clause to this class node's list
+ of \c using clauses. The unresolved \c using clause will be
+ resolved before the generate phase of qdoc. In an unresolved
+ \c using clause, the pointer to the function node is 0.
+ */
+void ClassNode::addUnresolvedUsingClause(const QString& signature)
+{
+ usingClauses_.append(UsingClause(signature));
+}
+
+/*!
*/
void ClassNode::fixBaseClasses()
{
diff --git a/src/tools/qdoc/node.h b/src/tools/qdoc/node.h
index 8e25aac9c1..b6717b3b1b 100644
--- a/src/tools/qdoc/node.h
+++ b/src/tools/qdoc/node.h
@@ -479,6 +479,18 @@ struct RelatedClass
QString signature_;
};
+struct UsingClause
+{
+ UsingClause() { }
+ UsingClause(const QString& signature) : node_(0), signature_(signature) { }
+ const QString& signature() const { return signature_; }
+ const Node* node() { return node_; }
+ void setNode(const Node* n) { node_ = n; }
+
+ const Node* node_;
+ QString signature_;
+};
+
class ClassNode : public InnerNode
{
public:
@@ -493,16 +505,19 @@ public:
void addResolvedBaseClass(Access access, ClassNode* node);
void addDerivedClass(Access access, ClassNode* node);
void addUnresolvedBaseClass(Access access, const QStringList& path, const QString& signature);
+ void addUnresolvedUsingClause(const QString& signature);
void fixBaseClasses();
void fixPropertyUsingBaseClasses(PropertyNode* pn);
QList<RelatedClass>& baseClasses() { return bases_; }
QList<RelatedClass>& derivedClasses() { return derived_; }
QList<RelatedClass>& ignoredBaseClasses() { return ignoredBases_; }
+ QList<UsingClause>& usingClauses() { return usingClauses_; }
const QList<RelatedClass> &baseClasses() const { return bases_; }
const QList<RelatedClass> &derivedClasses() const { return derived_; }
const QList<RelatedClass> &ignoredBaseClasses() const { return ignoredBases_; }
+ const QList<UsingClause>& usingClauses() const { return usingClauses_; }
QString serviceName() const { return sname; }
void setServiceName(const QString& value) { sname = value; }
@@ -517,6 +532,7 @@ private:
QList<RelatedClass> bases_;
QList<RelatedClass> derived_;
QList<RelatedClass> ignoredBases_;
+ QList<UsingClause> usingClauses_;
bool abstract_;
bool wrapper_;
QString sname;
diff --git a/src/tools/qdoc/qdocdatabase.cpp b/src/tools/qdoc/qdocdatabase.cpp
index 2f7c2eaeb7..75295613f7 100644
--- a/src/tools/qdoc/qdocdatabase.cpp
+++ b/src/tools/qdoc/qdocdatabase.cpp
@@ -1331,6 +1331,7 @@ void QDocDatabase::resolveStuff()
resolveQmlInheritance(primaryTreeRoot());
//primaryTree()->resolveTargets(primaryTreeRoot());
primaryTree()->resolveCppToQmlLinks();
+ primaryTree()->resolveUsingClauses();
}
/*!
diff --git a/src/tools/qdoc/tree.cpp b/src/tools/qdoc/tree.cpp
index ed4b4e3979..6393ad4e6f 100644
--- a/src/tools/qdoc/tree.cpp
+++ b/src/tools/qdoc/tree.cpp
@@ -499,6 +499,29 @@ void Tree::resolveCppToQmlLinks()
}
/*!
+ For each C++ class node, resolve any \c using clauses
+ that appeared in the class declaration.
+ */
+void Tree::resolveUsingClauses()
+{
+ foreach (Node* child, root_.childNodes()) {
+ if (child->isClass()) {
+ ClassNode* cn = static_cast<ClassNode*>(child);
+ QList<UsingClause>& usingClauses = cn->usingClauses();
+ QList<UsingClause>::iterator uc = usingClauses.begin();
+ while (uc != usingClauses.end()) {
+ if (!(*uc).node()) {
+ const Node* n = qdb_->findFunctionNode((*uc).signature(), cn, Node::CPP);
+ if (n)
+ (*uc).setNode(n);
+ }
+ ++uc;
+ }
+ }
+ }
+}
+
+/*!
*/
void Tree::fixInheritance(NamespaceNode* rootNode)
{
@@ -1427,7 +1450,8 @@ void Tree::insertQmlType(const QString& key, QmlTypeNode* n)
const Node* Tree::findFunctionNode(const QString& target, const Node* relative, Node::Genus genus)
{
QString t = target;
- t.chop(2);
+ if (t.endsWith("()"))
+ t.chop(2);
QStringList path = t.split("::");
const FunctionNode* fn = findFunctionNode(path, relative, SearchBaseClasses, genus);
if (fn && fn->metaness() != FunctionNode::MacroWithoutParams)
diff --git a/src/tools/qdoc/tree.h b/src/tools/qdoc/tree.h
index 2e6f766770..67063ef86a 100644
--- a/src/tools/qdoc/tree.h
+++ b/src/tools/qdoc/tree.h
@@ -153,6 +153,7 @@ class Tree
void resolveInheritanceHelper(int pass, ClassNode* cn);
void resolveProperties();
void resolveCppToQmlLinks();
+ void resolveUsingClauses();
void fixInheritance(NamespaceNode *rootNode = 0);
NamespaceNode *root() { return &root_; }
diff --git a/src/widgets/doc/src/modelview.qdoc b/src/widgets/doc/src/modelview.qdoc
index 153b94bbdd..e3a569e8ac 100644
--- a/src/widgets/doc/src/modelview.qdoc
+++ b/src/widgets/doc/src/modelview.qdoc
@@ -576,7 +576,7 @@
problem.
Qt Labs provides software called
- \l{http://qt-project.org/wiki/Model_Test}{ModelTest},
+ \l{http://wiki.qt.io/?title=Model_Test}{ModelTest},
which checks models while your programming is running. Every time the model
is changed, ModelTest scans the model and reports errors with an assert.
This is especially important for tree models, since their hierarchical
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index b3c7fb3e82..533564c1dc 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -7390,7 +7390,7 @@ void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints)
QWidget *fw = QApplication::focusWidget();
if (!fw)
return;
- qApp->inputMethod()->update(Qt::ImHints);
+ QGuiApplication::inputMethod()->update(Qt::ImHints);
}
/*!
@@ -7408,7 +7408,7 @@ void QGraphicsItem::updateMicroFocus()
for (int i = 0 ; i < scene()->views().count() ; ++i) {
if (scene()->views().at(i) == fw) {
if (qApp)
- qApp->inputMethod()->update(Qt::ImQueryAll);
+ QGuiApplication::inputMethod()->update(Qt::ImQueryAll);
break;
}
}
@@ -10141,9 +10141,9 @@ bool QGraphicsTextItem::sceneEvent(QEvent *event)
// Reset the focus widget's input context, regardless
// of how this item gained or lost focus.
if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) {
- qApp->inputMethod()->reset();
+ QGuiApplication::inputMethod()->reset();
} else {
- qApp->inputMethod()->update(Qt::ImQueryInput);
+ QGuiApplication::inputMethod()->update(Qt::ImQueryInput);
}
break;
case QEvent::ShortcutOverride:
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 0230b68315..ad58aeb488 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -847,7 +847,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
// the views, but if we are changing focus, we have to
// do it ourselves.
if (qApp)
- qApp->inputMethod()->commit();
+ QGuiApplication::inputMethod()->commit();
}
#endif //QT_NO_IM
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index d19087bd8d..78c842f7e1 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -117,6 +117,14 @@ static void initResources()
QT_BEGIN_NAMESPACE
+// Helper macro for static functions to check on the existence of the application class.
+#define CHECK_QAPP_INSTANCE(...) \
+ if (Q_LIKELY(QCoreApplication::instance())) { \
+ } else { \
+ qWarning("Must construct a QApplication first."); \
+ return __VA_ARGS__; \
+ }
+
Q_CORE_EXPORT void qt_call_post_routines();
QApplicationPrivate *QApplicationPrivate::self = 0;
@@ -827,7 +835,7 @@ QApplication::~QApplication()
if (QWidgetPrivate::allWidgets) {
QWidgetSet *mySet = QWidgetPrivate::allWidgets;
QWidgetPrivate::allWidgets = 0;
- for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) {
+ for (QWidgetSet::ConstIterator it = mySet->constBegin(), cend = mySet->constEnd(); it != cend; ++it) {
QWidget *w = *it;
if (!w->parent()) // window
w->destroy(true, true);
@@ -1190,7 +1198,7 @@ void QApplication::setStyle(QStyle *style)
// clean up the old style
if (QApplicationPrivate::app_style) {
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
- for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
+ for (QWidgetList::ConstIterator it = all.constBegin(), cend = all.constEnd(); it != cend; ++it) {
QWidget *w = *it;
if (!(w->windowType() == Qt::Desktop) && // except desktop
w->testAttribute(Qt::WA_WState_Polished)) { // has been polished
@@ -1238,8 +1246,8 @@ void QApplication::setStyle(QStyle *style)
// re-polish existing widgets if necessary
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
- for (QWidgetList::ConstIterator it1 = all.constBegin(); it1 != all.constEnd(); ++it1) {
- QWidget *w = *it1;
+ for (QWidgetList::ConstIterator it = all.constBegin(), cend = all.constEnd(); it != cend; ++it) {
+ QWidget *w = *it;
if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) {
if (w->style() == QApplicationPrivate::app_style)
QApplicationPrivate::app_style->polish(w); // repolish
@@ -1250,8 +1258,8 @@ void QApplication::setStyle(QStyle *style)
}
}
- for (QWidgetList::ConstIterator it2 = all.constBegin(); it2 != all.constEnd(); ++it2) {
- QWidget *w = *it2;
+ for (QWidgetList::ConstIterator it = all.constBegin(), cend = all.constEnd(); it != cend; ++it) {
+ QWidget *w = *it;
if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) {
QEvent e(QEvent::StyleChange);
QApplication::sendEvent(w, &e);
@@ -1416,12 +1424,15 @@ void QApplication::setGlobalStrut(const QSize& strut)
*/
QPalette QApplication::palette(const QWidget* w)
{
+ typedef PaletteHash::const_iterator PaletteHashConstIt;
+
PaletteHash *hash = app_palettes();
if (w && hash && hash->size()) {
- QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(w->metaObject()->className());
- if (it != hash->constEnd())
+ PaletteHashConstIt it = hash->constFind(w->metaObject()->className());
+ const PaletteHashConstIt cend = hash->constEnd();
+ if (it != cend)
return *it;
- for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
+ for (it = hash->constBegin(); it != cend; ++it) {
if (w->inherits(it.key()))
return it.value();
}
@@ -1480,7 +1491,7 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
QApplication::sendEvent(QApplication::instance(), &e);
QWidgetList wids = QApplication::allWidgets();
- for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
+ for (QWidgetList::ConstIterator it = wids.constBegin(), cend = wids.constEnd(); it != cend; ++it) {
QWidget *w = *it;
if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
QApplication::sendEvent(w, &e);
@@ -1582,6 +1593,8 @@ QFont QApplication::font()
QFont QApplication::font(const QWidget *widget)
{
+ typedef FontHash::const_iterator FontHashConstIt;
+
FontHash *hash = app_fonts();
if (widget && hash && hash->size()) {
@@ -1593,11 +1606,11 @@ QFont QApplication::font(const QWidget *widget)
return hash->value(QByteArrayLiteral("QMiniFont"));
}
#endif
- QHash<QByteArray, QFont>::ConstIterator it =
- hash->constFind(widget->metaObject()->className());
- if (it != hash->constEnd())
+ FontHashConstIt it = hash->constFind(widget->metaObject()->className());
+ const FontHashConstIt cend = hash->constEnd();
+ if (it != cend)
return it.value();
- for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
+ for (it = hash->constBegin(); it != cend; ++it) {
if (widget->inherits(it.key()))
return it.value();
}
@@ -1662,7 +1675,7 @@ void QApplication::setFont(const QFont &font, const char *className)
QApplication::sendEvent(QApplication::instance(), &e);
QWidgetList wids = QApplication::allWidgets();
- for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
+ for (QWidgetList::ConstIterator it = wids.constBegin(), cend = wids.constEnd(); it != cend; ++it) {
QWidget *w = *it;
if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
sendEvent(w, &e);
@@ -1767,7 +1780,7 @@ QWidgetList QApplication::topLevelWidgets()
QWidgetList list;
QWidgetList all = allWidgets();
- for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
+ for (QWidgetList::ConstIterator it = all.constBegin(), cend = all.constEnd(); it != cend; ++it) {
QWidget *w = *it;
if (w->isWindow() && w->windowType() != Qt::Desktop)
list.append(w);
@@ -2146,7 +2159,7 @@ void QApplication::setActiveWindow(QWidget* act)
if (QApplicationPrivate::focus_widget) {
if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled))
- qApp->inputMethod()->commit();
+ QGuiApplication::inputMethod()->commit();
QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, Qt::ActiveWindowFocusReason);
QApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange);
@@ -2850,6 +2863,7 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
*/
QDesktopWidget *QApplication::desktop()
{
+ CHECK_QAPP_INSTANCE(Q_NULLPTR)
if (!qt_desktopWidget || // not created yet
!(qt_desktopWidget->windowType() == Qt::Desktop)) { // reparented away
qt_desktopWidget = new QDesktopWidget();
@@ -2887,7 +2901,7 @@ void QApplication::setStartDragTime(int ms)
int QApplication::startDragTime()
{
- return qApp->styleHints()->startDragTime();
+ return QGuiApplication::styleHints()->startDragTime();
}
/*
@@ -2925,7 +2939,7 @@ void QApplication::setStartDragDistance(int l)
int QApplication::startDragDistance()
{
- return qApp->styleHints()->startDragDistance();
+ return QGuiApplication::styleHints()->startDragDistance();
}
/*!
@@ -3968,7 +3982,7 @@ void QApplication::setCursorFlashTime(int msecs)
int QApplication::cursorFlashTime()
{
- return qApp->styleHints()->cursorFlashTime();
+ return QGuiApplication::styleHints()->cursorFlashTime();
}
/*!
@@ -3986,7 +4000,7 @@ void QApplication::setDoubleClickInterval(int ms)
int QApplication::doubleClickInterval()
{
- return qApp->styleHints()->mouseDoubleClickInterval();
+ return QGuiApplication::styleHints()->mouseDoubleClickInterval();
}
/*!
@@ -4014,7 +4028,7 @@ void QApplication::setKeyboardInputInterval(int ms)
int QApplication::keyboardInputInterval()
{
- return qApp->styleHints()->keyboardInputInterval();
+ return QGuiApplication::styleHints()->keyboardInputInterval();
}
/*!
@@ -4105,6 +4119,7 @@ void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
*/
bool QApplication::isEffectEnabled(Qt::UIEffect effect)
{
+ CHECK_QAPP_INSTANCE(false)
return QColormap::instance().depth() >= 16
&& (QApplicationPrivate::enabledAnimations & QPlatformTheme::GeneralUiEffect)
&& (QApplicationPrivate::enabledAnimations & uiEffectToFlag(effect));
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
index d74d058251..d4b2326afd 100644
--- a/src/widgets/kernel/qapplication.h
+++ b/src/widgets/kernel/qapplication.h
@@ -165,9 +165,9 @@ public:
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED static QLocale keyboardInputLocale()
- { return qApp ? qApp->inputMethod()->locale() : QLocale::c(); }
+ { return qApp ? QGuiApplication::inputMethod()->locale() : QLocale::c(); }
QT_DEPRECATED static Qt::LayoutDirection keyboardInputDirection()
- { return qApp ? qApp->inputMethod()->inputDirection() : Qt::LeftToRight; }
+ { return qApp ? QGuiApplication::inputMethod()->inputDirection() : Qt::LeftToRight; }
#endif
static int exec();
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index 79acfed883..b5d3a56d3f 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -618,7 +618,7 @@ void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures,
if (gesture->hasHotSpot()) {
// guess the target widget using the hotspot of the gesture
QPoint pt = gesture->hotSpot().toPoint();
- if (QWidget *topLevel = qApp->topLevelAt(pt)) {
+ if (QWidget *topLevel = QApplication::topLevelAt(pt)) {
QWidget *child = topLevel->childAt(topLevel->mapFromGlobal(pt));
target = child ? child : topLevel;
}
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 6d896f5f50..65b861bc68 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -359,12 +359,12 @@ void QWidgetPrivate::setWSGeometry()
void QWidgetPrivate::updateWidgetTransform(QEvent *event)
{
Q_Q(QWidget);
- if (q == qGuiApp->focusObject() || event->type() == QEvent::FocusIn) {
+ if (q == QGuiApplication::focusObject() || event->type() == QEvent::FocusIn) {
QTransform t;
QPoint p = q->mapTo(q->topLevelWidget(), QPoint(0,0));
t.translate(p.x(), p.y());
- qApp->inputMethod()->setInputItemTransform(t);
- qApp->inputMethod()->setInputItemRectangle(q->rect());
+ QGuiApplication::inputMethod()->setInputItemTransform(t);
+ QGuiApplication::inputMethod()->setInputItemRectangle(q->rect());
}
}
@@ -3401,10 +3401,10 @@ void QWidgetPrivate::setEnabled_helper(bool enable)
if (enable) {
if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
- qApp->inputMethod()->update(Qt::ImEnabled);
+ QGuiApplication::inputMethod()->update(Qt::ImEnabled);
} else {
- qApp->inputMethod()->commit();
- qApp->inputMethod()->update(Qt::ImEnabled);
+ QGuiApplication::inputMethod()->commit();
+ QGuiApplication::inputMethod()->update(Qt::ImEnabled);
}
}
#endif //QT_NO_IM
@@ -6427,7 +6427,7 @@ void QWidget::setFocus(Qt::FocusReason reason)
if (prev) {
if (reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
&& prev->testAttribute(Qt::WA_InputMethodEnabled)) {
- qApp->inputMethod()->commit();
+ QGuiApplication::inputMethod()->commit();
}
if (reason != Qt::NoFocusReason) {
@@ -6550,7 +6550,7 @@ void QWidget::clearFocus()
{
if (hasFocus()) {
if (testAttribute(Qt::WA_InputMethodEnabled))
- qApp->inputMethod()->commit();
+ QGuiApplication::inputMethod()->commit();
QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange);
QApplication::sendEvent(this, &focusAboutToChange);
@@ -9429,7 +9429,7 @@ void QWidget::focusOutEvent(QFocusEvent *)
#ifndef Q_OS_IOS
// FIXME: revisit autoSIP logic, QTBUG-42906
if (qApp->autoSipEnabled() && testAttribute(Qt::WA_InputMethodEnabled))
- qApp->inputMethod()->hide();
+ QGuiApplication::inputMethod()->hide();
#endif
}
@@ -9718,8 +9718,8 @@ void QWidget::setInputMethodHints(Qt::InputMethodHints hints)
if (d->imHints == hints)
return;
d->imHints = hints;
- if (this == qApp->focusObject())
- qApp->inputMethod()->update(Qt::ImHints);
+ if (this == QGuiApplication::focusObject())
+ QGuiApplication::inputMethod()->update(Qt::ImHints);
#endif //QT_NO_IM
}
@@ -11061,18 +11061,18 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
d->createTLSysExtra();
#ifndef QT_NO_IM
QWidget *focusWidget = d->effectiveFocusWidget();
- if (on && !internalWinId() && this == qApp->focusObject()
+ if (on && !internalWinId() && this == QGuiApplication::focusObject()
&& focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
- qApp->inputMethod()->commit();
- qApp->inputMethod()->update(Qt::ImEnabled);
+ QGuiApplication::inputMethod()->commit();
+ QGuiApplication::inputMethod()->update(Qt::ImEnabled);
}
if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
parentWidget()->d_func()->enforceNativeChildren();
if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
d->createWinId();
- if (isEnabled() && focusWidget->isEnabled() && this == qApp->focusObject()
+ if (isEnabled() && focusWidget->isEnabled() && this == QGuiApplication::focusObject()
&& focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
- qApp->inputMethod()->update(Qt::ImEnabled);
+ QGuiApplication::inputMethod()->update(Qt::ImEnabled);
}
#endif //QT_NO_IM
break;
@@ -11105,10 +11105,10 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
break;
case Qt::WA_InputMethodEnabled: {
#ifndef QT_NO_IM
- if (qApp->focusObject() == this) {
+ if (QGuiApplication::focusObject() == this) {
if (!on)
- qApp->inputMethod()->commit();
- qApp->inputMethod()->update(Qt::ImEnabled);
+ QGuiApplication::inputMethod()->commit();
+ QGuiApplication::inputMethod()->update(Qt::ImEnabled);
}
#endif //QT_NO_IM
break;
@@ -11596,8 +11596,8 @@ void QWidget::setShortcutAutoRepeat(int id, bool enable)
void QWidget::updateMicroFocus()
{
// updating everything since this is currently called for any kind of state change
- if (this == qApp->focusObject())
- qApp->inputMethod()->update(Qt::ImQueryAll);
+ if (this == QGuiApplication::focusObject())
+ QGuiApplication::inputMethod()->update(Qt::ImQueryAll);
}
/*!
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 5b99809961..9425426215 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -598,7 +598,7 @@ public:
QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
- qApp->inputMethod()->show();
+ QGuiApplication::inputMethod()->show();
}
}
}
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 6b03ad0b6c..b7ffc20c8e 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -191,7 +191,7 @@ bool QWidgetWindow::event(QEvent *event)
case QEvent::FocusAboutToChange:
if (QApplicationPrivate::focus_widget) {
if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled))
- qApp->inputMethod()->commit();
+ QGuiApplication::inputMethod()->commit();
QGuiApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, event);
}
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 394d06843b..4f9ed2c325 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -93,6 +93,18 @@
QT_USE_NAMESPACE
+namespace {
+class AutoReleasePool
+{
+public:
+ AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
+ ~AutoReleasePool() { [pool release]; }
+
+private:
+ NSAutoreleasePool *pool;
+};
+}
+
@interface QT_MANGLE_NAMESPACE(NotificationReceiver) : NSObject {
QMacStylePrivate *mPrivate;
}
@@ -2122,6 +2134,8 @@ QMacStyle::QMacStyle()
: QCommonStyle(*new QMacStylePrivate)
{
Q_D(QMacStyle);
+ AutoReleasePool pool;
+
d->receiver = [[NotificationReceiver alloc] initWithPrivate:d];
NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
@@ -2137,6 +2151,8 @@ QMacStyle::QMacStyle()
QMacStyle::~QMacStyle()
{
Q_D(QMacStyle);
+ AutoReleasePool pool;
+
[reinterpret_cast<NSScroller*>(d->nsscroller) release];
NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
@@ -2152,6 +2168,7 @@ QMacStyle::~QMacStyle()
*/
QPixmap QMacStylePrivate::generateBackgroundPattern() const
{
+ AutoReleasePool pool;
QPixmap px(4, 4);
QMacCGContext cg(&px);
HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal);
@@ -2749,6 +2766,8 @@ QPalette QMacStyle::standardPalette() const
int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,
QStyleHintReturn *hret) const
{
+ AutoReleasePool pool;
+
SInt32 ret = 0;
switch (sh) {
case SH_Slider_SnapToValue:
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index eea63e5864..2f833499d9 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -1181,7 +1181,7 @@ void QAbstractSpinBox::timerEvent(QTimerEvent *event)
killTimer(d->spinClickThresholdTimerId);
d->spinClickThresholdTimerId = -1;
d->effectiveSpinRepeatRate = d->buttonState & Keyboard
- ? qApp->styleHints()->keyboardAutoRepeatRate()
+ ? QGuiApplication::styleHints()->keyboardAutoRepeatRate()
: d->spinClickTimerInterval;
d->spinClickTimerId = startTimer(d->effectiveSpinRepeatRate);
doStep = true;
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index cc4d2f7701..ab4c7bfff6 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -2646,7 +2646,7 @@ void QComboBox::showPopup()
}
if (qApp) {
- qApp->inputMethod()->reset();
+ QGuiApplication::inputMethod()->reset();
}
QScrollBar *sb = view()->horizontalScrollBar();
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index f115ce3079..0500907b3d 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -2153,7 +2153,7 @@ QMenu *QLineEdit::createStandardContextMenu()
d->selectAllAction = action;
connect(action, SIGNAL(triggered()), SLOT(selectAll()));
- if (!d->control->isReadOnly() && qApp->styleHints()->useRtlExtensions()) {
+ if (!d->control->isReadOnly() && QGuiApplication::styleHints()->useRtlExtensions()) {
popup->addSeparator();
QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, popup);
popup->addMenu(ctrlCharacterMenu);
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index b7d2ab4059..6a41c3791f 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -250,7 +250,7 @@ void QLineEditPrivate::resetInputMethod()
{
Q_Q(QLineEdit);
if (q->hasFocus() && qApp) {
- qApp->inputMethod()->reset();
+ QGuiApplication::inputMethod()->reset();
}
}
@@ -270,7 +270,7 @@ bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e )
if (mousePos >= 0) {
if (e->type() == QEvent::MouseButtonRelease)
- qApp->inputMethod()->invokeAction(QInputMethod::Click, mousePos);
+ QGuiApplication::inputMethod()->invokeAction(QInputMethod::Click, mousePos);
return true;
}
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 4cf7e1812e..f259f7e3a4 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -183,7 +183,7 @@ void QWidgetLineControl::commitPreedit()
if (!composeMode())
return;
- qApp->inputMethod()->commit();
+ QGuiApplication::inputMethod()->commit();
if (!composeMode())
return;
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index f181222655..039453f0d5 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -230,7 +230,7 @@ public:
{
#ifndef QT_NO_IM
if (composeMode())
- qApp->inputMethod()->reset();
+ QGuiApplication::inputMethod()->reset();
#endif
internalSetText(txt, -1, false);
}
@@ -328,7 +328,7 @@ public:
Qt::LayoutDirection layoutDirection() const {
if (m_layoutDirection == Qt::LayoutDirectionAuto) {
if (m_text.isEmpty())
- return qApp->inputMethod()->inputDirection();
+ return QGuiApplication::inputMethod()->inputDirection();
return m_text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
}
return m_layoutDirection;
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 39e0aa5b7a..faa63cb400 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -1739,7 +1739,7 @@ void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button
_q_updateCurrentCharFormatAndSelection();
#ifndef QT_NO_IM
if (contextWidget)
- qApp->inputMethod()->update(Qt::ImQueryInput);
+ QGuiApplication::inputMethod()->update(Qt::ImQueryInput);
#endif //QT_NO_IM
} else {
//emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1)));
@@ -1887,7 +1887,7 @@ bool QWidgetTextControlPrivate::sendMouseEventToInputContext(
if (cursorPos >= 0) {
if (eventType == QEvent::MouseButtonRelease)
- qApp->inputMethod()->invokeAction(QInputMethod::Click, cursorPos);
+ QGuiApplication::inputMethod()->invokeAction(QInputMethod::Click, cursorPos);
e->setAccepted(true);
return true;
@@ -2281,7 +2281,7 @@ QMenu *QWidgetTextControl::createStandardContextMenu(const QPointF &pos, QWidget
a->setObjectName(QStringLiteral("select-all"));
}
- if ((d->interactionFlags & Qt::TextEditable) && qApp->styleHints()->useRtlExtensions()) {
+ if ((d->interactionFlags & Qt::TextEditable) && QGuiApplication::styleHints()->useRtlExtensions()) {
menu->addSeparator();
QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, menu);
menu->addMenu(ctrlCharacterMenu);
@@ -2867,7 +2867,7 @@ void QWidgetTextControlPrivate::commitPreedit()
if (!isPreediting())
return;
- qApp->inputMethod()->commit();
+ QGuiApplication::inputMethod()->commit();
if (!isPreediting())
return;