summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-02-25 09:55:25 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-02-25 09:55:25 +0100
commit5439451defb11c29e2e1d18737cb99d0f576a961 (patch)
treea63443ca2445eb4447282c2f31938fb993cf039b
parent4e551aeb0e202397aafc5c6d09137acee98c9404 (diff)
parent97965a0908b8fbf7f01d0880410929a4ea61b48d (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: mkspecs/features/qt_module.prf src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm Change-Id: I7912c23b02b186831f0e465dbe5d1f9936205439
-rw-r--r--config.tests/unix/journald/journald.pro6
-rwxr-xr-xconfigure2
-rw-r--r--doc/global/qt-cpp-defines.qdocconf4
-rw-r--r--mkspecs/features/qt_helper_lib.prf3
-rw-r--r--mkspecs/features/qt_module.prf21
-rw-r--r--mkspecs/features/qt_module_headers.prf3
-rw-r--r--mkspecs/freebsd-clang/qmake.conf (renamed from mkspecs/unsupported/freebsd-clang/qmake.conf)4
-rw-r--r--mkspecs/freebsd-clang/qplatformdefs.h (renamed from mkspecs/freebsd-g++/qplatformdefs.h)0
-rw-r--r--mkspecs/unsupported/freebsd-g++/qmake.conf (renamed from mkspecs/freebsd-g++/qmake.conf)6
-rw-r--r--mkspecs/unsupported/freebsd-g++/qplatformdefs.h (renamed from mkspecs/unsupported/freebsd-clang/qplatformdefs.h)2
-rw-r--r--mkspecs/unsupported/freebsd-g++46/qmake.conf (renamed from mkspecs/freebsd-g++46/qmake.conf)6
-rw-r--r--mkspecs/unsupported/freebsd-g++46/qplatformdefs.h (renamed from mkspecs/freebsd-g++46/qplatformdefs.h)2
-rw-r--r--mkspecs/win32-g++/qmake.conf1
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp39
-rw-r--r--src/3rdparty/dbus-ifaces/com.canonical.AppMenu.Registrar.xml56
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java55
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtNative.java11
-rw-r--r--src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java9
-rw-r--r--src/android/templates/AndroidManifest.xml1
-rw-r--r--src/corelib/arch/qatomic_cxx11.h8
-rw-r--r--src/corelib/corelib.pro4
-rw-r--r--src/corelib/global/global.pri5
-rw-r--r--src/corelib/global/qglobal.cpp2
-rw-r--r--src/corelib/global/qversiontagging.h6
-rw-r--r--src/corelib/io/qfile.cpp2
-rw-r--r--src/corelib/io/qlockfile.cpp2
-rw-r--r--src/corelib/io/qurl.cpp2
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp11
-rw-r--r--src/corelib/io/qwinoverlappedionotifier.cpp16
-rw-r--r--src/corelib/json/qjson_p.h6
-rw-r--r--src/corelib/json/qjsonarray.cpp72
-rw-r--r--src/corelib/json/qjsonarray.h6
-rw-r--r--src/corelib/json/qjsondocument.cpp4
-rw-r--r--src/corelib/json/qjsonobject.cpp94
-rw-r--r--src/corelib/json/qjsonobject.h6
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp19
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp17
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h1
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp8
-rw-r--r--src/corelib/kernel/qjnihelpers_p.h2
-rw-r--r--src/corelib/mimetypes/qmimemagicrule.cpp21
-rw-r--r--src/corelib/mimetypes/qmimetypeparser.cpp55
-rw-r--r--src/corelib/mimetypes/qmimetypeparser_p.h2
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp2
-rw-r--r--src/corelib/tools/qmap.cpp2
-rw-r--r--src/corelib/tools/qringbuffer.cpp1
-rw-r--r--src/corelib/tools/qshareddata.h2
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h2
-rw-r--r--src/corelib/tools/qtimezoneprivate_win.cpp2
-rw-r--r--src/dbus/qdbusabstractinterface.h4
-rw-r--r--src/dbus/qdbusconnection.cpp4
-rw-r--r--src/dbus/qdbusextratypes.h2
-rw-r--r--src/dbus/qdbusintegrator.cpp3
-rw-r--r--src/gui/image/qbmphandler.cpp2
-rw-r--r--src/gui/image/qgifhandler.cpp4
-rw-r--r--src/gui/image/qimage.h2
-rw-r--r--src/gui/image/qimage_p.h6
-rw-r--r--src/gui/image/qpixmap_blitter.cpp2
-rw-r--r--src/gui/image/qpixmap_win.cpp2
-rw-r--r--src/gui/image/qppmhandler.cpp6
-rw-r--r--src/gui/image/qxbmhandler.cpp2
-rw-r--r--src/gui/image/qxpmhandler.cpp4
-rw-r--r--src/gui/kernel/qevent.cpp1
-rw-r--r--src/gui/kernel/qevent.h2
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h23
-rw-r--r--src/gui/kernel/qopenglcontext.h2
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp45
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h5
-rw-r--r--src/gui/kernel/qplatformwindow.cpp8
-rw-r--r--src/gui/kernel/qsimpledrag.cpp5
-rw-r--r--src/gui/kernel/qsimpledrag_p.h3
-rw-r--r--src/gui/kernel/qwindow.cpp2
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp7
-rw-r--r--src/gui/opengl/qopengl.cpp2
-rw-r--r--src/gui/opengl/qopenglextrafunctions.h2
-rw-r--r--src/gui/opengl/qopenglshaderprogram.cpp2
-rw-r--r--src/gui/opengl/qopenglversionfunctions.h2
-rw-r--r--src/gui/painting/qbackingstore.cpp3
-rw-r--r--src/gui/painting/qdrawhelper.cpp4
-rw-r--r--src/gui/painting/qdrawhelper_p.h9
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp45
-rw-r--r--src/gui/painting/qpen.h2
-rw-r--r--src/gui/painting/qplatformbackingstore.cpp33
-rw-r--r--src/gui/painting/qregion.cpp4
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp6
-rw-r--r--src/gui/text/qfontengine.cpp8
-rw-r--r--src/gui/text/qfontengine_ft.cpp10
-rw-r--r--src/gui/text/qfontmetrics.cpp4
-rw-r--r--src/gui/text/qfontsubset.cpp2
-rw-r--r--src/gui/text/qtextcursor.cpp4
-rw-r--r--src/gui/text/qtextcursor.h5
-rw-r--r--src/gui/text/qtextcursor_p.h2
-rw-r--r--src/gui/text/qtextdocument_p.cpp2
-rw-r--r--src/gui/text/qtextengine.cpp30
-rw-r--r--src/gui/text/qtextengine_p.h8
-rw-r--r--src/gui/text/qtextlayout.cpp22
-rw-r--r--src/gui/util/qvalidator.cpp2
-rw-r--r--src/network/access/qhttpnetworkreply.cpp8
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp13
-rw-r--r--src/network/ssl/qsslellipticcurve.h2
-rw-r--r--src/network/ssl/qsslkey_p.cpp7
-rw-r--r--src/network/ssl/qsslsocket_openssl_p.h2
-rw-r--r--src/platformsupport/dbusmenu/dbusmenu.pri4
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenubar.cpp172
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenubar_p.h (renamed from src/plugins/platforms/windows/array.h)93
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenuregistrarproxy.cpp64
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenuregistrarproxy_p.h127
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositor.cpp8
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp34
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp68
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes_p.h12
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler.cpp26
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm28
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.h15
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp5
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowsbackingstore.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsclipboard.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp46
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp14
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp14
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp93
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp43
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp110
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp9
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.cpp25
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.h5
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp25
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp66
-rw-r--r--src/plugins/platforms/windows/qwindowsmime.cpp156
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp20
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeimage.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowsole.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowsole.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.cpp15
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.h8
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsservices.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.h2
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp11
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp8
-rw-r--r--src/plugins/platforms/windows/windows.pri1
-rw-r--r--src/plugins/platforms/winrt/qwinrtbackingstore.cpp13
-rw-r--r--src/plugins/platforms/winrt/qwinrtbackingstore.h4
-rw-r--r--src/plugins/platforms/winrt/qwinrtclipboard.cpp185
-rw-r--r--src/plugins/platforms/winrt/qwinrtclipboard.h78
-rw-r--r--src/plugins/platforms/winrt/qwinrteglcontext.cpp21
-rw-r--r--src/plugins/platforms/winrt/qwinrteglcontext.h2
-rw-r--r--src/plugins/platforms/winrt/qwinrtfontdatabase.cpp27
-rw-r--r--src/plugins/platforms/winrt/qwinrtfontdatabase.h3
-rw-r--r--src/plugins/platforms/winrt/qwinrtinputcontext.cpp19
-rw-r--r--src/plugins/platforms/winrt/qwinrtinputcontext.h3
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.cpp37
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.h1
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.cpp7
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.h3
-rw-r--r--src/plugins/platforms/winrt/qwinrtwindow.cpp30
-rw-r--r--src/plugins/platforms/winrt/qwinrtwindow.h3
-rw-r--r--src/plugins/platforms/winrt/winrt.pro2
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp15
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp1
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp5
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp52
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp4
-rw-r--r--src/sql/kernel/qsqldriver.cpp43
-rw-r--r--src/testlib/qtestkeyboard.h6
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp8
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h1
-rw-r--r--src/widgets/dialogs/qfilesystemmodel_p.h10
-rw-r--r--src/widgets/itemviews/qlistview.cpp12
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp29
-rw-r--r--src/widgets/itemviews/qlistwidget.h2
-rw-r--r--src/widgets/kernel/qwidgetbackingstore.cpp51
-rw-r--r--src/widgets/kernel/qwidgetbackingstore_p.h2
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp76
-rw-r--r--src/widgets/styles/qstyleoption.cpp2
-rw-r--r--src/widgets/widgets/qcombobox.cpp1
-rw-r--r--src/widgets/widgets/qmenu_mac.mm10
-rw-r--r--tests/auto/auto.pro5
-rw-r--r--tests/auto/corelib/io/qstandardpaths/BLACKLIST2
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp3
-rw-r--r--tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp9
-rw-r--r--tests/auto/corelib/kernel/qtranslator/qtranslator.pro2
-rw-r--r--tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp9
-rw-r--r--tests/auto/gui/image/qimagereader/images/corrupt_clut.bmpbin0 -> 368 bytes
-rw-r--r--tests/auto/gui/image/qimagereader/tst_qimagereader.cpp1
-rw-r--r--tests/auto/gui/kernel/qwindow/BLACKLIST4
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp193
-rw-r--r--tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp29
-rw-r--r--tests/auto/opengl/qgl/BLACKLIST2
-rw-r--r--tests/auto/other/gestures/BLACKLIST2
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp1
-rw-r--r--tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp80
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp3
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/BLACKLIST2
-rw-r--r--tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST6
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST3
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST1
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp28
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp26
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/BLACKLIST2
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/qtreeview.pro2
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp51
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST4
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp10
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp5
-rw-r--r--tests/auto/widgets/widgets/qmenu/BLACKLIST3
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp110
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp5
-rw-r--r--tests/manual/qopenglwidget/openglwidget/main.cpp7
-rw-r--r--tests/manual/qopenglwidget/openglwidget/openglwidget.cpp12
-rw-r--r--tests/manual/qopenglwidget/openglwidget/openglwidget.h2
221 files changed, 2827 insertions, 979 deletions
diff --git a/config.tests/unix/journald/journald.pro b/config.tests/unix/journald/journald.pro
index 2bb50ceb71..ea765642e6 100644
--- a/config.tests/unix/journald/journald.pro
+++ b/config.tests/unix/journald/journald.pro
@@ -1,6 +1,10 @@
SOURCES = journald.c
CONFIG += link_pkgconfig
-PKGCONFIG_PRIVATE += libsystemd-journal
+
+packagesExist(libsystemd): \
+ PKGCONFIG_PRIVATE += libsystemd
+else: \
+ PKGCONFIG_PRIVATE += libsystemd-journal
CONFIG -= qt
diff --git a/configure b/configure
index dc569d747c..a034d5b908 100755
--- a/configure
+++ b/configure
@@ -2872,7 +2872,7 @@ if [ -z "$PLATFORM" ]; then
PLATFORM=ultrix-g++
;;
FreeBSD:*)
- PLATFORM=freebsd-g++
+ PLATFORM=freebsd-clang
PLATFORM_NOTES="
- Also available for FreeBSD: freebsd-icc
"
diff --git a/doc/global/qt-cpp-defines.qdocconf b/doc/global/qt-cpp-defines.qdocconf
index 967bbb8ede..54d2cbbe4e 100644
--- a/doc/global/qt-cpp-defines.qdocconf
+++ b/doc/global/qt-cpp-defines.qdocconf
@@ -161,3 +161,7 @@ Cpp.ignoredirectives += \
QT_WARNING_DISABLE_MSVC \
Q_ATTRIBUTE_FORMAT_PRINTF \
Q_MV_IOS
+
+# Qt 6: Remove
+falsehoods += \
+ "QT_VERSION >= QT_VERSION_CHECK\\(6,0,0\\)"
diff --git a/mkspecs/features/qt_helper_lib.prf b/mkspecs/features/qt_helper_lib.prf
index 70a17995cf..ebc629f57f 100644
--- a/mkspecs/features/qt_helper_lib.prf
+++ b/mkspecs/features/qt_helper_lib.prf
@@ -14,6 +14,9 @@ load(qt_build_paths)
TEMPLATE = lib
CONFIG -= qt
+CONFIG -= warning_clean # Don't presume 3rd party code to be clean
+load(qt_common)
+
contains(QT_CONFIG, debug_and_release): CONFIG += debug_and_release
contains(QT_CONFIG, build_all): CONFIG += build_all
diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf
index cdf1dde868..6a08d1c5eb 100644
--- a/mkspecs/features/qt_module.prf
+++ b/mkspecs/features/qt_module.prf
@@ -117,7 +117,6 @@ lib_bundle {
QMAKE_BUNDLE_EXTENSION = .framework
QMAKE_INFO_PLIST = $$QMAKESPEC/Info.plist.lib
}
- CONFIG -= qt_install_headers #no need to install these as well
!build_all| \
if(if(!debug_and_release|CONFIG(release, debug|release)): \
if(!simulator_and_device|CONFIG(device, simulator|device))) {
@@ -197,7 +196,7 @@ equals(QT_ARCH, i386):contains(QT_CPU_FEATURES.$$QT_ARCH, sse2):compiler_support
android: CONFIG += qt_android_deps no_linker_version_script
!header_module:unix:!isEmpty(QMAKE_LFLAGS_VERSION_SCRIPT):!no_linker_version_script:!static {
- verscript = $$OUT_PWD/$${TARGET}.version
+ verscript = $${TARGET}.version
QMAKE_LFLAGS += $${QMAKE_LFLAGS_VERSION_SCRIPT}$$verscript
internal_module {
@@ -222,16 +221,20 @@ android: CONFIG += qt_android_deps no_linker_version_script
}
# Add a post-processing step to replace the @FILE:filename@
- verscriptprocess.commands = perl $${PWD}/data/unix/findclasslist.pl < $${verscript}.in > $@
- verscriptprocess.target = $$verscript
+ verscript_in = $${verscript}.in
+ verscriptprocess.name = linker version script ${QMAKE_FILE_BASE}
+ verscriptprocess.input = verscript_in
+ verscriptprocess.CONFIG += no_link target_predeps
for(header, SYNCQT.PRIVATE_HEADER_FILES): \
verscriptprocess.depends += $${_PRO_FILE_PWD_}/$$header
- verscriptprocess.depends += $${verscript}.in
- QMAKE_EXTRA_TARGETS += verscriptprocess
- PRE_TARGETDEPS += $$verscript
- verscript = $${verscript}.in
+ verscriptprocess.output = $$verscript
+ verscriptprocess.commands = perl $${PWD}/data/unix/findclasslist.pl < ${QMAKE_FILE_IN} > $@
+ silent:verscriptprocess.commands = @echo creating linker version script ${QMAKE_FILE_BASE} && $$verscriptprocess.commands
+ QMAKE_EXTRA_COMPILERS += verscriptprocess
+
+ verscript = $$verscript_in
}
- write_file($$verscript, verscript_content)|error("Aborting.")
+ write_file($$OUT_PWD/$$verscript, verscript_content)|error("Aborting.")
unset(current)
unset(previous)
unset(verscript)
diff --git a/mkspecs/features/qt_module_headers.prf b/mkspecs/features/qt_module_headers.prf
index 777b4ffab3..7acca41d47 100644
--- a/mkspecs/features/qt_module_headers.prf
+++ b/mkspecs/features/qt_module_headers.prf
@@ -99,7 +99,8 @@ git_build: \
else: \
INC_PATH = $$MODULE_BASE_INDIR
include($$INC_PATH/include/$$MODULE_INCNAME/headers.pri, "", true)
-CONFIG += qt_install_headers
+!lib_bundle: \ # Headers are embedded into the bundle, so don't install them separately.
+ CONFIG += qt_install_headers
alien_syncqt: return()
diff --git a/mkspecs/unsupported/freebsd-clang/qmake.conf b/mkspecs/freebsd-clang/qmake.conf
index 9d9815a7b3..7f18bbb721 100644
--- a/mkspecs/unsupported/freebsd-clang/qmake.conf
+++ b/mkspecs/freebsd-clang/qmake.conf
@@ -30,7 +30,7 @@ QMAKE_OBJCOPY = objcopy
QMAKE_NM = nm -P
QMAKE_RANLIB =
-include(../../common/gcc-base-unix.conf)
-include(../../common/clang.conf)
+include(../common/gcc-base-unix.conf)
+include(../common/clang.conf)
load(qt_config)
diff --git a/mkspecs/freebsd-g++/qplatformdefs.h b/mkspecs/freebsd-clang/qplatformdefs.h
index d92eadd7e8..d92eadd7e8 100644
--- a/mkspecs/freebsd-g++/qplatformdefs.h
+++ b/mkspecs/freebsd-clang/qplatformdefs.h
diff --git a/mkspecs/freebsd-g++/qmake.conf b/mkspecs/unsupported/freebsd-g++/qmake.conf
index 282b6bdfa7..527a94870c 100644
--- a/mkspecs/freebsd-g++/qmake.conf
+++ b/mkspecs/unsupported/freebsd-g++/qmake.conf
@@ -5,7 +5,7 @@
MAKEFILE_GENERATOR = UNIX
QMAKE_PLATFORM = freebsd bsd
-include(../common/unix.conf)
+include(../../common/unix.conf)
QMAKE_CFLAGS_THREAD = -pthread -D_THREAD_SAFE
@@ -29,6 +29,6 @@ QMAKE_OBJCOPY = objcopy
QMAKE_NM = nm -P
QMAKE_RANLIB =
-include(../common/gcc-base-unix.conf)
-include(../common/g++-unix.conf)
+include(../../common/gcc-base-unix.conf)
+include(../../common/g++-unix.conf)
load(qt_config)
diff --git a/mkspecs/unsupported/freebsd-clang/qplatformdefs.h b/mkspecs/unsupported/freebsd-g++/qplatformdefs.h
index 41f1da615c..a3086b973a 100644
--- a/mkspecs/unsupported/freebsd-clang/qplatformdefs.h
+++ b/mkspecs/unsupported/freebsd-g++/qplatformdefs.h
@@ -37,4 +37,4 @@
**
****************************************************************************/
-#include "../../freebsd-g++/qplatformdefs.h"
+#include "../../freebsd-clang/qplatformdefs.h"
diff --git a/mkspecs/freebsd-g++46/qmake.conf b/mkspecs/unsupported/freebsd-g++46/qmake.conf
index b930fca78b..11041dee3d 100644
--- a/mkspecs/freebsd-g++46/qmake.conf
+++ b/mkspecs/unsupported/freebsd-g++46/qmake.conf
@@ -5,7 +5,7 @@
MAKEFILE_GENERATOR = UNIX
QMAKE_PLATFORM = freebsd bsd
-include(../common/unix.conf)
+include(../../common/unix.conf)
QMAKE_CFLAGS_THREAD = -pthread -D_THREAD_SAFE
@@ -29,8 +29,8 @@ QMAKE_OBJCOPY = objcopy
QMAKE_NM = nm -P
QMAKE_RANLIB =
-include(../common/gcc-base-unix.conf)
-include(../common/g++-unix.conf)
+include(../../common/gcc-base-unix.conf)
+include(../../common/g++-unix.conf)
# Redefined here because g++-base.conf sets QMAKE_CC and QMAKE_CXX
# to gcc and g++, respectively.
diff --git a/mkspecs/freebsd-g++46/qplatformdefs.h b/mkspecs/unsupported/freebsd-g++46/qplatformdefs.h
index e2f2d7c85b..a3086b973a 100644
--- a/mkspecs/freebsd-g++46/qplatformdefs.h
+++ b/mkspecs/unsupported/freebsd-g++46/qplatformdefs.h
@@ -37,4 +37,4 @@
**
****************************************************************************/
-#include "../freebsd-g++/qplatformdefs.h"
+#include "../../freebsd-clang/qplatformdefs.h"
diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf
index bb780882c1..abc6198bc7 100644
--- a/mkspecs/win32-g++/qmake.conf
+++ b/mkspecs/win32-g++/qmake.conf
@@ -31,6 +31,7 @@ QMAKE_CFLAGS_DEPS = -M
QMAKE_CFLAGS_WARN_ON = -Wall -Wextra
QMAKE_CFLAGS_WARN_OFF = -w
QMAKE_CFLAGS_RELEASE = -O2
+QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO = -O2 -g
QMAKE_CFLAGS_DEBUG = -g
QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses
QMAKE_CFLAGS_SPLIT_SECTIONS = -ffunction-sections
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp
index 7c7a70b09a..35df36cb55 100644
--- a/qmake/generators/mac/pbuilder_pbx.cpp
+++ b/qmake/generators/mac/pbuilder_pbx.cpp
@@ -98,19 +98,6 @@ struct ProjectBuilderSubDirs {
bool
ProjectBuilderMakefileGenerator::writeSubDirs(QTextStream &t)
{
- if(project->isActiveConfig("generate_pbxbuild_makefile")) {
- QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"),
- FileFixifyToIndir);
- QFile mkwrapf(mkwrap);
- if(mkwrapf.open(QIODevice::WriteOnly | QIODevice::Text)) {
- debug_msg(1, "pbuilder: Creating file: %s", mkwrap.toLatin1().constData());
- QTextStream mkwrapt(&mkwrapf);
- writingUnixMakefileGenerator = true;
- UnixMakefileGenerator::writeSubDirs(mkwrapt);
- writingUnixMakefileGenerator = false;
- }
- }
-
//HEADER
const int pbVersion = pbuilderVersion();
t << "// !$*UTF8*$!\n"
@@ -1664,32 +1651,6 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
<< "\t" << writeSettings("rootObject", keyFor("QMAKE_PBX_ROOT")) << ";\n"
<< "}\n";
- if(project->isActiveConfig("generate_pbxbuild_makefile")) {
- QString mkwrap = Option::output_dir + project->first("/MAKEFILE");
- QFile mkwrapf(mkwrap);
- if(mkwrapf.open(QIODevice::WriteOnly | QIODevice::Text)) {
- writingUnixMakefileGenerator = true;
- debug_msg(1, "pbuilder: Creating file: %s", mkwrap.toLatin1().constData());
- QTextStream mkwrapt(&mkwrapf);
- writeHeader(mkwrapt);
- const char cleans[] = "preprocess_clean ";
- const QString cmd = escapeFilePath(project->first("QMAKE_ORIG_TARGET") + projectSuffix() + "/") + " && " + pbxbuild();
- mkwrapt << "#This is a makefile wrapper for PROJECT BUILDER\n"
- << "all:\n\t"
- << "cd " << cmd << "\n"
- << "install: all\n\t"
- << "cd " << cmd << " install\n"
- << "distclean clean: preprocess_clean\n\t"
- << "cd " << cmd << " clean\n"
- << (!did_preprocess ? cleans : "") << ":\n";
- if(did_preprocess)
- mkwrapt << cleans << ":\n\t"
- << "make -f "
- << pbx_dir << Option::dir_sep << "qt_preprocess.mak $@\n";
- writingUnixMakefileGenerator = false;
- }
- }
-
// Scheme
{
QString xcodeSpecDir = project->first("QMAKE_XCODE_SPECDIR").toQString();
diff --git a/src/3rdparty/dbus-ifaces/com.canonical.AppMenu.Registrar.xml b/src/3rdparty/dbus-ifaces/com.canonical.AppMenu.Registrar.xml
new file mode 100644
index 0000000000..42a71707b6
--- /dev/null
+++ b/src/3rdparty/dbus-ifaces/com.canonical.AppMenu.Registrar.xml
@@ -0,0 +1,56 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
+ <dox:d><![CDATA[
+ @mainpage
+  
+ An interface to register menus that are associated with a window in an application.  The
+ main interface is documented here: @ref com::canonical::AppMenu::Registrar.
+     
+ The actual menus are transported using the dbusmenu protocol which is available
+ here: @ref com::canonical::dbusmenu.
+ ]]></dox:d>
+ <interface name="com.canonical.AppMenu.Registrar" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
+ <dox:d>
+ An interface to register a menu from an application's window to be displayed in another
+ window.  This manages that association between XWindow Window IDs and the dbus
+ address and object that provides the menu using the dbusmenu dbus interface.
+ </dox:d>
+ <method name="RegisterWindow">
+ <dox:d><![CDATA[
+ Associates a dbusmenu with a window
+      
+ /note this method assumes that the connection from the caller is the DBus connection
+ to use for the object.  Applications that use multiple DBus connections will need to
+ ensure this method is called with the same connection that implmenets the object.
+ ]]></dox:d>
+ <arg name="windowId" type="u" direction="in">
+ <dox:d>The XWindow ID of the window</dox:d>
+ </arg>
+ <arg name="menuObjectPath" type="o" direction="in">
+ <dox:d>The object on the dbus interface implementing the dbusmenu interface</dox:d>
+ </arg>
+ </method>
+ <method name="UnregisterWindow">
+ <dox:d>
+ A method to allow removing a window from the database. Windows will also be removed
+ when the client drops off DBus so this is not required. It is polite though. And
+ important for testing.
+ </dox:d>
+ <arg name="windowId" type="u" direction="in">
+ <dox:d>The XWindow ID of the window</dox:d>
+ </arg>
+ </method>
+ <method name="GetMenuForWindow">
+ <dox:d>Gets the registered menu for a given window ID.</dox:d>
+ <arg name="windowId" type="u" direction="in">
+ <dox:d>The XWindow ID of the window to get</dox:d>
+ </arg>
+ <arg name="service" type="s" direction="out">
+ <dox:d>The address of the connection on DBus (e.g. :1.23 or org.example.service)</dox:d>
+ </arg>
+ <arg name="menuObjectPath" type="o" direction="out">
+ <dox:d>The path to the object which implements the com.canonical.dbusmenu interface.</dox:d>
+ </arg>
+ </method>
+ </interface>
+</node>
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
index c434cc24b3..61a824e749 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -48,6 +48,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
import android.graphics.Rect;
import android.net.LocalServerSocket;
import android.net.LocalSocket;
@@ -74,6 +75,7 @@ import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.view.ViewTreeObserver;
+import android.widget.ImageView;
import android.widget.PopupMenu;
import java.io.BufferedReader;
@@ -101,6 +103,7 @@ public class QtActivityDelegate
private Method m_super_onConfigurationChanged = null;
private Method m_super_onActivityResult = null;
private Method m_super_dispatchGenericMotionEvent = null;
+ private Method m_super_onWindowFocusChanged = null;
private static final String NATIVE_LIBRARIES_KEY = "native.libraries";
private static final String BUNDLED_LIBRARIES_KEY = "bundled.libraries";
@@ -126,6 +129,8 @@ public class QtActivityDelegate
private HashMap<Integer, QtSurface> m_surfaces = null;
private HashMap<Integer, View> m_nativeViews = null;
private QtLayout m_layout = null;
+ private ImageView m_splashScreen = null;
+ private boolean m_splashScreenSticky = false;
private QtEditText m_editText = null;
private InputMethodManager m_imm = null;
private boolean m_quitApp = true;
@@ -516,6 +521,7 @@ public class QtActivityDelegate
m_super_onKeyUp = m_activity.getClass().getMethod("super_onKeyUp", Integer.TYPE, KeyEvent.class);
m_super_onConfigurationChanged = m_activity.getClass().getMethod("super_onConfigurationChanged", Configuration.class);
m_super_onActivityResult = m_activity.getClass().getMethod("super_onActivityResult", Integer.TYPE, Integer.TYPE, Intent.class);
+ m_super_onWindowFocusChanged = m_activity.getClass().getMethod("super_onWindowFocusChanged", Boolean.TYPE);
m_super_dispatchGenericMotionEvent = m_activity.getClass().getMethod("super_dispatchGenericMotionEvent", MotionEvent.class);
} catch (Exception e) {
e.printStackTrace();
@@ -871,6 +877,22 @@ public class QtActivityDelegate
};
}
m_layout = new QtLayout(m_activity, startApplication);
+
+ try {
+ ActivityInfo info = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(), PackageManager.GET_META_DATA);
+ if (info.metaData.containsKey("android.app.splash_screen_drawable")) {
+ m_splashScreenSticky = info.metaData.containsKey("android.app.splash_screen_sticky") && info.metaData.getBoolean("android.app.splash_screen_sticky");
+ int id = info.metaData.getInt("android.app.splash_screen_drawable");
+ m_splashScreen = new ImageView(m_activity);
+ m_splashScreen.setImageDrawable(m_activity.getResources().getDrawable(id));
+ m_splashScreen.setScaleType(ImageView.ScaleType.FIT_XY);
+ m_splashScreen.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ m_layout.addView(m_splashScreen);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
m_editText = new QtEditText(m_activity, this);
m_imm = (InputMethodManager)m_activity.getSystemService(Context.INPUT_METHOD_SERVICE);
m_surfaces = new HashMap<Integer, QtSurface>();
@@ -912,31 +934,34 @@ public class QtActivityDelegate
});
}
+ public void hideSplashScreen()
+ {
+ if (m_splashScreen == null)
+ return;
+ m_layout.removeView(m_splashScreen);
+ m_splashScreen = null;
+ }
+
+
public void initializeAccessibility()
{
new QtAccessibilityDelegate(m_activity, m_layout, this);
}
- public void onConfigurationChanged(Configuration configuration)
- {
+ public void onWindowFocusChanged(boolean hasFocus) {
try {
- m_super_onConfigurationChanged.invoke(m_activity, configuration);
+ m_super_onWindowFocusChanged.invoke(m_activity, hasFocus);
} catch (Exception e) {
e.printStackTrace();
}
+ if (hasFocus)
+ updateFullScreen();
+ }
- // if splash screen is defined, then show it
- // Note: QtActivity handles settting the splash screen
- // in onCreate, change that too if you are changing
- // how the splash screen should be displayed
+ public void onConfigurationChanged(Configuration configuration)
+ {
try {
- if (m_surfaces.size() == 0) {
- ActivityInfo info = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(), PackageManager.GET_META_DATA);
- if (info.metaData.containsKey("android.app.splash_screen_drawable"))
- m_activity.getWindow().setBackgroundDrawableResource(info.metaData.getInt("android.app.splash_screen_drawable"));
- else
- m_activity.getWindow().setBackgroundDrawable(new ColorDrawable(0xff000000));
- }
+ m_super_onConfigurationChanged.invoke(m_activity, configuration);
} catch (Exception e) {
e.printStackTrace();
}
@@ -1262,6 +1287,8 @@ public class QtActivityDelegate
m_layout.addView(surface, surfaceCount);
m_surfaces.put(id, surface);
+ if (!m_splashScreenSticky)
+ hideSplashScreen();
}
public void setSurfaceGeometry(int id, int x, int y, int w, int h) {
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
index 5d4f6e791a..48510b3fdf 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
@@ -728,6 +728,17 @@ public class QtNative
});
}
+ private static void hideSplashScreen()
+ {
+ runAction(new Runnable() {
+ @Override
+ public void run() {
+ if (m_activityDelegate != null)
+ m_activityDelegate.hideSplashScreen();
+ }
+ });
+ }
+
// screen methods
public static native void setDisplayMetrics(int screenWidthPixels,
int screenHeightPixels,
diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java
index 836a7677b3..92cea65e4b 100644
--- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java
+++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java
@@ -166,15 +166,6 @@ public class QtActivityLoader extends QtLoader {
+ "/\tQT_ANDROID_THEME_DISPLAY_DPI=" + m_displayDensity + "\t";
if (null == m_activity.getLastNonConfigurationInstance()) {
- // if splash screen is defined, then show it
- // Note: QtActivityDelegate handles updating the splash screen
- // in onConfigurationChanged, change that too if you are changing
- // how the splash screen should be displayed
- if (m_contextInfo.metaData.containsKey("android.app.splash_screen_drawable"))
- m_activity.getWindow().setBackgroundDrawableResource(m_contextInfo.metaData.getInt("android.app.splash_screen_drawable"));
- else
- m_activity.getWindow().setBackgroundDrawable(new ColorDrawable(0xff000000));
-
if (m_contextInfo.metaData.containsKey("android.app.background_running")
&& m_contextInfo.metaData.getBoolean("android.app.background_running")) {
ENVIRONMENT_VARIABLES += "QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED=0\t";
diff --git a/src/android/templates/AndroidManifest.xml b/src/android/templates/AndroidManifest.xml
index 02fd0ce23b..22c3ea7578 100644
--- a/src/android/templates/AndroidManifest.xml
+++ b/src/android/templates/AndroidManifest.xml
@@ -38,6 +38,7 @@
<!-- Splash screen -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
+ <!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
<!-- Background running -->
diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/arch/qatomic_cxx11.h
index 4c9001a7cd..bb49aae4fb 100644
--- a/src/corelib/arch/qatomic_cxx11.h
+++ b/src/corelib/arch/qatomic_cxx11.h
@@ -151,7 +151,7 @@ template <typename X> struct QAtomicOps
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T>
- static bool testAndSetRelaxed(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW
+ static bool testAndSetRelaxed(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
{
bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed);
if (currentValue)
@@ -160,7 +160,7 @@ template <typename X> struct QAtomicOps
}
template <typename T>
- static bool testAndSetAcquire(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW
+ static bool testAndSetAcquire(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
{
bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire);
if (currentValue)
@@ -169,7 +169,7 @@ template <typename X> struct QAtomicOps
}
template <typename T>
- static bool testAndSetRelease(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW
+ static bool testAndSetRelease(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
{
bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release);
if (currentValue)
@@ -178,7 +178,7 @@ template <typename X> struct QAtomicOps
}
template <typename T>
- static bool testAndSetOrdered(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW
+ static bool testAndSetOrdered(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW
{
bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel);
if (currentValue)
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index a8c8f65d37..78ea489ebc 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -25,6 +25,10 @@ ANDROID_PERMISSIONS = \
android.permission.INTERNET \
android.permission.WRITE_EXTERNAL_STORAGE
+# QtCore can't be compiled with -Wl,-no-undefined because it uses the "environ"
+# variable and on FreeBSD, this variable is in the final executable itself
+freebsd: QMAKE_LFLAGS_NOUNDEF =
+
load(qt_module)
load(qfeatures)
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index aa4945f90e..dd846955f6 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -53,7 +53,10 @@ slog2 {
journald {
CONFIG += link_pkgconfig
- PKGCONFIG_PRIVATE += libsystemd-journal
+ packagesExist(libsystemd): \
+ PKGCONFIG_PRIVATE += libsystemd
+ else: \
+ PKGCONFIG_PRIVATE += libsystemd-journal
DEFINES += QT_USE_JOURNALD
}
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 3ea121fcc2..cbcc6d02a6 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -430,7 +430,7 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
\since 5.7
Sets the indicated \a flag if \a on is \c true or unsets it if
- it if \a on is \c false. Returns a reference to this object.
+ \a on is \c false. Returns a reference to this object.
*/
/*!
diff --git a/src/corelib/global/qversiontagging.h b/src/corelib/global/qversiontagging.h
index f9062a98fb..ef3da7c658 100644
--- a/src/corelib/global/qversiontagging.h
+++ b/src/corelib/global/qversiontagging.h
@@ -65,11 +65,7 @@ QT_BEGIN_NAMESPACE
#elif defined(Q_CC_GNU) && !defined(Q_OS_ANDROID)
# if defined(Q_PROCESSOR_X86) && (defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD_KERNEL))
# if defined(Q_PROCESSOR_X86_64) // x86-64 or x32
-# if defined(__code_model_large__)
-# define QT_VERSION_TAG_RELOC(sym) ".quad " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n"
-# else
-# define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOTPCREL\n"
-# endif
+# define QT_VERSION_TAG_RELOC(sym) ".quad " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n"
# else // x86
# define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n"
# endif
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index ccacb6ed20..9b1bd3a411 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -581,7 +581,7 @@ QFile::rename(const QString &newName)
#ifdef Q_OS_LINUX
// rename() on Linux simply does nothing when renaming "foo" to "Foo" on a case-insensitive
// FS, such as FAT32. Move the file away and rename in 2 steps to work around.
- QTemporaryFile tempFile(d->fileName + QStringLiteral(".XXXXXX"));
+ QTemporaryFile tempFile(d->fileName + QLatin1String(".XXXXXX"));
tempFile.setAutoRemove(false);
if (!tempFile.open(QIODevice::ReadWrite)) {
d->setError(QFile::RenameError, tempFile.errorString());
diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp
index 88a96125bc..7e39dc56fb 100644
--- a/src/corelib/io/qlockfile.cpp
+++ b/src/corelib/io/qlockfile.cpp
@@ -227,7 +227,7 @@ bool QLockFile::tryLock(int timeout)
if (!d->isLocked && d->isApparentlyStale()) {
// Stale lock from another thread/process
// Ensure two processes don't remove it at the same time
- QLockFile rmlock(d->fileName + QStringLiteral(".rmlock"));
+ QLockFile rmlock(d->fileName + QLatin1String(".rmlock"));
if (rmlock.tryLock()) {
if (d->isApparentlyStale() && d->removeStaleLock())
continue;
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 7b1fee31b4..18eaea7e21 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -4271,7 +4271,7 @@ QUrl QUrl::fromUserInput(const QString &userInput)
return QUrl::fromLocalFile(trimmedString);
QUrl url = QUrl(trimmedString, QUrl::TolerantMode);
- QUrl urlPrepended = QUrl(QStringLiteral("http://") + trimmedString, QUrl::TolerantMode);
+ QUrl urlPrepended = QUrl(QLatin1String("http://") + trimmedString, QUrl::TolerantMode);
// Check the most common case of a valid url with a scheme
// We check if the port would be valid by adding the scheme to handle the case host:port
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index 48b915eef8..c7144d2c6b 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -49,13 +49,8 @@ QWindowsPipeWriter::QWindowsPipeWriter(HANDLE pipe, QObject * parent)
quitNow(false),
hasWritten(false)
{
-#if !defined(Q_OS_WINCE) || (_WIN32_WCE >= 0x600)
DuplicateHandle(GetCurrentProcess(), pipe, GetCurrentProcess(),
&writePipe, 0, FALSE, DUPLICATE_SAME_ACCESS);
-#else
- Q_UNUSED(pipe);
- writePipe = GetCurrentProcess();
-#endif
}
QWindowsPipeWriter::~QWindowsPipeWriter()
@@ -66,9 +61,7 @@ QWindowsPipeWriter::~QWindowsPipeWriter()
lock.unlock();
if (!wait(30000))
terminate();
-#if !defined(Q_OS_WINCE) || (_WIN32_WCE >= 0x600)
CloseHandle(writePipe);
-#endif
}
bool QWindowsPipeWriter::waitForWrite(int msecs)
@@ -159,7 +152,6 @@ void QWindowsPipeWriter::run()
msleep(100);
continue;
}
-#ifndef Q_OS_WINCE
if (writeError != ERROR_IO_PENDING) {
qErrnoWarning(writeError, "QWindowsPipeWriter: async WriteFile failed.");
return;
@@ -168,9 +160,6 @@ void QWindowsPipeWriter::run()
qErrnoWarning(GetLastError(), "QWindowsPipeWriter: GetOverlappedResult failed.");
return;
}
-#else
- return;
-#endif
}
totalWritten += written;
#if defined QPIPEWRITER_DEBUG
diff --git a/src/corelib/io/qwinoverlappedionotifier.cpp b/src/corelib/io/qwinoverlappedionotifier.cpp
index 3f599e464f..d7745ae1b6 100644
--- a/src/corelib/io/qwinoverlappedionotifier.cpp
+++ b/src/corelib/io/qwinoverlappedionotifier.cpp
@@ -81,6 +81,22 @@ QT_BEGIN_NAMESPACE
or WriteFile() is ignored and can be used for other purposes.
\warning This class is only available on Windows.
+
+ Due to peculiarities of the Windows I/O completion port API, users of
+ QWinOverlappedIoNotifier must pay attention to the following restrictions:
+ \list
+ \li File handles with a QWinOverlappedIoNotifer are assigned to an I/O
+ completion port until the handle is closed. It is impossible to
+ disassociate the file handle from the I/O completion port.
+ \li There can be only one QWinOverlappedIoNotifer per file handle. Creating
+ another QWinOverlappedIoNotifier for that file, even with a duplicated
+ handle, will fail.
+ \li Certain Windows API functions are unavailable for file handles that are
+ assigned to an I/O completion port. This includes the functions
+ \c{ReadFileEx} and \c{WriteFileEx}.
+ \endlist
+ See also the remarks in the MSDN documentation for the
+ \c{CreateIoCompletionPort} function.
*/
struct IOResult
diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h
index 5f6484728a..4c628ff1fe 100644
--- a/src/corelib/json/qjson_p.h
+++ b/src/corelib/json/qjson_p.h
@@ -795,7 +795,11 @@ public:
if (reserve) {
if (reserve < 128)
reserve = 128;
- size = qMax(size + reserve, size *2);
+ size = qMax(size + reserve, qMin(size *2, (int)Value::MaxSize));
+ if (size > Value::MaxSize) {
+ qWarning("QJson: Document too large to store in data structure");
+ return 0;
+ }
}
char *raw = (char *)malloc(size);
Q_CHECK_PTR(raw);
diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp
index 3eecc458aa..d4cc4b81df 100644
--- a/src/corelib/json/qjsonarray.cpp
+++ b/src/corelib/json/qjsonarray.cpp
@@ -262,8 +262,45 @@ QJsonArray QJsonArray::fromStringList(const QStringList &list)
QJsonArray QJsonArray::fromVariantList(const QVariantList &list)
{
QJsonArray array;
- for (QVariantList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it)
- array.append(QJsonValue::fromVariant(*it));
+ if (list.isEmpty())
+ return array;
+
+ array.detach2(1024);
+
+ QVector<QJsonPrivate::Value> values;
+ values.resize(list.size());
+ QJsonPrivate::Value *valueData = values.data();
+ uint currentOffset = sizeof(QJsonPrivate::Base);
+
+ for (int i = 0; i < list.size(); ++i) {
+ QJsonValue val = QJsonValue::fromVariant(list.at(i));
+
+ bool latinOrIntValue;
+ int valueSize = QJsonPrivate::Value::requiredStorage(val, &latinOrIntValue);
+
+ if (!array.detach2(valueSize))
+ return QJsonArray();
+
+ QJsonPrivate::Value *v = valueData + i;
+ v->type = (val.t == QJsonValue::Undefined ? QJsonValue::Null : val.t);
+ v->latinOrIntValue = latinOrIntValue;
+ v->latinKey = false;
+ v->value = QJsonPrivate::Value::valueToStore(val, currentOffset);
+ if (valueSize)
+ QJsonPrivate::Value::copyData(val, (char *)array.a + currentOffset, latinOrIntValue);
+
+ currentOffset += valueSize;
+ array.a->size = currentOffset;
+ }
+
+ // write table
+ array.a->tableOffset = currentOffset;
+ if (!array.detach2(sizeof(QJsonPrivate::offset)*values.size()))
+ return QJsonArray();
+ memcpy(array.a->table(), values.constData(), values.size()*sizeof(uint));
+ array.a->length = values.size();
+ array.a->size = currentOffset + sizeof(QJsonPrivate::offset)*values.size();
+
return array;
}
@@ -388,7 +425,7 @@ void QJsonArray::removeAt(int i)
if (!a || i < 0 || i >= (int)a->length)
return;
- detach();
+ detach2();
a->removeItems(i, 1);
++d->compactionCounter;
if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(a->length) / 2u)
@@ -448,7 +485,8 @@ void QJsonArray::insert(int i, const QJsonValue &value)
bool compressed;
int valueSize = QJsonPrivate::Value::requiredStorage(val, &compressed);
- detach(valueSize + sizeof(QJsonPrivate::Value));
+ if (!detach2(valueSize + sizeof(QJsonPrivate::Value)))
+ return;
if (!a->length)
a->tableOffset = sizeof(QJsonPrivate::Array);
@@ -498,7 +536,8 @@ void QJsonArray::replace(int i, const QJsonValue &value)
bool compressed;
int valueSize = QJsonPrivate::Value::requiredStorage(val, &compressed);
- detach(valueSize);
+ if (!detach2(valueSize))
+ return;
if (!a->length)
a->tableOffset = sizeof(QJsonPrivate::Array);
@@ -1129,21 +1168,38 @@ bool QJsonArray::operator!=(const QJsonArray &other) const
*/
void QJsonArray::detach(uint reserve)
{
+ Q_UNUSED(reserve)
+ Q_ASSERT(!reserve);
+ detach2(0);
+}
+
+/*!
+ \internal
+ */
+bool QJsonArray::detach2(uint reserve)
+{
if (!d) {
+ if (reserve >= QJsonPrivate::Value::MaxSize) {
+ qWarning("QJson: Document too large to store in data structure");
+ return false;
+ }
d = new QJsonPrivate::Data(reserve, QJsonValue::Array);
a = static_cast<QJsonPrivate::Array *>(d->header->root());
d->ref.ref();
- return;
+ return true;
}
if (reserve == 0 && d->ref.load() == 1)
- return;
+ return true;
QJsonPrivate::Data *x = d->clone(a, reserve);
+ if (!x)
+ return false;
x->ref.ref();
if (!d->ref.deref())
delete d;
d = x;
a = static_cast<QJsonPrivate::Array *>(d->header->root());
+ return true;
}
/*!
@@ -1154,7 +1210,7 @@ void QJsonArray::compact()
if (!d || !d->compactionCounter)
return;
- detach();
+ detach2();
d->compact();
a = static_cast<QJsonPrivate::Array *>(d->header->root());
}
diff --git a/src/corelib/json/qjsonarray.h b/src/corelib/json/qjsonarray.h
index 899b675600..3b6fa37cfa 100644
--- a/src/corelib/json/qjsonarray.h
+++ b/src/corelib/json/qjsonarray.h
@@ -191,10 +191,10 @@ public:
friend class const_iterator;
// stl style
- inline iterator begin() { detach(); return iterator(this, 0); }
+ inline iterator begin() { detach2(); return iterator(this, 0); }
inline const_iterator begin() const { return const_iterator(this, 0); }
inline const_iterator constBegin() const { return const_iterator(this, 0); }
- inline iterator end() { detach(); return iterator(this, size()); }
+ inline iterator end() { detach2(); return iterator(this, size()); }
inline const_iterator end() const { return const_iterator(this, size()); }
inline const_iterator constEnd() const { return const_iterator(this, size()); }
iterator insert(iterator before, const QJsonValue &value) { insert(before.i, value); return before; }
@@ -235,7 +235,9 @@ private:
QJsonArray(QJsonPrivate::Data *data, QJsonPrivate::Array *array);
void initialize();
void compact();
+ // ### Qt 6: remove me and merge with detach2
void detach(uint reserve = 0);
+ bool detach2(uint reserve = 0);
QJsonPrivate::Data *d;
QJsonPrivate::Array *a;
diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp
index a6746d5afe..1fde69ecf6 100644
--- a/src/corelib/json/qjsondocument.cpp
+++ b/src/corelib/json/qjsondocument.cpp
@@ -488,7 +488,7 @@ void QJsonDocument::setObject(const QJsonObject &object)
if (d->compactionCounter)
o.compact();
else
- o.detach();
+ o.detach2();
d = o.d;
d->ref.ref();
return;
@@ -515,7 +515,7 @@ void QJsonDocument::setArray(const QJsonArray &array)
if (d->compactionCounter)
a.compact();
else
- a.detach();
+ a.detach2();
d = a.d;
d->ref.ref();
return;
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index a3ce13a99f..4ee20ef168 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -203,11 +203,54 @@ QJsonObject &QJsonObject::operator =(const QJsonObject &other)
*/
QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map)
{
- // ### this is implemented the trivial way, not the most efficient way
-
QJsonObject object;
- for (QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it)
- object.insert(it.key(), QJsonValue::fromVariant(it.value()));
+ if (map.isEmpty())
+ return object;
+
+ object.detach2(1024);
+
+ QVector<QJsonPrivate::offset> offsets;
+ QJsonPrivate::offset currentOffset;
+ currentOffset = sizeof(QJsonPrivate::Base);
+
+ // the map is already sorted, so we can simply append one entry after the other and
+ // write the offset table at the end
+ for (QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it) {
+ QString key = it.key();
+ QJsonValue val = QJsonValue::fromVariant(it.value());
+
+ bool latinOrIntValue;
+ int valueSize = QJsonPrivate::Value::requiredStorage(val, &latinOrIntValue);
+
+ bool latinKey = QJsonPrivate::useCompressed(key);
+ int valueOffset = sizeof(QJsonPrivate::Entry) + QJsonPrivate::qStringSize(key, latinKey);
+ int requiredSize = valueOffset + valueSize;
+
+ if (!object.detach2(requiredSize + sizeof(QJsonPrivate::offset))) // offset for the new index entry
+ return QJsonObject();
+
+ QJsonPrivate::Entry *e = reinterpret_cast<QJsonPrivate::Entry *>(reinterpret_cast<char *>(object.o) + currentOffset);
+ e->value.type = val.t;
+ e->value.latinKey = latinKey;
+ e->value.latinOrIntValue = latinOrIntValue;
+ e->value.value = QJsonPrivate::Value::valueToStore(val, (char *)e - (char *)object.o + valueOffset);
+ QJsonPrivate::copyString((char *)(e + 1), key, latinKey);
+ if (valueSize)
+ QJsonPrivate::Value::copyData(val, (char *)e + valueOffset, latinOrIntValue);
+
+ offsets << currentOffset;
+ currentOffset += requiredSize;
+ object.o->size = currentOffset;
+ }
+
+ // write table
+ object.o->tableOffset = currentOffset;
+ if (!object.detach2(sizeof(QJsonPrivate::offset)*offsets.size()))
+ return QJsonObject();
+ memcpy(object.o->table(), offsets.constData(), offsets.size()*sizeof(uint));
+ object.o->length = offsets.size();
+ object.o->size = currentOffset + sizeof(QJsonPrivate::offset)*offsets.size();
+
return object;
}
@@ -276,16 +319,14 @@ QVariantHash QJsonObject::toVariantHash() const
*/
QStringList QJsonObject::keys() const
{
- if (!d)
- return QStringList();
-
QStringList keys;
- keys.reserve(o->length);
- for (uint i = 0; i < o->length; ++i) {
- QJsonPrivate::Entry *e = o->entryAt(i);
- keys.append(e->key());
+ if (o) {
+ keys.reserve(o->length);
+ for (uint i = 0; i < o->length; ++i) {
+ QJsonPrivate::Entry *e = o->entryAt(i);
+ keys.append(e->key());
+ }
}
-
return keys;
}
@@ -397,7 +438,8 @@ QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &
int valueOffset = sizeof(QJsonPrivate::Entry) + QJsonPrivate::qStringSize(key, latinKey);
int requiredSize = valueOffset + valueSize;
- detach(requiredSize + sizeof(QJsonPrivate::offset)); // offset for the new index entry
+ if (!detach2(requiredSize + sizeof(QJsonPrivate::offset))) // offset for the new index entry
+ return iterator();
if (!o->length)
o->tableOffset = sizeof(QJsonPrivate::Object);
@@ -441,7 +483,7 @@ void QJsonObject::remove(const QString &key)
if (!keyExists)
return;
- detach();
+ detach2();
o->removeItems(index, 1);
++d->compactionCounter;
if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u)
@@ -468,7 +510,7 @@ QJsonValue QJsonObject::take(const QString &key)
return QJsonValue(QJsonValue::Undefined);
QJsonValue v(d, o, o->entryAt(index)->value);
- detach();
+ detach2();
o->removeItems(index, 1);
++d->compactionCounter;
if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u)
@@ -562,7 +604,7 @@ QJsonObject::iterator QJsonObject::find(const QString &key)
int index = o ? o->indexOf(key, &keyExists) : 0;
if (!keyExists)
return end();
- detach();
+ detach2();
return iterator(this, index);
}
@@ -1069,21 +1111,35 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const
*/
void QJsonObject::detach(uint reserve)
{
+ Q_UNUSED(reserve)
+ Q_ASSERT(!reserve);
+ detach2(reserve);
+}
+
+bool QJsonObject::detach2(uint reserve)
+{
if (!d) {
+ if (reserve >= QJsonPrivate::Value::MaxSize) {
+ qWarning("QJson: Document too large to store in data structure");
+ return false;
+ }
d = new QJsonPrivate::Data(reserve, QJsonValue::Object);
o = static_cast<QJsonPrivate::Object *>(d->header->root());
d->ref.ref();
- return;
+ return true;
}
if (reserve == 0 && d->ref.load() == 1)
- return;
+ return true;
QJsonPrivate::Data *x = d->clone(o, reserve);
+ if (!x)
+ return false;
x->ref.ref();
if (!d->ref.deref())
delete d;
d = x;
o = static_cast<QJsonPrivate::Object *>(d->header->root());
+ return true;
}
/*!
@@ -1094,7 +1150,7 @@ void QJsonObject::compact()
if (!d || !d->compactionCounter)
return;
- detach();
+ detach2();
d->compact();
o = static_cast<QJsonPrivate::Object *>(d->header->root());
}
diff --git a/src/corelib/json/qjsonobject.h b/src/corelib/json/qjsonobject.h
index 5617eee04f..6cffbce83a 100644
--- a/src/corelib/json/qjsonobject.h
+++ b/src/corelib/json/qjsonobject.h
@@ -188,10 +188,10 @@ public:
friend class const_iterator;
// STL style
- inline iterator begin() { detach(); return iterator(this, 0); }
+ inline iterator begin() { detach2(); return iterator(this, 0); }
inline const_iterator begin() const { return const_iterator(this, 0); }
inline const_iterator constBegin() const { return const_iterator(this, 0); }
- inline iterator end() { detach(); return iterator(this, size()); }
+ inline iterator end() { detach2(); return iterator(this, size()); }
inline const_iterator end() const { return const_iterator(this, size()); }
inline const_iterator constEnd() const { return const_iterator(this, size()); }
iterator erase(iterator it);
@@ -221,7 +221,9 @@ private:
QJsonObject(QJsonPrivate::Data *data, QJsonPrivate::Object *object);
void initialize();
+ // ### Qt 6: remove me and merge with detach2
void detach(uint reserve = 0);
+ bool detach2(uint reserve = 0);
void compact();
QString keyAt(int i) const;
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index 4d5b0f156c..a923d83bcf 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -113,6 +113,7 @@ QAppleOperatingSystemVersion qt_apple_os_version()
// Use temporary variables so we can return 0.0.0 (unknown version)
// in case of an error partway through determining the OS version
qint32 major = 0, minor = 0, patch = 0;
+#if QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_10_10, __IPHONE_8_0)
#if defined(Q_OS_IOS)
@autoreleasepool {
NSArray *parts = [UIDevice.currentDevice.systemVersion componentsSeparatedByString:@"."];
@@ -136,6 +137,7 @@ QAppleOperatingSystemVersion qt_apple_os_version()
if (pGestalt('sys3', &patch) != 0)
return v;
#endif
+#endif
v.major = major;
v.minor = minor;
v.patch = patch;
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 42bda25be5..79a3254a39 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -588,7 +588,8 @@ void QCoreApplicationPrivate::initLocale()
This class is used by non-GUI applications to provide their event
loop. For non-GUI application that uses Qt, there should be exactly
one QCoreApplication object. For GUI applications, see
- QApplication.
+ QGuiApplication. For applications that use the Qt Widgets module,
+ see QApplication.
QCoreApplication contains the main event loop, where all events
from the operating system (e.g., timer and network events) and
@@ -602,10 +603,10 @@ void QCoreApplicationPrivate::initLocale()
operations can call processEvents() to keep the application
responsive.
- In general, we recommend that you create a QCoreApplication or a
- QApplication object in your \c main() function as early as
- possible. exec() will not return until the event loop exits; e.g.,
- when quit() is called.
+ In general, we recommend that you create a QCoreApplication,
+ QGuiApplication or a QApplication object in your \c main()
+ function as early as possible. exec() will not return until
+ the event loop exits; e.g., when quit() is called.
Several static convenience functions are also provided. The
QCoreApplication object is available from instance(). Events can
@@ -647,8 +648,8 @@ void QCoreApplicationPrivate::initLocale()
instance, when converting between data types such as floats and
strings, since the notation may differ between locales. To get
around this problem, call the POSIX function \c{setlocale(LC_NUMERIC,"C")}
- right after initializing QApplication or QCoreApplication to reset
- the locale that is used for number formatting to "C"-locale.
+ right after initializing QApplication, QGuiApplication or QCoreApplication
+ to reset the locale that is used for number formatting to "C"-locale.
\sa QGuiApplication, QAbstractEventDispatcher, QEventLoop,
{Semaphores Example}, {Wait Conditions Example}
@@ -658,7 +659,7 @@ void QCoreApplicationPrivate::initLocale()
\fn static QCoreApplication *QCoreApplication::instance()
Returns a pointer to the application's QCoreApplication (or
- QApplication) instance.
+ QGuiApplication/QApplication) instance.
If no instance has been allocated, \c null is returned.
*/
@@ -1865,7 +1866,7 @@ void QCoreApplication::quit()
Installing or removing a QTranslator, or changing an installed QTranslator
generates a \l{QEvent::LanguageChange}{LanguageChange} event for the
- QCoreApplication instance. A QApplication instance will propagate the event
+ QCoreApplication instance. A QGuiApplication instance will propagate the event
to all toplevel windows, where a reimplementation of changeEvent can
re-translate the user interface by passing user-visible strings via the
tr() function to the respective property setters. User-interface classes
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 73cefdafd7..4d7aa83c43 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -942,9 +942,8 @@ void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier)
void QEventDispatcherWin32::unregisterSocketNotifier(QSocketNotifier *notifier)
{
Q_ASSERT(notifier);
- int sockfd = notifier->socket();
- int type = notifier->type();
#ifndef QT_NO_DEBUG
+ int sockfd = notifier->socket();
if (sockfd < 0) {
qWarning("QSocketNotifier: Internal error");
return;
@@ -953,8 +952,16 @@ void QEventDispatcherWin32::unregisterSocketNotifier(QSocketNotifier *notifier)
return;
}
#endif
+ doUnregisterSocketNotifier(notifier);
+}
+void QEventDispatcherWin32::doUnregisterSocketNotifier(QSocketNotifier *notifier)
+{
Q_D(QEventDispatcherWin32);
+ int type = notifier->type();
+ int sockfd = notifier->socket();
+ Q_ASSERT(sockfd >= 0);
+
QSFDict::iterator it = d->active_fd.find(sockfd);
if (it != d->active_fd.end()) {
QSockFd &sd = it.value();
@@ -1210,11 +1217,11 @@ void QEventDispatcherWin32::closingDown()
// clean up any socketnotifiers
while (!d->sn_read.isEmpty())
- unregisterSocketNotifier((*(d->sn_read.begin()))->obj);
+ doUnregisterSocketNotifier((*(d->sn_read.begin()))->obj);
while (!d->sn_write.isEmpty())
- unregisterSocketNotifier((*(d->sn_write.begin()))->obj);
+ doUnregisterSocketNotifier((*(d->sn_write.begin()))->obj);
while (!d->sn_except.isEmpty())
- unregisterSocketNotifier((*(d->sn_except.begin()))->obj);
+ doUnregisterSocketNotifier((*(d->sn_except.begin()))->obj);
Q_ASSERT(d->active_fd.isEmpty());
// clean up any timers
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index 848dbaf475..d745f16975 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -109,6 +109,7 @@ public:
protected:
QEventDispatcherWin32(QEventDispatcherWin32Private &dd, QObject *parent = 0);
virtual void sendPostedEvents();
+ void doUnregisterSocketNotifier(QSocketNotifier *notifier);
private:
friend LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index f576ed0d1c..76f530ab9c 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -56,6 +56,7 @@ static jobject g_jClassLoader = Q_NULLPTR;
static jint g_androidSdkVersion = 0;
static jclass g_jNativeClass = Q_NULLPTR;
static jmethodID g_runPendingCppRunnablesMethodID = Q_NULLPTR;
+static jmethodID g_hideSplashScreenMethodID = Q_NULLPTR;
Q_GLOBAL_STATIC(std::deque<QtAndroidPrivate::Runnable>, g_pendingRunnables);
Q_GLOBAL_STATIC(QMutex, g_pendingRunnablesMutex);
@@ -338,7 +339,7 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
g_runPendingCppRunnablesMethodID = env->GetStaticMethodID(jQtNative,
"runPendingCppRunnablesOnUiThread",
"()V");
-
+ g_hideSplashScreenMethodID = env->GetStaticMethodID(jQtNative, "hideSplashScreen", "()V");
g_jNativeClass = static_cast<jclass>(env->NewGlobalRef(jQtNative));
env->DeleteLocalRef(jQtNative);
@@ -424,4 +425,9 @@ void QtAndroidPrivate::unregisterKeyEventListener(QtAndroidPrivate::KeyEventList
g_keyEventListeners()->listeners.removeOne(listener);
}
+void QtAndroidPrivate::hideSplashScreen(JNIEnv *env)
+{
+ env->CallStaticVoidMethod(g_jNativeClass, g_hideSplashScreenMethodID);
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qjnihelpers_p.h b/src/corelib/kernel/qjnihelpers_p.h
index 34bdbf6c80..78ad08a09e 100644
--- a/src/corelib/kernel/qjnihelpers_p.h
+++ b/src/corelib/kernel/qjnihelpers_p.h
@@ -127,6 +127,8 @@ namespace QtAndroidPrivate
Q_CORE_EXPORT void registerKeyEventListener(KeyEventListener *listener);
Q_CORE_EXPORT void unregisterKeyEventListener(KeyEventListener *listener);
+
+ Q_CORE_EXPORT void hideSplashScreen(JNIEnv *env);
}
QT_END_NAMESPACE
diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp
index 09473caa78..528dca3ff5 100644
--- a/src/corelib/mimetypes/qmimemagicrule.cpp
+++ b/src/corelib/mimetypes/qmimemagicrule.cpp
@@ -234,14 +234,14 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
m_matchFunction(nullptr)
{
if (m_type == Invalid)
- *errorString = QStringLiteral("Type %s is not supported").arg(type);
+ *errorString = QLatin1String("Type ") + type + QLatin1String(" is not supported");
// Parse for offset as "1" or "1:10"
const int colonIndex = offsets.indexOf(QLatin1Char(':'));
- const QString startPosStr = colonIndex == -1 ? offsets : offsets.mid(0, colonIndex);
- const QString endPosStr = colonIndex == -1 ? offsets : offsets.mid(colonIndex + 1);
- if (!QMimeTypeParserBase::parseNumber(startPosStr, &m_startPos, errorString) ||
- !QMimeTypeParserBase::parseNumber(endPosStr, &m_endPos, errorString)) {
+ const QStringRef startPosStr = offsets.midRef(0, colonIndex); // \ These decay to returning 'offsets'
+ const QStringRef endPosStr = offsets.midRef(colonIndex + 1);// / unchanged when colonIndex == -1
+ if (Q_UNLIKELY(!QMimeTypeParserBase::parseNumber(startPosStr, &m_startPos, errorString)) ||
+ Q_UNLIKELY(!QMimeTypeParserBase::parseNumber(endPosStr, &m_endPos, errorString))) {
m_type = Invalid;
return;
}
@@ -249,7 +249,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (m_value.isEmpty()) {
m_type = Invalid;
if (errorString)
- *errorString = QLatin1String("Invalid empty magic rule value");
+ *errorString = QStringLiteral("Invalid empty magic rule value");
return;
}
@@ -259,8 +259,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (!ok) {
m_type = Invalid;
if (errorString)
- *errorString = QString::fromLatin1("Invalid magic rule value \"%1\"").arg(
- QString::fromLatin1(m_value));
+ *errorString = QLatin1String("Invalid magic rule value \"") + QLatin1String(m_value) + QLatin1Char('"');
return;
}
m_numberMask = !m_mask.isEmpty() ? m_mask.toUInt(&ok, 0) : 0; // autodetect base
@@ -274,8 +273,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (m_mask.size() < 4 || !m_mask.startsWith("0x")) {
m_type = Invalid;
if (errorString)
- *errorString = QString::fromLatin1("Invalid magic rule mask \"%1\"").arg(
- QString::fromLatin1(m_mask));
+ *errorString = QLatin1String("Invalid magic rule mask \"") + QLatin1String(m_mask) + QLatin1Char('"');
return;
}
const QByteArray &tempMask = QByteArray::fromHex(QByteArray::fromRawData(
@@ -283,8 +281,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (tempMask.size() != m_pattern.size()) {
m_type = Invalid;
if (errorString)
- *errorString = QString::fromLatin1("Invalid magic rule mask size \"%1\"").arg(
- QString::fromLatin1(m_mask));
+ *errorString = QLatin1String("Invalid magic rule mask size \"") + QLatin1String(m_mask) + QLatin1Char('"');
return;
}
m_mask = tempMask;
diff --git a/src/corelib/mimetypes/qmimetypeparser.cpp b/src/corelib/mimetypes/qmimetypeparser.cpp
index 4e348b08ac..9ed345d37e 100644
--- a/src/corelib/mimetypes/qmimetypeparser.cpp
+++ b/src/corelib/mimetypes/qmimetypeparser.cpp
@@ -160,25 +160,36 @@ QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState curren
}
// Parse int number from an (attribute) string
-bool QMimeTypeParserBase::parseNumber(const QString &n, int *target, QString *errorMessage)
+bool QMimeTypeParserBase::parseNumber(const QStringRef &n, int *target, QString *errorMessage)
{
bool ok;
*target = n.toInt(&ok);
if (!ok) {
- *errorMessage = QString::fromLatin1("Not a number '%1'.").arg(n);
+ *errorMessage = QLatin1String("Not a number '") + n + QLatin1String("'.");
return false;
}
return true;
}
#ifndef QT_NO_XMLSTREAMREADER
-static QMimeMagicRule *createMagicMatchRule(const QXmlStreamAttributes &atts, QString *errorMessage)
+struct CreateMagicMatchRuleResult {
+ QString errorMessage; // must be first
+ QMimeMagicRule rule;
+
+ CreateMagicMatchRuleResult(const QStringRef &type, const QStringRef &value, const QStringRef &offsets, const QStringRef &mask)
+ : errorMessage(), rule(type.toString(), value.toUtf8(), offsets.toString(), mask.toLatin1(), &errorMessage)
+ {
+
+ }
+};
+
+static CreateMagicMatchRuleResult createMagicMatchRule(const QXmlStreamAttributes &atts)
{
- const QString type = atts.value(QLatin1String(matchTypeAttributeC)).toString();
- const QString value = atts.value(QLatin1String(matchValueAttributeC)).toString();
- const QString offsets = atts.value(QLatin1String(matchOffsetAttributeC)).toString();
- const QString mask = atts.value(QLatin1String(matchMaskAttributeC)).toString();
- return new QMimeMagicRule(type, value.toUtf8(), offsets, mask.toLatin1(), errorMessage);
+ const QStringRef type = atts.value(QLatin1String(matchTypeAttributeC));
+ const QStringRef value = atts.value(QLatin1String(matchValueAttributeC));
+ const QStringRef offsets = atts.value(QLatin1String(matchOffsetAttributeC));
+ const QStringRef mask = atts.value(QLatin1String(matchMaskAttributeC));
+ return CreateMagicMatchRuleResult(type, value, offsets, mask);
}
#endif
@@ -195,17 +206,16 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
QList<QMimeMagicRule> rules; // toplevel rules
QXmlStreamReader reader(dev);
ParseState ps = ParseBeginning;
- QXmlStreamAttributes atts;
while (!reader.atEnd()) {
switch (reader.readNext()) {
- case QXmlStreamReader::StartElement:
+ case QXmlStreamReader::StartElement: {
ps = nextState(ps, reader.name());
- atts = reader.attributes();
+ const QXmlStreamAttributes atts = reader.attributes();
switch (ps) {
case ParseMimeType: { // start parsing a MIME type name
const QString name = atts.value(QLatin1String(mimeTypeAttributeC)).toString();
if (name.isEmpty()) {
- reader.raiseError(QString::fromLatin1("Missing '%1'-attribute").arg(QString::fromLatin1(mimeTypeAttributeC)));
+ reader.raiseError(QStringLiteral("Missing 'type'-attribute"));
} else {
data.name = name;
}
@@ -219,8 +229,8 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
break;
case ParseGlobPattern: {
const QString pattern = atts.value(QLatin1String(patternAttributeC)).toString();
- unsigned weight = atts.value(QLatin1String(weightAttributeC)).toString().toInt();
- const bool caseSensitive = atts.value(QLatin1String(caseSensitiveAttributeC)).toString() == QLatin1String("true");
+ unsigned weight = atts.value(QLatin1String(weightAttributeC)).toInt();
+ const bool caseSensitive = atts.value(QLatin1String(caseSensitiveAttributeC)) == QLatin1String("true");
if (weight == 0)
weight = QMimeGlobPattern::DefaultWeight;
@@ -255,7 +265,7 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
break;
case ParseMagic: {
priority = 50;
- const QString priorityS = atts.value(QLatin1String(priorityAttributeC)).toString();
+ const QStringRef priorityS = atts.value(QLatin1String(priorityAttributeC));
if (!priorityS.isEmpty()) {
if (!parseNumber(priorityS, &priority, errorMessage))
return false;
@@ -266,28 +276,27 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
}
break;
case ParseMagicMatchRule: {
- QString magicErrorMessage;
- QMimeMagicRule *rule = createMagicMatchRule(atts, &magicErrorMessage);
- if (!rule->isValid())
- qWarning("QMimeDatabase: Error parsing %s\n%s", qPrintable(fileName), qPrintable(magicErrorMessage));
+ auto result = createMagicMatchRule(atts);
+ if (Q_UNLIKELY(!result.rule.isValid()))
+ qWarning("QMimeDatabase: Error parsing %ls\n%ls",
+ qUtf16Printable(fileName), qUtf16Printable(result.errorMessage));
QList<QMimeMagicRule> *ruleList;
if (currentRules.isEmpty())
ruleList = &rules;
else // nest this rule into the proper parent
ruleList = &currentRules.top()->m_subMatches;
- ruleList->append(*rule);
+ ruleList->append(std::move(result.rule));
//qDebug() << " MATCH added. Stack size was" << currentRules.size();
currentRules.push(&ruleList->last());
- delete rule;
break;
}
case ParseError:
- reader.raiseError(QString::fromLatin1("Unexpected element <%1>").
- arg(reader.name().toString()));
+ reader.raiseError(QLatin1String("Unexpected element <") + reader.name() + QLatin1Char('>'));
break;
default:
break;
}
+ }
break;
// continue switch QXmlStreamReader::Token...
case QXmlStreamReader::EndElement: // Finished element
diff --git a/src/corelib/mimetypes/qmimetypeparser_p.h b/src/corelib/mimetypes/qmimetypeparser_p.h
index cc11b70e71..a502439419 100644
--- a/src/corelib/mimetypes/qmimetypeparser_p.h
+++ b/src/corelib/mimetypes/qmimetypeparser_p.h
@@ -72,7 +72,7 @@ public:
bool parse(QIODevice *dev, const QString &fileName, QString *errorMessage);
- static bool parseNumber(const QString &n, int *target, QString *errorMessage);
+ static bool parseNumber(const QStringRef &n, int *target, QString *errorMessage);
protected:
virtual bool process(const QMimeType &t, QString *errorMessage) = 0;
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index a9d3c7f5d8..6587d900d2 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -1029,7 +1029,7 @@ QString QCommandLineParser::helpText() const
static QString wrapText(const QString &names, int longestOptionNameString, const QString &description)
{
const QLatin1Char nl('\n');
- QString text = QStringLiteral(" ") + names.leftJustified(longestOptionNameString) + QLatin1Char(' ');
+ QString text = QLatin1String(" ") + names.leftJustified(longestOptionNameString) + QLatin1Char(' ');
const int indent = text.length();
int lineStart = 0;
int lastBreakable = -1;
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 2a4d6da477..90edeca0a8 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -1181,7 +1181,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
/*!
\fn QPair<iterator, iterator> QMap::equal_range(const Key &key)
- Returns a pair of iterators delimiting the range of values that
+ Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
are stored under \a key.
*/
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
index 7e2d909dcd..db2004dfd9 100644
--- a/src/corelib/tools/qringbuffer.cpp
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -276,7 +276,6 @@ QByteArray QRingBuffer::read()
if (tailBuffer == 0) {
qba.resize(tail);
tail = 0;
- buffers.append(QByteArray());
} else {
--tailBuffer;
}
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index 366ce1477f..13b0032605 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -42,7 +42,7 @@
#include <QtCore/qglobal.h>
#include <QtCore/qatomic.h>
-#if QT_DEPRECATED_SINCE(5, 5)
+#if QT_DEPRECATED_SINCE(5, 6)
#include <QtCore/qhash.h>
#endif
#include <QtCore/qhashfunctions.h>
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index a946191cde..6a5c8f4fe5 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -63,7 +63,7 @@ QT_END_NAMESPACE
#include <QtCore/qatomic.h>
#include <QtCore/qobject.h> // for qobject_cast
#include <QtCore/qdebug.h>
-#if QT_DEPRECATED_SINCE(5, 5)
+#if QT_DEPRECATED_SINCE(5, 6)
#include <QtCore/qhash.h>
#endif
#include <QtCore/qhashfunctions.h>
diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp
index 0984949286..1d19f01b4e 100644
--- a/src/corelib/tools/qtimezoneprivate_win.cpp
+++ b/src/corelib/tools/qtimezoneprivate_win.cpp
@@ -378,7 +378,7 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
m_standardName = readRegistryString(baseKey, L"Std");
m_daylightName = readRegistryString(baseKey, L"Dlt");
// On Vista and later the optional dynamic key holds historic data
- const QString dynamicKeyPath = baseKeyPath + QStringLiteral("\\Dynamic DST");
+ const QString dynamicKeyPath = baseKeyPath + QLatin1String("\\Dynamic DST");
HKEY dynamicKey = NULL;
if (openRegistryKey(dynamicKeyPath, &dynamicKey)) {
// Find out the start and end years stored, then iterate over them
diff --git a/src/dbus/qdbusabstractinterface.h b/src/dbus/qdbusabstractinterface.h
index 37f5939f53..32c33f19f2 100644
--- a/src/dbus/qdbusabstractinterface.h
+++ b/src/dbus/qdbusabstractinterface.h
@@ -49,6 +49,10 @@
#include <QtDBus/qdbusextratypes.h>
#include <QtDBus/qdbusconnection.h>
+#ifdef interface
+#undef interface
+#endif
+
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index 017691aaf7..3f2e80cdac 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -60,6 +60,10 @@
#include <algorithm>
+#ifdef interface
+#undef interface
+#endif
+
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h
index 8c18459f2a..b65bfc1e9b 100644
--- a/src/dbus/qdbusextratypes.h
+++ b/src/dbus/qdbusextratypes.h
@@ -45,7 +45,7 @@
#include <QtCore/qvariant.h>
#include <QtCore/qstring.h>
#include <QtDBus/qdbusmacros.h>
-#if QT_DEPRECATED_SINCE(5, 5)
+#if QT_DEPRECATED_SINCE(5, 6)
#include <QtCore/qhash.h>
#endif
#include <QtCore/qhashfunctions.h>
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index b6fb9ae7cf..25678a56a9 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -69,6 +69,9 @@
#include "qdbusthreaddebug_p.h"
#include <algorithm>
+#ifdef interface
+#undef interface
+#endif
#ifndef QT_NO_DBUS
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index 3c8cc57572..b8290861af 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -300,7 +300,7 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
if (depth != 32) {
ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits;
- if (ncols > 256) // sanity check - don't run out of mem if color table is broken
+ if (ncols < 1 || ncols > 256) // sanity check - don't run out of mem if color table is broken
return false;
image.setColorCount(ncols);
}
diff --git a/src/gui/image/qgifhandler.cpp b/src/gui/image/qgifhandler.cpp
index 436567d432..476b456563 100644
--- a/src/gui/image/qgifhandler.cpp
+++ b/src/gui/image/qgifhandler.cpp
@@ -205,7 +205,7 @@ void QGIFFormat::disposePrevious(QImage *image)
fillRect(image, l, t, r-l+1, b-t+1, color(bgcol));
} else {
// Impossible: We don't know of a bgcol - use pixel 0
- QRgb *bits = (QRgb*)image->bits();
+ const QRgb *bits = reinterpret_cast<const QRgb *>(image->constBits());
fillRect(image, l, t, r-l+1, b-t+1, bits[0]);
}
// ### Changed: QRect(l, t, r-l+1, b-t+1)
@@ -214,7 +214,7 @@ void QGIFFormat::disposePrevious(QImage *image)
if (frame >= 0) {
for (int ln=t; ln<=b; ln++) {
memcpy(image->scanLine(ln)+l,
- backingstore.scanLine(ln-t),
+ backingstore.constScanLine(ln-t),
(r-l+1)*sizeof(QRgb));
}
// ### Changed: QRect(l, t, r-l+1, b-t+1)
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 4ccdaca94e..2aa19a8465 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -144,7 +144,7 @@ public:
QImage(const QImage &);
#ifdef Q_COMPILER_RVALUE_REFS
inline QImage(QImage &&other) Q_DECL_NOEXCEPT
- : QPaintDevice(), d(0)
+ : QPaintDevice(), d(Q_NULLPTR)
{ qSwap(d, other.d); }
#endif
~QImage();
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index 8e65f69d6e..8106289ad1 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -195,6 +195,12 @@ inline QImage::Format qt_alphaVersion(QImage::Format format)
return QImage::Format_ARGB32_Premultiplied;
}
+inline QImage::Format qt_maybeAlphaVersionWithSameDepth(QImage::Format format)
+{
+ const QImage::Format toFormat = qt_alphaVersion(format);
+ return qt_depthForFormat(format) == qt_depthForFormat(toFormat) ? toFormat : format;
+}
+
inline QImage::Format qt_alphaVersionForPainting(QImage::Format format)
{
QImage::Format toFormat = qt_alphaVersion(format);
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp
index a409840612..0906b65d96 100644
--- a/src/gui/image/qpixmap_blitter.cpp
+++ b/src/gui/image/qpixmap_blitter.cpp
@@ -189,7 +189,7 @@ void QBlittablePlatformPixmap::fromImage(const QImage &image,
correctFormatPic = correctFormatPic.convertToFormat(thisImg->format(), flags);
uchar *mem = thisImg->bits();
- const uchar *bits = correctFormatPic.bits();
+ const uchar *bits = correctFormatPic.constBits();
int bytesCopied = 0;
while (bytesCopied < correctFormatPic.byteCount()) {
memcpy(mem,bits,correctFormatPic.bytesPerLine());
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index 73700a9f52..7f20586156 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -204,7 +204,7 @@ Q_GUI_EXPORT HBITMAP qt_createIconMask(const QBitmap &bitmap)
QScopedArrayPointer<uchar> bits(new uchar[bpl * h]);
bm.invertPixels();
for (int y = 0; y < h; ++y)
- memcpy(bits.data() + y * bpl, bm.scanLine(y), bpl);
+ memcpy(bits.data() + y * bpl, bm.constScanLine(y), bpl);
HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits.data());
return hbm;
}
diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp
index 1e34db1450..42d3684aea 100644
--- a/src/gui/image/qppmhandler.cpp
+++ b/src/gui/image/qppmhandler.cpp
@@ -335,7 +335,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
if (image.format() == QImage::Format_Indexed8) {
QVector<QRgb> color = image.colorTable();
for (uint y=0; y<h; y++) {
- uchar *b = image.scanLine(y);
+ const uchar *b = image.constScanLine(y);
uchar *p = buf;
uchar *end = buf+bpl;
if (gray) {
@@ -356,7 +356,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
}
} else {
for (uint y=0; y<h; y++) {
- uchar *b = image.scanLine(y);
+ const uchar *b = image.constScanLine(y);
uchar *p = buf;
uchar *end = buf + bpl;
if (gray) {
@@ -386,7 +386,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
uint bpl = w * 3;
uchar *buf = new uchar[bpl];
for (uint y=0; y<h; y++) {
- QRgb *b = (QRgb*)image.scanLine(y);
+ const QRgb *b = reinterpret_cast<const QRgb *>(image.constScanLine(y));
uchar *p = buf;
uchar *end = buf+bpl;
while (p < end) {
diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp
index d277f8ccfd..eda816f0f2 100644
--- a/src/gui/image/qxbmhandler.cpp
+++ b/src/gui/image/qxbmhandler.cpp
@@ -216,7 +216,7 @@ static bool write_xbm_image(const QImage &sourceImage, QIODevice *device, const
char *p = buf;
int bpl = (w+7)/8;
for (int y = 0; y < h; ++y) {
- uchar *b = image.scanLine(y);
+ const uchar *b = image.constScanLine(y);
for (i = 0; i < bpl; ++i) {
*p++ = '0'; *p++ = 'x';
*p++ = hexrep[*b >> 4];
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index 235a9c5410..5ae8e893cb 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -1104,7 +1104,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const
// build color table
for(y=0; y<h; y++) {
- QRgb * yp = (QRgb *)image.scanLine(y);
+ const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y));
for(x=0; x<w; x++) {
QRgb color = *(yp + x);
if (!colorMap.contains(color))
@@ -1150,7 +1150,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const
// write pixels, limit to 4 characters per pixel
line.truncate(cpp*w);
for(y=0; y<h; y++) {
- QRgb * yp = (QRgb *) image.scanLine(y);
+ const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y));
int cc = 0;
for(x=0; x<w; x++) {
int color = (int)(*(yp + x));
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 223d54af96..d84cbeddf2 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3586,6 +3586,7 @@ static inline void formatTouchEvent(QDebug d, const QTouchEvent &t)
{
d << "QTouchEvent(";
QtDebugUtils::formatQEnum(d, t.type());
+ d << " device: " << t.device()->name();
d << " states: ";
QtDebugUtils::formatQFlags(d, t.touchPointStates());
d << ", " << t.touchPoints().size() << " points: " << t.touchPoints() << ')';
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 979e679c1e..eca5e6951d 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -801,7 +801,7 @@ public:
TouchPoint(const TouchPoint &other);
#ifdef Q_COMPILER_RVALUE_REFS
TouchPoint(TouchPoint &&other) Q_DECL_NOEXCEPT
- : d(0)
+ : d(Q_NULLPTR)
{ qSwap(d, other.d); }
TouchPoint &operator=(TouchPoint &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 50fb4d73ea..fe71de6c27 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -53,6 +53,7 @@
#include <QtCore/qglobal.h>
#include <QtCore/qmargins.h>
+#include <QtCore/qmath.h>
#include <QtCore/qrect.h>
#include <QtCore/qvector.h>
#include <QtCore/qloggingcategory.h>
@@ -389,6 +390,24 @@ inline QRegion fromNativeLocalRegion(const QRegion &pixelRegion, const QWindow *
return pointRegion;
}
+// 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 window.
+inline QRegion fromNativeLocalExposedRegion(const QRegion &pixelRegion, const QWindow *window)
+{
+ if (!QHighDpiScaling::isActive())
+ return pixelRegion;
+
+ const qreal scaleFactor = QHighDpiScaling::factor(window);
+ QRegion pointRegion;
+ foreach (const QRect &rect, pixelRegion.rects()) {
+ const QPointF topLeftP = QPointF(rect.topLeft()) / scaleFactor;
+ const QPointF bottomRightP = QPointF(rect.bottomRight()) / scaleFactor;
+ pointRegion += QRect(QPoint(qFloor(topLeftP.x()), qFloor(topLeftP.y())),
+ QPoint(qCeil(bottomRightP.x()), qCeil(bottomRightP.y())));
+ }
+ return pointRegion;
+}
+
inline QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *window)
{
if (!QHighDpiScaling::isActive())
@@ -454,6 +473,7 @@ QVector<T> fromNativePixels(const QVector<T> &pixelValues, const QWindow *window
return pixelValues;
QVector<T> pointValues;
+ pointValues.reserve(pixelValues.size());
for (const T &pixelValue : pixelValues)
pointValues.append(pixelValue / QHighDpiScaling::factor(window));
return pointValues;
@@ -467,6 +487,7 @@ QVector<T> toNativePixels(const QVector<T> &pointValues, const QWindow *window)
return pointValues;
QVector<T> pixelValues;
+ pixelValues.reserve(pointValues.size());
for (const T &pointValue : pointValues)
pixelValues.append(pointValue * QHighDpiScaling::factor(window));
return pixelValues;
@@ -506,6 +527,8 @@ namespace QHighDpi {
template <typename T> inline
T fromNativeLocalRegion(const T &value, ...) { return value; }
template <typename T> inline
+ T fromNativeLocalExposedRegion(const T &value, ...) { return value; }
+ template <typename T> inline
T toNativeLocalRegion(const T &value, ...) { return value; }
template <typename T> inline
diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h
index b3c7fe957d..56eb6f0e12 100644
--- a/src/gui/kernel/qopenglcontext.h
+++ b/src/gui/kernel/qopenglcontext.h
@@ -60,7 +60,7 @@
#include <QtGui/qopengl.h>
#include <QtGui/qopenglversionfunctions.h>
-#if QT_DEPRECATED_SINCE(5, 5)
+#if QT_DEPRECATED_SINCE(5, 6)
#include <QtCore/qhash.h>
#endif
#include <QtCore/qhashfunctions.h>
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index af0d71a57a..fe4d167078 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -39,6 +39,7 @@
#include "qplatformdialoghelper.h"
+#include <QtCore/QCoreApplication>
#include <QtCore/QVariant>
#include <QtCore/QSharedData>
#include <QtCore/QSettings>
@@ -257,7 +258,7 @@ void QColorDialogStaticData::readSettings()
#ifndef QT_NO_SETTINGS
const QSettings settings(QSettings::UserScope, QStringLiteral("QtProject"));
for (int i = 0; i < int(CustomColorCount); ++i) {
- const QVariant v = settings.value(QStringLiteral("Qt/customColors/") + QString::number(i));
+ const QVariant v = settings.value(QLatin1String("Qt/customColors/") + QString::number(i));
if (v.isValid())
customRgb[i] = v.toUInt();
}
@@ -270,7 +271,7 @@ void QColorDialogStaticData::writeSettings() const
if (!customSet) {
QSettings settings(QSettings::UserScope, QStringLiteral("QtProject"));
for (int i = 0; i < int(CustomColorCount); ++i)
- settings.setValue(QStringLiteral("Qt/customColors/") + QString::number(i), customRgb[i]);
+ settings.setValue(QLatin1String("Qt/customColors/") + QString::number(i), customRgb[i]);
}
#endif
}
@@ -411,7 +412,8 @@ public:
viewMode(QFileDialogOptions::Detail),
fileMode(QFileDialogOptions::AnyFile),
acceptMode(QFileDialogOptions::AcceptOpen),
- filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs)
+ filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs),
+ useDefaultNameFilters(true)
{}
QFileDialogOptions::FileDialogOptions options;
@@ -423,6 +425,7 @@ public:
QString labels[QFileDialogOptions::DialogLabelCount];
QDir::Filters filters;
QList<QUrl> sidebarUrls;
+ bool useDefaultNameFilters;
QStringList nameFilters;
QStringList mimeTypeFilters;
QString defaultSuffix;
@@ -534,14 +537,48 @@ QList<QUrl> QFileDialogOptions::sidebarUrls() const
return d->sidebarUrls;
}
+/*!
+ \since 5.7
+ \internal
+ The bool property useDefaultNameFilters indicates that no name filters have been
+ set or that they are equivalent to \gui{All Files (*)}. If it is true, the
+ platform can choose to hide the filter combo box.
+
+ \sa defaultNameFilterString().
+*/
+bool QFileDialogOptions::useDefaultNameFilters() const
+{
+ return d->useDefaultNameFilters;
+}
+
+void QFileDialogOptions::setUseDefaultNameFilters(bool dnf)
+{
+ d->useDefaultNameFilters = dnf;
+}
+
void QFileDialogOptions::setNameFilters(const QStringList &filters)
{
+ d->useDefaultNameFilters = filters.size() == 1
+ && filters.first() == QFileDialogOptions::defaultNameFilterString();
d->nameFilters = filters;
}
QStringList QFileDialogOptions::nameFilters() const
{
- return d->nameFilters;
+ return d->useDefaultNameFilters ?
+ QStringList(QFileDialogOptions::defaultNameFilterString()) : d->nameFilters;
+}
+
+/*!
+ \since 5.6
+ \internal
+ \return The translated default name filter string (\gui{All Files (*)}).
+ \sa defaultNameFilters(), nameFilters()
+*/
+
+QString QFileDialogOptions::defaultNameFilterString()
+{
+ return QCoreApplication::translate("QFileDialog", "All Files (*)");
}
void QFileDialogOptions::setMimeTypeFilters(const QStringList &filters)
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index d0594593dd..825dcf293d 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -349,6 +349,9 @@ public:
void setSidebarUrls(const QList<QUrl> &urls);
QList<QUrl> sidebarUrls() const;
+ bool useDefaultNameFilters() const;
+ void setUseDefaultNameFilters(bool d);
+
void setNameFilters(const QStringList &filters);
QStringList nameFilters() const;
@@ -377,6 +380,8 @@ public:
void setSupportedSchemes(const QStringList &schemes);
QStringList supportedSchemes() const;
+ static QString defaultNameFilterString();
+
private:
QSharedDataPointer<QFileDialogOptionsPrivate> d;
};
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index abbd1fe999..1d444f94c9 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -490,8 +490,10 @@ QPlatformScreen *QPlatformWindow::screenForGeometry(const QRect &newGeometry) co
{
QPlatformScreen *currentScreen = screen();
QPlatformScreen *fallback = currentScreen;
- //QRect::center can return a value outside the rectangle if it's empty
- const QPoint center = newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center();
+ // QRect::center can return a value outside the rectangle if it's empty.
+ // Apply mapToGlobal() in case it is a foreign/embedded window.
+ const QPoint center =
+ mapToGlobal(newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center());
if (!parent() && currentScreen && !currentScreen->geometry().contains(center)) {
const auto screens = currentScreen->virtualSiblings();
@@ -550,8 +552,8 @@ static inline const QScreen *effectiveScreen(const QWindow *window)
const QScreen *screen = window->screen();
if (!screen)
return QGuiApplication::primaryScreen();
- const QList<QScreen *> siblings = screen->virtualSiblings();
#ifndef QT_NO_CURSOR
+ const QList<QScreen *> siblings = screen->virtualSiblings();
if (siblings.size() > 1) {
const QPoint referencePoint = window->transientParent() ? window->transientParent()->geometry().center() : QCursor::pos();
for (const QScreen *sibling : siblings) {
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index 214c656a0b..a6ce04dc34 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -94,7 +94,8 @@ static QWindow* topLevelAt(const QPoint &pos)
QBasicDrag::QBasicDrag() :
m_restoreCursor(false), m_eventLoop(0),
m_executed_drop_action(Qt::IgnoreAction), m_can_drop(false),
- m_drag(0), m_drag_icon_window(0), m_useCompositing(true)
+ m_drag(0), m_drag_icon_window(0), m_useCompositing(true),
+ m_screen(Q_NULLPTR)
{
}
@@ -225,7 +226,7 @@ void QBasicDrag::startDrag()
pos = QPoint();
}
#endif
- recreateShapedPixmapWindow(Q_NULLPTR, pos);
+ recreateShapedPixmapWindow(m_screen, pos);
enableEventFilter();
}
diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h
index c7a40d1d03..8924b4d08f 100644
--- a/src/gui/kernel/qsimpledrag_p.h
+++ b/src/gui/kernel/qsimpledrag_p.h
@@ -97,6 +97,8 @@ protected:
bool useCompositing() const { return m_useCompositing; }
void setUseCompositing(bool on) { m_useCompositing = on; }
+ void setScreen(QScreen *screen) { m_screen = screen; }
+
Qt::DropAction executedDropAction() const { return m_executed_drop_action; }
void setExecutedDropAction(Qt::DropAction da) { m_executed_drop_action = da; }
@@ -115,6 +117,7 @@ private:
QDrag *m_drag;
QShapedPixmapWindow *m_drag_icon_window;
bool m_useCompositing;
+ QScreen *m_screen;
};
class Q_GUI_EXPORT QSimpleDrag : public QBasicDrag
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 0c7e0e5816..44fa88e7cf 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -375,7 +375,7 @@ void QWindowPrivate::setTopLevelScreen(QScreen *newScreen, bool recreate)
{
Q_Q(QWindow);
if (parentWindow) {
- qWarning() << this << '(' << newScreen << "): Attempt to set a screen on a child window.";
+ qWarning() << q << '(' << newScreen << "): Attempt to set a screen on a child window.";
return;
}
if (newScreen != topLevelScreen) {
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 2489974bb3..39bc161a7c 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -588,7 +588,8 @@ void QWindowSystemInterface::handleThemeChange(QWindow *tlw)
void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion &region)
{
- QWindowSystemInterfacePrivate::ExposeEvent *e = new QWindowSystemInterfacePrivate::ExposeEvent(tlw, QHighDpi::fromNativeLocalRegion(region, tlw));
+ QWindowSystemInterfacePrivate::ExposeEvent *e =
+ new QWindowSystemInterfacePrivate::ExposeEvent(tlw, QHighDpi::fromNativeLocalExposedRegion(region, tlw));
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
@@ -874,7 +875,7 @@ Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::Keybo
QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous);
}
-Q_GUI_EXPORT bool qt_handleShortcutEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1)
+Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1)
{
#ifndef QT_NO_SHORTCUT
@@ -927,7 +928,7 @@ static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoi
static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QList<QTouchEvent::TouchPoint>& pointList)
{
QList<struct QWindowSystemInterface::TouchPoint> newList;
-
+ newList.reserve(pointList.size());
for (const QTouchEvent::TouchPoint &p : pointList)
newList.append(touchPoint(p));
diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp
index 35b1ec3bcf..a798db662c 100644
--- a/src/gui/opengl/qopengl.cpp
+++ b/src/gui/opengl/qopengl.cpp
@@ -85,7 +85,7 @@ QOpenGLExtensionMatcher::QOpenGLExtensionMatcher()
if (!glGetStringi)
return;
- GLint numExtensions;
+ GLint numExtensions = 0;
funcs->glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
for (int i = 0; i < numExtensions; ++i) {
diff --git a/src/gui/opengl/qopenglextrafunctions.h b/src/gui/opengl/qopenglextrafunctions.h
index 06ab749f19..d3b25fa348 100644
--- a/src/gui/opengl/qopenglextrafunctions.h
+++ b/src/gui/opengl/qopenglextrafunctions.h
@@ -410,7 +410,7 @@ public:
void glVertexBindingDivisor(GLuint bindingindex, GLuint divisor);
private:
- static bool isInitialized(const QOpenGLExtraFunctionsPrivate *d) { return d != 0; }
+ static bool isInitialized(const QOpenGLExtraFunctionsPrivate *d) { return d != Q_NULLPTR; }
};
class QOpenGLExtraFunctionsPrivate : public QOpenGLFunctionsPrivate
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
index a32c111178..9ac020b64b 100644
--- a/src/gui/opengl/qopenglshaderprogram.cpp
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
@@ -3390,7 +3390,7 @@ QVector<float> QOpenGLShaderProgram::defaultInnerTessellationLevels() const
#if defined(QT_OPENGL_4)
Q_D(const QOpenGLShaderProgram);
if (d->tessellationFuncs)
- d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_OUTER_LEVEL, tessLevels.data());
+ d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_INNER_LEVEL, tessLevels.data());
#endif
return tessLevels;
}
diff --git a/src/gui/opengl/qopenglversionfunctions.h b/src/gui/opengl/qopenglversionfunctions.h
index cf6af549cb..20b21b8103 100644
--- a/src/gui/opengl/qopenglversionfunctions.h
+++ b/src/gui/opengl/qopenglversionfunctions.h
@@ -53,7 +53,7 @@
#ifndef QT_NO_OPENGL
-#if QT_DEPRECATED_SINCE(5, 5)
+#if QT_DEPRECATED_SINCE(5, 6)
#include <QtCore/qhash.h>
#endif
#include <QtCore/qhashfunctions.h>
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index 17304b16aa..801397751b 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -112,7 +112,8 @@ void QBackingStore::flush(const QRegion &region, QWindow *win, const QPoint &off
}
#endif
- d_ptr->platformBackingStore->flush(win, QHighDpi::toNativeLocalRegion(region, d_ptr->window), offset);
+ d_ptr->platformBackingStore->flush(win, QHighDpi::toNativeLocalRegion(region, win),
+ QHighDpi::toNativeLocalPosition(offset, win));
}
/*!
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index dcfa3f0647..1143123717 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -3426,13 +3426,13 @@ static SourceFetchProc64 sourceFetch64[NBlendTypes][QImage::NImageFormats] = {
static uint qt_gradient_pixel_fixed(const QGradientData *data, int fixed_pos)
{
int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS;
- return data->colorTable[qt_gradient_clamp(data, ipos)].toArgb32();
+ return data->colorTable32[qt_gradient_clamp(data, ipos)];
}
static const QRgba64& qt_gradient_pixel64_fixed(const QGradientData *data, int fixed_pos)
{
int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS;
- return data->colorTable[qt_gradient_clamp(data, ipos)];
+ return data->colorTable64[qt_gradient_clamp(data, ipos)];
}
static void QT_FASTCALL getLinearGradientValues(LinearGradientValues *v, const QSpanData *data)
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index cd53b688e9..af52ed0b43 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -274,7 +274,8 @@ struct QGradientData
#define GRADIENT_STOPTABLE_SIZE 1024
#define GRADIENT_STOPTABLE_SIZE_SHIFT 10
- QRgba64* colorTable; //[GRADIENT_STOPTABLE_SIZE];
+ const QRgba64 *colorTable64; //[GRADIENT_STOPTABLE_SIZE];
+ const QRgb *colorTable32; //[GRADIENT_STOPTABLE_SIZE];
uint alphaColor : 1;
};
@@ -382,13 +383,13 @@ static inline uint qt_gradient_clamp(const QGradientData *data, int ipos)
static inline uint qt_gradient_pixel(const QGradientData *data, qreal pos)
{
int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5));
- return data->colorTable[qt_gradient_clamp(data, ipos)].toArgb32();
+ return data->colorTable32[qt_gradient_clamp(data, ipos)];
}
static inline const QRgba64& qt_gradient_pixel64(const QGradientData *data, qreal pos)
{
int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5));
- return data->colorTable[qt_gradient_clamp(data, ipos)];
+ return data->colorTable64[qt_gradient_clamp(data, ipos)];
}
static inline qreal qRadialDeterminant(qreal a, qreal b, qreal c)
@@ -556,7 +557,7 @@ public:
delta_det4_vec.v = Simd::v_add(delta_det4_vec.v, v_delta_delta_det16); \
b_vec.v = Simd::v_add(b_vec.v, v_delta_b4); \
for (int i = 0; i < 4; ++i) \
- *buffer++ = (extended_mask | v_buffer_mask.i[i]) & data->gradient.colorTable[index_vec.i[i]].toArgb32(); \
+ *buffer++ = (extended_mask | v_buffer_mask.i[i]) & data->gradient.colorTable32[index_vec.i[i]]; \
}
#define FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP) \
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index e63d29a39d..34b4d97758 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -689,6 +689,7 @@ void QRasterPaintEngine::penChanged()
qDebug() << "QRasterPaintEngine::penChanged():" << state()->pen;
#endif
QRasterPaintEngineState *s = state();
+ Q_ASSERT(s);
s->strokeFlags |= DirtyPen;
s->dirty |= DirtyPen;
}
@@ -2200,6 +2201,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state();
+ Q_ASSERT(s);
int sr_l = qFloor(sr.left());
int sr_r = qCeil(sr.right()) - 1;
int sr_t = qFloor(sr.top());
@@ -2437,6 +2439,7 @@ void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap,
#endif
Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state();
+ Q_ASSERT(s);
QImage image;
@@ -3616,7 +3619,7 @@ QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color)
{
Q_ASSERT(image.depth() == 1);
- QImage sourceImage = image.convertToFormat(QImage::Format_MonoLSB);
+ const QImage sourceImage = image.convertToFormat(QImage::Format_MonoLSB);
QImage dest = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied);
QRgb fg = qPremultiply(color.rgba());
@@ -3625,7 +3628,7 @@ QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color)
int height = sourceImage.height();
int width = sourceImage.width();
for (int y=0; y<height; ++y) {
- uchar *source = sourceImage.scanLine(y);
+ const uchar *source = sourceImage.constScanLine(y);
QRgb *target = reinterpret_cast<QRgb *>(dest.scanLine(y));
if (!source || !target)
QT_THROW(std::bad_alloc()); // we must have run out of memory
@@ -4144,7 +4147,8 @@ class QGradientCache
{
inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) :
stops(qMove(s)), opacity(op), interpolationMode(mode) {}
- QRgba64 buffer[GRADIENT_STOPTABLE_SIZE];
+ QRgba64 buffer64[GRADIENT_STOPTABLE_SIZE];
+ QRgb buffer32[GRADIENT_STOPTABLE_SIZE];
QGradientStops stops;
int opacity;
QGradient::InterpolationMode interpolationMode;
@@ -4153,7 +4157,9 @@ class QGradientCache
typedef QMultiHash<quint64, CacheInfo> QGradientColorTableHash;
public:
- inline const QRgba64 *getBuffer(const QGradient &gradient, int opacity) {
+ typedef QPair<const QRgb *, const QRgba64 *> ColorBufferPair;
+
+ inline ColorBufferPair getBuffer(const QGradient &gradient, int opacity) {
quint64 hash_val = 0;
const QGradientStops stops = gradient.stops();
@@ -4169,7 +4175,8 @@ public:
do {
const CacheInfo &cache_info = it.value();
if (cache_info.stops == stops && cache_info.opacity == opacity && cache_info.interpolationMode == gradient.interpolationMode())
- return cache_info.buffer;
+ return qMakePair(reinterpret_cast<const QRgb *>(cache_info.buffer32),
+ reinterpret_cast<const QRgba64 *>(cache_info.buffer64));
++it;
} while (it != cache.constEnd() && it.key() == hash_val);
// an exact match for these stops and opacity was not found, create new cache
@@ -4183,14 +4190,18 @@ protected:
inline void generateGradientColorTable(const QGradient& g,
QRgba64 *colorTable,
int size, int opacity) const;
- QRgba64 *addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) {
+ ColorBufferPair addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) {
if (cache.size() == maxCacheSize()) {
// may remove more than 1, but OK
cache.erase(cache.begin() + (qrand() % maxCacheSize()));
}
CacheInfo cache_entry(gradient.stops(), opacity, gradient.interpolationMode());
- generateGradientColorTable(gradient, cache_entry.buffer, paletteSize(), opacity);
- return cache.insert(hash_val, cache_entry).value().buffer;
+ generateGradientColorTable(gradient, cache_entry.buffer64, paletteSize(), opacity);
+ for (int i = 0; i < GRADIENT_STOPTABLE_SIZE; ++i)
+ cache_entry.buffer32[i] = cache_entry.buffer64[i].toArgb32();
+ CacheInfo &cache_value = cache.insert(hash_val, cache_entry).value();
+ return qMakePair(reinterpret_cast<const QRgb *>(cache_value.buffer32),
+ reinterpret_cast<const QRgba64 *>(cache_value.buffer64));
}
QGradientColorTableHash cache;
@@ -4424,7 +4435,11 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
type = LinearGradient;
const QLinearGradient *g = static_cast<const QLinearGradient *>(brush.gradient());
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
- gradient.colorTable = const_cast<QRgba64*>(qt_gradient_cache()->getBuffer(*g, alpha));
+
+ QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha);
+ gradient.colorTable64 = colorBuffers.second;
+ gradient.colorTable32 = colorBuffers.first;
+
gradient.spread = g->spread();
QLinearGradientData &linearData = gradient.linear;
@@ -4441,7 +4456,11 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
type = RadialGradient;
const QRadialGradient *g = static_cast<const QRadialGradient *>(brush.gradient());
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
- gradient.colorTable = const_cast<QRgba64*>(qt_gradient_cache()->getBuffer(*g, alpha));
+
+ QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha);
+ gradient.colorTable64 = colorBuffers.second;
+ gradient.colorTable32 = colorBuffers.first;
+
gradient.spread = g->spread();
QRadialGradientData &radialData = gradient.radial;
@@ -4462,7 +4481,11 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
type = ConicalGradient;
const QConicalGradient *g = static_cast<const QConicalGradient *>(brush.gradient());
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
- gradient.colorTable = const_cast<QRgba64*>(qt_gradient_cache()->getBuffer(*g, alpha));
+
+ QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha);
+ gradient.colorTable64 = colorBuffers.second;
+ gradient.colorTable32 = colorBuffers.first;
+
gradient.spread = QGradient::RepeatSpread;
QConicalGradientData &conicalData = gradient.conical;
diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h
index f1130cbf75..7469931a48 100644
--- a/src/gui/painting/qpen.h
+++ b/src/gui/painting/qpen.h
@@ -71,7 +71,7 @@ public:
QPen &operator=(const QPen &pen) Q_DECL_NOTHROW;
#ifdef Q_COMPILER_RVALUE_REFS
QPen(QPen &&other) Q_DECL_NOTHROW
- : d(other.d) { other.d = 0; }
+ : d(other.d) { other.d = Q_NULLPTR; }
QPen &operator=(QPen &&other) Q_DECL_NOTHROW
{ qSwap(d, other.d); return *this; }
#endif
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index 9a3bde3fa3..6cec4a0a8d 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -269,12 +269,14 @@ static inline QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
static void blitTextureForWidget(const QPlatformTextureList *textures, int idx, QWindow *window, const QRect &deviceWindowRect,
QOpenGLTextureBlitter *blitter, const QPoint &offset)
{
+ const QRect clipRect = textures->clipRect(idx);
+ if (clipRect.isEmpty())
+ return;
+
QRect rectInWindow = textures->geometry(idx);
// relative to the TLW, not necessarily our window (if the flush is for a native child widget), have to adjust
rectInWindow.translate(-offset);
- QRect clipRect = textures->clipRect(idx);
- if (clipRect.isEmpty())
- clipRect = QRect(QPoint(0, 0), rectInWindow.size());
+
const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());
const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());
@@ -520,7 +522,23 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu
if (needsConversion)
image = image.convertToFormat(QImage::Format_RGBA8888);
+ // The image provided by the backingstore may have a stride larger than width * 4, for
+ // instance on platforms that manually implement client-side decorations.
+ static const int bytesPerPixel = 4;
+ const int strideInPixels = image.bytesPerLine() / bytesPerPixel;
+ const bool hasUnpackRowLength = !ctx->isOpenGLES() || ctx->format().majorVersion() >= 3;
+
QOpenGLFunctions *funcs = ctx->functions();
+
+ if (hasUnpackRowLength) {
+ funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, strideInPixels);
+ } else if (strideInPixels != image.width()) {
+ // No UNPACK_ROW_LENGTH on ES 2.0 and yet we would need it. This case is typically
+ // hit with QtWayland which is rarely used in combination with a ES2.0-only GL
+ // implementation. Therefore, accept the performance hit and do a copy.
+ image = image.copy();
+ }
+
if (resized) {
if (d_ptr->textureId)
funcs->glDeleteTextures(1, &d_ptr->textureId);
@@ -542,11 +560,9 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu
QRect imageRect = image.rect();
QRect rect = dirtyRegion.boundingRect() & imageRect;
- if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
- funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, image.width());
+ if (hasUnpackRowLength) {
funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, pixelType,
- image.constScanLine(rect.y()) + rect.x() * 4);
- funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ image.constScanLine(rect.y()) + rect.x() * bytesPerPixel);
} else {
// if the rect is wide enough it's cheaper to just
// extend it instead of doing an image copy
@@ -568,6 +584,9 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu
}
}
+ if (hasUnpackRowLength)
+ funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+
return d_ptr->textureId;
}
#endif // QT_NO_OPENGL
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index d104f9ff5a..35c4abb3ac 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -3751,7 +3751,7 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule)
QRegionPrivate *qt_bitmapToRegion(const QBitmap& bitmap)
{
- QImage image = bitmap.toImage();
+ const QImage image = bitmap.toImage();
QRegionPrivate *region = new QRegionPrivate;
@@ -3769,7 +3769,7 @@ QRegionPrivate *qt_bitmapToRegion(const QBitmap& bitmap)
int x,
y;
for (y = 0; y < image.height(); ++y) {
- uchar *line = image.scanLine(y);
+ const uchar *line = image.constScanLine(y);
int w = image.width();
uchar all = zero;
int prev1 = -1;
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index fe5564148e..d2c3eceeef 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -345,7 +345,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP
uchar *dest = d + (c.y + y) *dbpl + c.x/8;
if (y < mh) {
- uchar *src = mask.scanLine(y);
+ const uchar *src = mask.constScanLine(y);
for (int x = 0; x < c.w/8; ++x) {
if (x < (mw+7)/8)
dest[x] = src[x];
@@ -367,7 +367,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP
for (int y = 0; y < c.h; ++y) {
uchar *dest = d + (c.y + y) *dbpl + c.x;
if (y < mh) {
- uchar *src = (uchar *) mask.scanLine(y);
+ const uchar *src = mask.constScanLine(y);
for (int x = 0; x < c.w; ++x) {
if (x < mw)
dest[x] = (src[x >> 3] & (1 << (7 - (x & 7)))) > 0 ? 255 : 0;
@@ -378,7 +378,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP
for (int y = 0; y < c.h; ++y) {
uchar *dest = d + (c.y + y) *dbpl + c.x;
if (y < mh) {
- uchar *src = (uchar *) mask.scanLine(y);
+ const uchar *src = mask.constScanLine(y);
for (int x = 0; x < c.w; ++x) {
if (x < mw)
dest[x] = src[x];
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 8924a7c4ae..7c0492bb1a 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -829,7 +829,7 @@ void QFontEngine::addBitmapFontToPath(qreal x, qreal y, const QGlyphLayout &glyp
}
}
}
- const uchar *bitmap_data = bitmap.bits();
+ const uchar *bitmap_data = bitmap.constBits();
QFixedPoint offset = glyphs.offsets[i];
advanceX += offset.x;
advanceY += offset.y;
@@ -886,12 +886,12 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, con
QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed /*subPixelPosition*/, const QTransform &t)
{
- QImage alphaMask = alphaMapForGlyph(glyph, t);
+ const QImage alphaMask = alphaMapForGlyph(glyph, t);
QImage rgbMask(alphaMask.width(), alphaMask.height(), QImage::Format_RGB32);
for (int y=0; y<alphaMask.height(); ++y) {
uint *dst = (uint *) rgbMask.scanLine(y);
- uchar *src = (uchar *) alphaMask.scanLine(y);
+ const uchar *src = alphaMask.constScanLine(y);
for (int x=0; x<alphaMask.width(); ++x) {
int val = src[x];
dst[x] = qRgb(val, val, val);
@@ -979,7 +979,7 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph)
for (int y=0; y<im.height(); ++y) {
uchar *dst = (uchar *) alphaMap.scanLine(y);
- uint *src = (uint *) im.scanLine(y);
+ const uint *src = reinterpret_cast<const uint *>(im.constScanLine(y));
for (int x=0; x<im.width(); ++x)
dst[x] = qAlpha(src[x]);
}
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 81657a2702..779333351f 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1261,7 +1261,7 @@ QFixed QFontEngineFT::xHeight() const
TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
if (os2 && os2->sxHeight) {
lockFace();
- QFixed answer = QFixed(os2->sxHeight*freetype->face->size->metrics.y_ppem)/freetype->face->units_per_EM;
+ QFixed answer = QFixed(os2->sxHeight * freetype->face->size->metrics.y_ppem) / emSquareSize();
unlockFace();
return answer;
}
@@ -1273,7 +1273,7 @@ QFixed QFontEngineFT::averageCharWidth() const
TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
if (os2 && os2->xAvgCharWidth) {
lockFace();
- QFixed answer = QFixed(os2->xAvgCharWidth*freetype->face->size->metrics.x_ppem)/freetype->face->units_per_EM;
+ QFixed answer = QFixed(os2->xAvgCharWidth * freetype->face->size->metrics.x_ppem) / emSquareSize();
unlockFace();
return answer;
}
@@ -1301,7 +1301,7 @@ void QFontEngineFT::doKerning(QGlyphLayout *g, QFontEngine::ShaperFlags flags) c
kerning_pairs_loaded = true;
lockFace();
if (freetype->face->size->metrics.x_ppem != 0) {
- QFixed scalingFactor(freetype->face->units_per_EM/freetype->face->size->metrics.x_ppem);
+ QFixed scalingFactor = emSquareSize() / QFixed(freetype->face->size->metrics.x_ppem);
unlockFace();
const_cast<QFontEngineFT *>(this)->loadKerningPairs(scalingFactor);
} else {
@@ -1725,8 +1725,8 @@ static inline QImage alphaMapFromGlyphData(QFontEngineFT::Glyph *glyph, QFontEng
if (glyph == Q_NULLPTR)
return QImage();
- QImage::Format format;
- int bytesPerLine;
+ QImage::Format format = QImage::Format_Invalid;
+ int bytesPerLine = -1;
switch (glyphFormat) {
case QFontEngine::Format_Mono:
format = QImage::Format_Mono;
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 3bc8288b73..2189923b25 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -795,7 +795,7 @@ QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &te
\li Qt::TextSingleLine ignores newline characters.
\li Qt::TextExpandTabs expands tabs (see below)
\li Qt::TextShowMnemonic interprets "&x" as \underline{x}; i.e., underlined.
- \li Qt::TextWordBreak breaks the text to fit the rectangle.
+ \li Qt::TextWordWrap breaks the text to fit the rectangle.
\endlist
If Qt::TextExpandTabs is set in \a flags, then: if \a tabArray is
@@ -1579,7 +1579,7 @@ QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString&
\li Qt::TextSingleLine ignores newline characters.
\li Qt::TextExpandTabs expands tabs (see below)
\li Qt::TextShowMnemonic interprets "&x" as \underline{x}; i.e., underlined.
- \li Qt::TextWordBreak breaks the text to fit the rectangle.
+ \li Qt::TextWordWrap breaks the text to fit the rectangle.
\endlist
These flags are defined in the \l{Qt::TextFlag} enum.
diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp
index 34db39e4a8..a9387e5aa0 100644
--- a/src/gui/text/qfontsubset.cpp
+++ b/src/gui/text/qfontsubset.cpp
@@ -624,6 +624,7 @@ static QTtfTable generateName(const QVector<QTtfNameRecord> &name);
static QTtfTable generateName(const qttf_name_table &name)
{
QVector<QTtfNameRecord> list;
+ list.reserve(5);
QTtfNameRecord rec;
rec.nameId = 0;
rec.value = name.copyright;
@@ -1061,6 +1062,7 @@ static QVector<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QV
Q_ASSERT(hmtx.data.size() == hs.offset());
QVector<QTtfTable> list;
+ list.reserve(3);
list.append(glyf);
list.append(loca);
list.append(hmtx);
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index 85484b8b03..f824d1b369 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -1078,8 +1078,8 @@ QTextCursor::QTextCursor(const QTextBlock &block)
/*!
\internal
*/
-QTextCursor::QTextCursor(QTextDocumentPrivate &p, int pos)
- : d(new QTextCursorPrivate(&p))
+QTextCursor::QTextCursor(QTextDocumentPrivate *p, int pos)
+ : d(new QTextCursorPrivate(p))
{
d->adjusted_anchor = d->anchor = d->position = pos;
diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h
index b8fa3145eb..9610e61b39 100644
--- a/src/gui/text/qtextcursor.h
+++ b/src/gui/text/qtextcursor.h
@@ -67,6 +67,8 @@ class Q_GUI_EXPORT QTextCursor
public:
QTextCursor();
explicit QTextCursor(QTextDocument *document);
+ QTextCursor(QTextDocumentPrivate *p, int pos);
+ explicit QTextCursor(QTextCursorPrivate *d);
explicit QTextCursor(QTextFrame *frame);
explicit QTextCursor(const QTextBlock &block);
QTextCursor(const QTextCursor &cursor);
@@ -225,9 +227,6 @@ public:
QTextDocument *document() const;
private:
- QTextCursor(QTextDocumentPrivate &p, int pos);
- explicit QTextCursor(QTextCursorPrivate *d);
-
QSharedDataPointer<QTextCursorPrivate> d;
friend class QTextCursorPrivate;
friend class QTextDocumentPrivate;
diff --git a/src/gui/text/qtextcursor_p.h b/src/gui/text/qtextcursor_p.h
index 5b593b8a9b..84f912a3fa 100644
--- a/src/gui/text/qtextcursor_p.h
+++ b/src/gui/text/qtextcursor_p.h
@@ -107,7 +107,7 @@ public:
void aboutToRemoveCell(int from, int to);
static QTextCursor fromPosition(QTextDocumentPrivate *d, int pos)
- { return QTextCursor(*d, pos); }
+ { return QTextCursor(d, pos); }
QTextDocumentPrivate *priv;
qreal x;
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 5cb9e1bb74..348fa83756 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -1710,7 +1710,7 @@ bool QTextDocumentPrivate::ensureMaximumBlockCount()
beginEditBlock();
const int blocksToRemove = blocks.numNodes() - maximumBlockCount;
- QTextCursor cursor(*this, 0);
+ QTextCursor cursor(this, 0);
cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, blocksToRemove);
unreachableCharacterCount += cursor.selectionEnd() - cursor.selectionStart();
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index b15fc4c047..f5df6fd60b 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1065,7 +1065,7 @@ void QTextEngine::shapeText(int item) const
#ifdef QT_ENABLE_HARFBUZZ_NG
if (Q_LIKELY(qt_useHarfbuzzNG()))
- si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled);
+ si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled, letterSpacing != 0);
else
#endif
si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled);
@@ -1127,7 +1127,13 @@ QT_BEGIN_INCLUDE_NAMESPACE
QT_END_INCLUDE_NAMESPACE
-int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const
+int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si,
+ const ushort *string,
+ int itemLength,
+ QFontEngine *fontEngine,
+ const QVector<uint> &itemBoundaries,
+ bool kerningEnabled,
+ bool hasLetterSpacing) const
{
uint glyphs_shaped = 0;
@@ -1141,7 +1147,8 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st
hb_segment_properties_t props = HB_SEGMENT_PROPERTIES_DEFAULT;
props.direction = si.analysis.bidiLevel % 2 ? HB_DIRECTION_RTL : HB_DIRECTION_LTR;
- props.script = hb_qt_script_to_script(QChar::Script(si.analysis.script));
+ QChar::Script script = QChar::Script(si.analysis.script);
+ props.script = hb_qt_script_to_script(script);
// ### props.language = hb_language_get_default_for_script(props.script);
for (int k = 0; k < itemBoundaries.size(); k += 3) {
@@ -1174,10 +1181,19 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st
Q_ASSERT(hb_font);
hb_qt_font_set_use_design_metrics(hb_font, option.useDesignMetrics() ? uint(QFontEngine::DesignMetrics) : 0); // ###
- const hb_feature_t features[1] = {
- { HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) }
- };
- const int num_features = 1;
+ // Ligatures are incompatible with custom letter spacing, so when a letter spacing is set,
+ // we disable them for writing systems where they are purely cosmetic.
+ bool scriptRequiresOpenType = ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
+ || script == QChar::Script_Khmer || script == QChar::Script_Nko);
+
+ bool dontLigate = hasLetterSpacing && !scriptRequiresOpenType;
+ const hb_feature_t features[5] = {
+ { HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) },
+ { HB_TAG('l','i','g','a'), !dontLigate, 0, uint(-1) },
+ { HB_TAG('c','l','i','g'), !dontLigate, 0, uint(-1) },
+ { HB_TAG('d','l','i','g'), !dontLigate, 0, uint(-1) },
+ { HB_TAG('h','l','i','g'), !dontLigate, 0, uint(-1) } };
+ const int num_features = dontLigate ? 5 : 1;
const char *const *shaper_list = Q_NULLPTR;
#if defined(Q_OS_DARWIN)
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 83575af43a..ab08f2d5e5 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -649,7 +649,13 @@ private:
void addRequiredBoundaries() const;
void shapeText(int item) const;
#ifdef QT_ENABLE_HARFBUZZ_NG
- int shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const;
+ int shapeTextWithHarfbuzzNG(const QScriptItem &si,
+ const ushort *string,
+ int itemLength,
+ QFontEngine *fontEngine,
+ const QVector<uint> &itemBoundaries,
+ bool kerningEnabled,
+ bool hasLetterSpacing) const;
#endif
int shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 1cb42e822b..8902d52b28 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1064,12 +1064,15 @@ QList<QGlyphRun> QTextLayout::glyphRuns(int from, int length) const
QVector<quint32> indexes = oldGlyphRun.glyphIndexes();
QVector<QPointF> positions = oldGlyphRun.positions();
+ QRectF boundingRect = oldGlyphRun.boundingRect();
indexes += glyphRun.glyphIndexes();
positions += glyphRun.positions();
+ boundingRect = boundingRect.united(glyphRun.boundingRect());
oldGlyphRun.setGlyphIndexes(indexes);
oldGlyphRun.setPositions(positions);
+ oldGlyphRun.setBoundingRect(boundingRect);
} else {
glyphRunHash[key] = glyphRun;
}
@@ -2144,6 +2147,7 @@ static QGlyphRun glyphRunWithInfo(QFontEngine *fontEngine,
QGlyphRunPrivate *d = QGlyphRunPrivate::get(glyphRun);
int rangeStart = textPosition;
+ logClusters += textPosition;
while (*logClusters != glyphsStart && rangeStart < textPosition + textLength) {
++logClusters;
++rangeStart;
@@ -2328,16 +2332,16 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
if (mainFontEngine->type() == QFontEngine::Multi) {
QFontEngineMulti *multiFontEngine = static_cast<QFontEngineMulti *>(mainFontEngine);
- int end = rtl ? glyphLayout.numGlyphs : 0;
- int start = rtl ? end : 0;
- int which = glyphLayout.glyphs[rtl ? start - 1 : end] >> 24;
- for (; (rtl && start > 0) || (!rtl && end < glyphLayout.numGlyphs);
+ int start = rtl ? glyphLayout.numGlyphs : 0;
+ int end = start - 1;
+ int which = glyphLayout.glyphs[rtl ? start - 1 : end + 1] >> 24;
+ for (; (rtl && start > 0) || (!rtl && end < glyphLayout.numGlyphs - 1);
rtl ? --start : ++end) {
- const int e = glyphLayout.glyphs[rtl ? start - 1 : end] >> 24;
+ const int e = glyphLayout.glyphs[rtl ? start - 1 : end + 1] >> 24;
if (e == which)
continue;
- QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
+ QGlyphLayout subLayout = glyphLayout.mid(start, end - start + 1);
multiFontEngine->ensureEngineAt(which);
QGlyphRun::GlyphRunFlags subFlags = flags;
@@ -2361,13 +2365,13 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
}
if (rtl)
- end = start;
+ end = start - 1;
else
- start = end;
+ start = end + 1;
which = e;
}
- QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
+ QGlyphLayout subLayout = glyphLayout.mid(start, end - start + 1);
multiFontEngine->ensureEngineAt(which);
QGlyphRun::GlyphRunFlags subFlags = flags;
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp
index 430de3aef8..90c6e7a7b8 100644
--- a/src/gui/util/qvalidator.cpp
+++ b/src/gui/util/qvalidator.cpp
@@ -1066,7 +1066,7 @@ void QRegularExpressionValidatorPrivate::setRegularExpression(const QRegularExpr
if (origRe != re) {
usedRe = origRe = re; // copies also the pattern options
- usedRe.setPattern(QStringLiteral("\\A(?:") + re.pattern() + QStringLiteral(")\\z"));
+ usedRe.setPattern(QLatin1String("\\A(?:") + re.pattern() + QLatin1String(")\\z"));
emit q->regularExpressionChanged(re);
emit q->changed();
}
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index eda9dac745..f4510c3498 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -40,8 +40,6 @@
#include "qhttpnetworkreply_p.h"
#include "qhttpnetworkconnection_p.h"
-#include <qbytearraymatcher.h>
-
#ifndef QT_NO_HTTP
#ifndef QT_NO_SSL
@@ -611,11 +609,9 @@ void QHttpNetworkReplyPrivate::parseHeader(const QByteArray &header)
{
// see rfc2616, sec 4 for information about HTTP/1.1 headers.
// allows relaxed parsing here, accepts both CRLF & LF line endings
- const QByteArrayMatcher lf("\n");
- const QByteArrayMatcher colon(":");
int i = 0;
while (i < header.count()) {
- int j = colon.indexIn(header, i); // field-name
+ int j = header.indexOf(':', i); // field-name
if (j == -1)
break;
const QByteArray field = header.mid(i, j - i).trimmed();
@@ -623,7 +619,7 @@ void QHttpNetworkReplyPrivate::parseHeader(const QByteArray &header)
// any number of LWS is allowed before and after the value
QByteArray value;
do {
- i = lf.indexIn(header, j);
+ i = header.indexOf('\n', j);
if (i == -1)
break;
if (!value.isEmpty())
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index f3d504a6b6..20f7ab2622 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -300,19 +300,6 @@ static inline QAbstractSocket::SocketType qt_socket_getType(qintptr socketDescri
return QAbstractSocket::UnknownSocketType;
}
-/*! \internal
-
-*/
-static inline int qt_socket_getMaxMsgSize(qintptr socketDescriptor)
-{
- int value = 0;
- QT_SOCKLEN_T valueSize = sizeof(value);
- if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_MAX_MSG_SIZE, (char *) &value, &valueSize) != 0) {
- WS_ERROR_DEBUG(WSAGetLastError());
- }
- return value;
-}
-
// MS Transport Provider IOCTL to control
// reporting PORT_UNREACHABLE messages
// on UDP sockets via recv/WSARecv/etc.
diff --git a/src/network/ssl/qsslellipticcurve.h b/src/network/ssl/qsslellipticcurve.h
index a2dcce905d..6ee66d1ec1 100644
--- a/src/network/ssl/qsslellipticcurve.h
+++ b/src/network/ssl/qsslellipticcurve.h
@@ -43,7 +43,7 @@
#include <QtCore/QtGlobal>
#include <QtCore/QString>
#include <QtCore/QMetaType>
-#if QT_DEPRECATED_SINCE(5, 5)
+#if QT_DEPRECATED_SINCE(5, 6)
#include <QtCore/QHash>
#endif
#include <QtCore/qhashfunctions.h>
diff --git a/src/network/ssl/qsslkey_p.cpp b/src/network/ssl/qsslkey_p.cpp
index f26b178d0e..34f664093c 100644
--- a/src/network/ssl/qsslkey_p.cpp
+++ b/src/network/ssl/qsslkey_p.cpp
@@ -61,7 +61,6 @@
#include <QtCore/qatomic.h>
#include <QtCore/qbytearray.h>
-#include <QtCore/qbytearraymatcher.h>
#include <QtCore/qiodevice.h>
#ifndef QT_NO_DEBUG_STREAM
#include <QtCore/qdebug.h>
@@ -191,11 +190,9 @@ QByteArray QSslKeyPrivate::derFromPem(const QByteArray &pem, QMap<QByteArray, QB
if (der.contains("Proc-Type:")) {
// taken from QHttpNetworkReplyPrivate::parseHeader
- const QByteArrayMatcher lf("\n");
- const QByteArrayMatcher colon(":");
int i = 0;
while (i < der.count()) {
- int j = colon.indexIn(der, i); // field-name
+ int j = der.indexOf(':', i); // field-name
if (j == -1)
break;
const QByteArray field = der.mid(i, j - i).trimmed();
@@ -203,7 +200,7 @@ QByteArray QSslKeyPrivate::derFromPem(const QByteArray &pem, QMap<QByteArray, QB
// any number of LWS is allowed before and after the value
QByteArray value;
do {
- i = lf.indexIn(der, j);
+ i = der.indexOf('\n', j);
if (i == -1)
break;
if (!value.isEmpty())
diff --git a/src/network/ssl/qsslsocket_openssl_p.h b/src/network/ssl/qsslsocket_openssl_p.h
index dc60adda39..0674c05d71 100644
--- a/src/network/ssl/qsslsocket_openssl_p.h
+++ b/src/network/ssl/qsslsocket_openssl_p.h
@@ -145,7 +145,7 @@ public:
unsigned int tlsPskClientCallback(const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len);
#ifdef Q_OS_WIN
void fetchCaRootForCert(const QSslCertificate &cert);
- void _q_caRootLoaded(QSslCertificate,QSslCertificate);
+ void _q_caRootLoaded(QSslCertificate,QSslCertificate) Q_DECL_OVERRIDE;
#endif
Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
diff --git a/src/platformsupport/dbusmenu/dbusmenu.pri b/src/platformsupport/dbusmenu/dbusmenu.pri
index 9ca1f13897..2d0feca1a2 100644
--- a/src/platformsupport/dbusmenu/dbusmenu.pri
+++ b/src/platformsupport/dbusmenu/dbusmenu.pri
@@ -6,10 +6,14 @@ HEADERS += \
$$PWD/qdbusmenuadaptor_p.h \
$$PWD/qdbusmenutypes_p.h \
$$PWD/qdbusmenuconnection_p.h \
+ $$PWD/qdbusmenubar_p.h \
+ $$PWD/qdbusmenuregistrarproxy_p.h \
$$PWD/qdbusplatformmenu_p.h \
SOURCES += \
$$PWD/qdbusmenuadaptor.cpp \
$$PWD/qdbusmenutypes.cpp \
$$PWD/qdbusmenuconnection.cpp \
+ $$PWD/qdbusmenubar.cpp \
+ $$PWD/qdbusmenuregistrarproxy.cpp \
$$PWD/qdbusplatformmenu.cpp \
diff --git a/src/platformsupport/dbusmenu/qdbusmenubar.cpp b/src/platformsupport/dbusmenu/qdbusmenubar.cpp
new file mode 100644
index 0000000000..7d53de6db4
--- /dev/null
+++ b/src/platformsupport/dbusmenu/qdbusmenubar.cpp
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Dmitry Shachnev <mitya57@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdbusmenubar_p.h"
+#include "qdbusmenuregistrarproxy_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/* note: do not change these to QStringLiteral;
+ we are unloaded before QtDBus is done using the strings.
+ */
+#define REGISTRAR_SERVICE QLatin1String("com.canonical.AppMenu.Registrar")
+#define REGISTRAR_PATH QLatin1String("/com/canonical/AppMenu/Registrar")
+
+QDBusMenuBar::QDBusMenuBar()
+ : QPlatformMenuBar()
+ , m_menu(new QDBusPlatformMenu())
+ , m_menuAdaptor(new QDBusMenuAdaptor(m_menu))
+ , m_windowId(0)
+{
+ QDBusMenuItem::registerDBusTypes();
+ connect(m_menu, &QDBusPlatformMenu::propertiesUpdated,
+ m_menuAdaptor, &QDBusMenuAdaptor::ItemsPropertiesUpdated);
+ connect(m_menu, &QDBusPlatformMenu::updated,
+ m_menuAdaptor, &QDBusMenuAdaptor::LayoutUpdated);
+}
+
+QDBusMenuBar::~QDBusMenuBar()
+{
+ unregisterMenuBar();
+ delete m_menuAdaptor;
+ delete m_menu;
+ qDeleteAll(m_menuItems);
+}
+
+QDBusPlatformMenuItem *QDBusMenuBar::menuItemForMenu(QPlatformMenu *menu)
+{
+ if (!menu)
+ return nullptr;
+ quintptr tag = menu->tag();
+ const auto it = m_menuItems.constFind(tag);
+ if (it != m_menuItems.cend()) {
+ return *it;
+ } else {
+ QDBusPlatformMenuItem *item = new QDBusPlatformMenuItem;
+ updateMenuItem(item, menu);
+ m_menuItems.insert(tag, item);
+ return item;
+ }
+}
+
+void QDBusMenuBar::updateMenuItem(QDBusPlatformMenuItem *item, QPlatformMenu *menu)
+{
+ const QDBusPlatformMenu *ourMenu = qobject_cast<const QDBusPlatformMenu *>(menu);
+ item->setText(ourMenu->text());
+ item->setIcon(ourMenu->icon());
+ item->setEnabled(ourMenu->isEnabled());
+ item->setVisible(ourMenu->isVisible());
+ item->setMenu(menu);
+}
+
+void QDBusMenuBar::insertMenu(QPlatformMenu *menu, QPlatformMenu *before)
+{
+ QDBusPlatformMenuItem *menuItem = menuItemForMenu(menu);
+ QDBusPlatformMenuItem *beforeItem = menuItemForMenu(before);
+ m_menu->insertMenuItem(menuItem, beforeItem);
+ m_menu->emitUpdated();
+}
+
+void QDBusMenuBar::removeMenu(QPlatformMenu *menu)
+{
+ QDBusPlatformMenuItem *menuItem = menuItemForMenu(menu);
+ m_menu->removeMenuItem(menuItem);
+ m_menu->emitUpdated();
+}
+
+void QDBusMenuBar::syncMenu(QPlatformMenu *menu)
+{
+ QDBusPlatformMenuItem *menuItem = menuItemForMenu(menu);
+ updateMenuItem(menuItem, menu);
+}
+
+void QDBusMenuBar::handleReparent(QWindow *newParentWindow)
+{
+ if (newParentWindow && newParentWindow->winId() != m_windowId) {
+ unregisterMenuBar();
+ m_windowId = newParentWindow->winId();
+ registerMenuBar();
+ }
+}
+
+QPlatformMenu *QDBusMenuBar::menuForTag(quintptr tag) const
+{
+ QDBusPlatformMenuItem *menuItem = m_menuItems.value(tag);
+ if (menuItem)
+ return const_cast<QPlatformMenu *>(menuItem->menu());
+ return nullptr;
+}
+
+void QDBusMenuBar::registerMenuBar()
+{
+ static uint menuBarId = 0;
+
+ QDBusConnection connection = QDBusConnection::sessionBus();
+ m_objectPath = QStringLiteral("/MenuBar/%1").arg(++menuBarId);
+ if (!connection.registerObject(m_objectPath, m_menu))
+ return;
+
+ QDBusMenuRegistrarInterface registrar(REGISTRAR_SERVICE, REGISTRAR_PATH, connection, this);
+ QDBusPendingReply<> r = registrar.RegisterWindow(m_windowId, QDBusObjectPath(m_objectPath));
+ r.waitForFinished();
+ if (r.isError()) {
+ qWarning("Failed to register window menu, reason: %s (\"%s\")",
+ qUtf8Printable(r.error().name()), qUtf8Printable(r.error().message()));
+ connection.unregisterObject(m_objectPath);
+ }
+}
+
+void QDBusMenuBar::unregisterMenuBar()
+{
+ QDBusConnection connection = QDBusConnection::sessionBus();
+
+ if (m_windowId) {
+ QDBusMenuRegistrarInterface registrar(REGISTRAR_SERVICE, REGISTRAR_PATH, connection, this);
+ QDBusPendingReply<> r = registrar.UnregisterWindow(m_windowId);
+ r.waitForFinished();
+ if (r.isError())
+ qWarning("Failed to unregister window menu, reason: %s (\"%s\")",
+ qUtf8Printable(r.error().name()), qUtf8Printable(r.error().message()));
+ }
+
+ if (!m_objectPath.isEmpty())
+ connection.unregisterObject(m_objectPath);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/array.h b/src/platformsupport/dbusmenu/qdbusmenubar_p.h
index 98d2496a7f..157befe9e3 100644
--- a/src/plugins/platforms/windows/array.h
+++ b/src/platformsupport/dbusmenu/qdbusmenubar_p.h
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Dmitry Shachnev <mitya57@gmail.com>
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,66 +37,55 @@
**
****************************************************************************/
-#ifndef ARRAY_H
-#define ARRAY_H
+#ifndef QDBUSMENUBAR_P_H
+#define QDBUSMENUBAR_P_H
-#include <QtCore/QtGlobal>
-#include <algorithm>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
-QT_BEGIN_NAMESPACE
+#include <private/qdbusplatformmenu_p.h>
+#include <private/qdbusmenuadaptor_p.h>
+#include <QtCore/QHash>
+#include <QtCore/QString>
+#include <QtGui/QWindow>
-/* A simple, non-shared array. */
+QT_BEGIN_NAMESPACE
-template <class T>
-class Array
+class QDBusMenuBar : public QPlatformMenuBar
{
- Q_DISABLE_COPY(Array)
-public:
- enum { initialSize = 5 };
-
- typedef T* const_iterator;
-
- explicit Array(size_t size= 0) : data(0), m_capacity(0), m_size(0)
- { if (size) resize(size); }
- ~Array() { delete [] data; }
+ Q_OBJECT
- T *data;
- inline size_t size() const { return m_size; }
- inline const_iterator begin() const { return data; }
- inline const_iterator end() const { return data + m_size; }
-
- inline void append(const T &value)
- {
- const size_t oldSize = m_size;
- resize(m_size + 1);
- data[oldSize] = value;
- }
-
- inline void resize(size_t size)
- {
- if (size > m_size)
- reserve(size > 1 ? size + size / 2 : size_t(initialSize));
- m_size = size;
- }
+public:
+ QDBusMenuBar();
+ virtual ~QDBusMenuBar();
- void reserve(size_t capacity)
- {
- if (capacity > m_capacity) {
- const T *oldData = data;
- data = new T[capacity];
- if (oldData) {
- std::copy(oldData, oldData + m_size, data);
- delete [] oldData;
- }
- m_capacity = capacity;
- }
- }
+ void insertMenu(QPlatformMenu *menu, QPlatformMenu *before) Q_DECL_OVERRIDE;
+ void removeMenu(QPlatformMenu *menu) Q_DECL_OVERRIDE;
+ void syncMenu(QPlatformMenu *menu) Q_DECL_OVERRIDE;
+ void handleReparent(QWindow *newParentWindow) Q_DECL_OVERRIDE;
+ QPlatformMenu *menuForTag(quintptr tag) const Q_DECL_OVERRIDE;
private:
- size_t m_capacity;
- size_t m_size;
+ QDBusPlatformMenu *m_menu;
+ QDBusMenuAdaptor *m_menuAdaptor;
+ QHash<quintptr, QDBusPlatformMenuItem *> m_menuItems;
+ uint m_windowId;
+ QString m_objectPath;
+
+ QDBusPlatformMenuItem *menuItemForMenu(QPlatformMenu *menu);
+ static void updateMenuItem(QDBusPlatformMenuItem *item, QPlatformMenu *menu);
+ void registerMenuBar();
+ void unregisterMenuBar();
};
QT_END_NAMESPACE
-#endif // ARRAY_H
+#endif // QDBUSMENUBAR_P_H
diff --git a/src/platformsupport/dbusmenu/qdbusmenuregistrarproxy.cpp b/src/platformsupport/dbusmenu/qdbusmenuregistrarproxy.cpp
new file mode 100644
index 0000000000..c59b5a675e
--- /dev/null
+++ b/src/platformsupport/dbusmenu/qdbusmenuregistrarproxy.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Dmitry Shachnev <mitya57@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ * This file was originally created by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -p qdbusmenuregistrarproxy ../../3rdparty/dbus-ifaces/com.canonical.AppMenu.Registrar.xml
+ *
+ * However it is maintained manually.
+ */
+
+#include "qdbusmenuregistrarproxy_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*
+ * Implementation of interface class QDBusMenuRegistrarInterface
+ */
+
+QDBusMenuRegistrarInterface::QDBusMenuRegistrarInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+QDBusMenuRegistrarInterface::~QDBusMenuRegistrarInterface()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/dbusmenu/qdbusmenuregistrarproxy_p.h b/src/platformsupport/dbusmenu/qdbusmenuregistrarproxy_p.h
new file mode 100644
index 0000000000..c92de0a140
--- /dev/null
+++ b/src/platformsupport/dbusmenu/qdbusmenuregistrarproxy_p.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Dmitry Shachnev <mitya57@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ * This file was originally created by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -p qdbusmenuregistrarproxy ../../3rdparty/dbus-ifaces/com.canonical.AppMenu.Registrar.xml
+ *
+ * However it is maintained manually.
+ */
+
+#ifndef QDBUSMENUREGISTRARPROXY_P_H
+#define QDBUSMENUREGISTRARPROXY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QString>
+#include <QtCore/QVariant>
+#include <QtDBus/QDBusAbstractInterface>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusReply>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ * Proxy class for interface com.canonical.AppMenu.Registrar
+ */
+class QDBusMenuRegistrarInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ {
+ return "com.canonical.AppMenu.Registrar";
+ }
+
+public:
+ explicit QDBusMenuRegistrarInterface(const QString &service,
+ const QString &path,
+ const QDBusConnection &connection,
+ QObject *parent = nullptr);
+
+ ~QDBusMenuRegistrarInterface();
+
+public Q_SLOTS: // METHODS
+ QDBusPendingReply<QString, QDBusObjectPath> GetMenuForWindow(uint windowId)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(windowId);
+ return asyncCallWithArgumentList(QStringLiteral("GetMenuForWindow"), argumentList);
+ }
+ QDBusReply<QString> GetMenuForWindow(uint windowId, QDBusObjectPath &menuObjectPath)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(windowId);
+ QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetMenuForWindow"), argumentList);
+ QList<QVariant> arguments = reply.arguments();
+ if (reply.type() == QDBusMessage::ReplyMessage && arguments.count() == 2)
+ menuObjectPath = qdbus_cast<QDBusObjectPath>(arguments.at(1));
+ return reply;
+ }
+
+ QDBusPendingReply<> RegisterWindow(uint windowId, const QDBusObjectPath &menuObjectPath)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(windowId) << QVariant::fromValue(menuObjectPath);
+ return asyncCallWithArgumentList(QStringLiteral("RegisterWindow"), argumentList);
+ }
+
+ QDBusPendingReply<> UnregisterWindow(uint windowId)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(windowId);
+ return asyncCallWithArgumentList(QStringLiteral("UnregisterWindow"), argumentList);
+ }
+};
+
+QT_END_NAMESPACE
+
+#endif // QDBUSMENUREGISTRARPROXY_P_H
diff --git a/src/platformsupport/platformcompositor/qopenglcompositor.cpp b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
index 7bd7ba4834..610619a4e4 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositor.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
It is up to the platform plugin to manage the lifetime of the
compositor (instance(), destroy()), set the correct destination
- context and window as early as possible (setTargetWindow()),
+ context and window as early as possible (setTarget()),
register the composited windows as they are shown, activated,
raised and lowered (addWindow(), moveToTop(), etc.), and to
schedule repaints (update()).
@@ -183,11 +183,11 @@ static inline QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
static void clippedBlit(const QPlatformTextureList *textures, int idx, const QRect &targetWindowRect, QOpenGLTextureBlitter *blitter)
{
- const QRect rectInWindow = textures->geometry(idx);
- QRect clipRect = textures->clipRect(idx);
+ const QRect clipRect = textures->clipRect(idx);
if (clipRect.isEmpty())
- clipRect = QRect(QPoint(0, 0), rectInWindow.size());
+ return;
+ const QRect rectInWindow = textures->geometry(idx);
const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());
const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());
diff --git a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
index 80d20eac93..7c29be7804 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
@@ -40,6 +40,7 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QWindow>
#include <QtGui/QPainter>
+#include <QtGui/QOffscreenSurface>
#include <qpa/qplatformbackingstore.h>
#include <private/qwindow_p.h>
@@ -88,13 +89,28 @@ QOpenGLCompositorBackingStore::~QOpenGLCompositorBackingStore()
{
if (m_bsTexture) {
QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ // With render-to-texture-widgets QWidget makes sure the TLW's shareContext() is
+ // made current before destroying backingstores. That is however not the case for
+ // windows with regular widgets only.
+ QScopedPointer<QOffscreenSurface> tempSurface;
+ if (!ctx) {
+ ctx = QOpenGLCompositor::instance()->context();
+ tempSurface.reset(new QOffscreenSurface);
+ tempSurface->setFormat(ctx->format());
+ tempSurface->create();
+ ctx->makeCurrent(tempSurface.data());
+ }
+
if (ctx && m_bsTextureContext && ctx->shareGroup() == m_bsTextureContext->shareGroup())
glDeleteTextures(1, &m_bsTexture);
else
qWarning("QOpenGLCompositorBackingStore: Texture is not valid in the current context");
+
+ if (tempSurface)
+ ctx->doneCurrent();
}
- delete m_textures;
+ delete m_textures; // this does not actually own any GL resources
}
QPaintDevice *QOpenGLCompositorBackingStore::paintDevice()
@@ -164,16 +180,15 @@ void QOpenGLCompositorBackingStore::updateTexture()
void QOpenGLCompositorBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
- // Called for ordinary raster windows. This is rare since RasterGLSurface
- // support is claimed which leads to having all QWidget windows marked as
- // RasterGLSurface instead of just Raster. These go through
- // compositeAndFlush() instead of this function.
+ // Called for ordinary raster windows.
Q_UNUSED(region);
Q_UNUSED(offset);
QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
QOpenGLContext *dstCtx = compositor->context();
+ Q_ASSERT(dstCtx);
+
QWindow *dstWin = compositor->targetWindow();
if (!dstWin)
return;
@@ -190,7 +205,7 @@ void QOpenGLCompositorBackingStore::composeAndFlush(QWindow *window, const QRegi
QPlatformTextureList *textures, QOpenGLContext *context,
bool translucentBackground)
{
- // QOpenGLWidget/QQuickWidget content provided as textures. The raster content should go on top.
+ // QOpenGLWidget/QQuickWidget content provided as textures. The raster content goes on top.
Q_UNUSED(region);
Q_UNUSED(offset);
@@ -199,6 +214,12 @@ void QOpenGLCompositorBackingStore::composeAndFlush(QWindow *window, const QRegi
QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
QOpenGLContext *dstCtx = compositor->context();
+ Q_ASSERT(dstCtx); // setTarget() must have been called before, e.g. from QEGLFSWindow
+
+ // The compositor's context and the context to which QOpenGLWidget/QQuickWidget
+ // textures belong are not the same. They share resources, though.
+ Q_ASSERT(context->shareGroup() == dstCtx->shareGroup());
+
QWindow *dstWin = compositor->targetWindow();
if (!dstWin)
return;
@@ -260,6 +281,7 @@ void QOpenGLCompositorBackingStore::resize(const QSize &size, const QRegion &sta
if (m_bsTexture) {
glDeleteTextures(1, &m_bsTexture);
m_bsTexture = 0;
+ m_bsTextureContext = Q_NULLPTR;
}
}
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index 026ba11c3d..aee12eed76 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -59,9 +59,12 @@
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformservices.h>
#include <qpa/qplatformdialoghelper.h>
+#ifndef QT_NO_DBUS
+#include "QtPlatformSupport/private/qdbusplatformmenu_p.h"
+#include "QtPlatformSupport/private/qdbusmenubar_p.h"
+#endif
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
#include "QtPlatformSupport/private/qdbustrayicon_p.h"
-#include "QtPlatformSupport/private/qdbusplatformmenu_p.h"
#endif
#include <algorithm>
@@ -114,6 +117,21 @@ static bool isDBusTrayAvailable() {
}
#endif
+#ifndef QT_NO_DBUS
+static bool checkDBusGlobalMenuAvailable()
+{
+ QDBusConnection connection = QDBusConnection::sessionBus();
+ QString registrarService = QStringLiteral("com.canonical.AppMenu.Registrar");
+ return connection.interface()->isServiceRegistered(registrarService);
+}
+
+static bool isDBusGlobalMenuAvailable()
+{
+ static bool dbusGlobalMenuAvailable = checkDBusGlobalMenuAvailable();
+ return dbusGlobalMenuAvailable;
+}
+#endif
+
class QGenericUnixThemePrivate : public QPlatformThemePrivate
{
public:
@@ -172,6 +190,22 @@ QStringList QGenericUnixTheme::xdgIconThemePaths()
return paths;
}
+#ifndef QT_NO_DBUS
+QPlatformMenu *QGenericUnixTheme::createPlatformMenu() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusPlatformMenu();
+ return nullptr;
+}
+
+QPlatformMenuBar *QGenericUnixTheme::createPlatformMenuBar() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusMenuBar();
+ return nullptr;
+}
+#endif
+
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *QGenericUnixTheme::createPlatformSystemTrayIcon() const
{
@@ -559,6 +593,22 @@ QPlatformTheme *QKdeTheme::createKdeTheme()
return new QKdeTheme(kdeDirs, kdeVersion);
}
+#ifndef QT_NO_DBUS
+QPlatformMenu *QKdeTheme::createPlatformMenu() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusPlatformMenu();
+ return nullptr;
+}
+
+QPlatformMenuBar *QKdeTheme::createPlatformMenuBar() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusMenuBar();
+ return nullptr;
+}
+#endif
+
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *QKdeTheme::createPlatformSystemTrayIcon() const
{
@@ -655,6 +705,22 @@ QString QGnomeTheme::gtkFontName() const
return QStringLiteral("%1 %2").arg(QLatin1String(defaultSystemFontNameC)).arg(defaultSystemFontSize);
}
+#ifndef QT_NO_DBUS
+QPlatformMenu *QGnomeTheme::createPlatformMenu() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusPlatformMenu();
+ return nullptr;
+}
+
+QPlatformMenuBar *QGnomeTheme::createPlatformMenuBar() const
+{
+ if (isDBusGlobalMenuAvailable())
+ return new QDBusMenuBar();
+ return nullptr;
+}
+#endif
+
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *QGnomeTheme::createPlatformSystemTrayIcon() const
{
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
index 2d46a4d95e..b7e0d53d6f 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
@@ -85,6 +85,10 @@ public:
QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
static QStringList xdgIconThemePaths();
+#ifndef QT_NO_DBUS
+ QPlatformMenu *createPlatformMenu() const Q_DECL_OVERRIDE;
+ QPlatformMenuBar *createPlatformMenuBar() const Q_DECL_OVERRIDE;
+#endif
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE;
#endif
@@ -107,6 +111,10 @@ public:
const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
const QFont *font(Font type) const Q_DECL_OVERRIDE;
+#ifndef QT_NO_DBUS
+ QPlatformMenu *createPlatformMenu() const Q_DECL_OVERRIDE;
+ QPlatformMenuBar *createPlatformMenuBar() const Q_DECL_OVERRIDE;
+#endif
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE;
#endif
@@ -127,6 +135,10 @@ public:
QString standardButtonText(int button) const Q_DECL_OVERRIDE;
virtual QString gtkFontName() const;
+#ifndef QT_NO_DBUS
+ QPlatformMenu *createPlatformMenu() const Q_DECL_OVERRIDE;
+ QPlatformMenuBar *createPlatformMenuBar() const Q_DECL_OVERRIDE;
+#endif
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE;
#endif
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
index 8adf15cec4..e2c4bf9dc4 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp
+++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
@@ -136,10 +136,6 @@ void QTuioHandler::processPackets()
if (size != datagram.size())
datagram.resize(size);
- QOscBundle bundle(datagram);
- if (!bundle.isValid())
- continue;
-
// "A typical TUIO bundle will contain an initial ALIVE message,
// followed by an arbitrary number of SET messages that can fit into the
// actual bundle capacity and a concluding FSEQ message. A minimal TUIO
@@ -147,7 +143,19 @@ void QTuioHandler::processPackets()
// messages. The FSEQ frame ID is incremented for each delivered bundle,
// while redundant bundles can be marked using the frame sequence ID
// -1."
- QList<QOscMessage> messages = bundle.messages();
+ QList<QOscMessage> messages;
+
+ QOscBundle bundle(datagram);
+ if (bundle.isValid()) {
+ messages = bundle.messages();
+ } else {
+ QOscMessage msg(datagram);
+ if (!msg.isValid()) {
+ qCWarning(lcTuioSet) << "Got invalid datagram.";
+ continue;
+ }
+ messages.push_back(msg);
+ }
foreach (const QOscMessage &message, messages) {
if (message.addressPattern() != "/tuio/2Dcur") {
@@ -320,6 +328,14 @@ void QTuioHandler::process2DCurFseq(const QOscMessage &message)
Q_UNUSED(message); // TODO: do we need to do anything with the frame id?
QWindow *win = QGuiApplication::focusWindow();
+ // With TUIO the first application takes exclusive ownership of the "device"
+ // we cannot attach more than one application to the same port anyway.
+ // Forcing delivery makes it easy to use simulators in the same machine
+ // and forget about headaches about unfocused TUIO windows.
+ static bool forceDelivery = qEnvironmentVariableIsSet("QT_TUIOTOUCH_DELIVER_WITHOUT_FOCUS");
+ if (!win && QGuiApplication::topLevelWindows().length() > 0 && forceDelivery)
+ win = QGuiApplication::topLevelWindows().at(0);
+
if (!win)
return;
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
index 7028b4d9ec..bc4cb227a8 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
@@ -59,7 +59,7 @@ QCocoaAccessibility::~QCocoaAccessibility()
void QCocoaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
{
- if (!isActive() || !event->accessibleInterface())
+ if (!isActive() || !event->accessibleInterface() || !event->accessibleInterface()->isValid())
return;
QMacAccessibilityElement *element = [QMacAccessibilityElement elementWithId: event->uniqueId()];
if (!element) {
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
index 11c68efd40..0f8081715b 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
@@ -126,7 +126,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
if (!element) {
QAccessibleInterface *iface = QAccessible::accessibleInterface(anId);
Q_ASSERT(iface);
- if (!iface)
+ if (!iface || !iface->isValid())
return nil;
element = [[self alloc] initWithId:anId];
cache->insertElement(anId, element);
@@ -178,7 +178,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
static NSArray *defaultAttributes = nil;
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
- if (!iface)
+ if (!iface || !iface->isValid())
return defaultAttributes;
if (defaultAttributes == nil) {
@@ -232,7 +232,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
- (id)parentElement {
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
- if (!iface)
+ if (!iface || !iface->isValid())
return nil;
if (QWindow *window = iface->window()) {
@@ -265,7 +265,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
- (id)accessibilityAttributeValue:(NSString *)attribute {
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
- if (!iface) {
+ if (!iface || !iface->isValid()) {
qWarning() << "Called attribute on invalid object: " << axid;
return nil;
}
@@ -344,9 +344,11 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
} else if ([attribute isEqualToString:NSAccessibilityInsertionPointLineNumberAttribute]) {
if (QAccessibleTextInterface *text = iface->textInterface()) {
- int line = -1;
- int position = text->cursorPosition();
- convertLineOffset(text, &line, &position);
+ int line = 0; // true for all single line edits
+ if (iface->state().multiLine) {
+ int position = text->cursorPosition();
+ convertLineOffset(text, &line, &position);
+ }
return [NSNumber numberWithInt: line];
}
return nil;
@@ -362,7 +364,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
- (NSArray *)accessibilityParameterizedAttributeNames {
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
- if (!iface) {
+ if (!iface || !iface->isValid()) {
qWarning() << "Called attribute on invalid object: " << axid;
return nil;
}
@@ -387,7 +389,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
- (id)accessibilityAttributeValue:(NSString *)attribute forParameter:(id)parameter {
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
- if (!iface) {
+ if (!iface || !iface->isValid()) {
qWarning() << "Called attribute on invalid object: " << axid;
return nil;
}
@@ -454,7 +456,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute {
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
- if (!iface)
+ if (!iface || !iface->isValid())
return NO;
if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) {
@@ -473,7 +475,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute {
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
- if (!iface)
+ if (!iface || !iface->isValid())
return;
if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) {
if (QAccessibleActionInterface *action = iface->actionInterface())
@@ -502,7 +504,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
- (NSArray *)accessibilityActionNames {
NSMutableArray * nsActions = [NSMutableArray new];
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
- if (!iface)
+ if (!iface || !iface->isValid())
return nsActions;
const QStringList &supportedActionNames = QAccessibleBridgeUtils::effectiveActionNames(iface);
@@ -517,7 +519,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
- (NSString *)accessibilityActionDescription:(NSString *)action {
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
- if (!iface)
+ if (!iface || !iface->isValid())
return nil; // FIXME is that the right return type??
QString qtAction = QCocoaAccessible::translateAction(action, iface);
QString description;
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index 1e8c693df9..0375dd85f2 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -136,7 +136,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
if ([mSavePanel respondsToSelector:@selector(setLevel:)])
[mSavePanel setLevel:NSModalPanelWindowLevel];
- [mSavePanel setDelegate:self];
+
mReturnCode = -1;
mHelper = helper;
mNameFilterDropDownList = new QStringList(mOptions->nameFilters());
@@ -157,6 +157,10 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
[self createTextField];
[self createAccessory];
[mSavePanel setAccessoryView:mNameFilterDropDownList->size() > 1 ? mAccessoryView : nil];
+ // -setAccessoryView: can result in -panel:directoryDidChange:
+ // resetting our mCurrentDir, set the delegate
+ // here to make sure it gets the correct value.
+ [mSavePanel setDelegate:self];
#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_11)
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_11)
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.h b/src/plugins/platforms/cocoa/qcocoamenuitem.h
index ba2005eabc..0d6f67959b 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.h
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.h
@@ -46,17 +46,10 @@
//#define QT_COCOA_ENABLE_MENU_DEBUG
-#ifdef __OBJC__
-#define QT_FORWARD_DECLARE_OBJC_CLASS(__KLASS__) @class __KLASS__
-#else
-#define QT_FORWARD_DECLARE_OBJC_CLASS(__KLASS__) typedef struct objc_object __KLASS__
-#endif
-
-QT_FORWARD_DECLARE_OBJC_CLASS(NSMenuItem);
-QT_FORWARD_DECLARE_OBJC_CLASS(NSMenu);
-QT_FORWARD_DECLARE_OBJC_CLASS(NSObject);
-QT_FORWARD_DECLARE_OBJC_CLASS(NSView);
-
+Q_FORWARD_DECLARE_OBJC_CLASS(NSMenuItem);
+Q_FORWARD_DECLARE_OBJC_CLASS(NSMenu);
+Q_FORWARD_DECLARE_OBJC_CLASS(NSObject);
+Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
index 3d3381323c..88b4692c80 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
@@ -200,11 +200,8 @@ QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWindow *window) const
QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
- // If there is a "root" window into which raster and QOpenGLWidget content is
- // composited, all other contexts must share with its context.
- QOpenGLContext *compositingContext = QOpenGLCompositor::instance()->context();
EGLDisplay dpy = context->screen() ? static_cast<QEglFSScreen *>(context->screen()->handle())->display() : display();
- QPlatformOpenGLContext *share = compositingContext ? compositingContext->handle() : context->shareHandle();
+ QPlatformOpenGLContext *share = context->shareHandle();
QVariant nativeHandle = context->nativeHandle();
QEglFSContext *ctx;
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp
index c37096160e..2c386e2aea 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp
@@ -142,6 +142,14 @@ void QEglFSWindow::create()
if (Q_UNLIKELY(!context->create()))
qFatal("EGLFS: Failed to create compositing context");
compositor->setTarget(context, window());
+ // If there is a "root" window into which raster and QOpenGLWidget content is
+ // composited, all other contexts must share with its context.
+ if (!qt_gl_global_share_context()) {
+ qt_gl_set_global_share_context(context);
+ // What we set up here is in effect equivalent to the application setting
+ // AA_ShareOpenGLContexts. Set the attribute to be fully consistent.
+ QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
+ }
}
}
diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
index b2cd5b124b..7123ed826d 100644
--- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp
+++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
@@ -100,7 +100,7 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
SIZE size = {r.width(), r.height()};
POINT ptDst = {r.x(), r.y()};
POINT ptSrc = {0, 0};
- BLENDFUNCTION blend = {AC_SRC_OVER, 0, (BYTE)(255.0 * rw->opacity()), AC_SRC_ALPHA};
+ BLENDFUNCTION blend = {AC_SRC_OVER, 0, BYTE(qRound(255.0 * rw->opacity())), AC_SRC_ALPHA};
if (QWindowsContext::user32dll.updateLayeredWindowIndirect) {
RECT dirty = {dirtyRect.x(), dirtyRect.y(),
dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()};
@@ -126,7 +126,7 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
m_image->hdc(), br.x() + offset.x(), br.y() + offset.y(), SRCCOPY)) {
const DWORD lastError = GetLastError(); // QTBUG-35926, QTBUG-29716: may fail after lock screen.
if (lastError != ERROR_SUCCESS && lastError != ERROR_INVALID_HANDLE)
- qErrnoWarning(lastError, "%s: BitBlt failed", __FUNCTION__);
+ qErrnoWarning(int(lastError), "%s: BitBlt failed", __FUNCTION__);
}
rw->releaseDC();
#ifndef Q_OS_WINCE
@@ -162,7 +162,7 @@ void QWindowsBackingStore::resize(const QSize &size, const QRegion &region)
if (QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha)
m_alphaNeedsFill = true;
else // upgrade but here we know app painting does not rely on alpha hence no need to fill
- format = qt_alphaVersionForPainting(format);
+ format = qt_maybeAlphaVersionWithSameDepth(format);
QWindowsNativeImage *oldwni = m_image.data();
QWindowsNativeImage *newwni = new QWindowsNativeImage(size.width(), size.height(), format);
diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp
index 95e595b88e..d527e07308 100644
--- a/src/plugins/platforms/windows/qwindowsclipboard.cpp
+++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp
@@ -265,9 +265,9 @@ bool QWindowsClipboard::clipboardViewerWndProc(HWND hwnd, UINT message, WPARAM w
switch (message) {
case WM_CHANGECBCHAIN: {
- const HWND toBeRemoved = (HWND)wParam;
+ const HWND toBeRemoved = reinterpret_cast<HWND>(wParam);
if (toBeRemoved == m_nextClipboardViewer) {
- m_nextClipboardViewer = (HWND)lParam;
+ m_nextClipboardViewer = reinterpret_cast<HWND>(lParam);
} else {
propagateClipboardMessage(message, wParam, lParam);
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 8501ec6731..efeb1f5f05 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -107,10 +107,10 @@ static inline bool useRTL_Extensions(QSysInfo::WinVersion ver)
if ((ver & QSysInfo::WV_NT_based) && (ver >= QSysInfo::WV_VISTA)) {
// Since the IsValidLanguageGroup/IsValidLocale functions always return true on
// Vista, check the Keyboard Layouts for enabling RTL.
- if (const UINT nLayouts = GetKeyboardLayoutList(0, 0)) {
+ if (const int nLayouts = GetKeyboardLayoutList(0, 0)) {
QScopedArrayPointer<HKL> lpList(new HKL[nLayouts]);
GetKeyboardLayoutList(nLayouts, lpList.data());
- for (UINT i = 0; i < nLayouts; ++i) {
+ for (int i = 0; i < nLayouts; ++i) {
switch (PRIMARYLANGID((quintptr)lpList[i])) {
case LANG_ARABIC:
case LANG_HEBREW:
@@ -546,15 +546,15 @@ QString QWindowsContext::registerWindowClass(QString cname,
// add an instance-specific ID, the address of the window proc.
static int classExists = -1;
- const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0);
+ const HINSTANCE appInstance = static_cast<HINSTANCE>(GetModuleHandle(0));
if (classExists == -1) {
WNDCLASS wcinfo;
- classExists = GetClassInfo(appInstance, (wchar_t*)cname.utf16(), &wcinfo);
+ classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo);
classExists = classExists && wcinfo.lpfnWndProc != proc;
}
if (classExists)
- cname += QString::number((quintptr)proc);
+ cname += QString::number(reinterpret_cast<quintptr>(proc));
if (d->m_registeredWindowClassNames.contains(cname)) // already registered in our list
return cname;
@@ -574,13 +574,13 @@ QString QWindowsContext::registerWindowClass(QString cname,
#ifndef Q_OS_WINCE
wc.hbrBackground = brush;
if (icon) {
- wc.hIcon = (HICON)LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
+ wc.hIcon = static_cast<HICON>(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE));
if (wc.hIcon) {
int sw = GetSystemMetrics(SM_CXSMICON);
int sh = GetSystemMetrics(SM_CYSMICON);
- wc.hIconSm = (HICON)LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, sw, sh, 0);
+ wc.hIconSm = static_cast<HICON>(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, sw, sh, 0));
} else {
- wc.hIcon = (HICON)LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+ wc.hIcon = static_cast<HICON>(LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
wc.hIconSm = 0;
}
} else {
@@ -596,7 +596,7 @@ QString QWindowsContext::registerWindowClass(QString cname,
#endif
wc.lpszMenuName = 0;
- wc.lpszClassName = (wchar_t*)cname.utf16();
+ wc.lpszClassName = reinterpret_cast<LPCWSTR>(cname.utf16());
#ifndef Q_OS_WINCE
ATOM atom = RegisterClassEx(&wc);
#else
@@ -616,10 +616,10 @@ QString QWindowsContext::registerWindowClass(QString cname,
void QWindowsContext::unregisterWindowClasses()
{
- const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0);
+ const HINSTANCE appInstance = static_cast<HINSTANCE>(GetModuleHandle(0));
foreach (const QString &name, d->m_registeredWindowClassNames) {
- if (!UnregisterClass((wchar_t*)name.utf16(), appInstance) && QWindowsContext::verbose)
+ if (!UnregisterClass(reinterpret_cast<LPCWSTR>(name.utf16()), appInstance) && QWindowsContext::verbose)
qErrnoWarning("UnregisterClass failed for '%s'", qPrintable(name));
}
d->m_registeredWindowClassNames.clear();
@@ -635,11 +635,11 @@ QString QWindowsContext::windowsErrorMessage(unsigned long errorCode)
QString rc = QString::fromLatin1("#%1: ").arg(errorCode);
ushort *lpMsgBuf;
- const int len = FormatMessage(
+ const DWORD len = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, errorCode, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
+ NULL, errorCode, 0, reinterpret_cast<LPTSTR>(&lpMsgBuf), 0, NULL);
if (len) {
- rc = QString::fromUtf16(lpMsgBuf, len);
+ rc = QString::fromUtf16(lpMsgBuf, int(len));
LocalFree(lpMsgBuf);
} else {
rc += QString::fromLatin1("<unknown error>");
@@ -803,11 +803,11 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn,
if (!wndProc)
wndProc = DefWindowProc;
QString className = registerWindowClass(classNameIn, wndProc);
- return CreateWindowEx(0, (wchar_t*)className.utf16(),
+ return CreateWindowEx(0, reinterpret_cast<LPCWSTR>(className.utf16()),
windowName, style,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
- HWND_MESSAGE, NULL, (HINSTANCE)GetModuleHandle(0), NULL);
+ HWND_MESSAGE, NULL, static_cast<HINSTANCE>(GetModuleHandle(0)), NULL);
}
#ifndef Q_OS_WINCE
@@ -818,11 +818,11 @@ static inline QString errorMessageFromComError(const _com_error &comError)
{
TCHAR *message = Q_NULLPTR;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, comError.Error(), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
+ NULL, DWORD(comError.Error()), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
message, 0, NULL);
if (message) {
const QString result = QString::fromWCharArray(message).trimmed();
- LocalFree((HLOCAL)message);
+ LocalFree(static_cast<HLOCAL>(message));
return result;
}
if (const WORD wCode = comError.WCode())
@@ -1070,7 +1070,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
platformWindow->handleMoved();
return true;
case QtWindows::ResizeEvent:
- platformWindow->handleResized((int)wParam);
+ platformWindow->handleResized(static_cast<int>(wParam));
return true;
#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
case QtWindows::QuerySizeHints:
@@ -1212,7 +1212,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
sessionManager->setActive(false);
sessionManager->allowsInteraction();
- bool endsession = (bool) wParam;
+ const bool endsession = wParam != 0;
// we receive the message for each toplevel window included internal hidden ones,
// but the aboutToQuit signal should be emitted only once.
@@ -1279,7 +1279,7 @@ bool QWindowsContext::handleContextMenuEvent(QWindow *window, const MSG &msg)
bool mouseTriggered = false;
QPoint globalPos;
QPoint pos;
- if (msg.lParam != (int)0xffffffff) {
+ if (msg.lParam != int(0xffffffff)) {
mouseTriggered = true;
globalPos.setX(msg.pt.x);
globalPos.setY(msg.pt.y);
@@ -1287,8 +1287,8 @@ bool QWindowsContext::handleContextMenuEvent(QWindow *window, const MSG &msg)
RECT clientRect;
if (GetClientRect(msg.hwnd, &clientRect)) {
- if (pos.x() < (int)clientRect.left || pos.x() >= (int)clientRect.right ||
- pos.y() < (int)clientRect.top || pos.y() >= (int)clientRect.bottom)
+ if (pos.x() < clientRect.left || pos.x() >= clientRect.right ||
+ pos.y() < clientRect.top || pos.y() >= clientRect.bottom)
{
// This is the case that user has right clicked in the window's caption,
// We should call DefWindowProc() to display a default shortcut menu
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index 5c2610a3fe..0eb7043bbc 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -119,8 +119,8 @@ HCURSOR QWindowsCursor::createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot
ICONINFO ii;
ii.fIcon = 0;
- ii.xHotspot = hotSpot.x();
- ii.yHotspot = hotSpot.y();
+ ii.xHotspot = DWORD(hotSpot.x());
+ ii.yHotspot = DWORD(hotSpot.y());
ii.hbmMask = im;
ii.hbmColor = ic;
@@ -148,8 +148,8 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
QScopedArrayPointer<uchar> xMask(new uchar[height * n]);
int x = 0;
for (int i = 0; i < height; ++i) {
- const uchar *bits = bbits.scanLine(i);
- const uchar *mask = mbits.scanLine(i);
+ const uchar *bits = bbits.constScanLine(i);
+ const uchar *mask = mbits.constScanLine(i);
for (int j = 0; j < n; ++j) {
uchar b = bits[j];
uchar m = mask[j];
@@ -179,8 +179,8 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
x += sysN;
} else {
int fillWidth = n > sysN ? sysN : n;
- const uchar *bits = bbits.scanLine(i);
- const uchar *mask = mbits.scanLine(i);
+ const uchar *bits = bbits.constScanLine(i);
+ const uchar *mask = mbits.constScanLine(i);
for (int j = 0; j < fillWidth; ++j) {
uchar b = bits[j];
uchar m = mask[j];
@@ -577,7 +577,7 @@ HCURSOR QWindowsCursor::createCursorFromShape(Qt::CursorShape cursorShape, const
for (const QWindowsStandardCursorMapping *s = standardCursors; s < sEnd; ++s) {
if (s->shape == cursorShape) {
#ifndef Q_OS_WINCE
- return (HCURSOR)LoadImage(0, s->resource, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+ return static_cast<HCURSOR>(LoadImage(0, s->resource, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
#else
return LoadCursor(0, s->resource);
#endif
diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp
index 2c6e6b9771..246f53ef2f 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -645,7 +645,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState,
m_chosenEffect = DROPEFFECT_COPY;
HGLOBAL hData = GlobalAlloc(0, sizeof(DWORD));
if (hData) {
- DWORD *moveEffect = (DWORD *)GlobalLock(hData);;
+ DWORD *moveEffect = reinterpret_cast<DWORD *>(GlobalLock(hData));
*moveEffect = DROPEFFECT_MOVE;
GlobalUnlock(hData);
STGMEDIUM medium;
@@ -653,7 +653,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState,
medium.tymed = TYMED_HGLOBAL;
medium.hGlobal = hData;
FORMATETC format;
- format.cfFormat = RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT);
+ format.cfFormat = CLIPFORMAT(RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT));
format.tymed = TYMED_HGLOBAL;
format.ptd = 0;
format.dwAspect = 1;
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index da28b5b19b..a11196d1d2 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -193,9 +193,9 @@ bool QWindowsLibGLESv2::init()
qCDebug(lcQpaGl) << "Qt: Using OpenGL ES 2.0 from" << dllName;
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
- m_lib = ::LoadLibraryW((const wchar_t *) QString::fromLatin1(dllName).utf16());
+ m_lib = ::LoadLibraryW(reinterpret_cast<LPCWSTR>(QString::fromLatin1(dllName).utf16()));
if (!m_lib) {
- qErrnoWarning(::GetLastError(), "Failed to load %s", dllName);
+ qErrnoWarning(int(GetLastError()), "Failed to load %s", dllName);
return false;
}
#endif // !QT_STATIC
@@ -401,7 +401,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester:
Q_UNUSED(preferredType)
#endif
if (display == EGL_NO_DISPLAY)
- display = libEGL.eglGetDisplay((EGLNativeDisplayType)dc);
+ display = libEGL.eglGetDisplay(dc);
if (!display) {
qWarning("%s: Could not obtain EGL display", __FUNCTION__);
return 0;
@@ -433,8 +433,8 @@ QWindowsOpenGLContext *QWindowsEGLStaticContext::createContext(QOpenGLContext *c
void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, int *err)
{
*err = 0;
- EGLSurface surface = libEGL.eglCreateWindowSurface(m_display, (EGLConfig) nativeConfig,
- (EGLNativeWindowType) nativeWindow, 0);
+ EGLSurface surface = libEGL.eglCreateWindowSurface(m_display, nativeConfig,
+ static_cast<EGLNativeWindowType>(nativeWindow), 0);
if (surface == EGL_NO_SURFACE) {
*err = libEGL.eglGetError();
qWarning("%s: Could not create the EGL window surface: 0x%x", __FUNCTION__, *err);
@@ -445,7 +445,7 @@ void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *na
void QWindowsEGLStaticContext::destroyWindowSurface(void *nativeSurface)
{
- libEGL.eglDestroySurface(m_display, (EGLSurface) nativeSurface);
+ libEGL.eglDestroySurface(m_display, nativeSurface);
}
QSurfaceFormat QWindowsEGLStaticContext::formatFromConfig(EGLDisplay display, EGLConfig config,
@@ -996,7 +996,7 @@ EGLConfig QWindowsEGLContext::chooseConfig(const QSurfaceFormat &format)
QVector<EGLConfig> configs(matching);
QWindowsEGLStaticContext::libEGL.eglChooseConfig(display, configureAttributes.constData(), configs.data(), configs.size(), &matching);
if (!cfg && matching > 0)
- cfg = configs.first();
+ cfg = configs.constFirst();
EGLint red = 0;
EGLint green = 0;
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
index 2d5eb4b4b9..743408949d 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
@@ -276,10 +276,10 @@ namespace {
quint16 nameIds[requiredRecordCount] = { 1, 2, 3, 4, 6 };
int sizeOfHeader = sizeof(NameTable) + sizeof(NameRecord) * requiredRecordCount;
- int newFamilyNameSize = newFamilyName.size() * sizeof(quint16);
+ int newFamilyNameSize = newFamilyName.size() * int(sizeof(quint16));
const QString regularString = QString::fromLatin1("Regular");
- int regularStringSize = regularString.size() * sizeof(quint16);
+ int regularStringSize = regularString.size() * int(sizeof(quint16));
// Align table size of table to 32 bits (pad with 0)
int fullSize = ((sizeOfHeader + newFamilyNameSize + regularStringSize) & ~3) + 4;
@@ -641,11 +641,24 @@ QDebug operator<<(QDebug d, const QFontDef &def)
{
QDebugStateSaver saver(d);
d.nospace();
- d << "Family=" << def.family << " Stylename=" << def.styleName
- << " pointsize=" << def.pointSize << " pixelsize=" << def.pixelSize
- << " styleHint=" << def.styleHint << " weight=" << def.weight
- << " stretch=" << def.stretch << " hintingPreference="
- << def.hintingPreference;
+ d.noquote();
+ d << "QFontDef(Family=\"" << def.family << '"';
+ if (!def.styleName.isEmpty())
+ d << ", stylename=" << def.styleName;
+ d << ", pointsize=" << def.pointSize << ", pixelsize=" << def.pixelSize
+ << ", styleHint=" << def.styleHint << ", weight=" << def.weight
+ << ", stretch=" << def.stretch << ", hintingPreference="
+ << def.hintingPreference << ')';
+ return d;
+}
+
+QDebug operator<<(QDebug d, const LOGFONT &lf)
+{
+ QDebugStateSaver saver(d);
+ d.nospace();
+ d.noquote();
+ d << "LOGFONT(\"" << QString::fromWCharArray(lf.lfFaceName)
+ << "\", lfWidth=" << lf.lfWidth << ", lfHeight=" << lf.lfHeight << ')';
return d;
}
#endif // !QT_NO_DEBUG_STREAM
@@ -799,7 +812,7 @@ static QString getEnglishName(const uchar *table, quint32 bytes)
length /= 2;
i18n_name.resize(length);
- QChar *uc = (QChar *) i18n_name.unicode();
+ QChar *uc = const_cast<QChar *>(i18n_name.unicode());
const unsigned char *string = table + string_offset + offset;
for (int i = 0; i < length; ++i)
uc[i] = getUShort(string + 2*i);
@@ -807,10 +820,10 @@ static QString getEnglishName(const uchar *table, quint32 bytes)
// Apple Roman
i18n_name.resize(length);
- QChar *uc = (QChar *) i18n_name.unicode();
+ QChar *uc = const_cast<QChar *>(i18n_name.unicode());
const unsigned char *string = table + string_offset + offset;
for (int i = 0; i < length; ++i)
- uc[i] = QLatin1Char(string[i]);
+ uc[i] = QLatin1Char(char(string[i]));
}
}
}
@@ -877,14 +890,13 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
static const int SMOOTH_SCALABLE = 0xffff;
const QString foundryName; // No such concept.
- const NEWTEXTMETRIC *tm = (NEWTEXTMETRIC *)textmetric;
- const bool fixed = !(tm->tmPitchAndFamily & TMPF_FIXED_PITCH);
- const bool ttf = (tm->tmPitchAndFamily & TMPF_TRUETYPE);
- const bool scalable = tm->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
- const int size = scalable ? SMOOTH_SCALABLE : tm->tmHeight;
- const QFont::Style style = tm->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
+ const bool fixed = !(textmetric->tmPitchAndFamily & TMPF_FIXED_PITCH);
+ const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE);
+ const bool scalable = textmetric->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
+ const int size = scalable ? SMOOTH_SCALABLE : textmetric->tmHeight;
+ const QFont::Style style = textmetric->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
const bool antialias = false;
- const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(tm->tmWeight);
+ const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(textmetric->tmWeight);
const QFont::Stretch stretch = QFont::Unstretched;
#ifndef QT_NO_DEBUG_OUTPUT
@@ -964,18 +976,21 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
return true;
}
-static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric,
- int type, LPARAM registerAlias)
+static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
+ DWORD type, LPARAM lParam)
{
+ const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
const uchar charSet = f->elfLogFont.lfCharSet;
+ const bool registerAlias = bool(lParam);
- const FONTSIGNATURE signature = textmetric->ntmFontSig;
-
- // NEWTEXTMETRICEX is a NEWTEXTMETRIC, which according to the documentation is
- // identical to a TEXTMETRIC except for the last four members, which we don't use
- // anyway
- addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type, registerAlias);
+ // NEWTEXTMETRICEX (passed for TT fonts) is a NEWTEXTMETRIC, which according
+ // to the documentation is identical to a TEXTMETRIC except for the last four
+ // members, which we don't use anyway
+ const FONTSIGNATURE *signature = Q_NULLPTR;
+ if (type & TRUETYPE_FONTTYPE)
+ signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(textmetric)->ntmFontSig;
+ addFontToDatabase(familyName, charSet, textmetric, signature, type, registerAlias);
// keep on enumerating
return 1;
@@ -994,7 +1009,7 @@ void QWindowsFontDatabase::populateFamily(const QString &familyName, bool regist
familyName.toWCharArray(lf.lfFaceName);
lf.lfFaceName[familyName.size()] = 0;
lf.lfPitchAndFamily = 0;
- EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, (LPARAM)registerAlias, 0);
+ EnumFontFamiliesEx(dummy, &lf, storeFont, LPARAM(registerAlias), 0);
ReleaseDC(0, dummy);
}
@@ -1015,9 +1030,11 @@ struct PopulateFamiliesContext
};
} // namespace
-static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *tm, int, LPARAM lparam)
+static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
+ DWORD, LPARAM lparam)
{
// the "@family" fonts are just the same as "family". Ignore them.
+ const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
const wchar_t *faceNameW = f->elfLogFont.lfFaceName;
if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) {
const QString faceName = QString::fromWCharArray(faceNameW);
@@ -1027,7 +1044,7 @@ static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICE
context->seenSystemDefaultFont = true;
// Register current font's english name as alias
- const bool ttf = (tm->ntmTm.tmPitchAndFamily & TMPF_TRUETYPE);
+ const bool ttf = textmetric->tmPitchAndFamily & TMPF_TRUETYPE;
if (ttf && localizedName(faceName)) {
const QString englishName = getEnglishName(faceName);
if (!englishName.isEmpty()) {
@@ -1051,7 +1068,7 @@ void QWindowsFontDatabase::populateFontDatabase()
lf.lfFaceName[0] = 0;
lf.lfPitchAndFamily = 0;
PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family());
- EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)populateFontFamilies, reinterpret_cast<LPARAM>(&context), 0);
+ EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, reinterpret_cast<LPARAM>(&context), 0);
ReleaseDC(0, dummy);
// Work around EnumFontFamiliesEx() not listing the system font.
if (!context.seenSystemDefaultFont)
@@ -1157,8 +1174,9 @@ QT_WARNING_POP
DWORD count = 0;
QByteArray newFontData = font.data();
- HANDLE fontHandle = AddFontMemResourceEx((void *)newFontData.constData(), newFontData.size(), 0,
- &count);
+ HANDLE fontHandle =
+ AddFontMemResourceEx(const_cast<char *>(newFontData.constData()),
+ DWORD(newFontData.size()), 0, &count);
if (count == 0 && fontHandle != 0) {
RemoveFontMemResourceEx(fontHandle);
fontHandle = 0;
@@ -1376,8 +1394,9 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
return families;
DWORD dummy = 0;
- font.handle = AddFontMemResourceEx((void *)fontData.constData(), fontData.size(), 0,
- &dummy);
+ font.handle =
+ AddFontMemResourceEx(const_cast<char *>(fontData.constData()),
+ DWORD(fontData.size()), 0, &dummy);
if (font.handle == 0)
return QStringList();
@@ -1753,12 +1772,16 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
IDWriteFont *directWriteFont = 0;
HRESULT hr = data->directWriteGdiInterop->CreateFontFromLOGFONT(&lf, &directWriteFont);
if (FAILED(hr)) {
- qErrnoWarning("%s: CreateFontFromLOGFONT failed", __FUNCTION__);
+ const QString errorString = qt_error_string(int(GetLastError()));
+ qWarning().noquote().nospace() << "DirectWrite: CreateFontFromLOGFONT() failed ("
+ << errorString << ") for " << request << ' ' << lf << " dpi=" << dpi;
} else {
IDWriteFontFace *directWriteFontFace = NULL;
hr = directWriteFont->CreateFontFace(&directWriteFontFace);
if (FAILED(hr)) {
- qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__);
+ const QString errorString = qt_error_string(int(GetLastError()));
+ qWarning().noquote() << "DirectWrite: CreateFontFace() failed ("
+ << errorString << ") for " << request << ' ' << lf << " dpi=" << dpi;
} else {
QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
request.pixelSize,
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
index 8b61379c42..fb75e75dcd 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
@@ -396,14 +396,13 @@ static bool addFontToDatabase(const QString &faceName,
static const int SMOOTH_SCALABLE = 0xffff;
const QString foundryName; // No such concept.
- const NEWTEXTMETRIC *tm = (NEWTEXTMETRIC *)textmetric;
- const bool fixed = !(tm->tmPitchAndFamily & TMPF_FIXED_PITCH);
- const bool ttf = (tm->tmPitchAndFamily & TMPF_TRUETYPE);
- const bool scalable = tm->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
- const int size = scalable ? SMOOTH_SCALABLE : tm->tmHeight;
- const QFont::Style style = tm->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
+ const bool fixed = !(textmetric->tmPitchAndFamily & TMPF_FIXED_PITCH);
+ const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE);
+ const bool scalable = textmetric->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
+ const int size = scalable ? SMOOTH_SCALABLE : textmetric->tmHeight;
+ const QFont::Style style = textmetric->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
const bool antialias = false;
- const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(tm->tmWeight);
+ const QFont::Weight weight = QPlatformFontDatabase::weightFromInteger(textmetric->tmWeight);
const QFont::Stretch stretch = QFont::Unstretched;
#ifndef QT_NO_DEBUG_STREAM
@@ -520,19 +519,21 @@ static QByteArray getFntTable(HFONT hfont, uint tag)
}
#endif
-static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric,
- int type, LPARAM)
+static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
+ DWORD type, LPARAM)
{
-
+ const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
const QString faceName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
const QString fullName = QString::fromWCharArray(f->elfFullName);
const uchar charSet = f->elfLogFont.lfCharSet;
- const FONTSIGNATURE signature = textmetric->ntmFontSig;
- // NEWTEXTMETRICEX is a NEWTEXTMETRIC, which according to the documentation is
- // identical to a TEXTMETRIC except for the last four members, which we don't use
- // anyway
- addFontToDatabase(faceName, fullName, charSet, (TEXTMETRIC *)textmetric, &signature, type, false);
+ // NEWTEXTMETRICEX (passed for TT fonts) is a NEWTEXTMETRIC, which according
+ // to the documentation is identical to a TEXTMETRIC except for the last four
+ // members, which we don't use anyway
+ const FONTSIGNATURE *signature = Q_NULLPTR;
+ if (type & TRUETYPE_FONTTYPE)
+ signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(textmetric)->ntmFontSig;
+ addFontToDatabase(faceName, fullName, charSet, textmetric, signature, type, false);
// keep on enumerating
return 1;
@@ -559,7 +560,7 @@ void QWindowsFontDatabaseFT::populateFamily(const QString &familyName)
familyName.toWCharArray(lf.lfFaceName);
lf.lfFaceName[familyName.size()] = 0;
lf.lfPitchAndFamily = 0;
- EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, 0, 0);
+ EnumFontFamiliesEx(dummy, &lf, storeFont, 0, 0);
ReleaseDC(0, dummy);
}
@@ -579,17 +580,20 @@ struct PopulateFamiliesContext
// Delayed population of font families
-static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *tm, int, LPARAM lparam)
+static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
+ DWORD, LPARAM lparam)
{
+ const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
// the "@family" fonts are just the same as "family". Ignore them.
const wchar_t *faceNameW = f->elfLogFont.lfFaceName;
if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) {
// Register only font families for which a font file exists for delayed population
+ const bool ttf = textmetric->tmPitchAndFamily & TMPF_TRUETYPE;
const QString faceName = QString::fromWCharArray(faceNameW);
const FontKey *key = findFontKey(faceName);
if (!key) {
key = findFontKey(QString::fromWCharArray(f->elfFullName));
- if (!key && (tm->ntmTm.tmPitchAndFamily & TMPF_TRUETYPE) && localizedName(faceName))
+ if (!key && ttf && localizedName(faceName))
key = findFontKey(getEnglishName(faceName));
}
if (key) {
@@ -599,7 +603,6 @@ static int QT_WIN_CALLBACK populateFontFamilies(ENUMLOGFONTEX* f, NEWTEXTMETRICE
context->seenSystemDefaultFont = true;
// Register current font's english name as alias
- const bool ttf = (tm->ntmTm.tmPitchAndFamily & TMPF_TRUETYPE);
if (ttf && localizedName(faceName)) {
const QString englishName = getEnglishName(faceName);
if (!englishName.isEmpty()) {
@@ -623,7 +626,7 @@ void QWindowsFontDatabaseFT::populateFontDatabase()
lf.lfFaceName[0] = 0;
lf.lfPitchAndFamily = 0;
PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family());
- EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)populateFontFamilies, reinterpret_cast<LPARAM>(&context), 0);
+ EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, reinterpret_cast<LPARAM>(&context), 0);
ReleaseDC(0, dummy);
// Work around EnumFontFamiliesEx() not listing the system font
if (!context.seenSystemDefaultFont)
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index 1b88f8bbe4..c78412c8ec 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -166,6 +166,12 @@ bool QWindowsFontEngine::hasEbdtTable() const
return GetFontData(hdc, MAKE_TAG('E', 'B', 'D', 'T'), 0, 0, 0) != GDI_ERROR;
}
+static inline QString stringFromOutLineTextMetric(const OUTLINETEXTMETRIC *otm, PSTR offset)
+{
+ const uchar *p = reinterpret_cast<const uchar *>(otm) + quintptr(offset);
+ return QString::fromWCharArray(reinterpret_cast<const wchar_t *>(p));
+}
+
void QWindowsFontEngine::getCMap()
{
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable();
@@ -189,11 +195,12 @@ void QWindowsFontEngine::getCMap()
_faceId.index = 0;
if(cmap) {
OUTLINETEXTMETRIC *otm = getOutlineTextMetric(hdc);
- designToDevice = QFixed((int)otm->otmEMSquare)/QFixed::fromReal(fontDef.pixelSize);
- unitsPerEm = otm->otmEMSquare;
- x_height = (int)otm->otmsXHeight;
+ unitsPerEm = int(otm->otmEMSquare);
+ const QFixed unitsPerEmF(unitsPerEm);
+ designToDevice = unitsPerEmF / QFixed::fromReal(fontDef.pixelSize);
+ x_height = int(otm->otmsXHeight);
loadKerningPairs(designToDevice);
- _faceId.filename = QFile::encodeName(QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFullName)));
+ _faceId.filename = QFile::encodeName(stringFromOutLineTextMetric(otm, otm->otmpFullName));
lineWidth = otm->otmsUnderscoreSize;
fsType = otm->otmfsType;
free(otm);
@@ -394,9 +401,9 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape
for(int i = 0; i < glyphs->numGlyphs; i++) {
unsigned int glyph = glyphs->glyphs[i];
if(int(glyph) >= designAdvancesSize) {
- int newSize = (glyph + 256) >> 8 << 8;
- designAdvances = q_check_ptr((QFixed *)realloc(designAdvances,
- newSize*sizeof(QFixed)));
+ const int newSize = int(glyph + 256) >> 8 << 8;
+ designAdvances = reinterpret_cast<QFixed *>(realloc(designAdvances, size_t(newSize) * sizeof(QFixed)));
+ Q_CHECK_PTR(designAdvances);
for(int i = designAdvancesSize; i < newSize; ++i)
designAdvances[i] = -1000000;
designAdvancesSize = newSize;
@@ -418,9 +425,9 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape
unsigned int glyph = glyphs->glyphs[i];
if (glyph >= widthCacheSize) {
- int newSize = (glyph + 256) >> 8 << 8;
- widthCache = q_check_ptr((unsigned char *)realloc(widthCache,
- newSize*sizeof(QFixed)));
+ const uint newSize = (glyph + 256) >> 8 << 8;
+ widthCache = reinterpret_cast<unsigned char *>(realloc(widthCache, newSize * sizeof(QFixed)));
+ Q_CHECK_PTR(widthCache);
memset(widthCache + widthCacheSize, 0, newSize - widthCacheSize);
widthCacheSize = newSize;
}
@@ -440,7 +447,7 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape
++chrLen;
}
SIZE size = {0, 0};
- GetTextExtentPoint32(hdc, (wchar_t *)ch, chrLen, &size);
+ GetTextExtentPoint32(hdc, reinterpret_cast<const wchar_t *>(ch), chrLen, &size);
width = size.cx;
} else {
calculateTTFGlyphWidth(hdc, glyph, width);
@@ -448,7 +455,7 @@ void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shape
glyphs->advances[i] = width;
// if glyph's within cache range, store it for later
if (width > 0 && width < 0x100)
- widthCache[glyph] = width;
+ widthCache[glyph] = uchar(width);
}
}
@@ -489,10 +496,10 @@ bool QWindowsFontEngine::getOutlineMetrics(glyph_t glyph, const QTransform &t, g
// results provided when transforming via MAT2 does not
// match the glyphs that are drawn using a WorldTransform
XFORM xform;
- xform.eM11 = t.m11();
- xform.eM12 = t.m12();
- xform.eM21 = t.m21();
- xform.eM22 = t.m22();
+ xform.eM11 = FLOAT(t.m11());
+ xform.eM12 = FLOAT(t.m12());
+ xform.eM21 = FLOAT(t.m21());
+ xform.eM22 = FLOAT(t.m22());
xform.eDx = 0;
xform.eDy = 0;
SetGraphicsMode(hdc, GM_ADVANCED);
@@ -514,7 +521,8 @@ bool QWindowsFontEngine::getOutlineMetrics(glyph_t glyph, const QTransform &t, g
if (res != GDI_ERROR) {
*metrics = glyph_metrics_t(gm.gmptGlyphOrigin.x, -gm.gmptGlyphOrigin.y,
- (int)gm.gmBlackBoxX, (int)gm.gmBlackBoxY, gm.gmCellIncX, gm.gmCellIncY);
+ int(gm.gmBlackBoxX), int(gm.gmBlackBoxY),
+ gm.gmCellIncX, gm.gmCellIncY);
return true;
} else {
return false;
@@ -533,7 +541,7 @@ glyph_metrics_t QWindowsFontEngine::boundingBox(glyph_t glyph, const QTransform
if (!ttf && !success) {
// Bitmap fonts
- wchar_t ch = glyph;
+ wchar_t ch = wchar_t(glyph);
ABCFLOAT abc;
GetCharABCWidthsFloat(hdc, ch, ch, &abc);
int width = qRound(abc.abcfB);
@@ -798,7 +806,7 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
return false;
// #### obey scale
*metric = glyph_metrics_t(gMetric.gmptGlyphOrigin.x, -gMetric.gmptGlyphOrigin.y,
- (int)gMetric.gmBlackBoxX, (int)gMetric.gmBlackBoxY,
+ int(gMetric.gmBlackBoxX), int(gMetric.gmBlackBoxY),
gMetric.gmCellIncX, gMetric.gmCellIncY);
}
#endif
@@ -808,17 +816,15 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
if (ttf)
glyphFormat |= GGO_GLYPH_INDEX;
- int bufferSize = GDI_ERROR;
- bufferSize = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, 0, 0, &mat);
- if ((DWORD)bufferSize == GDI_ERROR) {
+ const DWORD bufferSize = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, 0, 0, &mat);
+ if (bufferSize == GDI_ERROR)
return false;
- }
- void *dataBuffer = new char[bufferSize];
+ char *dataBuffer = new char[bufferSize];
DWORD ret = GDI_ERROR;
ret = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, bufferSize, dataBuffer, &mat);
if (ret == GDI_ERROR) {
- delete [](char *)dataBuffer;
+ delete [] dataBuffer;
return false;
}
@@ -831,20 +837,18 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
}
#endif
- int offset = 0;
- int headerOffset = 0;
- TTPOLYGONHEADER *ttph = 0;
+ DWORD offset = 0;
+ DWORD headerOffset = 0;
QPointF oset = position.toPointF();
while (headerOffset < bufferSize) {
- ttph = (TTPOLYGONHEADER*)((char *)dataBuffer + headerOffset);
+ const TTPOLYGONHEADER *ttph = reinterpret_cast<const TTPOLYGONHEADER *>(dataBuffer + headerOffset);
QPointF lastPoint(qt_to_qpointf(ttph->pfxStart, scale));
path->moveTo(lastPoint + oset);
offset += sizeof(TTPOLYGONHEADER);
- TTPOLYCURVE *curve;
- while (offset<int(headerOffset + ttph->cb)) {
- curve = (TTPOLYCURVE*)((char*)(dataBuffer) + offset);
+ while (offset < headerOffset + ttph->cb) {
+ const TTPOLYCURVE *curve = reinterpret_cast<const TTPOLYCURVE *>(dataBuffer + offset);
switch (curve->wType) {
case TT_PRIM_LINE: {
for (int i=0; i<curve->cpfx; ++i) {
@@ -889,7 +893,7 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
path->closeSubpath();
headerOffset += ttph->cb;
}
- delete [] (char*)dataBuffer;
+ delete [] dataBuffer;
return true;
}
@@ -987,15 +991,15 @@ QFontEngine::Properties QWindowsFontEngine::properties() const
Properties p;
p.emSquare = unitsPerEm;
p.italicAngle = otm->otmItalicAngle;
- p.postscriptName = QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFamilyName)).toLatin1();
- p.postscriptName += QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpStyleName)).toLatin1();
- p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(p.postscriptName);
+ const QByteArray name = stringFromOutLineTextMetric(otm, otm->otmpFamilyName).toLatin1()
+ + stringFromOutLineTextMetric(otm, otm->otmpStyleName).toLatin1();
+ p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(name);
p.boundingBox = QRectF(otm->otmrcFontBox.left, -otm->otmrcFontBox.top,
otm->otmrcFontBox.right - otm->otmrcFontBox.left,
otm->otmrcFontBox.top - otm->otmrcFontBox.bottom);
p.ascent = otm->otmAscent;
p.descent = -otm->otmDescent;
- p.leading = (int)otm->otmLineGap;
+ p.leading = int(otm->otmLineGap);
p.capHeight = 0;
p.lineWidth = otm->otmsUnderscoreSize;
free(otm);
@@ -1061,10 +1065,10 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
XFORM xform;
if (has_transformation) {
- xform.eM11 = t.m11();
- xform.eM12 = t.m12();
- xform.eM21 = t.m21();
- xform.eM22 = t.m22();
+ xform.eM11 = FLOAT(t.m11());
+ xform.eM12 = FLOAT(t.m12());
+ xform.eM21 = FLOAT(t.m21());
+ xform.eM22 = FLOAT(t.m22());
xform.eDx = margin;
xform.eDy = margin;
@@ -1074,7 +1078,7 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
SetWorldTransform(hdc, &xform);
HGDIOBJ old_font = SelectObject(hdc, font);
- int ggo_options = GGO_METRICS | (ttf ? GGO_GLYPH_INDEX : 0);
+ const UINT ggo_options = GGO_METRICS | (ttf ? GGO_GLYPH_INDEX : 0);
GLYPHMETRICS tgm;
MAT2 mat;
memset(&mat, 0, sizeof(mat));
@@ -1088,13 +1092,13 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
SelectObject(hdc, old_font);
if (result == GDI_ERROR) {
- const int errorCode = GetLastError();
+ const int errorCode = int(GetLastError());
qErrnoWarning(errorCode, "QWinFontEngine: unable to query transformed glyph metrics (GetGlyphOutline() failed, error %d)...", errorCode);
return 0;
}
- iw = tgm.gmBlackBoxX;
- ih = tgm.gmBlackBoxY;
+ iw = int(tgm.gmBlackBoxX);
+ ih = int(tgm.gmBlackBoxY);
xform.eDx -= tgm.gmptGlyphOrigin.x;
xform.eDy += tgm.gmptGlyphOrigin.y;
@@ -1131,11 +1135,11 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
if (has_transformation) {
SetGraphicsMode(hdc, GM_ADVANCED);
SetWorldTransform(hdc, &xform);
- ExtTextOut(hdc, 0, 0, options, 0, (LPCWSTR) &glyph, 1, 0);
+ ExtTextOut(hdc, 0, 0, options, 0, reinterpret_cast<LPCWSTR>(&glyph), 1, 0);
} else
#endif // !Q_OS_WINCE
{
- ExtTextOut(hdc, -gx + margin, -gy + margin, options, 0, (LPCWSTR) &glyph, 1, 0);
+ ExtTextOut(hdc, -gx + margin, -gy + margin, options, 0, reinterpret_cast<LPCWSTR>(&glyph), 1, 0);
}
SelectObject(hdc, old_font);
@@ -1166,7 +1170,7 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo
QImage::Format mask_format = QWindowsNativeImage::systemFormat();
mask_format = QImage::Format_RGB32;
- QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format);
+ const QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format);
if (mask == 0) {
if (m_fontEngineData->clearTypeEnabled)
DeleteObject(font);
@@ -1181,11 +1185,11 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo
for (int y=0; y<mask->height(); ++y) {
uchar *dest = alphaMap.scanLine(y);
if (mask->image().format() == QImage::Format_RGB16) {
- const qint16 *src = (qint16 *) ((const QImage &) mask->image()).scanLine(y);
+ const qint16 *src = reinterpret_cast<const qint16 *>(mask->image().constScanLine(y));
for (int x=0; x<mask->width(); ++x)
dest[x] = 255 - qGray(src[x]);
} else {
- const uint *src = (uint *) ((const QImage &) mask->image()).scanLine(y);
+ const uint *src = reinterpret_cast<const uint *>(mask->image().constScanLine(y));
for (int x=0; x<mask->width(); ++x) {
if (QWindowsNativeImage::systemFormat() == QImage::Format_RGB16)
dest[x] = 255 - qGray(src[x]);
@@ -1213,11 +1217,11 @@ QImage QWindowsFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed, const QTra
UINT contrast;
SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0);
- SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) 1000, 0);
+ SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, reinterpret_cast<void *>(quintptr(1000)), 0);
int margin = glyphMargin(QFontEngine::Format_A32);
QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QImage::Format_RGB32);
- SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) quintptr(contrast), 0);
+ SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, reinterpret_cast<void *>(quintptr(contrast)), 0);
if (mask == 0)
return QImage();
@@ -1230,7 +1234,7 @@ QImage QWindowsFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed, const QTra
QImage rgbMask(mask->width(), mask->height(), QImage::Format_RGB32);
for (int y=0; y<mask->height(); ++y) {
uint *dest = (uint *) rgbMask.scanLine(y);
- const uint *src = (uint *) source.scanLine(y);
+ const uint *src = reinterpret_cast<const uint *>(source.constScanLine(y));
for (int x=0; x<mask->width(); ++x) {
dest[x] = 0xffffffff - (0x00ffffff & src[x]);
}
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
index 02b56fc40a..2831962ef4 100644
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
@@ -499,7 +499,7 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed sub
QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8);
for (int y=0; y<im.height(); ++y) {
- uint *src = (uint*) im.scanLine(y);
+ const uint *src = reinterpret_cast<const uint *>(im.constScanLine(y));
uchar *dst = alphaMap.scanLine(y);
for (int x=0; x<im.width(); ++x) {
*dst = 255 - (m_fontEngineData->pow_gamma[qGray(0xffffffff - *src)] * 255. / 2047.);
@@ -765,12 +765,17 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph
transform.m21 = matrix.m21();
transform.m22 = matrix.m22();
+ DWRITE_RENDERING_MODE renderMode =
+ fontDef.hintingPreference == QFont::PreferNoHinting
+ ? DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC
+ : DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL;
+
IDWriteGlyphRunAnalysis *glyphAnalysis = NULL;
HRESULT hr = m_fontEngineData->directWriteFactory->CreateGlyphRunAnalysis(
&glyphRun,
1.0f,
&transform,
- DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC,
+ renderMode,
DWRITE_MEASURING_MODE_NATURAL,
0.0, 0.0,
&glyphAnalysis
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp
index 71b2387c7c..48f2e3aaef 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp
@@ -1017,7 +1017,7 @@ QOpenGLStaticContext::QOpenGLStaticContext() :
QByteArray QOpenGLStaticContext::getGlString(unsigned int which)
{
if (const GLubyte *s = opengl32.glGetString(which))
- return QByteArray((const char*)s);
+ return QByteArray(reinterpret_cast<const char*>(s));
return QByteArray();
}
@@ -1244,7 +1244,7 @@ bool QWindowsGLContext::updateObtainedParams(HDC hdc, int *obtainedSwapInterval)
bool hasRobustness = false;
if (m_obtainedFormat.majorVersion() < 3) {
- const char *exts = (const char *) QOpenGLStaticContext::opengl32.glGetString(GL_EXTENSIONS);
+ const char *exts = reinterpret_cast<const char *>(QOpenGLStaticContext::opengl32.glGetString(GL_EXTENSIONS));
hasRobustness = exts && strstr(exts, "GL_ARB_robustness");
} else {
typedef const GLubyte * (APIENTRY *glGetStringi_t)(GLenum, GLuint);
@@ -1253,7 +1253,7 @@ bool QWindowsGLContext::updateObtainedParams(HDC hdc, int *obtainedSwapInterval)
GLint n = 0;
QOpenGLStaticContext::opengl32.glGetIntegerv(GL_NUM_EXTENSIONS, &n);
for (GLint i = 0; i < n; ++i) {
- const char *p = (const char *) glGetStringi(GL_EXTENSIONS, i);
+ const char *p = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
if (p && !strcmp(p, "GL_ARB_robustness")) {
hasRobustness = true;
break;
@@ -1270,10 +1270,9 @@ bool QWindowsGLContext::updateObtainedParams(HDC hdc, int *obtainedSwapInterval)
void QWindowsGLContext::releaseDCs()
{
- const QOpenGLContextData *end = m_windowContexts.end();
- for (const QOpenGLContextData *p = m_windowContexts.begin(); p < end; ++p)
- ReleaseDC(p->hwnd, p->hdc);
- m_windowContexts.resize(0);
+ for (const auto &e : m_windowContexts)
+ ReleaseDC(e.hwnd, e.hdc);
+ m_windowContexts.clear();
}
static inline QWindowsWindow *glWindowOf(QPlatformSurface *s)
@@ -1288,12 +1287,12 @@ static inline HWND handleOf(QPlatformSurface *s)
// Find a window in a context list.
static inline const QOpenGLContextData *
- findByHWND(const Array<QOpenGLContextData> &data, HWND hwnd)
+ findByHWND(const std::vector<QOpenGLContextData> &data, HWND hwnd)
{
- const QOpenGLContextData *end = data.end();
- for (const QOpenGLContextData *p = data.begin(); p < end; ++p)
- if (p->hwnd == hwnd)
- return p;
+ for (const auto &e : data) {
+ if (e.hwnd == hwnd)
+ return &e;
+ }
return 0;
}
@@ -1347,7 +1346,7 @@ bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface)
if (m_obtainedFormat.swapBehavior() == QSurfaceFormat::DoubleBuffer)
window->setFlag(QWindowsWindow::OpenGLDoubleBuffered);
}
- m_windowContexts.append(newContext);
+ m_windowContexts.push_back(newContext);
m_lost = false;
bool success = QOpenGLStaticContext::opengl32.wglMakeCurrent(newContext.hdc, newContext.renderingContext);
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h
index 791a17301e..3acfed1ccf 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.h
+++ b/src/plugins/platforms/windows/qwindowsglcontext.h
@@ -40,12 +40,13 @@
#ifndef QWINDOWSGLCONTEXT_H
#define QWINDOWSGLCONTEXT_H
-#include "array.h"
#include "qtwindows_additional.h"
#include "qwindowsopenglcontext.h"
#include <QtGui/QOpenGLContext>
+#include <vector>
+
QT_BEGIN_NAMESPACE
class QDebug;
@@ -264,7 +265,7 @@ private:
QOpenGLContext *m_context;
QSurfaceFormat m_obtainedFormat;
HGLRC m_renderingContext;
- Array<QOpenGLContextData> m_windowContexts;
+ std::vector<QOpenGLContextData> m_windowContexts;
PIXELFORMATDESCRIPTOR m_obtainedPixelFormatDescriptor;
int m_pixelFormat;
bool m_extensionsUsed;
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index f1addf186d..d0c3b80707 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -323,7 +323,9 @@ void QWindowsInputContext::invokeAction(QInputMethod::Action action, int cursorP
// position.
const HIMC himc = ImmGetContext(m_compositionContext.hwnd);
const HWND imeWindow = ImmGetDefaultIMEWnd(m_compositionContext.hwnd);
- SendMessage(imeWindow, m_WM_MSIME_MOUSE, MAKELONG(MAKEWORD(MK_LBUTTON, cursorPosition == 0 ? 2 : 1), cursorPosition), (LPARAM)himc);
+ const WPARAM mouseOperationCode =
+ MAKELONG(MAKEWORD(MK_LBUTTON, cursorPosition == 0 ? 2 : 1), cursorPosition);
+ SendMessage(imeWindow, m_WM_MSIME_MOUSE, mouseOperationCode, LPARAM(himc));
ImmReleaseContext(m_compositionContext.hwnd, himc);
}
@@ -332,7 +334,7 @@ static inline QString getCompositionString(HIMC himc, DWORD dwIndex)
enum { bufferSize = 256 };
wchar_t buffer[bufferSize];
const int length = ImmGetCompositionString(himc, dwIndex, buffer, bufferSize * sizeof(wchar_t));
- return QString::fromWCharArray(buffer, length / sizeof(wchar_t));
+ return QString::fromWCharArray(buffer, size_t(length) / sizeof(wchar_t));
}
// Determine the converted string range as pair of start/length to be selected.
@@ -563,9 +565,8 @@ bool QWindowsInputContext::handleIME_Request(WPARAM wParam,
if (size < 0)
return false;
*result = size;
- return true;
}
- break;
+ return true;
case IMR_CONFIRMRECONVERTSTRING:
return true;
default:
@@ -576,7 +577,7 @@ bool QWindowsInputContext::handleIME_Request(WPARAM wParam,
void QWindowsInputContext::handleInputLanguageChanged(WPARAM wparam, LPARAM lparam)
{
- const LCID newLanguageId = languageIdFromLocaleId(lparam);
+ const LCID newLanguageId = languageIdFromLocaleId(WORD(lparam));
if (newLanguageId == m_languageId)
return;
const LCID oldLanguageId = m_languageId;
@@ -610,13 +611,13 @@ int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv)
if (!surroundingTextV.isValid())
return -1;
const QString surroundingText = surroundingTextV.toString();
- const DWORD memSize = sizeof(RECONVERTSTRING)
- + (surroundingText.length() + 1) * sizeof(ushort);
+ const int memSize = int(sizeof(RECONVERTSTRING))
+ + (surroundingText.length() + 1) * int(sizeof(ushort));
qCDebug(lcQpaInputMethods) << __FUNCTION__ << " reconv=" << reconv
<< " surroundingText=" << surroundingText << " size=" << memSize;
// If memory is not allocated, return the required size.
if (!reconv)
- return surroundingText.isEmpty() ? -1 : int(memSize);
+ return surroundingText.isEmpty() ? -1 : memSize;
const QVariant posV = QInputMethod::queryFocusObject(Qt::ImCursorPosition, QVariant());
const int pos = posV.isValid() ? posV.toInt() : 0;
@@ -635,13 +636,13 @@ int QWindowsInputContext::reconvertString(RECONVERTSTRING *reconv)
QInputMethodEvent selectEvent(QString(), attributes);
QCoreApplication::sendEvent(fo, &selectEvent);
- reconv->dwSize = memSize;
+ reconv->dwSize = DWORD(memSize);
reconv->dwVersion = 0;
- reconv->dwStrLen = surroundingText.size();
+ reconv->dwStrLen = DWORD(surroundingText.size());
reconv->dwStrOffset = sizeof(RECONVERTSTRING);
- reconv->dwCompStrLen = endPos - startPos; // TCHAR count.
- reconv->dwCompStrOffset = startPos * sizeof(ushort); // byte count.
+ reconv->dwCompStrLen = DWORD(endPos - startPos); // TCHAR count.
+ reconv->dwCompStrOffset = DWORD(startPos) * sizeof(ushort); // byte count.
reconv->dwTargetStrLen = reconv->dwCompStrLen;
reconv->dwTargetStrOffset = reconv->dwCompStrOffset;
ushort *pastReconv = reinterpret_cast<ushort *>(reconv + 1);
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 2904999d96..e0ebb142f5 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -543,8 +543,8 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co
case QPlatformIntegration::FontSmoothingGamma:
return QVariant(QWindowsFontDatabase::fontSmoothingGamma());
case QPlatformIntegration::MouseDoubleClickInterval:
- if (const int ms = GetDoubleClickTime())
- return QVariant(ms);
+ if (const UINT ms = GetDoubleClickTime())
+ return QVariant(int(ms));
break;
case QPlatformIntegration::UseRtlExtensions:
return QVariant(d->m_context.useRTLExtensions());
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index 6fc49c1384..48de7d56f8 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -547,7 +547,7 @@ Q_STATIC_ASSERT((NumMods == KeyboardLayoutItem::NumQtKeys));
/**
Remap return or action key to select key for windows mobile.
*/
-inline int winceKeyBend(int keyCode)
+inline quint32 winceKeyBend(quint32 keyCode)
{
return KeyTbl[keyCode];
}
@@ -581,10 +581,10 @@ QT_END_INCLUDE_NAMESPACE
#endif // Q_OS_WINCE
// Translate a VK into a Qt key code, or unicode character
-static inline int toKeyOrUnicode(int vk, int scancode, unsigned char *kbdBuffer, bool *isDeadkey = 0)
+static inline quint32 toKeyOrUnicode(quint32 vk, quint32 scancode, unsigned char *kbdBuffer, bool *isDeadkey = 0)
{
Q_ASSERT(vk > 0 && vk < 256);
- int code = 0;
+ quint32 code = 0;
QChar unicodeBuffer[5];
int res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast<LPWSTR>(unicodeBuffer), 5, 0);
// When Ctrl modifier is used ToUnicode does not return correct values. In order to assign the
@@ -638,13 +638,13 @@ void QWindowsKeyMapper::changeKeyboard()
/* MAKELCID()'s first argument is a WORD, and GetKeyboardLayout()
* returns a DWORD. */
- LCID newLCID = MAKELCID((quintptr)GetKeyboardLayout(0), SORT_DEFAULT);
+ LCID newLCID = MAKELCID(quintptr(GetKeyboardLayout(0)), SORT_DEFAULT);
// keyboardInputLocale = qt_localeFromLCID(newLCID);
bool bidi = false;
wchar_t LCIDFontSig[16];
if (GetLocaleInfo(newLCID, LOCALE_FONTSIGNATURE, LCIDFontSig, sizeof(LCIDFontSig) / sizeof(wchar_t))
- && (LCIDFontSig[7] & (wchar_t)0x0800))
+ && (LCIDFontSig[7] & wchar_t(0x0800)))
bidi = true;
keyboardInputDirection = bidi ? Qt::RightToLeft : Qt::LeftToRight;
@@ -668,7 +668,7 @@ void QWindowsKeyMapper::updateKeyMap(const MSG &msg)
unsigned char kbdBuffer[256]; // Will hold the complete keyboard state
GetKeyboardState(kbdBuffer);
const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask;
- updatePossibleKeyCodes(kbdBuffer, scancode, msg.wParam);
+ updatePossibleKeyCodes(kbdBuffer, scancode, quint32(msg.wParam));
}
// Fills keyLayout for that vk_key. Values are all characters one can type using that key
@@ -727,7 +727,7 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32
keyLayout[vk_key].qtKey[7] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey);
keyLayout[vk_key].deadkeys |= isDeadKey ? 0x80 : 0;
// Add a fall back key for layouts which don't do composition and show non-latin1 characters
- int fallbackKey = winceKeyBend(vk_key);
+ quint32 fallbackKey = winceKeyBend(vk_key);
if (!fallbackKey || fallbackKey == Qt::Key_unknown) {
fallbackKey = 0;
if (vk_key != keyLayout[vk_key].qtKey[0] && vk_key < 0x5B && vk_key > 0x2F)
@@ -768,7 +768,7 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32
static inline QString messageKeyText(const MSG &msg)
{
- const QChar ch = QChar((ushort)msg.wParam);
+ const QChar ch = QChar(ushort(msg.wParam));
return ch.isNull() ? QString() : QString(ch);
}
@@ -813,7 +813,7 @@ static void showSystemMenu(QWindow* w)
topLevelHwnd,
0);
if (ret)
- qWindowsWndProc(topLevelHwnd, WM_SYSCOMMAND, ret, 0);
+ qWindowsWndProc(topLevelHwnd, WM_SYSCOMMAND, WPARAM(ret), 0);
}
static inline void sendExtendedPressRelease(QWindow *w, int k,
@@ -877,7 +877,7 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con
if (cmd < 0 || cmd > 52)
return false;
- const int qtKey = CmdTbl[cmd];
+ const int qtKey = int(CmdTbl[cmd]);
sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0);
// QTBUG-43343: Make sure to return false if Qt does not handle the key, otherwise,
// the keys are not passed to the active media player.
@@ -891,10 +891,10 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con
bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &msg, bool /* grab */)
{
- const int msgType = msg.message;
+ const UINT msgType = msg.message;
const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask;
- quint32 vk_key = msg.wParam;
+ quint32 vk_key = quint32(msg.wParam);
quint32 nModifiers = 0;
QWindow *receiver = m_keyGrabber ? m_keyGrabber : window;
@@ -955,13 +955,13 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
if (dirStatus == VK_LSHIFT
&& ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL))
|| (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) {
- sendExtendedPressRelease(receiver, Qt::Key_Direction_L, 0, scancode, msg.wParam, nModifiers, QString(), false);
+ sendExtendedPressRelease(receiver, Qt::Key_Direction_L, 0, scancode, vk_key, nModifiers, QString(), false);
result = true;
dirStatus = 0;
} else if (dirStatus == VK_RSHIFT
&& ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL))
|| (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) {
- sendExtendedPressRelease(receiver, Qt::Key_Direction_R, 0, scancode, msg.wParam, nModifiers, QString(), false);
+ sendExtendedPressRelease(receiver, Qt::Key_Direction_R, 0, scancode, vk_key, nModifiers, QString(), false);
result = true;
dirStatus = 0;
} else {
@@ -1036,7 +1036,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
|| (msg.wParam >= VK_OEM_PLUS && msg.wParam <= VK_OEM_3))
? 0 : int(Qt::KeypadModifier);
default:
- if ((uint)msg.lParam == 0x004c0001 || (uint)msg.lParam == 0xc04c0001)
+ if (uint(msg.lParam) == 0x004c0001 || uint(msg.lParam) == 0xc04c0001)
state |= Qt::KeypadModifier;
break;
}
@@ -1048,6 +1048,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
case Qt::Key_Slash:
case Qt::Key_NumLock:
state |= Qt::KeypadModifier;
+ break;
default:
break;
}
@@ -1057,13 +1058,13 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
if (msgType == WM_KEYDOWN || msgType == WM_IME_KEYDOWN || msgType == WM_SYSKEYDOWN) {
// Get the last record of this key press, so we can validate the current state
// The record is not removed from the list
- KeyRecord *rec = key_recorder.findKey(msg.wParam, false);
+ KeyRecord *rec = key_recorder.findKey(int(msg.wParam), false);
// If rec's state doesn't match the current state, something has changed behind our back
// (Consumed by modal widget is one possibility) So, remove the record from the list
// This will stop the auto-repeat of the key, should a modifier change, for example
if (rec && rec->state != state) {
- key_recorder.findKey(msg.wParam, true);
+ key_recorder.findKey(int(msg.wParam), true);
rec = 0;
}
@@ -1076,11 +1077,11 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
QChar uch;
if (PeekMessage(&wm_char, 0, charType, charType, PM_REMOVE)) {
// Found a ?_CHAR
- uch = QChar((ushort)wm_char.wParam);
+ uch = QChar(ushort(wm_char.wParam));
if (msgType == WM_SYSKEYDOWN && uch.isLetter() && (msg.lParam & KF_ALTDOWN))
uch = uch.toLower(); // (See doc of WM_SYSCHAR) Alt-letter
if (!code && !uch.row())
- code = asciiToKeycode(uch.cell(), state);
+ code = asciiToKeycode(char(uch.cell()), state);
}
// Special handling for the WM_IME_KEYDOWN message. Microsoft IME (Korean) will not
@@ -1091,7 +1092,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
const QWindowsInputContext *windowsInputContext =
qobject_cast<const QWindowsInputContext *>(QWindowsIntegration::instance()->inputContext());
if (!(windowsInputContext && windowsInputContext->isComposing()))
- vk_key = ImmGetVirtualKey((HWND)window->winId());
+ vk_key = ImmGetVirtualKey(reinterpret_cast<HWND>(window->winId()));
BYTE keyState[256];
wchar_t newKey[3] = {0};
GetKeyboardState(keyState);
@@ -1111,14 +1112,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
uch = QChar(QLatin1Char(0x7f)); // Windows doesn't know this one.
} else {
if (msgType != WM_SYSKEYDOWN || !code) {
- UINT map = MapVirtualKey(msg.wParam, 2);
+ UINT map = MapVirtualKey(UINT(msg.wParam), 2);
// If the high bit of the return value is set, it's a deadkey
if (!(map & 0x80000000))
- uch = QChar((ushort)map);
+ uch = QChar(ushort(map));
}
}
if (!code && !uch.row())
- code = asciiToKeycode(uch.cell(), state);
+ code = asciiToKeycode(char(uch.cell()), state);
}
// Special handling of global Windows hotkeys
@@ -1147,9 +1148,9 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
if (rec) {
if (code < Qt::Key_Shift || code > Qt::Key_ScrollLock) {
QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyRelease, code,
- Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, rec->text, true);
+ Qt::KeyboardModifier(state), scancode, quint32(msg.wParam), nModifiers, rec->text, true);
QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyPress, code,
- Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, rec->text, true);
+ Qt::KeyboardModifier(state), scancode, quint32(msg.wParam), nModifiers, rec->text, true);
result = true;
}
}
@@ -1157,7 +1158,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
// and store the key data into our records.
else {
const QString text = uch.isNull() ? QString() : QString(uch);
- const char a = uch.row() ? 0 : uch.cell();
+ const char a = uch.row() ? char(0) : char(uch.cell());
const Qt::KeyboardModifiers modifiers(state);
#ifndef QT_NO_SHORTCUT
// Is Qt interested in the context menu key?
@@ -1166,9 +1167,9 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
return false;
}
#endif // !QT_NO_SHORTCUT
- key_recorder.storeKey(msg.wParam, a, state, text);
+ key_recorder.storeKey(int(msg.wParam), a, state, text);
QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyPress, code,
- modifiers, scancode, msg.wParam, nModifiers, text, false);
+ modifiers, scancode, quint32(msg.wParam), nModifiers, text, false);
result =true;
bool store = true;
#ifndef Q_OS_WINCE
@@ -1187,7 +1188,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
}
#endif // !Q_OS_WINCE
if (!store)
- key_recorder.findKey(msg.wParam, true);
+ key_recorder.findKey(int(msg.wParam), true);
}
}
@@ -1197,7 +1198,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
// The key may not be in our records if, for example, the down event was handled by
// win32 natively, or our window gets focus while a key is already press, but now gets
// the key release event.
- KeyRecord* rec = key_recorder.findKey(msg.wParam, true);
+ const KeyRecord *rec = key_recorder.findKey(int(msg.wParam), true);
if (!rec && !(code == Qt::Key_Shift
|| code == Qt::Key_Control
|| code == Qt::Key_Meta
@@ -1205,13 +1206,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
// Someone ate the key down event
} else {
if (!code)
- code = asciiToKeycode(rec->ascii ? rec->ascii : msg.wParam, state);
+ code = asciiToKeycode(rec->ascii ? char(rec->ascii) : char(msg.wParam), state);
// Map SHIFT + Tab to SHIFT + BackTab, QShortcutMap knows about this translation
if (code == Qt::Key_Tab && (state & Qt::ShiftModifier) == Qt::ShiftModifier)
code = Qt::Key_Backtab;
QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyRelease, code,
- Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers,
+ Qt::KeyboardModifier(state), scancode, quint32(msg.wParam),
+ nModifiers,
(rec ? rec->text : QString()), false);
result = true;
#ifndef Q_OS_WINCE
diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp
index 61c867cf07..cb112446fc 100644
--- a/src/plugins/platforms/windows/qwindowsmime.cpp
+++ b/src/plugins/platforms/windows/qwindowsmime.cpp
@@ -156,7 +156,7 @@ static bool qt_write_dibv5(QDataStream &s, QImage image)
bi.bV5Planes = 1;
bi.bV5BitCount = 32;
bi.bV5Compression = BI_BITFIELDS;
- bi.bV5SizeImage = bpl_bmp*image.height();
+ bi.bV5SizeImage = DWORD(bpl_bmp * image.height());
bi.bV5XPelsPerMeter = 0;
bi.bV5YPelsPerMeter = 0;
bi.bV5ClrUsed = 0;
@@ -176,30 +176,29 @@ static bool qt_write_dibv5(QDataStream &s, QImage image)
image = image.convertToFormat(QImage::Format_ARGB32);
uchar *buf = new uchar[bpl_bmp];
- uchar *b;
- memset(buf, 0, bpl_bmp);
+ memset(buf, 0, size_t(bpl_bmp));
for (int y=image.height()-1; y>=0; y--) {
// write the image bits
- QRgb *p = (QRgb *)image.scanLine(y);
- QRgb *end = p + image.width();
- b = buf;
+ const QRgb *p = reinterpret_cast<const QRgb *>(image.constScanLine(y));
+ const QRgb *end = p + image.width();
+ uchar *b = buf;
while (p < end) {
int alpha = qAlpha(*p);
if (alpha) {
- *b++ = qBlue(*p);
- *b++ = qGreen(*p);
- *b++ = qRed(*p);
+ *b++ = uchar(qBlue(*p));
+ *b++ = uchar(qGreen(*p));
+ *b++ = uchar(qRed(*p));
} else {
//white for fully transparent pixels.
*b++ = 0xff;
*b++ = 0xff;
*b++ = 0xff;
}
- *b++ = alpha;
+ *b++ = uchar(alpha);
p++;
}
- d->write((char*)buf, bpl_bmp);
+ d->write(reinterpret_cast<const char *>(buf), bpl_bmp);
if (s.status() != QDataStream::Ok) {
delete[] buf;
return false;
@@ -227,25 +226,22 @@ static bool qt_read_dibv5(QDataStream &s, QImage &image)
if (d->atEnd())
return false;
- d->read((char *)&bi, sizeof(bi)); // read BITMAPV5HEADER header
+ d->read(reinterpret_cast<char *>(&bi), sizeof(bi)); // read BITMAPV5HEADER header
if (s.status() != QDataStream::Ok)
return false;
- int nbits = bi.bV5BitCount;
- int comp = bi.bV5Compression;
- if (nbits != 32 || bi.bV5Planes != 1 || comp != BMP_BITFIELDS)
+ const int nbits = bi.bV5BitCount;
+ if (nbits != 32 || bi.bV5Planes != 1 || bi.bV5Compression != BMP_BITFIELDS)
return false; //Unsupported DIBV5 format
- int w = bi.bV5Width, h = bi.bV5Height;
- int red_mask = bi.bV5RedMask;
- int green_mask = bi.bV5GreenMask;
- int blue_mask = bi.bV5BlueMask;
- int alpha_mask = bi.bV5AlphaMask;
- int red_shift = 0;
- int green_shift = 0;
- int blue_shift = 0;
- int alpha_shift = 0;
- QImage::Format format = QImage::Format_ARGB32;
+ const int w = bi.bV5Width;
+ int h = bi.bV5Height;
+ const int red_mask = int(bi.bV5RedMask);
+ const int green_mask = int(bi.bV5GreenMask);
+ const int blue_mask = int(bi.bV5BlueMask);
+ const int alpha_mask = int(bi.bV5AlphaMask);
+
+ const QImage::Format format = QImage::Format_ARGB32;
if (bi.bV5Height < 0)
h = -h; // support images with negative height
@@ -257,30 +253,25 @@ static bool qt_read_dibv5(QDataStream &s, QImage &image)
image.setDotsPerMeterX(bi.bV5XPelsPerMeter);
image.setDotsPerMeterY(bi.bV5YPelsPerMeter);
- red_shift = calc_shift(red_mask);
- green_shift = calc_shift(green_mask);
- blue_shift = calc_shift(blue_mask);
- if (alpha_mask) {
- alpha_shift = calc_shift(alpha_mask);
- }
+ const int red_shift = calc_shift(red_mask);
+ const int green_shift = calc_shift(green_mask);
+ const int blue_shift = calc_shift(blue_mask);
+ const int alpha_shift = alpha_mask ? calc_shift(alpha_mask) : 0u;
- int bpl = image.bytesPerLine();
+ const int bpl = image.bytesPerLine();
uchar *data = image.bits();
- QRgb *p;
- QRgb *end;
+
uchar *buf24 = new uchar[bpl];
- int bpl24 = ((w*nbits+31)/32)*4;
- uchar *b;
- unsigned int c;
+ const int bpl24 = ((w * nbits + 31) / 32) * 4;
while (--h >= 0) {
- p = (QRgb *)(data + h*bpl);
- end = p + w;
- if (d->read((char *)buf24,bpl24) != bpl24)
+ QRgb *p = reinterpret_cast<QRgb *>(data + h * bpl);
+ QRgb *end = p + w;
+ if (d->read(reinterpret_cast<char *>(buf24), bpl24) != bpl24)
break;
- b = buf24;
+ const uchar *b = buf24;
while (p < end) {
- c = *b | (*(b+1))<<8 | (*(b+2))<<16 | (*(b+3))<<24;
+ const int c = *b | (*(b + 1)) << 8 | (*(b + 2)) << 16 | (*(b + 3)) << 24;
*p++ = qRgba(((c & red_mask) >> red_shift) ,
((c & green_mask) >> green_shift),
((c & blue_mask) >> blue_shift),
@@ -295,9 +286,9 @@ static bool qt_read_dibv5(QDataStream &s, QImage &image)
uchar *buf = new uchar[bpl];
h = -bi.bV5Height;
for (int y = 0; y < h/2; ++y) {
- memcpy(buf, data + y*bpl, bpl);
- memcpy(data + y*bpl, data + (h-y-1)*bpl, bpl);
- memcpy(data + (h-y-1)*bpl, buf, bpl);
+ memcpy(buf, data + y * bpl, size_t(bpl));
+ memcpy(data + y*bpl, data + (h - y -1) * bpl, size_t(bpl));
+ memcpy(data + (h - y -1 ) * bpl, buf, size_t(bpl));
}
delete [] buf;
}
@@ -315,7 +306,7 @@ static int getCf(const FORMATETC &formatetc)
static FORMATETC setCf(int cf)
{
FORMATETC formatetc;
- formatetc.cfFormat = cf;
+ formatetc.cfFormat = CLIPFORMAT(cf);
formatetc.dwAspect = DVASPECT_CONTENT;
formatetc.lindex = -1;
formatetc.ptd = NULL;
@@ -325,12 +316,12 @@ static FORMATETC setCf(int cf)
static bool setData(const QByteArray &data, STGMEDIUM *pmedium)
{
- HGLOBAL hData = GlobalAlloc(0, data.size());
+ HGLOBAL hData = GlobalAlloc(0, SIZE_T(data.size()));
if (!hData)
return false;
void *out = GlobalLock(hData);
- memcpy(out, data.data(), data.size());
+ memcpy(out, data.data(), size_t(data.size()));
GlobalUnlock(hData);
pmedium->tymed = TYMED_HGLOBAL;
pmedium->hGlobal = hData;
@@ -345,8 +336,8 @@ static QByteArray getData(int cf, IDataObject *pDataObj, int lindex = -1)
formatetc.lindex = lindex;
STGMEDIUM s;
if (pDataObj->GetData(&formatetc, &s) == S_OK) {
- DWORD * val = (DWORD*)GlobalLock(s.hGlobal);
- data = QByteArray::fromRawData((char*)val, GlobalSize(s.hGlobal));
+ const void *val = GlobalLock(s.hGlobal);
+ data = QByteArray::fromRawData(reinterpret_cast<const char *>(val), int(GlobalSize(s.hGlobal)));
data.detach();
GlobalUnlock(s.hGlobal);
ReleaseStgMedium(&s);
@@ -362,7 +353,7 @@ static QByteArray getData(int cf, IDataObject *pDataObj, int lindex = -1)
while(SUCCEEDED(hr)){
hr = s.pstm->Read(szBuffer, sizeof(szBuffer), &actualRead);
if (SUCCEEDED(hr) && actualRead > 0) {
- data += QByteArray::fromRawData(szBuffer, actualRead);
+ data += QByteArray::fromRawData(szBuffer, int(actualRead));
}
if (actualRead != sizeof(szBuffer))
break;
@@ -514,11 +505,11 @@ QWindowsMime::~QWindowsMime()
*/
int QWindowsMime::registerMimeType(const QString &mime)
{
- int f = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (mime.utf16()));
+ const UINT f = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (mime.utf16()));
if (!f)
qErrnoWarning("QWindowsMime::registerMimeType: Failed to register clipboard format");
- return f;
+ return int(f);
}
/*!
@@ -661,9 +652,9 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa
++u;
}
res.truncate(ri);
- const int byteLength = res.length() * sizeof(ushort);
+ const int byteLength = res.length() * int(sizeof(ushort));
QByteArray r(byteLength + 2, '\0');
- memcpy(r.data(), res.unicode(), byteLength);
+ memcpy(r.data(), res.unicode(), size_t(byteLength));
r[byteLength] = 0;
r[byteLength+1] = 0;
return setData(r, pmedium);
@@ -706,17 +697,17 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData
QString str;
QByteArray data = getData(CF_UNICODETEXT, pDataObj);
if (!data.isEmpty()) {
- str = QString::fromWCharArray((const wchar_t *)data.data());
+ str = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData()));
str.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
} else {
data = getData(CF_TEXT, pDataObj);
if (!data.isEmpty()) {
const char* d = data.data();
- const int s = qstrlen(d);
+ const unsigned s = qstrlen(d);
QByteArray r(data.size()+1, '\0');
char* o = r.data();
int j=0;
- for (int i=0; i<s; i++) {
+ for (unsigned i = 0; i < s; ++i) {
char c = d[i];
if (c!='\r')
o[j++]=c;
@@ -777,22 +768,22 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
for (int i=0; i<urls.size(); i++) {
QString fn = QDir::toNativeSeparators(urls.at(i).toLocalFile());
if (!fn.isEmpty()) {
- size += sizeof(ushort) * (fn.length() + 1);
+ size += sizeof(ushort) * size_t(fn.length() + 1);
fileNames.append(fn);
}
}
QByteArray result(size, '\0');
- DROPFILES* d = (DROPFILES*)result.data();
+ DROPFILES* d = reinterpret_cast<DROPFILES *>(result.data());
d->pFiles = sizeof(DROPFILES);
GetCursorPos(&d->pt); // try
d->fNC = true;
- char* files = ((char*)d) + d->pFiles;
+ char *files = (reinterpret_cast<char*>(d)) + d->pFiles;
d->fWide = true;
- wchar_t* f = (wchar_t*)files;
+ wchar_t *f = reinterpret_cast<wchar_t *>(files);
for (int i=0; i<fileNames.size(); i++) {
- int l = fileNames.at(i).length();
+ const size_t l = size_t(fileNames.at(i).length());
memcpy(f, fileNames.at(i).utf16(), l * sizeof(ushort));
f += l;
*f++ = 0;
@@ -805,7 +796,8 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
QByteArray result;
if (!urls.isEmpty()) {
QString url = urls.at(0).toString();
- result = QByteArray((const char *)url.utf16(), url.length() * sizeof(ushort));
+ result = QByteArray(reinterpret_cast<const char *>(url.utf16()),
+ url.length() * int(sizeof(ushort)));
}
result.append('\0');
result.append('\0');
@@ -860,9 +852,9 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD
if (data.isEmpty())
return QVariant();
- LPDROPFILES hdrop = (LPDROPFILES)data.data();
+ const DROPFILES *hdrop = reinterpret_cast<const DROPFILES *>(data.constData());
if (hdrop->fWide) {
- const wchar_t* filesw = (const wchar_t *)(data.data() + hdrop->pFiles);
+ const wchar_t *filesw = reinterpret_cast<const wchar_t *>(data.constData() + hdrop->pFiles);
int i = 0;
while (filesw[i]) {
QString fileurl = QString::fromWCharArray(filesw + i);
@@ -870,7 +862,7 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD
i += fileurl.length()+1;
}
} else {
- const char* files = (const char *)data.data() + hdrop->pFiles;
+ const char* files = reinterpret_cast<const char *>(data.constData() + hdrop->pFiles);
int i=0;
while (files[i]) {
urls += QUrl::fromLocalFile(QString::fromLocal8Bit(files+i));
@@ -886,7 +878,7 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD
QByteArray data = getData(CF_INETURL_W, pDataObj);
if (data.isEmpty())
return QVariant();
- return QUrl(QString::fromWCharArray((const wchar_t *)data.constData()));
+ return QUrl(QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData())));
} else if (canGetData(CF_INETURL, pDataObj)) {
QByteArray data = getData(CF_INETURL, pDataObj);
if (data.isEmpty())
@@ -1014,14 +1006,14 @@ bool QWindowsMimeHtml::convertFromMime(const FORMATETC &formatetc, const QMimeDa
result += "<!--EndFragment-->";
// set the correct number for EndHTML
- QByteArray pos = QString::number(result.size()).toLatin1();
- memcpy((char *)(result.data() + 53 - pos.length()), pos.constData(), pos.length());
+ QByteArray pos = QByteArray::number(result.size());
+ memcpy(reinterpret_cast<char *>(result.data() + 53 - pos.length()), pos.constData(), size_t(pos.length()));
// set correct numbers for StartFragment and EndFragment
- pos = QString::number(result.indexOf("<!--StartFragment-->") + 20).toLatin1();
- memcpy((char *)(result.data() + 79 - pos.length()), pos.constData(), pos.length());
- pos = QString::number(result.indexOf("<!--EndFragment-->")).toLatin1();
- memcpy((char *)(result.data() + 103 - pos.length()), pos.constData(), pos.length());
+ pos = QByteArray::number(result.indexOf("<!--StartFragment-->") + 20);
+ memcpy(reinterpret_cast<char *>(result.data() + 79 - pos.length()), pos.constData(), size_t(pos.length()));
+ pos = QByteArray::number(result.indexOf("<!--EndFragment-->"));
+ memcpy(reinterpret_cast<char *>(result.data() + 103 - pos.length()), pos.constData(), size_t(pos.length()));
return setData(result, pmedium);
}
@@ -1249,9 +1241,9 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData
++u;
}
res.truncate(ri);
- const int byteLength = res.length() * sizeof(ushort);
+ const int byteLength = res.length() * int(sizeof(ushort));
QByteArray r(byteLength + 2, '\0');
- memcpy(r.data(), res.unicode(), byteLength);
+ memcpy(r.data(), res.unicode(), size_t(byteLength));
r[byteLength] = 0;
r[byteLength+1] = 0;
data = r;
@@ -1288,7 +1280,7 @@ QVariant QBuiltInMimes::convertToMime(const QString &mimeType, IDataObject *pDat
qCDebug(lcQpaMime) << __FUNCTION__;
if (mimeType == QLatin1String("text/html") && preferredType == QVariant::String) {
// text/html is in wide chars on windows (compatible with Mozilla)
- val = QString::fromWCharArray((const wchar_t *)data.data());
+ val = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData()));
} else {
val = data; // it should be enough to return the data and let QMimeData do the rest.
}
@@ -1428,8 +1420,8 @@ bool QLastResortMimes::canConvertToMime(const QString &mimeType, IDataObject *pD
if (isCustomMimeType(mimeType)) {
// MSDN documentation for QueryGetData says only -1 is supported, so ignore lindex here.
QString clipFormat = customMimeType(mimeType);
- int cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
- return canGetData(cf, pDataObj);
+ const UINT cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
+ return canGetData(int(cf), pDataObj);
} else if (formats.keys(mimeType).isEmpty()) {
// if it is not in there then register it and see if we can get it
int cf = QWindowsMime::registerMimeType(mimeType);
@@ -1449,8 +1441,8 @@ QVariant QLastResortMimes::convertToMime(const QString &mimeType, IDataObject *p
if (isCustomMimeType(mimeType)) {
int lindex;
QString clipFormat = customMimeType(mimeType, &lindex);
- int cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
- data = getData(cf, pDataObj, lindex);
+ const UINT cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
+ data = getData(int(cf), pDataObj, lindex);
} else if (formats.keys(mimeType).isEmpty()) {
int cf = QWindowsMime::registerMimeType(mimeType);
data = getData(cf, pDataObj);
@@ -1599,7 +1591,7 @@ void QWindowsMimeConverter::ensureInitialized() const
QString QWindowsMimeConverter::clipboardFormatName(int cf)
{
wchar_t buf[256] = {0};
- return GetClipboardFormatName(cf, buf, 255)
+ return GetClipboardFormatName(UINT(cf), buf, 255)
? QString::fromWCharArray(buf) : QString();
}
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index c8b18f3b57..5ae5ae3129 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -210,7 +210,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
// Check for events synthesized from touch. Lower 7 bits are touch/pen index, bit 8 indicates touch.
// However, when tablet support is active, extraInfo is a packet serial number. This is not a problem
// since we do not want to ignore mouse events coming from a tablet.
- const quint64 extraInfo = GetMessageExtraInfo();
+ const quint64 extraInfo = quint64(GetMessageExtraInfo());
if ((extraInfo & signatureMask) == miWpSignature) {
if (extraInfo & 0x80) { // Bit 7 indicates touch event, else tablet pen.
source = Qt::MouseEventSynthesizedBySystem;
@@ -250,7 +250,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
}
QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window->handle());
- const Qt::MouseButtons buttons = keyStateToMouseButtons((int)msg.wParam);
+ const Qt::MouseButtons buttons = keyStateToMouseButtons(int(msg.wParam));
// If the window was recently resized via mouse doubleclick on the frame or title bar,
// we don't get WM_LBUTTONDOWN or WM_LBUTTONDBLCLK for the second click,
@@ -426,13 +426,13 @@ static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int del
bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND,
MSG msg, LRESULT *)
{
- const Qt::KeyboardModifiers mods = keyStateToModifiers((int)msg.wParam);
+ const Qt::KeyboardModifiers mods = keyStateToModifiers(int(msg.wParam));
int delta;
if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL)
- delta = (short) HIWORD (msg.wParam);
+ delta = HIWORD (msg.wParam);
else
- delta = (int) msg.wParam;
+ delta = int(msg.wParam);
Qt::Orientation orientation = (msg.message == WM_MOUSEHWHEEL
|| (mods & Qt::AltModifier)) ?
@@ -503,15 +503,17 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
return true;
const QRect screenGeometry = screen->geometry();
- const int winTouchPointCount = msg.wParam;
+ const int winTouchPointCount = int(msg.wParam);
QScopedArrayPointer<TOUCHINPUT> winTouchInputs(new TOUCHINPUT[winTouchPointCount]);
- memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * winTouchPointCount);
+ memset(winTouchInputs.data(), 0, sizeof(TOUCHINPUT) * size_t(winTouchPointCount));
QTouchPointList touchPoints;
touchPoints.reserve(winTouchPointCount);
Qt::TouchPointStates allStates = 0;
- QWindowsContext::user32dll.getTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT));
+ QWindowsContext::user32dll.getTouchInputInfo(reinterpret_cast<HANDLE>(msg.lParam),
+ UINT(msg.wParam),
+ winTouchInputs.data(), sizeof(TOUCHINPUT));
for (int i = 0; i < winTouchPointCount; ++i) {
const TOUCHINPUT &winTouchInput = winTouchInputs[i];
int id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1);
@@ -552,7 +554,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
touchPoints.append(touchPoint);
}
- QWindowsContext::user32dll.closeTouchInputHandle((HANDLE) msg.lParam);
+ QWindowsContext::user32dll.closeTouchInputHandle(reinterpret_cast<HANDLE>(msg.lParam));
// all touch points released, forget the ids we've seen, they may not be reused
if (allStates == Qt::TouchPointReleased)
diff --git a/src/plugins/platforms/windows/qwindowsnativeimage.cpp b/src/plugins/platforms/windows/qwindowsnativeimage.cpp
index 72e3268405..bc8bfda32b 100644
--- a/src/plugins/platforms/windows/qwindowsnativeimage.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeimage.cpp
@@ -99,13 +99,13 @@ static inline HBITMAP createDIB(HDC hdc, int width, int height,
bmi.blueMask = 0;
}
- void *bits = 0;
+ uchar *bits = Q_NULLPTR;
HBITMAP bitmap = CreateDIBSection(hdc, reinterpret_cast<BITMAPINFO *>(&bmi),
- DIB_RGB_COLORS, &bits, 0, 0);
+ DIB_RGB_COLORS, reinterpret_cast<void **>(&bits), 0, 0);
if (Q_UNLIKELY(!bitmap || !bits))
qFatal("%s: CreateDIBSection failed.", __FUNCTION__);
- *bitsIn = (uchar*)bits;
+ *bitsIn = bits;
return bitmap;
}
@@ -118,7 +118,7 @@ QWindowsNativeImage::QWindowsNativeImage(int width, int height,
if (width != 0 && height != 0) {
uchar *bits;
m_bitmap = createDIB(m_hdc, width, height, format, &bits);
- m_null_bitmap = (HBITMAP)SelectObject(m_hdc, m_bitmap);
+ m_null_bitmap = static_cast<HBITMAP>(SelectObject(m_hdc, m_bitmap));
m_image = QImage(bits, width, height, format);
Q_ASSERT(m_image.paintEngine()->type() == QPaintEngine::Raster);
static_cast<QRasterPaintEngine *>(m_image.paintEngine())->setDC(m_hdc);
diff --git a/src/plugins/platforms/windows/qwindowsole.cpp b/src/plugins/platforms/windows/qwindowsole.cpp
index 43325d5235..a1a8c0b499 100644
--- a/src/plugins/platforms/windows/qwindowsole.cpp
+++ b/src/plugins/platforms/windows/qwindowsole.cpp
@@ -221,7 +221,7 @@ QWindowsOleDataObject::EnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC FAR* ppe
fmtetcs = mc.allFormatsForMime(data);
} else {
FORMATETC formatetc;
- formatetc.cfFormat = CF_PERFORMEDDROPEFFECT;
+ formatetc.cfFormat = CLIPFORMAT(CF_PERFORMEDDROPEFFECT);
formatetc.dwAspect = DVASPECT_CONTENT;
formatetc.lindex = -1;
formatetc.ptd = NULL;
@@ -275,7 +275,7 @@ QWindowsOleEnumFmtEtc::QWindowsOleEnumFmtEtc(const QVector<FORMATETC> &fmtetcs)
m_lpfmtetcs.reserve(fmtetcs.count());
for (int idx = 0; idx < fmtetcs.count(); ++idx) {
LPFORMATETC destetc = new FORMATETC();
- if (copyFormatEtc(destetc, (LPFORMATETC)&(fmtetcs.at(idx)))) {
+ if (copyFormatEtc(destetc, &(fmtetcs.at(idx)))) {
m_lpfmtetcs.append(destetc);
} else {
m_isNull = true;
@@ -369,14 +369,14 @@ QWindowsOleEnumFmtEtc::Next(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetch
nOffset = m_nIndex + i;
if (nOffset < ULONG(m_lpfmtetcs.count())) {
- copyFormatEtc((LPFORMATETC)&(rgelt[i]), m_lpfmtetcs.at(nOffset));
+ copyFormatEtc(rgelt + i, m_lpfmtetcs.at(int(nOffset)));
i++;
} else {
break;
}
}
- m_nIndex += (WORD)i;
+ m_nIndex += i;
if (pceltFetched != NULL)
*pceltFetched = i;
@@ -403,7 +403,7 @@ QWindowsOleEnumFmtEtc::Skip(ULONG celt)
}
}
- m_nIndex += (WORD)i;
+ m_nIndex += i;
if (i != celt)
return ResultFromScode(S_FALSE);
@@ -437,7 +437,7 @@ QWindowsOleEnumFmtEtc::Clone(LPENUMFORMATETC FAR* newEnum)
return NOERROR;
}
-bool QWindowsOleEnumFmtEtc::copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const
+bool QWindowsOleEnumFmtEtc::copyFormatEtc(LPFORMATETC dest, const FORMATETC *src) const
{
if (dest == NULL || src == NULL)
return false;
diff --git a/src/plugins/platforms/windows/qwindowsole.h b/src/plugins/platforms/windows/qwindowsole.h
index 027a749759..009111e55c 100644
--- a/src/plugins/platforms/windows/qwindowsole.h
+++ b/src/plugins/platforms/windows/qwindowsole.h
@@ -109,7 +109,7 @@ public:
STDMETHOD(Clone)(LPENUMFORMATETC FAR* newEnum);
private:
- bool copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const;
+ bool copyFormatEtc(LPFORMATETC dest, const FORMATETC *src) const;
ULONG m_dwRefs;
ULONG m_nIndex;
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp
index b0856a7441..4ca7f0e413 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
+++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
@@ -81,10 +81,10 @@ GpuDescription GpuDescription::detect()
const HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier);
direct3D9->Release();
if (SUCCEEDED(hr)) {
- result.vendorId = int(adapterIdentifier.VendorId);
- result.deviceId = int(adapterIdentifier.DeviceId);
- result.revision = int(adapterIdentifier.Revision);
- result.subSysId = int(adapterIdentifier.SubSysId);
+ result.vendorId = adapterIdentifier.VendorId;
+ result.deviceId = adapterIdentifier.DeviceId;
+ result.revision = adapterIdentifier.Revision;
+ result.subSysId = adapterIdentifier.SubSysId;
QVector<int> version(4, 0);
version[0] = HIWORD(adapterIdentifier.DriverVersion.HighPart); // Product
version[1] = LOWORD(adapterIdentifier.DriverVersion.HighPart); // Version
@@ -335,10 +335,10 @@ bool QWindowsOpenGLTester::testDesktopGL()
WNDCLASS wclass;
wclass.cbClsExtra = 0;
wclass.cbWndExtra = 0;
- wclass.hInstance = (HINSTANCE) GetModuleHandle(0);
+ wclass.hInstance = static_cast<HINSTANCE>(GetModuleHandle(0));
wclass.hIcon = 0;
wclass.hCursor = 0;
- wclass.hbrBackground = (HBRUSH) (COLOR_BACKGROUND);
+ wclass.hbrBackground = HBRUSH(COLOR_BACKGROUND);
wclass.lpszMenuName = 0;
wclass.lpfnWndProc = DefWindowProc;
wclass.lpszClassName = className;
@@ -377,8 +377,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
typedef const GLubyte * (APIENTRY * GetString_t)(GLenum name);
GetString_t GetString = reinterpret_cast<GetString_t>(::GetProcAddress(lib, "glGetString"));
if (GetString) {
- const char *versionStr = (const char *) GetString(GL_VERSION);
- if (versionStr) {
+ if (const char *versionStr = reinterpret_cast<const char *>(GetString(GL_VERSION))) {
const QByteArray version(versionStr);
const int majorDot = version.indexOf('.');
if (majorDot != -1) {
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.h b/src/plugins/platforms/windows/qwindowsopengltester.h
index 482a1df3d8..39e20b55d1 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.h
+++ b/src/plugins/platforms/windows/qwindowsopengltester.h
@@ -57,10 +57,10 @@ struct GpuDescription
QString toString() const;
QVariant toVariant() const;
- int vendorId;
- int deviceId;
- int revision;
- int subSysId;
+ uint vendorId;
+ uint deviceId;
+ uint revision;
+ uint subSysId;
QVersionNumber driverVersion;
QByteArray driverName;
QByteArray description;
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index 84428c2b1f..b476c9be1d 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -158,7 +158,7 @@ BOOL QT_WIN_CALLBACK monitorEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM
static inline WindowsScreenDataList monitorData()
{
WindowsScreenDataList result;
- EnumDisplayMonitors(0, 0, monitorEnumCallback, (LPARAM)&result);
+ EnumDisplayMonitors(0, 0, monitorEnumCallback, reinterpret_cast<LPARAM>(&result));
return result;
}
@@ -206,7 +206,7 @@ Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat =
QPixmap QWindowsScreen::grabWindow(WId window, int x, int y, int width, int height) const
{
RECT r;
- HWND hwnd = window ? (HWND)window : GetDesktopWindow();
+ HWND hwnd = window ? reinterpret_cast<HWND>(window) : GetDesktopWindow();
GetClientRect(hwnd, &r);
if (width < 0) width = r.right - r.left;
@@ -440,7 +440,7 @@ QWindowsScreenManager::QWindowsScreenManager() :
bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam)
{
- const int newDepth = (int)wParam;
+ const int newDepth = int(wParam);
const WORD newHorizontalResolution = LOWORD(lParam);
const WORD newVerticalResolution = HIWORD(lParam);
if (newDepth != m_lastDepth || newHorizontalResolution != m_lastHorizontalResolution
diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp
index 2382be4e3c..3c99e3507e 100644
--- a/src/plugins/platforms/windows/qwindowsservices.cpp
+++ b/src/plugins/platforms/windows/qwindowsservices.cpp
@@ -59,7 +59,10 @@ static inline bool shellExecute(const QUrl &url)
#ifndef Q_OS_WINCE
const QString nativeFilePath =
url.isLocalFile() ? QDir::toNativeSeparators(url.toLocalFile()) : url.toString(QUrl::FullyEncoded);
- const quintptr result = (quintptr)ShellExecute(0, 0, (wchar_t*)nativeFilePath.utf16(), 0, 0, SW_SHOWNORMAL);
+ const quintptr result =
+ reinterpret_cast<quintptr>(ShellExecute(0, 0,
+ reinterpret_cast<const wchar_t *>(nativeFilePath.utf16()),
+ 0, 0, SW_SHOWNORMAL));
// ShellExecute returns a value greater than 32 if successful
if (result <= 32) {
qWarning("ShellExecute '%s' failed (error %s).", qPrintable(url.toString()), qPrintable(QString::number(result)));
@@ -97,7 +100,7 @@ static inline QString mailCommand()
if (debug)
qDebug() << __FUNCTION__ << "keyName=" << keyName;
command[0] = 0;
- if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, (const wchar_t*)keyName.utf16(), 0, KEY_READ, &handle)) {
+ if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, reinterpret_cast<const wchar_t*>(keyName.utf16()), 0, KEY_READ, &handle)) {
DWORD bufferSize = BufferSize;
RegQueryValueEx(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(command), &bufferSize);
RegCloseKey(handle);
@@ -140,7 +143,8 @@ static inline bool launchMail(const QUrl &url)
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
- if (!CreateProcess(NULL, (wchar_t*)command.utf16(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
+ if (!CreateProcess(NULL, reinterpret_cast<wchar_t *>(const_cast<ushort *>(command.utf16())),
+ NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
qErrnoWarning("Unable to launch '%s'", qPrintable(command));
return false;
}
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
index 165154345d..8db6895999 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -322,7 +322,7 @@ QDebug operator<<(QDebug d, const QWindowsTabletDeviceData &t)
}
#endif // !QT_NO_DEBUG_STREAM
-QWindowsTabletDeviceData QWindowsTabletSupport::tabletInit(const quint64 uniqueId, const UINT cursorType) const
+QWindowsTabletDeviceData QWindowsTabletSupport::tabletInit(qint64 uniqueId, UINT cursorType) const
{
QWindowsTabletDeviceData result;
result.uniqueId = uniqueId;
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.h b/src/plugins/platforms/windows/qwindowstabletsupport.h
index b0720639e0..4a24d62770 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.h
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.h
@@ -129,7 +129,7 @@ public:
private:
unsigned options() const;
- QWindowsTabletDeviceData tabletInit(const quint64 uniqueId, const UINT cursorType) const;
+ QWindowsTabletDeviceData tabletInit(qint64 uniqueId, UINT cursorType) const;
static QWindowsWinTab32DLL m_winTab32DLL;
const HWND m_window;
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index 5c283a3113..a7f00d5f6d 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -462,7 +462,9 @@ static QPixmap loadIconFromShell32(int resourceId, QSizeF size)
HMODULE hmod = QSystemLibrary::load(L"shell32");
#endif
if (hmod) {
- HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size.width(), size.height(), 0);
+ HICON iconHandle =
+ static_cast<HICON>(LoadImage(hmod, MAKEINTRESOURCE(resourceId),
+ IMAGE_ICON, int(size.width()), int(size.height()), 0));
if (iconHandle) {
QPixmap iconpixmap = qt_pixmapFromWinHICON(iconHandle);
DestroyIcon(iconHandle);
@@ -592,7 +594,7 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) con
if (sp == FileLinkIcon || sp == DirLinkIcon || sp == DirLinkOpenIcon) {
QPainter painter(&pixmap);
QPixmap link = loadIconFromShell32(30, pixmapSize);
- painter.drawPixmap(0, 0, pixmapSize.width(), pixmapSize.height(), link);
+ painter.drawPixmap(0, 0, int(pixmapSize.width()), int(pixmapSize.height()), link);
}
pixmap.setDevicePixelRatio(scaleFactor);
return pixmap;
@@ -667,7 +669,8 @@ static QPixmap pixmapFromShellImageList(int iImageList, const SHFILEINFO &info)
return result;
IImageList *imageList = 0;
- HRESULT hr = QWindowsContext::shell32dll.sHGetImageList(iImageList, iID_IImageList, (void **)&imageList);
+ HRESULT hr = QWindowsContext::shell32dll.sHGetImageList(iImageList, iID_IImageList,
+ reinterpret_cast<void **>(&imageList));
if (hr != S_OK)
return result;
HICON hIcon;
@@ -699,7 +702,7 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
QPixmap pixmap;
const QString filePath = QDir::toNativeSeparators(fileInfo.filePath());
- const int width = size.width();
+ const int width = int(size.width());
const int iconSize = width > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON;
const int requestedImageListSize =
#ifdef USE_IIMAGELIST
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 464fcc886f..4c503a2c48 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -189,7 +189,7 @@ static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
return QPoint(0, 0);
const QWindowsScreenManager &screenManager = QWindowsContext::instance()->screenManager();
const QWindowsScreen *screen = screenManager.screens().size() == 1
- ? screenManager.screens().first() : screenManager.screenAtDp(point);
+ ? screenManager.screens().constFirst() : screenManager.screenAtDp(point);
if (screen)
return screen->availableGeometry().topLeft() - screen->geometry().topLeft();
#else
@@ -1585,7 +1585,9 @@ void QWindowsWindow::handleGeometryChange()
// QTBUG-32121: OpenGL/normal windows (with exception of ANGLE) do not receive
// expose events when shrinking, synthesize.
if (!testFlag(OpenGL_ES2) && isExposed()
- && !(m_data.geometry.width() >= previousGeometry.width() || m_data.geometry.height() >= previousGeometry.height())) {
+ && m_data.geometry.size() != previousGeometry.size() // Exclude plain move
+ // One dimension grew -> Windows will send expose, no need to synthesize.
+ && !(m_data.geometry.width() > previousGeometry.width() || m_data.geometry.height() > previousGeometry.height())) {
fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true);
}
if (previousGeometry.topLeft() != m_data.geometry.topLeft()) {
@@ -2005,7 +2007,7 @@ QMargins QWindowsWindow::frameMargins() const
// Always skip calculating style-dependent margins for windows claimed to be frameless.
// This allows users to remove the margins by handling WM_NCCALCSIZE with WS_THICKFRAME set
// to ensure Areo snap still works (QTBUG-40578).
- m_data.frame = window()->flags() & Qt::FramelessWindowHint
+ m_data.frame = m_data.flags & Qt::FramelessWindowHint
? QMargins(0, 0, 0, 0)
: QWindowsGeometryHint::frame(style(), exStyle());
clearFlag(FrameDirty);
diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri
index 67af5c03ef..766168ccb8 100644
--- a/src/plugins/platforms/windows/windows.pri
+++ b/src/plugins/platforms/windows/windows.pri
@@ -55,7 +55,6 @@ HEADERS += \
$$PWD/qwindowsmime.h \
$$PWD/qwindowsinternalmimedata.h \
$$PWD/qwindowscursor.h \
- $$PWD/array.h \
$$PWD/qwindowsinputcontext.h \
$$PWD/qwindowstheme.h \
$$PWD/qwindowsdialoghelpers.h \
diff --git a/src/plugins/platforms/winrt/qwinrtbackingstore.cpp b/src/plugins/platforms/winrt/qwinrtbackingstore.cpp
index 4517200a2d..fc7ab15f73 100644
--- a/src/plugins/platforms/winrt/qwinrtbackingstore.cpp
+++ b/src/plugins/platforms/winrt/qwinrtbackingstore.cpp
@@ -47,6 +47,9 @@
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcQpaBackingStore, "qt.qpa.backingstore")
+Q_LOGGING_CATEGORY(lcQpaBackingStoreVerbose, "qt.qpa.backingstore.verbose")
+
class QWinRTBackingStorePrivate
{
public:
@@ -62,6 +65,7 @@ QWinRTBackingStore::QWinRTBackingStore(QWindow *window)
: QPlatformBackingStore(window), d_ptr(new QWinRTBackingStorePrivate)
{
Q_D(QWinRTBackingStore);
+ qCDebug(lcQpaBackingStore) << __FUNCTION__ << this << window;
d->initialized = false;
d->screen = static_cast<QWinRTScreen*>(window->screen()->handle());
@@ -73,6 +77,7 @@ QWinRTBackingStore::QWinRTBackingStore(QWindow *window)
bool QWinRTBackingStore::initialize()
{
Q_D(QWinRTBackingStore);
+ qCDebug(lcQpaBackingStoreVerbose) << __FUNCTION__ << d->initialized;
if (d->initialized)
return true;
@@ -94,6 +99,7 @@ bool QWinRTBackingStore::initialize()
QWinRTBackingStore::~QWinRTBackingStore()
{
+ qCDebug(lcQpaBackingStore) << __FUNCTION__ << this;
}
QPaintDevice *QWinRTBackingStore::paintDevice()
@@ -107,6 +113,8 @@ void QWinRTBackingStore::flush(QWindow *window, const QRegion &region, const QPo
Q_D(QWinRTBackingStore);
Q_UNUSED(offset)
+ qCDebug(lcQpaBackingStoreVerbose) << __FUNCTION__ << this << window << region;
+
if (d->size.isEmpty())
return;
@@ -140,6 +148,8 @@ void QWinRTBackingStore::resize(const QSize &size, const QRegion &staticContents
Q_D(QWinRTBackingStore);
Q_UNUSED(staticContents)
+ qCDebug(lcQpaBackingStoreVerbose) << __FUNCTION__ << this << size;
+
if (!initialize())
return;
@@ -169,11 +179,14 @@ QImage QWinRTBackingStore::toImage() const
void QWinRTBackingStore::beginPaint(const QRegion &region)
{
+ qCDebug(lcQpaBackingStoreVerbose) << __FUNCTION__ << this << region;
+
resize(window()->size(), region);
}
void QWinRTBackingStore::endPaint()
{
+ qCDebug(lcQpaBackingStoreVerbose) << __FUNCTION__ << this;
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/winrt/qwinrtbackingstore.h b/src/plugins/platforms/winrt/qwinrtbackingstore.h
index 20b27a3865..b5d9dfed4f 100644
--- a/src/plugins/platforms/winrt/qwinrtbackingstore.h
+++ b/src/plugins/platforms/winrt/qwinrtbackingstore.h
@@ -39,9 +39,13 @@
#include <qpa/qplatformbackingstore.h>
#include <QtCore/QScopedPointer>
+#include <QtCore/QLoggingCategory>
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcQpaBackingStore)
+Q_DECLARE_LOGGING_CATEGORY(lcQpaBackingStoreVerbose)
+
class QWinRTScreen;
class QWinRTBackingStorePrivate;
diff --git a/src/plugins/platforms/winrt/qwinrtclipboard.cpp b/src/plugins/platforms/winrt/qwinrtclipboard.cpp
new file mode 100644
index 0000000000..4e71490902
--- /dev/null
+++ b/src/plugins/platforms/winrt/qwinrtclipboard.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwinrtclipboard.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/qfunctions_winrt.h>
+#include <QtCore/private/qeventdispatcher_winrt_p.h>
+
+#include <Windows.ApplicationModel.datatransfer.h>
+
+#include <functional>
+
+using namespace ABI::Windows::ApplicationModel::DataTransfer;
+using namespace ABI::Windows::Foundation;
+using namespace Microsoft::WRL;
+using namespace Microsoft::WRL::Wrappers;
+
+typedef IEventHandler<IInspectable *> ContentChangedHandler;
+
+#define RETURN_NULLPTR_IF_FAILED(msg) RETURN_IF_FAILED(msg, return nullptr)
+
+QT_BEGIN_NAMESPACE
+
+QWinRTClipboard::QWinRTClipboard()
+{
+#ifndef Q_OS_WINPHONE
+ QEventDispatcherWinRT::runOnXamlThread([this]() {
+ HRESULT hr;
+ hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_ApplicationModel_DataTransfer_Clipboard).Get(),
+ &m_nativeClipBoard);
+ Q_ASSERT_SUCCEEDED(hr);
+
+ EventRegistrationToken tok;
+ hr = m_nativeClipBoard->add_ContentChanged(Callback<ContentChangedHandler>(this, &QWinRTClipboard::onContentChanged).Get(), &tok);
+ Q_ASSERT_SUCCEEDED(hr);
+
+ return hr;
+ });
+#endif // !Q_OS_WINPHONE
+}
+
+QMimeData *QWinRTClipboard::mimeData(QClipboard::Mode mode)
+{
+ if (!supportsMode(mode))
+ return nullptr;
+
+#ifndef Q_OS_WINPHONE
+ ComPtr<IDataPackageView> view;
+ HRESULT hr;
+ hr = m_nativeClipBoard->GetContent(&view);
+ RETURN_NULLPTR_IF_FAILED("Could not get clipboard content.");
+
+ ComPtr<IAsyncOperation<HSTRING>> op;
+ HString result;
+ // This throws a security exception (WinRT originate error / 0x40080201.
+ // Unfortunately there seems to be no way to avoid this, neither
+ // running on the XAML thread, nor some other way. Stack Overflow
+ // confirms this problem since Windows (Phone) 8.0.
+ hr = view->GetTextAsync(&op);
+ RETURN_NULLPTR_IF_FAILED("Could not get clipboard text.");
+
+ hr = QWinRTFunctions::await(op, result.GetAddressOf());
+ RETURN_NULLPTR_IF_FAILED("Could not get clipboard text content");
+
+ quint32 size;
+ const wchar_t *textStr = result.GetRawBuffer(&size);
+ QString text = QString::fromWCharArray(textStr, size);
+ text.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
+ m_mimeData.setText(text);
+
+ return &m_mimeData;
+#else // Q_OS_WINPHONE
+ return QPlatformClipboard::mimeData(mode);
+#endif // Q_OS_WINPHONE
+}
+
+// Inspired by QWindowsMimeText::convertFromMime
+inline QString convertToWindowsLineEnding(const QString &text)
+{
+ const QChar *u = text.unicode();
+ QString res;
+ const int s = text.length();
+ int maxsize = s + s / 40 + 3;
+ res.resize(maxsize);
+ int ri = 0;
+ bool cr = false;
+ for (int i = 0; i < s; ++i) {
+ if (*u == QLatin1Char('\r'))
+ cr = true;
+ else {
+ if (*u == QLatin1Char('\n') && !cr)
+ res[ri++] = QLatin1Char('\r');
+ cr = false;
+ }
+ res[ri++] = *u;
+ if (ri+3 >= maxsize) {
+ maxsize += maxsize / 4;
+ res.resize(maxsize);
+ }
+ ++u;
+ }
+ res.truncate(ri);
+ return res;
+}
+
+void QWinRTClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
+{
+ if (!supportsMode(mode))
+ return;
+
+#ifndef Q_OS_WINPHONE
+ const QString text = data->text();
+ HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([this, text]() {
+ HRESULT hr;
+ ComPtr<IDataPackage> package;
+ hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_ApplicationModel_DataTransfer_DataPackage).Get(),
+ &package);
+
+ const QString nativeString = convertToWindowsLineEnding(text);
+ HStringReference textRef(reinterpret_cast<LPCWSTR>(nativeString.utf16()), nativeString.length());
+
+ hr = package->SetText(textRef.Get());
+ RETURN_HR_IF_FAILED("Could not set text to clipboard data package.");
+
+ hr = m_nativeClipBoard->SetContent(package.Get());
+ RETURN_HR_IF_FAILED("Could not set clipboard content.");
+ return S_OK;
+ });
+ RETURN_VOID_IF_FAILED("Could not set clipboard text.");
+ emitChanged(mode);
+#else // Q_OS_WINPHONE
+ QPlatformClipboard::setMimeData(data, mode);
+#endif // Q_OS_WINPHONE
+}
+
+bool QWinRTClipboard::supportsMode(QClipboard::Mode mode) const
+{
+#ifndef Q_OS_WINPHONE
+ return mode == QClipboard::Clipboard;
+#else
+ return QPlatformClipboard::supportsMode(mode);
+#endif
+}
+
+HRESULT QWinRTClipboard::onContentChanged(IInspectable *, IInspectable *)
+{
+ emitChanged(QClipboard::Clipboard);
+ return S_OK;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/winrt/qwinrtclipboard.h b/src/plugins/platforms/winrt/qwinrtclipboard.h
new file mode 100644
index 0000000000..1fb10bdfc0
--- /dev/null
+++ b/src/plugins/platforms/winrt/qwinrtclipboard.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINRTPLATFORMCLIPBOARD_H
+#define QWINRTPLATFORMCLIPBOARD_H
+
+#include <qpa/qplatformclipboard.h>
+#include <QMimeData>
+
+#include <wrl.h>
+
+#ifndef Q_OS_WINPHONE
+namespace ABI {
+ namespace Windows {
+ namespace ApplicationModel {
+ namespace DataTransfer {
+ struct IClipboardStatics;
+ }
+ }
+ }
+}
+#endif // !Q_OS_WINPHONE
+
+QT_BEGIN_NAMESPACE
+
+class QWinRTClipboard: public QPlatformClipboard
+{
+public:
+ QWinRTClipboard();
+
+ QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard) Q_DECL_OVERRIDE;
+ void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard) Q_DECL_OVERRIDE;
+ bool supportsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE;
+
+ HRESULT onContentChanged(IInspectable *, IInspectable *);
+private:
+#ifndef Q_OS_WINPHONE
+ Microsoft::WRL::ComPtr<ABI::Windows::ApplicationModel::DataTransfer::IClipboardStatics> m_nativeClipBoard;
+#endif
+ QMimeData m_mimeData;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWINRTPLATFORMCLIPBOARD_H
diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
index 8ca669141e..34f439b70f 100644
--- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp
+++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
@@ -49,6 +49,7 @@
#include <QOffscreenSurface>
#include <QOpenGLContext>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtPlatformSupport/private/qeglpbuffer_p.h>
QT_BEGIN_NAMESPACE
@@ -148,14 +149,17 @@ bool QWinRTEGLContext::makeCurrent(QPlatformSurface *windowSurface)
Q_D(QWinRTEGLContext);
Q_ASSERT(windowSurface->surface()->supportsOpenGL());
- if (windowSurface->surface()->surfaceClass() == QSurface::Offscreen)
- return false;
+ EGLSurface surface;
+ if (windowSurface->surface()->surfaceClass() == QSurface::Window) {
+ QWinRTWindow *window = static_cast<QWinRTWindow *>(windowSurface);
+ if (window->eglSurface() == EGL_NO_SURFACE)
+ window->createEglSurface(g->eglDisplay, d->eglConfig);
- QWinRTWindow *window = static_cast<QWinRTWindow *>(windowSurface);
- if (window->eglSurface() == EGL_NO_SURFACE)
- window->createEglSurface(g->eglDisplay, d->eglConfig);
+ surface = window->eglSurface();
+ } else { // Offscreen
+ surface = static_cast<QEGLPbuffer *>(windowSurface)->pbuffer();
+ }
- EGLSurface surface = window->eglSurface();
if (surface == EGL_NO_SURFACE)
return false;
@@ -346,4 +350,9 @@ QFunctionPointer QWinRTEGLContext::getProcAddress(const QByteArray &procName)
return eglGetProcAddress(procName.constData());
}
+EGLDisplay QWinRTEGLContext::display()
+{
+ return g->eglDisplay;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.h b/src/plugins/platforms/winrt/qwinrteglcontext.h
index 31a2124b03..49b289cd79 100644
--- a/src/plugins/platforms/winrt/qwinrteglcontext.h
+++ b/src/plugins/platforms/winrt/qwinrteglcontext.h
@@ -38,6 +38,7 @@
#define QWINDOWSEGLCONTEXT_H
#include <qpa/qplatformopenglcontext.h>
+#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
@@ -57,6 +58,7 @@ public:
QSurfaceFormat format() const Q_DECL_OVERRIDE;
QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE;
+ static EGLDisplay display();
private:
QScopedPointer<QWinRTEGLContextPrivate> d_ptr;
Q_DECLARE_PRIVATE(QWinRTEGLContext)
diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp b/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
index 793256a83f..22fb8cb63e 100644
--- a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
+++ b/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
@@ -47,6 +47,20 @@ using namespace Microsoft::WRL;
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcQpaFonts, "qt.qpa.fonts")
+
+QDebug operator<<(QDebug d, const QFontDef &def)
+{
+ QDebugStateSaver saver(d);
+ d.nospace();
+ d << "Family=" << def.family << " Stylename=" << def.styleName
+ << " pointsize=" << def.pointSize << " pixelsize=" << def.pixelSize
+ << " styleHint=" << def.styleHint << " weight=" << def.weight
+ << " stretch=" << def.stretch << " hintingPreference="
+ << def.hintingPreference;
+ return d;
+}
+
// Based on unicode range tables at http://www.microsoft.com/typography/otspec/os2.htm#ur
static QFontDatabase::WritingSystem writingSystemFromUnicodeRange(const DWRITE_UNICODE_RANGE &range)
{
@@ -114,6 +128,7 @@ static QFontDatabase::WritingSystem writingSystemFromUnicodeRange(const DWRITE_U
QString QWinRTFontDatabase::fontDir() const
{
+ qCDebug(lcQpaFonts) << __FUNCTION__;
QString fontDirectory = QBasicFontDatabase::fontDir();
if (!QFile::exists(fontDirectory)) {
// Fall back to app directory + fonts, and just app directory after that
@@ -130,6 +145,8 @@ QString QWinRTFontDatabase::fontDir() const
QWinRTFontDatabase::~QWinRTFontDatabase()
{
+ qCDebug(lcQpaFonts) << __FUNCTION__;
+
foreach (IDWriteFontFile *fontFile, m_fonts.keys())
fontFile->Release();
@@ -149,6 +166,8 @@ bool QWinRTFontDatabase::fontsAlwaysScalable() const
void QWinRTFontDatabase::populateFontDatabase()
{
+ qCDebug(lcQpaFonts) << __FUNCTION__;
+
ComPtr<IDWriteFactory1> factory;
HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory1), &factory);
if (FAILED(hr)) {
@@ -204,6 +223,8 @@ void QWinRTFontDatabase::populateFontDatabase()
void QWinRTFontDatabase::populateFamily(const QString &familyName)
{
+ qCDebug(lcQpaFonts) << __FUNCTION__ << familyName;
+
IDWriteFontFamily *fontFamily = m_fontFamilies.value(familyName);
if (!fontFamily) {
qWarning("The font family %s was not found.", qPrintable(familyName));
@@ -367,6 +388,8 @@ void QWinRTFontDatabase::populateFamily(const QString &familyName)
QFontEngine *QWinRTFontDatabase::fontEngine(const QFontDef &fontDef, void *handle)
{
+ qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDEF" << fontDef << handle;
+
if (!handle) // Happens if a font family population failed
return 0;
@@ -436,6 +459,8 @@ QStringList QWinRTFontDatabase::fallbacksForFamily(const QString &family, QFont:
Q_UNUSED(styleHint)
Q_UNUSED(script)
+ qCDebug(lcQpaFonts) << __FUNCTION__ << family;
+
QStringList result;
if (family == QLatin1String("Helvetica"))
result.append(QStringLiteral("Arial"));
@@ -445,6 +470,8 @@ QStringList QWinRTFontDatabase::fallbacksForFamily(const QString &family, QFont:
void QWinRTFontDatabase::releaseHandle(void *handle)
{
+ qCDebug(lcQpaFonts) << __FUNCTION__ << handle;
+
if (!handle)
return;
diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.h b/src/plugins/platforms/winrt/qwinrtfontdatabase.h
index 41619f5bd8..e8495e202f 100644
--- a/src/plugins/platforms/winrt/qwinrtfontdatabase.h
+++ b/src/plugins/platforms/winrt/qwinrtfontdatabase.h
@@ -38,12 +38,15 @@
#define QWINRTFONTDATABASE_H
#include <QtPlatformSupport/private/qbasicfontdatabase_p.h>
+#include <QtCore/QLoggingCategory>
struct IDWriteFontFile;
struct IDWriteFontFamily;
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcQpaFonts)
+
struct FontDescription
{
quint32 index;
diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
index a0474b6710..72fc378760 100644
--- a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
+++ b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
@@ -54,6 +54,8 @@ typedef ITypedEventHandler<InputPane*, InputPaneVisibilityEventArgs*> InputPaneV
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.input.methods")
+
inline QRectF getInputPaneRect(IInputPane *pane, qreal scaleFactor)
{
Rect rect;
@@ -78,6 +80,8 @@ inline QRectF getInputPaneRect(IInputPane *pane, qreal scaleFactor)
QWinRTInputContext::QWinRTInputContext(QWinRTScreen *screen)
: m_screen(screen)
{
+ qCDebug(lcQpaInputMethods) << __FUNCTION__ << screen;
+
IInputPaneStatics *statics;
if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(),
&statics))) {
@@ -114,6 +118,7 @@ bool QWinRTInputContext::isInputPanelVisible() const
HRESULT QWinRTInputContext::onShowing(IInputPane *pane, IInputPaneVisibilityEventArgs *)
{
+ qCDebug(lcQpaInputMethods) << __FUNCTION__ << pane;
m_isInputPanelVisible = true;
emitInputPanelVisibleChanged();
return handleVisibilityChange(pane);
@@ -121,6 +126,7 @@ HRESULT QWinRTInputContext::onShowing(IInputPane *pane, IInputPaneVisibilityEven
HRESULT QWinRTInputContext::onHiding(IInputPane *pane, IInputPaneVisibilityEventArgs *)
{
+ qCDebug(lcQpaInputMethods) << __FUNCTION__ << pane;
m_isInputPanelVisible = false;
emitInputPanelVisibleChanged();
return handleVisibilityChange(pane);
@@ -128,6 +134,7 @@ HRESULT QWinRTInputContext::onHiding(IInputPane *pane, IInputPaneVisibilityEvent
HRESULT QWinRTInputContext::handleVisibilityChange(IInputPane *pane)
{
+ qCDebug(lcQpaInputMethods) << __FUNCTION__ << pane;
const QRectF keyboardRect = getInputPaneRect(pane, m_screen->scaleFactor());
if (m_keyboardRect != keyboardRect) {
m_keyboardRect = keyboardRect;
@@ -165,31 +172,35 @@ static HRESULT getInputPane(ComPtr<IInputPane2> *inputPane2)
void QWinRTInputContext::showInputPanel()
{
+ qCDebug(lcQpaInputMethods) << __FUNCTION__;
+
QEventDispatcherWinRT::runOnXamlThread([&]() {
ComPtr<IInputPane2> inputPane;
HRESULT hr = getInputPane(&inputPane);
if (FAILED(hr))
- return hr;
+ return S_OK;
boolean success;
hr = inputPane->TryShow(&success);
if (FAILED(hr) || !success)
qErrnoWarning(hr, "Failed to show input panel.");
- return hr;
+ return S_OK;
});
}
void QWinRTInputContext::hideInputPanel()
{
+ qCDebug(lcQpaInputMethods) << __FUNCTION__;
+
QEventDispatcherWinRT::runOnXamlThread([&]() {
ComPtr<IInputPane2> inputPane;
HRESULT hr = getInputPane(&inputPane);
if (FAILED(hr))
- return hr;
+ return S_OK;
boolean success;
hr = inputPane->TryHide(&success);
if (FAILED(hr) || !success)
qErrnoWarning(hr, "Failed to hide input panel.");
- return hr;
+ return S_OK;
});
}
diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.h b/src/plugins/platforms/winrt/qwinrtinputcontext.h
index 6f88ff46e6..d5a1a40efc 100644
--- a/src/plugins/platforms/winrt/qwinrtinputcontext.h
+++ b/src/plugins/platforms/winrt/qwinrtinputcontext.h
@@ -39,6 +39,7 @@
#include <qpa/qplatforminputcontext.h>
#include <QtCore/QRectF>
+#include <QtCore/QLoggingCategory>
#include <wrl.h>
@@ -58,6 +59,8 @@ namespace ABI {
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods)
+
class QWinRTScreen;
class QWinRTInputContext : public QPlatformInputContext
{
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp
index 2281bf56cc..30c0e81e21 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.cpp
+++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp
@@ -44,13 +44,19 @@
#include "qwinrteglcontext.h"
#include "qwinrtfontdatabase.h"
#include "qwinrttheme.h"
+#include "qwinrtclipboard.h"
-#include <QtGui/QSurface>
+#include <QtGui/QOffscreenSurface>
#include <QtGui/QOpenGLContext>
-#include <qfunctions_winrt.h>
+#include <QtGui/QSurface>
+#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <qpa/qwindowsysteminterface.h>
+#include <qpa/qplatformwindow.h>
#include <qpa/qplatformoffscreensurface.h>
+#include <qfunctions_winrt.h>
+
#include <functional>
#include <wrl.h>
#include <windows.ui.xaml.h>
@@ -106,6 +112,7 @@ class QWinRTIntegrationPrivate
public:
QPlatformFontDatabase *fontDatabase;
QPlatformServices *platformServices;
+ QPlatformClipboard *clipboard;
QWinRTScreen *mainScreen;
QScopedPointer<QWinRTInputContext> inputContext;
@@ -190,6 +197,7 @@ QWinRTIntegration::QWinRTIntegration() : d_ptr(new QWinRTIntegrationPrivate)
screenAdded(d->mainScreen);
d->platformServices = new QWinRTServices;
+ d->clipboard = new QWinRTClipboard;
}
QWinRTIntegration::~QWinRTIntegration()
@@ -295,6 +303,12 @@ QPlatformServices *QWinRTIntegration::services() const
return d->platformServices;
}
+QPlatformClipboard *QWinRTIntegration::clipboard() const
+{
+ Q_D(const QWinRTIntegration);
+ return d->clipboard;
+}
+
Qt::KeyboardModifiers QWinRTIntegration::queryKeyboardModifiers() const
{
Q_D(const QWinRTIntegration);
@@ -385,11 +399,20 @@ HRESULT QWinRTIntegration::onResume(IInspectable *, IInspectable *)
QPlatformOffscreenSurface *QWinRTIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
{
- // This is only used for shutdown of applications.
- // In case we do not return an empty surface the scenegraph will try
- // to create a new native window during application exit causing crashes
- // or assertions.
- return new QPlatformOffscreenSurface(surface);
+ QEGLPbuffer *pbuffer = nullptr;
+ HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([&pbuffer, surface]() {
+ pbuffer = new QEGLPbuffer(QWinRTEGLContext::display(), surface->requestedFormat(), surface);
+ return S_OK;
+ });
+ if (hr == UI_E_WINDOW_CLOSED) {
+ // This is only used for shutdown of applications.
+ // In case we do not return an empty surface the scenegraph will try
+ // to create a new native window during application exit causing crashes
+ // or assertions.
+ return new QPlatformOffscreenSurface(surface);
+ }
+
+ return pbuffer;
}
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.h b/src/plugins/platforms/winrt/qwinrtintegration.h
index 9bf5d27973..1ed286ab2e 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.h
+++ b/src/plugins/platforms/winrt/qwinrtintegration.h
@@ -93,6 +93,7 @@ public:
QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE;
QPlatformServices *services() const Q_DECL_OVERRIDE;
+ QPlatformClipboard *clipboard() const Q_DECL_OVERRIDE;
Qt::KeyboardModifiers queryKeyboardModifiers() const Q_DECL_OVERRIDE;
QStringList themeNames() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp
index 7d09551f5b..7ef13fd0aa 100644
--- a/src/plugins/platforms/winrt/qwinrttheme.cpp
+++ b/src/plugins/platforms/winrt/qwinrttheme.cpp
@@ -56,6 +56,8 @@ using namespace ABI::Windows::UI::ViewManagement;
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcQpaTheme, "qt.qpa.theme")
+
static IUISettings *uiSettings()
{
static ComPtr<IUISettings> settings;
@@ -285,12 +287,14 @@ QWinRTTheme::QWinRTTheme()
: d_ptr(new QWinRTThemePrivate)
{
Q_D(QWinRTTheme);
+ qCDebug(lcQpaTheme) << __FUNCTION__;
nativeColorSettings(d->palette);
}
bool QWinRTTheme::usePlatformNativeDialog(DialogType type) const
{
+ qCDebug(lcQpaTheme) << __FUNCTION__ << type;
static bool useNativeDialogs = qEnvironmentVariableIsSet("QT_USE_WINRT_NATIVE_DIALOGS")
? qEnvironmentVariableIntValue("QT_USE_WINRT_NATIVE_DIALOGS") : true;
@@ -301,6 +305,7 @@ bool QWinRTTheme::usePlatformNativeDialog(DialogType type) const
QPlatformDialogHelper *QWinRTTheme::createPlatformDialogHelper(DialogType type) const
{
+ qCDebug(lcQpaTheme) << __FUNCTION__ << type;
switch (type) {
case FileDialog:
return new QWinRTFileDialogHelper;
@@ -314,6 +319,7 @@ QPlatformDialogHelper *QWinRTTheme::createPlatformDialogHelper(DialogType type)
QVariant QWinRTTheme::styleHint(QPlatformIntegration::StyleHint hint)
{
+ qCDebug(lcQpaTheme) << __FUNCTION__ << hint;
HRESULT hr;
switch (hint) {
case QPlatformIntegration::CursorFlashTime: {
@@ -363,6 +369,7 @@ QVariant QWinRTTheme::styleHint(QPlatformIntegration::StyleHint hint)
const QPalette *QWinRTTheme::palette(Palette type) const
{
Q_D(const QWinRTTheme);
+ qCDebug(lcQpaTheme) << __FUNCTION__ << type;
if (type == SystemPalette)
return &d->palette;
return QPlatformTheme::palette(type);
diff --git a/src/plugins/platforms/winrt/qwinrttheme.h b/src/plugins/platforms/winrt/qwinrttheme.h
index 2e159cbd55..e1a0e14964 100644
--- a/src/plugins/platforms/winrt/qwinrttheme.h
+++ b/src/plugins/platforms/winrt/qwinrttheme.h
@@ -39,9 +39,12 @@
#include <qpa/qplatformtheme.h>
#include <qpa/qplatformintegration.h>
+#include <QtCore/QLoggingCategory>
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcQpaTheme)
+
class QWinRTThemePrivate;
class QWinRTTheme : public QPlatformTheme
{
diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp
index 8a53047d1e..c6ed0dea0c 100644
--- a/src/plugins/platforms/winrt/qwinrtwindow.cpp
+++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp
@@ -69,6 +69,8 @@ using namespace ABI::Windows::UI::Xaml::Controls;
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcQpaWindows, "qt.qpa.windows");
+
static void setUIElementVisibility(IUIElement *uiElement, bool visibility)
{
Q_ASSERT(uiElement);
@@ -101,6 +103,7 @@ QWinRTWindow::QWinRTWindow(QWindow *window)
, d_ptr(new QWinRTWindowPrivate)
{
Q_D(QWinRTWindow);
+ qCDebug(lcQpaWindows) << __FUNCTION__ << this;
d->surface = EGL_NO_SURFACE;
d->display = EGL_NO_DISPLAY;
@@ -133,6 +136,15 @@ QWinRTWindow::QWinRTWindow(QWindow *window)
hr = d->swapChainPanel.As(&d->uiElement);
Q_ASSERT_SUCCEEDED(hr);
+ ComPtr<Xaml::IFrameworkElement> frameworkElement;
+ hr = d->swapChainPanel.As(&frameworkElement);
+ Q_ASSERT_SUCCEEDED(hr);
+ const QSizeF size = QSizeF(d->screen->geometry().size()) / d->screen->scaleFactor();
+ hr = frameworkElement->put_Width(size.width());
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = frameworkElement->put_Height(size.height());
+ Q_ASSERT_SUCCEEDED(hr);
+
ComPtr<IDependencyObject> canvas = d->screen->canvas();
ComPtr<IPanel> panel;
hr = canvas.As(&panel);
@@ -152,6 +164,7 @@ QWinRTWindow::QWinRTWindow(QWindow *window)
QWinRTWindow::~QWinRTWindow()
{
Q_D(QWinRTWindow);
+ qCDebug(lcQpaWindows) << __FUNCTION__ << this;
HRESULT hr;
hr = QEventDispatcherWinRT::runOnXamlThread([d]() {
@@ -178,6 +191,8 @@ QWinRTWindow::~QWinRTWindow()
if (!d->surface)
return;
+ qCDebug(lcQpaWindows) << __FUNCTION__ << ": Destroying surface";
+
EGLBoolean value = eglDestroySurface(d->display, d->surface);
d->surface = EGL_NO_SURFACE;
if (Q_UNLIKELY(value == EGL_FALSE))
@@ -205,12 +220,15 @@ bool QWinRTWindow::isExposed() const
void QWinRTWindow::setGeometry(const QRect &rect)
{
Q_D(QWinRTWindow);
+ qCDebug(lcQpaWindows) << __FUNCTION__ << this << rect;
const Qt::WindowFlags windowFlags = window()->flags();
const Qt::WindowFlags windowType = windowFlags & Qt::WindowType_Mask;
if (window()->isTopLevel() && (windowType == Qt::Window || windowType == Qt::Dialog)) {
- QPlatformWindow::setGeometry(windowFlags & Qt::MaximizeUsingFullscreenGeometryHint
- ? d->screen->geometry() : d->screen->availableGeometry());
+ const QRect screenRect = windowFlags & Qt::MaximizeUsingFullscreenGeometryHint
+ ? d->screen->geometry() : d->screen->availableGeometry();
+ qCDebug(lcQpaWindows) << __FUNCTION__ << "top-level, overwrite" << screenRect;
+ QPlatformWindow::setGeometry(screenRect);
QWindowSystemInterface::handleGeometryChange(window(), geometry());
} else {
QPlatformWindow::setGeometry(rect);
@@ -234,6 +252,8 @@ void QWinRTWindow::setGeometry(const QRect &rect)
Q_ASSERT_SUCCEEDED(hr);
hr = frameworkElement->put_Height(size.height());
Q_ASSERT_SUCCEEDED(hr);
+ qCDebug(lcQpaWindows) << __FUNCTION__ << "(setGeometry Xaml)" << this
+ << topLeft << size;
return S_OK;
});
Q_ASSERT_SUCCEEDED(hr);
@@ -242,6 +262,8 @@ void QWinRTWindow::setGeometry(const QRect &rect)
void QWinRTWindow::setVisible(bool visible)
{
Q_D(QWinRTWindow);
+ qCDebug(lcQpaWindows) << __FUNCTION__ << this << visible;
+
if (!window()->isTopLevel())
return;
if (visible) {
@@ -263,6 +285,7 @@ void QWinRTWindow::setWindowTitle(const QString &title)
void QWinRTWindow::raise()
{
Q_D(QWinRTWindow);
+ qCDebug(lcQpaWindows) << __FUNCTION__ << this;
if (!window()->isTopLevel())
return;
d->screen->raise(window());
@@ -271,6 +294,7 @@ void QWinRTWindow::raise()
void QWinRTWindow::lower()
{
Q_D(QWinRTWindow);
+ qCDebug(lcQpaWindows) << __FUNCTION__ << this;
if (!window()->isTopLevel())
return;
d->screen->lower(window());
@@ -290,6 +314,8 @@ qreal QWinRTWindow::devicePixelRatio() const
void QWinRTWindow::setWindowState(Qt::WindowState state)
{
Q_D(QWinRTWindow);
+ qCDebug(lcQpaWindows) << __FUNCTION__ << this << state;
+
if (d->state == state)
return;
diff --git a/src/plugins/platforms/winrt/qwinrtwindow.h b/src/plugins/platforms/winrt/qwinrtwindow.h
index 9ac7adbf4d..36f5b9de84 100644
--- a/src/plugins/platforms/winrt/qwinrtwindow.h
+++ b/src/plugins/platforms/winrt/qwinrtwindow.h
@@ -37,12 +37,15 @@
#ifndef QWINRTWINDOW_H
#define QWINRTWINDOW_H
+#include <QtCore/QLoggingCategory>
#include <qpa/qplatformwindow.h>
#include <qpa/qwindowsysteminterface.h>
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcQpaWindows)
+
class QWinRTWindowPrivate;
class QWinRTWindow : public QPlatformWindow
{
diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro
index be6aad02d1..991ec1789b 100644
--- a/src/plugins/platforms/winrt/winrt.pro
+++ b/src/plugins/platforms/winrt/winrt.pro
@@ -16,6 +16,7 @@ INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/freetype/include
SOURCES = \
main.cpp \
qwinrtbackingstore.cpp \
+ qwinrtclipboard.cpp \
qwinrtcursor.cpp \
qwinrteglcontext.cpp \
qwinrteventdispatcher.cpp \
@@ -33,6 +34,7 @@ SOURCES = \
HEADERS = \
qwinrtbackingstore.h \
+ qwinrtclipboard.h \
qwinrtcursor.h \
qwinrteglcontext.h \
qwinrteventdispatcher.h \
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index e3686ec010..e57b089878 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -185,7 +185,7 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI
m_hasAlpha = QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha;
if (!m_hasAlpha)
- format = qt_alphaVersionForPainting(format);
+ format = qt_maybeAlphaVersionWithSameDepth(format);
m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format);
m_graphics_buffer = new QXcbShmGraphicsBuffer(&m_qimage);
@@ -326,12 +326,9 @@ QPaintDevice *QXcbBackingStore::paintDevice()
void QXcbBackingStore::beginPaint(const QRegion &region)
{
- if (!m_image && !m_size.isEmpty())
- resize(m_size, QRegion());
-
if (!m_image)
return;
- m_size = QSize();
+
m_paintRegion = region;
m_image->preparePaint(m_paintRegion);
@@ -438,8 +435,7 @@ void QXcbBackingStore::resize(const QSize &size, const QRegion &)
return;
Q_XCB_NOOP(connection());
-
- QXcbScreen *screen = window()->screen() ? static_cast<QXcbScreen *>(window()->screen()->handle()) : 0;
+ QXcbScreen *screen = static_cast<QXcbScreen *>(window()->screen()->handle());
QPlatformWindow *pw = window()->handle();
if (!pw) {
window()->create();
@@ -448,11 +444,6 @@ void QXcbBackingStore::resize(const QSize &size, const QRegion &)
QXcbWindow* win = static_cast<QXcbWindow *>(pw);
delete m_image;
- if (!screen) {
- m_image = 0;
- m_size = size;
- return;
- }
m_image = new QXcbShmImage(screen, size, win->depth(), win->imageFormat());
// Slow path for bgr888 VNC: Create an additional image, paint into that and
// swap R and B while copying to m_image after each paint.
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.h b/src/plugins/platforms/xcb/qxcbbackingstore.h
index b3c0a74f25..1f5652d918 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.h
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.h
@@ -77,7 +77,6 @@ private:
QXcbShmImage *m_image;
QRegion m_paintRegion;
QImage m_rgbImage;
- QSize m_size;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index ca19c3dce8..e94433dd4b 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -44,6 +44,7 @@
#include "qtouchdevice.h"
#include <qpa/qwindowsysteminterface.h>
#include <QDebug>
+#include <cmath>
#ifdef XCB_USE_XINPUT2
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index 3983e90205..9409de2406 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -199,6 +199,7 @@ void QXcbDrag::startDrag()
XCB_ATOM_ATOM, 32, drag_types.size(), (const void *)drag_types.constData());
setUseCompositing(current_virtual_desktop->compositingActive());
+ setScreen(current_virtual_desktop->screens().constFirst()->screen());
QBasicDrag::startDrag();
if (connection()->mouseGrabber() == Q_NULLPTR)
shapedPixmapWindow()->setMouseGrabEnabled(true);
@@ -328,6 +329,9 @@ void QXcbDrag::move(const QPoint &globalPos)
if (virtualDesktop != current_virtual_desktop) {
setUseCompositing(virtualDesktop->compositingActive());
recreateShapedPixmapWindow(static_cast<QPlatformScreen*>(screen)->screen(), deviceIndependentPos);
+ if (connection()->mouseGrabber() == Q_NULLPTR)
+ shapedPixmapWindow()->setMouseGrabEnabled(true);
+
current_virtual_desktop = virtualDesktop;
} else {
QBasicDrag::moveShapedPixmapWindow(deviceIndependentPos);
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 041a9992bb..339529edf1 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -214,7 +214,10 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe
m_geometry = QRect(QPoint(), m_virtualSize);
if (m_availableGeometry.isEmpty())
- m_availableGeometry = m_geometry;
+ m_availableGeometry = m_geometry & m_virtualDesktop->workArea();
+
+ if (m_sizeMillimeters.isEmpty())
+ m_sizeMillimeters = m_virtualSizeMillimeters;
readXResources();
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 240a1dbc74..11202944bd 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -56,6 +56,7 @@
#include "qxcbsystemtraytracker.h"
#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformcursor.h>
#include <algorithm>
@@ -267,6 +268,26 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
}
#endif // XCB_USE_XLIB
+// TODO move this into a utility function in QWindow or QGuiApplication
+static QWindow *childWindowAt(QWindow *win, const QPoint &p)
+{
+ foreach (QObject *obj, win->children()) {
+ if (obj->isWindowType()) {
+ QWindow *childWin = static_cast<QWindow *>(obj);
+ if (childWin->isVisible()) {
+ if (QWindow *recurse = childWindowAt(childWin, p))
+ return recurse;
+ }
+ }
+ }
+ if (!win->isTopLevel()
+ && !(win->flags() & Qt::WindowTransparentForInput)
+ && win->geometry().contains(win->parent()->mapFromGlobal(p))) {
+ return win;
+ }
+ return Q_NULLPTR;
+}
+
static const char *wm_window_type_property_id = "_q_xcb_wm_window_type";
QXcbWindow::QXcbWindow(QWindow *window)
@@ -646,7 +667,7 @@ void QXcbWindow::setGeometry(const QRect &rect)
const QRect wmGeometry = windowToWmGeometry(rect);
- if (newScreen && newScreen != currentScreen)
+ if (newScreen != currentScreen)
QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
if (qt_window_private(window())->positionAutomatic) {
@@ -861,6 +882,33 @@ void QXcbWindow::hide()
connection()->setMouseGrabber(Q_NULLPTR);
m_mapped = false;
+
+ // Hiding a modal window doesn't send an enter event to its transient parent when the
+ // mouse is already over the parent window, so the enter event must be emulated.
+ if (window()->isModal()) {
+ // Get the cursor position at modal window screen
+ const QPoint nativePos = xcbScreen()->cursor()->pos();
+ const QPoint cursorPos = QHighDpi::fromNativePixels(nativePos, xcbScreen()->screenForPosition(nativePos)->screen());
+
+ // Find the top level window at cursor position.
+ // Don't use QGuiApplication::topLevelAt(): search only the virtual siblings of this window's screen
+ QWindow *enterWindow = Q_NULLPTR;
+ foreach (QPlatformScreen *screen, xcbScreen()->virtualSiblings()) {
+ if (screen->geometry().contains(cursorPos)) {
+ const QPoint devicePosition = QHighDpi::toNativePixels(cursorPos, screen->screen());
+ enterWindow = screen->topLevelAt(devicePosition);
+ break;
+ }
+ }
+
+ if (enterWindow && enterWindow != window()) {
+ // Find the child window at cursor position, otherwise use the top level window
+ if (QWindow *childWindow = childWindowAt(enterWindow, cursorPos))
+ enterWindow = childWindow;
+ const QPoint localPos = enterWindow->mapFromGlobal(cursorPos);
+ QWindowSystemInterface::handleEnterEvent(enterWindow, localPos, cursorPos);
+ }
+ }
}
static QWindow *tlWindow(QWindow *window)
@@ -1612,7 +1660,7 @@ void QXcbWindow::requestActivateWindow()
return;
}
- if (!m_mapped || !xcbScreen()) {
+ if (!m_mapped) {
m_deferredActivation = true;
return;
}
diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
index 4dbbadb847..a21b4d8a65 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
@@ -506,8 +506,8 @@ void QGtk3FontDialogHelper::hide()
static QString qt_fontToString(const QFont &font)
{
PangoFontDescription *desc = pango_font_description_new();
- pango_font_description_set_size(desc, font.pointSizeF() * PANGO_SCALE);
- pango_font_description_set_family(desc, font.family().toUtf8());
+ pango_font_description_set_size(desc, (font.pointSizeF() > 0.0 ? font.pointSizeF() : QFontInfo(font).pointSizeF()) * PANGO_SCALE);
+ pango_font_description_set_family(desc, QFontInfo(font).family().toUtf8());
int weight = font.weight();
if (weight >= QFont::Black)
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp
index ea44585f33..ac51941f43 100644
--- a/src/sql/kernel/qsqldriver.cpp
+++ b/src/sql/kernel/qsqldriver.cpp
@@ -466,6 +466,9 @@ QString QSqlDriver::stripDelimiters(const QString &identifier, IdentifierType ty
with the values from \a rec. If \a preparedStatement is true, the
string will contain placeholders instead of values.
+ The generated flag in each field of \a rec determines whether the
+ field is included in the generated statement.
+
This method can be used to manipulate tables without having to worry
about database-dependent SQL dialects. For non-prepared statements,
the values will be properly escaped.
@@ -488,31 +491,25 @@ QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName,
s.prepend(QLatin1String("SELECT ")).append(QLatin1String(" FROM ")).append(tableName);
break;
case WhereStatement:
- if (preparedStatement) {
- for (int i = 0; i < rec.count(); ++i) {
- s.append(prepareIdentifier(rec.fieldName(i), FieldName,this));
- if (rec.isNull(i))
- s.append(QLatin1String(" IS NULL"));
- else
- s.append(QLatin1String(" = ?"));
- s.append(QLatin1String(" AND "));
- }
- } else {
- for (i = 0; i < rec.count(); ++i) {
- s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this));
- QString val = formatValue(rec.field(i));
- if (val == QLatin1String("NULL"))
- s.append(QLatin1String(" IS NULL"));
- else
- s.append(QLatin1String(" = ")).append(val);
- s.append(QLatin1String(" AND "));
- }
- }
- if (!s.isEmpty()) {
- s.prepend(QLatin1String("WHERE "));
- s.chop(5); // remove tailing AND
+ {
+ const QString tableNamePrefix = tableName.isEmpty()
+ ? QString()
+ : prepareIdentifier(tableName, QSqlDriver::TableName, this) + QLatin1Char('.');
+ for (int i = 0; i < rec.count(); ++i) {
+ if (!rec.isGenerated(i))
+ continue;
+ s.append(s.isEmpty() ? QLatin1String("WHERE ") : QLatin1String(" AND "));
+ s.append(tableNamePrefix);
+ s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this));
+ if (rec.isNull(i))
+ s.append(QLatin1String(" IS NULL"));
+ else if (preparedStatement)
+ s.append(QLatin1String(" = ?"));
+ else
+ s.append(QLatin1String(" = ")).append(formatValue(rec.field(i)));
}
break;
+ }
case UpdateStatement:
s.append(QLatin1String("UPDATE ")).append(tableName).append(
QLatin1String(" SET "));
diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h
index 1119b04293..e750fdb5a9 100644
--- a/src/testlib/qtestkeyboard.h
+++ b/src/testlib/qtestkeyboard.h
@@ -63,7 +63,7 @@
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
-Q_GUI_EXPORT bool qt_handleShortcutEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1);
+Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1);
namespace QTest
{
@@ -99,7 +99,7 @@ namespace QTest
if (action == Shortcut) {
int timestamp = 0;
- qt_handleShortcutEvent(window, timestamp, code, modifier, text, repeat);
+ qt_sendShortcutOverrideEvent(window, timestamp, code, modifier, text, repeat);
return;
}
@@ -180,7 +180,7 @@ namespace QTest
QKeyEvent a(press ? QEvent::KeyPress : QEvent::KeyRelease, code, modifier, text, repeat);
QSpontaneKeyEvent::setSpontaneous(&a);
- if (press && qt_handleShortcutEvent(widget, a.timestamp(), code, modifier, text, repeat))
+ if (press && qt_sendShortcutOverrideEvent(widget, a.timestamp(), code, modifier, text, repeat))
return;
if (!qApp->notify(widget, &a))
QTest::qWarn("Keyboard event not accepted by receiving widget");
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 07422f8811..50667e2a91 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -532,7 +532,6 @@ QFileDialogPrivate::QFileDialogPrivate()
deleteAction(0),
showHiddenAction(0),
useDefaultCaption(true),
- defaultFileTypes(true),
qFileDialogUi(0),
options(new QFileDialogOptions)
{
@@ -663,8 +662,8 @@ void QFileDialogPrivate::retranslateStrings()
{
Q_Q(QFileDialog);
/* WIDGETS */
- if (defaultFileTypes)
- q->setNameFilter(QFileDialog::tr("All Files (*)"));
+ if (options->useDefaultNameFilters())
+ q->setNameFilter(QFileDialogOptions::defaultNameFilterString());
if (nativeDialogInUse)
return;
@@ -1400,7 +1399,6 @@ QStringList qt_strip_filters(const QStringList &filters)
void QFileDialog::setNameFilters(const QStringList &filters)
{
Q_D(QFileDialog);
- d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)")));
QStringList cleanedFilters;
const int numFilters = filters.count();
cleanedFilters.reserve(numFilters);
@@ -1529,7 +1527,7 @@ static QString nameFilterForMime(const QString &mimeType)
return QFileDialog::tr("All files (*)");
} else {
const QString patterns = mime.globPatterns().join(QLatin1Char(' '));
- return mime.comment() + QStringLiteral(" (") + patterns + QLatin1Char(')');
+ return mime.comment() + QLatin1String(" (") + patterns + QLatin1Char(')');
}
}
return QString();
diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index 84831ac03e..f273a4fb37 100644
--- a/src/widgets/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
@@ -250,7 +250,6 @@ public:
QAction *newFolderAction;
bool useDefaultCaption;
- bool defaultFileTypes;
// setVisible_sys returns true if it ends up showing a native
// dialog. Returning false means that a non-native dialog must be
diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h
index 8e622e777a..af3406b699 100644
--- a/src/widgets/dialogs/qfilesystemmodel_p.h
+++ b/src/widgets/dialogs/qfilesystemmodel_p.h
@@ -268,16 +268,6 @@ public:
delayedSortTimer.start(0);
}
- static bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
- {
- return QString::compare(s1, s2, Qt::CaseInsensitive) < 0;
- }
-
- static bool nodeCaseInsensitiveLessThan(const QFileSystemModelPrivate::QFileSystemNode &s1, const QFileSystemModelPrivate::QFileSystemNode &s2)
- {
- return QString::compare(s1.fileName, s2.fileName, Qt::CaseInsensitive) < 0;
- }
-
QIcon icon(const QModelIndex &index) const;
QString name(const QModelIndex &index) const;
QString displayName(const QModelIndex &index) const;
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 53a5dcba9c..646ab58e3d 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -1440,13 +1440,11 @@ QModelIndexList QListView::selectedIndexes() const
return QModelIndexList();
QModelIndexList viewSelected = d->selectionModel->selectedIndexes();
- for (int i = 0; i < viewSelected.count(); ++i) {
- const QModelIndex &index = viewSelected.at(i);
- if (!isIndexHidden(index) && index.parent() == d->root && index.column() == d->column)
- ++i;
- else
- viewSelected.removeAt(i);
- }
+ auto ignorable = [this, d](const QModelIndex &index) {
+ return index.column() != d->column || index.parent() != d->root || isIndexHidden(index);
+ };
+ viewSelected.erase(std::remove_if(viewSelected.begin(), viewSelected.end(), ignorable),
+ viewSelected.end());
return viewSelected;
}
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index 1f129e483b..434e819d9c 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -1069,10 +1069,6 @@ void QListWidgetPrivate::setup()
QObject::connect(q, SIGNAL(entered(QModelIndex)), q, SLOT(_q_emitItemEntered(QModelIndex)));
QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
q, SLOT(_q_emitItemChanged(QModelIndex)));
- QObject::connect(q->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
- q, SLOT(_q_emitCurrentItemChanged(QModelIndex,QModelIndex)));
- QObject::connect(q->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
- q, SIGNAL(itemSelectionChanged()));
QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
q, SLOT(_q_dataChanged(QModelIndex,QModelIndex)));
QObject::connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), q, SLOT(_q_sort()));
@@ -1355,6 +1351,31 @@ QListWidget::~QListWidget()
}
/*!
+ \reimp
+*/
+
+void QListWidget::setSelectionModel(QItemSelectionModel *selectionModel)
+{
+ Q_D(QListWidget);
+
+ if (d->selectionModel) {
+ QObject::disconnect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
+ this, SLOT(_q_emitCurrentItemChanged(QModelIndex,QModelIndex)));
+ QObject::disconnect(d->selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+ this, SIGNAL(itemSelectionChanged()));
+ }
+
+ QListView::setSelectionModel(selectionModel);
+
+ if (d->selectionModel) {
+ QObject::connect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
+ this, SLOT(_q_emitCurrentItemChanged(QModelIndex,QModelIndex)));
+ QObject::connect(d->selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+ this, SIGNAL(itemSelectionChanged()));
+ }
+}
+
+/*!
Returns the item that occupies the given \a row in the list if one has been
set; otherwise returns 0.
diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h
index ed85dbac5d..06e2469398 100644
--- a/src/widgets/itemviews/qlistwidget.h
+++ b/src/widgets/itemviews/qlistwidget.h
@@ -207,6 +207,8 @@ public:
explicit QListWidget(QWidget *parent = Q_NULLPTR);
~QListWidget();
+ void setSelectionModel(QItemSelectionModel *selectionModel) Q_DECL_OVERRIDE;
+
QListWidgetItem *item(int row) const;
int row(const QListWidgetItem *item) const;
void insertItem(int row, QListWidgetItem *item);
diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp
index 38b23ec439..03f62582ff 100644
--- a/src/widgets/kernel/qwidgetbackingstore.cpp
+++ b/src/widgets/kernel/qwidgetbackingstore.cpp
@@ -1065,6 +1065,31 @@ static inline bool discardSyncRequest(QWidget *tlw, QTLWExtra *tlwExtra)
return false;
}
+bool QWidgetBackingStore::syncAllowed()
+{
+#ifndef QT_NO_OPENGL
+ QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
+ if (textureListWatcher && !textureListWatcher->isLocked()) {
+ textureListWatcher->deleteLater();
+ textureListWatcher = 0;
+ } else if (!tlwExtra->widgetTextures.isEmpty()) {
+ bool skipSync = false;
+ foreach (QPlatformTextureList *tl, tlwExtra->widgetTextures) {
+ if (tl->isLocked()) {
+ if (!textureListWatcher)
+ textureListWatcher = new QPlatformTextureListWatcher(this);
+ if (!textureListWatcher->isLocked())
+ textureListWatcher->watch(tl);
+ skipSync = true;
+ }
+ }
+ if (skipSync) // cannot compose due to widget textures being in use
+ return false;
+ }
+#endif
+ return true;
+}
+
/*!
Synchronizes the \a exposedRegion of the \a exposedWidget with the backing store.
@@ -1095,7 +1120,8 @@ void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedReg
else
markDirtyOnScreen(exposedRegion, exposedWidget, QPoint());
- doSync();
+ if (syncAllowed())
+ doSync();
}
/*!
@@ -1121,27 +1147,8 @@ void QWidgetBackingStore::sync()
return;
}
-#ifndef QT_NO_OPENGL
- if (textureListWatcher && !textureListWatcher->isLocked()) {
- textureListWatcher->deleteLater();
- textureListWatcher = 0;
- } else if (!tlwExtra->widgetTextures.isEmpty()) {
- bool skipSync = false;
- foreach (QPlatformTextureList *tl, tlwExtra->widgetTextures) {
- if (tl->isLocked()) {
- if (!textureListWatcher)
- textureListWatcher = new QPlatformTextureListWatcher(this);
- if (!textureListWatcher->isLocked())
- textureListWatcher->watch(tl);
- skipSync = true;
- }
- }
- if (skipSync) // cannot compose due to widget textures being in use
- return;
- }
-#endif
-
- doSync();
+ if (syncAllowed())
+ doSync();
}
void QWidgetBackingStore::doSync()
diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h
index d2d4d97841..6e3ba57ced 100644
--- a/src/widgets/kernel/qwidgetbackingstore_p.h
+++ b/src/widgets/kernel/qwidgetbackingstore_p.h
@@ -170,6 +170,8 @@ private:
void updateLists(QWidget *widget);
+ bool syncAllowed();
+
inline void addDirtyWidget(QWidget *widget, const QRegion &rgn)
{
if (widget && !widget->d_func()->inDirtyList && !widget->data->in_destructor) {
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 6b6ca2e9cc..6a3785ea03 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -319,6 +319,14 @@ QPointer<QWidget> qt_last_mouse_receiver = 0;
void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
{
+#if !defined(Q_OS_OSX) && !defined(Q_OS_IOS) // Cocoa tracks popups
+ // Ignore all enter/leave events from QPA if we are not on the first-level context menu.
+ // This prevents duplicated events on most platforms. Fake events will be delivered in
+ // QWidgetWindow::handleMouseEvent(QMouseEvent *). Make an exception whether the widget
+ // is already under mouse - let the mouse leave.
+ if (QApplicationPrivate::inPopupMode() && m_widget != QApplication::activePopupWidget() && !m_widget->underMouse())
+ return;
+#endif
if (event->type() == QEvent::Leave) {
QWidget *enter = 0;
// Check from window system event queue if the next queued enter targets a window
@@ -413,14 +421,13 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
QEvent::MouseButtonRelease : QEvent::MouseButtonPress;
if (qApp->d_func()->inPopupMode()) {
QWidget *activePopupWidget = qApp->activePopupWidget();
- QWidget *popup = activePopupWidget;
QPoint mapped = event->pos();
- if (popup != m_widget)
- mapped = popup->mapFromGlobal(event->globalPos());
+ if (activePopupWidget != m_widget)
+ mapped = activePopupWidget->mapFromGlobal(event->globalPos());
bool releaseAfter = false;
- QWidget *popupChild = popup->childAt(mapped);
+ QWidget *popupChild = activePopupWidget->childAt(mapped);
- if (popup != qt_popup_down) {
+ if (activePopupWidget != qt_popup_down) {
qt_button_down = 0;
qt_popup_down = 0;
}
@@ -429,7 +436,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
qt_button_down = popupChild;
- qt_popup_down = popup;
+ qt_popup_down = activePopupWidget;
break;
case QEvent::MouseButtonRelease:
releaseAfter = true;
@@ -440,18 +447,41 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
int oldOpenPopupCount = openPopupCount;
- if (popup->isEnabled()) {
+ if (activePopupWidget->isEnabled()) {
// deliver event
qt_replay_popup_mouse_event = false;
- QWidget *receiver = popup;
+ QWidget *receiver = activePopupWidget;
QPoint widgetPos = mapped;
if (qt_button_down)
receiver = qt_button_down;
else if (popupChild)
receiver = popupChild;
- if (receiver != popup)
+ if (receiver != activePopupWidget)
widgetPos = receiver->mapFromGlobal(event->globalPos());
- QWidget *alien = m_widget->childAt(m_widget->mapFromGlobal(event->globalPos()));
+ QWidget *alien = receiver;
+
+#if !defined(Q_OS_OSX) && !defined(Q_OS_IOS) // Cocoa tracks popups
+ const bool reallyUnderMouse = activePopupWidget->rect().contains(mapped);
+ const bool underMouse = activePopupWidget->underMouse();
+ if (activePopupWidget != m_widget || (!underMouse && qt_button_down)) {
+ // If active popup menu is not the first-level popup menu then we must emulate enter/leave events,
+ // because first-level popup menu grabs the mouse and enter/leave events are delivered only to it
+ // by QPA. Make an exception for first-level popup menu when the mouse button is pressed on widget.
+ if (underMouse != reallyUnderMouse) {
+ if (reallyUnderMouse) {
+ QApplicationPrivate::dispatchEnterLeave(receiver, Q_NULLPTR, event->screenPos());
+ qt_last_mouse_receiver = receiver;
+ } else {
+ QApplicationPrivate::dispatchEnterLeave(Q_NULLPTR, qt_last_mouse_receiver, event->screenPos());
+ qt_last_mouse_receiver = receiver;
+ receiver = activePopupWidget;
+ }
+ }
+ } else if (!reallyUnderMouse) {
+ alien = Q_NULLPTR;
+ }
+#endif
+
QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(),
event->button(), event->buttons(), event->modifiers(), event->source());
e.setTimestamp(event->timestamp());
@@ -463,7 +493,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
- popup->close();
+ activePopupWidget->close();
break;
default:
break;
@@ -509,7 +539,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
} else if (event->type() == contextMenuTrigger
&& event->button() == Qt::RightButton
&& (openPopupCount == oldOpenPopupCount)) {
- QWidget *popupEvent = popup;
+ QWidget *popupEvent = activePopupWidget;
if (qt_button_down)
popupEvent = qt_button_down;
else if(popupChild)
@@ -718,7 +748,6 @@ void QWidgetWindow::handleCloseEvent(QCloseEvent *event)
{
bool is_closing = m_widget->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
event->setAccepted(is_closing);
- QWindow::event(event); // Call QWindow QCloseEvent handler.
}
#ifndef QT_NO_WHEELEVENT
@@ -728,13 +757,24 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event)
if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
return;
+ QWidget *rootWidget = m_widget;
+ QPoint pos = event->pos();
+
+ // Use proper popup window for wheel event. Some QPA sends the wheel
+ // event to the root menu, so redirect it to the proper popup window.
+ QWidget *activePopupWidget = QApplication::activePopupWidget();
+ if (activePopupWidget && activePopupWidget != m_widget) {
+ rootWidget = activePopupWidget;
+ pos = rootWidget->mapFromGlobal(event->globalPos());
+ }
+
// which child should have it?
- QWidget *widget = m_widget->childAt(event->pos());
+ QWidget *widget = rootWidget->childAt(pos);
if (!widget)
- widget = m_widget;
+ widget = rootWidget;
- QPoint mapped = widget->mapFrom(m_widget, event->pos());
+ QPoint mapped = widget->mapFrom(rootWidget, pos);
QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->angleDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source());
QGuiApplication::sendSpontaneousEvent(widget, &translated);
@@ -961,8 +1001,8 @@ void QWidgetWindow::updateObjectName()
{
QString name = m_widget->objectName();
if (name.isEmpty())
- name = QString::fromUtf8(m_widget->metaObject()->className()) + QStringLiteral("Class");
- name += QStringLiteral("Window");
+ name = QString::fromUtf8(m_widget->metaObject()->className()) + QLatin1String("Class");
+ name += QLatin1String("Window");
setObjectName(name);
}
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 73e28e8230..73e6f69041 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -204,7 +204,7 @@ void QStyleOption::init(const QWidget *widget)
if (!(state & QStyle::State_Active) && !qt_mac_can_clickThrough(widget))
state &= ~QStyle::State_Enabled;
#endif
-#if defined(Q_OS_MACX)
+#if defined(Q_OS_OSX) && !defined(QT_NO_STYLE_MAC)
switch (QMacStyle::widgetSizePolicy(widget)) {
case QMacStyle::SizeSmall:
state |= QStyle::State_Small;
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 46507e3e3c..1cf7591302 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -2444,6 +2444,7 @@ struct IndexSetter {
{
cb->setCurrentIndex(index);
emit cb->activated(index);
+ emit cb->activated(cb->itemText(index));
}
};
}
diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index c24779d61f..29f5913b5d 100644
--- a/src/widgets/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
@@ -73,8 +73,11 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla
\since 5.2
Returns the native NSMenu for this menu. Available on OS X only.
+
+ \note Qt sets the delegate on the native menu. If you need to set your own
+ delegate, make sure you save the original one and forward any calls to it.
*/
-NSMenu* QMenu::toNSMenu()
+NSMenu *QMenu::toNSMenu()
{
// Call into the cocoa platform plugin: qMenuToNSMenu(platformMenu())
QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("qmenutonsmenu");
@@ -139,8 +142,11 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem*
\since 5.2
Returns the native NSMenu for this menu bar. Available on OS X only.
+
+ \note Qt may set the delegate on the native menu bar. If you need to set your
+ own delegate, make sure you save the original one and forward any calls to it.
*/
-NSMenu* QMenuBar::toNSMenu()
+NSMenu *QMenuBar::toNSMenu()
{
// Call into the cocoa platform plugin: qMenuBarToNSMenu(platformMenuBar())
QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("qmenubartonsmenu");
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index e905a416a6..ad7998a198 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -29,9 +29,10 @@ cross_compile: SUBDIRS -= tools cmake installed_cma
!qtHaveModule(printsupport): SUBDIRS -= printsupport
!qtHaveModule(concurrent): SUBDIRS -= concurrent
!qtHaveModule(network): SUBDIRS -= network
+!qtHaveModule(dbus): SUBDIRS -= dbus
# Disable the QtDBus tests if we can't connect to the session bus
-qtHaveModule(dbus) {
+!cross_compile:qtHaveModule(dbus) {
!system("dbus-send --session --type=signal / local.AutotestCheck.Hello >/dev/null 2>&1") {
contains(QT_CONFIG, dbus-linked): \
error("QtDBus is enabled but session bus is not available. Please check the installation.")
@@ -39,6 +40,4 @@ qtHaveModule(dbus) {
warning("QtDBus is enabled with runtime support, but session bus is not available. Skipping QtDBus tests.")
SUBDIRS -= dbus
}
-} else {
- SUBDIRS -= dbus
}
diff --git a/tests/auto/corelib/io/qstandardpaths/BLACKLIST b/tests/auto/corelib/io/qstandardpaths/BLACKLIST
new file mode 100644
index 0000000000..8496a620b3
--- /dev/null
+++ b/tests/auto/corelib/io/qstandardpaths/BLACKLIST
@@ -0,0 +1,2 @@
+[testRuntimeDirectory]
+rhel-7.1
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 540284f0b1..b1b94a3c5f 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -1844,6 +1844,8 @@ void tst_QObject::moveToThread()
thread.wait();
}
+ // WinRT does not allow connection to localhost
+#ifndef Q_OS_WINRT
{
// make sure socket notifiers are moved with the object
MoveToThreadThread thread;
@@ -1879,6 +1881,7 @@ void tst_QObject::moveToThread()
QMetaObject::invokeMethod(socket, "deleteLater", Qt::QueuedConnection);
thread.wait();
}
+#endif
}
diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
index d70ed4f47f..1598382959 100644
--- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
+++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
@@ -126,6 +126,10 @@ signals:
void tst_QSocketNotifier::unexpectedDisconnection()
{
+#ifdef Q_OS_WINRT
+ // WinRT does not allow a connection to the localhost
+ QSKIP("Local connection not allowed", SkipAll);
+#else
/*
Given two sockets and two QSocketNotifiers registered on each
their socket. If both sockets receive data, and the first slot
@@ -191,6 +195,7 @@ void tst_QSocketNotifier::unexpectedDisconnection()
writeEnd1->close();
writeEnd2->close();
server.close();
+#endif // !Q_OS_WINRT
}
class MixingWithTimersHelper : public QObject
@@ -229,6 +234,9 @@ void MixingWithTimersHelper::socketFired()
void tst_QSocketNotifier::mixingWithTimers()
{
+#ifdef Q_OS_WINRT
+ QSKIP("WinRT does not allow connection to localhost", SkipAll);
+#else
QTimer timer;
timer.setInterval(0);
timer.start();
@@ -253,6 +261,7 @@ void tst_QSocketNotifier::mixingWithTimers()
QCOMPARE(helper.timerActivated, true);
QTRY_COMPARE(helper.socketActivated, true);
+#endif // !Q_OS_WINRT
}
#ifdef Q_OS_UNIX
diff --git a/tests/auto/corelib/kernel/qtranslator/qtranslator.pro b/tests/auto/corelib/kernel/qtranslator/qtranslator.pro
index b7a5a85e09..63189e5562 100644
--- a/tests/auto/corelib/kernel/qtranslator/qtranslator.pro
+++ b/tests/auto/corelib/kernel/qtranslator/qtranslator.pro
@@ -5,5 +5,5 @@ SOURCES = tst_qtranslator.cpp
RESOURCES += qtranslator.qrc
android:!android-no-sdk: RESOURCES += android_testdata.qrc
-else: TESTDATA += hellotr_la.qm msgfmt_from_po.qm
+else: TESTDATA += dependencies_la.qm hellotr_la.qm msgfmt_from_po.qm
diff --git a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
index c366b38d57..59ea484355 100644
--- a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
+++ b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
@@ -53,6 +53,7 @@ private slots:
private:
int languageChangeEventCounter;
+ QSharedPointer<QTemporaryDir> dataDir;
};
tst_QTranslator::tst_QTranslator()
@@ -85,8 +86,16 @@ void tst_QTranslator::initTestCase()
// chdir into the directory containing our testdata,
// to make the code simpler (load testdata via relative paths)
+#ifdef Q_OS_WINRT
+ // ### TODO: Use this for all platforms in 5.7
+ dataDir = QEXTRACTTESTDATA(QStringLiteral("/"));
+ QVERIFY2(!dataDir.isNull(), qPrintable("Could not extract test data"));
+ QVERIFY2(QDir::setCurrent(dataDir->path()), qPrintable("Could not chdir to " + dataDir->path()));
+#else // !Q_OS_WINRT
QString testdata_dir = QFileInfo(QFINDTESTDATA("hellotr_la.qm")).absolutePath();
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
+#endif // !Q_OS_WINRT
+
}
bool tst_QTranslator::eventFilter(QObject *, QEvent *event)
diff --git a/tests/auto/gui/image/qimagereader/images/corrupt_clut.bmp b/tests/auto/gui/image/qimagereader/images/corrupt_clut.bmp
new file mode 100644
index 0000000000..aeb063fce5
--- /dev/null
+++ b/tests/auto/gui/image/qimagereader/images/corrupt_clut.bmp
Binary files differ
diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
index 7d353dfb91..bd02dc6255 100644
--- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
@@ -1477,6 +1477,7 @@ void tst_QImageReader::readCorruptImage_data()
QTest::newRow("corrupt gif") << QString("corrupt.gif") << true << QString("") << QByteArray("gif");
QTest::newRow("corrupt png") << QString("corrupt.png") << true << QString("") << QByteArray("png");
QTest::newRow("corrupt bmp") << QString("corrupt.bmp") << true << QString("") << QByteArray("bmp");
+ QTest::newRow("corrupt bmp (clut)") << QString("corrupt_clut.bmp") << true << QString("") << QByteArray("bmp");
QTest::newRow("corrupt xpm (colors)") << QString("corrupt-colors.xpm") << true
<< QString("QImage: XPM color specification is missing: bla9an.n#x")
<< QByteArray("xpm");
diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST
index 774c22a8e9..0622ba30b7 100644
--- a/tests/auto/gui/kernel/qwindow/BLACKLIST
+++ b/tests/auto/gui/kernel/qwindow/BLACKLIST
@@ -1,3 +1,5 @@
+[testInputEvents]
+rhel-7.1
[positioning:default]
ubuntu-14.04
[modalWindowPosition]
@@ -6,3 +8,5 @@ ubuntu-14.04
ubuntu-14.04
[setVisible]
ubuntu-14.04
+[modalWindowEnterEventOnHide_QTBUG35109]
+ubuntu-14.04
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 232571bc1c..892dc0899f 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -92,6 +92,9 @@ private slots:
void modalWithChildWindow();
void modalWindowModallity();
void modalWindowPosition();
+#ifndef QT_NO_CURSOR
+ void modalWindowEnterEventOnHide_QTBUG35109();
+#endif
void windowsTransientChildren();
void requestUpdate();
void initTestCase();
@@ -868,10 +871,24 @@ public:
}
}
}
+ bool event(QEvent *e) {
+ switch (e->type()) {
+ case QEvent::Enter:
+ ++enterEventCount;
+ break;
+ case QEvent::Leave:
+ ++leaveEventCount;
+ break;
+ default:
+ break;
+ }
+ return QWindow::event(e);
+ }
void resetCounters() {
mousePressedCount = mouseReleasedCount = mouseMovedCount = mouseDoubleClickedCount = 0;
mouseSequenceSignature = QString();
touchPressedCount = touchReleasedCount = touchMovedCount = 0;
+ enterEventCount = leaveEventCount = 0;
}
InputTestWindow() {
@@ -889,6 +906,7 @@ public:
QPointF mousePressScreenPos, mouseMoveScreenPos, mousePressLocalPos;
int touchPressedCount, touchReleasedCount, touchMovedCount;
QEvent::Type touchEventType;
+ int enterEventCount, leaveEventCount;
bool ignoreMouse, ignoreTouch;
@@ -1884,6 +1902,181 @@ void tst_QWindow::modalWindowPosition()
QCOMPARE(window.geometry(), origGeo);
}
+#ifndef QT_NO_CURSOR
+void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109()
+{
+ if (QGuiApplication::platformName() == QLatin1String("cocoa"))
+ QSKIP("This test fails on OS X on CI");
+
+ const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center();
+
+ const int childOffset = 16;
+ const QPoint rootPos = center - QPoint(m_testWindowSize.width(),
+ m_testWindowSize.height())/2;
+ const QPoint modalPos = rootPos + QPoint(childOffset * 5,
+ childOffset * 5);
+ const QPoint cursorPos = rootPos - QPoint(80, 80);
+
+ // Test whether tlw can receive the enter event
+ {
+ QCursor::setPos(cursorPos);
+ QCoreApplication::processEvents();
+
+ InputTestWindow root;
+ root.setTitle(__FUNCTION__);
+ root.setGeometry(QRect(rootPos, m_testWindowSize));
+ root.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&root));
+ root.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&root));
+
+ // Move the mouse over the root window, but not over the modal window.
+ QCursor::setPos(rootPos + QPoint(childOffset * 5 / 2,
+ childOffset * 5 / 2));
+
+ // Wait for the enter event. It must be delivered here, otherwise second
+ // compare can PASS because of this event even after "resetCounters()".
+ QTRY_COMPARE(root.enterEventCount, 1);
+ QTRY_COMPARE(root.leaveEventCount, 0);
+
+ QWindow modal;
+ modal.setTitle(QLatin1String("Modal - ") + __FUNCTION__);
+ modal.setTransientParent(&root);
+ modal.resize(m_testWindowSize/2);
+ modal.setFramePosition(modalPos);
+ modal.setModality(Qt::ApplicationModal);
+ modal.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&modal));
+ modal.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&modal));
+
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(root.leaveEventCount, 1);
+
+ root.resetCounters();
+ modal.close();
+
+ // Check for the enter event
+ QTRY_COMPARE(root.enterEventCount, 1);
+ }
+
+ // Test whether child window can receive the enter event
+ {
+ QCursor::setPos(cursorPos);
+ QCoreApplication::processEvents();
+
+ QWindow root;
+ root.setTitle(__FUNCTION__);
+ root.setGeometry(QRect(rootPos, m_testWindowSize));
+
+ QWindow childLvl1;
+ childLvl1.setParent(&root);
+ childLvl1.setGeometry(childOffset,
+ childOffset,
+ m_testWindowSize.width() - childOffset,
+ m_testWindowSize.height() - childOffset);
+
+ InputTestWindow childLvl2;
+ childLvl2.setParent(&childLvl1);
+ childLvl2.setGeometry(childOffset,
+ childOffset,
+ childLvl1.width() - childOffset,
+ childLvl1.height() - childOffset);
+
+ root.show();
+ childLvl1.show();
+ childLvl2.show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(&root));
+ root.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&root));
+ QVERIFY(childLvl1.isVisible());
+ QVERIFY(childLvl2.isVisible());
+
+ // Move the mouse over the child window, but not over the modal window.
+ // Be sure that the value is almost left-top of second child window for
+ // checking proper position mapping.
+ QCursor::setPos(rootPos + QPoint(childOffset * 5 / 2,
+ childOffset * 5 / 2));
+
+ // Wait for the enter event. It must be delivered here, otherwise second
+ // compare can PASS because of this event even after "resetCounters()".
+ QTRY_COMPARE(childLvl2.enterEventCount, 1);
+ QTRY_COMPARE(childLvl2.leaveEventCount, 0);
+
+ QWindow modal;
+ modal.setTitle(QLatin1String("Modal - ") + __FUNCTION__);
+ modal.setTransientParent(&root);
+ modal.resize(m_testWindowSize/2);
+ modal.setFramePosition(modalPos);
+ modal.setModality(Qt::ApplicationModal);
+ modal.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&modal));
+ modal.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&modal));
+
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(childLvl2.leaveEventCount, 1);
+
+ childLvl2.resetCounters();
+ modal.close();
+
+ // Check for the enter event
+ QTRY_COMPARE(childLvl2.enterEventCount, 1);
+ }
+
+ // Test whether tlw can receive the enter event if mouse is over the invisible child windnow
+ {
+ QCursor::setPos(cursorPos);
+ QCoreApplication::processEvents();
+
+ InputTestWindow root;
+ root.setTitle(__FUNCTION__);
+ root.setGeometry(QRect(rootPos, m_testWindowSize));
+
+ QWindow child;
+ child.setParent(&root);
+ child.setGeometry(QRect(QPoint(), m_testWindowSize));
+
+ root.show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(&root));
+ root.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&root));
+ QVERIFY(!child.isVisible());
+
+ // Move the mouse over the child window, but not over the modal window.
+ QCursor::setPos(rootPos + QPoint(childOffset * 5 / 2,
+ childOffset * 5 / 2));
+
+ // Wait for the enter event. It must be delivered here, otherwise second
+ // compare can PASS because of this event even after "resetCounters()".
+ QTRY_COMPARE(root.enterEventCount, 1);
+ QTRY_COMPARE(root.leaveEventCount, 0);
+
+ QWindow modal;
+ modal.setTitle(QLatin1String("Modal - ") + __FUNCTION__);
+ modal.setTransientParent(&root);
+ modal.resize(m_testWindowSize/2);
+ modal.setFramePosition(modalPos);
+ modal.setModality(Qt::ApplicationModal);
+ modal.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&modal));
+ modal.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&modal));
+
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(root.leaveEventCount, 1);
+
+ root.resetCounters();
+ modal.close();
+
+ // Check for the enter event
+ QTRY_COMPARE(root.enterEventCount, 1);
+ }
+}
+#endif
+
static bool isNativeWindowVisible(const QWindow *window)
{
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
index 4b3d709812..7c60c8c9f8 100644
--- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
+++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
@@ -65,6 +65,7 @@ private slots:
void setRawDataAndGetAsVector();
void boundingRect();
void mixedScripts();
+ void multiLineBoundingRect();
private:
int m_testFontId;
@@ -730,6 +731,34 @@ void tst_QGlyphRun::mixedScripts()
QCOMPARE(glyphRuns.size(), 2);
}
+void tst_QGlyphRun::multiLineBoundingRect()
+{
+ QTextLayout layout;
+ layout.setText("Foo Bar");
+ layout.beginLayout();
+
+ QTextLine line = layout.createLine();
+ line.setNumColumns(4);
+ line.setPosition(QPointF(0, 0));
+
+ line = layout.createLine();
+ line.setPosition(QPointF(0, 10));
+
+ layout.endLayout();
+
+ QCOMPARE(layout.lineCount(), 2);
+
+ QList<QGlyphRun> firstLineGlyphRuns = layout.lineAt(0).glyphRuns();
+ QList<QGlyphRun> allGlyphRuns = layout.glyphRuns();
+ QCOMPARE(firstLineGlyphRuns.size(), 1);
+ QCOMPARE(allGlyphRuns.size(), 1);
+
+ QGlyphRun firstLineGlyphRun = firstLineGlyphRuns.first();
+ QGlyphRun allGlyphRun = allGlyphRuns.first();
+
+ QVERIFY(firstLineGlyphRun.boundingRect().height() < allGlyphRun.boundingRect().height());
+}
+
#endif // QT_NO_RAWFONT
QTEST_MAIN(tst_QGlyphRun)
diff --git a/tests/auto/opengl/qgl/BLACKLIST b/tests/auto/opengl/qgl/BLACKLIST
index fa7c829b30..547a9a2a73 100644
--- a/tests/auto/opengl/qgl/BLACKLIST
+++ b/tests/auto/opengl/qgl/BLACKLIST
@@ -1,3 +1,5 @@
+[]
+rhel-7.1
[glWidgetRendering]
windows
[glFBORendering]
diff --git a/tests/auto/other/gestures/BLACKLIST b/tests/auto/other/gestures/BLACKLIST
index 4e8745ca78..28e4856056 100644
--- a/tests/auto/other/gestures/BLACKLIST
+++ b/tests/auto/other/gestures/BLACKLIST
@@ -1,2 +1,4 @@
+[]
+rhel-7.1
[customGesture]
opensuse-13.1
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 023f800d29..99e3fc5bf2 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -1411,6 +1411,7 @@ void tst_QAccessibility::menuTest()
{
QMainWindow mw;
mw.resize(300, 200);
+ mw.menuBar()->setNativeMenuBar(false);
QMenu *file = mw.menuBar()->addMenu("&File");
QMenu *fileNew = file->addMenu("&New...");
fileNew->menuAction()->setShortcut(tr("Ctrl+N"));
diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index b4f403fc0c..799b93c33b 100644
--- a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -104,7 +104,7 @@ void tst_QSqlRelationalTableModel::recreateTestTables(QSqlDatabase db)
QVERIFY_SQL( q, exec("insert into " + reltest1 + " values(5, 'nat', NULL, NULL)"));
QVERIFY_SQL( q, exec("insert into " + reltest1 + " values(6, 'ale', NULL, 2)"));
- QVERIFY_SQL( q, exec("create table " + reltest2 + " (tid int not null primary key, title varchar(20))"));
+ QVERIFY_SQL( q, exec("create table " + reltest2 + " (id int not null primary key, title varchar(20))"));
QVERIFY_SQL( q, exec("insert into " + reltest2 + " values(1, 'herr')"));
QVERIFY_SQL( q, exec("insert into " + reltest2 + " values(2, 'mister')"));
@@ -196,7 +196,7 @@ void tst_QSqlRelationalTableModel::data()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.columnCount(), 4);
@@ -241,7 +241,7 @@ void tst_QSqlRelationalTableModel::setData()
model.setTable(reltest1);
model.setSort(0, Qt::AscendingOrder);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QVERIFY(model.setData(model.index(0, 1), QString("harry2")));
@@ -271,7 +271,7 @@ void tst_QSqlRelationalTableModel::setData()
QCOMPARE(model.data(model.index(3, 1)).toString(), QString("boris2"));
QCOMPARE(model.data(model.index(3, 2)).toInt(), 1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
QCOMPARE(model.data(model.index(3,2)).toString(), QString("herr"));
@@ -284,7 +284,7 @@ void tst_QSqlRelationalTableModel::setData()
model.setTable(reltest1);
model.setEditStrategy(QSqlTableModel::OnFieldChange);
model.setSort(0, Qt::AscendingOrder);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QVERIFY(model.setData(model.index(1,1), QString("trond2")));
@@ -302,7 +302,7 @@ void tst_QSqlRelationalTableModel::setData()
QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond2"));
QCOMPARE(model.data(model.index(2, 2)).toInt(), 2);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(2, 2)).toString(), QString("mister"));
}
@@ -312,12 +312,12 @@ void tst_QSqlRelationalTableModel::setData()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
//sybase doesn't allow tables with the same alias used twice as col names
//so don't set up an identical relation when using the tds driver
if (dbType != QSqlDriver::Sybase)
- model.setRelation(3, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(3, QSqlRelation(reltest2, "id", "title"));
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
model.setSort(0, Qt::AscendingOrder);
@@ -346,9 +346,9 @@ void tst_QSqlRelationalTableModel::setData()
QCOMPARE(model.data(model.index(3, 2)).toInt(), 1);
QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
if (dbType != QSqlDriver::Sybase)
- model.setRelation(3, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(3, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
@@ -406,7 +406,7 @@ void tst_QSqlRelationalTableModel::multipleRelation()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
model.setRelation(3, QSqlRelation(reltest4, "id", "name"));
model.setSort(0, Qt::AscendingOrder);
QVERIFY_SQL(model, select());
@@ -420,7 +420,7 @@ void tst_QSqlRelationalTableModel::multipleRelation()
// Redo same test in the LeftJoin mode
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
model.setRelation(3, QSqlRelation(reltest4, "id", "name"));
model.setSort(0, Qt::AscendingOrder);
model.setJoinMode(QSqlRelationalTableModel::LeftJoin);
@@ -443,7 +443,7 @@ void tst_QSqlRelationalTableModel::insertRecord()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
model.setSort(0, Qt::AscendingOrder);
QVERIFY_SQL(model, select());
@@ -493,7 +493,7 @@ void tst_QSqlRelationalTableModel::setRecord()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
model.setSort(0, Qt::AscendingOrder);
QVERIFY_SQL(model, select());
@@ -554,11 +554,11 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
model.setSort(0, Qt::AscendingOrder);
if (dbType != QSqlDriver::Sybase)
- model.setRelation(3, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(3, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(0,0)).toInt(), 1);
@@ -662,7 +662,7 @@ void tst_QSqlRelationalTableModel::removeColumn()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QVERIFY_SQL(model, removeColumn(3));
@@ -688,7 +688,7 @@ void tst_QSqlRelationalTableModel::removeColumn()
QSqlRelationalTableModel lmodel(0, db);
lmodel.setTable(reltest1);
- lmodel.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ lmodel.setRelation(2, QSqlRelation(reltest2, "id", "title"));
lmodel.setJoinMode(QSqlRelationalTableModel::LeftJoin);
QVERIFY_SQL(lmodel, select());
@@ -719,7 +719,7 @@ void tst_QSqlRelationalTableModel::filter()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
model.setFilter("title = 'herr'");
QVERIFY_SQL(model, select());
@@ -746,9 +746,9 @@ void tst_QSqlRelationalTableModel::sort()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
if (dbType != QSqlDriver::Sybase)
- model.setRelation(3, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(3, QSqlRelation(reltest2, "id", "title"));
model.setSort(2, Qt::DescendingOrder);
QVERIFY_SQL(model, select());
@@ -874,7 +874,7 @@ void tst_QSqlRelationalTableModel::revert()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
model.setRelation(3, QSqlRelation(reltest4, "id", "name"));
model.setSort(0, Qt::AscendingOrder);
@@ -912,10 +912,10 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
if (dbType != QSqlDriver::Sybase)
- model.setRelation(3, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(3, QSqlRelation(reltest2, "id", "title"));
model.setSort(1, Qt::AscendingOrder);
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
@@ -1013,7 +1013,7 @@ void tst_QSqlRelationalTableModel::invalidData()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
//try set a non-existent relational key
@@ -1043,7 +1043,7 @@ void tst_QSqlRelationalTableModel::relationModel()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QVERIFY(!model.relationModel(0));
@@ -1137,7 +1137,7 @@ void tst_QSqlRelationalTableModel::casing()
QSqlRelationalTableModel model(0, db);
model.setTable(qTableName("CASETEST1", db).toUpper());
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
@@ -1160,11 +1160,11 @@ void tst_QSqlRelationalTableModel::escapedRelations()
//try with relation table name quoted
if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) {
model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(reltest2.toUpper(),QSqlDriver::TableName),
- "tid",
+ "id",
"title"));
} else {
model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(reltest2,QSqlDriver::TableName),
- "tid",
+ "id",
"title"));
}
@@ -1185,11 +1185,11 @@ void tst_QSqlRelationalTableModel::escapedRelations()
model.setJoinMode(QSqlRelationalTableModel::InnerJoin);
if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) {
model.setRelation(2, QSqlRelation(reltest2,
- db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName).toUpper(),
+ db.driver()->escapeIdentifier("id", QSqlDriver::FieldName).toUpper(),
"title"));
} else {
model.setRelation(2, QSqlRelation(reltest2,
- db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName),
+ db.driver()->escapeIdentifier("id", QSqlDriver::FieldName),
"title"));
}
QVERIFY_SQL(model, select());
@@ -1210,11 +1210,11 @@ void tst_QSqlRelationalTableModel::escapedRelations()
if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) {
model.setRelation(2, QSqlRelation(reltest2,
- "tid",
+ "id",
db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper()));
} else {
model.setRelation(2, QSqlRelation(reltest2,
- "tid",
+ "id",
db.driver()->escapeIdentifier("title", QSqlDriver::FieldName)));
}
@@ -1235,11 +1235,11 @@ void tst_QSqlRelationalTableModel::escapedRelations()
model.setJoinMode(QSqlRelationalTableModel::InnerJoin);
if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2) {
model.setRelation(2, QSqlRelation(reltest2,
- "tid",
+ "id",
db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper()));
} else {
model.setRelation(2, QSqlRelation(reltest2,
- "tid",
+ "id",
db.driver()->escapeIdentifier("title", QSqlDriver::FieldName)));
}
QVERIFY_SQL(model, select());
@@ -1273,7 +1273,7 @@ void tst_QSqlRelationalTableModel::escapedTableName()
model.setTable(db.driver()->escapeIdentifier(reltest1, QSqlDriver::TableName));
}
model.setSort(0, Qt::AscendingOrder);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QVERIFY(model.setData(model.index(0, 1), QString("harry2")));
@@ -1303,7 +1303,7 @@ void tst_QSqlRelationalTableModel::escapedTableName()
QCOMPARE(model.data(model.index(3, 1)).toString(), QString("boris2"));
QCOMPARE(model.data(model.index(3, 2)).toInt(), 1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
QCOMPARE(model.data(model.index(3,2)).toString(), QString("herr"));
@@ -1320,7 +1320,7 @@ void tst_QSqlRelationalTableModel::escapedTableName()
model.setTable(db.driver()->escapeIdentifier(reltest1, QSqlDriver::TableName));
}
model.setSort(0, Qt::AscendingOrder);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
model.setJoinMode(QSqlRelationalTableModel::LeftJoin);
QVERIFY_SQL(model, select());
@@ -1352,7 +1352,7 @@ void tst_QSqlRelationalTableModel::escapedTableName()
QCOMPARE(model.data(model.index(3, 1)).toString(), QString("boris2"));
QCOMPARE(model.data(model.index(3, 2)).toInt(), 1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
QCOMPARE(model.data(model.index(3,2)).toString(), QString("herr"));
@@ -1480,7 +1480,7 @@ void tst_QSqlRelationalTableModel::selectAfterUpdate()
QSqlRelationalTableModel model(0, db);
model.setTable(reltest1);
- model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
+ model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.relationModel(2)->rowCount(), 2);
{
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index 94002ec75b..0806077031 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -543,6 +543,7 @@ static QProcessEnvironment processEnvironment()
static QProcessEnvironment result;
if (result.isEmpty()) {
const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment();
+ const bool preserveLibPath = qEnvironmentVariableIsSet("QT_PRESERVE_TESTLIB_PATH");
foreach (const QString &key, systemEnvironment.keys()) {
const bool useVariable = key == QLatin1String("PATH") || key == QLatin1String("QT_QPA_PLATFORM")
#if defined(Q_OS_QNX)
@@ -557,6 +558,8 @@ static QProcessEnvironment processEnvironment()
#ifdef __COVERAGESCANNER__
|| key == QLatin1String("QT_TESTCOCOON_ACTIVE")
#endif
+ || ( preserveLibPath && (key == QLatin1String("QT_PLUGIN_PATH")
+ || key == QLatin1String("LD_LIBRARY_PATH")))
;
if (useVariable)
result.insert(key, systemEnvironment.value(key));
diff --git a/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST
index 6d3c17f35f..5fd026537e 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST
+++ b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST
@@ -1,5 +1,7 @@
[task256466_wrongStyle]
opensuse-13.1
+rhel-7.1
[setFont]
ubuntu-14.04
redhatenterpriselinuxworkstation-6.6
+rhel-7.1
diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST b/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST
index 7f55c2dae0..14c41711ac 100644
--- a/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST
+++ b/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST
@@ -1,2 +1,8 @@
[panGesture:Two finger]
xcb
+[swipeGesture:SmallDirectionChange]
+rhel-7.1
+[swipeGesture:Line]
+rhel-7.1
+[pinchGesture:Standard]
+rhel-7.1
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST
index 717c791280..373343fa22 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST
@@ -1,2 +1,5 @@
[hoverEnterLeaveEvent]
ubuntu-14.04
+rhel-7.1
+[QTBUG_6986_sendMouseEventToAlienWidget]
+rhel-7.1
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST
index 5db5c97917..c8d93585b2 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST
@@ -1,2 +1,3 @@
[initialShow2]
ubuntu-14.04
+rhel-7.1
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index 5058dd2a81..651172e79f 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -149,6 +149,7 @@ private slots:
void taskQTBUG_39902_mutualScrollBars();
void horizontalScrollingByVerticalWheelEvents();
void taskQTBUG_7232_AllowUserToControlSingleStep();
+ void taskQTBUG_51086_skippingIndexesInSelectedIndexes();
};
// Testing get/set functions
@@ -2492,5 +2493,32 @@ void tst_QListView::taskQTBUG_7232_AllowUserToControlSingleStep()
QCOMPARE(hStep1, lv.horizontalScrollBar()->singleStep());
}
+void tst_QListView::taskQTBUG_51086_skippingIndexesInSelectedIndexes()
+{
+ // simple way to get access to selectedIndexes()
+ class QListViewWithPublicSelectedIndexes : public QListView
+ {
+ public:
+ using QListView::selectedIndexes;
+ };
+
+ QStandardItemModel data(10, 1);
+ QItemSelectionModel selections(&data);
+ QListViewWithPublicSelectedIndexes list;
+ list.setModel(&data);
+ list.setSelectionModel(&selections);
+
+ list.setRowHidden(7, true);
+ list.setRowHidden(8, true);
+
+ for (int i = 0, count = data.rowCount(); i < count; ++i)
+ selections.select(data.index(i, 0), QItemSelectionModel::Select);
+
+ const QModelIndexList indexes = list.selectedIndexes();
+
+ QVERIFY(!indexes.contains(data.index(7, 0)));
+ QVERIFY(!indexes.contains(data.index(8, 0)));
+}
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index 84b00147ca..e8bd86bee5 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -115,6 +115,7 @@ private slots:
void QTBUG8086_currentItemChangedOnClick();
void QTBUG14363_completerWithAnyKeyPressedEditTriggers();
void mimeData();
+ void QTBUG50891_ensureSelectionModelSignalConnectionsAreSet();
protected slots:
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last)
@@ -1700,5 +1701,30 @@ void tst_QListWidget::mimeData()
delete data2;
}
+void tst_QListWidget::QTBUG50891_ensureSelectionModelSignalConnectionsAreSet()
+{
+ qRegisterMetaType<QListWidgetItem*>("QListWidgetItem*");
+ QListWidget list;
+ for (int i = 0 ; i < 4; ++i)
+ new QListWidgetItem(QString::number(i), &list);
+
+ list.setSelectionModel(new QItemSelectionModel(list.model()));
+ list.show();
+
+ QSignalSpy currentItemChangedSpy(&list, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)));
+ QSignalSpy itemSelectionChangedSpy(&list, SIGNAL(itemSelectionChanged()));
+
+ QVERIFY(QTest::qWaitForWindowExposed(&list));
+
+ QCOMPARE(currentItemChangedSpy.count(), 0);
+ QCOMPARE(itemSelectionChangedSpy.count(), 0);
+
+ QTest::mouseClick(list.viewport(), Qt::LeftButton, 0, list.visualItemRect(list.item(2)).center());
+
+ QCOMPARE(currentItemChangedSpy.count(), 1);
+ QCOMPARE(itemSelectionChangedSpy.count(), 1);
+
+}
+
QTEST_MAIN(tst_QListWidget)
#include "tst_qlistwidget.moc"
diff --git a/tests/auto/widgets/itemviews/qtreeview/BLACKLIST b/tests/auto/widgets/itemviews/qtreeview/BLACKLIST
new file mode 100644
index 0000000000..5eb80007c4
--- /dev/null
+++ b/tests/auto/widgets/itemviews/qtreeview/BLACKLIST
@@ -0,0 +1,2 @@
+[setSortingEnabledChild]
+windows
diff --git a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro
index e8406dab7b..3abd58e73d 100644
--- a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro
+++ b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro
@@ -4,5 +4,3 @@ QT += widgets testlib
QT += widgets-private gui-private core-private
SOURCES += tst_qtreeview.cpp
HEADERS += ../../../../shared/fakedirmodel.h
-
-win32: CONFIG += insignificant_test
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 137f18e23a..938c8a47ac 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -189,7 +189,8 @@ private slots:
void hiddenItems();
void spanningItems();
void rowSizeHint();
- void setSortingEnabled();
+ void setSortingEnabledTopLevel();
+ void setSortingEnabledChild();
void headerHidden();
void indentation();
@@ -2501,33 +2502,31 @@ void tst_QTreeView::rowSizeHint()
//From task 155449 (QTreeWidget has a large width for the first section when sorting
//is turned on before items are added)
-void tst_QTreeView::setSortingEnabled()
+
+void tst_QTreeView::setSortingEnabledTopLevel()
{
- //1st the treeview is a top-level
- {
- QTreeView view;
- QStandardItemModel model(1,1);
- view.setModel(&model);
- const int size = view.header()->sectionSize(0);
- view.setSortingEnabled(true);
- model.setColumnCount(3);
- //we test that changing the column count doesn't change the 1st column size
- QCOMPARE(view.header()->sectionSize(0), size);
- }
+ QTreeView view;
+ QStandardItemModel model(1,1);
+ view.setModel(&model);
+ const int size = view.header()->sectionSize(0);
+ view.setSortingEnabled(true);
+ model.setColumnCount(3);
+ //we test that changing the column count doesn't change the 1st column size
+ QCOMPARE(view.header()->sectionSize(0), size);
+}
- //then it is no more a top-level
- {
- QMainWindow win;
- QTreeView view;
- QStandardItemModel model(1,1);
- view.setModel(&model);
- win.setCentralWidget(&view);
- const int size = view.header()->sectionSize(0);
- view.setSortingEnabled(true);
- model.setColumnCount(3);
- //we test that changing the column count doesn't change the 1st column size
- QCOMPARE(view.header()->sectionSize(0), size);
- }
+void tst_QTreeView::setSortingEnabledChild()
+{
+ QMainWindow win;
+ QTreeView view;
+ QStandardItemModel model(1,1);
+ view.setModel(&model);
+ win.setCentralWidget(&view);
+ const int size = view.header()->sectionSize(0);
+ view.setSortingEnabled(true);
+ model.setColumnCount(3);
+ //we test that changing the column count doesn't change the 1st column size
+ QCOMPARE(view.header()->sectionSize(0), size);
}
void tst_QTreeView::headerHidden()
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 78ccbe302a..8d18d40e05 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -10,6 +10,7 @@ ubuntu-14.04
osx
[updateWhileMinimized]
ubuntu-14.04
+rhel-7.1
osx
[focusProxyAndInputMethods]
linux
@@ -31,6 +32,7 @@ osx
osx
[widgetAt]
osx
+rhel-7.1
[sheetOpacity]
osx
[resizeEvent]
@@ -63,8 +65,10 @@ osx
osx
[taskQTBUG_4055_sendSyntheticEnterLeave]
osx
+rhel-7.1
[syntheticEnterLeave]
osx
+rhel-7.1
[maskedUpdate]
osx
[hideWhenFocusWidgetIsChild]
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index 0fbe5bc86b..607fc1625a 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -492,9 +492,10 @@ void tst_QMdiArea::subWindowActivated2()
spy.clear();
mdiArea.show();
- QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
+ QVERIFY(QTest::qWaitForWindowActive(&mdiArea));
QTRY_COMPARE(spy.count(), 1);
- QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
+ QVERIFY(mdiArea.currentSubWindow());
+ QTRY_COMPARE(mdiArea.activeSubWindow(), activeSubWindow);
spy.clear();
if (qGuiApp->styleHints()->showIsFullScreen())
@@ -632,7 +633,7 @@ void tst_QMdiArea::changeWindowTitle()
mw->setWindowTitle( mwc );
QMdiArea *ws = new QMdiArea( mw );
mw->setCentralWidget( ws );
- mw->menuBar();
+ mw->menuBar()->setNativeMenuBar(false);
mw->show();
QVERIFY(QTest::qWaitForWindowExposed(mw));
@@ -741,7 +742,7 @@ void tst_QMdiArea::changeModified()
mw->setWindowTitle( mwc );
QMdiArea *ws = new QMdiArea( mw );
mw->setCentralWidget( ws );
- mw->menuBar();
+ mw->menuBar()->setNativeMenuBar(false);
mw->show();
QWidget *widget = new QWidget( ws );
@@ -2006,6 +2007,7 @@ void tst_QMdiArea::iconGeometryInMenuBar()
#if !defined (Q_OS_MAC) && !defined(Q_OS_WINCE)
QMainWindow mainWindow;
QMenuBar *menuBar = mainWindow.menuBar();
+ menuBar->setNativeMenuBar(false);
QMdiArea *mdiArea = new QMdiArea;
QMdiSubWindow *subWindow = mdiArea->addSubWindow(new QWidget);
mainWindow.setCentralWidget(mdiArea);
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/BLACKLIST b/tests/auto/widgets/widgets/qmdisubwindow/BLACKLIST
new file mode 100644
index 0000000000..a10cf663d0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmdisubwindow/BLACKLIST
@@ -0,0 +1,2 @@
+[setSystemMenu]
+rhel-7.1
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index b58d33ab4a..fe5c3a14a0 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -967,7 +967,7 @@ void tst_QMdiSubWindow::setSystemMenu()
QMdiArea *mdiArea = new QMdiArea;
mdiArea->addSubWindow(subWindow);
mainWindow.setCentralWidget(mdiArea);
- mainWindow.menuBar();
+ mainWindow.menuBar()->setNativeMenuBar(false);
mainWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
QTest::qWait(60);
@@ -1467,6 +1467,7 @@ void tst_QMdiSubWindow::hideAndShow()
QMainWindow mainWindow;
mainWindow.setGeometry(0, 0, 640, 480);
QMenuBar *menuBar = mainWindow.menuBar();
+ menuBar->setNativeMenuBar(false);
mainWindow.setCentralWidget(tabWidget);
mainWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
@@ -1735,6 +1736,7 @@ void tst_QMdiSubWindow::replaceMenuBarWhileMaximized()
mainWindow.setCentralWidget(mdiArea);
QMenuBar *menuBar = mainWindow.menuBar();
+ menuBar->setNativeMenuBar(false);
mainWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
@@ -1751,6 +1753,7 @@ void tst_QMdiSubWindow::replaceMenuBarWhileMaximized()
// Replace.
mainWindow.setMenuBar(new QMenuBar);
menuBar = mainWindow.menuBar();
+ menuBar->setNativeMenuBar(false);
qApp->processEvents();
QVERIFY(subWindow->maximizedButtonsWidget());
diff --git a/tests/auto/widgets/widgets/qmenu/BLACKLIST b/tests/auto/widgets/widgets/qmenu/BLACKLIST
index de49d5ff45..dbc3e26837 100644
--- a/tests/auto/widgets/widgets/qmenu/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmenu/BLACKLIST
@@ -1,2 +1,5 @@
[task258920_mouseBorder]
osx
+rhel-7.1
+[pushButtonPopulateOnAboutToShow]
+rhel-7.1
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index a04978341b..17efc05f59 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -105,6 +105,9 @@ private slots:
void QTBUG7411_submenus_activate();
void QTBUG30595_rtl_submenu();
void QTBUG20403_nested_popup_on_shortcut_trigger();
+#ifndef QT_NO_CURSOR
+ void QTBUG47515_widgetActionEnterLeave();
+#endif
void QTBUG_10735_crashWithDialog();
#ifdef Q_OS_MAC
void QTBUG_37933_ampersands_data();
@@ -447,6 +450,7 @@ void tst_QMenu::overrideMenuAction()
//test the override menu action by first creating an action to which we set its menu
QMainWindow w;
w.resize(300, 200);
+ w.menuBar()->setNativeMenuBar(false);
centerOnScreen(&w);
QAction *aFileMenu = new QAction("&File", &w);
@@ -1065,6 +1069,112 @@ void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger()
QVERIFY(!subsub1.isVisible());
}
+class MyWidget : public QWidget
+{
+public:
+ MyWidget(QWidget *parent) :
+ QWidget(parent),
+ move(0), enter(0), leave(0)
+ {
+ setMinimumSize(100, 100);
+ setMouseTracking(true);
+ }
+
+ bool event(QEvent *e) Q_DECL_OVERRIDE
+ {
+ switch (e->type()) {
+ case QEvent::MouseMove:
+ ++move;
+ break;
+ case QEvent::Enter:
+ ++enter;
+ break;
+ case QEvent::Leave:
+ ++leave;
+ break;
+ default:
+ break;
+ }
+ return QWidget::event(e);
+ }
+
+ int move, enter, leave;
+};
+
+#ifndef QT_NO_CURSOR
+void tst_QMenu::QTBUG47515_widgetActionEnterLeave()
+{
+ if (QGuiApplication::platformName() == QLatin1String("cocoa"))
+ QSKIP("This test fails on OS X on CI");
+
+ const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center();
+ const QPoint cursorPos = center - QPoint(100, 100);
+
+ QScopedPointer<QMenu> menu1(new QMenu("Menu1"));
+ QScopedPointer<QMenu> menu2(new QMenu("Menu2"));
+
+ QWidgetAction *wA1 = new QWidgetAction(menu1.data());
+ MyWidget *w1 = new MyWidget(menu1.data());
+ wA1->setDefaultWidget(w1);
+
+ QWidgetAction *wA2 = new QWidgetAction(menu2.data());
+ MyWidget *w2 = new MyWidget(menu2.data());
+ wA2->setDefaultWidget(w2);
+
+ QAction *nextMenuAct = menu1->addMenu(menu2.data());
+
+ menu1->addAction(wA1);
+ menu2->addAction(wA2);
+
+ // Root menu
+ {
+ QCursor::setPos(cursorPos);
+ QCoreApplication::processEvents();
+
+ menu1->popup(center);
+ QVERIFY(QTest::qWaitForWindowExposed(menu1.data()));
+
+ QCursor::setPos(w1->mapToGlobal(w1->rect().center()));
+ QVERIFY(w1->isVisible());
+ QTRY_COMPARE(w1->leave, 0);
+ QTRY_COMPARE(w1->enter, 1);
+
+ // Check whether leave event is not delivered on mouse move
+ w1->move = 0;
+ QCursor::setPos(w1->mapToGlobal(w1->rect().center()) + QPoint(1, 1));
+ QTRY_COMPARE(w1->move, 1);
+ QTRY_COMPARE(w1->leave, 0);
+ QTRY_COMPARE(w1->enter, 1);
+
+ QCursor::setPos(cursorPos);
+ QTRY_COMPARE(w1->leave, 1);
+ QTRY_COMPARE(w1->enter, 1);
+ }
+
+ // Submenu
+ {
+ menu1->setActiveAction(nextMenuAct);
+ QVERIFY(QTest::qWaitForWindowExposed(menu2.data()));
+
+ QCursor::setPos(w2->mapToGlobal(w2->rect().center()));
+ QVERIFY(w2->isVisible());
+ QTRY_COMPARE(w2->leave, 0);
+ QTRY_COMPARE(w2->enter, 1);
+
+ // Check whether leave event is not delivered on mouse move
+ w2->move = 0;
+ QCursor::setPos(w2->mapToGlobal(w2->rect().center()) + QPoint(1, 1));
+ QTRY_COMPARE(w2->move, 1);
+ QTRY_COMPARE(w2->leave, 0);
+ QTRY_COMPARE(w2->enter, 1);
+
+ QCursor::setPos(cursorPos);
+ QTRY_COMPARE(w2->leave, 1);
+ QTRY_COMPARE(w2->enter, 1);
+ }
+}
+#endif // !QT_NO_CURSOR
+
class MyMenu : public QMenu
{
Q_OBJECT
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index ad7638650b..3bcdea3137 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -206,6 +206,7 @@ void tst_QMenuBar::cleanup()
TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb)
{
TestMenu result;
+ mb->setNativeMenuBar(false);
connect(mb, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*)));
QMenu *menu = mb->addMenu(QStringLiteral("&accel"));
QAction *action = menu->addAction(QStringLiteral("menu1") );
@@ -273,6 +274,7 @@ void tst_QMenuBar::onComplexActionTriggered()
TestMenu tst_QMenuBar::initComplexMenuBar(QMenuBar *mb)
{
TestMenu result;
+ mb->setNativeMenuBar(false);
QMenu *menu = addNumberedMenu(mb, 1);
result.menus << menu;
for (char c = 'a'; c < 'c'; ++c)
@@ -986,6 +988,7 @@ void tst_QMenuBar::check_altClosePress()
QMainWindow w;
w.setWindowTitle(QTest::currentTestFunction());
+ w.menuBar()->setNativeMenuBar(false);
QMenu *menuFile = w.menuBar()->addMenu(tr("&File"));
menuFile->addAction("Quit");
QMenu *menuEdit = w.menuBar()->addMenu(tr("&Edit"));
@@ -1061,6 +1064,7 @@ void tst_QMenuBar::check_menuPosition()
menu.addAction("item");
}
+ w.menuBar()->setNativeMenuBar(false);
QAction *menu_action = w.menuBar()->addMenu(&menu);
centerOnScreen(&w);
w.show();
@@ -1394,6 +1398,7 @@ void tst_QMenuBar::cornerWidgets()
widget.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + dataTag);
QVBoxLayout *layout = new QVBoxLayout(&widget);
QMenuBar *menuBar = new QMenuBar(&widget);
+ menuBar->setNativeMenuBar(false);
layout->addWidget(menuBar);
QMenu *fileMenu = menuBar->addMenu("File");
fileMenu->addAction("Quit");
diff --git a/tests/manual/qopenglwidget/openglwidget/main.cpp b/tests/manual/qopenglwidget/openglwidget/main.cpp
index 44ed45c2a2..d2c11fdfd1 100644
--- a/tests/manual/qopenglwidget/openglwidget/main.cpp
+++ b/tests/manual/qopenglwidget/openglwidget/main.cpp
@@ -176,6 +176,13 @@ int main(int argc, char *argv[])
glw3->setObjectName("GL widget in scroll area (possibly native)");
glw3->setFormat(format);
glw3->setFixedSize(600, 600);
+ OpenGLWidget *glw3child = new OpenGLWidget(0);
+ const float glw3ClearColor[] = { 0.5f, 0.2f, 0.8f };
+ glw3child->setClearColor(glw3ClearColor);
+ glw3child->setObjectName("Child widget of GL Widget in scroll area");
+ glw3child->setFormat(format);
+ glw3child->setParent(glw3);
+ glw3child->setGeometry(500, 500, 100, 100); // lower right corner of parent
QScrollArea *sa = new QScrollArea;
sa->setWidget(glw3);
sa->setMinimumSize(100, 100);
diff --git a/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp b/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp
index 5819a14e9e..031558a787 100644
--- a/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp
+++ b/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp
@@ -73,6 +73,8 @@ public:
int m_interval;
QVector3D m_rotAxis;
+
+ float clearColor[3];
};
@@ -80,6 +82,7 @@ OpenGLWidget::OpenGLWidget(int interval, const QVector3D &rotAxis, QWidget *pare
: QOpenGLWidget(parent)
{
d.reset(new OpenGLWidgetPrivate(this));
+ d->clearColor[0] = d->clearColor[1] = d->clearColor[2] = 0.0f;
d->m_interval = interval;
d->m_rotAxis = rotAxis;
if (interval > 0) {
@@ -146,7 +149,7 @@ void OpenGLWidgetPrivate::render()
const qreal retinaScale = q->devicePixelRatio();
glViewport(0, 0, width() * retinaScale, height() * retinaScale);
- glClearColor(0.0, 0.0, 0.0, 1.0);
+ glClearColor(clearColor[0], clearColor[1], clearColor[2], 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
m_program->bind();
@@ -189,3 +192,10 @@ void OpenGLWidgetPrivate::render()
if (m_interval <= 0)
q->update();
}
+
+void OpenGLWidget::setClearColor(const float *c)
+{
+ d->clearColor[0] = c[0];
+ d->clearColor[1] = c[1];
+ d->clearColor[2] = c[2];
+}
diff --git a/tests/manual/qopenglwidget/openglwidget/openglwidget.h b/tests/manual/qopenglwidget/openglwidget/openglwidget.h
index affef103f8..32fb4e2660 100644
--- a/tests/manual/qopenglwidget/openglwidget/openglwidget.h
+++ b/tests/manual/qopenglwidget/openglwidget/openglwidget.h
@@ -44,6 +44,8 @@ public:
void resizeGL(int w, int h);
void paintGL();
+ void setClearColor(const float *c);
+
private:
QScopedPointer<OpenGLWidgetPrivate> d;
};