summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2015-01-21 11:14:34 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-01-21 11:14:34 +0100
commit112342b32650f56e289c7dcd181d5897b0b77a78 (patch)
tree76e9a37bcaa70097d009628bb2b116ea782c72cb /src
parent3bbc1bf53bac7648637d92abecadc568acfffb2d (diff)
parentb6191b16d41459ed73cea738dfaf8e25e81ae22b (diff)
Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/zlib.pri2
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtSurface.java2
-rw-r--r--src/corelib/doc/src/external-resources.qdoc11
-rw-r--r--src/corelib/global/global.pri2
-rw-r--r--src/corelib/global/qcompilerdetection.h6
-rw-r--r--src/corelib/global/qendian.h12
-rw-r--r--src/corelib/global/qglobal.cpp78
-rw-r--r--src/corelib/global/qlibraryinfo.cpp7
-rw-r--r--src/corelib/global/qnamespace.qdoc2
-rw-r--r--src/corelib/io/qstandardpaths_mac.mm1
-rw-r--r--src/corelib/io/qwindowspipewriter_p.h6
-rw-r--r--src/corelib/kernel/qobject.cpp10
-rw-r--r--src/corelib/kernel/qvariant.cpp49
-rw-r--r--src/corelib/kernel/qvariant.h6
-rw-r--r--src/corelib/thread/qatomic.cpp86
-rw-r--r--src/corelib/thread/qatomic.h96
-rw-r--r--src/corelib/thread/qthread.cpp4
-rw-r--r--src/corelib/tools/qbytearray.cpp3
-rw-r--r--src/corelib/tools/qbytearraymatcher.cpp2
-rw-r--r--src/corelib/tools/qdatetime.cpp42
-rw-r--r--src/corelib/tools/qfreelist_p.h2
-rw-r--r--src/corelib/tools/qlocale_p.h6
-rw-r--r--src/corelib/tools/qmargins.cpp2
-rw-r--r--src/corelib/tools/qvsnprintf.cpp1
-rw-r--r--src/corelib/xml/qxmlstream.cpp4
-rw-r--r--src/dbus/doc/src/qtdbus-index.qdoc17
-rw-r--r--src/dbus/qdbus_symbols.cpp4
-rw-r--r--src/dbus/qdbus_symbols_p.h5
-rw-r--r--src/dbus/qdbusconnection.cpp2
-rw-r--r--src/dbus/qdbusintegrator.cpp9
-rw-r--r--src/dbus/qdbusserver.cpp3
-rw-r--r--src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp2
-rw-r--r--src/gui/image/qjpeghandler.cpp6
-rw-r--r--src/gui/kernel/qopenglcontext.cpp14
-rw-r--r--src/gui/kernel/qplatformservices.cpp3
-rw-r--r--src/gui/kernel/qplatformservices.h1
-rw-r--r--src/gui/painting/qpaintengineex.cpp4
-rw-r--r--src/gui/painting/qpathclipper_p.h32
-rw-r--r--src/gui/text/qfontmetrics.cpp8
-rw-r--r--src/gui/text/qtextformat.cpp2
-rw-r--r--src/network/access/qnetworkreply.cpp2
-rw-r--r--src/network/kernel/qhostaddress.cpp36
-rw-r--r--src/network/kernel/qnetworkproxy_mac.cpp15
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp3
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp3
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp5
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm8
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp52
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp556
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.h88
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp2
-rw-r--r--src/plugins/platforms/android/qandroidplatformopenglcontext.cpp6
-rw-r--r--src/plugins/platforms/android/qandroidplatformopenglwindow.cpp20
-rw-r--r--src/plugins/platforms/android/qandroidplatformopenglwindow.h4
-rw-r--r--src/plugins/platforms/android/qandroidplatformscreen.cpp2
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h4
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm6
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm19
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm17
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.h1
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm11
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.h14
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.mm117
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm19
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp17
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h1
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp36
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h3
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp44
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h5
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp41
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbxsettings.cpp8
-rw-r--r--src/printsupport/kernel/qprint_p.h2
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp2
-rw-r--r--src/printsupport/kernel/qprinter.cpp5
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp12
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp43
-rw-r--r--src/sql/kernel/qsqlquery.cpp1
-rw-r--r--src/testlib/qbenchmark_p.h1
-rw-r--r--src/testlib/qtest.h3
-rw-r--r--src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc2
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp56
-rw-r--r--src/widgets/dialogs/qcolordialog.h1
-rw-r--r--src/widgets/dialogs/qcolordialog_p.h14
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp4
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/layout.qdoc2
-rw-r--r--src/widgets/kernel/qwidget.cpp11
-rw-r--r--src/widgets/styles/qfusionstyle.cpp3
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp12
-rw-r--r--src/widgets/widgets/qdockwidget.cpp5
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp3
96 files changed, 1033 insertions, 890 deletions
diff --git a/src/3rdparty/zlib.pri b/src/3rdparty/zlib.pri
index a7073d5c3a..868d1c71bb 100644
--- a/src/3rdparty/zlib.pri
+++ b/src/3rdparty/zlib.pri
@@ -1,5 +1,5 @@
wince*: DEFINES += NO_ERRNO_H
-INCLUDEPATH += $$PWD/zlib
+INCLUDEPATH = $$PWD/zlib $$INCLUDEPATH
SOURCES+= \
$$PWD/zlib/adler32.c \
$$PWD/zlib/compress.c \
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java b/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java
index 34fc31b222..516671739e 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java
@@ -45,7 +45,6 @@ package org.qtproject.qt5.android;
import android.app.Activity;
import android.content.Context;
import android.graphics.PixelFormat;
-import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
@@ -87,7 +86,6 @@ public class QtSurface extends SurfaceView implements SurfaceHolder.Callback
@Override
public void surfaceCreated(SurfaceHolder holder)
{
- QtNative.setSurface(getId(), holder.getSurface(), getWidth(), getHeight());
}
@Override
diff --git a/src/corelib/doc/src/external-resources.qdoc b/src/corelib/doc/src/external-resources.qdoc
index a4f1b8723a..03af1d81bf 100644
--- a/src/corelib/doc/src/external-resources.qdoc
+++ b/src/corelib/doc/src/external-resources.qdoc
@@ -55,3 +55,14 @@
\externalpage http://www.iana.org/assignments/character-sets/character-sets.xml
\title IANA character-sets encoding file
*/
+
+/*!
+ \externalpage http://doc-snapshot.qt-project.org/qt5-5.4/qtdesigner-manual.html
+ \title Using a Designer UI File in Your Application
+*/
+
+/*!
+ \externalpage http://doc-snapshot.qt-project.org/qt5-5.4/designer-widget-mode.html#the-property-editor
+ \title Qt Designer's Widget Editing Mode#The Property Editor
+*/
+*/
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index 86621364ec..0b1374a3bb 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -35,6 +35,8 @@ INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global
# Only used on platforms with CONFIG += precompile_header
PRECOMPILED_HEADER = global/qt_pch.h
+# qlogging.cpp uses backtrace(3), which is in a separate library on the BSDs.
+
if(linux*|hurd*):!cross_compile:!static:!*-armcc* {
QMAKE_LFLAGS += -Wl,-e,qt_core_boilerplate
prog=$$quote(if (/program interpreter: (.*)]/) { print $1; })
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 77f6c48857..2881a0fcbd 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -142,6 +142,10 @@
# if defined(__INTEL_COMPILER)
/* Intel C++ also masquerades as GCC */
# define Q_CC_INTEL (__INTEL_COMPILER)
+# ifdef __clang__
+/* Intel C++ masquerades as Clang masquerading as GCC */
+# define Q_CC_CLANG 305
+# endif
# define Q_ASSUME_IMPL(expr) __assume(expr)
# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
# if __INTEL_COMPILER >= 1300 && !defined(__APPLE__)
@@ -537,9 +541,11 @@
# define Q_COMPILER_RANGE_FOR
# define Q_COMPILER_RAW_STRINGS
# define Q_COMPILER_REF_QUALIFIERS
+# define Q_COMPILER_UNICODE_STRINGS
# define Q_COMPILER_UNRESTRICTED_UNIONS
# endif
# if __INTEL_COMPILER >= 1500
+# define Q_COMPILER_CONSTEXPR
# define Q_COMPILER_ALIGNAS
# define Q_COMPILER_ALIGNOF
# define Q_COMPILER_INHERITING_CONSTRUCTORS
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h
index 1d72ba0fae..957ba2ad63 100644
--- a/src/corelib/global/qendian.h
+++ b/src/corelib/global/qendian.h
@@ -87,9 +87,15 @@ template <typename T> inline T qFromUnaligned(const uchar *src)
*/
template <typename T> T qbswap(T source);
+#ifdef __has_builtin
+# define QT_HAS_BUILTIN(x) __has_builtin(x)
+#else
+# define QT_HAS_BUILTIN(x) 0
+#endif
+
// GCC 4.3 implemented all the intrinsics, but the 16-bit one only got implemented in 4.8;
// Clang 2.6 implemented the 32- and 64-bit but waited until 3.2 to implement the 16-bit one
-#if (defined(Q_CC_GNU) && Q_CC_GNU >= 403) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 206)
+#if (defined(Q_CC_GNU) && Q_CC_GNU >= 403) || QT_HAS_BUILTIN(__builtin_bswap32)
template <> inline quint64 qbswap<quint64>(quint64 source)
{
return __builtin_bswap64(source);
@@ -130,7 +136,7 @@ template <> inline quint32 qbswap<quint32>(quint32 source)
| ((source & 0xff000000) >> 24);
}
#endif // GCC & Clang intrinsics
-#if (defined(Q_CC_GNU) && Q_CC_GNU >= 408) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 302)
+#if (defined(Q_CC_GNU) && Q_CC_GNU >= 408) || QT_HAS_BUILTIN(__builtin_bswap16)
template <> inline quint16 qbswap<quint16>(quint16 source)
{
return __builtin_bswap16(source);
@@ -148,6 +154,8 @@ template <> inline quint16 qbswap<quint16>(quint16 source)
}
#endif // GCC & Clang intrinsics
+#undef QT_HAS_BUILTIN
+
// signed specializations
template <> inline qint64 qbswap<qint64>(qint64 source)
{
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 4895bf6dd9..0a9e2f97db 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -41,6 +41,8 @@
#include "qdatetime.h"
#include <private/qlocale_tools_p.h>
+#include <private/qsystemlibrary_p.h>
+
#ifndef QT_NO_QOBJECT
#include <private/qthread_p.h>
#endif
@@ -1876,6 +1878,70 @@ QT_BEGIN_INCLUDE_NAMESPACE
QT_END_INCLUDE_NAMESPACE
#ifndef Q_OS_WINRT
+
+# ifndef Q_OS_WINCE
+
+// Determine Windows versions >= 8 by querying the version of kernel32.dll.
+static inline bool determineWinOsVersionPost8(OSVERSIONINFO *result)
+{
+ typedef WORD (WINAPI* PtrGetFileVersionInfoSizeW)(LPCWSTR, LPDWORD);
+ typedef BOOL (WINAPI* PtrVerQueryValueW)(LPCVOID, LPCWSTR, LPVOID, PUINT);
+ typedef BOOL (WINAPI* PtrGetFileVersionInfoW)(LPCWSTR, DWORD, DWORD, LPVOID);
+
+ QSystemLibrary versionLib(QStringLiteral("version"));
+ if (!versionLib.load())
+ return false;
+ PtrGetFileVersionInfoSizeW getFileVersionInfoSizeW = (PtrGetFileVersionInfoSizeW)versionLib.resolve("GetFileVersionInfoSizeW");
+ PtrVerQueryValueW verQueryValueW = (PtrVerQueryValueW)versionLib.resolve("VerQueryValueW");
+ PtrGetFileVersionInfoW getFileVersionInfoW = (PtrGetFileVersionInfoW)versionLib.resolve("GetFileVersionInfoW");
+ if (!getFileVersionInfoSizeW || !verQueryValueW || !getFileVersionInfoW)
+ return false;
+
+ const wchar_t kernel32Dll[] = L"kernel32.dll";
+ DWORD handle;
+ const DWORD size = getFileVersionInfoSizeW(kernel32Dll, &handle);
+ if (!size)
+ return false;
+ QScopedArrayPointer<BYTE> versionInfo(new BYTE[size]);
+ if (!getFileVersionInfoW(kernel32Dll, handle, size, versionInfo.data()))
+ return false;
+ UINT uLen;
+ VS_FIXEDFILEINFO *fileInfo = Q_NULLPTR;
+ if (!verQueryValueW(versionInfo.data(), L"\\", (LPVOID *)&fileInfo, &uLen))
+ return false;
+ const DWORD fileVersionMS = fileInfo->dwFileVersionMS;
+ const DWORD fileVersionLS = fileInfo->dwFileVersionLS;
+ result->dwMajorVersion = HIWORD(fileVersionMS);
+ result->dwMinorVersion = LOWORD(fileVersionMS);
+ result->dwBuildNumber = HIWORD(fileVersionLS);
+ return true;
+}
+
+// Fallback for determining Windows versions >= 8 by looping using the
+// version check macros. Note that it will return build number=0 to avoid
+// inefficient looping.
+static inline void determineWinOsVersionFallbackPost8(OSVERSIONINFO *result)
+{
+ result->dwBuildNumber = 0;
+ DWORDLONG conditionMask = 0;
+ VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
+ VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL);
+ OSVERSIONINFOEX checkVersion = { sizeof(OSVERSIONINFOEX), result->dwMajorVersion, 0,
+ result->dwBuildNumber, result->dwPlatformId, {'\0'}, 0, 0, 0, 0, 0 };
+ for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMajorVersion)
+ result->dwMajorVersion = checkVersion.dwMajorVersion;
+ conditionMask = 0;
+ checkVersion.dwMajorVersion = result->dwMajorVersion;
+ checkVersion.dwMinorVersion = 0;
+ VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_EQUAL);
+ VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
+ VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL);
+ for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMinorVersion)
+ result->dwMinorVersion = checkVersion.dwMinorVersion;
+}
+
+# endif // !Q_OS_WINCE
+
static inline OSVERSIONINFO winOsVersion()
{
OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0, {'\0'}};
@@ -1891,16 +1957,8 @@ static inline OSVERSIONINFO winOsVersion()
# endif
# ifndef Q_OS_WINCE
if (result.dwMajorVersion == 6 && result.dwMinorVersion == 2) {
- // This could be Windows 8.1 or higher. Note that as of Windows 9,
- // the major version needs to be checked as well.
- DWORDLONG conditionMask = 0;
- VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
- VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
- VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL);
- OSVERSIONINFOEX checkVersion = { sizeof(OSVERSIONINFOEX), result.dwMajorVersion, result.dwMinorVersion,
- result.dwBuildNumber, result.dwPlatformId, {'\0'}, 0, 0, 0, 0, 0 };
- for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMinorVersion)
- result.dwMinorVersion = checkVersion.dwMinorVersion;
+ if (!determineWinOsVersionPost8(&result))
+ determineWinOsVersionFallbackPost8(&result);
}
# endif // !Q_OS_WINCE
return result;
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index c60ca7e9b0..575da452b9 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -116,10 +116,11 @@ QLibrarySettings::QLibrarySettings()
QStringList children = settings->childGroups();
#ifdef QT_BOOTSTRAPPED
haveEffectiveSourcePaths = children.contains(QLatin1String("EffectiveSourcePaths"));
- haveEffectivePaths = haveEffectiveSourcePaths || children.contains(QLatin1String("EffectivePaths"));
#else
- haveEffectivePaths = children.contains(QLatin1String("EffectivePaths"));
+ // EffectiveSourcePaths is for the Qt build only, so needs no backwards compat trickery.
+ bool haveEffectiveSourcePaths = false;
#endif
+ haveEffectivePaths = haveEffectiveSourcePaths || children.contains(QLatin1String("EffectivePaths"));
// Backwards compat: an existing but empty file is claimed to contain the Paths section.
havePaths = (!haveEffectivePaths && !children.contains(QLatin1String(platformsSection)))
|| children.contains(QLatin1String("Paths"));
@@ -128,9 +129,7 @@ QLibrarySettings::QLibrarySettings()
settings.reset(0);
#else
} else {
-#ifdef QT_BOOTSTRAPPED
haveEffectiveSourcePaths = false;
-#endif
haveEffectivePaths = false;
havePaths = false;
#endif
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 4b582642f3..c8aa53aced 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -592,7 +592,7 @@
string, "ddd MMM d yyyy". See QDate::toString() for more information.
\value ISODate \l{ISO 8601} extended format: either \c{YYYY-MM-DD} for dates or
- \c{YYYY-MM-DDTHH:MM:SS}, \c{YYYY-MM-DDTHH:MM:SSTZD} (e.g., 1997-07-16T19:20:30+01:00)
+ \c{YYYY-MM-DDTHH:mm:ss}, \c{YYYY-MM-DDTHH:mm:ssTZD} (e.g., 1997-07-16T19:20:30+01:00)
for combined dates and times.
\value SystemLocaleShortDate The \l{QLocale::ShortFormat}{short format} used
diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm
index 4cd71d7d52..9d5d6de6ad 100644
--- a/src/corelib/io/qstandardpaths_mac.mm
+++ b/src/corelib/io/qstandardpaths_mac.mm
@@ -173,6 +173,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
case TempLocation:
return QDir::tempPath();
case GenericDataLocation:
+ case AppDataLocation:
case AppLocalDataLocation:
case GenericCacheLocation:
case CacheLocation:
diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h
index 47b7744e81..6035993500 100644
--- a/src/corelib/io/qwindowspipewriter_p.h
+++ b/src/corelib/io/qwindowspipewriter_p.h
@@ -45,7 +45,7 @@
// We mean it.
//
-#include <qdatetime.h>
+#include <qelapsedtimer.h>
#include <qthread.h>
#include <qmutex.h>
#include <qwaitcondition.h>
@@ -83,7 +83,7 @@ public:
{
if (totalTimeOut == -1)
return SLEEPMAX;
- return qMax(totalTimeOut - timer.elapsed(), 0);
+ return qMax(int(totalTimeOut - timer.elapsed()), 0);
}
bool hasTimedOut() const
@@ -99,7 +99,7 @@ public:
}
private:
- QTime timer;
+ QElapsedTimer timer;
int totalTimeOut;
int nextSleep;
};
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 2f9ef9ca4a..be6441933f 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -2742,9 +2742,9 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign
You can check if the QMetaObject::Connection is valid by casting it to a bool.
This function works in the same way as
- connect(const QObject *sender, const char *signal,
+ \c {connect(const QObject *sender, const char *signal,
const QObject *receiver, const char *method,
- Qt::ConnectionType type)
+ Qt::ConnectionType type)}
but it uses QMetaMethod to specify signal and method.
\sa connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
@@ -2997,7 +2997,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
otherwise returns \c false.
This function provides the same possibilities like
- disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
+ \c {disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) }
but uses QMetaMethod to represent the signal and the method to be disconnected.
Additionally this function returnsfalse and no signals and slots disconnected
@@ -4113,7 +4113,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
This macro associates extra information to the class, which is available
using QObject::metaObject(). Qt makes only limited use of this feature, in
- the \l{Active Qt}, \l{Qt D-Bus} and \l{Qt QML} modules.
+ the \l{Active Qt}, \l{Qt D-Bus} and \l{Qt QML module}{Qt QML}.
The extra information takes the form of a \a Name string and a \a Value
literal string.
@@ -4125,7 +4125,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
\sa QMetaObject::classInfo()
\sa QAxFactory
\sa {Using Qt D-Bus Adaptors}
- \sa {Extending QML - Default Property Example}
+ \sa {Extending QML}
*/
/*!
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 3f958138b3..f7b8fe5ca5 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -4001,6 +4001,13 @@ void QAssociativeIterable::const_iterator::end()
m_impl.end();
}
+void find(QAssociativeIterable::const_iterator &it, const QVariant &key)
+{
+ Q_ASSERT(key.userType() == it.m_impl._metaType_id_key);
+ const QtMetaTypePrivate::VariantData dkey(key.userType(), key.constData(), 0 /*key.flags()*/);
+ it.m_impl.find(dkey);
+}
+
/*!
Returns a QAssociativeIterable::const_iterator for the beginning of the container. This
can be used in stl-style iteration.
@@ -4028,27 +4035,37 @@ QAssociativeIterable::const_iterator QAssociativeIterable::end() const
}
/*!
+ \internal
+
+ Returns a QAssociativeIterable::const_iterator for the given key \a key
+ in the container, if the types are convertible.
+
+ If the key is not found, returns end().
+
+ This can be used in stl-style iteration.
+
+ \sa begin(), end(), value()
+*/
+QAssociativeIterable::const_iterator find(const QAssociativeIterable &iterable, const QVariant &key)
+{
+ QAssociativeIterable::const_iterator it(iterable, new QAtomicInt(0));
+ QVariant key_ = key;
+ if (key_.canConvert(iterable.m_impl._metaType_id_key) && key_.convert(iterable.m_impl._metaType_id_key))
+ find(it, key_);
+ else
+ it.end();
+ return it;
+}
+
+/*!
Returns the value for the given \a key in the container, if the types are convertible.
*/
QVariant QAssociativeIterable::value(const QVariant &key) const
{
- QVariant key_ = key;
- if (!key_.canConvert(m_impl._metaType_id_key))
- return QVariant();
- if (!key_.convert(m_impl._metaType_id_key))
+ const const_iterator it = find(*this, key);
+ if (it == end())
return QVariant();
- const QtMetaTypePrivate::VariantData dkey(key_.userType(), key_.constData(), 0 /*key.flags()*/);
- QtMetaTypePrivate::QAssociativeIterableImpl impl = m_impl;
- impl.find(dkey);
- QtMetaTypePrivate::QAssociativeIterableImpl endIt = m_impl;
- endIt.end();
- if (impl.equal(endIt))
- return QVariant();
- const QtMetaTypePrivate::VariantData d = impl.getCurrentValue();
- QVariant v(d.metaTypeId, d.data, d.flags);
- if (d.metaTypeId == qMetaTypeId<QVariant>())
- return *reinterpret_cast<const QVariant*>(d.data);
- return v;
+ return *it;
}
/*!
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 7bee756fa5..c33ac834c0 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -633,6 +633,9 @@ public:
void begin();
void end();
+ // ### Qt 5.5: make find() (1st one) a member function
+ friend void find(const_iterator &it, const QVariant &key);
+ friend const_iterator find(const QAssociativeIterable &iterable, const QVariant &key);
public:
~const_iterator();
const_iterator(const const_iterator &other);
@@ -662,6 +665,9 @@ public:
const_iterator begin() const;
const_iterator end() const;
+private: // ### Qt 5.5: make it a public find() member function:
+ friend const_iterator find(const QAssociativeIterable &iterable, const QVariant &key);
+public:
QVariant value(const QVariant &key) const;
diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp
index 2ac32d5d6b..0f4c8efb03 100644
--- a/src/corelib/thread/qatomic.cpp
+++ b/src/corelib/thread/qatomic.cpp
@@ -250,7 +250,7 @@
/*!
- \fn int QAtomicInteger::load() const
+ \fn T QAtomicInteger::load() const
Atomically loads the value of this QAtomicInteger using relaxed memory
ordering. The value is not modified in any way, but note that there's no
@@ -260,7 +260,7 @@
*/
/*!
- \fn int QAtomicInteger::loadAcquire() const
+ \fn T QAtomicInteger::loadAcquire() const
Atomically loads the value of this QAtomicInteger using the "Acquire" memory
ordering. The value is not modified in any way, but note that there's no
@@ -270,7 +270,7 @@
*/
/*!
- \fn void QAtomicInteger::store(int newValue)
+ \fn void QAtomicInteger::store(T newValue)
Atomically stores the \a newValue value into this atomic type, using
relaxed memory ordering.
@@ -279,7 +279,7 @@
*/
/*!
- \fn void QAtomicInteger::storeRelease(int newValue)
+ \fn void QAtomicInteger::storeRelease(T newValue)
Atomically stores the \a newValue value into this atomic type, using
the "Release" memory ordering.
@@ -288,7 +288,7 @@
*/
/*!
- \fn QAtomicInteger::operator int() const
+ \fn QAtomicInteger::operator T() const
\since 5.3
Atomically loads the value of this QAtomicInteger using a sequentially
@@ -300,7 +300,7 @@
*/
/*!
- \fn QAtomicInteger &QAtomicInteger::operator=(int newValue)
+ \fn QAtomicInteger &QAtomicInteger::operator=(T newValue)
\since 5.3
Atomically stores the \a newValue value into this atomic type using a
@@ -335,7 +335,7 @@
*/
/*!
- \fn int QAtomicInteger::operator++()
+ \fn T QAtomicInteger::operator++()
\since 5.3
Atomically pre-increments the value of this QAtomicInteger. Returns the new
@@ -348,7 +348,7 @@
*/
/*!
- \fn int QAtomicInteger::operator++(int)
+ \fn T QAtomicInteger::operator++(int)
\since 5.3
Atomically post-increments the value of this QAtomicInteger. Returns the old
@@ -373,7 +373,7 @@
*/
/*!
- \fn int QAtomicInteger::operator--()
+ \fn T QAtomicInteger::operator--()
\since 5.3
Atomically pre-decrements the value of this QAtomicInteger. Returns the new
@@ -386,7 +386,7 @@
*/
/*!
- \fn int QAtomicInteger::operator--(int)
+ \fn T QAtomicInteger::operator--(int)
\since 5.3
Atomically post-decrements the value of this QAtomicInteger. Returns the old
@@ -409,7 +409,7 @@
Returns \c true if atomic test-and-set is wait-free, false otherwise.
*/
-/*! \fn bool QAtomicInteger::testAndSetRelaxed(int expectedValue, int newValue)
+/*! \fn bool QAtomicInteger::testAndSetRelaxed(T expectedValue, T newValue)
Atomic test-and-set.
@@ -423,7 +423,7 @@
processor to freely reorder memory accesses.
*/
-/*! \fn bool QAtomicInteger::testAndSetAcquire(int expectedValue, int newValue)
+/*! \fn bool QAtomicInteger::testAndSetAcquire(T expectedValue, T newValue)
Atomic test-and-set.
@@ -438,7 +438,7 @@
be re-ordered before the atomic operation.
*/
-/*! \fn bool QAtomicInteger::testAndSetRelease(int expectedValue, int newValue)
+/*! \fn bool QAtomicInteger::testAndSetRelease(T expectedValue, T newValue)
Atomic test-and-set.
@@ -453,7 +453,7 @@
re-ordered after the atomic operation.
*/
-/*! \fn bool QAtomicInteger::testAndSetOrdered(int expectedValue, int newValue)
+/*! \fn bool QAtomicInteger::testAndSetOrdered(T expectedValue, T newValue)
Atomic test-and-set.
@@ -480,7 +480,7 @@
otherwise.
*/
-/*! \fn int QAtomicInteger::fetchAndStoreRelaxed(int newValue)
+/*! \fn T QAtomicInteger::fetchAndStoreRelaxed(T newValue)
Atomic fetch-and-store.
@@ -492,7 +492,7 @@
processor to freely reorder memory accesses.
*/
-/*! \fn int QAtomicInteger::fetchAndStoreAcquire(int newValue)
+/*! \fn T QAtomicInteger::fetchAndStoreAcquire(T newValue)
Atomic fetch-and-store.
@@ -505,7 +505,7 @@
be re-ordered before the atomic operation.
*/
-/*! \fn int QAtomicInteger::fetchAndStoreRelease(int newValue)
+/*! \fn T QAtomicInteger::fetchAndStoreRelease(T newValue)
Atomic fetch-and-store.
@@ -518,7 +518,7 @@
re-ordered after the atomic operation.
*/
-/*! \fn int QAtomicInteger::fetchAndStoreOrdered(int newValue)
+/*! \fn T QAtomicInteger::fetchAndStoreOrdered(T newValue)
Atomic fetch-and-store.
@@ -543,7 +543,7 @@
otherwise.
*/
-/*! \fn int QAtomicInteger::fetchAndAddRelaxed(int valueToAdd)
+/*! \fn T QAtomicInteger::fetchAndAddRelaxed(T valueToAdd)
Atomic fetch-and-add.
@@ -557,7 +557,7 @@
\sa operator+=(), fetchAndSubRelaxed()
*/
-/*! \fn int QAtomicInteger::fetchAndAddAcquire(int valueToAdd)
+/*! \fn T QAtomicInteger::fetchAndAddAcquire(T valueToAdd)
Atomic fetch-and-add.
@@ -572,7 +572,7 @@
\sa operator+=(), fetchAndSubAcquire()
*/
-/*! \fn int QAtomicInteger::fetchAndAddRelease(int valueToAdd)
+/*! \fn T QAtomicInteger::fetchAndAddRelease(T valueToAdd)
Atomic fetch-and-add.
@@ -587,7 +587,7 @@
\sa operator+=(), fetchAndSubRelease()
*/
-/*! \fn int QAtomicInteger::fetchAndAddOrdered(int valueToAdd)
+/*! \fn T QAtomicInteger::fetchAndAddOrdered(T valueToAdd)
Atomic fetch-and-add.
@@ -602,7 +602,7 @@
\sa operator+=(), fetchAndSubOrdered()
*/
-/*! \fn int QAtomicInteger::operator+=(int valueToAdd)
+/*! \fn T QAtomicInteger::operator+=(T valueToAdd)
\since 5.3
Atomic add-and-fetch.
@@ -616,7 +616,7 @@
\sa fetchAndAddOrdered(), operator-=()
*/
-/*! \fn int QAtomicInteger::fetchAndSubRelaxed(int valueToSub)
+/*! \fn T QAtomicInteger::fetchAndSubRelaxed(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -631,7 +631,7 @@
\sa operator-=(), fetchAndAddRelaxed()
*/
-/*! \fn int QAtomicInteger::fetchAndSubAcquire(int valueToSub)
+/*! \fn T QAtomicInteger::fetchAndSubAcquire(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -647,7 +647,7 @@
\sa operator-=(), fetchAndAddAcquire()
*/
-/*! \fn int QAtomicInteger::fetchAndSubRelease(int valueToSub)
+/*! \fn T QAtomicInteger::fetchAndSubRelease(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -663,7 +663,7 @@
\sa operator-=(), fetchAndAddRelease()
*/
-/*! \fn int QAtomicInteger::fetchAndSubOrdered(int valueToSub)
+/*! \fn T QAtomicInteger::fetchAndSubOrdered(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -679,7 +679,7 @@
\sa operator-=(), fetchAndAddOrdered()
*/
-/*! \fn int QAtomicInteger::operator-=(int valueToSub)
+/*! \fn T QAtomicInteger::operator-=(T valueToSub)
\since 5.3
Atomic sub-and-fetch.
@@ -693,7 +693,7 @@
\sa fetchAndSubOrdered(), operator+=()
*/
-/*! \fn int QAtomicInteger::fetchAndOrRelaxed(int valueToOr)
+/*! \fn T QAtomicInteger::fetchAndOrRelaxed(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -708,7 +708,7 @@
\sa operator|=()
*/
-/*! \fn int QAtomicInteger::fetchAndOrAcquire(int valueToOr)
+/*! \fn T QAtomicInteger::fetchAndOrAcquire(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -724,7 +724,7 @@
\sa operator|=()
*/
-/*! \fn int QAtomicInteger::fetchAndOrRelease(int valueToOr)
+/*! \fn T QAtomicInteger::fetchAndOrRelease(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -740,7 +740,7 @@
\sa operator|=()
*/
-/*! \fn int QAtomicInteger::fetchAndOrOrdered(int valueToOr)
+/*! \fn T QAtomicInteger::fetchAndOrOrdered(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -756,7 +756,7 @@
\sa operator|=()
*/
-/*! \fn int QAtomicInteger::operator|=(int valueToOr)
+/*! \fn T QAtomicInteger::operator|=(T valueToOr)
\since 5.3
Atomic or-and-fetch.
@@ -770,7 +770,7 @@
\sa fetchAndOrOrdered()
*/
-/*! \fn int QAtomicInteger::fetchAndXorRelaxed(int valueToXor)
+/*! \fn T QAtomicInteger::fetchAndXorRelaxed(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -785,7 +785,7 @@
\sa operator^=()
*/
-/*! \fn int QAtomicInteger::fetchAndXorAcquire(int valueToXor)
+/*! \fn T QAtomicInteger::fetchAndXorAcquire(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -801,7 +801,7 @@
\sa operator^=()
*/
-/*! \fn int QAtomicInteger::fetchAndXorRelease(int valueToXor)
+/*! \fn T QAtomicInteger::fetchAndXorRelease(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -817,7 +817,7 @@
\sa operator^=()
*/
-/*! \fn int QAtomicInteger::fetchAndXorOrdered(int valueToXor)
+/*! \fn T QAtomicInteger::fetchAndXorOrdered(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -833,7 +833,7 @@
\sa operator^=()
*/
-/*! \fn int QAtomicInteger::operator^=(int valueToXor)
+/*! \fn T QAtomicInteger::operator^=(T valueToXor)
\since 5.3
Atomic xor-and-fetch.
@@ -847,7 +847,7 @@
\sa fetchAndXorOrdered()
*/
-/*! \fn int QAtomicInteger::fetchAndAndRelaxed(int valueToAnd)
+/*! \fn T QAtomicInteger::fetchAndAndRelaxed(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -862,7 +862,7 @@
\sa operator&=()
*/
-/*! \fn int QAtomicInteger::fetchAndAndAcquire(int valueToAnd)
+/*! \fn T QAtomicInteger::fetchAndAndAcquire(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -878,7 +878,7 @@
\sa operator&=()
*/
-/*! \fn int QAtomicInteger::fetchAndAndRelease(int valueToAnd)
+/*! \fn T QAtomicInteger::fetchAndAndRelease(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -894,7 +894,7 @@
\sa operator&=()
*/
-/*! \fn int QAtomicInteger::fetchAndAndOrdered(int valueToAnd)
+/*! \fn T QAtomicInteger::fetchAndAndOrdered(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -910,7 +910,7 @@
\sa operator&=()
*/
-/*! \fn int QAtomicInteger::operator&=(int valueToAnd)
+/*! \fn T QAtomicInteger::operator&=(T valueToAnd)
\since 5.3
Atomic add-and-fetch.
diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h
index a665746db4..c273973472 100644
--- a/src/corelib/thread/qatomic.h
+++ b/src/corelib/thread/qatomic.h
@@ -73,13 +73,13 @@ public:
}
#ifdef Q_QDOC
- int load() const;
- int loadAcquire() const;
- void store(int newValue);
- void storeRelease(int newValue);
+ T load() const;
+ T loadAcquire() const;
+ void store(T newValue);
+ void storeRelease(T newValue);
- operator int() const;
- QAtomicInteger &operator=(int);
+ operator T() const;
+ QAtomicInteger &operator=(T);
static Q_DECL_CONSTEXPR bool isReferenceCountingNative();
static Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree();
@@ -90,56 +90,56 @@ public:
static Q_DECL_CONSTEXPR bool isTestAndSetNative();
static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree();
- bool testAndSetRelaxed(int expectedValue, int newValue);
- bool testAndSetAcquire(int expectedValue, int newValue);
- bool testAndSetRelease(int expectedValue, int newValue);
- bool testAndSetOrdered(int expectedValue, int newValue);
+ bool testAndSetRelaxed(T expectedValue, T newValue);
+ bool testAndSetAcquire(T expectedValue, T newValue);
+ bool testAndSetRelease(T expectedValue, T newValue);
+ bool testAndSetOrdered(T expectedValue, T newValue);
static Q_DECL_CONSTEXPR bool isFetchAndStoreNative();
static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree();
- int fetchAndStoreRelaxed(int newValue);
- int fetchAndStoreAcquire(int newValue);
- int fetchAndStoreRelease(int newValue);
- int fetchAndStoreOrdered(int newValue);
+ T fetchAndStoreRelaxed(T newValue);
+ T fetchAndStoreAcquire(T newValue);
+ T fetchAndStoreRelease(T newValue);
+ T fetchAndStoreOrdered(T newValue);
static Q_DECL_CONSTEXPR bool isFetchAndAddNative();
static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree();
- int fetchAndAddRelaxed(int valueToAdd);
- int fetchAndAddAcquire(int valueToAdd);
- int fetchAndAddRelease(int valueToAdd);
- int fetchAndAddOrdered(int valueToAdd);
-
- int fetchAndSubRelaxed(int valueToSub);
- int fetchAndSubAcquire(int valueToSub);
- int fetchAndSubRelease(int valueToSub);
- int fetchAndSubOrdered(int valueToSub);
-
- int fetchAndOrRelaxed(int valueToOr);
- int fetchAndOrAcquire(int valueToOr);
- int fetchAndOrRelease(int valueToOr);
- int fetchAndOrOrdered(int valueToOr);
-
- int fetchAndAndRelaxed(int valueToAnd);
- int fetchAndAndAcquire(int valueToAnd);
- int fetchAndAndRelease(int valueToAnd);
- int fetchAndAndOrdered(int valueToAnd);
-
- int fetchAndXorRelaxed(int valueToXor);
- int fetchAndXorAcquire(int valueToXor);
- int fetchAndXorRelease(int valueToXor);
- int fetchAndXorOrdered(int valueToXor);
-
- int operator++();
- int operator++(int);
- int operator--();
- int operator--(int);
- int operator+=(int value);
- int operator-=(int value);
- int operator|=(int value);
- int operator&=(int value);
- int operator^=(int value);
+ T fetchAndAddRelaxed(T valueToAdd);
+ T fetchAndAddAcquire(T valueToAdd);
+ T fetchAndAddRelease(T valueToAdd);
+ T fetchAndAddOrdered(T valueToAdd);
+
+ T fetchAndSubRelaxed(T valueToSub);
+ T fetchAndSubAcquire(T valueToSub);
+ T fetchAndSubRelease(T valueToSub);
+ T fetchAndSubOrdered(T valueToSub);
+
+ T fetchAndOrRelaxed(T valueToOr);
+ T fetchAndOrAcquire(T valueToOr);
+ T fetchAndOrRelease(T valueToOr);
+ T fetchAndOrOrdered(T valueToOr);
+
+ T fetchAndAndRelaxed(T valueToAnd);
+ T fetchAndAndAcquire(T valueToAnd);
+ T fetchAndAndRelease(T valueToAnd);
+ T fetchAndAndOrdered(T valueToAnd);
+
+ T fetchAndXorRelaxed(T valueToXor);
+ T fetchAndXorAcquire(T valueToXor);
+ T fetchAndXorRelease(T valueToXor);
+ T fetchAndXorOrdered(T valueToXor);
+
+ T operator++();
+ T operator++(int);
+ T operator--();
+ T operator--(int);
+ T operator+=(T value);
+ T operator-=(T value);
+ T operator|=(T value);
+ T operator&=(T value);
+ T operator^=(T value);
#endif
};
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 3caad7c4b2..933fd06afa 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -178,7 +178,7 @@ QThreadPrivate::~QThreadPrivate()
event loop by calling exec() and runs a Qt event loop inside the thread.
You can use worker objects by moving them to the thread using
- QObject::moveToThread.
+ QObject::moveToThread().
\snippet code/src_corelib_thread_qthread.cpp worker
@@ -256,7 +256,7 @@ QThreadPrivate::~QThreadPrivate()
\l{Mandelbrot Example}, as that is the name of the QThread subclass).
Note that this is currently not available with release builds on Windows.
- \sa {Thread Support in Qt}, QThreadStorage, {Synchronizing Threads}
+ \sa {Thread Support in Qt}, QThreadStorage, {Synchronizing Threads},
{Mandelbrot Example}, {Semaphores Example}, {Wait Conditions Example}
*/
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index a267dc6f7b..a683a36f61 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -45,6 +45,7 @@
#include <qmath.h>
#ifndef QT_NO_COMPRESS
+#include <zconf.h>
#include <zlib.h>
#endif
#include <ctype.h>
@@ -4017,7 +4018,7 @@ QByteArray QByteArray::fromRawData(const char *data, int size)
copies of it exist that have not been modified.
This function can be used instead of fromRawData() to re-use
- existings QByteArray objects to save memory re-allocations.
+ existing QByteArray objects to save memory re-allocations.
\sa fromRawData(), data(), constData()
*/
diff --git a/src/corelib/tools/qbytearraymatcher.cpp b/src/corelib/tools/qbytearraymatcher.cpp
index f14d941c27..82f012be66 100644
--- a/src/corelib/tools/qbytearraymatcher.cpp
+++ b/src/corelib/tools/qbytearraymatcher.cpp
@@ -256,7 +256,7 @@ static int qFindByteArrayBoyerMoore(
#define REHASH(a) \
if (sl_minus_1 < sizeof(uint) * CHAR_BIT) \
- hashHaystack -= (a) << sl_minus_1; \
+ hashHaystack -= uint(a) << sl_minus_1; \
hashHaystack <<= 1
/*!
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 3326044b43..b95ccc0874 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -182,7 +182,7 @@ static void rfcDateImpl(const QString &s, QDate *dd = 0, QTime *dt = 0, int *utc
int minOffset = 0;
bool positiveOffset = false;
- // Matches "Wdy, DD Mon YYYY HH:MM:SS ±hhmm" (Wdy, being optional)
+ // Matches "Wdy, DD Mon YYYY HH:mm:ss ±hhmm" (Wdy, being optional)
QRegExp rex(QStringLiteral("^(?:[A-Z][a-z]+,)?[ \\t]*(\\d{1,2})[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d)(?::(\\d\\d))?)?[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?"));
if (s.indexOf(rex) == 0) {
if (dd) {
@@ -203,7 +203,7 @@ static void rfcDateImpl(const QString &s, QDate *dd = 0, QTime *dt = 0, int *utc
if (utcOffset)
*utcOffset = ((hourOffset * 60 + minOffset) * (positiveOffset ? 60 : -60));
} else {
- // Matches "Wdy Mon DD HH:MM:SS YYYY"
+ // Matches "Wdy Mon DD HH:mm:ss YYYY"
QRegExp rex(QStringLiteral("^[A-Z][a-z]+[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d):(\\d\\d))?[ \\t]+(\\d\\d\\d\\d)[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?"));
if (s.indexOf(rex) == 0) {
if (dd) {
@@ -233,7 +233,7 @@ static void rfcDateImpl(const QString &s, QDate *dd = 0, QTime *dt = 0, int *utc
}
#endif // QT_NO_DATESTRING
-// Return offset in [+-]HH:MM format
+// Return offset in [+-]HH:mm format
// Qt::ISODate puts : between the hours and minutes, but Qt:TextDate does not
static QString toOffsetString(Qt::DateFormat format, int offset)
{
@@ -248,7 +248,7 @@ static QString toOffsetString(Qt::DateFormat format, int offset)
.arg((qAbs(offset) / 60) % 60, 2, 10, QLatin1Char('0'));
}
-// Parse offset in [+-]HH[:]MM format
+// Parse offset in [+-]HH[[:]mm] format
static int fromOffsetString(const QStringRef &offsetString, bool *valid)
{
*valid = false;
@@ -272,7 +272,7 @@ static int fromOffsetString(const QStringRef &offsetString, bool *valid)
// Split the hour and minute parts
QVector<QStringRef> parts = offsetString.mid(1).split(QLatin1Char(':'));
if (parts.count() == 1) {
- // [+-]HHMM format
+ // [+-]HHmm or [+-]HH format
parts.append(parts.first().mid(2));
parts[0] = parts.first().left(2);
}
@@ -282,7 +282,7 @@ static int fromOffsetString(const QStringRef &offsetString, bool *valid)
if (!ok)
return 0;
- const int minute = parts.at(1).toInt(&ok);
+ const int minute = (parts.at(1).isEmpty()) ? 0 : parts.at(1).toInt(&ok);
if (!ok || minute < 0 || minute > 59)
return 0;
@@ -1598,12 +1598,12 @@ int QTime::msec() const
Returns the time as a string. The \a format parameter determines
the format of the string.
- If \a format is Qt::TextDate, the string format is HH:MM:SS;
+ If \a format is Qt::TextDate, the string format is HH:mm:ss;
e.g. 1 second before midnight would be "23:59:59".
If \a format is Qt::ISODate, the string format corresponds to the
ISO 8601 extended specification for representations of dates,
- which is also HH:MM:SS.
+ which is also HH:mm:ss.
If the \a format is Qt::SystemLocaleShortDate or
Qt::SystemLocaleLongDate, the string format depends on the locale
@@ -1925,13 +1925,13 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format,
int msec = 0;
if (size == 5) {
- // HH:MM format
+ // HH:mm format
second = 0;
msec = 0;
} else if (string.at(5) == QLatin1Char(',') || string.at(5) == QLatin1Char('.')) {
if (format == Qt::TextDate)
return QTime();
- // ISODate HH:MM.SSSSSS format
+ // ISODate HH:mm.ssssss format
// We only want 5 digits worth of fraction of minute. This follows the existing
// behavior that determines how milliseconds are read; 4 millisecond digits are
// read and then rounded to 3. If we read at most 5 digits for fraction of minute,
@@ -1951,7 +1951,7 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format,
second = secondNoMs;
msec = qMin(qRound(secondFraction * 1000.0), 999);
} else {
- // HH:MM:SS or HH:MM:SS.sssss
+ // HH:mm:ss or HH:mm:ss.zzz
second = string.mid(6, 2).toInt(&ok);
if (!ok)
return QTime();
@@ -3294,8 +3294,8 @@ bool QDateTime::isDaylightTime() const
}
/*!
- Sets the date part of this datetime to \a date.
- If no time is set, it is set to midnight.
+ Sets the date part of this datetime to \a date. If no time is set yet, it
+ is set to midnight. If \a date is invalid, this QDateTime becomes invalid.
\sa date(), setTime(), setTimeSpec()
*/
@@ -3307,7 +3307,14 @@ void QDateTime::setDate(const QDate &date)
}
/*!
- Sets the time part of this datetime to \a time.
+ Sets the time part of this datetime to \a time. If \a time is not valid,
+ this function sets it to midnight. Therefore, it's possible to clear any
+ set time in a QDateTime by setting it to a default QTime:
+
+ \code
+ QDateTime dt = QDateTime::currentDateTime();
+ dt.setTime(QTime());
+ \endcode
\sa time(), setDate(), setTimeSpec()
*/
@@ -3533,7 +3540,7 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
If the \a format is Qt::ISODate, the string format corresponds
to the ISO 8601 extended specification for representations of
- dates and times, taking the form YYYY-MM-DDTHH:MM:SS[Z|[+|-]HH:MM],
+ dates and times, taking the form YYYY-MM-DDTHH:mm:ss[Z|[+|-]HH:mm],
depending on the timeSpec() of the QDateTime. If the timeSpec()
is Qt::UTC, Z will be appended to the string; if the timeSpec() is
Qt::OffsetFromUTC, the offset in hours and minutes from UTC will
@@ -4452,15 +4459,14 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format)
isoString = isoString.right(isoString.length() - 11);
int offset = 0;
- // Check end of string for Time Zone definition, either Z for UTC or [+-]HH:MM for Offset
+ // Check end of string for Time Zone definition, either Z for UTC or [+-]HH:mm for Offset
if (isoString.endsWith(QLatin1Char('Z'))) {
spec = Qt::UTC;
isoString = isoString.left(isoString.size() - 1);
} else {
// the loop below is faster but functionally equal to:
// const int signIndex = isoString.indexOf(QRegExp(QStringLiteral("[+-]")));
- const int sizeOfTimeZoneString = 4;
- int signIndex = isoString.size() - sizeOfTimeZoneString - 1;
+ int signIndex = isoString.size() - 1;
bool found = false;
{
const QChar plus = QLatin1Char('+');
diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h
index bfb03fb723..189140016c 100644
--- a/src/corelib/tools/qfreelist_p.h
+++ b/src/corelib/tools/qfreelist_p.h
@@ -171,7 +171,7 @@ class QFreeList
// take the current serial number from \a o, increment it, and store it in \a n
static inline int incrementserial(int o, int n)
{
- return (n & ConstantsType::IndexMask) | ((o + ConstantsType::SerialCounter) & ConstantsType::SerialMask);
+ return int((uint(n) & ConstantsType::IndexMask) | ((uint(o) + ConstantsType::SerialCounter) & ConstantsType::SerialMask));
}
// the blocks
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index c5e62027c4..4e3022478a 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -418,9 +418,9 @@ Q_STATIC_ASSERT(!ascii_isspace('\0'));
Q_STATIC_ASSERT(!ascii_isspace('\a'));
Q_STATIC_ASSERT(!ascii_isspace('a'));
Q_STATIC_ASSERT(!ascii_isspace('\177'));
-Q_STATIC_ASSERT(!ascii_isspace('\200'));
-Q_STATIC_ASSERT(!ascii_isspace('\xA0'));
-Q_STATIC_ASSERT(!ascii_isspace('\377'));
+Q_STATIC_ASSERT(!ascii_isspace(uchar('\200')));
+Q_STATIC_ASSERT(!ascii_isspace(uchar('\xA0')));
+Q_STATIC_ASSERT(!ascii_isspace(uchar('\377')));
#endif
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp
index 419551aaca..265e44bfcf 100644
--- a/src/corelib/tools/qmargins.cpp
+++ b/src/corelib/tools/qmargins.cpp
@@ -484,7 +484,7 @@ QDebug operator<<(QDebug dbg, const QMargins &m) {
/*!
\fn bool QMarginsF::isNull() const
- Returns \c true if all margins are is 0; otherwise returns
+ Returns \c true if all margins are 0; otherwise returns
false.
*/
diff --git a/src/corelib/tools/qvsnprintf.cpp b/src/corelib/tools/qvsnprintf.cpp
index cf595b8f31..be92e20fac 100644
--- a/src/corelib/tools/qvsnprintf.cpp
+++ b/src/corelib/tools/qvsnprintf.cpp
@@ -97,6 +97,7 @@ int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap)
#endif
/*!
+ \target bytearray-qsnprintf
\relates QByteArray
A portable snprintf() function, calls qvsnprintf.
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index 9928098a33..fe3c4049ad 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -726,7 +726,7 @@ static const short QXmlStreamReader_tokenTypeString_indices[] = {
/*!
\property QXmlStreamReader::namespaceProcessing
- the namespace-processing flag of the stream reader
+ The namespace-processing flag of the stream reader
This property controls whether or not the stream reader processes
namespaces. If enabled, the reader processes namespaces, otherwise
@@ -3306,7 +3306,7 @@ QTextCodec *QXmlStreamWriter::codec() const
/*!
\property QXmlStreamWriter::autoFormatting
\since 4.4
- the auto-formatting flag of the stream writer
+ The auto-formatting flag of the stream writer
This property controls whether or not the stream writer
automatically formats the generated XML data. If enabled, the
diff --git a/src/dbus/doc/src/qtdbus-index.qdoc b/src/dbus/doc/src/qtdbus-index.qdoc
index 2249924ada..d534ea9140 100644
--- a/src/dbus/doc/src/qtdbus-index.qdoc
+++ b/src/dbus/doc/src/qtdbus-index.qdoc
@@ -212,5 +212,22 @@
\li \l{Qt D-Bus XML compiler (qdbusxml2cpp)}
\li \l{Qt D-Bus C++ Classes}
\li \l{Qt D-Bus Examples}
+ \li \l{D-Bus Viewer}
\endlist
*/
+
+/*!
+ \page qdbusviewer.html
+ \title D-Bus Viewer
+ \keyword qdbusviewer
+
+ The Qt D-Bus Viewer is a tool that lets you introspect D-Bus objects and messages. You can
+ choose between the system bus and the session bus. Click on any service on the list
+ on the left side to see all the exported objects.
+
+ You can invoke methods by double-clicking on them. If a method takes one or more IN parameters,
+ a property editor opens.
+
+ Right-click on a signal to connect to it. All emitted signals including their parameters
+ are output in the message view on the lower side of the window.
+*/
diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp
index e475a23f48..67643098d9 100644
--- a/src/dbus/qdbus_symbols.cpp
+++ b/src/dbus/qdbus_symbols.cpp
@@ -86,9 +86,9 @@ bool qdbus_loadLibDBus()
static int majorversions[] = { 3, 2, -1 };
const QString baseNames[] = {
#ifdef Q_OS_WIN
- QStringLiteral("dbus-1"),
+ QLatin1String("dbus-1"),
#endif
- QStringLiteral("libdbus-1")
+ QLatin1String("libdbus-1")
};
lib->unload();
diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h
index 6175e3ccde..cfa3442518 100644
--- a/src/dbus/qdbus_symbols_p.h
+++ b/src/dbus/qdbus_symbols_p.h
@@ -183,6 +183,9 @@ DEFINEFUNC(dbus_bool_t , dbus_connection_add_filter, (DBusConnection
void *user_data,
DBusFreeFunction free_data_function),
(connection, function, user_data, free_data_function), return)
+DEFINEFUNC(dbus_bool_t , dbus_connection_can_send_type, (DBusConnection *connection,
+ int type),
+ (connection, type), return)
DEFINEFUNC(void , dbus_connection_close, (DBusConnection *connection),
(connection), return)
DEFINEFUNC(DBusDispatchStatus , dbus_connection_dispatch, (DBusConnection *connection),
@@ -396,6 +399,8 @@ DEFINEFUNC(void , dbus_pending_call_unref, (DBusPendingCall
/* dbus-server.h */
DEFINEFUNC(dbus_bool_t , dbus_server_allocate_data_slot, (dbus_int32_t *slot_p),
(slot_p), return)
+DEFINEFUNC(void , dbus_server_free_data_slot, (dbus_int32_t *slot_p),
+ (slot_p), return)
DEFINEFUNC(void , dbus_server_disconnect, (DBusServer *server),
(server), )
DEFINEFUNC(char* , dbus_server_get_address, (DBusServer *server),
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index 4f58d640ff..d25c620b58 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -947,7 +947,7 @@ bool QDBusConnection::isConnected() const
*/
QDBusError QDBusConnection::lastError() const
{
- return d ? d->lastError : QDBusError();
+ return d ? d->lastError : QDBusError(QDBusError::Disconnected, QStringLiteral("Not connected."));
}
/*!
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index c88194b918..b741e97894 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -66,6 +66,9 @@
QT_BEGIN_NAMESPACE
+// used with dbus_server_allocate_data_slot
+static dbus_int32_t server_slot = -1;
+
static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1);
#define qDBusDebug if (::isDebugging == 0); else qDebug
@@ -1084,8 +1087,10 @@ void QDBusConnectionPrivate::closeConnection()
mode = InvalidMode; // prevent reentrancy
baseService.clear();
- if (server)
+ if (server) {
q_dbus_server_disconnect(server);
+ q_dbus_server_free_data_slot(&server_slot);
+ }
if (oldMode == ClientMode || oldMode == PeerMode) {
if (connection) {
@@ -1651,8 +1656,6 @@ void QDBusConnectionPrivate::handleSignal(const QDBusMessage& msg)
handleSignal(key, msg); // third try
}
-static dbus_int32_t server_slot = -1;
-
void QDBusConnectionPrivate::setServer(DBusServer *s, const QDBusErrorInternal &error)
{
mode = ServerMode;
diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp
index 54b38ee848..3fec7c9111 100644
--- a/src/dbus/qdbusserver.cpp
+++ b/src/dbus/qdbusserver.cpp
@@ -110,6 +110,7 @@ QDBusServer::~QDBusServer()
}
d->serverConnectionNames.clear();
}
+ d->deleteLater();
}
/*!
@@ -129,7 +130,7 @@ bool QDBusServer::isConnected() const
*/
QDBusError QDBusServer::lastError() const
{
- return d->lastError;
+ return d ? d->lastError : QDBusError(QDBusError::Disconnected, QStringLiteral("Not connected."));
}
/*!
diff --git a/src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp b/src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp
index f43bba1324..a691c24ce0 100644
--- a/src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp
+++ b/src/gui/doc/snippets/code/src_gui_image_qpixmap.cpp
@@ -48,7 +48,7 @@ static const char * const start_xpm[]={
//! [1]
QPixmap myPixmap;
-myPixmap->setMask(myPixmap->createHeuristicMask());
+myPixmap.setMask(myPixmap.createHeuristicMask());
//! [1]
//! [2]
diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp
index eb580c81f1..b07e1e28d3 100644
--- a/src/gui/image/qjpeghandler.cpp
+++ b/src/gui/image/qjpeghandler.cpp
@@ -825,10 +825,10 @@ static int getExifOrientation(QByteArray &exifData)
quint16 tag;
quint16 type;
quint32 components;
- quint32 value;
-
- stream >> tag >> type >> components >> value;
+ quint16 value;
+ quint16 dummy;
+ stream >> tag >> type >> components >> value >> dummy;
if (tag == 0x0112) { // Tag Exif.Image.Orientation
if (components !=1)
return -1;
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 1cd67b19d2..3fccd6ba9a 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -518,8 +518,9 @@ void QOpenGLContext::setScreen(QScreen *screen)
in addition. Therefore \a handle is variant containing a platform-specific
value type. These classes can be found in the QtPlatformHeaders module.
- When create() is called with native handles set, the handles' ownership are
- not taken, meaning that \c destroy() will not destroy the native context.
+ When create() is called with native handles set, QOpenGLContext does not
+ take ownership of the handles, so destroying the QOpenGLContext does not
+ destroy the native context.
\note Some frameworks track the current context and surfaces internally.
Making the adopted QOpenGLContext current via Qt will have no effect on such
@@ -582,8 +583,8 @@ QVariant QOpenGLContext::nativeHandle() const
Returns \c true if the native context was successfully created and is ready to
be used with makeCurrent(), swapBuffers(), etc.
- \note If the context is already created, this function will first call
- \c destroy(), and then create a new OpenGL context.
+ \note If the context already exists, this function destroys the existing
+ context first, and then creates a new one.
\sa makeCurrent(), format()
*/
@@ -606,6 +607,8 @@ bool QOpenGLContext::create()
}
/*!
+ \internal
+
Destroy the underlying platform context associated with this context.
If any other context is directly or indirectly sharing resources with this
@@ -659,8 +662,7 @@ void QOpenGLContext::destroy()
/*!
Destroys the QOpenGLContext object.
- This implicitly calls \c destroy(), so if this is the current context for the
- thread, doneCurrent() is also called.
+ If this is the current context for the thread, doneCurrent() is also called.
*/
QOpenGLContext::~QOpenGLContext()
{
diff --git a/src/gui/kernel/qplatformservices.cpp b/src/gui/kernel/qplatformservices.cpp
index e11a1858f6..2188920c86 100644
--- a/src/gui/kernel/qplatformservices.cpp
+++ b/src/gui/kernel/qplatformservices.cpp
@@ -49,6 +49,9 @@ QT_BEGIN_NAMESPACE
\brief The QPlatformServices provides the backend for desktop-related functionality.
*/
+QPlatformServices::QPlatformServices()
+{ }
+
bool QPlatformServices::openUrl(const QUrl &url)
{
qWarning("This plugin does not support QPlatformServices::openUrl() for '%s'.",
diff --git a/src/gui/kernel/qplatformservices.h b/src/gui/kernel/qplatformservices.h
index 00a87d51f5..005748d18c 100644
--- a/src/gui/kernel/qplatformservices.h
+++ b/src/gui/kernel/qplatformservices.h
@@ -52,6 +52,7 @@ class QUrl;
class Q_GUI_EXPORT QPlatformServices
{
public:
+ QPlatformServices();
virtual ~QPlatformServices() { }
virtual bool openUrl(const QUrl &url);
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 0c3ea37b29..f5e6f7cca6 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -1075,9 +1075,9 @@ void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem)
}
}
-bool QPaintEngineEx::requiresPretransformedGlyphPositions(QFontEngine *, const QTransform &t) const
+bool QPaintEngineEx::requiresPretransformedGlyphPositions(QFontEngine *, const QTransform &) const
{
- return t.type() >= QTransform::TxProject;
+ return false;
}
bool QPaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const
diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h
index 5475503f22..5fc8bbaf09 100644
--- a/src/gui/painting/qpathclipper_p.h
+++ b/src/gui/painting/qpathclipper_p.h
@@ -414,22 +414,6 @@ inline void QPathSegments::addIntersection(int index, const Intersection &inters
}
}
-inline void QWingedEdge::TraversalStatus::flipDirection()
-{
- direction = QWingedEdge::flip(direction);
-}
-
-inline void QWingedEdge::TraversalStatus::flipTraversal()
-{
- traversal = QWingedEdge::flip(traversal);
-}
-
-inline void QWingedEdge::TraversalStatus::flip()
-{
- flipDirection();
- flipTraversal();
-}
-
inline int QWingedEdge::edgeCount() const
{
return m_edges.size();
@@ -471,11 +455,27 @@ inline QPathEdge::Traversal QWingedEdge::flip(QPathEdge::Traversal traversal)
return traversal == QPathEdge::RightTraversal ? QPathEdge::LeftTraversal : QPathEdge::RightTraversal;
}
+inline void QWingedEdge::TraversalStatus::flipTraversal()
+{
+ traversal = QWingedEdge::flip(traversal);
+}
+
inline QPathEdge::Direction QWingedEdge::flip(QPathEdge::Direction direction)
{
return direction == QPathEdge::Forward ? QPathEdge::Backward : QPathEdge::Forward;
}
+inline void QWingedEdge::TraversalStatus::flipDirection()
+{
+ direction = QWingedEdge::flip(direction);
+}
+
+inline void QWingedEdge::TraversalStatus::flip()
+{
+ flipDirection();
+ flipTraversal();
+}
+
QT_END_NAMESPACE
#endif // QPATHCLIPPER_P_H
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 9610482145..e010dd62ae 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -647,7 +647,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const
e.g. for italicized fonts, and that the width of the returned
rectangle might be different than what the width() method returns.
- If you want to know the advance width of the string (to layout
+ If you want to know the advance width of the string (to lay out
a set of strings next to each other), use width() instead.
Newline characters are processed as normal characters, \e not as
@@ -817,7 +817,7 @@ QSize QFontMetrics::size(int flags, const QString &text, int tabStops, int *tabA
e.g. for italicized fonts, and that the width of the returned
rectangle might be different than what the width() method returns.
- If you want to know the advance width of the string (to layout
+ If you want to know the advance width of the string (to lay out
a set of strings next to each other), use width() instead.
Newline characters are processed as normal characters, \e not as
@@ -1432,7 +1432,7 @@ qreal QFontMetricsF::width(QChar ch) const
e.g. for italicized fonts, and that the width of the returned
rectangle might be different than what the width() method returns.
- If you want to know the advance width of the string (to layout
+ If you want to know the advance width of the string (to lay out
a set of strings next to each other), use width() instead.
Newline characters are processed as normal characters, \e not as
@@ -1606,7 +1606,7 @@ QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *ta
e.g. for italicized fonts, and that the width of the returned
rectangle might be different than what the width() method returns.
- If you want to know the advance width of the string (to layout
+ If you want to know the advance width of the string (to lay out
a set of strings next to each other), use width() instead.
Newline characters are processed as normal characters, \e not as
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 1502758ee8..ab4b10522a 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -305,7 +305,7 @@ uint QTextFormatPrivate::recalcHash() const
{
hashValue = 0;
for (QVector<Property>::ConstIterator it = props.constBegin(); it != props.constEnd(); ++it)
- hashValue += (it->key << 16) + variantHash(it->value);
+ hashValue += (static_cast<quint32>(it->key) << 16) + variantHash(it->value);
hashDirty = false;
diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp
index d9b3acdd92..1710af723f 100644
--- a/src/network/access/qnetworkreply.cpp
+++ b/src/network/access/qnetworkreply.cpp
@@ -606,7 +606,7 @@ QList<QByteArray> QNetworkReply::rawHeaderList() const
/*!
Returns the attribute associated with the code \a code. If the
- attribute has not been set, it returns an invalid QVariant (type QMetaType::Unknown).
+ attribute has not been set, it returns an invalid QVariant (type QMetaType::UnknownType).
You can expect the default values listed in
QNetworkRequest::Attribute to be applied to the values returned by
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp
index 10fdf2f97d..b68f6adfff 100644
--- a/src/network/kernel/qhostaddress.cpp
+++ b/src/network/kernel/qhostaddress.cpp
@@ -778,18 +778,34 @@ bool QHostAddress::operator==(const QHostAddress &other) const
bool QHostAddress::operator ==(SpecialAddress other) const
{
QT_ENSURE_PARSED(this);
- QHostAddress otherAddress(other);
- QT_ENSURE_PARSED(&otherAddress);
+ switch (other) {
+ case Null:
+ return d->protocol == QAbstractSocket::UnknownNetworkLayerProtocol;
- if (d->protocol == QAbstractSocket::IPv4Protocol)
- return otherAddress.d->protocol == QAbstractSocket::IPv4Protocol && d->a == otherAddress.d->a;
- if (d->protocol == QAbstractSocket::IPv6Protocol) {
- return otherAddress.d->protocol == QAbstractSocket::IPv6Protocol
- && memcmp(&d->a6, &otherAddress.d->a6, sizeof(Q_IPV6ADDR)) == 0;
+ case Broadcast:
+ return d->protocol == QAbstractSocket::IPv4Protocol && d->a == INADDR_BROADCAST;
+
+ case LocalHost:
+ return d->protocol == QAbstractSocket::IPv4Protocol && d->a == INADDR_LOOPBACK;
+
+ case Any:
+ return d->protocol == QAbstractSocket::AnyIPProtocol;
+
+ case AnyIPv4:
+ return d->protocol == QAbstractSocket::IPv4Protocol && d->a == INADDR_ANY;
+
+ case LocalHostIPv6:
+ case AnyIPv6:
+ if (d->protocol == QAbstractSocket::IPv6Protocol) {
+ Q_IPV6ADDR ip6 = { { 0 } };
+ ip6[15] = quint8(other == LocalHostIPv6); // 1 for localhost, 0 for any
+ return memcmp(&d->a6, &ip6, sizeof ip6) == 0;
+ }
+ return false;
}
- if (d->protocol == QAbstractSocket::AnyIPProtocol)
- return other == QHostAddress::Any;
- return int(other) == int(Null);
+
+ Q_UNREACHABLE();
+ return false;
}
/*!
diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp
index 7d262467c3..a1ac349949 100644
--- a/src/network/kernel/qnetworkproxy_mac.cpp
+++ b/src/network/kernel/qnetworkproxy_mac.cpp
@@ -221,18 +221,29 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query)
int enabled;
if (CFNumberGetValue(pacEnabled, kCFNumberIntType, &enabled) && enabled) {
// PAC is enabled
- CFStringRef cfPacLocation = (CFStringRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigURLString);
+ // kSCPropNetProxiesProxyAutoConfigURLString returns the URL string
+ // as entered in the system proxy configuration dialog
+ CFStringRef pacLocationSetting = (CFStringRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigURLString);
+ QCFType<CFStringRef> cfPacLocation = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, pacLocationSetting, NULL, NULL,
+ kCFStringEncodingUTF8);
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
QCFType<CFDataRef> pacData;
QCFType<CFURLRef> pacUrl = CFURLCreateWithString(kCFAllocatorDefault, cfPacLocation, NULL);
+ if (!pacUrl) {
+ qWarning("Invalid PAC URL \"%s\"", qPrintable(QCFString::toQString(cfPacLocation)));
+ return result;
+ }
SInt32 errorCode;
if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, pacUrl, &pacData, NULL, NULL, &errorCode)) {
QString pacLocation = QCFString::toQString(cfPacLocation);
qWarning("Unable to get the PAC script at \"%s\" (%s)", qPrintable(pacLocation), cfurlErrorDescription(errorCode));
return result;
}
-
+ if (!pacData) {
+ qWarning("\"%s\" returned an empty PAC script", qPrintable(QCFString::toQString(cfPacLocation)));
+ return result;
+ }
QCFType<CFStringRef> pacScript = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, pacData, kCFStringEncodingISOLatin1);
if (!pacScript) {
// This should never happen, but the documentation says it may return NULL if there was a problem creating the object.
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index ad170e187c..eed1b70025 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -567,9 +567,6 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16
return false;
}
- localPort = port;
- localAddress = address;
-
#if defined (QNATIVESOCKETENGINE_DEBUG)
qDebug("QNativeSocketEnginePrivate::nativeBind(%s, %i) == true",
address.toString().toLatin1().constData(), port);
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index f5943d657f..184add15c3 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -852,9 +852,6 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &a, quint16 port)
return false;
}
- localPort = port;
- localAddress = address;
-
#if defined (QNATIVESOCKETENGINE_DEBUG)
qDebug("QNativeSocketEnginePrivate::nativeBind(%s, %i) == true",
address.toString().toLatin1().constData(), port);
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index f129bb40dd..f2e2ded3f5 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -530,6 +530,11 @@ QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintin
break;
}
+ if (QGuiApplication::platformNativeInterface()->nativeResourceForScreen("nofonthinting",
+ QGuiApplication::primaryScreen())) {
+ return QFontEngine::HintNone;
+ }
+
if (useXftConf) {
void *hintStyleResource =
QGuiApplication::platformNativeInterface()->nativeResourceForScreen("hintstyle",
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index ac73cd04ad..4244719b34 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -177,6 +177,8 @@ QCoreTextFontDatabase::QCoreTextFontDatabase()
QCoreTextFontDatabase::~QCoreTextFontDatabase()
{
+ foreach (CTFontDescriptorRef ref, m_systemFontDescriptors)
+ CFRelease(ref);
}
static CFArrayRef availableFamilyNames()
@@ -810,7 +812,11 @@ QFont *QCoreTextFontDatabase::themeFont(QPlatformTheme::Font f) const
CTFontDescriptorRef fontDesc = fontDescriptorFromTheme(f);
FontDescription fd;
getFontDescription(fontDesc, &fd);
- m_systemFontDescriptors.insert(fontDesc);
+
+ if (!m_systemFontDescriptors.contains(fontDesc))
+ m_systemFontDescriptors.insert(fontDesc);
+ else
+ CFRelease(fontDesc);
QFont *font = new QFont(fd.familyName, fd.pixelSize, fd.weight, fd.style == QFont::StyleItalic);
return font;
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
index f0977b4735..f52b9d4b4d 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
@@ -125,7 +125,6 @@ void QNetworkManagerEngine::setupConfigurations()
activeConnectionsList.insert(acPath.path(), activeConnection);
connect(activeConnection, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
this, SLOT(activeConnectionPropertiesChanged(QMap<QString,QVariant>)));
- activeConnection->setConnections();
QStringList devices = activeConnection->devices();
if (!devices.isEmpty()) {
@@ -180,7 +179,7 @@ void QNetworkManagerEngine::connectToId(const QString &id)
NMDeviceType connectionType = connection->getType();
QString dbusDevicePath;
- const QString settingsPath = connection->connectionInterface()->path();
+ const QString settingsPath = connection->path();
QString specificPath = configuredAccessPoints.key(settingsPath);
if (isConnectionActive(settingsPath))
@@ -277,7 +276,6 @@ void QNetworkManagerEngine::interfacePropertiesChanged(const QMap<QString, QVari
connect(activeConnection, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
this, SLOT(activeConnectionPropertiesChanged(QMap<QString,QVariant>)));
- activeConnection->setConnections();
}
const QString id = activeConnection->connection().path();
@@ -373,10 +371,10 @@ void QNetworkManagerEngine::deviceConnectionsChanged(const QStringList &connecti
{
QMutexLocker locker(&mutex);
for (int i = 0; i < connections.count(); ++i) {
- if (connectionsList.contains(connections.at(i)->connectionInterface()->path()))
+ if (connectionsList.contains(connections.at(i)->path()))
continue;
- const QString settingsPath = connections.at(i)->connectionInterface()->path();
+ const QString settingsPath = connections.at(i)->path();
QNetworkConfigurationPrivatePointer ptr =
accessPointConfigurations.value(settingsPath);
@@ -399,11 +397,10 @@ void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path)
connect(iDevice,SIGNAL(connectionsChanged(QStringList)),
this,SLOT(deviceConnectionsChanged(QStringList)));
- iDevice->setConnections();
interfaceDevices.insert(path.path(),iDevice);
if (iDevice->deviceType() == DEVICE_TYPE_WIFI) {
QNetworkManagerInterfaceDeviceWireless *wirelessDevice =
- new QNetworkManagerInterfaceDeviceWireless(iDevice->connectionInterface()->path(),this);
+ new QNetworkManagerInterfaceDeviceWireless(iDevice->path(),this);
connect(wirelessDevice, SIGNAL(accessPointAdded(QString)),
this, SLOT(newAccessPoint(QString)));
@@ -417,9 +414,9 @@ void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path)
if (iDevice->deviceType() == DEVICE_TYPE_ETHERNET) {
QNetworkManagerInterfaceDeviceWired *wiredDevice =
- new QNetworkManagerInterfaceDeviceWired(iDevice->connectionInterface()->path(),this);
+ new QNetworkManagerInterfaceDeviceWired(iDevice->path(),this);
connect(wiredDevice,SIGNAL(carrierChanged(bool)),this,SLOT(wiredCarrierChanged(bool)));
- wiredDevices.insert(iDevice->connectionInterface()->path(), wiredDevice);
+ wiredDevices.insert(iDevice->path(), wiredDevice);
}
}
@@ -454,7 +451,7 @@ void QNetworkManagerEngine::wiredCarrierChanged(bool carrier)
for (int i = 0; i < connections.count(); ++i) {
QNetworkManagerSettingsConnection *connection = connections.at(i);
if (connection->getType() == DEVICE_TYPE_ETHERNET
- && settingsPath.path() == connection->connectionInterface()->path()) {
+ && settingsPath.path() == connection->path()) {
QNetworkConfigurationPrivatePointer ptr =
accessPointConfigurations.value(settingsPath.path());
@@ -486,9 +483,9 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path,
}
QNetworkManagerSettingsConnection *connection =
- new QNetworkManagerSettingsConnection(settings->connectionInterface()->service(),
+ new QNetworkManagerSettingsConnection(settings->service(),
path.path(),this);
- const QString settingsPath = connection->connectionInterface()->path();
+ const QString settingsPath = connection->path();
if (accessPointConfigurations.contains(settingsPath)) {
return;
}
@@ -506,7 +503,7 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path,
for (int i = 0; i < accessPoints.count(); ++i) {
if (connection->getSsid() == accessPoints.at(i)->ssid()) {
// remove the corresponding accesspoint from configurations
- apPath = accessPoints.at(i)->connectionInterface()->path();
+ apPath = accessPoints.at(i)->path();
QNetworkConfigurationPrivatePointer ptr
= accessPointConfigurations.take(apPath);
if (ptr) {
@@ -533,7 +530,7 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path,
i.next();
if (i.value()->deviceType() == deviceType) {
QNetworkManagerInterfaceDeviceWired *wiredDevice
- = wiredDevices.value(i.value()->connectionInterface()->path());
+ = wiredDevices.value(i.value()->path());
if (wiredDevice->carrier()) {
cpPriv->state |= QNetworkConfiguration::Discovered;
}
@@ -564,7 +561,7 @@ bool QNetworkManagerEngine::isConnectionActive(const QString &settingsPath)
QNetworkManagerSettingsConnection *settingsConnection = connectionFromId(settingsPath);
if (settingsConnection->getType() == DEVICE_TYPE_MODEM) {
- return isActiveContext(settingsConnection->connectionInterface()->path());
+ return isActiveContext(settingsConnection->path());
}
return false;
@@ -611,7 +608,7 @@ void QNetworkManagerEngine::updateConnection()
qobject_cast<QNetworkManagerSettingsConnection *>(sender());
if (!connection)
return;
- const QString settingsPath = connection->connectionInterface()->path();
+ const QString settingsPath = connection->path();
QNetworkConfigurationPrivate *cpPriv = parseConnection(settingsPath, connection->getSettings());
@@ -682,20 +679,19 @@ void QNetworkManagerEngine::newAccessPoint(const QString &path)
bool okToAdd = true;
for (int i = 0; i < accessPoints.count(); ++i) {
- if (accessPoints.at(i)->connectionInterface()->path() == path) {
+ if (accessPoints.at(i)->path() == path) {
okToAdd = false;
}
}
if (okToAdd) {
accessPoints.append(accessPoint);
- accessPoint->setConnections();
}
// Check if configuration exists for connection.
if (!accessPoint->ssid().isEmpty()) {
for (int i = 0; i < connections.count(); ++i) {
QNetworkManagerSettingsConnection *connection = connections.at(i);
- const QString settingsPath = connection->connectionInterface()->path();
+ const QString settingsPath = connection->path();
if (accessPoint->ssid() == connection->getSsid()) {
if (!configuredAccessPoints.contains(path)) {
@@ -741,18 +737,18 @@ void QNetworkManagerEngine::removeAccessPoint(const QString &path)
QMutexLocker locker(&mutex);
for (int i = 0; i < accessPoints.count(); ++i) {
QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i);
- if (accessPoint->connectionInterface()->path() == path) {
+ if (accessPoint->path() == path) {
accessPoints.removeOne(accessPoint);
- if (configuredAccessPoints.contains(accessPoint->connectionInterface()->path())) {
+ if (configuredAccessPoints.contains(accessPoint->path())) {
// find connection and change state to Defined
- configuredAccessPoints.remove(accessPoint->connectionInterface()->path());
+ configuredAccessPoints.remove(accessPoint->path());
for (int i = 0; i < connections.count(); ++i) {
QNetworkManagerSettingsConnection *connection = connections.at(i);
if (accessPoint->ssid() == connection->getSsid()) {//might not have bssid yet
- const QString settingsPath = connection->connectionInterface()->path();
+ const QString settingsPath = connection->path();
const QString connectionId = settingsPath;
QNetworkConfigurationPrivatePointer ptr =
@@ -804,7 +800,7 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) {
QNetworkManagerInterfaceDevice device(devicePath.path(),this);
if (device.deviceType() == DEVICE_TYPE_ETHERNET) {
- QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(device.connectionInterface()->path());
+ QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(device.path());
if (wiredDevice->carrier()) {
cpPriv->state |= QNetworkConfiguration::Discovered;
break;
@@ -819,10 +815,10 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
if (connectionSsid == accessPoints.at(i)->ssid()
&& map.value("802-11-wireless").value("seen-bssids").toStringList().contains(accessPoints.at(i)->hwAddress())) {
cpPriv->state |= QNetworkConfiguration::Discovered;
- if (!configuredAccessPoints.contains(accessPoints.at(i)->connectionInterface()->path())) {
- configuredAccessPoints.insert(accessPoints.at(i)->connectionInterface()->path(),settingsPath);
+ if (!configuredAccessPoints.contains(accessPoints.at(i)->path())) {
+ configuredAccessPoints.insert(accessPoints.at(i)->path(),settingsPath);
- const QString accessPointId = accessPoints.at(i)->connectionInterface()->path();
+ const QString accessPointId = accessPoints.at(i)->path();
QNetworkConfigurationPrivatePointer ptr =
accessPointConfigurations.take(accessPointId);
@@ -881,7 +877,7 @@ QNetworkManagerSettingsConnection *QNetworkManagerEngine::connectionFromId(const
{
for (int i = 0; i < connections.count(); ++i) {
QNetworkManagerSettingsConnection *connection = connections.at(i);
- if (id == connection->connectionInterface()->path())
+ if (id == connection->path())
return connection;
}
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
index 9f4ae55e78..16a7e475e0 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
@@ -47,32 +47,24 @@
#ifndef QT_NO_DBUS
+#define DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
+
QT_BEGIN_NAMESPACE
-class QNetworkManagerInterfacePrivate
-{
-public:
- QDBusInterface *connectionInterface;
- bool valid;
-};
QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
- : QObject(parent)
-{
- d = new QNetworkManagerInterfacePrivate();
- d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
- QLatin1String(NM_DBUS_PATH),
- QLatin1String(NM_DBUS_INTERFACE),
- QDBusConnection::systemBus(),parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
+ : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
+ QLatin1String(NM_DBUS_PATH),
+ NM_DBUS_INTERFACE,
+ QDBusConnection::systemBus(),parent)
+{
+ if (!isValid()) {
return;
}
- d->valid = true;
- QDBusInterface managerPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
+ PropertiesDBusInterface managerPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
QLatin1String(NM_DBUS_PATH),
- QLatin1String("org.freedesktop.DBus.Properties"),
+ DBUS_PROPERTIES_INTERFACE,
QDBusConnection::systemBus());
QList<QVariant> argumentList;
argumentList << QLatin1String(NM_DBUS_INTERFACE);
@@ -81,13 +73,17 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
argumentList);
if (!propsReply.isError()) {
propertyMap = propsReply.value();
+ } else {
+ qWarning() << Q_FUNC_INFO << "propsReply"<<propsReply.error().message();
}
QDBusPendingReply<QList <QDBusObjectPath> > nmReply
- = d->connectionInterface->call(QLatin1String("GetDevices"));
+ = call(QLatin1String("GetDevices"));
nmReply.waitForFinished();
if (!nmReply.isError()) {
devicesPathList = nmReply.value();
+ } else {
+ qWarning() << Q_FUNC_INFO <<"nmReply"<<nmReply.error().message();
}
QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
@@ -99,13 +95,6 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
QNetworkManagerInterface::~QNetworkManagerInterface()
{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerInterface::isValid()
-{
- return d->valid;
}
bool QNetworkManagerInterface::setConnections()
@@ -138,16 +127,11 @@ bool QNetworkManagerInterface::setConnections()
return allOk;
}
-QDBusInterface *QNetworkManagerInterface::connectionInterface() const
-{
- return d->connectionInterface;
-}
-
QList <QDBusObjectPath> QNetworkManagerInterface::getDevices()
{
if (devicesPathList.isEmpty()) {
//qWarning() << "using blocking call!";
- QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetDevices"));
+ QDBusReply<QList<QDBusObjectPath> > reply = call(QLatin1String("GetDevices"));
devicesPathList = reply.value();
}
return devicesPathList;
@@ -157,7 +141,7 @@ void QNetworkManagerInterface::activateConnection(QDBusObjectPath connectionPath
QDBusObjectPath devicePath,
QDBusObjectPath specificObject)
{
- QDBusPendingCall pendingCall = d->connectionInterface->asyncCall(QLatin1String("ActivateConnection"),
+ QDBusPendingCall pendingCall = asyncCall(QLatin1String("ActivateConnection"),
QVariant::fromValue(connectionPath),
QVariant::fromValue(devicePath),
QVariant::fromValue(specificObject));
@@ -167,9 +151,9 @@ void QNetworkManagerInterface::activateConnection(QDBusObjectPath connectionPath
this, SIGNAL(activationFinished(QDBusPendingCallWatcher*)));
}
-void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath) const
+void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath)
{
- d->connectionInterface->asyncCall(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath));
+ asyncCall(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath));
}
bool QNetworkManagerInterface::wirelessEnabled() const
@@ -245,73 +229,38 @@ void QNetworkManagerInterface::propertiesSwap(QMap<QString,QVariant> map)
}
}
-class QNetworkManagerInterfaceAccessPointPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent)
- : QObject(parent)
-{
- d = new QNetworkManagerInterfaceAccessPointPrivate();
- d->path = dbusPathName;
- d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
- QDBusConnection::systemBus(),parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
+ : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
+ dbusPathName,
+ NM_DBUS_INTERFACE_ACCESS_POINT,
+ QDBusConnection::systemBus(),parent)
+{
+ if (!isValid()) {
return;
}
- QDBusInterface accessPointPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String("org.freedesktop.DBus.Properties"),
+ PropertiesDBusInterface *accessPointPropertiesInterface = new PropertiesDBusInterface(QLatin1String(NM_DBUS_SERVICE),
+ dbusPathName,
+ DBUS_PROPERTIES_INTERFACE,
QDBusConnection::systemBus());
QList<QVariant> argumentList;
argumentList << QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT);
QDBusPendingReply<QVariantMap> propsReply
- = accessPointPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"),
+ = accessPointPropertiesInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetAll"),
argumentList);
if (!propsReply.isError()) {
propertyMap = propsReply.value();
}
QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- d->path,
+ dbusPathName,
QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
QLatin1String("PropertiesChanged"),
this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-
- d->valid = true;
-
}
QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint()
{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerInterfaceAccessPoint::isValid()
-{
- return d->valid;
-}
-
-bool QNetworkManagerInterfaceAccessPoint::setConnections()
-{
- if (!isValid())
- return false;
-
- return true;
-}
-
-QDBusInterface *QNetworkManagerInterfaceAccessPoint::connectionInterface() const
-{
- return d->connectionInterface;
}
quint32 QNetworkManagerInterfaceAccessPoint::flags() const
@@ -386,31 +335,19 @@ void QNetworkManagerInterfaceAccessPoint::propertiesSwap(QMap<QString,QVariant>
}
}
-class QNetworkManagerInterfaceDevicePrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent)
- : QObject(parent)
+ : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
+ deviceObjectPath,
+ NM_DBUS_INTERFACE_DEVICE,
+ QDBusConnection::systemBus(),parent)
{
- d = new QNetworkManagerInterfaceDevicePrivate();
- d->path = deviceObjectPath;
- d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String(NM_DBUS_INTERFACE_DEVICE),
- QDBusConnection::systemBus(),parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
+ if (!isValid()) {
return;
}
- QDBusInterface devicePropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String("org.freedesktop.DBus.Properties"),
+ PropertiesDBusInterface devicePropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
+ deviceObjectPath,
+ DBUS_PROPERTIES_INTERFACE,
QDBusConnection::systemBus(),parent);
QList<QVariant> argumentList;
@@ -424,35 +361,14 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de
}
QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- d->path,
+ deviceObjectPath,
QLatin1String(NM_DBUS_INTERFACE_DEVICE),
QLatin1String("PropertiesChanged"),
this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
- d->valid = true;
}
QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice()
{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerInterfaceDevice::isValid()
-{
- return d->valid;
-}
-
-bool QNetworkManagerInterfaceDevice::setConnections()
-{
- if (!isValid())
- return false;
-
- return true;
-}
-
-QDBusInterface *QNetworkManagerInterfaceDevice::connectionInterface() const
-{
- return d->connectionInterface;
}
QString QNetworkManagerInterfaceDevice::udi() const
@@ -519,31 +435,19 @@ void QNetworkManagerInterfaceDevice::propertiesSwap(QMap<QString,QVariant> map)
Q_EMIT propertiesChanged(map);
}
-class QNetworkManagerInterfaceDeviceWiredPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent)
- : QObject(parent)
-{
- d = new QNetworkManagerInterfaceDeviceWiredPrivate();
- d->path = ifaceDevicePath;
- d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
- QDBusConnection::systemBus(), parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
+ : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
+ ifaceDevicePath,
+ NM_DBUS_INTERFACE_DEVICE_WIRED,
+ QDBusConnection::systemBus(), parent)
+{
+ if (!isValid()) {
return;
}
- QDBusInterface deviceWiredPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String("org.freedesktop.DBus.Properties"),
- QDBusConnection::systemBus(),parent);
+ PropertiesDBusInterface deviceWiredPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
+ ifaceDevicePath,
+ DBUS_PROPERTIES_INTERFACE,
+ QDBusConnection::systemBus(),parent);
QList<QVariant> argumentList;
argumentList << QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED);
@@ -556,36 +460,14 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q
}
QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- d->path,
+ ifaceDevicePath,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
QLatin1String("PropertiesChanged"),
this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-
- d->valid = true;
}
QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired()
{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerInterfaceDeviceWired::isValid()
-{
-
- return d->valid;
-}
-
-bool QNetworkManagerInterfaceDeviceWired::setConnections()
-{
- if (!isValid())
- return false;
- return true;
-}
-
-QDBusInterface *QNetworkManagerInterfaceDeviceWired::connectionInterface() const
-{
- return d->connectionInterface;
}
QString QNetworkManagerInterfaceDeviceWired::hwAddress() const
@@ -639,39 +521,27 @@ void QNetworkManagerInterfaceDeviceWired::propertiesSwap(QMap<QString,QVariant>
Q_EMIT propertiesChanged(map);
}
-class QNetworkManagerInterfaceDeviceWirelessPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent)
- : QObject(parent)
-{
- d = new QNetworkManagerInterfaceDeviceWirelessPrivate();
- d->path = ifaceDevicePath;
- d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
- QDBusConnection::systemBus(), parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
+ : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
+ ifaceDevicePath,
+ NM_DBUS_INTERFACE_DEVICE_WIRELESS,
+ QDBusConnection::systemBus(), parent)
+{
+ if (!isValid()) {
return;
}
-
+ interfacePath = ifaceDevicePath;
QDBusPendingReply<QList <QDBusObjectPath> > nmReply
- = d->connectionInterface->call(QLatin1String("GetAccessPoints"));
+ = call(QLatin1String("GetAccessPoints"));
if (!nmReply.isError()) {
accessPointsList = nmReply.value();
}
- QDBusInterface deviceWirelessPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String("org.freedesktop.DBus.Properties"),
+ PropertiesDBusInterface deviceWirelessPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
+ interfacePath,
+ DBUS_PROPERTIES_INTERFACE,
QDBusConnection::systemBus(),parent);
QList<QVariant> argumentList;
@@ -684,31 +554,21 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c
}
QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- d->path,
+ interfacePath,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
QLatin1String("PropertiesChanged"),
this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
QDBusPendingReply<QList<QDBusObjectPath> > reply
- = d->connectionInterface->asyncCall(QLatin1String("GetAccessPoints"));
+ = asyncCall(QLatin1String("GetAccessPoints"));
QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(reply);
connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
this, SLOT(accessPointsFinished(QDBusPendingCallWatcher*)));
-
-
- d->valid = true;
}
QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless()
{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerInterfaceDeviceWireless::isValid()
-{
- return d->valid;
}
void QNetworkManagerInterfaceDeviceWireless::slotAccessPointAdded(QDBusObjectPath path)
@@ -732,16 +592,16 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections()
bool allOk = true;
if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
- QLatin1String("AccessPointAdded"),
- this, SLOT(slotAccessPointAdded(QDBusObjectPath)))) {
+ interfacePath,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+ QLatin1String("AccessPointAdded"),
+ this, SLOT(slotAccessPointAdded(QDBusObjectPath)))) {
allOk = false;
}
if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
- d->path,
+ interfacePath,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
QLatin1String("AccessPointRemoved"),
this, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) {
@@ -749,7 +609,7 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections()
}
if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
- d->path,
+ interfacePath,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
QLatin1String("ScanDone"),
this, SLOT(scanIsDone()))) {
@@ -771,17 +631,12 @@ void QNetworkManagerInterfaceDeviceWireless::accessPointsFinished(QDBusPendingCa
}
}
-QDBusInterface *QNetworkManagerInterfaceDeviceWireless::connectionInterface() const
-{
- return d->connectionInterface;
-}
-
QList <QDBusObjectPath> QNetworkManagerInterfaceDeviceWireless::getAccessPoints()
{
if (accessPointsList.isEmpty()) {
//qWarning() << "Using blocking call!";
QDBusReply<QList<QDBusObjectPath> > reply
- = d->connectionInterface->call(QLatin1String("GetAccessPoints"));
+ = call(QLatin1String("GetAccessPoints"));
accessPointsList = reply.value();
}
return accessPointsList;
@@ -829,7 +684,7 @@ void QNetworkManagerInterfaceDeviceWireless::scanIsDone()
void QNetworkManagerInterfaceDeviceWireless::requestScan()
{
- d->connectionInterface->asyncCall(QLatin1String("RequestScan"));
+ asyncCall(QLatin1String("RequestScan"));
}
void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMap<QString,QVariant> map)
@@ -844,29 +699,17 @@ void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMap<QString,QVarian
}
}
-class QNetworkManagerInterfaceDeviceModemPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
QNetworkManagerInterfaceDeviceModem::QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath, QObject *parent)
- : QObject(parent)
-{
- d = new QNetworkManagerInterfaceDeviceModemPrivate();
- d->path = ifaceDevicePath;
- d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM),
- QDBusConnection::systemBus(), parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
+ : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
+ ifaceDevicePath,
+ NM_DBUS_INTERFACE_DEVICE_MODEM,
+ QDBusConnection::systemBus(), parent)
+{
+ if (!isValid()) {
return;
}
- QDBusInterface deviceModemPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
+ PropertiesDBusInterface deviceModemPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
+ ifaceDevicePath,
QLatin1String("org.freedesktop.DBus.Properties"),
QDBusConnection::systemBus(),parent);
@@ -880,36 +723,14 @@ QNetworkManagerInterfaceDeviceModem::QNetworkManagerInterfaceDeviceModem(const Q
}
QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- d->path,
+ ifaceDevicePath,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM),
QLatin1String("PropertiesChanged"),
this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
- d->valid = true;
}
QNetworkManagerInterfaceDeviceModem::~QNetworkManagerInterfaceDeviceModem()
{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerInterfaceDeviceModem::isValid()
-{
-
- return d->valid;
-}
-
-bool QNetworkManagerInterfaceDeviceModem::setConnections()
-{
- if (!isValid() )
- return false;
-
- return true;
-}
-
-QDBusInterface *QNetworkManagerInterfaceDeviceModem::connectionInterface() const
-{
- return d->connectionInterface;
}
QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceDeviceModem::modemCapabilities() const
@@ -936,59 +757,39 @@ void QNetworkManagerInterfaceDeviceModem::propertiesSwap(QMap<QString,QVariant>
Q_EMIT propertiesChanged(map);
}
-class QNetworkManagerSettingsPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
QNetworkManagerSettings::QNetworkManagerSettings(const QString &settingsService, QObject *parent)
- : QObject(parent)
-{
- d = new QNetworkManagerSettingsPrivate();
- d->path = settingsService;
- d->connectionInterface = new QDBusInterface(settingsService,
- QLatin1String(NM_DBUS_PATH_SETTINGS),
- QLatin1String(NM_DBUS_IFACE_SETTINGS),
- QDBusConnection::systemBus());
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
+ : QDBusAbstractInterface(settingsService,
+ NM_DBUS_PATH_SETTINGS,
+ NM_DBUS_IFACE_SETTINGS,
+ QDBusConnection::systemBus(), parent)
+{
+ if (!isValid()) {
return;
}
-
+ interfacePath = settingsService;
QDBusPendingReply<QList <QDBusObjectPath> > nmReply
- = d->connectionInterface->call(QLatin1String("ListConnections"));
+ = call(QLatin1String("ListConnections"));
if (!nmReply.isError()) {
connectionsList = nmReply.value();
}
-
- d->valid = true;
}
QNetworkManagerSettings::~QNetworkManagerSettings()
{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerSettings::isValid()
-{
- return d->valid;
}
bool QNetworkManagerSettings::setConnections()
{
bool allOk = true;
-
- if (!QDBusConnection::systemBus().connect(d->path,
+ if (!QDBusConnection::systemBus().connect(interfacePath,
QLatin1String(NM_DBUS_PATH_SETTINGS),
QLatin1String(NM_DBUS_IFACE_SETTINGS),
QLatin1String("NewConnection"),
this, SIGNAL(newConnection(QDBusObjectPath)))) {
allOk = false;
+ qWarning() << Q_FUNC_INFO << "NewConnection could not be connected";
}
return allOk;
@@ -999,7 +800,7 @@ QList <QDBusObjectPath> QNetworkManagerSettings::listConnections()
if (connectionsList.isEmpty()) {
//qWarning() << "Using blocking call!";
QDBusReply<QList<QDBusObjectPath> > reply
- = d->connectionInterface->call(QLatin1String("ListConnections"));
+ = call(QLatin1String("ListConnections"));
connectionsList = reply.value();
}
return connectionsList;
@@ -1010,59 +811,30 @@ QString QNetworkManagerSettings::getConnectionByUuid(const QString &uuid)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(uuid);
- QDBusReply<QDBusObjectPath > reply = d->connectionInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetConnectionByUuid"), argumentList);
+ QDBusReply<QDBusObjectPath > reply = callWithArgumentList(QDBus::Block,QLatin1String("GetConnectionByUuid"), argumentList);
return reply.value().path();
}
-QDBusInterface *QNetworkManagerSettings::connectionInterface() const
-{
- return d->connectionInterface;
-}
-
-
-class QNetworkManagerSettingsConnectionPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- QString service;
- QNmSettingsMap settingsMap;
- bool valid;
-};
-
QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent)
- : QObject(parent)
+ : QDBusAbstractInterface(settingsService,
+ connectionObjectPath,
+ NM_DBUS_IFACE_SETTINGS_CONNECTION,
+ QDBusConnection::systemBus(), parent)
{
qDBusRegisterMetaType<QNmSettingsMap>();
- d = new QNetworkManagerSettingsConnectionPrivate();
- d->path = connectionObjectPath;
- d->service = settingsService;
- d->connectionInterface = new QDBusInterface(settingsService,
- d->path,
- QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
- QDBusConnection::systemBus(), parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
+ if (!isValid()) {
return;
}
- d->valid = true;
-
+ interfacepath = connectionObjectPath;
QDBusPendingReply<QNmSettingsMap> nmReply
- = d->connectionInterface->call(QLatin1String("GetSettings"));
+ = call(QLatin1String("GetSettings"));
if (!nmReply.isError()) {
- d->settingsMap = nmReply.value();
+ settingsMap = nmReply.value();
}
}
QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection()
{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerSettingsConnection::isValid()
-{
- return d->valid;
}
bool QNetworkManagerSettingsConnection::setConnections()
@@ -1072,16 +844,16 @@ bool QNetworkManagerSettingsConnection::setConnections()
QDBusConnection dbusConnection = QDBusConnection::systemBus();
bool allOk = true;
- if (!dbusConnection.connect(d->service,
- d->path,
+ if (!dbusConnection.connect(service(),
+ interfacepath,
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
QLatin1String("Updated"),
this, SIGNAL(updated()))) {
allOk = false;
}
- if (!dbusConnection.connect(d->service,
- d->path,
+ if (!dbusConnection.connect(service(),
+ interfacepath,
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
QLatin1String("Removed"),
this, SIGNAL(slotSettingsRemoved()))) {
@@ -1092,28 +864,23 @@ bool QNetworkManagerSettingsConnection::setConnections()
void QNetworkManagerSettingsConnection::slotSettingsRemoved()
{
- Q_EMIT removed(d->path);
-}
-
-QDBusInterface *QNetworkManagerSettingsConnection::connectionInterface() const
-{
- return d->connectionInterface;
+ Q_EMIT removed(interfacepath);
}
QNmSettingsMap QNetworkManagerSettingsConnection::getSettings()
{
- if (d->settingsMap.isEmpty()) {
+ if (settingsMap.isEmpty()) {
//qWarning() << "Using blocking call!";
- QDBusReply<QNmSettingsMap> reply = d->connectionInterface->call(QLatin1String("GetSettings"));
- d->settingsMap = reply.value();
+ QDBusReply<QNmSettingsMap> reply = call(QLatin1String("GetSettings"));
+ settingsMap = reply.value();
}
- return d->settingsMap;
+ return settingsMap;
}
NMDeviceType QNetworkManagerSettingsConnection::getType()
{
const QString devType =
- d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString();
+ settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString();
if (devType == QLatin1String("802-3-ethernet"))
return DEVICE_TYPE_ETHERNET;
@@ -1128,7 +895,7 @@ NMDeviceType QNetworkManagerSettingsConnection::getType()
bool QNetworkManagerSettingsConnection::isAutoConnect()
{
const QVariant autoConnect =
- d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("autoconnect"));
+ settingsMap.value(QLatin1String("connection")).value(QLatin1String("autoconnect"));
// NetworkManager default is to auto connect
if (!autoConnect.isValid())
@@ -1139,27 +906,27 @@ bool QNetworkManagerSettingsConnection::isAutoConnect()
quint64 QNetworkManagerSettingsConnection::getTimestamp()
{
- return d->settingsMap.value(QLatin1String("connection"))
+ return settingsMap.value(QLatin1String("connection"))
.value(QLatin1String("timestamp")).toUInt();
}
QString QNetworkManagerSettingsConnection::getId()
{
- return d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("id")).toString();
+ return settingsMap.value(QLatin1String("connection")).value(QLatin1String("id")).toString();
}
QString QNetworkManagerSettingsConnection::getUuid()
{
- const QString id = d->settingsMap.value(QLatin1String("connection"))
+ const QString id = settingsMap.value(QLatin1String("connection"))
.value(QLatin1String("uuid")).toString();
// is no uuid, return the connection path
- return id.isEmpty() ? d->connectionInterface->path() : id;
+ return id.isEmpty() ? path() : id;
}
QString QNetworkManagerSettingsConnection::getSsid()
{
- return d->settingsMap.value(QLatin1String("802-11-wireless"))
+ return settingsMap.value(QLatin1String("802-11-wireless"))
.value(QLatin1String("ssid")).toString();
}
@@ -1168,10 +935,10 @@ QString QNetworkManagerSettingsConnection::getMacAddress()
NMDeviceType type = getType();
if (type == DEVICE_TYPE_ETHERNET) {
- return d->settingsMap.value(QLatin1String("802-3-ethernet"))
+ return settingsMap.value(QLatin1String("802-3-ethernet"))
.value(QLatin1String("mac-address")).toString();
} else if (type == DEVICE_TYPE_WIFI) {
- return d->settingsMap.value(QLatin1String("802-11-wireless"))
+ return settingsMap.value(QLatin1String("802-11-wireless"))
.value(QLatin1String("mac-address")).toString();
} else {
return QString();
@@ -1181,36 +948,24 @@ QString QNetworkManagerSettingsConnection::getMacAddress()
QStringList QNetworkManagerSettingsConnection::getSeenBssids()
{
if (getType() == DEVICE_TYPE_WIFI) {
- return d->settingsMap.value(QLatin1String("802-11-wireless"))
+ return settingsMap.value(QLatin1String("802-11-wireless"))
.value(QLatin1String("seen-bssids")).toStringList();
} else {
return QStringList();
}
}
-class QNetworkManagerConnectionActivePrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString &activeConnectionObjectPath, QObject *parent)
- : QObject(parent)
-{
- d = new QNetworkManagerConnectionActivePrivate();
- d->path = activeConnectionObjectPath;
- d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
- QDBusConnection::systemBus(), parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
+ : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
+ activeConnectionObjectPath,
+ NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
+ QDBusConnection::systemBus(), parent)
+{
+ if (!isValid()) {
return;
}
- QDBusInterface connectionActivePropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
+ PropertiesDBusInterface connectionActivePropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
+ activeConnectionObjectPath,
QLatin1String("org.freedesktop.DBus.Properties"),
QDBusConnection::systemBus());
@@ -1228,35 +983,14 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString &
}
QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- d->path,
+ activeConnectionObjectPath,
QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
QLatin1String("PropertiesChanged"),
this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
- d->valid = true;
}
QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive()
{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerConnectionActive::isValid()
-{
- return d->valid;
-}
-
-bool QNetworkManagerConnectionActive::setConnections()
-{
- if (!isValid())
- return false;
-
- return true;
-}
-
-QDBusInterface *QNetworkManagerConnectionActive::connectionInterface() const
-{
- return d->connectionInterface;
}
QDBusObjectPath QNetworkManagerConnectionActive::connection() const
@@ -1327,44 +1061,24 @@ void QNetworkManagerConnectionActive::propertiesSwap(QMap<QString,QVariant> map)
}
}
-class QNetworkManagerIp4ConfigPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
QNetworkManagerIp4Config::QNetworkManagerIp4Config( const QString &deviceObjectPath, QObject *parent)
- : QObject(parent)
-{
- d = new QNetworkManagerIp4ConfigPrivate();
- d->path = deviceObjectPath;
- d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
- d->path,
- QLatin1String(NM_DBUS_INTERFACE_IP4_CONFIG),
- QDBusConnection::systemBus(), parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
+ : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
+ deviceObjectPath,
+ NM_DBUS_INTERFACE_IP4_CONFIG,
+ QDBusConnection::systemBus(), parent)
+{
+ if (!isValid()) {
return;
}
- d->valid = true;
}
QNetworkManagerIp4Config::~QNetworkManagerIp4Config()
{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerIp4Config::isValid()
-{
- return d->valid;
}
QStringList QNetworkManagerIp4Config::domains() const
{
- return d->connectionInterface->property("Domains").toStringList();
+ return property("Domains").toStringList();
}
QT_END_NAMESPACE
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
index e645159d71..f945532603 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
@@ -55,6 +55,7 @@
#include <QtDBus/QDBusPendingCallWatcher>
#include <QtDBus/QDBusObjectPath>
#include <QtDBus/QDBusContext>
+#include <QtDBus/QDBusAbstractInterface>
#include <QMap>
#ifndef QT_NO_DBUS
@@ -128,8 +129,7 @@ Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ServerThing))
QT_BEGIN_NAMESPACE
-class QNetworkManagerInterfacePrivate;
-class QNetworkManagerInterface : public QObject
+class QNetworkManagerInterface : public QDBusAbstractInterface
{
Q_OBJECT
@@ -151,10 +151,9 @@ public:
QList <QDBusObjectPath> getDevices();
void activateConnection(QDBusObjectPath connection,QDBusObjectPath device, QDBusObjectPath specificObject);
- void deactivateConnection(QDBusObjectPath connectionPath) const;
+ void deactivateConnection(QDBusObjectPath connectionPath);
QDBusObjectPath path() const;
- QDBusInterface *connectionInterface() const;
bool wirelessEnabled() const;
bool wirelessHardwareEnabled() const;
@@ -162,7 +161,6 @@ public:
NMState state();
QString version() const;
bool setConnections();
- bool isValid();
Q_SIGNALS:
void deviceAdded(QDBusObjectPath);
@@ -177,14 +175,12 @@ private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private:
- QNetworkManagerInterfacePrivate *d;
QVariantMap propertyMap;
QList<QDBusObjectPath> devicesPathList;
};
-class QNetworkManagerInterfaceAccessPointPrivate;
-class QNetworkManagerInterfaceAccessPoint : public QObject
+class QNetworkManagerInterfaceAccessPoint : public QDBusAbstractInterface
{
Q_OBJECT
@@ -229,8 +225,6 @@ public:
explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = 0);
~QNetworkManagerInterfaceAccessPoint();
- QDBusInterface *connectionInterface() const;
-
quint32 flags() const;
quint32 wpaFlags() const;
quint32 rsnFlags() const;
@@ -240,8 +234,7 @@ public:
quint32 mode() const;
quint32 maxBitrate() const;
quint32 strength() const;
- bool setConnections();
- bool isValid();
+ // bool setConnections();
Q_SIGNALS:
void propertiesChanged(QMap <QString,QVariant>);
@@ -251,12 +244,10 @@ private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private:
- QNetworkManagerInterfaceAccessPointPrivate *d;
QVariantMap propertyMap;
};
-class QNetworkManagerInterfaceDevicePrivate;
-class QNetworkManagerInterfaceDevice : public QObject
+class QNetworkManagerInterfaceDevice : public QDBusAbstractInterface
{
Q_OBJECT
@@ -267,14 +258,11 @@ public:
QString udi() const;
QString networkInterface() const;
- QDBusInterface *connectionInterface() const;
quint32 ip4Address() const;
quint32 state() const;
quint32 deviceType() const;
QDBusObjectPath ip4config() const;
- bool setConnections();
- bool isValid();
Q_SIGNALS:
void stateChanged(const QString &, quint32);
@@ -284,12 +272,10 @@ Q_SIGNALS:
private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private:
- QNetworkManagerInterfaceDevicePrivate *d;
QVariantMap propertyMap;
};
-class QNetworkManagerInterfaceDeviceWiredPrivate;
-class QNetworkManagerInterfaceDeviceWired : public QObject
+class QNetworkManagerInterfaceDeviceWired : public QDBusAbstractInterface
{
Q_OBJECT
@@ -299,12 +285,9 @@ public:
QObject *parent = 0);
~QNetworkManagerInterfaceDeviceWired();
- QDBusInterface *connectionInterface() const;
QString hwAddress() const;
quint32 speed() const;
bool carrier() const;
- bool setConnections();
- bool isValid();
QStringList availableConnections();
Q_SIGNALS:
@@ -316,12 +299,10 @@ private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private:
- QNetworkManagerInterfaceDeviceWiredPrivate *d;
QVariantMap propertyMap;
};
-class QNetworkManagerInterfaceDeviceWirelessPrivate;
-class QNetworkManagerInterfaceDeviceWireless : public QObject
+class QNetworkManagerInterfaceDeviceWireless : public QDBusAbstractInterface
{
Q_OBJECT
@@ -343,7 +324,6 @@ public:
QDBusObjectPath path() const;
QList <QDBusObjectPath> getAccessPoints();
- QDBusInterface *connectionInterface() const;
QString hwAddress() const;
quint32 mode() const;
@@ -351,7 +331,6 @@ public:
QDBusObjectPath activeAccessPoint() const;
quint32 wirelessCapabilities() const;
bool setConnections();
- bool isValid();
void requestScan();
Q_SIGNALS:
@@ -372,13 +351,12 @@ private Q_SLOTS:
void accessPointsFinished(QDBusPendingCallWatcher *watcher);
private:
- QNetworkManagerInterfaceDeviceWirelessPrivate *d;
QVariantMap propertyMap;
QList <QDBusObjectPath> accessPointsList;
+ QString interfacePath;
};
-class QNetworkManagerInterfaceDeviceModemPrivate;
-class QNetworkManagerInterfaceDeviceModem : public QObject
+class QNetworkManagerInterfaceDeviceModem : public QDBusAbstractInterface
{
Q_OBJECT
@@ -397,12 +375,6 @@ public:
QObject *parent = 0);
~QNetworkManagerInterfaceDeviceModem();
- QDBusObjectPath path() const;
- QDBusInterface *connectionInterface() const;
-
- bool setConnections();
- bool isValid();
-
ModemCapabilities modemCapabilities() const;
ModemCapabilities currentCapabilities() const;
@@ -414,14 +386,12 @@ private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private:
- QNetworkManagerInterfaceDeviceModemPrivate *d;
QVariantMap propertyMap;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkManagerInterfaceDeviceModem::ModemCapabilities)
-class QNetworkManagerSettingsPrivate;
-class QNetworkManagerSettings : public QObject
+class QNetworkManagerSettings : public QDBusAbstractInterface
{
Q_OBJECT
@@ -430,22 +400,19 @@ public:
explicit QNetworkManagerSettings(const QString &settingsService, QObject *parent = 0);
~QNetworkManagerSettings();
- QDBusInterface *connectionInterface() const;
QList <QDBusObjectPath> listConnections();
QString getConnectionByUuid(const QString &uuid);
bool setConnections();
- bool isValid();
Q_SIGNALS:
void newConnection(QDBusObjectPath);
void connectionsListReady();
private:
- QNetworkManagerSettingsPrivate *d;
QList <QDBusObjectPath> connectionsList;
+ QString interfacePath;
};
-class QNetworkManagerSettingsConnectionPrivate;
-class QNetworkManagerSettingsConnection : public QObject
+class QNetworkManagerSettingsConnection : public QDBusAbstractInterface
{
Q_OBJECT
@@ -454,7 +421,6 @@ public:
QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent = 0);
~QNetworkManagerSettingsConnection();
- QDBusInterface *connectionInterface() const;
QNmSettingsMap getSettings();
bool setConnections();
NMDeviceType getType();
@@ -465,7 +431,6 @@ public:
QString getSsid();
QString getMacAddress();
QStringList getSeenBssids();
- bool isValid();
Q_SIGNALS:
void updated();
@@ -474,13 +439,12 @@ Q_SIGNALS:
private Q_SLOTS:
void slotSettingsRemoved();
-
private:
- QNetworkManagerSettingsConnectionPrivate *d;
+ QNmSettingsMap settingsMap;
+ QString interfacepath;
};
-class QNetworkManagerConnectionActivePrivate;
-class QNetworkManagerConnectionActive : public QObject
+class QNetworkManagerConnectionActive : public QDBusAbstractInterface
{
Q_OBJECT
@@ -495,15 +459,12 @@ public:
explicit QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = 0);
~ QNetworkManagerConnectionActive();
- QDBusInterface *connectionInterface() const;
QDBusObjectPath connection() const;
QDBusObjectPath specificObject() const;
QStringList devices() const;
quint32 state() const;
bool defaultRoute() const;
bool default6Route() const;
- bool setConnections();
- bool isValid();
Q_SIGNALS:
@@ -514,12 +475,10 @@ private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private:
- QNetworkManagerConnectionActivePrivate *d;
QVariantMap propertyMap;
};
-class QNetworkManagerIp4ConfigPrivate;
-class QNetworkManagerIp4Config : public QObject
+class QNetworkManagerIp4Config : public QDBusAbstractInterface
{
Q_OBJECT
@@ -528,10 +487,17 @@ public:
~QNetworkManagerIp4Config();
QStringList domains() const;
- bool isValid();
+};
- private:
- QNetworkManagerIp4ConfigPrivate *d;
+class PropertiesDBusInterface : public QDBusAbstractInterface
+{
+public:
+ PropertiesDBusInterface(const QString &service, const QString &path,
+ const QString &interface, const QDBusConnection &connection,
+ QObject *parent = 0)
+ : QDBusAbstractInterface(service, path, interface.toLatin1().data(), connection, parent)
+ {}
+ ~PropertiesDBusInterface() = default;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index df0a8c56cb..ab653860f3 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -376,8 +376,6 @@ namespace QtAndroid
const auto &it = m_surfaces.find(surfaceId);
if (it != m_surfaces.end())
m_surfaces.remove(surfaceId);
- if (m_surfaces.isEmpty())
- m_surfaceId = 1;
QJNIEnvironmentPrivate env;
if (!env)
diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
index 5781f0d7c6..4c38178343 100644
--- a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
+++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
@@ -50,8 +50,10 @@ QAndroidPlatformOpenGLContext::QAndroidPlatformOpenGLContext(const QSurfaceForma
void QAndroidPlatformOpenGLContext::swapBuffers(QPlatformSurface *surface)
{
- if (surface->surface()->surfaceClass() == QSurface::Window)
- static_cast<QAndroidPlatformOpenGLWindow *>(surface)->checkNativeSurface(eglConfig());
+ if (surface->surface()->surfaceClass() == QSurface::Window &&
+ static_cast<QAndroidPlatformOpenGLWindow *>(surface)->checkNativeSurface(eglConfig())) {
+ QEGLPlatformContext::makeCurrent(surface);
+ }
QEGLPlatformContext::swapBuffers(surface);
}
diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
index 8dc8e84f0a..de7f1f6990 100644
--- a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
+++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
@@ -138,19 +138,19 @@ EGLSurface QAndroidPlatformOpenGLWindow::eglSurface(EGLConfig config)
return m_eglSurface;
}
-void QAndroidPlatformOpenGLWindow::checkNativeSurface(EGLConfig config)
+bool QAndroidPlatformOpenGLWindow::checkNativeSurface(EGLConfig config)
{
QMutexLocker lock(&m_surfaceMutex);
if (m_nativeSurfaceId == -1 || !m_androidSurfaceObject.isValid())
- return;
+ return false; // makeCurrent is NOT needed.
createEgl(config);
-
// we've create another surface, the window should be repainted
QRect availableGeometry = screen()->availableGeometry();
if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), geometry().size())));
+ return true; // makeCurrent is needed!
}
void QAndroidPlatformOpenGLWindow::applicationStateChanged(Qt::ApplicationState state)
@@ -209,15 +209,19 @@ void QAndroidPlatformOpenGLWindow::surfaceChanged(JNIEnv *jniEnv, jobject surfac
Q_UNUSED(jniEnv);
Q_UNUSED(w);
Q_UNUSED(h);
+
lockSurface();
m_androidSurfaceObject = surface;
- m_surfaceWaitCondition.wakeOne();
+ if (surface) // wait until we have a valid surface to draw into
+ m_surfaceWaitCondition.wakeOne();
unlockSurface();
- // repaint the window
- QRect availableGeometry = screen()->availableGeometry();
- if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
- QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), geometry().size())));
+ if (surface) {
+ // repaint the window, when we have a valid surface
+ QRect availableGeometry = screen()->availableGeometry();
+ if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
+ QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), geometry().size())));
+ }
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.h b/src/plugins/platforms/android/qandroidplatformopenglwindow.h
index 71787edee1..6d6548fc6a 100644
--- a/src/plugins/platforms/android/qandroidplatformopenglwindow.h
+++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.h
@@ -54,7 +54,7 @@ public:
EGLSurface eglSurface(EGLConfig config);
QSurfaceFormat format() const;
- void checkNativeSurface(EGLConfig config);
+ bool checkNativeSurface(EGLConfig config);
void applicationStateChanged(Qt::ApplicationState);
@@ -66,7 +66,7 @@ protected:
void clearEgl();
private:
- EGLDisplay m_eglDisplay;
+ EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
EGLSurface m_eglSurface = EGL_NO_SURFACE;
EGLNativeWindowType m_nativeWindow = nullptr;
diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp
index 940add3a38..a4e82a29ef 100644
--- a/src/plugins/platforms/android/qandroidplatformscreen.cpp
+++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp
@@ -391,7 +391,7 @@ Qt::ScreenOrientation QAndroidPlatformScreen::nativeOrientation() const
void QAndroidPlatformScreen::surfaceChanged(JNIEnv *env, jobject surface, int w, int h)
{
lockSurface();
- if (surface && w && h) {
+ if (surface && w > 0 && h > 0) {
releaseSurface();
m_nativeSurface = ANativeWindow_fromSurface(env, surface);
QMetaObject::invokeMethod(this, "setDirty", Qt::QueuedConnection, Q_ARG(QRect, QRect(0, 0, w, h)));
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index ffa616f968..c36634db74 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -48,7 +48,7 @@ class QCocoaBackingStore;
class QCocoaGLContext;
QT_END_NAMESPACE
-Q_FORWARD_DECLARE_OBJC_CLASS(QNSViewMouseMoveHelper);
+Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
@interface QT_MANGLE_NAMESPACE(QNSView) : NSView <NSTextInputClient> {
QImage m_backingStore;
@@ -72,7 +72,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QNSViewMouseMoveHelper);
bool m_shouldSetGLContextinDrawRect;
#endif
NSString *m_inputSource;
- QNSViewMouseMoveHelper *m_mouseMoveHelper;
+ QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) *m_mouseMoveHelper;
bool m_resendKeyEvent;
bool m_scrolling;
}
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 2f4dcd2a8c..9c24851115 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -83,7 +83,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
- (CGFloat)deviceDeltaZ;
@end
-@interface QNSViewMouseMoveHelper : NSObject
+@interface QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) : NSObject
{
QNSView *view;
}
@@ -97,7 +97,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
@end
-@implementation QNSViewMouseMoveHelper
+@implementation QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)
- (id)initWithView:(QNSView *)theView
{
@@ -158,7 +158,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
currentCustomDragTypes = 0;
m_sendUpAsRightButton = false;
m_inputSource = 0;
- m_mouseMoveHelper = [[QNSViewMouseMoveHelper alloc] initWithView:self];
+ m_mouseMoveHelper = [[QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) alloc] initWithView:self];
m_resendKeyEvent = false;
m_scrolling = false;
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index 76c02d939f..6e56f47954 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -75,9 +75,7 @@ static QUIView *focusView()
- (id)initWithQIOSInputContext:(QIOSInputContext *)context
{
- id originalSelf = self;
if (self = [super initWithTarget:self action:@selector(gestureStateChanged:)]) {
- Q_ASSERT(self == originalSelf);
m_context = context;
@@ -505,7 +503,22 @@ void QIOSInputContext::scroll(int y)
[rootView.layer addAnimation:animation forKey:@"AnimateSubLayerTransform"];
rootView.layer.sublayerTransform = translationTransform;
- [rootView.qtViewController updateProperties];
+ bool keyboardScrollIsActive = y != 0;
+
+ // Raise all known windows to above the status-bar if we're scrolling the screen,
+ // while keeping the relative window level between the windows the same.
+ NSArray *applicationWindows = [[UIApplication sharedApplication] windows];
+ static QHash<UIWindow *, UIWindowLevel> originalWindowLevels;
+ for (UIWindow *window in applicationWindows) {
+ if (keyboardScrollIsActive && !originalWindowLevels.contains(window))
+ originalWindowLevels.insert(window, window.windowLevel);
+
+ UIWindowLevel windowLevelAdjustment = keyboardScrollIsActive ? UIWindowLevelStatusBar : 0;
+ window.windowLevel = originalWindowLevels.value(window) + windowLevelAdjustment;
+
+ if (!keyboardScrollIsActive)
+ originalWindowLevels.remove(window);
+ }
}
completion:^(BOOL){
if (self) {
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 4af2a4965f..712bf0098b 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -46,6 +46,7 @@
#include <qpa/qwindowsysteminterface.h>
#include "qiosapplicationdelegate.h"
#include "qiosviewcontroller.h"
+#include "quiview.h"
#include <sys/sysctl.h>
@@ -244,6 +245,22 @@ void QIOSScreen::updateProperties()
m_geometry = fromCGRect([rootView convertRect:m_uiScreen.bounds fromView:m_uiWindow]).toRect();
m_availableGeometry = fromCGRect([rootView convertRect:m_uiScreen.applicationFrame fromView:m_uiWindow]).toRect();
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0 && ![m_uiWindow.rootViewController shouldAutorotate]) {
+ // Setting the statusbar orientation (content orientation) on iOS8+ will result in the UIScreen
+ // updating its geometry and available geometry, which in the case of content orientation is not
+ // what we want. We want to reflect the screen geometry based on the locked orientation, and
+ // adjust the available geometry based on the repositioned status bar for the current status
+ // bar orientation.
+
+ Qt::ScreenOrientation lockedOrientation = toQtScreenOrientation(UIDeviceOrientation(rootView.qtViewController.lockedOrientation));
+ Qt::ScreenOrientation contenOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation));
+
+ QTransform transform = screen()->transformBetween(lockedOrientation, contenOrientation, m_geometry).inverted();
+
+ m_geometry = transform.mapRect(m_geometry);
+ m_availableGeometry = transform.mapRect(m_availableGeometry);
+ }
+
if (m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry) {
const qreal millimetersPerInch = 25.4;
m_physicalSize = QSizeF(m_geometry.size()) / m_unscaledDpi * millimetersPerInch;
diff --git a/src/plugins/platforms/ios/qiostextresponder.h b/src/plugins/platforms/ios/qiostextresponder.h
index 118ab8958a..21b61bf8da 100644
--- a/src/plugins/platforms/ios/qiostextresponder.h
+++ b/src/plugins/platforms/ios/qiostextresponder.h
@@ -51,6 +51,7 @@ class QIOSInputContext;
QIOSInputContext *m_inputContext;
QString m_markedText;
BOOL m_inSendEventToFocusObject;
+ BOOL m_inSelectionChange;
}
- (id)initWithInputContext:(QIOSInputContext *)context;
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index bebc7577f8..15fade0838 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -171,6 +171,7 @@
return self;
m_inSendEventToFocusObject = NO;
+ m_inSelectionChange = NO;
m_inputContext = inputContext;
QVariantMap platformData = [self imValue:Qt::ImPlatformData].toMap();
@@ -302,6 +303,7 @@
return;
if (updatedProperties & (Qt::ImCursorPosition | Qt::ImAnchorPosition)) {
+ QScopedValueRollback<BOOL> rollback(m_inSelectionChange, true);
[self.inputDelegate selectionWillChange:self];
[self.inputDelegate selectionDidChange:self];
}
@@ -349,6 +351,15 @@
- (void)setSelectedTextRange:(UITextRange *)range
{
+ if (m_inSelectionChange) {
+ // After [UITextInputDelegate selectionWillChange], UIKit will cancel
+ // any ongoing auto correction (if enabled) and ask us to set an empty selection.
+ // This is contradictory to our current attempt to set a selection, so we ignore
+ // the callback. UIKit will be re-notified of the new selection after
+ // [UITextInputDelegate selectionDidChange].
+ return;
+ }
+
QUITextRange *r = static_cast<QUITextRange *>(range);
QList<QInputMethodEvent::Attribute> attrs;
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, r.range.location, r.range.length, 0);
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.h b/src/plugins/platforms/ios/qiosviewcontroller.h
index 586edd589d..df7ce0ff4a 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.h
+++ b/src/plugins/platforms/ios/qiosviewcontroller.h
@@ -35,15 +35,17 @@
class QIOSScreen;
-@interface QIOSViewController : UIViewController {
- QIOSScreen *m_screen;
-}
+@interface QIOSViewController : UIViewController
-@property (nonatomic, assign) BOOL changingOrientation;
+- (id)initWithQIOSScreen:(QIOSScreen *)screen;
+- (void)updateProperties;
+
+@property (nonatomic, assign) UIInterfaceOrientation lockedOrientation;
+
+// UIViewController
+@property (nonatomic, assign) BOOL shouldAutorotate;
@property (nonatomic, assign) BOOL prefersStatusBarHidden;
@property (nonatomic, assign) UIStatusBarAnimation preferredStatusBarUpdateAnimation;
-- (id)initWithQIOSScreen:(QIOSScreen *)screen;
-- (void)updateProperties;
@end
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm
index a2d81e3b6c..01bc84ae68 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.mm
+++ b/src/plugins/platforms/ios/qiosviewcontroller.mm
@@ -41,6 +41,8 @@
#import "qiosviewcontroller.h"
+#include <QtCore/qscopedvaluerollback.h>
+
#include <QtGui/QGuiApplication>
#include <QtGui/QWindow>
#include <QtGui/QScreen>
@@ -119,6 +121,13 @@
// -------------------------------------------------------------------------
+@interface QIOSViewController () {
+ QIOSScreen *m_screen;
+ BOOL m_updatingProperties;
+}
+@property (nonatomic, assign) BOOL changingOrientation;
+@end
+
@implementation QIOSViewController
- (id)initWithQIOSScreen:(QIOSScreen *)screen
@@ -147,6 +156,7 @@
#endif
self.changingOrientation = NO;
+ self.shouldAutorotate = [super shouldAutorotate];
// Status bar may be initially hidden at startup through Info.plist
self.prefersStatusBarHidden = infoPlistValue(@"UIStatusBarHidden", false);
@@ -173,6 +183,10 @@
[center addObserver:self selector:@selector(willChangeStatusBarFrame:)
name:UIApplicationWillChangeStatusBarFrameNotification
object:[UIApplication sharedApplication]];
+
+ [center addObserver:self selector:@selector(didChangeStatusBarOrientation:)
+ name:UIApplicationDidChangeStatusBarOrientationNotification
+ object:[UIApplication sharedApplication]];
}
- (void)viewDidUnload
@@ -183,19 +197,16 @@
// -------------------------------------------------------------------------
--(BOOL)shouldAutorotate
-{
- // Until a proper orientation and rotation API is in place, we always auto rotate.
- // If auto rotation is not wanted, you would need to switch it off manually from Info.plist.
- return YES;
-}
-
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_6_0)
-(NSUInteger)supportedInterfaceOrientations
{
- // We need to tell iOS that we support all orientations in order to set
- // status bar orientation when application content orientation changes.
- return UIInterfaceOrientationMaskAll;
+ // As documented by Apple in the iOS 6.0 release notes, setStatusBarOrientation:animated:
+ // only works if the supportedInterfaceOrientations of the view controller is 0, making
+ // us responsible for ensuring that the status bar orientation is consistent. We enter
+ // this mode when auto-rotation is disabled due to an explicit content orientation being
+ // set on the focus window. Note that this is counter to what the documentation for
+ // supportedInterfaceOrientations says, which states that the method should not return 0.
+ return [self shouldAutorotate] ? UIInterfaceOrientationMaskAll : 0;
}
#endif
@@ -203,7 +214,7 @@
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
Q_UNUSED(interfaceOrientation);
- return YES;
+ return [self shouldAutorotate];
}
#endif
@@ -250,6 +261,22 @@
}];
}
+- (void)didChangeStatusBarOrientation:(NSNotification *)notification
+{
+ Q_UNUSED(notification);
+
+ if (self.view.window.screen != [UIScreen mainScreen])
+ return;
+
+ // If the statusbar changes orientation due to auto-rotation we don't care,
+ // there will be re-layout anyways. Only if the statusbar changes due to
+ // reportContentOrientation, we need to update the window layout.
+ if (self.changingOrientation)
+ return;
+
+ [self.view setNeedsLayout];
+}
+
- (void)viewWillLayoutSubviews
{
if (!QCoreApplication::instance())
@@ -265,6 +292,15 @@
if (!isQtApplication())
return;
+ // Prevent recursion caused by updating the status bar appearance (position
+ // or visibility), which in turn may cause a layout of our subviews, and
+ // a reset of window-states, which themselves affect the view controller
+ // properties such as the statusbar visibilty.
+ if (m_updatingProperties)
+ return;
+
+ QScopedValueRollback<BOOL> updateRollback(m_updatingProperties, YES);
+
QWindow *focusWindow = QGuiApplication::focusWindow();
// If we don't have a focus window we leave the statusbar
@@ -281,14 +317,10 @@
// All decisions are based on the the top level window
focusWindow = qt_window_private(focusWindow)->topLevelWindow();
- bool hasScrolledRootViewDueToVirtualKeyboard =
- !CATransform3DIsIdentity(self.view.layer.sublayerTransform);
+ UIApplication *uiApplication = [UIApplication sharedApplication];
bool currentStatusBarVisibility = self.prefersStatusBarHidden;
- self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen
- || hasScrolledRootViewDueToVirtualKeyboard;
- self.preferredStatusBarUpdateAnimation = hasScrolledRootViewDueToVirtualKeyboard ?
- UIStatusBarAnimationFade : UIStatusBarAnimationNone;
+ self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen;
if (self.prefersStatusBarHidden != currentStatusBarVisibility) {
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0)
@@ -297,13 +329,60 @@
} else
#endif
{
- [[UIApplication sharedApplication]
- setStatusBarHidden:self.prefersStatusBarHidden
+ [uiApplication setStatusBarHidden:self.prefersStatusBarHidden
withAnimation:self.preferredStatusBarUpdateAnimation];
}
[self.view setNeedsLayout];
}
+
+
+ // -------------- Content orientation ---------------
+
+ static BOOL kAnimateContentOrientationChanges = YES;
+
+ Qt::ScreenOrientation contentOrientation = focusWindow->contentOrientation();
+ if (contentOrientation != Qt::PrimaryOrientation) {
+ // An explicit content orientation has been reported for the focus window,
+ // so we keep the status bar in sync with content orientation. This will ensure
+ // that the task bar (and associated gestures) are also rotated accordingly.
+
+ if (self.shouldAutorotate) {
+ // We are moving from Qt::PrimaryOrientation to an explicit orientation,
+ // so we need to store the current statusbar orientation, as we need it
+ // later when mapping screen coordinates for QScreen and for returning
+ // to Qt::PrimaryOrientation.
+ self.lockedOrientation = uiApplication.statusBarOrientation;
+
+ // Calling setStatusBarOrientation only has an effect when auto-rotation is
+ // disabled, which makes sense when there's an explicit content orientation.
+ self.shouldAutorotate = NO;
+ }
+
+ [uiApplication setStatusBarOrientation:
+ UIInterfaceOrientation(fromQtScreenOrientation(contentOrientation))
+ animated:kAnimateContentOrientationChanges];
+
+ } else {
+ // The content orientation is set to Qt::PrimaryOrientation, meaning
+ // that auto-rotation should be enabled. But we may be coming out of
+ // a state of locked orientation, which needs some cleanup before we
+ // can enable auto-rotation again.
+ if (!self.shouldAutorotate) {
+ // First we need to restore the statusbar to what it was at the
+ // time of locking the orientation, otherwise iOS will be very
+ // confused when it starts doing auto-rotation again.
+ [uiApplication setStatusBarOrientation:
+ UIInterfaceOrientation(self.lockedOrientation)
+ animated:kAnimateContentOrientationChanges];
+
+ // Then we can re-enable auto-rotation
+ self.shouldAutorotate = YES;
+
+ // And finally let iOS rotate the root view to match the device orientation
+ [UIViewController attemptRotationToDeviceOrientation];
+ }
+ }
}
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0)
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index 480062e4de..6c4614408d 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -75,6 +75,15 @@ QIOSWindow::QIOSWindow(QWindow *window)
setWindowState(window->windowState());
setOpacity(window->opacity());
+
+ Qt::ScreenOrientation initialOrientation = window->contentOrientation();
+ if (initialOrientation != Qt::PrimaryOrientation) {
+ // Start up in portrait, then apply possible content orientation,
+ // as per Apple's documentation.
+ dispatch_async(dispatch_get_main_queue(), ^{
+ handleContentOrientationChange(initialOrientation);
+ });
+ }
}
QIOSWindow::~QIOSWindow()
@@ -322,10 +331,12 @@ void QIOSWindow::updateWindowLevel()
void QIOSWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
{
- // Keep the status bar in sync with content orientation. This will ensure
- // that the task bar (and associated gestures) are aligned correctly:
- UIInterfaceOrientation uiOrientation = UIInterfaceOrientation(fromQtScreenOrientation(orientation));
- [[UIApplication sharedApplication] setStatusBarOrientation:uiOrientation animated:NO];
+ // Update the QWindow representation straight away, so that
+ // we can update the statusbar orientation based on the new
+ // content orientation.
+ qt_window_private(window())->contentOrientation = orientation;
+
+ [m_view.qtViewController updateProperties];
}
void QIOSWindow::applicationStateChanged(Qt::ApplicationState)
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index d10c7fdb20..9a42b7712d 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -126,13 +126,15 @@ HCURSOR QWindowsCursor::createPixmapCursor(const QPixmap &pixmap, const QPoint &
// Create a cursor from image and mask of the format QImage::Format_Mono.
static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
- QPoint hotSpot = QPoint(),
+ QPoint hotSpot = QPoint(-1, -1),
bool invb = false, bool invm = false)
{
const int width = bbits.width();
const int height = bbits.height();
- if (hotSpot.isNull())
- hotSpot = QPoint(width / 2, height / 2);
+ if (hotSpot.x() < 0)
+ hotSpot.setX(width / 2);
+ if (hotSpot.y() < 0)
+ hotSpot.setY(height / 2);
const int n = qMax(1, width / 8);
#if !defined(Q_OS_WINCE)
QScopedArrayPointer<uchar> xBits(new uchar[height * n]);
diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp
index fce60c3169..d3eb049269 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -626,7 +626,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState,
const QPlatformDropQtResponse response =
QWindowSystemInterface::handleDrop(m_window, windowsDrag->dropData(),
m_lastPoint / QWindowsScaling::factor(),
- translateToQDragDropActions(*pdwEffect));
+ translateToQDragDropActions(m_chosenEffect));
if (response.isAccepted()) {
const Qt::DropAction action = response.acceptedAction();
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
index f8747a741e..5c241b1fc8 100644
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
@@ -511,8 +511,9 @@ QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t,
const QTransform &xform)
{
glyph_metrics_t metrics = QFontEngine::boundingBox(t, xform);
- int width = (metrics.width + margin * 2 + 4).ceil().toInt() ;
- int height = (metrics.height + margin * 2 + 4).ceil().toInt();
+ // This needs to be kept in sync with alphaMapBoundingBox
+ int width = (metrics.width + margin * 2).ceil().toInt() ;
+ int height = (metrics.height + margin * 2).ceil().toInt();
UINT16 glyphIndex = t;
FLOAT glyphAdvance = metrics.xoff.toReal();
@@ -695,6 +696,18 @@ QString QWindowsFontEngineDirectWrite::fontNameSubstitute(const QString &familyN
return QSettings(QLatin1String(keyC), QSettings::NativeFormat).value(familyName, familyName).toString();
}
+glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph, QFixed pos, const QTransform &matrix, GlyphFormat format)
+{
+ Q_UNUSED(pos);
+ int margin = 0;
+ if (format == QFontEngine::Format_A32 || format == QFontEngine::Format_ARGB)
+ margin = glyphMargin(QFontEngine::Format_A32);
+ glyph_metrics_t gm = QFontEngine::boundingBox(glyph, matrix);
+ gm.width += margin * 2;
+ gm.height += margin * 2;
+ return gm;
+}
+
QT_END_NAMESPACE
#endif // QT_NO_DIRECTWRITE
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h
index 2addb90de3..e0466c138d 100644
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h
+++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h
@@ -75,6 +75,7 @@ public:
glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
glyph_metrics_t boundingBox(glyph_t g);
+ glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed, const QTransform &matrix, GlyphFormat);
QFixed ascent() const;
QFixed descent() const;
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index b7de580c44..5d94ec3c38 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -1298,21 +1298,7 @@ void QWindowsWindow::setGeometryDp(const QRect &rectIn)
const QMargins margins = frameMarginsDp();
rect.moveTopLeft(rect.topLeft() + QPoint(margins.left(), margins.top()));
}
- const QSize oldSize = m_data.geometry.size();
m_data.geometry = rect;
- const QSize newSize = rect.size();
- // Check on hint.
- if (newSize != oldSize) {
- const QWindowsGeometryHint hint(window(), m_data.customMargins);
- if (!hint.validSize(newSize)) {
- qWarning("%s: Attempt to set a size (%dx%d) violating the constraints"
- "(%dx%d - %dx%d) on window %s/'%s'.", __FUNCTION__,
- newSize.width(), newSize.height(),
- hint.minimumSize.width(), hint.minimumSize.height(),
- hint.maximumSize.width(), hint.maximumSize.height(),
- window()->metaObject()->className(), qPrintable(window()->objectName()));
- }
- }
if (m_data.hwnd) {
// A ResizeEvent with resulting geometry will be sent. If we cannot
// achieve that size (for example, window title minimal constraint),
@@ -1625,17 +1611,6 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
setFlag(FrameDirty);
- if ((oldState == Qt::WindowMaximized) != (newState == Qt::WindowMaximized)) {
- if (visible && !(newState == Qt::WindowMinimized)) {
- setFlag(WithinMaximize);
- if (newState == Qt::WindowFullScreen)
- setFlag(MaximizeToFullScreen);
- ShowWindow(m_data.hwnd, (newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE);
- clearFlag(WithinMaximize);
- clearFlag(MaximizeToFullScreen);
- }
- }
-
if ((oldState == Qt::WindowFullScreen) != (newState == Qt::WindowFullScreen)) {
#ifdef Q_OS_WINCE
HWND handle = FindWindow(L"HHTaskBar", L"");
@@ -1715,6 +1690,15 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
m_savedStyle = 0;
m_savedFrameGeometry = QRect();
}
+ } else if ((oldState == Qt::WindowMaximized) != (newState == Qt::WindowMaximized)) {
+ if (visible && !(newState == Qt::WindowMinimized)) {
+ setFlag(WithinMaximize);
+ if (newState == Qt::WindowFullScreen)
+ setFlag(MaximizeToFullScreen);
+ ShowWindow(m_data.hwnd, (newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE);
+ clearFlag(WithinMaximize);
+ clearFlag(MaximizeToFullScreen);
+ }
}
if ((oldState == Qt::WindowMinimized) != (newState == Qt::WindowMinimized)) {
@@ -1761,6 +1745,8 @@ void QWindowsWindow::windowEvent(QEvent *event)
case QEvent::WindowBlocked: // Blocked by another modal window.
setEnabled(false);
setFlag(BlockedByModal);
+ if (hasMouseCapture())
+ ReleaseCapture();
break;
case QEvent::WindowUnblocked:
setEnabled(true);
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index 74d73d7cdf..bbde948090 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -181,8 +181,6 @@ void QXcbShmImage::destroy()
if (segmentSize && m_shm_info.shmaddr)
Q_XCB_CALL(xcb_shm_detach(xcb_connection(), m_shm_info.shmseg));
- xcb_image_destroy(m_xcb_image);
-
if (segmentSize) {
if (m_shm_info.shmaddr) {
shmdt(m_shm_info.shmaddr);
@@ -192,6 +190,8 @@ void QXcbShmImage::destroy()
}
}
+ xcb_image_destroy(m_xcb_image);
+
if (m_gc)
Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc));
delete m_graphics_buffer;
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 956b0f83d2..05035a5b1e 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -71,7 +71,8 @@ static int resourceType(const QByteArray &key)
QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"),
QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"),
QByteArrayLiteral("rootwindow"),
- QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled")
+ QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled"),
+ QByteArrayLiteral("nofonthinting")
};
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key);
@@ -281,6 +282,9 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceStr
case GetTimestamp:
result = getTimestamp(xcbScreen);
break;
+ case NoFontHinting:
+ result = xcbScreen->noFontHinting() ? this : 0; //qboolptr...
+ break;
default:
break;
}
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index b2044e6ee9..1db2d1cf83 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -65,7 +65,8 @@ public:
X11Screen,
RootWindow,
ScreenSubpixelType,
- ScreenAntialiasingEnabled
+ ScreenAntialiasingEnabled,
+ NoFontHinting
};
QXcbNativeInterface();
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index def6e2ce9a..0f25d10aac 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -53,7 +53,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr,
, m_screen(scr)
, m_crtc(output ? output->crtc : 0)
, m_outputName(outputName)
- , m_sizeMillimeters(output ? QSize(output->mm_width, output->mm_height) : QSize())
+ , m_outputSizeMillimeters(output ? QSize(output->mm_width, output->mm_height) : QSize())
, m_virtualSize(scr->width_in_pixels, scr->height_in_pixels)
, m_virtualSizeMillimeters(scr->width_in_millimeters, scr->height_in_millimeters)
, m_orientation(Qt::PrimaryOrientation)
@@ -62,6 +62,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr,
, m_forcedDpi(-1)
, m_devicePixelRatio(1)
, m_hintStyle(QFontEngine::HintStyle(-1))
+ , m_noFontHinting(false)
, m_subpixelType(QFontEngine::SubpixelAntialiasingType(-1))
, m_antialiasingEnabled(-1)
, m_xSettings(0)
@@ -71,18 +72,27 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr,
updateGeometry(output ? output->timestamp : 0);
updateRefreshRate();
+
const int dpr = int(devicePixelRatio());
// On VNC, it can be that physical size is unknown while
// virtual size is known (probably back-calculated from DPI and resolution)
if (m_sizeMillimeters.isEmpty())
m_sizeMillimeters = m_virtualSizeMillimeters;
- if (m_geometry.isEmpty())
+ if (m_geometry.isEmpty()) {
m_geometry = QRect(QPoint(), m_virtualSize/dpr);
+ m_nativeGeometry = QRect(QPoint(), m_virtualSize);
+ }
if (m_availableGeometry.isEmpty())
m_availableGeometry = m_geometry;
readXResources();
+ // disable font hinting when we do UI scaling
+ static bool dpr_scaling_enabled = (qgetenv("QT_DEVICE_PIXEL_RATIO").toInt() > 1
+ || qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto");
+ 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);
@@ -93,6 +103,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *scr,
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);
@@ -313,8 +324,14 @@ QDpi QXcbScreen::logicalDpi() const
if (m_forcedDpi > 0)
return QDpi(m_forcedDpi/dpr, m_forcedDpi/dpr);
- return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width() / dpr,
- Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height() / dpr);
+ static const bool auto_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto";
+ if (auto_dpr) {
+ return QDpi(Q_MM_PER_INCH * m_geometry.width() / m_sizeMillimeters.width(),
+ Q_MM_PER_INCH * m_geometry.height() / m_sizeMillimeters.height());
+ } else {
+ return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width() / dpr,
+ Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height() / dpr);
+ }
}
@@ -413,6 +430,24 @@ void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp)
if (crtc) {
xGeometry = QRect(crtc->x, crtc->y, crtc->width, crtc->height);
xAvailableGeometry = xGeometry;
+ switch (crtc->rotation) {
+ case XCB_RANDR_ROTATION_ROTATE_0: // xrandr --rotate normal
+ m_orientation = Qt::LandscapeOrientation;
+ m_sizeMillimeters = m_outputSizeMillimeters;
+ break;
+ case XCB_RANDR_ROTATION_ROTATE_90: // xrandr --rotate left
+ m_orientation = Qt::PortraitOrientation;
+ m_sizeMillimeters = m_outputSizeMillimeters.transposed();
+ break;
+ case XCB_RANDR_ROTATION_ROTATE_180: // xrandr --rotate inverted
+ m_orientation = Qt::InvertedLandscapeOrientation;
+ m_sizeMillimeters = m_outputSizeMillimeters;
+ break;
+ case XCB_RANDR_ROTATION_ROTATE_270: // xrandr --rotate right
+ m_orientation = Qt::InvertedPortraitOrientation;
+ m_sizeMillimeters = m_outputSizeMillimeters.transposed();
+ break;
+ }
free(crtc);
}
}
@@ -441,6 +476,7 @@ void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp)
m_devicePixelRatio = qRound(dpi/96);
const int dpr = int(devicePixelRatio()); // we may override m_devicePixelRatio
m_geometry = QRect(xGeometry.topLeft()/dpr, xGeometry.size()/dpr);
+ m_nativeGeometry = QRect(xGeometry.topLeft(), xGeometry.size());
m_availableGeometry = QRect(xAvailableGeometry.topLeft()/dpr, xAvailableGeometry.size()/dpr);
QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry);
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index 4d0ae9847a..652d64c105 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -63,6 +63,7 @@ public:
QWindow *topLevelAt(const QPoint &point) const Q_DECL_OVERRIDE;
QRect geometry() const Q_DECL_OVERRIDE { return m_geometry; }
+ QRect nativeGeometry() const { return m_nativeGeometry; }
QRect availableGeometry() const Q_DECL_OVERRIDE {return m_availableGeometry;}
int depth() const Q_DECL_OVERRIDE { return m_screen->root_depth; }
QImage::Format format() const Q_DECL_OVERRIDE;
@@ -98,6 +99,7 @@ public:
void readXResources();
QFontEngine::HintStyle hintStyle() const { return m_hintStyle; }
+ bool noFontHinting() const { return m_noFontHinting; }
QFontEngine::SubpixelAntialiasingType subpixelType() const { return m_subpixelType; }
int antialiasingEnabled() const { return m_antialiasingEnabled; }
@@ -112,8 +114,10 @@ private:
xcb_screen_t *m_screen;
xcb_randr_crtc_t m_crtc;
QString m_outputName;
+ QSizeF m_outputSizeMillimeters;
QSizeF m_sizeMillimeters;
QRect m_geometry;
+ QRect m_nativeGeometry;
QRect m_availableGeometry;
QSize m_virtualSize;
QSizeF m_virtualSizeMillimeters;
@@ -130,6 +134,7 @@ private:
int m_forcedDpi;
int m_devicePixelRatio;
QFontEngine::HintStyle m_hintStyle;
+ bool m_noFontHinting;
QFontEngine::SubpixelAntialiasingType m_subpixelType;
int m_antialiasingEnabled;
QXcbXSettings *m_xSettings;
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 4d14dd14a3..4676133777 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -142,7 +142,7 @@ static inline QRect mapToNative(const QRect &qtRect, int dpr)
return QRect(qtRect.x() * dpr, qtRect.y() * dpr, qtRect.width() * dpr, qtRect.height() * dpr);
}
-// When converting native rects to Qt rects: round top/left towards the origin and
+// When mapping expose events to Qt rects: round top/left towards the origin and
// bottom/right away from the origin, making sure that we cover the whole widget
static inline QPoint dpr_floor(const QPoint &p, int dpr)
@@ -155,11 +155,15 @@ static inline QPoint dpr_ceil(const QPoint &p, int dpr)
return QPoint((p.x() + dpr - 1) / dpr, (p.y() + dpr - 1) / dpr);
}
-static inline QRect mapFromNative(const QRect &xRect, int dpr)
+static inline QRect mapExposeFromNative(const QRect &xRect, int dpr)
{
return QRect(dpr_floor(xRect.topLeft(), dpr), dpr_ceil(xRect.bottomRight(), dpr));
}
+static inline QRect mapGeometryFromNative(const QRect &xRect, int dpr)
+{
+ return QRect(xRect.topLeft() / dpr, xRect.bottomRight() / dpr);
+}
// Returns \c true if we should set WM_TRANSIENT_FOR on \a w
static inline bool isTransient(const QWindow *w)
@@ -1670,7 +1674,7 @@ public:
return false;
if (expose->count == 0)
m_pending = false;
- *m_region |= mapFromNative(QRect(expose->x, expose->y, expose->width, expose->height), m_dpr);
+ *m_region |= mapExposeFromNative(QRect(expose->x, expose->y, expose->width, expose->height), m_dpr);
return true;
}
@@ -1698,7 +1702,7 @@ void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event)
{
const int dpr = int(devicePixelRatio());
QRect x_rect(event->x, event->y, event->width, event->height);
- QRect rect = mapFromNative(x_rect, dpr);
+ QRect rect = mapExposeFromNative(x_rect, dpr);
if (m_exposeRegion.isEmpty())
m_exposeRegion = rect;
@@ -1783,6 +1787,23 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even
}
}
+// Temporary workaround for bug in QPlatformScreen::screenForNativeGeometry
+// we need the native geometries to detect our screen, but that's not
+// available in cross-platform code. Will be fixed properly when highDPI
+// support is refactored to expose the native coordinate system.
+
+QPlatformScreen *QXcbWindow::screenForNativeGeometry(const QRect &newGeometry) const
+{
+ QXcbScreen *currentScreen = static_cast<QXcbScreen*>(screen());
+ if (!parent() && !currentScreen->nativeGeometry().intersects(newGeometry)) {
+ Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) {
+ if (static_cast<QXcbScreen*>(screen)->nativeGeometry().intersects(newGeometry))
+ return screen;
+ }
+ }
+ return currentScreen;
+}
+
void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event)
{
bool fromSendEvent = (event->response_type & 0x80);
@@ -1799,15 +1820,23 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
}
}
- QRect rect = mapFromNative(QRect(pos, QSize(event->width, event->height)), int(devicePixelRatio()));
+ const int dpr = devicePixelRatio();
+ const QRect nativeRect = QRect(pos, QSize(event->width, event->height));
+ const QRect rect = mapGeometryFromNative(nativeRect, dpr);
QPlatformWindow::setGeometry(rect);
QWindowSystemInterface::handleGeometryChange(window(), rect);
- QPlatformScreen *newScreen = screenForGeometry(rect);
+ QPlatformScreen *newScreen = screenForNativeGeometry(nativeRect);
if (newScreen != m_screen) {
m_screen = static_cast<QXcbScreen*>(newScreen);
QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen());
+ int newDpr = devicePixelRatio();
+ if (newDpr != dpr) {
+ QRect newRect = mapGeometryFromNative(nativeRect, newDpr);
+ QPlatformWindow::setGeometry(newRect);
+ QWindowSystemInterface::handleGeometryChange(window(), newRect);
+ }
}
m_configureNotifyPending = false;
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index 340070e882..b78bf779d0 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -151,6 +151,8 @@ public:
virtual void create();
virtual void destroy();
+ QPlatformScreen *screenForNativeGeometry(const QRect &newGeometry) const;
+
public Q_SLOTS:
void updateSyncRequestCounter();
diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp
index 13d42832db..a1dadb0e54 100644
--- a/src/plugins/platforms/xcb/qxcbxsettings.cpp
+++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp
@@ -36,7 +36,9 @@
#include <QtCore/QByteArray>
#include <QtCore/QtEndian>
+#ifdef XCB_USE_XLIB
#include <X11/extensions/XIproto.h>
+#endif //XCB_USE_XLIB
QT_BEGIN_NAMESPACE
/* Implementation of http://standards.freedesktop.org/xsettings-spec/xsettings-0.5.html */
@@ -138,6 +140,7 @@ public:
return value + 4 - remainder;
}
+#ifdef XCB_USE_XLIB
void populateSettings(const QByteArray &xSettings)
{
if (xSettings.length() < 12)
@@ -212,6 +215,7 @@ public:
}
}
+#endif //XCB_USE_XLIB
QXcbScreen *screen;
xcb_window_t x_settings_window;
@@ -258,8 +262,10 @@ QXcbXSettings::QXcbXSettings(QXcbScreen *screen)
const uint32_t event_mask[] = { XCB_EVENT_MASK_STRUCTURE_NOTIFY|XCB_EVENT_MASK_PROPERTY_CHANGE };
xcb_change_window_attributes(screen->xcb_connection(),d_ptr->x_settings_window,event,event_mask);
+#ifdef XCB_USE_XLIB
d_ptr->populateSettings(d_ptr->getSettings());
d_ptr->initialized = true;
+#endif //XCB_USE_XLIB
}
QXcbXSettings::~QXcbXSettings()
@@ -279,7 +285,9 @@ void QXcbXSettings::handlePropertyNotifyEvent(const xcb_property_notify_event_t
Q_D(QXcbXSettings);
if (event->window != d->x_settings_window)
return;
+#ifdef XCB_USE_XLIB
d->populateSettings(d->getSettings());
+#endif //XCB_USE_XLIB
}
void QXcbXSettings::registerCallbackForProperty(const QByteArray &property, QXcbXSettings::PropertyChangeFunc func, void *handle)
diff --git a/src/printsupport/kernel/qprint_p.h b/src/printsupport/kernel/qprint_p.h
index 504a0d6e20..ebb165190e 100644
--- a/src/printsupport/kernel/qprint_p.h
+++ b/src/printsupport/kernel/qprint_p.h
@@ -143,7 +143,7 @@ namespace QPrint {
QPrint::OutputBinId id;
};
-};
+}
struct InputSlotMap {
QPrint::InputSlotId id;
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index 4e0a3e0795..69f74ef775 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -931,6 +931,8 @@ void QWin32PrintEnginePrivate::initHDC()
default:
break;
}
+
+ updateMetrics();
}
void QWin32PrintEnginePrivate::release()
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index 437a68e609..8ed2732c1e 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -1224,7 +1224,10 @@ void QPrinter::setPageSize(PageSize newPageSize)
void QPrinter::setPaperSize(const QSizeF &paperSize, QPrinter::Unit unit)
{
- setPageSize(QPageSize(paperSize, QPageSize::Unit(unit)));
+ if (unit == QPrinter::DevicePixel)
+ setPageSize(QPageSize(paperSize * qt_pixelMultiplier(resolution()), QPageSize::Point));
+ else
+ setPageSize(QPageSize(paperSize, QPageSize::Unit(unit)));
}
/*!
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index d9b31c7702..9462df8f97 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -393,10 +393,20 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni
colSize*sizeof(SQLTCHAR),
&lengthIndicator);
if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
- if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) {
+ if (lengthIndicator == SQL_NULL_DATA) {
fieldVal.clear();
break;
}
+ // starting with ODBC Native Client 2012, SQL_NO_TOTAL is returned
+ // instead of the length (which sometimes was wrong in older versions)
+ // see link for more info: http://msdn.microsoft.com/en-us/library/jj219209.aspx
+ // if length indicator equals SQL_NO_TOTAL, indicating that
+ // more data can be fetched, but size not known, collect data
+ // and fetch next block
+ if (lengthIndicator == SQL_NO_TOTAL) {
+ fieldVal += fromSQLTCHAR(buf, colSize);
+ continue;
+ }
// if SQL_SUCCESS_WITH_INFO is returned, indicating that
// more data can be fetched, the length indicator does NOT
// contain the number of bytes returned - it contains the
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index 52b96a5456..455e1f46ca 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -426,11 +426,8 @@ QVariant QPSQLResult::data(int i)
#ifndef QT_NO_DATESTRING
if (str.isEmpty())
return QVariant(QTime());
- if (str.at(str.length() - 3) == QLatin1Char('+') || str.at(str.length() - 3) == QLatin1Char('-'))
- // strip the timezone
- // TODO: fix this when timestamp support comes into QDateTime
- return QVariant(QTime::fromString(str.left(str.length() - 3), Qt::ISODate));
- return QVariant(QTime::fromString(str, Qt::ISODate));
+ else
+ return QVariant(QTime::fromString(str, Qt::ISODate));
#else
return QVariant(str);
#endif
@@ -438,19 +435,13 @@ QVariant QPSQLResult::data(int i)
case QVariant::DateTime: {
QString dtval = QString::fromLatin1(val);
#ifndef QT_NO_DATESTRING
- if (dtval.length() < 10)
- return QVariant(QDateTime());
- // remove the timezone
- // TODO: fix this when timestamp support comes into QDateTime
- if (dtval.at(dtval.length() - 3) == QLatin1Char('+') || dtval.at(dtval.length() - 3) == QLatin1Char('-'))
- dtval.chop(3);
- // milliseconds are sometimes returned with 2 digits only
- if (dtval.at(dtval.length() - 3).isPunct())
- dtval += QLatin1Char('0');
- if (dtval.isEmpty())
+ if (dtval.length() < 10) {
return QVariant(QDateTime());
- else
- return QVariant(QDateTime::fromString(dtval, Qt::ISODate));
+ } else {
+ QChar sign = dtval[dtval.size() - 3];
+ if (sign == QLatin1Char('-') || sign == QLatin1Char('+')) dtval += QLatin1String(":00");
+ return QVariant(QDateTime::fromString(dtval, Qt::ISODate).toLocalTime());
+ }
#else
return QVariant(dtval);
#endif
@@ -536,6 +527,11 @@ QSqlRecord QPSQLResult::record() const
int precision = PQfmod(d->result, i);
switch (ptype) {
+ case QTIMESTAMPOID:
+ case QTIMESTAMPTZOID:
+ precision = 3;
+ break;
+
case QNUMERICOID:
if (precision != -1) {
len = (precision >> 16);
@@ -1263,15 +1259,10 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
case QVariant::DateTime:
#ifndef QT_NO_DATESTRING
if (field.value().toDateTime().isValid()) {
- QDate dt = field.value().toDateTime().date();
- QTime tm = field.value().toDateTime().time();
- // msecs need to be right aligned otherwise psql interprets them wrong
- r = QLatin1Char('\'') + QString::number(dt.year()) + QLatin1Char('-')
- + QString::number(dt.month()).rightJustified(2, QLatin1Char('0')) + QLatin1Char('-')
- + QString::number(dt.day()).rightJustified(2, QLatin1Char('0')) + QLatin1Char(' ')
- + tm.toString() + QLatin1Char('.')
- + QString::number(tm.msec()).rightJustified(3, QLatin1Char('0'))
- + QLatin1Char('\'');
+ // we force the value to be considered with a timezone information, and we force it to be UTC
+ // this is safe since postgresql stores only the UTC value and not the timezone offset (only used
+ // while parsing), so we have correct behavior in both case of with timezone and without tz
+ r = QLatin1String("TIMESTAMP WITH TIME ZONE ") + QLatin1Char('\'') + field.value().toDateTime().toUTC().toString(QLatin1String("yyyy-MM-ddThh:mm:ss.zzz")) + QLatin1Char('Z') + QLatin1Char('\'');
} else {
r = QLatin1String("NULL");
}
diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp
index 98e262a7e2..2808587d96 100644
--- a/src/sql/kernel/qsqlquery.cpp
+++ b/src/sql/kernel/qsqlquery.cpp
@@ -1060,6 +1060,7 @@ bool QSqlQuery::exec()
*/
bool QSqlQuery::execBatch(BatchExecutionMode mode)
{
+ d->sqlResult->resetBindCount();
return d->sqlResult->execBatch(mode == ValuesAsColumns);
}
diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h
index 889798e862..5bf3760f66 100644
--- a/src/testlib/qbenchmark_p.h
+++ b/src/testlib/qbenchmark_p.h
@@ -105,6 +105,7 @@ public:
QBenchmarkResult()
: value(-1)
, iterations(-1)
+ , metric(QTest::FramesPerSecond)
, setByMacro(true)
, valid(false)
{ }
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 40d9eac46d..0c00e47afc 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -91,8 +91,7 @@ template<> inline char *toString(const QDate &date)
template<> inline char *toString(const QDateTime &dateTime)
{
return dateTime.isValid()
- ? qstrdup(qPrintable(dateTime.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")) +
- (dateTime.timeSpec() == Qt::LocalTime ? QLatin1String("[local time]") : QLatin1String("[UTC]"))))
+ ? qstrdup(qPrintable(dateTime.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz[t]"))))
: qstrdup("Invalid QDateTime");
}
#endif // QT_NO_DATESTRING
diff --git a/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc b/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc
index 446b441675..9f5ef59e94 100644
--- a/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc
+++ b/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc
@@ -805,7 +805,7 @@
{QWidget::addAction}().
\endquotation
- If you don't include the function name with the \b{\\overlaod}
+ If you don't include the function name with the \b{\\overload}
command, then instead of the "This function overloads..." line
with the link to the documentation for the primary version, you
get the old standard line:
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index aa1b4b1023..5fffe61877 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -57,6 +57,7 @@
#include "qdialogbuttonbox.h"
#include "qscreen.h"
#include "qcursor.h"
+#include "qtimer.h"
#include <algorithm>
@@ -1539,8 +1540,18 @@ void QColorDialogPrivate::_q_pickScreenColor()
#else
q->grabMouse();
#endif
+
+#ifdef Q_OS_WIN32 // excludes WinCE and WinRT
+ // On Windows mouse tracking doesn't work over other processes's windows
+ updateTimer->start(30);
+
+ // HACK: Because mouse grabbing doesn't work across processes, we have to have a dummy,
+ // invisible window to catch the mouse click, otherwise we will click whatever we clicked
+ // and loose focus.
+ dummyTransparentWindow.show();
+#endif
q->grabKeyboard();
- /* With setMouseTracking(true) the desired color can be more precisedly picked up,
+ /* With setMouseTracking(true) the desired color can be more precisely picked up,
* and continuously pushing the mouse button is not necessary.
*/
q->setMouseTracking(true);
@@ -1567,6 +1578,10 @@ void QColorDialogPrivate::releaseColorPicking()
cp->setCrossVisible(true);
q->removeEventFilter(colorPickingEventFilter);
q->releaseMouse();
+#ifdef Q_OS_WIN32
+ updateTimer->stop();
+ dummyTransparentWindow.setVisible(false);
+#endif
q->releaseKeyboard();
q->setMouseTracking(false);
lblScreenColorInfo->setText(QLatin1String("\n"));
@@ -1593,6 +1608,10 @@ void QColorDialogPrivate::init(const QColor &initial)
#ifdef Q_WS_MAC
delegate = 0;
#endif
+#ifdef Q_OS_WIN32
+ dummyTransparentWindow.resize(1, 1);
+ dummyTransparentWindow.setFlags(Qt::Tool | Qt::FramelessWindowHint);
+#endif
q->setCurrentColor(initial);
}
@@ -1733,6 +1752,10 @@ void QColorDialogPrivate::initWidgets()
cancel = buttons->addButton(QDialogButtonBox::Cancel);
QObject::connect(cancel, SIGNAL(clicked()), q, SLOT(reject()));
+#ifdef Q_OS_WIN32
+ updateTimer = new QTimer(q);
+ QObject::connect(updateTimer, SIGNAL(timeout()), q, SLOT(_q_updateColorPicking()));
+#endif
retranslateStrings();
}
@@ -2138,18 +2161,41 @@ void QColorDialog::changeEvent(QEvent *e)
QDialog::changeEvent(e);
}
-bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e)
+void QColorDialogPrivate::_q_updateColorPicking()
{
- // If the cross is visible the grabbed color will be black most of the times
- cp->setCrossVisible(!cp->geometry().contains(e->pos()));
+#ifndef QT_NO_CURSOR
+ Q_Q(QColorDialog);
+ static QPoint lastGlobalPos;
+ QPoint newGlobalPos = QCursor::pos();
+ if (lastGlobalPos == newGlobalPos)
+ return;
+ lastGlobalPos = newGlobalPos;
- const QPoint globalPos = e->globalPos();
+ if (!q->rect().contains(q->mapFromGlobal(newGlobalPos))) { // Inside the dialog mouse tracking works, handleColorPickingMouseMove will be called
+ updateColorPicking(newGlobalPos);
+#ifdef Q_OS_WIN32
+ dummyTransparentWindow.setPosition(newGlobalPos);
+#endif
+ }
+#endif // ! QT_NO_CURSOR
+}
+
+void QColorDialogPrivate::updateColorPicking(const QPoint &globalPos)
+{
const QColor color = grabScreenColor(globalPos);
// QTBUG-39792, do not change standard, custom color selectors while moving as
// otherwise it is not possible to pre-select a custom cell for assignment.
setCurrentColor(color, ShowColor);
updateColorLabelText(globalPos);
+}
+
+bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e)
+{
+ // If the cross is visible the grabbed color will be black most of the times
+ cp->setCrossVisible(!cp->geometry().contains(e->pos()));
+
+ updateColorPicking(e->globalPos());
return true;
}
diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h
index 22ff907e7a..87e62be81f 100644
--- a/src/widgets/dialogs/qcolordialog.h
+++ b/src/widgets/dialogs/qcolordialog.h
@@ -112,6 +112,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int))
Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int))
Q_PRIVATE_SLOT(d_func(), void _q_pickScreenColor())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateColorPicking())
friend class QColorShower;
};
diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h
index 7e6c8b1231..cf8bb33d94 100644
--- a/src/widgets/dialogs/qcolordialog_p.h
+++ b/src/widgets/dialogs/qcolordialog_p.h
@@ -49,6 +49,7 @@
#include "private/qdialog_p.h"
#include "qcolordialog.h"
#include "qsharedpointer.h"
+#include "qwindow.h"
#ifndef QT_NO_COLORDIALOG
@@ -63,6 +64,7 @@ class QVBoxLayout;
class QPushButton;
class QWellArray;
class QColorPickingEventFilter;
+class QTimer;
class QColorDialogPrivate : public QDialogPrivate
{
@@ -75,7 +77,11 @@ public:
SetColorAll = ShowColor | SelectColor
};
- QColorDialogPrivate() : options(new QColorDialogOptions) {}
+ QColorDialogPrivate() : options(new QColorDialogOptions)
+#ifdef Q_OS_WIN32
+ , updateTimer(0)
+#endif
+ {}
QPlatformColorDialogHelper *platformColorDialogHelper() const
{ return static_cast<QPlatformColorDialogHelper *>(platformHelper()); }
@@ -104,7 +110,9 @@ public:
void _q_newCustom(int, int);
void _q_newStandard(int, int);
void _q_pickScreenColor();
+ void _q_updateColorPicking();
void updateColorLabelText(const QPoint &);
+ void updateColorPicking(const QPoint &pos);
void releaseColorPicking();
bool handleColorPickingMouseMove(QMouseEvent *e);
bool handleColorPickingMouseButtonRelease(QMouseEvent *e);
@@ -137,6 +145,10 @@ public:
QPointer<QObject> receiverToDisconnectOnClose;
QByteArray memberToDisconnectOnClose;
+#ifdef Q_OS_WIN32
+ QTimer *updateTimer;
+ QWindow dummyTransparentWindow;
+#endif
#ifdef Q_WS_MAC
void openCocoaColorPanel(const QColor &initial,
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index c6d1df04aa..3f178189b9 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -110,10 +110,10 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance
{
Q_Q(QProgressDialog);
label = new QLabel(labelText, q);
- int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q);
- label->setAlignment(Qt::Alignment(align));
bar = new QProgressBar(q);
bar->setRange(min, max);
+ int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q);
+ label->setAlignment(Qt::Alignment(align));
autoClose = true;
autoReset = true;
forceHide = false;
diff --git a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
index f581df4cb3..7e2e79fc5d 100644
--- a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
@@ -219,7 +219,7 @@
\section1 Custom Widgets in Layouts
When you make your own widget class, you should also communicate its layout
- properties. If the widget has a one of Qt's layouts, this is already taken
+ properties. If the widget uses one of Qt's layouts, this is already taken
care of. If the widget does not have any child widgets, or uses manual
layout, you can change the behavior of the widget using any or all of the
following mechanisms:
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 403e64d1ba..9e3aa83976 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -7233,7 +7233,7 @@ QByteArray QWidget::saveGeometry() const
/*!
\since 4.2
- Restores the geometry and state top-level widgets stored in the
+ Restores the geometry and state of top-level widgets stored in the
byte array \a geometry. Returns \c true on success; otherwise
returns \c false.
@@ -12390,10 +12390,9 @@ static void releaseMouseGrabOfWidget(QWidget *widget)
\note Only visible widgets can grab mouse input. If isVisible()
returns \c false for a widget, that widget cannot call grabMouse().
- \note \b{(Mac OS X developers)} For \e Cocoa, calling
- grabMouse() on a widget only works when the mouse is inside the
- frame of that widget. For \e Carbon, it works outside the widget's
- frame as well, like for Windows and X11.
+ \note On Windows, grabMouse() only works when the mouse is inside a window
+ owned by the process.
+ On OS X, grabMouse() only works when the mouse is inside the frame of that widget.
\sa releaseMouse(), grabKeyboard(), releaseKeyboard()
*/
@@ -12414,7 +12413,7 @@ void QWidget::grabMouse()
\warning Grabbing the mouse might lock the terminal.
- \note \b{(Mac OS X developers)} See the note in QWidget::grabMouse().
+ \note See the note in QWidget::grabMouse().
\sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor()
*/
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 94b6000436..6ae0bde20a 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -514,6 +514,9 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
break;
}
arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, rotation);
+ if (arrow.isNull())
+ break;
+
QRect rect = option->rect;
QRect arrowRect;
int imageMax = qMin(arrow.height(), arrow.width());
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 282416971b..ea51d4989e 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3397,8 +3397,10 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
state = QIcon::On;
QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
- int labelWidth = pixmap.width();
- int labelHeight = pixmap.height();
+ int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio();
+ int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio();
+ int labelWidth = pixmapWidth;
+ int labelHeight = pixmapHeight;
int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint()
int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
if (!button->text.isEmpty())
@@ -3407,15 +3409,15 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
//Determine label alignment:
if (textAlignment & Qt::AlignLeft) { /*left*/
iconRect = QRect(textRect.x(), textRect.y() + (textRect.height() - labelHeight) / 2,
- pixmap.width(), pixmap.height());
+ pixmapWidth, pixmapHeight);
} else if (textAlignment & Qt::AlignHCenter) { /* center */
iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
textRect.y() + (textRect.height() - labelHeight) / 2,
- pixmap.width(), pixmap.height());
+ pixmapWidth, pixmapHeight);
} else { /*right*/
iconRect = QRect(textRect.x() + textRect.width() - labelWidth,
textRect.y() + (textRect.height() - labelHeight) / 2,
- pixmap.width(), pixmap.height());
+ pixmapWidth, pixmapHeight);
}
iconRect = visualRect(button->direction, textRect, iconRect);
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 01a1f5046e..4121074e2e 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -930,12 +930,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
initDrag(event->pos(), true);
if (state == 0)
break;
-#ifdef Q_WS_WIN
- // On Windows, NCA mouse events don't contain modifier info
- state->ctrlDrag = GetKeyState(VK_CONTROL) & 0x8000;
-#else
state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
-#endif
startDrag();
break;
case QEvent::NonClientAreaMouseMove:
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 72a556db7c..e56fd111e5 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -288,8 +288,7 @@ void QPlainTextDocumentLayout::documentChanged(int from, int charsRemoved, int c
if (changeStartBlock == changeEndBlock && newBlockCount == d->blockCount) {
QTextBlock block = changeStartBlock;
- int blockLineCount = block.layout()->lineCount();
- if (block.isValid() && blockLineCount) {
+ if (block.isValid() && block.length()) {
QRectF oldBr = blockBoundingRect(block);
layoutBlock(block);
QRectF newBr = blockBoundingRect(block);