summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--config.tests/unix/evdev/evdev.cpp4
-rwxr-xr-xconfigure24
-rw-r--r--configure.json4
-rw-r--r--examples/opengl/computegles31/Qt-logo-medium.pngbin0 -> 24817 bytes
-rw-r--r--examples/opengl/computegles31/computegles31.pro9
-rw-r--r--examples/opengl/computegles31/computegles31.qrc5
-rw-r--r--examples/opengl/computegles31/glwindow.cpp423
-rw-r--r--examples/opengl/computegles31/glwindow.h99
-rw-r--r--examples/opengl/computegles31/main.cpp118
-rw-r--r--examples/opengl/opengl.pro3
-rw-r--r--examples/widgets/desktop/systray/window.cpp12
-rw-r--r--examples/widgets/painting/fontsampler/mainwindow.cpp10
-rw-r--r--examples/widgets/painting/fontsampler/mainwindow.h4
-rw-r--r--mkspecs/common/angle.conf9
-rw-r--r--mkspecs/common/gcc-base-mac.conf3
-rw-r--r--mkspecs/common/ios/clang.conf29
-rw-r--r--mkspecs/common/macx.conf6
-rw-r--r--mkspecs/common/msvc-desktop.conf7
-rw-r--r--mkspecs/common/uikit.conf2
-rw-r--r--mkspecs/common/uikit/clang.conf7
-rw-r--r--mkspecs/common/uikit/qmake.conf (renamed from mkspecs/common/ios/qmake.conf)2
-rw-r--r--mkspecs/common/windows-gles.conf7
-rw-r--r--mkspecs/common/winrt_winphone/qmake.conf5
-rw-r--r--mkspecs/darwin-g++/qmake.conf2
-rw-r--r--mkspecs/devices/common/freebsd_device_post.conf5
-rw-r--r--mkspecs/devices/common/freebsd_device_pre.conf27
-rw-r--r--mkspecs/devices/freebsd-generic-clang/qmake.conf9
-rw-r--r--mkspecs/devices/freebsd-generic-clang/qplatformdefs.h (renamed from mkspecs/macx-clang-32/qplatformdefs.h)3
-rw-r--r--mkspecs/devices/freebsd-rasp-pi-clang/qmake.conf25
-rw-r--r--mkspecs/devices/freebsd-rasp-pi-clang/qplatformdefs.h (renamed from mkspecs/macx-g++42/qplatformdefs.h)3
-rw-r--r--mkspecs/devices/linux-jetson-tx1-g++/qmake.conf51
-rw-r--r--mkspecs/devices/linux-jetson-tx1-g++/qplatformdefs.h (renamed from mkspecs/macx-g++-32/qplatformdefs.h)5
-rw-r--r--mkspecs/devices/linux-rcar-h2-g++/qmake.conf31
-rw-r--r--mkspecs/devices/linux-rcar-h2-g++/qplatformdefs.h (renamed from mkspecs/macx-g++40/qplatformdefs.h)5
-rw-r--r--mkspecs/features/mac/default_post.prf67
-rw-r--r--mkspecs/features/mac/sdk.prf79
-rw-r--r--mkspecs/features/moc.prf2
-rw-r--r--mkspecs/features/qt.prf4
-rw-r--r--mkspecs/features/qt_build_config.prf2
-rw-r--r--mkspecs/features/qt_common.prf2
-rw-r--r--mkspecs/features/qt_configure.prf4
-rw-r--r--mkspecs/features/qt_functions.prf6
-rw-r--r--mkspecs/features/resolve_target.prf12
-rw-r--r--mkspecs/features/testcase.prf3
-rw-r--r--mkspecs/features/uikit/default_post.prf42
-rw-r--r--mkspecs/features/uikit/default_pre.prf3
-rw-r--r--mkspecs/features/uikit/qt_config.prf19
-rw-r--r--mkspecs/features/uikit/sdk.prf1
-rw-r--r--mkspecs/macx-clang-32/Info.plist.app22
-rw-r--r--mkspecs/macx-clang-32/Info.plist.dSYM.in18
-rw-r--r--mkspecs/macx-clang-32/Info.plist.lib22
-rw-r--r--mkspecs/macx-clang-32/qmake.conf16
-rw-r--r--mkspecs/macx-clang/qmake.conf6
-rw-r--r--mkspecs/macx-g++-32/Info.plist.app22
-rw-r--r--mkspecs/macx-g++-32/Info.plist.dSYM.in18
-rw-r--r--mkspecs/macx-g++-32/Info.plist.lib22
-rw-r--r--mkspecs/macx-g++-32/qmake.conf23
-rw-r--r--mkspecs/macx-g++/qmake.conf6
-rw-r--r--mkspecs/macx-g++40/Info.plist.app22
-rw-r--r--mkspecs/macx-g++40/Info.plist.dSYM.in18
-rw-r--r--mkspecs/macx-g++40/Info.plist.lib22
-rw-r--r--mkspecs/macx-g++40/qmake.conf27
-rw-r--r--mkspecs/macx-g++42/Info.plist.app22
-rw-r--r--mkspecs/macx-g++42/Info.plist.dSYM.in18
-rw-r--r--mkspecs/macx-g++42/Info.plist.lib22
-rw-r--r--mkspecs/macx-g++42/qmake.conf27
-rw-r--r--mkspecs/macx-icc/qmake.conf3
-rw-r--r--mkspecs/macx-ios-clang/qmake.conf4
-rw-r--r--mkspecs/macx-llvm/Info.plist.app22
-rw-r--r--mkspecs/macx-llvm/Info.plist.dSYM.in18
-rw-r--r--mkspecs/macx-llvm/Info.plist.lib22
-rw-r--r--mkspecs/macx-llvm/qmake.conf26
-rw-r--r--mkspecs/macx-llvm/qplatformdefs.h41
-rw-r--r--mkspecs/macx-tvos-clang/qmake.conf6
-rw-r--r--mkspecs/macx-watchos-clang/qmake.conf6
-rw-r--r--mkspecs/win32-g++/qmake.conf8
-rw-r--r--mkspecs/win32-icc/qmake.conf9
-rw-r--r--qmake/Makefile.unix11
-rw-r--r--qmake/Makefile.win322
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp66
-rw-r--r--qmake/generators/projectgenerator.cpp11
-rw-r--r--qmake/generators/unix/unixmake.cpp9
-rw-r--r--qmake/generators/unix/unixmake2.cpp102
-rw-r--r--qmake/generators/win32/msbuild_objectmodel.h3
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp31
-rw-r--r--qmake/generators/win32/msvc_objectmodel.h3
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp103
-rw-r--r--qmake/library/qmakeevaluator.cpp17
-rw-r--r--src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro18
-rw-r--r--src/angle/src/QtANGLE/QtANGLE.pro (renamed from src/angle/src/libGLESv2/libGLESv2.pro)65
-rw-r--r--src/angle/src/libEGL/libEGL.pro27
-rw-r--r--src/angle/src/src.pro2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp8
-rw-r--r--src/corelib/global/global.pri6
-rw-r--r--src/corelib/global/qglobal.cpp305
-rw-r--r--src/corelib/global/qoperatingsystemversion.cpp423
-rw-r--r--src/corelib/global/qoperatingsystemversion.h129
-rw-r--r--src/corelib/global/qoperatingsystemversion_darwin.mm101
-rw-r--r--src/corelib/global/qoperatingsystemversion_p.h87
-rw-r--r--src/corelib/global/qoperatingsystemversion_win.cpp171
-rw-r--r--src/corelib/global/qsysinfo.h53
-rw-r--r--src/corelib/io/qdatastream.h281
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp4
-rw-r--r--src/corelib/io/qfilesystemiterator_win.cpp3
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp53
-rw-r--r--src/corelib/io/qfilesystemwatcher_p.h10
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp286
-rw-r--r--src/corelib/io/qfilesystemwatcher_win_p.h15
-rw-r--r--src/corelib/io/qsettings.cpp250
-rw-r--r--src/corelib/io/qsettings_mac.cpp13
-rw-r--r--src/corelib/io/qsettings_p.h18
-rw-r--r--src/corelib/io/qsettings_win.cpp31
-rw-r--r--src/corelib/io/qstorageinfo.cpp22
-rw-r--r--src/corelib/io/qstorageinfo.h3
-rw-r--r--src/corelib/io/qstorageinfo_p.h1
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp51
-rw-r--r--src/corelib/io/qtemporarydir.cpp27
-rw-r--r--src/corelib/io/qtemporarydir.h1
-rw-r--r--src/corelib/io/qtextstream.cpp15
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm54
-rw-r--r--src/corelib/kernel/qcore_mac_p.h6
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp10
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h2
-rw-r--r--src/corelib/kernel/qobject.cpp76
-rw-r--r--src/corelib/kernel/qobject.h8
-rw-r--r--src/corelib/tools/qarraydata.cpp51
-rw-r--r--src/corelib/tools/qarraydata.h11
-rw-r--r--src/corelib/tools/qbytearray.cpp86
-rw-r--r--src/corelib/tools/qdatetime.cpp9
-rw-r--r--src/corelib/tools/qlocale.cpp66
-rw-r--r--src/corelib/tools/qlocale.h4
-rw-r--r--src/corelib/tools/qlocale.qdoc11
-rw-r--r--src/corelib/tools/qlocale_p.h4
-rw-r--r--src/corelib/tools/qringbuffer.cpp1
-rw-r--r--src/corelib/tools/qstring.cpp145
-rw-r--r--src/corelib/tools/qstring.h10
-rw-r--r--src/dbus/qdbusutil_p.h6
-rw-r--r--src/gui/configure.json2
-rw-r--r--src/gui/image/qicon.cpp42
-rw-r--r--src/gui/image/qicon_p.h2
-rw-r--r--src/gui/kernel/qevent.cpp2
-rw-r--r--src/gui/kernel/qguiapplication.cpp4
-rw-r--r--src/gui/kernel/qtouchdevice.h1
-rw-r--r--src/gui/kernel/qtouchdevice_p.h7
-rw-r--r--src/gui/kernel/qwindow.cpp52
-rw-r--r--src/gui/kernel/qwindow_p.h3
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp416
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h6
-rw-r--r--src/gui/opengl/qopengl.cpp21
-rw-r--r--src/gui/opengl/qopenglfunctions.h568
-rw-r--r--src/gui/opengl/qopenglshaderprogram.cpp223
-rw-r--r--src/gui/painting/qcoregraphics.mm3
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp41
-rw-r--r--src/gui/text/qtextdocument.cpp19
-rw-r--r--src/gui/text/qtextdocument.h1
-rw-r--r--src/gui/text/qtexthtmlparser.cpp57
-rw-r--r--src/gui/text/qtextlayout.cpp10
-rw-r--r--src/gui/util/qdesktopservices.cpp9
-rw-r--r--src/network/access/qhttpnetworkreply.cpp8
-rw-r--r--src/network/access/qhttpnetworkreply_p.h2
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp3
-rw-r--r--src/network/access/qhttpthreaddelegate_p.h3
-rw-r--r--src/network/access/qnetworkaccessbackend_p.h1
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp13
-rw-r--r--src/network/access/qnetworkreplyhttpimpl_p.h4
-rw-r--r--src/network/access/qnetworkrequest.cpp7
-rw-r--r--src/network/access/qnetworkrequest.h1
-rw-r--r--src/network/kernel/kernel.pri3
-rw-r--r--src/network/kernel/qhostaddress.cpp10
-rw-r--r--src/network/socket/qabstractsocket.cpp4
-rw-r--r--src/network/socket/qsocks5socketengine.cpp11
-rw-r--r--src/network/ssl/qsslsocket_winrt.cpp8
-rw-r--r--src/platformsupport/devicediscovery/qdevicediscovery_static.cpp4
-rw-r--r--src/platformsupport/fbconvenience/qfbcursor.cpp18
-rw-r--r--src/platformsupport/fbconvenience/qfbcursor_p.h11
-rw-r--r--src/platformsupport/fbconvenience/qfbscreen.cpp160
-rw-r--r--src/platformsupport/fbconvenience/qfbscreen_p.h19
-rw-r--r--src/platformsupport/fbconvenience/qfbwindow.cpp32
-rw-r--r--src/platformsupport/fontdatabases/fontdatabases.pro2
-rw-r--r--src/platformsupport/fontdatabases/mac/coretext.pri16
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h4
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp4
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp4
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp4
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp4
-rw-r--r--src/platformsupport/kmsconvenience/kmsconvenience.pro20
-rw-r--r--src/platformsupport/kmsconvenience/qkmsdevice.cpp608
-rw-r--r--src/platformsupport/kmsconvenience/qkmsdevice_p.h165
-rw-r--r--src/platformsupport/platformsupport.pro4
-rw-r--r--src/plugins/platforms/bsdfb/qbsdfbscreen.cpp2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplication.mm24
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoadrag.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm14
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h17
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm105
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h60
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm567
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h7
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm123
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h7
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm58
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp21
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dcontext.cpp18
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dcontext.h2
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp5
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp21
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dpaintdevice.cpp19
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp166
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.cpp9
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp27
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dwindow.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp36
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h11
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp24
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.h2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp15
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp23
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h14
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp21
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h7
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp14
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro6
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp429
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h60
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp121
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h30
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp52
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h33
-rw-r--r--src/plugins/platforms/ios/kernel.pro5
-rw-r--r--src/plugins/platforms/ios/optional/nsphotolibrarysupport/nsphotolibrarysupport.pro6
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm3
-rw-r--r--src/plugins/platforms/ios/qiosmessagedialog.mm3
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm7
-rw-r--r--src/plugins/platforms/ios/qiostextinputoverlay.mm4
-rw-r--r--src/plugins/platforms/ios/quiview.mm3
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp2
-rw-r--r--src/plugins/platforms/qnx/qnx.pro14
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp8
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.h4
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp6
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.h8
-rw-r--r--src/plugins/platforms/vnc/qvncscreen.cpp13
-rw-r--r--src/plugins/platforms/vnc/qvncscreen.h4
-rw-r--r--src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp17
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp3
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp27
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp50
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h1
-rw-r--r--src/plugins/platforms/windows/windows.pri4
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp45
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h2
-rw-r--r--src/testlib/qtestcase.cpp37
-rw-r--r--src/tools/bootstrap/bootstrap.pro5
-rw-r--r--src/tools/moc/preprocessor.cpp29
-rw-r--r--src/tools/moc/preprocessor.h1
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.cpp24
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.h4
-rw-r--r--src/widgets/accessible/simplewidgets.cpp12
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp48
-rw-r--r--src/widgets/dialogs/qfileinfogatherer_p.h4
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp3
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp10
-rw-r--r--src/widgets/itemviews/qlistview.cpp8
-rw-r--r--src/widgets/kernel/qapplication_p.h6
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm24
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp3
-rw-r--r--src/widgets/util/qsystemtrayicon.cpp117
-rw-r--r--src/widgets/util/qsystemtrayicon.h1
-rw-r--r--src/widgets/util/qsystemtrayicon_p.h19
-rw-r--r--src/widgets/util/qsystemtrayicon_qpa.cpp17
-rw-r--r--src/widgets/util/qsystemtrayicon_win.cpp57
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp17
-rw-r--r--src/widgets/widgets/qmenubar.cpp1
-rw-r--r--sync.profile1
-rw-r--r--tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro1
-rw-r--r--tests/auto/corelib/global/qlogging/test/test.pro2
-rw-r--r--tests/auto/corelib/io/qfile/test/test.pro2
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.pro1
-rw-r--r--tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro2
-rw-r--r--tests/auto/corelib/io/qprocess/test/test.pro2
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp73
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp2
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp25
-rw-r--r--tests/auto/corelib/json/json.pro1
-rw-r--r--tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro1
-rw-r--r--tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro1
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp2
-rw-r--r--tests/auto/corelib/kernel/qsharedmemory/test/test.pro1
-rw-r--r--tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro1
-rw-r--r--tests/auto/corelib/plugin/qfactoryloader/test/test.pro2
-rw-r--r--tests/auto/corelib/plugin/qlibrary/tst/tst.pro1
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro11
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst/tst.pro1
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/test/test.pro2
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp50
-rw-r--r--tests/auto/corelib/tools/qlocale/test/test.pro1
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp24
-rw-r--r--tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp143
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp24
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp11
-rw-r--r--tests/auto/network/access/qnetworkreply/test/test.pro2
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp252
-rw-r--r--tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro1
-rw-r--r--tests/auto/other/atwrapper/.gitignore1
-rw-r--r--tests/auto/other/atwrapper/TODO17
-rw-r--r--tests/auto/other/atwrapper/atWrapper.cpp636
-rw-r--r--tests/auto/other/atwrapper/atWrapper.h80
-rw-r--r--tests/auto/other/atwrapper/atWrapper.pro21
-rw-r--r--tests/auto/other/atwrapper/atWrapperAutotest.cpp65
-rw-r--r--tests/auto/other/atwrapper/desert.ini14
-rw-r--r--tests/auto/other/atwrapper/ephron.ini14
-rw-r--r--tests/auto/other/atwrapper/gullgubben.ini12
-rw-r--r--tests/auto/other/atwrapper/honshu.ini16
-rw-r--r--tests/auto/other/atwrapper/kramer.ini12
-rw-r--r--tests/auto/other/atwrapper/scruffy.ini15
-rw-r--r--tests/auto/other/atwrapper/spareribs.ini14
-rw-r--r--tests/auto/other/atwrapper/titan.ini13
-rw-r--r--tests/auto/other/lancelot/lancelot.pro1
-rw-r--r--tests/auto/other/macplist/tst_macplist.cpp3
-rw-r--r--tests/auto/other/other.pro1
-rwxr-xr-xtests/auto/test.pl223
-rw-r--r--tests/auto/widgets/kernel/qapplication/test/test.pro2
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro1
-rw-r--r--tests/auto/widgets/widgets/qmenubar/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp40
-rw-r--r--tests/baselineserver/shared/baselineprotocol.cpp11
-rw-r--r--tests/manual/qstorageinfo/printvolumes.cpp12
-rw-r--r--tests/manual/qsysinfo/main.cpp13
-rw-r--r--tests/manual/windowchildgeometry/controllerwidget.cpp5
-rw-r--r--tools/configure/Makefile.mingw2
-rw-r--r--tools/configure/Makefile.win324
-rw-r--r--tools/configure/configureapp.cpp4
339 files changed, 6831 insertions, 5713 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 8c302d7039..6d42bbdd34 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -4,4 +4,4 @@ CONFIG += warning_clean
QT_SOURCE_TREE = $$PWD
QT_BUILD_TREE = $$shadowed($$PWD)
-MODULE_VERSION = 5.8.0
+MODULE_VERSION = 5.9.0
diff --git a/config.tests/unix/evdev/evdev.cpp b/config.tests/unix/evdev/evdev.cpp
index 8d7f608dd4..b00b1a8141 100644
--- a/config.tests/unix/evdev/evdev.cpp
+++ b/config.tests/unix/evdev/evdev.cpp
@@ -37,8 +37,12 @@
**
****************************************************************************/
+#if defined(__FreeBSD__)
+#include <dev/evdev/input.h>
+#else
#include <linux/input.h>
#include <linux/kd.h>
+#endif
enum {
e1 = ABS_PRESSURE,
diff --git a/configure b/configure
index 938831df09..3e9004a5d0 100755
--- a/configure
+++ b/configure
@@ -515,6 +515,24 @@ QT_EXT_PREFIX=
# default qpa platform
# Android vars
+if [ -z "$ANDROID_SDK_ROOT" ]; then
+ if [ "$UNAME_SYSTEM" = "Darwin" ] && [ -d "$HOME/Library/Android/sdk" ]; then
+ ANDROID_SDK_ROOT="$HOME/Library/Android/sdk"
+ elif [ "$UNAME_SYSTEM" = "Linux" ] && [ -d "$HOME/Android/Sdk" ]; then
+ ANDROID_SDK_ROOT="$HOME/Android/Sdk"
+ fi
+fi
+
+if [ -z "$ANDROID_NDK_ROOT" ]; then
+ if [ -d "$ANDROID_SDK_ROOT/ndk-bundle" ]; then
+ ANDROID_NDK_ROOT="$ANDROID_SDK_ROOT/ndk-bundle"
+ elif [ "$UNAME_SYSTEM" = "Darwin" ] && [ -d "$HOME/Library/Android/sdk/ndk-bundle" ]; then
+ ANDROID_NDK_ROOT="$HOME/Library/Android/sdk/ndk-bundle"
+ elif [ "$UNAME_SYSTEM" = "Linux" ] && [ -d "$HOME/Android/Sdk/ndk-bundle" ]; then
+ ANDROID_NDK_ROOT="$HOME/Android/Sdk/ndk-bundle"
+ fi
+fi
+
CFG_DEFAULT_ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT
CFG_DEFAULT_ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT
CFG_DEFAULT_ANDROID_PLATFORM=android-16
@@ -1696,9 +1714,11 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
qfsfileengine_win.o \
qlocale_win.o \
qsettings_win.o \
+ qoperatingsystemversion_win.o \
qsystemlibrary.o \
registry.o"
EXTRA_SRCS="\"\$(SOURCE_PATH)/src/corelib/corelib/io/qfilesystemengine_win.cpp\" \
+ \"\$(SOURCE_PATH)/src/corelib/global/qoperatingsystemversion_win.cpp\" \
\"\$(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_win.cpp\" \
\"\$(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp\" \
\"\$(SOURCE_PATH)/src/corelib/io/qsettings_win.cpp\" \
@@ -1731,12 +1751,12 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
EXTRA_OBJS="$EXTRA_OBJS \
qsettings_mac.o \
qcore_mac.o \
- qcore_mac_objc.o \
+ qoperatingsystemversion_darwin.o \
qcore_foundation.o"
EXTRA_SRCS="$EXTRA_SRCS \
\"\$(SOURCE_PATH)/src/corelib/io/qsettings_mac.cpp\" \
\"\$(SOURCE_PATH)/src/corelib/kernel/qcore_mac.cpp\" \
- \"\$(SOURCE_PATH)/src/corelib/kernel/qcore_mac_objc.mm\" \
+ \"\$(SOURCE_PATH)/src/corelib/global/qoperatingsystemversion_darwin.mm\" \
\"\$(SOURCE_PATH)/src/corelib/kernel/qcore_foundation.mm\""
fi
diff --git a/configure.json b/configure.json
index 3480aed20f..6b44867b79 100644
--- a/configure.json
+++ b/configure.json
@@ -419,7 +419,8 @@
"features": {
"shared": {
"label": "Building shared libraries",
- "condition": "!config.uikit && !config.integrity",
+ "autoDetect": "!config.uikit",
+ "condition": "!config.integrity",
"output": [
"shared",
"publicFeature",
@@ -920,6 +921,7 @@
},
"widgets": {
"label": "Qt Widgets",
+ "autoDetect": "!config.tvos && !config.watchos",
"condition": "features.gui",
"output": [
"privateFeature",
diff --git a/examples/opengl/computegles31/Qt-logo-medium.png b/examples/opengl/computegles31/Qt-logo-medium.png
new file mode 100644
index 0000000000..a1ca1f1830
--- /dev/null
+++ b/examples/opengl/computegles31/Qt-logo-medium.png
Binary files differ
diff --git a/examples/opengl/computegles31/computegles31.pro b/examples/opengl/computegles31/computegles31.pro
new file mode 100644
index 0000000000..5b9d7e4387
--- /dev/null
+++ b/examples/opengl/computegles31/computegles31.pro
@@ -0,0 +1,9 @@
+HEADERS = $$PWD/glwindow.h
+
+SOURCES = $$PWD/glwindow.cpp \
+ $$PWD/main.cpp
+
+RESOURCES += computegles31.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/opengl/computegles31
+INSTALLS += target
diff --git a/examples/opengl/computegles31/computegles31.qrc b/examples/opengl/computegles31/computegles31.qrc
new file mode 100644
index 0000000000..b99eb0a82e
--- /dev/null
+++ b/examples/opengl/computegles31/computegles31.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>Qt-logo-medium.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/opengl/computegles31/glwindow.cpp b/examples/opengl/computegles31/glwindow.cpp
new file mode 100644
index 0000000000..d2cea169a1
--- /dev/null
+++ b/examples/opengl/computegles31/glwindow.cpp
@@ -0,0 +1,423 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "glwindow.h"
+#include <QImage>
+#include <QOpenGLShaderProgram>
+#include <QOpenGLContext>
+#include <QOpenGLFunctions>
+#include <QOpenGLExtraFunctions>
+//#include <QtGui/qopenglext.h>
+#include <QtGui/qopengl.h>
+#include <QDebug>
+#include <QTimer>
+#include <math.h>
+
+#ifndef GL_READ_WRITE
+#define GL_READ_WRITE 0x88BA
+#endif
+
+#ifndef GL_RGBA8
+#define GL_RGBA8 0x8058
+#endif
+
+#ifndef GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
+#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
+#endif
+
+GLWindow::GLWindow()
+ : m_texImageInput(0),
+ m_texImageTmp(0),
+ m_texImageProcessed(0),
+ m_shaderDisplay(0),
+ m_shaderComputeV(0),
+ m_shaderComputeH(0),
+ m_blurRadius(0.0f),
+ m_animate(true)
+{
+ const float animationStart = 0.0;
+ const float animationEnd = 10.0;
+ const float animationLength = 1000;
+
+ m_animationGroup = new QSequentialAnimationGroup(this);
+ m_animationGroup->setLoopCount(-1);
+
+ m_animationForward = new QPropertyAnimation(this, QByteArrayLiteral("blurRadius"));
+ m_animationForward->setStartValue(animationStart);
+ m_animationForward->setEndValue(animationEnd);
+ m_animationForward->setDuration(animationLength);
+ m_animationGroup->addAnimation(m_animationForward);
+
+ m_animationBackward = new QPropertyAnimation(this, QByteArrayLiteral("blurRadius"));
+ m_animationBackward->setStartValue(animationEnd);
+ m_animationBackward->setEndValue(animationStart);
+ m_animationBackward->setDuration(animationLength);
+ m_animationGroup->addAnimation(m_animationBackward);
+
+ m_animationGroup->start();
+}
+
+GLWindow::~GLWindow()
+{
+ makeCurrent();
+ delete m_texImageInput;
+ delete m_texImageProcessed;
+ delete m_texImageTmp;
+ delete m_shaderDisplay;
+ delete m_shaderComputeH;
+ delete m_shaderComputeV;
+ delete m_animationGroup;
+ delete m_animationForward;
+ delete m_animationBackward;
+}
+
+void GLWindow::setBlurRadius(float blurRadius)
+{
+ int radius = int(blurRadius);
+ if (radius != m_blurRadius) {
+ m_blurRadius = radius;
+ update();
+ }
+}
+
+void GLWindow::setAnimating(bool animate)
+{
+ m_animate = animate;
+ if (animate)
+ m_animationGroup->start();
+ else
+ m_animationGroup->stop();
+}
+
+void GLWindow::keyPressEvent(QKeyEvent *e)
+{
+ if (e->key() == Qt::Key_Space) { // pause
+ setAnimating(!m_animate);
+ }
+ update();
+}
+
+
+
+
+static const char *vsDisplaySource =
+ "const vec4 vertices[4] = vec4[4] (\n"
+ " vec4( -1.0, 1.0, 0.0, 1.0),\n"
+ " vec4( -1.0, -1.0, 0.0, 1.0),\n"
+ " vec4( 1.0, 1.0, 0.0, 1.0),\n"
+ " vec4( 1.0, -1.0, 0.0, 1.0)\n"
+ ");\n"
+ "const vec2 texCoords[4] = vec2[4] (\n"
+ " vec2( 0.0, 1.0),\n"
+ " vec2( 0.0, 0.0),\n"
+ " vec2( 1.0, 1.0),\n"
+ " vec2( 1.0, 0.0)\n"
+ ");\n"
+ "out vec2 texCoord;\n"
+ "uniform mat4 matProjection;\n"
+ "uniform vec2 imageRatio;\n"
+ "void main() {\n"
+ " gl_Position = matProjection * ( vertices[gl_VertexID] * vec4(imageRatio,0,1) );\n"
+ " texCoord = texCoords[gl_VertexID];\n"
+ "}\n";
+
+static const char *fsDisplaySource =
+ "in lowp vec2 texCoord; \n"
+ "uniform sampler2D samImage; \n"
+ "layout(location = 0) out lowp vec4 color;\n"
+ "void main() {\n"
+ " lowp vec4 texColor = texture(samImage,texCoord);\n"
+ " color = vec4(texColor.rgb, 1.0);\n"
+ "}\n";
+
+static const char *csComputeSourceV =
+ //"#extension GL_EXT_gpu_shader5 : require \n"
+ "#define COMPUTEPATCHSIZE 32 \n"
+ "#define IMGFMT rgba8 \n"
+ "layout (local_size_x = COMPUTEPATCHSIZE, local_size_y = COMPUTEPATCHSIZE) in;\n"
+ "layout(binding=0, IMGFMT) uniform highp image2D inputImage; // Use a sampler to improve performance \n"
+ "layout(binding=1, IMGFMT) uniform highp image2D resultImage;\n"
+ "uniform int radius;\n"
+ "const float cutoff = 2.2;\n"
+ "float sigma = clamp(float(radius) / cutoff,0.02,100.0);\n" // Const initialization with dynamically uniform expressions doesn't work in GLES
+ "float expFactor = 1.0 / (2.0 * sigma * sigma);\n" // Same here
+
+ "float gaussian(float distance) {\n"
+ " return exp( -(distance * distance) * expFactor);\n"
+ "}\n"
+
+ "void main() {\n"
+ " ivec2 imgSize = imageSize(resultImage);\n"
+ " int x = int(gl_GlobalInvocationID.x);\n"
+ " int y = int(gl_GlobalInvocationID.y);\n"
+ " if ( (x >= imgSize.x) || (y >= imgSize.y) ) return;\n"
+ " vec4 sumPixels = vec4(0.0);\n"
+ " float sumWeights = 0.0;\n"
+ " int left = clamp(x - radius, 0, imgSize.x - 1);\n"
+ " int right = clamp(x + radius, 0, imgSize.x - 1);\n"
+ " int top = clamp(y - radius, 0, imgSize.y - 1);\n"
+ " int bottom = clamp(y + radius, 0, imgSize.y - 1);\n"
+ " for (int iY = top; iY <= bottom; iY++) {\n"
+ " float dy = float(abs(iY - y));\n"
+ " vec4 imgValue = imageLoad(inputImage, ivec2(x,iY));\n"
+ " float weight = gaussian(dy);\n"
+ " sumWeights += weight;\n"
+ " sumPixels += (imgValue * weight);\n"
+ " }\n"
+ " sumPixels /= sumWeights;\n"
+ " imageStore(resultImage, ivec2(x,y), sumPixels);"
+ "}\n";
+
+static const char *csComputeSourceH =
+ //"#extension GL_EXT_gpu_shader5 : require \n"
+ "#define COMPUTEPATCHSIZE 32 \n"
+ "#define IMGFMT rgba8 \n"
+ "layout (local_size_x = COMPUTEPATCHSIZE, local_size_y = COMPUTEPATCHSIZE) in;\n"
+ "layout(binding=0, IMGFMT) uniform highp image2D inputImage; // Use a sampler to improve performance \n"
+ "layout(binding=1, IMGFMT) uniform highp image2D resultImage;\n"
+ "uniform int radius;\n"
+ "const float cutoff = 2.2;\n"
+ "float sigma = clamp(float(radius) / cutoff,0.02,100.0);\n"
+ "float expFactor = 1.0 / (2.0 * sigma * sigma);\n"
+
+ "float gaussian(float distance) {\n"
+ " return exp( -(distance * distance) * expFactor);\n"
+ "}\n"
+
+ "void main() {\n"
+ " ivec2 imgSize = imageSize(resultImage);\n"
+ " int x = int(gl_GlobalInvocationID.x);\n"
+ " int y = int(gl_GlobalInvocationID.y);\n"
+ " if ( (x >= imgSize.x) || (y >= imgSize.y) ) return;\n"
+ " vec4 sumPixels = vec4(0.0);\n"
+ " float sumWeights = 0.0;\n"
+ " int left = clamp(x - radius, 0, imgSize.x - 1);\n"
+ " int right = clamp(x + radius, 0, imgSize.x - 1);\n"
+ " int top = clamp(y - radius, 0, imgSize.y - 1);\n"
+ " int bottom = clamp(y + radius, 0, imgSize.y - 1);\n"
+ " for (int iX = left; iX <= right; iX++) {\n"
+ " float dx = float(abs(iX - x));\n"
+ " vec4 imgValue = imageLoad(inputImage, ivec2(iX,y));\n"
+ " float weight = gaussian(dx);\n"
+ " sumWeights += weight;\n"
+ " sumPixels += (imgValue * weight);\n"
+ " }\n"
+ " sumPixels /= sumWeights;\n"
+ " imageStore(resultImage, ivec2(x,y), sumPixels);"
+ "}\n";
+
+
+
+QByteArray versionedShaderCode(const char *src)
+{
+ QByteArray versionedSrc;
+
+ if (QOpenGLContext::currentContext()->isOpenGLES())
+ versionedSrc.append(QByteArrayLiteral("#version 310 es\n"));
+ else
+ versionedSrc.append(QByteArrayLiteral("#version 430\n"));
+
+ versionedSrc.append(src);
+ return versionedSrc;
+}
+
+void computeProjection(int winWidth, int winHeight, int imgWidth, int imgHeight, QMatrix4x4 &outProjection, QSizeF &outQuadSize)
+{
+ float ratioImg = float(imgWidth) / float(imgHeight);
+ float ratioCanvas = float(winWidth) / float(winHeight);
+
+ float correction = ratioImg / ratioCanvas;
+ float rescaleFactor = 1.0f;
+ float quadWidth = 1.0f;
+ float quadHeight = 1.0f;
+
+ if (correction < 1.0f) // canvas larger than image -- height = 1.0, vertical black bands
+ {
+ quadHeight = 1.0f;
+ quadWidth = 1.0f * ratioImg;
+ rescaleFactor = ratioCanvas;
+ correction = 1.0f / rescaleFactor;
+ }
+ else // image larger than canvas -- width = 1.0, horizontal black bands
+ {
+ quadWidth = 1.0f;
+ quadHeight = 1.0f / ratioImg;
+ correction = 1.0f / ratioCanvas;
+ }
+
+ const float frustumWidth = 1.0f * rescaleFactor;
+ const float frustumHeight = 1.0f * rescaleFactor * correction;
+
+ outProjection = QMatrix4x4();
+ outProjection.ortho(
+ -frustumWidth,
+ frustumWidth,
+ -frustumHeight,
+ frustumHeight,
+ -1.0f,
+ 1.0f);
+ outQuadSize = QSizeF(quadWidth,quadHeight);
+}
+
+void GLWindow::initializeGL()
+{
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ qDebug() << "Got a "
+ << ctx->format().majorVersion()
+ << "."
+ << ctx->format().minorVersion()
+ << ((ctx->format().renderableType() == QSurfaceFormat::OpenGLES) ? (" GLES") : (" GL"))
+ << " context";
+ //QOpenGLFunctions *f = ctx->functions();
+
+ if (m_texImageInput) {
+ delete m_texImageInput;
+ m_texImageInput = 0;
+ }
+ QImage img(":/Qt-logo-medium.png");
+ Q_ASSERT(!img.isNull());
+ m_texImageInput = new QOpenGLTexture(img.convertToFormat(QImage::Format_RGBA8888).mirrored());
+
+ if (m_texImageTmp) {
+ delete m_texImageTmp;
+ m_texImageTmp = 0;
+ }
+ m_texImageTmp = new QOpenGLTexture(QOpenGLTexture::Target2D);
+ m_texImageTmp->setFormat(m_texImageInput->format());
+ m_texImageTmp->setSize(m_texImageInput->width(),m_texImageInput->height());
+ m_texImageTmp->allocateStorage(QOpenGLTexture::RGBA,QOpenGLTexture::UInt8); // WTF?
+
+ if (m_texImageProcessed) {
+ delete m_texImageProcessed;
+ m_texImageProcessed = 0;
+ }
+ m_texImageProcessed = new QOpenGLTexture(QOpenGLTexture::Target2D);
+ m_texImageProcessed->setFormat(m_texImageInput->format());
+ m_texImageProcessed->setSize(m_texImageInput->width(),m_texImageInput->height());
+ m_texImageProcessed->allocateStorage(QOpenGLTexture::RGBA,QOpenGLTexture::UInt8);
+
+ m_texImageProcessed->setMagnificationFilter(QOpenGLTexture::Linear);
+ m_texImageProcessed->setMinificationFilter(QOpenGLTexture::Linear);
+ m_texImageProcessed->setWrapMode(QOpenGLTexture::ClampToEdge);
+
+ if (m_shaderDisplay) {
+ delete m_shaderDisplay;
+ m_shaderDisplay = 0;
+ }
+ m_shaderDisplay = new QOpenGLShaderProgram;
+ // Prepend the correct version directive to the sources. The rest is the
+ // same, thanks to the common GLSL syntax.
+ m_shaderDisplay->addShaderFromSourceCode(QOpenGLShader::Vertex, versionedShaderCode(vsDisplaySource));
+ m_shaderDisplay->addShaderFromSourceCode(QOpenGLShader::Fragment, versionedShaderCode(fsDisplaySource));
+ m_shaderDisplay->link();
+
+ if (m_shaderComputeV) {
+ delete m_shaderComputeV;
+ m_shaderComputeV = 0;
+ }
+ m_shaderComputeV = new QOpenGLShaderProgram;
+ m_shaderComputeV->addShaderFromSourceCode(QOpenGLShader::Compute, versionedShaderCode(csComputeSourceV));
+ m_shaderComputeV->link();
+
+ if (m_shaderComputeH) {
+ delete m_shaderComputeH;
+ m_shaderComputeH = 0;
+ }
+ m_shaderComputeH = new QOpenGLShaderProgram;
+ m_shaderComputeH->addShaderFromSourceCode(QOpenGLShader::Compute, versionedShaderCode(csComputeSourceH));
+ m_shaderComputeH->link();
+}
+
+void GLWindow::resizeGL(int w, int h)
+{
+ computeProjection(w,h,m_texImageInput->width(),m_texImageInput->height(),m_proj,m_quadSize);
+}
+
+QSize getWorkGroups(int workGroupSize, const QSize &imageSize)
+{
+ int x = imageSize.width();
+ x = (x % workGroupSize) ? (x / workGroupSize) + 1 : (x / workGroupSize);
+ int y = imageSize.height();
+ y = (y % workGroupSize) ? (y / workGroupSize) + 1 : (y / workGroupSize);
+ return QSize(x,y);
+}
+
+void GLWindow::paintGL()
+{
+ // Now use QOpenGLExtraFunctions instead of QOpenGLFunctions as we want to
+ // do more than what GL(ES) 2.0 offers.
+ QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions();
+
+
+ // Process input image
+ QSize workGroups = getWorkGroups( 32, QSize(m_texImageInput->width(), m_texImageInput->height()));
+ // Pass 1
+ f->glBindImageTexture(0, m_texImageInput->textureId(), 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
+ f->glBindImageTexture(1, m_texImageTmp->textureId(), 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
+ m_shaderComputeV->bind();
+ m_shaderComputeV->setUniformValue("radius",m_blurRadius);
+ f->glDispatchCompute(workGroups.width(),workGroups.height(),1);
+ f->glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
+ m_shaderComputeV->release();
+ // Pass 2
+ f->glBindImageTexture(0, m_texImageTmp->textureId(), 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
+ f->glBindImageTexture(1, m_texImageProcessed->textureId(), 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
+ m_shaderComputeH->bind();
+ m_shaderComputeH->setUniformValue("radius",m_blurRadius);
+ f->glDispatchCompute(workGroups.width(),workGroups.height(),1);
+ f->glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
+ m_shaderComputeH->release();
+ // Compute cleanup
+ f->glBindImageTexture(0, 0, 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
+ f->glBindImageTexture(1, 0, 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
+
+ // Display processed image
+ f->glClearColor(0, 0, 0, 1);
+ f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ m_texImageProcessed->bind(GL_TEXTURE0);
+ m_shaderDisplay->bind();
+ m_shaderDisplay->setUniformValue("matProjection",m_proj);
+ m_shaderDisplay->setUniformValue("imageRatio",m_quadSize);
+ m_shaderDisplay->setUniformValue("samImage",0);
+ f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ m_shaderDisplay->release();
+ m_texImageProcessed->release(GL_TEXTURE0);
+}
+
diff --git a/examples/opengl/computegles31/glwindow.h b/examples/opengl/computegles31/glwindow.h
new file mode 100644
index 0000000000..15ece01780
--- /dev/null
+++ b/examples/opengl/computegles31/glwindow.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GLWIDGET_H
+#define GLWIDGET_H
+
+#include <QOpenGLWindow>
+#include <QOpenGLTexture>
+#include <QMatrix4x4>
+#include <QVector3D>
+#include <QKeyEvent>
+#include <QPropertyAnimation>
+#include <QSequentialAnimationGroup>
+#include <QRectF>
+
+QT_BEGIN_NAMESPACE
+
+class QOpenGLTexture;
+class QOpenGLShaderProgram;
+class QOpenGLBuffer;
+class QOpenGLVertexArrayObject;
+
+QT_END_NAMESPACE
+
+class GLWindow : public QOpenGLWindow
+{
+ Q_OBJECT
+ Q_PROPERTY(float blurRadius READ blurRadius WRITE setBlurRadius)
+
+public:
+ GLWindow();
+ ~GLWindow();
+
+ void initializeGL() override;
+ void resizeGL(int w, int h) override;
+ void paintGL() override;
+
+ float blurRadius() const { return m_blurRadius; }
+ void setBlurRadius(float blurRadius);
+
+protected:
+ void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
+ void setAnimating(bool animate);
+
+private:
+ QPropertyAnimation *m_animationForward;
+ QPropertyAnimation *m_animationBackward;
+ QSequentialAnimationGroup *m_animationGroup;
+ QOpenGLTexture *m_texImageInput;
+ QOpenGLTexture *m_texImageTmp;
+ QOpenGLTexture *m_texImageProcessed;
+ QOpenGLShaderProgram *m_shaderDisplay;
+ QOpenGLShaderProgram *m_shaderComputeV;
+ QOpenGLShaderProgram *m_shaderComputeH;
+ QMatrix4x4 m_proj;
+ QSizeF m_quadSize;
+
+ int m_blurRadius;
+ bool m_animate;
+};
+
+#endif
diff --git a/examples/opengl/computegles31/main.cpp b/examples/opengl/computegles31/main.cpp
new file mode 100644
index 0000000000..ff2a1e622d
--- /dev/null
+++ b/examples/opengl/computegles31/main.cpp
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QSurfaceFormat>
+#include <QOffscreenSurface>
+#include <QOpenGLContext>
+#include <QDebug>
+#include <QPair>
+#include "glwindow.h"
+
+bool OGLSupports(int major, int minor, bool gles = false)
+{
+ QOpenGLContext ctx;
+ QSurfaceFormat fmt;
+ fmt.setVersion(major, minor);
+ if (gles)
+ fmt.setRenderableType(QSurfaceFormat::OpenGLES);
+ else
+ fmt.setRenderableType(QSurfaceFormat::OpenGL);
+
+ ctx.setFormat(fmt);
+ ctx.create();
+ if (!ctx.isValid())
+ return false;
+ int ctxMajor = ctx.format().majorVersion();
+ int ctxMinor = ctx.format().minorVersion();
+ bool isGles = (ctx.format().renderableType() == QSurfaceFormat::OpenGLES);
+
+ if (isGles != gles) return false;
+ if (ctxMajor < major) return false;
+ if (ctxMajor == major && ctxMinor < minor)
+ return false;
+ return true;
+}
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qDebug() << "Support for GL 2.0 "<<( OGLSupports(2,0) ? "yes" : "no");
+ qDebug() << "Support for GL 2.1 "<<( OGLSupports(2,1) ? "yes" : "no");
+ qDebug() << "Support for GL 3.0 "<<( OGLSupports(3,0) ? "yes" : "no");
+ qDebug() << "Support for GL 3.1 "<<( OGLSupports(3,1) ? "yes" : "no");
+ qDebug() << "Support for GL 3.2 "<<( OGLSupports(3,2) ? "yes" : "no");
+ qDebug() << "Support for GL 3.3 "<<( OGLSupports(3,3) ? "yes" : "no");
+ qDebug() << "Support for GL 4.0 "<<( OGLSupports(4,0) ? "yes" : "no");
+ qDebug() << "Support for GL 4.1 "<<( OGLSupports(4,1) ? "yes" : "no");
+ qDebug() << "Support for GL 4.2 "<<( OGLSupports(4,2) ? "yes" : "no");
+ qDebug() << "Support for GL 4.3 "<<( OGLSupports(4,3) ? "yes" : "no");
+ qDebug() << "Support for GL 4.4 "<<( OGLSupports(4,4) ? "yes" : "no");
+ qDebug() << "Support for GL 4.5 "<<( OGLSupports(4,5) ? "yes" : "no");
+ qDebug() << "Support for GLES 2.0 "<<( OGLSupports(2,0,true) ? "yes" : "no");
+ qDebug() << "Support for GLES 3.0 "<<( OGLSupports(3,0,true) ? "yes" : "no");
+ qDebug() << "Support for GLES 3.1 "<<( OGLSupports(3,1,true) ? "yes" : "no");
+ qDebug() << "Support for GLES 3.2 "<<( OGLSupports(3,2,true) ? "yes" : "no");
+
+ QSurfaceFormat fmt;
+ fmt.setDepthBufferSize(24);
+
+ // Request OpenGL 4.3 compatibility or OpenGL ES 3.1.
+ if (OGLSupports(4,3)) {
+ qDebug("Requesting 4.3 compatibility context");
+ fmt.setVersion(4, 3);
+ fmt.setRenderableType(QSurfaceFormat::OpenGL);
+ fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
+ } else if (OGLSupports(3,1,true)) {
+ qDebug("Requesting 3.1 GLES context");
+ fmt.setVersion(3, 1);
+ fmt.setRenderableType(QSurfaceFormat::OpenGLES);
+ } else {
+ qWarning("Error: This system does not support OpenGL Compute Shaders! Exiting.");
+ return -1;
+ }
+ QSurfaceFormat::setDefaultFormat(fmt);
+
+ GLWindow glWindow;
+ glWindow.showMaximized();
+
+ return app.exec();
+}
diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro
index a102e08733..ef44201494 100644
--- a/examples/opengl/opengl.pro
+++ b/examples/opengl/opengl.pro
@@ -14,7 +14,8 @@ qtHaveModule(widgets) {
qopenglwidget \
cube \
textures \
- hellogles3
+ hellogles3 \
+ computegles31
}
EXAMPLE_FILES += \
diff --git a/examples/widgets/desktop/systray/window.cpp b/examples/widgets/desktop/systray/window.cpp
index 518f03d4b5..ac05f16341 100644
--- a/examples/widgets/desktop/systray/window.cpp
+++ b/examples/widgets/desktop/systray/window.cpp
@@ -161,10 +161,16 @@ void Window::iconActivated(QSystemTrayIcon::ActivationReason reason)
void Window::showMessage()
{
showIconCheckBox->setChecked(true);
- QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(
+ QSystemTrayIcon::MessageIcon msgIcon = QSystemTrayIcon::MessageIcon(
typeComboBox->itemData(typeComboBox->currentIndex()).toInt());
- trayIcon->showMessage(titleEdit->text(), bodyEdit->toPlainText(), icon,
+ if (msgIcon == QSystemTrayIcon::NoIcon) {
+ QIcon icon(iconComboBox->itemIcon(iconComboBox->currentIndex()));
+ trayIcon->showMessage(titleEdit->text(), bodyEdit->toPlainText(), icon,
durationSpinBox->value() * 1000);
+ } else {
+ trayIcon->showMessage(titleEdit->text(), bodyEdit->toPlainText(), msgIcon,
+ durationSpinBox->value() * 1000);
+ }
}
//! [5]
@@ -216,6 +222,8 @@ void Window::createMessageGroupBox()
typeComboBox->addItem(style()->standardIcon(
QStyle::SP_MessageBoxCritical), tr("Critical"),
QSystemTrayIcon::Critical);
+ typeComboBox->addItem(QIcon(), tr("Custom icon"),
+ QSystemTrayIcon::NoIcon);
typeComboBox->setCurrentIndex(1);
durationLabel = new QLabel(tr("Duration:"));
diff --git a/examples/widgets/painting/fontsampler/mainwindow.cpp b/examples/widgets/painting/fontsampler/mainwindow.cpp
index 33d560edf3..394a65b41e 100644
--- a/examples/widgets/painting/fontsampler/mainwindow.cpp
+++ b/examples/widgets/painting/fontsampler/mainwindow.cpp
@@ -214,9 +214,9 @@ QMap<QString, StyleItems> MainWindow::currentPageMap()
return pageMap;
}
-#if !defined(QT_NO_PRINTER) && !defined(QT_NO_PRINTDIALOG)
void MainWindow::on_printAction_triggered()
{
+#if !defined(QT_NO_PRINTER) && !defined(QT_NO_PRINTDIALOG)
pageMap = currentPageMap();
if (pageMap.count() == 0)
@@ -233,10 +233,12 @@ void MainWindow::on_printAction_triggered()
printer.setFromTo(1, pageMap.keys().count());
printDocument(&printer);
+#endif // QT_NO_PRINTER
}
void MainWindow::printDocument(QPrinter *printer)
{
+#if !defined(QT_NO_PRINTER) && !defined(QT_NO_PRINTDIALOG)
printer->setFromTo(1, pageMap.count());
QProgressDialog progress(tr("Preparing font samples..."), tr("&Cancel"),
@@ -265,10 +267,12 @@ void MainWindow::printDocument(QPrinter *printer)
}
painter.end();
+#endif // QT_NO_PRINTER
}
void MainWindow::on_printPreviewAction_triggered()
{
+#if !defined(QT_NO_PRINTER) && !defined(QT_NO_PRINTDIALOG)
pageMap = currentPageMap();
if (pageMap.count() == 0)
@@ -279,10 +283,12 @@ void MainWindow::on_printPreviewAction_triggered()
connect(&preview, SIGNAL(paintRequested(QPrinter*)),
this, SLOT(printDocument(QPrinter*)));
preview.exec();
+#endif // QT_NO_PRINTER
}
void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer)
{
+#if !defined(QT_NO_PRINTER) && !defined(QT_NO_PRINTDIALOG)
QString family = pageMap.keys()[index];
StyleItems items = pageMap[family];
@@ -345,5 +351,5 @@ void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer)
}
painter->restore();
-}
#endif // QT_NO_PRINTER
+}
diff --git a/examples/widgets/painting/fontsampler/mainwindow.h b/examples/widgets/painting/fontsampler/mainwindow.h
index f39e1b1916..e79da07326 100644
--- a/examples/widgets/painting/fontsampler/mainwindow.h
+++ b/examples/widgets/painting/fontsampler/mainwindow.h
@@ -72,15 +72,11 @@ public:
public slots:
void on_clearAction_triggered();
void on_markAction_triggered();
-#if !defined(QT_NO_PRINTER) && !defined(QT_NO_PRINTDIALOG)
void on_printAction_triggered();
void on_printPreviewAction_triggered();
-#endif
void on_unmarkAction_triggered();
-#if !defined(QT_NO_PRINTER) && !defined(QT_NO_PRINTDIALOG)
void printDocument(QPrinter *printer);
void printPage(int index, QPainter *painter, QPrinter *printer);
-#endif
void showFont(QTreeWidgetItem *item);
void updateStyles(QTreeWidgetItem *item, int column);
diff --git a/mkspecs/common/angle.conf b/mkspecs/common/angle.conf
deleted file mode 100644
index fffdb581c5..0000000000
--- a/mkspecs/common/angle.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-# Renaming these files requires that the LIBRARY entry of their corresponding
-# def files are also updated to reflect the name.
-# The .def files are found in the angle directories:
-#
-# qtbase\src\3rdparty\angle\src\libEGL\libEGL[d?].def
-# qtbase\src\3rdparty\angle\src\libEGL\libGLESv2[d?].def
-
-LIBEGL_NAME="libEGL"
-LIBGLESV2_NAME="libGLESv2"
diff --git a/mkspecs/common/gcc-base-mac.conf b/mkspecs/common/gcc-base-mac.conf
index e9bf780ec1..34211b764d 100644
--- a/mkspecs/common/gcc-base-mac.conf
+++ b/mkspecs/common/gcc-base-mac.conf
@@ -12,12 +12,11 @@ include(gcc-base.conf)
QMAKE_COMPILER_DEFINES += __APPLE__ __GNUC__=4 __APPLE_CC__
-QMAKE_LFLAGS += -headerpad_max_install_names
-
QMAKE_LFLAGS_SHLIB += -single_module -dynamiclib
QMAKE_LFLAGS_PLUGIN += $$QMAKE_LFLAGS_SHLIB
QMAKE_LFLAGS_INCREMENTAL += -undefined suppress -flat_namespace
QMAKE_LFLAGS_SONAME += -install_name$${LITERAL_WHITESPACE}
+QMAKE_LFLAGS_HEADERPAD += -headerpad_max_install_names
QMAKE_LFLAGS_VERSION += -current_version$${LITERAL_WHITESPACE}
QMAKE_LFLAGS_COMPAT_VERSION += -compatibility_version$${LITERAL_WHITESPACE}
diff --git a/mkspecs/common/ios/clang.conf b/mkspecs/common/ios/clang.conf
deleted file mode 100644
index f45b89665f..0000000000
--- a/mkspecs/common/ios/clang.conf
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# compiler settings for iOS clang compilers
-#
-
-# iOS build flags
-QMAKE_IOS_CFLAGS += -fvisibility=hidden -fpascal-strings -fmessage-length=0
-QMAKE_IOS_CFLAGS += -Wno-trigraphs -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -Wno-sign-conversion
-QMAKE_IOS_CXXFLAGS += -fvisibility-inlines-hidden
-
-# Based on the following information, http://clang.llvm.org/doxygen/ObjCRuntime_8h_source.html,
-# we can conclude that it's safe to always pass the following flags
-QMAKE_IOS_OBJ_CFLAGS += -fobjc-nonfragile-abi -fobjc-legacy-dispatch
-
-# But these only apply to non-ARM targets
-!contains(QT_ARCH, arm): QMAKE_IOS_CFLAGS += -fexceptions -fasm-blocks
-
-# Clang 3.1 (and above) flags
-QMAKE_IOS_CFLAGS += -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-implicit-atomic-properties -Wformat -Wno-missing-braces -Wno-unused-function -Wno-unused-label -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-sign-compare -Wpointer-sign -Wno-newline-eof -Wdeprecated-declarations -Winvalid-offsetof -Wno-conversion
-QMAKE_IOS_CXXFLAGS += -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors
-QMAKE_IOS_OBJ_CFLAGS += -Wno-deprecated-implementations -Wprotocol -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector
-
-# Set build flags
-QMAKE_CFLAGS += $$QMAKE_IOS_CFLAGS
-QMAKE_CXXFLAGS += $$QMAKE_IOS_CFLAGS $$QMAKE_IOS_CXXFLAGS
-QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_IOS_OBJ_CFLAGS
-
-QMAKE_IOS_CFLAGS =
-QMAKE_IOS_CXXFLAGS =
-QMAKE_IOS_OBJ_CFLAGS =
diff --git a/mkspecs/common/macx.conf b/mkspecs/common/macx.conf
index 69d731b48a..4be0eb3c39 100644
--- a/mkspecs/common/macx.conf
+++ b/mkspecs/common/macx.conf
@@ -5,4 +5,10 @@
QMAKE_PLATFORM += macos osx macx
QMAKE_MAC_SDK = macosx
+device.sdk = macosx
+device.target = device
+device.dir_affix = $${device.sdk}
+device.CONFIG = $${device.sdk}
+device.deployment_identifier = $${device.sdk}
+
include(mac.conf)
diff --git a/mkspecs/common/msvc-desktop.conf b/mkspecs/common/msvc-desktop.conf
index 1b9d57bff0..b72cdff252 100644
--- a/mkspecs/common/msvc-desktop.conf
+++ b/mkspecs/common/msvc-desktop.conf
@@ -9,8 +9,6 @@ isEmpty(MSC_VER)|isEmpty(MSVC_VER): error("Source mkspec must set both MSC_VER a
# Baseline: Visual Studio 2005 (8.0), VC++ 14.0
#
-include(angle.conf)
-
MAKEFILE_GENERATOR = MSVC.NET
QMAKE_PLATFORM = win32
QMAKE_COMPILER = msvc
@@ -92,8 +90,8 @@ QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib
QMAKE_LIBS_GUI = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib ws2_32.lib ole32.lib user32.lib advapi32.lib
QMAKE_LIBS_NETWORK = ws2_32.lib
QMAKE_LIBS_OPENGL = glu32.lib opengl32.lib gdi32.lib user32.lib
-QMAKE_LIBS_OPENGL_ES2 = $${LIBEGL_NAME}.lib $${LIBGLESV2_NAME}.lib gdi32.lib user32.lib
-QMAKE_LIBS_OPENGL_ES2_DEBUG = $${LIBEGL_NAME}d.lib $${LIBGLESV2_NAME}d.lib gdi32.lib user32.lib
+QMAKE_LIBS_OPENGL_ES2 = gdi32.lib user32.lib
+QMAKE_LIBS_OPENGL_ES2_DEBUG = gdi32.lib user32.lib
QMAKE_LIBS_COMPAT = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib
QMAKE_LIBS_QT_ENTRY = -lqtmain
@@ -107,5 +105,6 @@ VCSOLUTION_EXTENSION = .sln
VCPROJ_KEYWORD = Qt4VSv1.0
include(msvc-base.conf)
+include(windows-gles.conf)
unset(MSC_VER)
diff --git a/mkspecs/common/uikit.conf b/mkspecs/common/uikit.conf
index bfbab36db6..de0fb33351 100644
--- a/mkspecs/common/uikit.conf
+++ b/mkspecs/common/uikit.conf
@@ -3,7 +3,7 @@
#
QMAKE_PLATFORM += uikit
-CONFIG += bitcode reduce_exports
+CONFIG += bitcode reduce_exports shallow_bundle no_qt_rpath
INCLUDEPATH += $$PWD/uikit
DEFINES += DARWIN_NO_CARBON
diff --git a/mkspecs/common/uikit/clang.conf b/mkspecs/common/uikit/clang.conf
new file mode 100644
index 0000000000..6b9b7eea8e
--- /dev/null
+++ b/mkspecs/common/uikit/clang.conf
@@ -0,0 +1,7 @@
+#
+# compiler settings for iOS/tvOS/watchOS clang compilers
+#
+
+# Based on the following information, http://clang.llvm.org/doxygen/ObjCRuntime_8h_source.html,
+# we can conclude that it's safe to always pass the following flags
+QMAKE_OBJECTIVE_CFLAGS += -fobjc-nonfragile-abi -fobjc-legacy-dispatch
diff --git a/mkspecs/common/ios/qmake.conf b/mkspecs/common/uikit/qmake.conf
index b579562236..45a4f0c806 100644
--- a/mkspecs/common/ios/qmake.conf
+++ b/mkspecs/common/uikit/qmake.conf
@@ -1,5 +1,5 @@
#
-# Common build settings for all iOS configurations
+# Common build settings for all iOS/tvOS/watchOS configurations
#
QMAKE_XCODE_CODE_SIGN_IDENTITY = "iPhone Developer"
diff --git a/mkspecs/common/windows-gles.conf b/mkspecs/common/windows-gles.conf
new file mode 100644
index 0000000000..78b96c42d4
--- /dev/null
+++ b/mkspecs/common/windows-gles.conf
@@ -0,0 +1,7 @@
+# Output name of Qt's ANGLE GLES library. (Note that this is different from upstream ANGLE)
+LIBQTANGLE_NAME = QtANGLE
+
+# Set up .lib files used for linking
+QMAKE_LIBS_OPENGL_ES2 = -l$${LIBQTANGLE_NAME} $$QMAKE_LIBS_OPENGL_ES2
+QMAKE_LIBS_OPENGL_ES2_DEBUG = -l$${LIBQTANGLE_NAME}d $$QMAKE_LIBS_OPENGL_ES2_DEBUG
+
diff --git a/mkspecs/common/winrt_winphone/qmake.conf b/mkspecs/common/winrt_winphone/qmake.conf
index 05c9bd39a5..0c3af4a7a8 100644
--- a/mkspecs/common/winrt_winphone/qmake.conf
+++ b/mkspecs/common/winrt_winphone/qmake.conf
@@ -4,8 +4,6 @@
# Written for Microsoft Visual C++
#
-include(../angle.conf)
-
MAKEFILE_GENERATOR = MSBUILD
QMAKE_COMPILER = msvc
QMAKE_PLATFORM = winrt win32
@@ -80,8 +78,6 @@ QMAKE_LIBS += runtimeobject.lib
QMAKE_LIBS_CORE += ws2_32.lib
QMAKE_LIBS_GUI =
QMAKE_LIBS_NETWORK += ws2_32.lib
-QMAKE_LIBS_OPENGL_ES2 = $${LIBEGL_NAME}.lib $${LIBGLESV2_NAME}.lib
-QMAKE_LIBS_OPENGL_ES2_DEBUG = $${LIBEGL_NAME}d.lib $${LIBGLESV2_NAME}d.lib
QMAKE_LIBS_QT_ENTRY = -lqtmain
@@ -98,6 +94,7 @@ WINRT_MANIFEST.capabilities = defaults
WINRT_MANIFEST.capabilities_device = defaults
include(../msvc-base.conf)
+include(../windows-gles.conf)
unset(MSC_VER)
diff --git a/mkspecs/darwin-g++/qmake.conf b/mkspecs/darwin-g++/qmake.conf
index 09c55456ec..85955f7af0 100644
--- a/mkspecs/darwin-g++/qmake.conf
+++ b/mkspecs/darwin-g++/qmake.conf
@@ -56,7 +56,6 @@ QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib
QMAKE_LINK = c++
QMAKE_LINK_SHLIB = c++
-QMAKE_LFLAGS += -headerpad_max_install_names
QMAKE_LFLAGS =
QMAKE_LFLAGS_RELEASE =
QMAKE_LFLAGS_DEBUG =
@@ -65,6 +64,7 @@ QMAKE_LFLAGS_SHLIB = -prebind -dynamiclib -single_module
QMAKE_LFLAGS_PLUGIN = -prebind -bundle
QMAKE_LFLAGS_THREAD =
QMAKE_LFLAGS_SONAME += -install_name$${LITERAL_WHITESPACE}
+QMAKE_LFLAGS_HEADERPAD += -headerpad_max_install_names
QMAKE_LFLAGS_VERSION = -current_version$${LITERAL_WHITESPACE}
QMAKE_LFLAGS_COMPAT_VERSION = -compatibility_version$${LITERAL_WHITESPACE}
diff --git a/mkspecs/devices/common/freebsd_device_post.conf b/mkspecs/devices/common/freebsd_device_post.conf
new file mode 100644
index 0000000000..1d9694af31
--- /dev/null
+++ b/mkspecs/devices/common/freebsd_device_post.conf
@@ -0,0 +1,5 @@
+QMAKE_CFLAGS += $$COMPILER_FLAGS
+QMAKE_CXXFLAGS += $$COMPILER_FLAGS
+QMAKE_LFLAGS += $$LINKER_FLAGS
+
+deviceSanityCheckCompiler()
diff --git a/mkspecs/devices/common/freebsd_device_pre.conf b/mkspecs/devices/common/freebsd_device_pre.conf
new file mode 100644
index 0000000000..97d70b5265
--- /dev/null
+++ b/mkspecs/devices/common/freebsd_device_pre.conf
@@ -0,0 +1,27 @@
+QT_QPA_DEFAULT_PLATFORM = bsdfb
+
+MAKEFILE_GENERATOR = UNIX
+CONFIG += incremental
+QMAKE_INCREMENTAL_STYLE = sublib
+
+include(../../freebsd-clang/qmake.conf)
+
+load(device_config)
+
+# modifications to g++-unix.conf
+QMAKE_CC = $${CROSS_COMPILE}cc
+QMAKE_CXX = $${CROSS_COMPILE}c++
+QMAKE_LINK = $${QMAKE_CXX}
+QMAKE_LINK_SHLIB = $${QMAKE_CXX}
+
+# modifications to linux.conf
+QMAKE_AR = $${CROSS_COMPILE}ar cqs
+QMAKE_OBJCOPY = $${CROSS_COMPILE}objcopy
+QMAKE_NM = $${CROSS_COMPILE}nm -P
+QMAKE_STRIP = $${CROSS_COMPILE}strip
+
+# Do not set QMAKE_INCDIR to system include here
+# it messes up system include order. --sysroot is
+# sufficient. See link for details:
+# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213217
+QMAKE_LIBDIR = $$[QT_SYSROOT]/usr/lib
diff --git a/mkspecs/devices/freebsd-generic-clang/qmake.conf b/mkspecs/devices/freebsd-generic-clang/qmake.conf
new file mode 100644
index 0000000000..1c3ca9b1f7
--- /dev/null
+++ b/mkspecs/devices/freebsd-generic-clang/qmake.conf
@@ -0,0 +1,9 @@
+#
+# Generic qmake configuration for cross-compiling with clang
+#
+# A minimal configure line could look something like this:
+# ./configure -device freebsd-generic-clang -device-option CROSS_COMPILE=/usr/armv6-freebsd/usr/bin/
+
+include(../common/freebsd_device_pre.conf)
+include(../common/freebsd_device_post.conf)
+load(qt_config)
diff --git a/mkspecs/macx-clang-32/qplatformdefs.h b/mkspecs/devices/freebsd-generic-clang/qplatformdefs.h
index 063491dd90..de53ea5e16 100644
--- a/mkspecs/macx-clang-32/qplatformdefs.h
+++ b/mkspecs/devices/freebsd-generic-clang/qplatformdefs.h
@@ -37,5 +37,4 @@
**
****************************************************************************/
-#include "../common/mac/qplatformdefs.h"
-
+#include "../../common/bsd/qplatformdefs.h"
diff --git a/mkspecs/devices/freebsd-rasp-pi-clang/qmake.conf b/mkspecs/devices/freebsd-rasp-pi-clang/qmake.conf
new file mode 100644
index 0000000000..2105f08c78
--- /dev/null
+++ b/mkspecs/devices/freebsd-rasp-pi-clang/qmake.conf
@@ -0,0 +1,25 @@
+# qmake configuration for the Raspberry Pi and Raspberry Pi 2
+
+include(../common/freebsd_device_pre.conf)
+
+QT_QPA_DEFAULT_PLATFORM = eglfs
+# Preferred eglfs backend
+EGLFS_DEVICE_INTEGRATION = eglfs_brcm
+
+QMAKE_LIBDIR_OPENGL_ES2 = $$[QT_SYSROOT]/usr/local/lib
+QMAKE_LIBDIR_EGL = $$QMAKE_LIBDIR_OPENGL_ES2
+QMAKE_LIBDIR_OPENVG = $$QMAKE_LIBDIR_OPENGL_ES2
+
+QMAKE_INCDIR_EGL = $$[QT_SYSROOT]/usr/local/include \
+ $$[QT_SYSROOT]/usr/local/include/interface/vcos/pthreads \
+ $$[QT_SYSROOT]/usr/local/include/interface/vmcs_host/linux
+QMAKE_INCDIR_OPENGL_ES2 = $${QMAKE_INCDIR_EGL}
+QMAKE_INCDIR_OPENVG = $${QMAKE_INCDIR_EGL}
+
+QMAKE_LIBS_EGL = -lEGL -lGLESv2
+QMAKE_LIBS_OPENGL_ES2 = $${QMAKE_LIBS_EGL}
+QMAKE_LIBS_OPENVG = -lEGL -lOpenVG -lGLESv2
+
+include(../common/freebsd_device_post.conf)
+
+load(qt_config)
diff --git a/mkspecs/macx-g++42/qplatformdefs.h b/mkspecs/devices/freebsd-rasp-pi-clang/qplatformdefs.h
index 063491dd90..3fd73d421a 100644
--- a/mkspecs/macx-g++42/qplatformdefs.h
+++ b/mkspecs/devices/freebsd-rasp-pi-clang/qplatformdefs.h
@@ -37,5 +37,4 @@
**
****************************************************************************/
-#include "../common/mac/qplatformdefs.h"
-
+#include "../freebsd-generic-clang/qplatformdefs.h"
diff --git a/mkspecs/devices/linux-jetson-tx1-g++/qmake.conf b/mkspecs/devices/linux-jetson-tx1-g++/qmake.conf
new file mode 100644
index 0000000000..06cf329f3a
--- /dev/null
+++ b/mkspecs/devices/linux-jetson-tx1-g++/qmake.conf
@@ -0,0 +1,51 @@
+#
+# qmake configuration for Jetson TX1 boards running 64-bit Linux For Tegra
+# (tested with R24.2, sample root filesystem)
+#
+# Note that this environment has been tested with X11 only.
+#
+# A typical configure line might look like the following:
+#
+# configure \
+# -device linux-jetson-tx1-g++ \
+# -device-option CROSS_COMPILE=/opt/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- \
+# -sysroot /opt/Linux_for_Tegra/rootfs
+#
+# Note that this builds for GLX + OpenGL. To use EGL + OpenGL ES instead, pass
+# -opengl es2 and ensure the rootfs has the headers (rootfs/usr/include/EGL,
+# GLES2, GLES3), which may not be the case out of the box.
+#
+# Check the configure output carefully, some features may be disabled due to the
+# rootfs not having the necessary dev files.
+#
+# If getting cryptic linker errors from static libs like libm.a, check that the
+# symlinks libm.so, libz.so, etc. under rootfs/usr/lib/aarch64-linux-gnu are not
+# broken. If they are, due to using absolute paths, change them so that they are
+# relative to rootfs.
+
+include(../common/linux_device_pre.conf)
+
+QMAKE_INCDIR += \
+ $$[QT_SYSROOT]/usr/include \
+ $$[QT_SYSROOT]/usr/include/aarch64-linux-gnu
+
+QMAKE_LIBDIR += \
+ $$[QT_SYSROOT]/usr/lib \
+ $$[QT_SYSROOT]/lib/aarch64-linux-gnu \
+ $$[QT_SYSROOT]/usr/lib/aarch64-linux-gnu
+
+QMAKE_LFLAGS += \
+ -Wl,-rpath-link,$$[QT_SYSROOT]/usr/lib \
+ -Wl,-rpath-link,$$[QT_SYSROOT]/usr/lib/aarch64-linux-gnu \
+ -Wl,-rpath-link,$$[QT_SYSROOT]/usr/lib/aarch64-linux-gnu/tegra \
+ -Wl,-rpath-link,$$[QT_SYSROOT]/lib/aarch64-linux-gnu
+
+DISTRO_OPTS += aarch64
+COMPILER_FLAGS += -mtune=cortex-a57.cortex-a53 -march=armv8-a
+
+# When configured with -opengl es2, eglfs will be functional with its
+# dummy fullscreen X11 backend, in addition to xcb.
+EGLFS_DEVICE_INTEGRATION = eglfs_x11
+
+include(../common/linux_arm_device_post.conf)
+load(qt_config)
diff --git a/mkspecs/macx-g++-32/qplatformdefs.h b/mkspecs/devices/linux-jetson-tx1-g++/qplatformdefs.h
index 063491dd90..e927f75015 100644
--- a/mkspecs/macx-g++-32/qplatformdefs.h
+++ b/mkspecs/devices/linux-jetson-tx1-g++/qplatformdefs.h
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the qmake spec of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,5 +37,4 @@
**
****************************************************************************/
-#include "../common/mac/qplatformdefs.h"
-
+#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/devices/linux-rcar-h2-g++/qmake.conf b/mkspecs/devices/linux-rcar-h2-g++/qmake.conf
new file mode 100644
index 0000000000..6a9346e4d3
--- /dev/null
+++ b/mkspecs/devices/linux-rcar-h2-g++/qmake.conf
@@ -0,0 +1,31 @@
+#
+# qmake configuration for the Renesas R-Car H2 (Lager)
+#
+# Both eglfs and wayland should be functional, via DRM/KMS.
+#
+# Below is an example configure line that assumes the SDK is in
+# $HOME/rcar/toolchain. 'make install' will copy the host tools to qt5-host and
+# the target contents to qt5. The latter is what should be deployed to
+# /usr/local/qt5 on the target device.
+#
+# ./configure -prefix /usr/local/qt5 -extprefix $HOME/rcar/qt5 -hostprefix $HOME/rcar/qt5-host \
+# -device rcar-h2 \
+# -device-option CROSS_COMPILE=$HOME/rcar/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi- \
+# -sysroot $HOME/rcar/toolchain/sysroots/cortexa15hf-neon-poky-linux-gnueabi \
+# -nomake examples -nomake tests -v
+
+include(../common/linux_device_pre.conf)
+
+QMAKE_LIBS_EGL += -lEGL
+QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL
+QMAKE_LIBS_OPENVG += -lOpenVG -lEGL
+
+DISTRO_OPTS += hard-float
+COMPILER_FLAGS += -mtune=cortex-a15 -march=armv7-a -mfpu=neon-vfpv4
+
+# Preferred eglfs backend
+EGLFS_DEVICE_INTEGRATION = eglfs_kms
+
+include(../common/linux_arm_device_post.conf)
+
+load(qt_config)
diff --git a/mkspecs/macx-g++40/qplatformdefs.h b/mkspecs/devices/linux-rcar-h2-g++/qplatformdefs.h
index 063491dd90..e927f75015 100644
--- a/mkspecs/macx-g++40/qplatformdefs.h
+++ b/mkspecs/devices/linux-rcar-h2-g++/qplatformdefs.h
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the qmake spec of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,5 +37,4 @@
**
****************************************************************************/
-#include "../common/mac/qplatformdefs.h"
-
+#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf
index 99c92d15f0..1b2e5d5db4 100644
--- a/mkspecs/features/mac/default_post.prf
+++ b/mkspecs/features/mac/default_post.prf
@@ -1,4 +1,9 @@
load(default_post)
+
+# Ensure that we process sdk.prf first, as it will update QMAKE_CXX
+# and friends that other features/extra compilers may depend on.
+sdk: load(sdk)
+
!no_objective_c:CONFIG += objective_c
qt {
@@ -24,11 +29,63 @@ qt {
}
}
-macx-xcode:!isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) {
- debug_information_format.name = DEBUG_INFORMATION_FORMAT
- debug_information_format.value = $$QMAKE_XCODE_DEBUG_INFORMATION_FORMAT
- debug_information_format.build = debug
- QMAKE_MAC_XCODE_SETTINGS += debug_information_format
+# Add the same default rpaths as Xcode does for new projects.
+# This is especially important for iOS/tvOS/watchOS where no other option is possible.
+!no_default_rpath {
+ QMAKE_RPATHDIR += @executable_path/Frameworks
+ equals(TEMPLATE, lib):!plugin:lib_bundle: QMAKE_RPATHDIR += @loader_path/Frameworks
+}
+
+!bitcode: QMAKE_LFLAGS += $$QMAKE_LFLAGS_HEADERPAD
+
+macx-xcode {
+ !isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) {
+ debug_information_format.name = DEBUG_INFORMATION_FORMAT
+ debug_information_format.value = $$QMAKE_XCODE_DEBUG_INFORMATION_FORMAT
+ debug_information_format.build = debug
+ QMAKE_MAC_XCODE_SETTINGS += debug_information_format
+ }
+
+ QMAKE_XCODE_ARCHS =
+
+ arch_device.name = "ARCHS[sdk=$${device.sdk}*]"
+ arch_device.value = $$QMAKE_APPLE_DEVICE_ARCHS
+ QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_DEVICE_ARCHS
+ QMAKE_MAC_XCODE_SETTINGS += arch_device
+
+ simulator {
+ arch_simulator.name = "ARCHS[sdk=$${simulator.sdk}*]"
+ arch_simulator.value = $$QMAKE_APPLE_SIMULATOR_ARCHS
+ QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_SIMULATOR_ARCHS
+ QMAKE_MAC_XCODE_SETTINGS += arch_simulator
+ }
+
+ only_active_arch.name = ONLY_ACTIVE_ARCH
+ only_active_arch.value = YES
+ only_active_arch.build = debug
+ QMAKE_MAC_XCODE_SETTINGS += only_active_arch
+} else {
+ VALID_ARCHS =
+ device|!simulator: VALID_ARCHS += $$QMAKE_APPLE_DEVICE_ARCHS
+ simulator: VALID_ARCHS += $$QMAKE_APPLE_SIMULATOR_ARCHS
+
+ isEmpty(VALID_ARCHS): \
+ error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture")
+
+ single_arch: VALID_ARCHS = $$first(VALID_ARCHS)
+
+ ACTIVE_ARCHS = $(filter $(EXPORT_VALID_ARCHS), $(ARCHS))
+ ARCH_ARGS = $(foreach arch, $(if $(EXPORT_ACTIVE_ARCHS), $(EXPORT_ACTIVE_ARCHS), $(EXPORT_VALID_ARCHS)), -arch $(arch))
+
+ QMAKE_EXTRA_VARIABLES += VALID_ARCHS ACTIVE_ARCHS ARCH_ARGS
+
+ arch_flags = $(EXPORT_ARCH_ARGS)
+
+ QMAKE_CFLAGS += $$arch_flags
+ QMAKE_CXXFLAGS += $$arch_flags
+ QMAKE_LFLAGS += $$arch_flags
+
+ QMAKE_PCH_ARCHS = $$VALID_ARCHS
}
cache(QMAKE_XCODE_DEVELOPER_PATH, stash)
diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf
index c7f5850aa0..be885e52ee 100644
--- a/mkspecs/features/mac/sdk.prf
+++ b/mkspecs/features/mac/sdk.prf
@@ -49,28 +49,36 @@ for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_
}
!equals(MAKEFILE_GENERATOR, XCODE) {
- uikit:!host_build {
- ios: deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET
- tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET
- watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET
-
- device|!simulator: device_archs = $$QMAKE_APPLE_DEVICE_ARCHS
- simulator: simulator_archs = $$QMAKE_APPLE_SIMULATOR_ARCHS
- archs = $$device_archs $$simulator_archs
-
- isEmpty(archs): \
- error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture")
+ macos: deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET
+ ios: deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET
+ tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET
+ watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET
+
+ device|!simulator: device_archs = $$QMAKE_APPLE_DEVICE_ARCHS
+ simulator: simulator_archs = $$QMAKE_APPLE_SIMULATOR_ARCHS
+ archs = $$device_archs $$simulator_archs
+
+ isEmpty(archs): \
+ error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture")
+
+ single_arch {
+ device_archs = $$first(device_archs)
+ simulator_archs = $$first(simulator_archs)
+ archs = $$first(archs)
+ }
+ # If we're doing a simulator and device build, device and simulator architectures
+ # use different paths and flags for the sysroot and deployment target switch, so we
+ # must multiplex them across multiple architectures using -Xarch. Otherwise we fall
+ # back to the simple path. This is not strictly necessary but results in cleaner
+ # command lines and makes it easier for people to override EXPORT_VALID_ARCHS to
+ # limit individual rules to a different set of architecture(s) from the overall
+ # build (such as machtest in QtCore).
+ simulator:device {
QMAKE_XARCH_CFLAGS =
QMAKE_XARCH_LFLAGS =
QMAKE_EXTRA_VARIABLES += QMAKE_XARCH_CFLAGS QMAKE_XARCH_LFLAGS
- single_arch {
- device_archs = $$first(device_archs)
- simulator_archs = $$first(simulator_archs)
- archs = $$first(archs)
- }
-
for(arch, archs) {
contains(simulator_archs, $$arch) {
sdk = $$simulator.sdk
@@ -98,27 +106,30 @@ for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_
QMAKE_XARCH_LFLAGS_$${arch}
}
- QMAKE_CFLAGS_USE_PRECOMPILE =
- for(arch, archs) {
- QMAKE_CFLAGS_USE_PRECOMPILE += \
- -Xarch_$${arch} \
- -include${QMAKE_PCH_OUTPUT_$${arch}}
- }
- QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
- QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
- QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
-
- QMAKE_PCH_OUTPUT_EXT = _${QMAKE_PCH_ARCH}$${QMAKE_PCH_OUTPUT_EXT}
- } else: osx {
- version_identifier = macosx
- deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET
+ QMAKE_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
+ QMAKE_CXXFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
+ QMAKE_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS)
+ } else {
+ simulator: \
+ version_identifier = $$simulator.deployment_identifier
+ else: \
+ version_identifier = $$device.deployment_identifier
version_min_flag = -m$${version_identifier}-version-min=$$deployment_target
QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag
QMAKE_CXXFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag
QMAKE_LFLAGS += -Wl,-syslibroot,$$QMAKE_MAC_SDK_PATH $$version_min_flag
}
- QMAKE_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
- QMAKE_CXXFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
- QMAKE_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS)
+ # Enable precompiled headers for multiple architectures
+ QMAKE_CFLAGS_USE_PRECOMPILE =
+ for(arch, archs) {
+ QMAKE_CFLAGS_USE_PRECOMPILE += \
+ -Xarch_$${arch} \
+ -include${QMAKE_PCH_OUTPUT_$${arch}}
+ }
+ QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+ QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+ QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+
+ QMAKE_PCH_OUTPUT_EXT = _${QMAKE_PCH_ARCH}$${QMAKE_PCH_OUTPUT_EXT}
}
diff --git a/mkspecs/features/moc.prf b/mkspecs/features/moc.prf
index 59ed81b49e..0bc7482ec7 100644
--- a/mkspecs/features/moc.prf
+++ b/mkspecs/features/moc.prf
@@ -27,7 +27,7 @@ win32:count(MOC_INCLUDEPATH, 40, >) {
# QNX's compiler sets "gcc" config, but does not support the -dM option;
# UIKit builds are always multi-arch due to simulator_and_device (unless
# -sdk is used) so this feature cannot possibly work.
-if(gcc|intel_icl|msvc):!rim_qcc:!uikit {
+if(gcc|intel_icl|msvc):!rim_qcc:!uikit:if(!macos|count(QMAKE_APPLE_DEVICE_ARCHS, 1)) {
moc_predefs.CONFIG = no_link
gcc: moc_predefs.commands = $$QMAKE_CXX $$QMAKE_CXXFLAGS -dM -E -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
else:intel_icl: moc_predefs.commands = $$QMAKE_CXX $$QMAKE_CXXFLAGS -QdM -P -Fi${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf
index 9bf0d2fad3..07b7565f48 100644
--- a/mkspecs/features/qt.prf
+++ b/mkspecs/features/qt.prf
@@ -246,13 +246,13 @@ contains(qt_module_deps, qml): \
# copy qml files. this part is platform spesific.
mac {
- osx {
+ !shallow_bundle {
# Note: user can override QMAKE_BUNDLE_QML from pro file to change target bundle path
isEmpty(QMAKE_QML_BUNDLE_PATH):QMAKE_QML_BUNDLE_PATH = "Resources/qt_qml"
qmlTargetPath = $$OUT_PWD/$${TARGET}.app/Contents/$$QMAKE_QML_BUNDLE_PATH
qtconfTargetPath = $$OUT_PWD/$${TARGET}.app/Contents/Resources/qt.conf
} else {
- # iOS: flat bundle layout (no Contents/Resources)
+ # shallow bundle layout (no Contents/Resources)
isEmpty(QMAKE_QML_BUNDLE_PATH):QMAKE_QML_BUNDLE_PATH = "qt_qml"
qmlTargetPath = $CODESIGNING_FOLDER_PATH/$$QMAKE_QML_BUNDLE_PATH
qtconfTargetPath = $CODESIGNING_FOLDER_PATH/qt.conf
diff --git a/mkspecs/features/qt_build_config.prf b/mkspecs/features/qt_build_config.prf
index 95e63ecae0..f543b47351 100644
--- a/mkspecs/features/qt_build_config.prf
+++ b/mkspecs/features/qt_build_config.prf
@@ -80,6 +80,8 @@ CONFIG += \
# resolved), nor functional (.res files end up in .prl files and break things).
unix: CONFIG += explicitlib
+# By default we want tests on macOS to be built as standalone executables
+macos: CONFIG += testcase_no_bundle
defineTest(qtBuildPart) {
bp = $$eval($$upper($$section(_QMAKE_CONF_, /, -2, -2))_BUILD_PARTS)
diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf
index d30983f62b..fefd36a7b8 100644
--- a/mkspecs/features/qt_common.prf
+++ b/mkspecs/features/qt_common.prf
@@ -12,6 +12,8 @@
QMAKE_DIR_REPLACE_SANE += DESTDIR
CONFIG -= debug_and_release_target
+DEFINES *= QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
+
qtConfig(c++11): CONFIG += c++11 strict_c++
qtConfig(c++14): CONFIG += c++14
qtConfig(c++1z): CONFIG += c++1z
diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf
index 289e2250bd..1181566fec 100644
--- a/mkspecs/features/qt_configure.prf
+++ b/mkspecs/features/qt_configure.prf
@@ -739,6 +739,10 @@ defineTest(qtConfTest_compile) {
# can work with a regular main() entry point on Windows.
qmake_configs += "console"
+ # for platforms with multiple architectures (macOS, iOS, tvOS, watchOS),
+ # make sure tests are only built for a single architecture
+ qmake_configs += "single_arch"
+
qmake_args += "\"CONFIG += $$qmake_configs\""
!$$host {
diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
index 999cd18154..c00fdb73f8 100644
--- a/mkspecs/features/qt_functions.prf
+++ b/mkspecs/features/qt_functions.prf
@@ -33,11 +33,13 @@ defineReplace(qtRelativeRPathBase) {
darwin {
if(equals(TEMPLATE, app):app_bundle)|\
if(equals(TEMPLATE, lib):plugin:plugin_bundle) {
- ios: return($$target.path/$${TARGET}.app)
+ shallow_bundle: return($$target.path/$${TARGET}.app)
return($$target.path/$${TARGET}.app/Contents/MacOS)
}
- equals(TEMPLATE, lib):!plugin:lib_bundle: \
+ equals(TEMPLATE, lib):!plugin:lib_bundle {
+ shallow_bundle: return($$target.path/$${TARGET}.framework)
return($$target.path/$${TARGET}.framework/Versions/Current)
+ }
}
return($$target.path)
}
diff --git a/mkspecs/features/resolve_target.prf b/mkspecs/features/resolve_target.prf
index 629a02a4f3..8678c33ecd 100644
--- a/mkspecs/features/resolve_target.prf
+++ b/mkspecs/features/resolve_target.prf
@@ -32,7 +32,17 @@ win32 {
mac {
equals(TEMPLATE, lib) {
- lib_bundle {
+ plugin:plugin_bundle {
+ !isEmpty(QMAKE_PLUGIN_BUNDLE_NAME): \
+ plugin_target = $$QMAKE_PLUGIN_BUNDLE_NAME
+ else: \
+ plugin_target = $$TARGET
+ QMAKE_RESOLVED_BUNDLE = $${QMAKE_RESOLVED_TARGET}$${plugin_target}.plugin
+ !shallow_bundle: \
+ QMAKE_RESOLVED_TARGET = $${QMAKE_RESOLVED_BUNDLE}/Contents/MacOS/$${TARGET}
+ else: \
+ QMAKE_RESOLVED_TARGET = $${QMAKE_RESOLVED_BUNDLE}$${TARGET}
+ } else: !plugin:lib_bundle {
!isEmpty(QMAKE_FRAMEWORK_BUNDLE_NAME): \
framework_target = $$QMAKE_FRAMEWORK_BUNDLE_NAME
else: \
diff --git a/mkspecs/features/testcase.prf b/mkspecs/features/testcase.prf
index c202664c47..3e1537dde0 100644
--- a/mkspecs/features/testcase.prf
+++ b/mkspecs/features/testcase.prf
@@ -6,6 +6,9 @@
# qt_build_config tells us to re-enable exceptions here.
testcase_exceptions: CONFIG += exceptions
+# Set in qt_build_config.prf
+testcase_no_bundle: CONFIG -= app_bundle
+
benchmark: type = benchmark
else: type = check
diff --git a/mkspecs/features/uikit/default_post.prf b/mkspecs/features/uikit/default_post.prf
index 6e23e23a6a..0a2e4122f5 100644
--- a/mkspecs/features/uikit/default_post.prf
+++ b/mkspecs/features/uikit/default_post.prf
@@ -53,40 +53,10 @@ macx-xcode {
}
}
-macx-xcode {
- arch_device.name = "ARCHS[sdk=$${device.sdk}*]"
- arch_simulator.name = "ARCHS[sdk=$${simulator.sdk}*]"
-
- arch_device.value = $$QMAKE_APPLE_DEVICE_ARCHS
- arch_simulator.value = $$QMAKE_APPLE_SIMULATOR_ARCHS
- QMAKE_XCODE_ARCHS = $$QMAKE_APPLE_DEVICE_ARCHS $$QMAKE_APPLE_SIMULATOR_ARCHS
-
- QMAKE_MAC_XCODE_SETTINGS += arch_device arch_simulator
-
- only_active_arch.name = ONLY_ACTIVE_ARCH
- only_active_arch.value = YES
- only_active_arch.build = debug
- QMAKE_MAC_XCODE_SETTINGS += only_active_arch
-} else {
- VALID_ARCHS =
- device|!simulator: VALID_ARCHS += $$QMAKE_APPLE_DEVICE_ARCHS
- simulator: VALID_ARCHS += $$QMAKE_APPLE_SIMULATOR_ARCHS
-
- isEmpty(VALID_ARCHS): \
- error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture")
-
- single_arch: VALID_ARCHS = $$first(VALID_ARCHS)
-
- ACTIVE_ARCHS = $(filter $(EXPORT_VALID_ARCHS), $(ARCHS))
- ARCH_ARGS = $(foreach arch, $(if $(EXPORT_ACTIVE_ARCHS), $(EXPORT_ACTIVE_ARCHS), $(EXPORT_VALID_ARCHS)), -arch $(arch))
-
- QMAKE_EXTRA_VARIABLES += VALID_ARCHS ACTIVE_ARCHS ARCH_ARGS
-
- arch_flags = $(EXPORT_ARCH_ARGS)
-
- QMAKE_CFLAGS += $$arch_flags
- QMAKE_CXXFLAGS += $$arch_flags
- QMAKE_LFLAGS += $$arch_flags
-
- QMAKE_PCH_ARCHS = $$VALID_ARCHS
+!xcodebuild:equals(TEMPLATE, app):!isEmpty(QMAKE_INFO_PLIST) {
+ # Only link in photo library support if Info.plist contains
+ # NSPhotoLibraryUsageDescription. Otherwise it will be rejected from AppStore.
+ plist_path = $$absolute_path($$QMAKE_INFO_PLIST, $$_PRO_FILE_PWD_)
+ system("/usr/libexec/PlistBuddy -c 'Print NSPhotoLibraryUsageDescription' $$system_quote($$plist_path) &>/dev/null"): \
+ QTPLUGIN += qiosnsphotolibrarysupport
}
diff --git a/mkspecs/features/uikit/default_pre.prf b/mkspecs/features/uikit/default_pre.prf
index ecc3b9d3ab..00e29a5c8b 100644
--- a/mkspecs/features/uikit/default_pre.prf
+++ b/mkspecs/features/uikit/default_pre.prf
@@ -23,3 +23,6 @@ load(default_pre)
# Check for supported Xcode versions
lessThan(QMAKE_XCODE_VERSION, "4.3"): \
error("This mkspec requires Xcode 4.3 or later")
+
+ios:shared:lessThan(QMAKE_IOS_DEPLOYMENT_TARGET, "8.0"): \
+ QMAKE_IOS_DEPLOYMENT_TARGET = 8.0
diff --git a/mkspecs/features/uikit/qt_config.prf b/mkspecs/features/uikit/qt_config.prf
deleted file mode 100644
index 5fa5a536f8..0000000000
--- a/mkspecs/features/uikit/qt_config.prf
+++ /dev/null
@@ -1,19 +0,0 @@
-load(qt_config)
-
-isEmpty(QT_ARCH) {
- # The configure tests are run without QT_ARCH being resolved yet, which
- # means we fail to pass -arch to the compiler, resulting in broke tests.
- # As the Xcode toolchain doesn't seem to have a way to auto-detect the
- # arch based on the SDK, we have to hard-code the arch for configure.
- contains(QMAKE_MAC_SDK, $${device.sdk}.*) {
- QT_ARCH = arm
- } else { # Simulator
- ios: QT_ARCH = i386
- tvos: QT_ARCH = x64
- watchos: QT_ARCH = i386
- }
-
- # Prevent the arch/config tests from building as multi-arch binaries,
- # as we only want the lowest common denominator features.
- CONFIG += single_arch
-}
diff --git a/mkspecs/features/uikit/sdk.prf b/mkspecs/features/uikit/sdk.prf
index 287441c760..0bfc26211a 100644
--- a/mkspecs/features/uikit/sdk.prf
+++ b/mkspecs/features/uikit/sdk.prf
@@ -1,4 +1,3 @@
-
load(sdk)
macx-xcode {
diff --git a/mkspecs/macx-clang-32/Info.plist.app b/mkspecs/macx-clang-32/Info.plist.app
deleted file mode 100644
index 8e44bd7f60..0000000000
--- a/mkspecs/macx-clang-32/Info.plist.app
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
- <key>CFBundleIconFile</key>
- <string>@ICON@</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@EXECUTABLE@</string>
- <key>CFBundleIdentifier</key>
- <string>@BUNDLEIDENTIFIER@</string>
- <key>NOTE</key>
- <string>This file was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/macx-clang-32/Info.plist.dSYM.in b/mkspecs/macx-clang-32/Info.plist.dSYM.in
deleted file mode 100644
index a8c8d0d4fb..0000000000
--- a/mkspecs/macx-clang-32/Info.plist.dSYM.in
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
- <dict>
- <key>CFBundleIdentifier</key>
- <string>com.apple.xcode.dsym.$${BUNDLEIDENTIFIER}</string>
- <key>CFBundlePackageType</key>
- <string>dSYM</string>
- <key>CFBundleSignature</key>
- <string>????</string>
-!!IF !isEmpty(VERSION)
- <key>CFBundleShortVersionString</key>
- <string>$${VER_MAJ}.$${VER_MIN}</string>
- <key>CFBundleVersion</key>
- <string>$${VER_MAJ}.$${VER_MIN}.$${VER_PAT}</string>
-!!ENDIF
- </dict>
-</plist>
diff --git a/mkspecs/macx-clang-32/Info.plist.lib b/mkspecs/macx-clang-32/Info.plist.lib
deleted file mode 100644
index 7cbdb9af12..0000000000
--- a/mkspecs/macx-clang-32/Info.plist.lib
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundlePackageType</key>
- <string>FMWK</string>
- <key>CFBundleShortVersionString</key>
- <string>@SHORT_VERSION@</string>
- <key>CFBundleVersion</key>
- <string>@FULL_VERSION@</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@LIBRARY@</string>
- <key>CFBundleIdentifier</key>
- <string>@BUNDLEIDENTIFIER@</string>
- <key>NOTE</key>
- <string>Please, do NOT change this file -- It was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/macx-clang-32/qmake.conf b/mkspecs/macx-clang-32/qmake.conf
deleted file mode 100644
index ba3c7cab6c..0000000000
--- a/mkspecs/macx-clang-32/qmake.conf
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# qmake configuration for 32-bit Clang on OS X
-#
-
-include(../common/macx.conf)
-include(../common/gcc-base-mac.conf)
-include(../common/clang.conf)
-include(../common/clang-mac.conf)
-
-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
-
-QMAKE_CFLAGS += -arch i386
-QMAKE_CXXFLAGS += -arch i386
-QMAKE_LFLAGS += -arch i386
-
-load(qt_config)
diff --git a/mkspecs/macx-clang/qmake.conf b/mkspecs/macx-clang/qmake.conf
index 4d56d771a1..ebae6e36ca 100644
--- a/mkspecs/macx-clang/qmake.conf
+++ b/mkspecs/macx-clang/qmake.conf
@@ -2,11 +2,13 @@
# qmake configuration for Clang on OS X
#
+QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
+
+QMAKE_APPLE_DEVICE_ARCHS = x86_64
+
include(../common/macx.conf)
include(../common/gcc-base-mac.conf)
include(../common/clang.conf)
include(../common/clang-mac.conf)
-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
-
load(qt_config)
diff --git a/mkspecs/macx-g++-32/Info.plist.app b/mkspecs/macx-g++-32/Info.plist.app
deleted file mode 100644
index 8e44bd7f60..0000000000
--- a/mkspecs/macx-g++-32/Info.plist.app
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
- <key>CFBundleIconFile</key>
- <string>@ICON@</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@EXECUTABLE@</string>
- <key>CFBundleIdentifier</key>
- <string>@BUNDLEIDENTIFIER@</string>
- <key>NOTE</key>
- <string>This file was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/macx-g++-32/Info.plist.dSYM.in b/mkspecs/macx-g++-32/Info.plist.dSYM.in
deleted file mode 100644
index a8c8d0d4fb..0000000000
--- a/mkspecs/macx-g++-32/Info.plist.dSYM.in
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
- <dict>
- <key>CFBundleIdentifier</key>
- <string>com.apple.xcode.dsym.$${BUNDLEIDENTIFIER}</string>
- <key>CFBundlePackageType</key>
- <string>dSYM</string>
- <key>CFBundleSignature</key>
- <string>????</string>
-!!IF !isEmpty(VERSION)
- <key>CFBundleShortVersionString</key>
- <string>$${VER_MAJ}.$${VER_MIN}</string>
- <key>CFBundleVersion</key>
- <string>$${VER_MAJ}.$${VER_MIN}.$${VER_PAT}</string>
-!!ENDIF
- </dict>
-</plist>
diff --git a/mkspecs/macx-g++-32/Info.plist.lib b/mkspecs/macx-g++-32/Info.plist.lib
deleted file mode 100644
index 7cbdb9af12..0000000000
--- a/mkspecs/macx-g++-32/Info.plist.lib
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundlePackageType</key>
- <string>FMWK</string>
- <key>CFBundleShortVersionString</key>
- <string>@SHORT_VERSION@</string>
- <key>CFBundleVersion</key>
- <string>@FULL_VERSION@</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@LIBRARY@</string>
- <key>CFBundleIdentifier</key>
- <string>@BUNDLEIDENTIFIER@</string>
- <key>NOTE</key>
- <string>Please, do NOT change this file -- It was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/macx-g++-32/qmake.conf b/mkspecs/macx-g++-32/qmake.conf
deleted file mode 100644
index 3cd707d537..0000000000
--- a/mkspecs/macx-g++-32/qmake.conf
+++ /dev/null
@@ -1,23 +0,0 @@
-#macx-g++ (different from g++.conf)
-
-#
-# qmake configuration for macx-g++
-#
-# OS X + command-line compiler
-#
-
-MAKEFILE_GENERATOR = UNIX
-CONFIG += app_bundle incremental global_init_link_order lib_version_first
-QMAKE_INCREMENTAL_STYLE = sublib
-
-include(../common/macx.conf)
-include(../common/gcc-base-mac.conf)
-include(../common/g++-macx.conf)
-
-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
-
-QMAKE_CFLAGS += -arch i386
-QMAKE_CXXFLAGS += -arch i386
-QMAKE_LFLAGS += -arch i386
-
-load(qt_config)
diff --git a/mkspecs/macx-g++/qmake.conf b/mkspecs/macx-g++/qmake.conf
index 5b3105c668..7cabdaab12 100644
--- a/mkspecs/macx-g++/qmake.conf
+++ b/mkspecs/macx-g++/qmake.conf
@@ -10,10 +10,12 @@ MAKEFILE_GENERATOR = UNIX
CONFIG += app_bundle incremental global_init_link_order lib_version_first
QMAKE_INCREMENTAL_STYLE = sublib
+QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
+
+QMAKE_APPLE_DEVICE_ARCHS = x86_64
+
include(../common/macx.conf)
include(../common/gcc-base-mac.conf)
include(../common/g++-macx.conf)
-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
-
load(qt_config)
diff --git a/mkspecs/macx-g++40/Info.plist.app b/mkspecs/macx-g++40/Info.plist.app
deleted file mode 100644
index 8e44bd7f60..0000000000
--- a/mkspecs/macx-g++40/Info.plist.app
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
- <key>CFBundleIconFile</key>
- <string>@ICON@</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@EXECUTABLE@</string>
- <key>CFBundleIdentifier</key>
- <string>@BUNDLEIDENTIFIER@</string>
- <key>NOTE</key>
- <string>This file was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/macx-g++40/Info.plist.dSYM.in b/mkspecs/macx-g++40/Info.plist.dSYM.in
deleted file mode 100644
index a8c8d0d4fb..0000000000
--- a/mkspecs/macx-g++40/Info.plist.dSYM.in
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
- <dict>
- <key>CFBundleIdentifier</key>
- <string>com.apple.xcode.dsym.$${BUNDLEIDENTIFIER}</string>
- <key>CFBundlePackageType</key>
- <string>dSYM</string>
- <key>CFBundleSignature</key>
- <string>????</string>
-!!IF !isEmpty(VERSION)
- <key>CFBundleShortVersionString</key>
- <string>$${VER_MAJ}.$${VER_MIN}</string>
- <key>CFBundleVersion</key>
- <string>$${VER_MAJ}.$${VER_MIN}.$${VER_PAT}</string>
-!!ENDIF
- </dict>
-</plist>
diff --git a/mkspecs/macx-g++40/Info.plist.lib b/mkspecs/macx-g++40/Info.plist.lib
deleted file mode 100644
index 7cbdb9af12..0000000000
--- a/mkspecs/macx-g++40/Info.plist.lib
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundlePackageType</key>
- <string>FMWK</string>
- <key>CFBundleShortVersionString</key>
- <string>@SHORT_VERSION@</string>
- <key>CFBundleVersion</key>
- <string>@FULL_VERSION@</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@LIBRARY@</string>
- <key>CFBundleIdentifier</key>
- <string>@BUNDLEIDENTIFIER@</string>
- <key>NOTE</key>
- <string>Please, do NOT change this file -- It was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/macx-g++40/qmake.conf b/mkspecs/macx-g++40/qmake.conf
deleted file mode 100644
index 308cc2007c..0000000000
--- a/mkspecs/macx-g++40/qmake.conf
+++ /dev/null
@@ -1,27 +0,0 @@
-#macx-g++ (different from g++.conf)
-
-#
-# qmake configuration for macx-g++
-#
-# OS X + command-line compiler
-#
-
-MAKEFILE_GENERATOR = UNIX
-CONFIG += app_bundle incremental global_init_link_order lib_version_first
-QMAKE_INCREMENTAL_STYLE = sublib
-
-include(../common/macx.conf)
-include(../common/gcc-base-mac.conf)
-include(../common/g++-macx.conf)
-
-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
-
-QMAKE_CC = gcc-4.0
-QMAKE_CXX = g++-4.0
-
-QMAKE_LINK = $$QMAKE_CXX
-QMAKE_LINK_SHLIB = $$QMAKE_CXX
-QMAKE_LINK_C = $$QMAKE_CC
-QMAKE_LINK_C_SHLIB = $$QMAKE_CC
-
-load(qt_config)
diff --git a/mkspecs/macx-g++42/Info.plist.app b/mkspecs/macx-g++42/Info.plist.app
deleted file mode 100644
index 8e44bd7f60..0000000000
--- a/mkspecs/macx-g++42/Info.plist.app
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
- <key>CFBundleIconFile</key>
- <string>@ICON@</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@EXECUTABLE@</string>
- <key>CFBundleIdentifier</key>
- <string>@BUNDLEIDENTIFIER@</string>
- <key>NOTE</key>
- <string>This file was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/macx-g++42/Info.plist.dSYM.in b/mkspecs/macx-g++42/Info.plist.dSYM.in
deleted file mode 100644
index a8c8d0d4fb..0000000000
--- a/mkspecs/macx-g++42/Info.plist.dSYM.in
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
- <dict>
- <key>CFBundleIdentifier</key>
- <string>com.apple.xcode.dsym.$${BUNDLEIDENTIFIER}</string>
- <key>CFBundlePackageType</key>
- <string>dSYM</string>
- <key>CFBundleSignature</key>
- <string>????</string>
-!!IF !isEmpty(VERSION)
- <key>CFBundleShortVersionString</key>
- <string>$${VER_MAJ}.$${VER_MIN}</string>
- <key>CFBundleVersion</key>
- <string>$${VER_MAJ}.$${VER_MIN}.$${VER_PAT}</string>
-!!ENDIF
- </dict>
-</plist>
diff --git a/mkspecs/macx-g++42/Info.plist.lib b/mkspecs/macx-g++42/Info.plist.lib
deleted file mode 100644
index 7cbdb9af12..0000000000
--- a/mkspecs/macx-g++42/Info.plist.lib
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundlePackageType</key>
- <string>FMWK</string>
- <key>CFBundleShortVersionString</key>
- <string>@SHORT_VERSION@</string>
- <key>CFBundleVersion</key>
- <string>@FULL_VERSION@</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@LIBRARY@</string>
- <key>CFBundleIdentifier</key>
- <string>@BUNDLEIDENTIFIER@</string>
- <key>NOTE</key>
- <string>Please, do NOT change this file -- It was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/macx-g++42/qmake.conf b/mkspecs/macx-g++42/qmake.conf
deleted file mode 100644
index b24cb7f3f3..0000000000
--- a/mkspecs/macx-g++42/qmake.conf
+++ /dev/null
@@ -1,27 +0,0 @@
-#macx-g++ (different from g++.conf)
-
-#
-# qmake configuration for macx-g++
-#
-# OS X + command-line compiler
-#
-
-MAKEFILE_GENERATOR = UNIX
-CONFIG += app_bundle incremental global_init_link_order lib_version_first
-QMAKE_INCREMENTAL_STYLE = sublib
-
-include(../common/macx.conf)
-include(../common/gcc-base-mac.conf)
-include(../common/g++-macx.conf)
-
-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
-
-QMAKE_CC = gcc-4.2
-QMAKE_CXX = g++-4.2
-
-QMAKE_LINK = $$QMAKE_CXX
-QMAKE_LINK_SHLIB = $$QMAKE_CXX
-QMAKE_LINK_C = $$QMAKE_CC
-QMAKE_LINK_C_SHLIB = $$QMAKE_CC
-
-load(qt_config)
diff --git a/mkspecs/macx-icc/qmake.conf b/mkspecs/macx-icc/qmake.conf
index 35e55f799e..990f3b39ee 100644
--- a/mkspecs/macx-icc/qmake.conf
+++ b/mkspecs/macx-icc/qmake.conf
@@ -64,13 +64,14 @@ QMAKE_CXXFLAGS_DISABLE_LTCG = $$QMAKE_CFLAGS_DISABLE_LTCG
QMAKE_LINK = icpc
QMAKE_LINK_SHLIB = icpc
-QMAKE_LFLAGS = -headerpad_max_install_names
+QMAKE_LFLAGS =
QMAKE_LFLAGS_RELEASE =
QMAKE_LFLAGS_DEBUG =
QMAKE_LFLAGS_SHLIB = -single_module -dynamiclib
QMAKE_LFLAGS_INCREMENTAL = -undefined suppress -flat_namespace
QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB
QMAKE_LFLAGS_SONAME = -install_name$${LITERAL_WHITESPACE}
+QMAKE_LFLAGS_HEADERPAD = -headerpad_max_install_names
QMAKE_LFLAGS_THREAD =
QMAKE_LFLAGS_RPATH = -Wl,-rpath,
QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
diff --git a/mkspecs/macx-ios-clang/qmake.conf b/mkspecs/macx-ios-clang/qmake.conf
index e21445deb7..3f6d133a76 100644
--- a/mkspecs/macx-ios-clang/qmake.conf
+++ b/mkspecs/macx-ios-clang/qmake.conf
@@ -14,7 +14,7 @@ include(../common/ios.conf)
include(../common/gcc-base-mac.conf)
include(../common/clang.conf)
include(../common/clang-mac.conf)
-include(../common/ios/clang.conf)
-include(../common/ios/qmake.conf)
+include(../common/uikit/clang.conf)
+include(../common/uikit/qmake.conf)
load(qt_config)
diff --git a/mkspecs/macx-llvm/Info.plist.app b/mkspecs/macx-llvm/Info.plist.app
deleted file mode 100644
index 8e44bd7f60..0000000000
--- a/mkspecs/macx-llvm/Info.plist.app
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
- <key>CFBundleIconFile</key>
- <string>@ICON@</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@EXECUTABLE@</string>
- <key>CFBundleIdentifier</key>
- <string>@BUNDLEIDENTIFIER@</string>
- <key>NOTE</key>
- <string>This file was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/macx-llvm/Info.plist.dSYM.in b/mkspecs/macx-llvm/Info.plist.dSYM.in
deleted file mode 100644
index a8c8d0d4fb..0000000000
--- a/mkspecs/macx-llvm/Info.plist.dSYM.in
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
- <dict>
- <key>CFBundleIdentifier</key>
- <string>com.apple.xcode.dsym.$${BUNDLEIDENTIFIER}</string>
- <key>CFBundlePackageType</key>
- <string>dSYM</string>
- <key>CFBundleSignature</key>
- <string>????</string>
-!!IF !isEmpty(VERSION)
- <key>CFBundleShortVersionString</key>
- <string>$${VER_MAJ}.$${VER_MIN}</string>
- <key>CFBundleVersion</key>
- <string>$${VER_MAJ}.$${VER_MIN}.$${VER_PAT}</string>
-!!ENDIF
- </dict>
-</plist>
diff --git a/mkspecs/macx-llvm/Info.plist.lib b/mkspecs/macx-llvm/Info.plist.lib
deleted file mode 100644
index 7cbdb9af12..0000000000
--- a/mkspecs/macx-llvm/Info.plist.lib
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundlePackageType</key>
- <string>FMWK</string>
- <key>CFBundleShortVersionString</key>
- <string>@SHORT_VERSION@</string>
- <key>CFBundleVersion</key>
- <string>@FULL_VERSION@</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@LIBRARY@</string>
- <key>CFBundleIdentifier</key>
- <string>@BUNDLEIDENTIFIER@</string>
- <key>NOTE</key>
- <string>Please, do NOT change this file -- It was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/macx-llvm/qmake.conf b/mkspecs/macx-llvm/qmake.conf
deleted file mode 100644
index 0434d29b50..0000000000
--- a/mkspecs/macx-llvm/qmake.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-#macx-g++ (different from g++.conf)
-
-#
-# qmake configuration for macx-g++
-#
-# OS X + command-line compiler
-#
-
-MAKEFILE_GENERATOR = UNIX
-CONFIG += app_bundle incremental global_init_link_order lib_version_first
-QMAKE_INCREMENTAL_STYLE = sublib
-
-include(../common/macx.conf)
-include(../common/gcc-base-mac.conf)
-include(../common/llvm.conf)
-
-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
-
-QMAKE_XCODE_GCC_VERSION = com.apple.compilers.llvmgcc42
-
-QMAKE_OBJCFLAGS_PRECOMPILE = -x objective-c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
-QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
-QMAKE_OBJCXXFLAGS_PRECOMPILE = -x objective-c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
-QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
-
-load(qt_config)
diff --git a/mkspecs/macx-llvm/qplatformdefs.h b/mkspecs/macx-llvm/qplatformdefs.h
deleted file mode 100644
index 063491dd90..0000000000
--- a/mkspecs/macx-llvm/qplatformdefs.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake spec 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 "../common/mac/qplatformdefs.h"
-
diff --git a/mkspecs/macx-tvos-clang/qmake.conf b/mkspecs/macx-tvos-clang/qmake.conf
index e945cc9d28..d233f5b7b3 100644
--- a/mkspecs/macx-tvos-clang/qmake.conf
+++ b/mkspecs/macx-tvos-clang/qmake.conf
@@ -4,8 +4,6 @@
QMAKE_TVOS_DEPLOYMENT_TARGET = 9.1
-INCLUDEPATH += $$PWD/tvos
-
QMAKE_APPLE_TARGETED_DEVICE_FAMILY = 3
QMAKE_APPLE_DEVICE_ARCHS = arm64
@@ -15,7 +13,7 @@ include(../common/tvos.conf)
include(../common/gcc-base-mac.conf)
include(../common/clang.conf)
include(../common/clang-mac.conf)
-include(../common/ios/clang.conf)
-include(../common/ios/qmake.conf)
+include(../common/uikit/clang.conf)
+include(../common/uikit/qmake.conf)
load(qt_config)
diff --git a/mkspecs/macx-watchos-clang/qmake.conf b/mkspecs/macx-watchos-clang/qmake.conf
index 03c05ad717..f68848d1e7 100644
--- a/mkspecs/macx-watchos-clang/qmake.conf
+++ b/mkspecs/macx-watchos-clang/qmake.conf
@@ -4,8 +4,6 @@
QMAKE_WATCHOS_DEPLOYMENT_TARGET = 2.2
-INCLUDEPATH += $$PWD/watchos
-
QMAKE_APPLE_TARGETED_DEVICE_FAMILY = 4
QMAKE_APPLE_DEVICE_ARCHS = armv7k
@@ -15,7 +13,7 @@ include(../common/watchos.conf)
include(../common/gcc-base-mac.conf)
include(../common/clang.conf)
include(../common/clang-mac.conf)
-include(../common/ios/clang.conf)
-include(../common/ios/qmake.conf)
+include(../common/uikit/clang.conf)
+include(../common/uikit/qmake.conf)
load(qt_config)
diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf
index 6ed39745ae..bb172f46a6 100644
--- a/mkspecs/win32-g++/qmake.conf
+++ b/mkspecs/win32-g++/qmake.conf
@@ -8,7 +8,6 @@
#
load(device_config)
-include(../common/angle.conf)
MAKEFILE_GENERATOR = MINGW
QMAKE_PLATFORM = win32 mingw
@@ -100,8 +99,8 @@ QMAKE_LIBS_CORE = -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32
QMAKE_LIBS_GUI = -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lws2_32 -lole32 -luuid -luser32 -ladvapi32
QMAKE_LIBS_NETWORK = -lws2_32
QMAKE_LIBS_OPENGL = -lglu32 -lopengl32 -lgdi32 -luser32
-QMAKE_LIBS_OPENGL_ES2 = -l$${LIBEGL_NAME} -l$${LIBGLESV2_NAME} -lgdi32 -luser32
-QMAKE_LIBS_OPENGL_ES2_DEBUG = -l$${LIBEGL_NAME}d -l$${LIBGLESV2_NAME}d -lgdi32 -luser32
+QMAKE_LIBS_OPENGL_ES2 = -lgdi32 -luser32
+QMAKE_LIBS_OPENGL_ES2_DEBUG = -lgdi32 -luser32
QMAKE_LIBS_COMPAT = -ladvapi32 -lshell32 -lcomdlg32 -luser32 -lgdi32 -lws2_32
QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain
@@ -113,4 +112,7 @@ QMAKE_STRIP = $${CROSS_COMPILE}strip
QMAKE_STRIPFLAGS_LIB += --strip-unneeded
QMAKE_OBJCOPY = $${CROSS_COMPILE}objcopy
QMAKE_NM = $${CROSS_COMPILE}nm -P
+
+include(../common/windows-gles.conf)
+
load(qt_config)
diff --git a/mkspecs/win32-icc/qmake.conf b/mkspecs/win32-icc/qmake.conf
index dd54131526..e19570bf16 100644
--- a/mkspecs/win32-icc/qmake.conf
+++ b/mkspecs/win32-icc/qmake.conf
@@ -4,8 +4,6 @@
# Written for Intel C++
#
-include(../common/angle.conf)
-
MAKEFILE_GENERATOR = MSVC.NET
QMAKE_PLATFORM = win32
CONFIG += incremental flat debug_and_release debug_and_release_target
@@ -89,8 +87,8 @@ QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib
QMAKE_LIBS_GUI = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib ws2_32.lib ole32.lib user32.lib advapi32.lib
QMAKE_LIBS_NETWORK = ws2_32.lib
QMAKE_LIBS_OPENGL = glu32.lib opengl32.lib gdi32.lib user32.lib delayimp.lib
-QMAKE_LIBS_OPENGL_ES2 = $${LIBEGL_NAME}.lib $${LIBGLESV2_NAME}.lib gdi32.lib user32.lib
-QMAKE_LIBS_OPENGL_ES2_DEBUG = $${LIBEGL_NAME}d.lib $${LIBGLESV2_NAME}d.lib gdi32.lib user32.lib
+QMAKE_LIBS_OPENGL_ES2 = gdi32.lib user32.lib
+QMAKE_LIBS_OPENGL_ES2_DEBUG = gdi32.lib user32.lib
QMAKE_LIBS_COMPAT = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib
QMAKE_LIBS_QT_ENTRY = -lqtmain
@@ -99,4 +97,7 @@ QMAKE_LIB = xilib /NOLOGO
QMAKE_RC = rc
DSP_EXTENSION = .dsp
+
+include(../common/windows-gles.conf)
+
load(qt_config)
diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix
index 320979150f..425fe62ef6 100644
--- a/qmake/Makefile.unix
+++ b/qmake/Makefile.unix
@@ -18,7 +18,7 @@ QOBJS=qtextcodec.o qutfcodec.o qstring.o qstring_compat.o qstringbuilder.o qtext
qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o qfileinfo.o qdatetime.o qstringlist.o \
qabstractfileengine.o qtemporaryfile.o qmap.o qmetatype.o qsettings.o qsystemerror.o qlibraryinfo.o \
qvariant.o qvsnprintf.o qlocale.o qlocale_tools.o qlinkedlist.o qnumeric.o \
- qcryptographichash.o qxmlstream.o qxmlutils.o qlogging.o \
+ qcryptographichash.o qxmlstream.o qxmlutils.o qlogging.o qoperatingsystemversion.o \
qjson.o qjsondocument.o qjsonparser.o qjsonarray.o qjsonobject.o qjsonvalue.o \
$(QTOBJS)
@@ -269,6 +269,15 @@ qmetatype.o: $(SOURCE_PATH)/src/corelib/kernel/qmetatype.cpp
qcore_mac.o: $(SOURCE_PATH)/src/corelib/kernel/qcore_mac.cpp
$(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/kernel/qcore_mac.cpp
+qoperatingsystemversion.o: $(SOURCE_PATH)/src/corelib/global/qoperatingsystemversion.cpp
+ $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/global/qoperatingsystemversion.cpp
+
+qoperatingsystemversion_win.o: $(SOURCE_PATH)/src/corelib/global/qoperatingsystemversion_win.cpp
+ $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/global/qoperatingsystemversion_win.cpp
+
+qoperatingsystemversion_darwin.o: $(SOURCE_PATH)/src/corelib/global/qoperatingsystemversion_darwin.mm
+ $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/global/qoperatingsystemversion_darwin.mm
+
qcore_mac_objc.o: $(SOURCE_PATH)/src/corelib/kernel/qcore_mac_objc.mm
$(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/kernel/qcore_mac_objc.mm
diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32
index 3e67632939..f023dc9e3f 100644
--- a/qmake/Makefile.win32
+++ b/qmake/Makefile.win32
@@ -101,6 +101,8 @@ QTOBJS= \
qlocale_win.obj \
qmalloc.obj \
qmap.obj \
+ qoperatingsystemversion.obj \
+ qoperatingsystemversion_win.obj \
qregexp.obj \
qtextcodec.obj \
qutfcodec.obj \
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp
index dce22ed712..feedec298a 100644
--- a/qmake/generators/mac/pbuilder_pbx.cpp
+++ b/qmake/generators/mac/pbuilder_pbx.cpp
@@ -1113,6 +1113,8 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
}
bool copyBundleResources = project->isActiveConfig("app_bundle") && project->first("TEMPLATE") == "app";
ProStringList bundle_resources_files;
+ ProStringList embedded_frameworks;
+ QMap<ProString, ProStringList> embedded_plugins;
// Copy Bundle Data
if (!project->isEmpty("QMAKE_BUNDLE_DATA")) {
ProStringList bundle_file_refs;
@@ -1123,6 +1125,11 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
for(int i = 0; i < bundle_data.count(); i++) {
ProStringList bundle_files;
ProString path = project->first(ProKey(bundle_data[i] + ".path"));
+ const bool isEmbeddedFramework = ((!osx && path == QLatin1String("Frameworks"))
+ || (osx && path == QLatin1String("Contents/Frameworks")));
+ const ProString pluginsPrefix = ProString(osx ? QLatin1String("Contents/PlugIns") : QLatin1String("PlugIns"));
+ const bool isEmbeddedPlugin = (path == pluginsPrefix) || path.startsWith(pluginsPrefix + "/");
+
//all files
const ProStringList &files = project->values(ProKey(bundle_data[i] + ".files"));
for(int file = 0; file < files.count(); file++) {
@@ -1140,19 +1147,29 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
bundle_files += file_key;
t << "\t\t" << file_key << " = {\n"
<< "\t\t\t" << writeSettings("fileRef", file_ref_key) << ";\n"
- << "\t\t\t" << writeSettings("isa", "PBXBuildFile", SettingsNoQuote) << ";\n"
- << "\t\t};\n";
+ << "\t\t\t" << writeSettings("isa", "PBXBuildFile", SettingsNoQuote) << ";\n";
+ if (isEmbeddedFramework || isEmbeddedPlugin || name.endsWith(".dylib") || name.endsWith(".framework"))
+ t << "\t\t\t" << writeSettings("settings", "{ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }", SettingsNoQuote) << ";\n";
+ t << "\t\t};\n";
}
if (copyBundleResources && ((!osx && path.isEmpty())
|| (osx && path == QLatin1String("Contents/Resources")))) {
for (const ProString &s : qAsConst(bundle_files))
bundle_resources_files << s;
+ } else if (copyBundleResources && isEmbeddedFramework) {
+ for (const ProString &s : qAsConst(bundle_files))
+ embedded_frameworks << s;
+ } else if (copyBundleResources && isEmbeddedPlugin) {
+ for (const ProString &s : qAsConst(bundle_files)) {
+ ProString subpath = (path == pluginsPrefix) ? ProString() : path.mid(pluginsPrefix.size() + 1);
+ embedded_plugins[subpath] << s;
+ }
} else {
QString phase_key = keyFor("QMAKE_PBX_BUNDLE_COPY." + bundle_data[i]);
- if (!project->isEmpty(ProKey(bundle_data[i] + ".version"))) {
- //###
- }
+ //if (!project->isActiveConfig("shallow_bundle")
+ // && !project->isEmpty(ProKey(bundle_data[i] + ".version"))) {
+ //}
project->values("QMAKE_PBX_BUILDPHASES").append(phase_key);
t << "\t\t" << phase_key << " = {\n"
@@ -1196,6 +1213,35 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
<< "\t\t\t" << writeSettings("runOnlyForDeploymentPostprocessing", "0", SettingsNoQuote) << ";\n"
<< "\t\t\t" << writeSettings("name", grp) << ";\n"
<< "\t\t};\n";
+
+ QString grp2("Embed Frameworks"), key2 = keyFor(grp2);
+ project->values("QMAKE_PBX_BUILDPHASES").append(key2);
+ t << "\t\t" << key2 << " = {\n"
+ << "\t\t\t" << writeSettings("isa", "PBXCopyFilesBuildPhase", SettingsNoQuote) << ";\n"
+ << "\t\t\t" << writeSettings("buildActionMask", "2147483647", SettingsNoQuote) << ";\n"
+ << "\t\t\t" << writeSettings("dstPath", "") << ";\n"
+ << "\t\t\t" << writeSettings("dstSubfolderSpec", "10", SettingsNoQuote) << ";\n"
+ << "\t\t\t" << writeSettings("files", embedded_frameworks, SettingsAsList, 4) << ";\n"
+ << "\t\t\t" << writeSettings("name", grp2) << ";\n"
+ << "\t\t\t" << writeSettings("runOnlyForDeploymentPostprocessing", "0", SettingsNoQuote) << ";\n"
+ << "\t\t};\n";
+
+ QMapIterator<ProString, ProStringList> it(embedded_plugins);
+ while (it.hasNext()) {
+ it.next();
+ QString suffix = !it.key().isEmpty() ? (" (" + it.key() + ")") : QString();
+ QString grp3("Embed PlugIns" + suffix), key3 = keyFor(grp3);
+ project->values("QMAKE_PBX_BUILDPHASES").append(key3);
+ t << "\t\t" << key3 << " = {\n"
+ << "\t\t\t" << writeSettings("isa", "PBXCopyFilesBuildPhase", SettingsNoQuote) << ";\n"
+ << "\t\t\t" << writeSettings("buildActionMask", "2147483647", SettingsNoQuote) << ";\n"
+ << "\t\t\t" << writeSettings("dstPath", it.key()) << ";\n"
+ << "\t\t\t" << writeSettings("dstSubfolderSpec", "13", SettingsNoQuote) << ";\n"
+ << "\t\t\t" << writeSettings("files", it.value(), SettingsAsList, 4) << ";\n"
+ << "\t\t\t" << writeSettings("name", grp3) << ";\n"
+ << "\t\t\t" << writeSettings("runOnlyForDeploymentPostprocessing", "0", SettingsNoQuote) << ";\n"
+ << "\t\t};\n";
+ }
}
//REFERENCE
@@ -1515,9 +1561,15 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
plist_in_text.replace(QLatin1String("@ICON@"),
(project->isEmpty("ICON") ? QString("") : project->first("ICON").toQString().section(Option::dir_sep, -1)));
if (project->first("TEMPLATE") == "app") {
- plist_in_text.replace(QLatin1String("@EXECUTABLE@"), project->first("QMAKE_ORIG_TARGET").toQString());
+ ProString app_bundle_name = project->first("QMAKE_APPLICATION_BUNDLE_NAME");
+ if (app_bundle_name.isEmpty())
+ app_bundle_name = project->first("QMAKE_ORIG_TARGET");
+ plist_in_text.replace(QLatin1String("@EXECUTABLE@"), app_bundle_name.toQString());
} else {
- plist_in_text.replace(QLatin1String("@LIBRARY@"), project->first("QMAKE_ORIG_TARGET").toQString());
+ ProString lib_bundle_name = project->first("QMAKE_FRAMEWORK_BUNDLE_NAME");
+ if (lib_bundle_name.isEmpty())
+ lib_bundle_name = project->first("QMAKE_ORIG_TARGET");
+ plist_in_text.replace(QLatin1String("@LIBRARY@"), lib_bundle_name.toQString());
}
QString bundlePrefix = project->first("QMAKE_TARGET_BUNDLE_PREFIX").toQString();
if (bundlePrefix.isEmpty())
diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp
index e45217cb45..790de30a0c 100644
--- a/qmake/generators/projectgenerator.cpp
+++ b/qmake/generators/projectgenerator.cpp
@@ -344,6 +344,17 @@ ProjectGenerator::writeMakefile(QTextStream &t)
<< getWritableVar("CONFIG_REMOVE", false)
<< getWritableVar("INCLUDEPATH") << endl;
+ t << "# The following define makes your compiler emit warnings if you use\n"
+ "# any feature of Qt which as been marked as deprecated (the exact warnings\n"
+ "# depend on your compiler). Please consult the documentation of the\n"
+ "# deprecated API in order to know how to port your code away from it.\n"
+ "DEFINES += QT_DEPRECATED_WARNINGS\n"
+ "\n"
+ "# You can also make your code fail to compile if you use deprecated APIs.\n"
+ "# In order to do so, uncomment the following line.\n"
+ "# You can also select to disable deprecated APIs only up to a certain version of Qt.\n"
+ "#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0\n\n";
+
t << "# Input" << "\n";
t << getWritableVar("HEADERS")
<< getWritableVar("FORMS")
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
index 349dcd2f40..794d04a6e9 100644
--- a/qmake/generators/unix/unixmake.cpp
+++ b/qmake/generators/unix/unixmake.cpp
@@ -599,10 +599,13 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
plain_targ = escapeFilePath(plain_targ);
if (bundle != NoBundle) {
QString suffix;
- if (project->first("TEMPLATE") == "lib")
- suffix = "/Versions/" + project->first("QMAKE_FRAMEWORK_VERSION") + "/$(TARGET)";
- else
+ if (project->first("TEMPLATE") == "lib") {
+ if (!project->isActiveConfig("shallow_bundle"))
+ suffix += "/Versions/" + project->first("QMAKE_FRAMEWORK_VERSION");
+ suffix += "/$(TARGET)";
+ } else {
suffix = "/" + project->first("QMAKE_BUNDLE_LOCATION") + "/$(QMAKE_TARGET)";
+ }
dst_targ += suffix;
if (bundle == SolidBundle) {
if (!ret.isEmpty())
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
index 6fa355390f..3d12ffd65c 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -596,9 +596,10 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
<< var("QMAKE_LINK_SHLIB_CMD") << "\n\t"
<< mkdir_p_asstring("\"`dirname $(DESTDIR)$(TARGETD)`\"", false) << "\n\t"
<< "-$(MOVE) $(TARGET) $(DESTDIR)$(TARGETD)\n\t"
- << mkdir_p_asstring("\"`dirname $(DESTDIR)$(TARGET0)`\"", false) << "\n\t"
- << varGlue("QMAKE_LN_SHLIB", "-", " ",
- " Versions/Current/$(TARGET) $(DESTDIR)$(TARGET0)") << "\n\t";
+ << mkdir_p_asstring("\"`dirname $(DESTDIR)$(TARGET0)`\"", false) << "\n\t";
+ if (!project->isActiveConfig("shallow_bundle"))
+ t << varGlue("QMAKE_LN_SHLIB", "-", " ",
+ " Versions/Current/$(TARGET) $(DESTDIR)$(TARGET0)") << "\n\t";
if(!project->isEmpty("QMAKE_POST_LINK"))
t << "\n\t" << var("QMAKE_POST_LINK");
t << endl << endl;
@@ -777,10 +778,17 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
} else {
info_plist = escapeFilePath(fileFixify(info_plist));
}
- bool isFramework = project->first("TEMPLATE") == "lib" && project->isActiveConfig("lib_bundle");
+ bool isFramework = project->first("TEMPLATE") == "lib"
+ && !project->isActiveConfig("plugin")
+ && project->isActiveConfig("lib_bundle");
+ bool isShallowBundle = project->isActiveConfig("shallow_bundle");
QString info_plist_out = bundle_dir +
- (isFramework ? ("Versions/" + project->first("QMAKE_FRAMEWORK_VERSION") + "/Resources/Info.plist")
- : "Contents/Info.plist");
+ (!isShallowBundle
+ ? (isFramework
+ ? ("Versions/" + project->first("QMAKE_FRAMEWORK_VERSION") + "/Resources/")
+ : "Contents/")
+ : QString())
+ + "Info.plist";
bundledFiles << info_plist_out;
alldeps << info_plist_out;
QString destdir = info_plist_out.section(Option::dir_sep, 0, -2);
@@ -814,14 +822,22 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
commonSedArgs << "-e \"s,@BUNDLEIDENTIFIER@," << bundleIdentifier << ",g\" ";
if (!isFramework) {
+ ProString app_bundle_name = var("QMAKE_APPLICATION_BUNDLE_NAME");
+ if (app_bundle_name.isEmpty())
+ app_bundle_name = var("QMAKE_ORIG_TARGET");
+
+ ProString plugin_bundle_name = var("QMAKE_PLUGIN_BUNDLE_NAME");
+ if (plugin_bundle_name.isEmpty())
+ plugin_bundle_name = var("QMAKE_ORIG_TARGET");
+
QString icon = fileFixify(var("ICON"));
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
<< "@sed ";
for (const ProString &arg : qAsConst(commonSedArgs))
t << arg;
t << "-e \"s,@ICON@," << icon.section(Option::dir_sep, -1) << ",g\" "
- << "-e \"s,@EXECUTABLE@," << var("QMAKE_ORIG_TARGET") << ",g\" "
- << "-e \"s,@LIBRARY@," << var("QMAKE_ORIG_TARGET") << ",g\" "
+ << "-e \"s,@EXECUTABLE@," << app_bundle_name << ",g\" "
+ << "-e \"s,@LIBRARY@," << plugin_bundle_name << ",g\" "
<< "-e \"s,@TYPEINFO@,"<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" "
<< "" << info_plist << " >" << info_plist_out << endl;
@@ -838,12 +854,17 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
<< "@$(COPY_FILE) " << escapeFilePath(icon) << ' ' << icon_path_f << endl;
}
} else {
- symlinks[bundle_dir + "Resources"] = "Versions/Current/Resources";
+ ProString lib_bundle_name = var("QMAKE_FRAMEWORK_BUNDLE_NAME");
+ if (lib_bundle_name.isEmpty())
+ lib_bundle_name = var("QMAKE_ORIG_TARGET");
+
+ if (!isShallowBundle)
+ symlinks[bundle_dir + "Resources"] = "Versions/Current/Resources";
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
<< "@sed ";
for (const ProString &arg : qAsConst(commonSedArgs))
t << arg;
- t << "-e \"s,@LIBRARY@," << var("QMAKE_ORIG_TARGET") << ",g\" "
+ t << "-e \"s,@LIBRARY@," << lib_bundle_name << ",g\" "
<< "-e \"s,@TYPEINFO@,"
<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" "
@@ -857,18 +878,20 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
for(int i = 0; i < bundle_data.count(); i++) {
const ProStringList &files = project->values(ProKey(bundle_data[i] + ".files"));
QString path = bundle_dir;
- const ProKey vkey(bundle_data[i] + ".version");
const ProKey pkey(bundle_data[i] + ".path");
- if (!project->isEmpty(vkey)) {
- QString version = project->first(vkey) + "/" +
- project->first("QMAKE_FRAMEWORK_VERSION") + "/";
- ProString name = project->first(pkey);
- int pos = name.indexOf('/');
- if (pos > 0)
- name = name.mid(0, pos);
- symlinks[Option::fixPathToTargetOS(path + name)] =
- project->first(vkey) + "/Current/" + name;
- path += version;
+ if (!project->isActiveConfig("shallow_bundle")) {
+ const ProKey vkey(bundle_data[i] + ".version");
+ if (!project->isEmpty(vkey)) {
+ QString version = project->first(vkey) + "/" +
+ project->first("QMAKE_FRAMEWORK_VERSION") + "/";
+ ProString name = project->first(pkey);
+ int pos = name.indexOf('/');
+ if (pos > 0)
+ name = name.mid(0, pos);
+ symlinks[Option::fixPathToTargetOS(path + name)] =
+ project->first(vkey) + "/Current/" + name;
+ path += version;
+ }
}
path += project->first(pkey).toQString();
path = Option::fixPathToTargetOS(path);
@@ -906,15 +929,17 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
<< "@$(SYMLINK) " << escapeFilePath(symIt.value()) << ' ' << bundle_dir_f << endl;
}
- QString currentLink = bundle_dir + "Versions/Current";
- QString currentLink_f = escapeDependencyPath(currentLink);
- bundledFiles << currentLink;
- alldeps << currentLink;
- t << currentLink_f << ": $(MAKEFILE)\n\t"
- << mkdir_p_asstring(bundle_dir + "Versions") << "\n\t"
- << "@-$(DEL_FILE) " << currentLink_f << "\n\t"
- << "@$(SYMLINK) " << project->first("QMAKE_FRAMEWORK_VERSION")
- << ' ' << currentLink_f << endl;
+ if (!project->isActiveConfig("shallow_bundle")) {
+ QString currentLink = bundle_dir + "Versions/Current";
+ QString currentLink_f = escapeDependencyPath(currentLink);
+ bundledFiles << currentLink;
+ alldeps << currentLink;
+ t << currentLink_f << ": $(MAKEFILE)\n\t"
+ << mkdir_p_asstring(bundle_dir + "Versions") << "\n\t"
+ << "@-$(DEL_FILE) " << currentLink_f << "\n\t"
+ << "@$(SYMLINK) " << project->first("QMAKE_FRAMEWORK_VERSION")
+ << ' ' << currentLink_f << endl;
+ }
}
}
@@ -1186,12 +1211,17 @@ void UnixMakefileGenerator::init2()
bundle_loc.prepend("/");
if(!bundle_loc.endsWith("/"))
bundle_loc += "/";
- project->values("TARGET_").append(project->first("QMAKE_BUNDLE") +
- bundle_loc + project->first("TARGET"));
- project->values("TARGET_x.y").append(project->first("QMAKE_BUNDLE") +
- "/Versions/" +
- project->first("QMAKE_FRAMEWORK_VERSION") +
- bundle_loc + project->first("TARGET"));
+ const QString target = project->first("QMAKE_BUNDLE") +
+ bundle_loc + project->first("TARGET");
+ project->values("TARGET_").append(target);
+ if (!project->isActiveConfig("shallow_bundle")) {
+ project->values("TARGET_x.y").append(project->first("QMAKE_BUNDLE") +
+ "/Versions/" +
+ project->first("QMAKE_FRAMEWORK_VERSION") +
+ bundle_loc + project->first("TARGET"));
+ } else {
+ project->values("TARGET_x.y").append(target);
+ }
} else if(project->isActiveConfig("plugin")) {
QString prefix;
if(!project->isActiveConfig("no_plugin_name_prefix"))
diff --git a/qmake/generators/win32/msbuild_objectmodel.h b/qmake/generators/win32/msbuild_objectmodel.h
index d594fbaca8..fe46430e60 100644
--- a/qmake/generators/win32/msbuild_objectmodel.h
+++ b/qmake/generators/win32/msbuild_objectmodel.h
@@ -32,12 +32,9 @@
#include "project.h"
#include "xmloutput.h"
#include "msvc_objectmodel.h"
-#include <qatomic.h>
#include <qlist.h>
#include <qstring.h>
-#include <qstringlist.h>
#include <qmap.h>
-#include <qdebug.h>
QT_BEGIN_NAMESPACE
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp
index fb9c4f354d..f219130e18 100644
--- a/qmake/generators/win32/msvc_objectmodel.cpp
+++ b/qmake/generators/win32/msvc_objectmodel.cpp
@@ -30,11 +30,40 @@
#include "msvc_vcproj.h"
#include "msvc_vcxproj.h"
#include <qscopedpointer.h>
-#include <qstringlist.h>
#include <qfileinfo.h>
QT_BEGIN_NAMESPACE
+static DotNET vsVersionFromString(const char *versionString)
+{
+ struct VSVersionMapping
+ {
+ const char *str;
+ DotNET version;
+ };
+ static VSVersionMapping mapping[] = {
+ "7.0", NET2002,
+ "7.1", NET2003,
+ "8.0", NET2005,
+ "9.0", NET2008,
+ "10.0", NET2010,
+ "11.0", NET2012,
+ "12.0", NET2013,
+ "14.0", NET2015
+ };
+ DotNET result = NETUnknown;
+ for (const auto entry : mapping) {
+ if (strcmp(entry.str, versionString) == 0)
+ return entry.version;
+ }
+ return result;
+}
+
+DotNET vsVersionFromString(const ProString &versionString)
+{
+ return vsVersionFromString(versionString.toLatin1().constData());
+}
+
// XML Tags ---------------------------------------------------------
const char _Configuration[] = "Configuration";
const char _Configurations[] = "Configurations";
diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h
index a744804760..35bc3913a8 100644
--- a/qmake/generators/win32/msvc_objectmodel.h
+++ b/qmake/generators/win32/msvc_objectmodel.h
@@ -34,7 +34,6 @@
#include <proitems.h>
-#include <qatomic.h>
#include <qlist.h>
#include <qstring.h>
#include <qstringlist.h>
@@ -55,6 +54,8 @@ enum DotNET {
NET2015 = 0xd0
};
+DotNET vsVersionFromString(const ProString &versionString);
+
/*
This Object model is of course VERY simplyfied,
and does not actually follow the original MSVC
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index cb44937bea..77cb554ec6 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -32,7 +32,6 @@
#include <qdir.h>
#include <qdiriterator.h>
#include <qcryptographichash.h>
-#include <qregexp.h>
#include <qhash.h>
#include <quuid.h>
#include <stdlib.h>
@@ -51,97 +50,6 @@ const char _GUIDFormFiles[] = "{99349809-55BA-4b9d-BF79-8FDBB0286EB3}
const char _GUIDExtraCompilerFiles[] = "{E0D8C965-CC5F-43d7-AD63-FAEF0BBC0F85}";
const char _GUIDDeploymentFiles[] = "{D9D6E243-F8AF-46E4-B9FD-80ECBC20BA3E}";
const char _GUIDDistributionFiles[] = "{B83CAF91-C7BF-462F-B76C-EA11631F866C}";
-QT_END_NAMESPACE
-
-#ifdef Q_OS_WIN32
-#include <qt_windows.h>
-#include <windows/registry_p.h>
-
-QT_BEGIN_NAMESPACE
-
-struct DotNetCombo {
- DotNET version;
- const char *versionStr;
- const char *regKey;
-} dotNetCombo[] = {
- {NET2015, "MSVC.NET 2015 (14.0)", "Software\\Microsoft\\VisualStudio\\14.0\\Setup\\VC\\ProductDir"},
- {NET2013, "MSVC.NET 2013 (12.0)", "Software\\Microsoft\\VisualStudio\\12.0\\Setup\\VC\\ProductDir"},
- {NET2013, "MSVC.NET 2013 Express Edition (12.0)", "Software\\Microsoft\\VCExpress\\12.0\\Setup\\VC\\ProductDir"},
- {NET2012, "MSVC.NET 2012 (11.0)", "Software\\Microsoft\\VisualStudio\\11.0\\Setup\\VC\\ProductDir"},
- {NET2012, "MSVC.NET 2012 Express Edition (11.0)", "Software\\Microsoft\\VCExpress\\11.0\\Setup\\VC\\ProductDir"},
- {NET2010, "MSVC.NET 2010 (10.0)", "Software\\Microsoft\\VisualStudio\\10.0\\Setup\\VC\\ProductDir"},
- {NET2010, "MSVC.NET 2010 Express Edition (10.0)", "Software\\Microsoft\\VCExpress\\10.0\\Setup\\VC\\ProductDir"},
- {NET2008, "MSVC.NET 2008 (9.0)", "Software\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir"},
- {NET2008, "MSVC.NET 2008 Express Edition (9.0)", "Software\\Microsoft\\VCExpress\\9.0\\Setup\\VC\\ProductDir"},
- {NET2005, "MSVC.NET 2005 (8.0)", "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"},
- {NET2005, "MSVC.NET 2005 Express Edition (8.0)", "Software\\Microsoft\\VCExpress\\8.0\\Setup\\VC\\ProductDir"},
- {NET2003, "MSVC.NET 2003 (7.1)", "Software\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir"},
- {NET2002, "MSVC.NET 2002 (7.0)", "Software\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir"},
- {NETUnknown, "", ""},
-};
-
-QT_END_NAMESPACE
-#endif
-
-QT_BEGIN_NAMESPACE
-DotNET which_dotnet_version(const QByteArray &preferredVersion = QByteArray())
-{
-#ifndef Q_OS_WIN32
- Q_UNUSED(preferredVersion);
- return NET2002; // Always generate 7.0 versions on other platforms
-#else
- // Only search for the version once
- static DotNET current_version = NETUnknown;
- if(current_version != NETUnknown)
- return current_version;
-
- // Fallback to .NET 2002
- current_version = NET2002;
-
- const DotNetCombo *lowestInstalledVersion = 0;
- QHash<DotNET, QString> installPaths;
- int installed = 0;
- int i = 0;
- for(; dotNetCombo[i].version; ++i) {
- QString path = qt_readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey,
- KEY_WOW64_32KEY);
- if (!path.isEmpty() && installPaths.value(dotNetCombo[i].version) != path) {
- lowestInstalledVersion = &dotNetCombo[i];
- installPaths.insert(lowestInstalledVersion->version, path);
- ++installed;
- current_version = lowestInstalledVersion->version;
- if (QByteArray(lowestInstalledVersion->versionStr).contains(preferredVersion)) {
- installed = 1;
- break;
- }
- }
- }
-
- if (installed < 2)
- return current_version;
-
- // More than one version installed, search directory path
- QString paths = qgetenv("PATH");
- const QStringList pathlist = paths.split(QLatin1Char(';'));
- for (const QString &path : pathlist) {
- for (i = 0; dotNetCombo[i].version; ++i) {
- const QString productPath = installPaths.value(dotNetCombo[i].version);
- if (productPath.isEmpty())
- continue;
- if (path.startsWith(productPath, Qt::CaseInsensitive)) {
- current_version = dotNetCombo[i].version;
- return current_version;
- }
- }
- }
-
- warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio, but"
- " none in your PATH. Falling back to lowest version (%s)",
- qPrintable(lowestInstalledVersion->versionStr));
-
- return current_version;
-#endif
-};
// Flatfile Tags ----------------------------------------------------
const char _slnHeader70[] = "Microsoft Visual Studio Solution File, Format Version 7.00";
@@ -612,7 +520,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
return;
}
- switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) {
+ switch (vcProject.Configuration.CompilerVersion) {
case NET2015:
t << _slnHeader140;
break;
@@ -639,7 +547,8 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
break;
default:
t << _slnHeader70;
- warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .sln", which_dotnet_version());
+ warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .sln",
+ vcProject.Configuration.CompilerVersion);
break;
}
@@ -933,7 +842,7 @@ void VcprojGenerator::initProject()
// Own elements -----------------------------
vcProject.Name = project->first("QMAKE_ORIG_TARGET").toQString();
- switch (which_dotnet_version(project->first("MSVC_VER").toLatin1())) {
+ switch (vcProject.Configuration.CompilerVersion) {
case NET2015:
vcProject.Version = "14.00";
break;
@@ -962,7 +871,7 @@ void VcprojGenerator::initProject()
break;
default:
vcProject.Version = "7.00";
- warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .vcproj", which_dotnet_version());
+ warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .vcproj", vcProject.Configuration.CompilerVersion);
break;
}
@@ -986,7 +895,7 @@ void VcprojGenerator::initConfiguration()
// - to know of certain compiler/linker options
VCConfiguration &conf = vcProject.Configuration;
conf.suppressUnknownOptionWarnings = project->isActiveConfig("suppress_vcproj_warnings");
- conf.CompilerVersion = which_dotnet_version(project->first("MSVC_VER").toLatin1());
+ conf.CompilerVersion = vsVersionFromString(project->first("MSVC_VER"));
if (conf.CompilerVersion >= NET2012) {
conf.WinRT = project->isActiveConfig("winrt");
diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp
index 338131d06b..dd10afa023 100644
--- a/qmake/library/qmakeevaluator.cpp
+++ b/qmake/library/qmakeevaluator.cpp
@@ -1024,21 +1024,8 @@ void QMakeEvaluator::loadDefaults()
if (GetComputerName(name, &name_length))
vars[ProKey("QMAKE_HOST.name")] << ProString(QString::fromWCharArray(name));
- QSysInfo::WinVersion ver = QSysInfo::WindowsVersion;
- vars[ProKey("QMAKE_HOST.version")] << ProString(QString::number(ver));
- ProString verStr;
- switch (ver) {
- case QSysInfo::WV_Me: verStr = ProString("WinMe"); break;
- case QSysInfo::WV_95: verStr = ProString("Win95"); break;
- case QSysInfo::WV_98: verStr = ProString("Win98"); break;
- case QSysInfo::WV_NT: verStr = ProString("WinNT"); break;
- case QSysInfo::WV_2000: verStr = ProString("Win2000"); break;
- case QSysInfo::WV_2003: verStr = ProString("Win2003"); break;
- case QSysInfo::WV_XP: verStr = ProString("WinXP"); break;
- case QSysInfo::WV_VISTA: verStr = ProString("WinVista"); break;
- default: verStr = ProString("Unknown"); break;
- }
- vars[ProKey("QMAKE_HOST.version_string")] << verStr;
+ vars[ProKey("QMAKE_HOST.version")] << ProString(QSysInfo::kernelVersion());
+ vars[ProKey("QMAKE_HOST.version_string")] << ProString(QSysInfo::productVersion());
SYSTEM_INFO info;
GetSystemInfo(&info);
diff --git a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro
index 4ba2ee3ec4..0f7d7c2bda 100644
--- a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro
+++ b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro
@@ -13,7 +13,7 @@ load(qt_helper_lib)
SHAPERS += opentype # HB's main shaper; enabling it should be enough most of the time
# native shaper on Apple platforms; could be used alone to handle both OT and AAT fonts
-darwin:!if(watchos:CONFIG(simulator, simulator|device)): SHAPERS += coretext
+darwin: SHAPERS += coretext
DEFINES += HAVE_CONFIG_H
DEFINES += HB_NO_UNICODE_FUNCS HB_DISABLE_DEPRECATED
@@ -155,4 +155,20 @@ contains(SHAPERS, coretext) {
# On Mac OS they are part of the ApplicationServices umbrella framework,
# even in 10.8 where they were also made available stand-alone.
LIBS_PRIVATE += -framework ApplicationServices
+
+ # CoreText is documented to be available on watchOS, but the headers aren't present
+ # in the watchOS Simulator SDK like they are supposed to be. Work around the problem
+ # by adding the device SDK's headers to the search path as a fallback.
+ # rdar://25314492, rdar://27844864
+ watchos:simulator {
+ simulator_system_frameworks = $$xcodeSDKInfo(Path, $${simulator.sdk})/System/Library/Frameworks
+ device_system_frameworks = $$xcodeSDKInfo(Path, $${device.sdk})/System/Library/Frameworks
+ for (arch, QMAKE_APPLE_SIMULATOR_ARCHS) {
+ QMAKE_CXXFLAGS += \
+ -Xarch_$${arch} \
+ -F$$simulator_system_frameworks \
+ -Xarch_$${arch} \
+ -F$$device_system_frameworks
+ }
+ }
}
diff --git a/src/angle/src/libGLESv2/libGLESv2.pro b/src/angle/src/QtANGLE/QtANGLE.pro
index b699ae159a..ee3111b6ee 100644
--- a/src/angle/src/libGLESv2/libGLESv2.pro
+++ b/src/angle/src/QtANGLE/QtANGLE.pro
@@ -1,10 +1,59 @@
CONFIG += simd no_batch
include(../common/common.pri)
+TARGET=$$qtLibraryTarget($${LIBQTANGLE_NAME})
DEF_FILE_TARGET=$${TARGET}
-TARGET=$$qtLibraryTarget($${LIBGLESV2_NAME})
INCLUDEPATH += $$OUT_PWD/.. $$ANGLE_DIR/src/libANGLE
+!build_pass {
+ # Merge libGLESv2 and libEGL .def files located under $$ANGLE_DIR into QtANGLE$${SUFFIX}.def
+ DEF_FILES = \
+ libGLESv2/libGLESv2 \
+ libEGL/libEGL
+
+ SUFFIX =
+ for (DEBUG_RELEASE, $$list(0 1)) {
+ DEF_MERGED = \
+ "LIBRARY $${LIBQTANGLE_NAME}$$SUFFIX" \
+ EXPORTS
+ mingw: SUFFIX = $${SUFFIX}_mingw32
+ PASS = 0
+ MAX_ORDINAL = 0
+
+ for (DEF_FILE, DEF_FILES) {
+ DEF_FILE_PATH = $$ANGLE_DIR/src/$$DEF_FILE$${SUFFIX}.def
+ DEF_SRC = $$cat($$DEF_FILE_PATH, lines)
+ DEF_MERGED += \
+ ";" \
+ "; Generated from:" \
+ "; $$DEF_FILE_PATH"
+
+ for (line, DEF_SRC) {
+ !contains(line, "(LIBRARY.*|EXPORTS)") {
+ LINESPLIT = $$split(line, @)
+ !count(LINESPLIT, 1) {
+ equals(PASS, 1) {
+ # In the second .def file we must allocate new ordinals in order
+ # to not clash with the ordinals from the first file. We then start off
+ # from MAX_ORDINAL + 1 and increase sequentially
+ MAX_ORDINAL = $$num_add($$MAX_ORDINAL, 1)
+ line = $$section(line, @, 0, -2)@$$MAX_ORDINAL
+ } else {
+ ORDINAL = $$last(LINESPLIT)
+ greaterThan(ORDINAL, $$MAX_ORDINAL): \
+ MAX_ORDINAL = $$ORDINAL
+ }
+ }
+ DEF_MERGED += $$line
+ }
+ }
+ PASS = 1
+ }
+ write_file($${LIBQTANGLE_NAME}$${SUFFIX}.def, DEF_MERGED)|error()
+ SUFFIX = "d"
+ }
+}
+
# Remember to adapt tools/configure/configureapp.cpp if the Direct X version changes.
!winrt: \
LIBS_PRIVATE += -ld3d9
@@ -234,7 +283,8 @@ SOURCES += \
$$ANGLE_DIR/src/libGLESv2/entry_points_gles_3_0.cpp \
$$ANGLE_DIR/src/libGLESv2/entry_points_gles_3_0_ext.cpp \
$$ANGLE_DIR/src/libGLESv2/global_state.cpp \
- $$ANGLE_DIR/src/libGLESv2/libGLESv2.cpp
+ $$ANGLE_DIR/src/libGLESv2/libGLESv2.cpp \
+ $$ANGLE_DIR/src/libEGL/libEGL.cpp
SSE2_SOURCES += $$ANGLE_DIR/src/libANGLE/renderer/d3d/loadimageSSE2.cpp
@@ -361,8 +411,8 @@ angle_d3d11 {
}
!static {
- DEF_FILE = $$ANGLE_DIR/src/libGLESv2/$${DEF_FILE_TARGET}.def
- mingw:equals(QT_ARCH, i386): DEF_FILE = $$ANGLE_DIR/src/libGLESv2/$${DEF_FILE_TARGET}_mingw32.def
+ DEF_FILE = $$PWD/$${DEF_FILE_TARGET}.def
+ mingw: equals(QT_ARCH, i386): DEF_FILE = $$PWD/$${DEF_FILE_TARGET}_mingw32.def
} else {
DEFINES += DllMain=DllMain_ANGLE # prevent symbol from conflicting with the user's DllMain
}
@@ -610,5 +660,10 @@ gles3_headers.files = \
$$ANGLE_DIR/include/GLES3/gl3ext.h \
$$ANGLE_DIR/include/GLES3/gl3platform.h
gles3_headers.path = $$[QT_INSTALL_HEADERS]/QtANGLE/GLES3
-INSTALLS += khr_headers gles2_headers
+egl_headers.files = \
+ $$ANGLE_DIR/include/EGL/egl.h \
+ $$ANGLE_DIR/include/EGL/eglext.h \
+ $$ANGLE_DIR/include/EGL/eglplatform.h
+egl_headers.path = $$[QT_INSTALL_HEADERS]/QtANGLE/EGL
+INSTALLS += khr_headers gles2_headers egl_headers
angle_d3d11: INSTALLS += gles3_headers
diff --git a/src/angle/src/libEGL/libEGL.pro b/src/angle/src/libEGL/libEGL.pro
deleted file mode 100644
index 3b2d516ecb..0000000000
--- a/src/angle/src/libEGL/libEGL.pro
+++ /dev/null
@@ -1,27 +0,0 @@
-include(../common/common.pri)
-DEF_FILE_TARGET=$${TARGET}
-TARGET=$$qtLibraryTarget($${LIBEGL_NAME})
-winrt: LIBS_PRIVATE += -ld3d11
-
-LIBS_PRIVATE += -ldxguid
-QMAKE_USE_PRIVATE += $${LIBGLESV2_NAME}
-
-DEFINES += GL_APICALL= GL_GLEXT_PROTOTYPES= EGLAPI= LIBEGL_IMPLEMENTATION
-
-HEADERS += \
- $$ANGLE_DIR/src/libEGL/resource.h
-
-SOURCES += \
- $$ANGLE_DIR/src/libEGL/libEGL.cpp
-
-!static {
- DEF_FILE = $$ANGLE_DIR/src/libEGL/$${DEF_FILE_TARGET}.def
- mingw:equals(QT_ARCH, i386): DEF_FILE = $$ANGLE_DIR/src/libEGL/$${DEF_FILE_TARGET}_mingw32.def
-}
-
-egl_headers.files = \
- $$ANGLE_DIR/include/EGL/egl.h \
- $$ANGLE_DIR/include/EGL/eglext.h \
- $$ANGLE_DIR/include/EGL/eglplatform.h
-egl_headers.path = $$[QT_INSTALL_HEADERS]/QtANGLE/EGL
-INSTALLS += egl_headers
diff --git a/src/angle/src/src.pro b/src/angle/src/src.pro
index d1f5f57591..77c3ee7198 100644
--- a/src/angle/src/src.pro
+++ b/src/angle/src/src.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS += compiler libGLESv2 libEGL
+SUBDIRS += compiler QtANGLE
CONFIG += ordered
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
index 9fd52517c2..f852988e9a 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
@@ -48,14 +48,6 @@
**
****************************************************************************/
-//! [0]
-QLineEdit *lineEdit = static_cast<QLineEdit *>(
- qt_find_obj_child(myWidget, "QLineEdit", "my line edit"));
-if (lineEdit)
- lineEdit->setText("Default");
-//! [0]
-
-
//! [1]
QObject *obj = new QPushButton;
obj->metaObject()->className(); // returns "QPushButton"
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index f74662b464..bd2e125006 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -2,6 +2,8 @@
HEADERS += \
global/qglobal.h \
+ global/qoperatingsystemversion.h \
+ global/qoperatingsystemversion_p.h \
global/qsystemdetection.h \
global/qcompilerdetection.h \
global/qprocessordetection.h \
@@ -27,11 +29,15 @@ SOURCES += \
global/qlibraryinfo.cpp \
global/qmalloc.cpp \
global/qnumeric.cpp \
+ global/qoperatingsystemversion.cpp \
global/qlogging.cpp \
global/qhooks.cpp
VERSIONTAGGING_SOURCES = global/qversiontagging.cpp
+darwin: SOURCES += global/qoperatingsystemversion_darwin.mm
+win32: SOURCES += global/qoperatingsystemversion_win.cpp
+
# qlibraryinfo.cpp includes qconfig.cpp
INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index d06acb83b2..cbefe92eca 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -45,6 +45,8 @@
#include "qthreadstorage.h"
#include "qdir.h"
#include "qdatetime.h"
+#include "qoperatingsystemversion.h"
+#include "qoperatingsystemversion_p.h"
#include <private/qlocale_tools_p.h>
#include <qmutex.h>
@@ -1088,12 +1090,14 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
+ \deprecated
\variable QSysInfo::WindowsVersion
\brief the version of the Windows operating system on which the
application is run.
*/
/*!
+ \deprecated
\fn QSysInfo::WindowsVersion QSysInfo::windowsVersion()
\since 4.4
@@ -1103,12 +1107,14 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
+ \deprecated
\variable QSysInfo::MacintoshVersion
\brief the version of the Macintosh operating system on which
the application is run.
*/
/*!
+ \deprecated
\fn QSysInfo::MacVersion QSysInfo::macVersion()
Returns the version of Darwin (\macos or iOS) on which the
@@ -1126,6 +1132,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
+ \deprecated
\enum QSysInfo::WinVersion
This enum provides symbolic names for the various versions of the
@@ -1182,6 +1189,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
+ \deprecated
\enum QSysInfo::MacVersion
This enum provides symbolic names for the various versions of the
@@ -1943,28 +1951,31 @@ QT_BEGIN_INCLUDE_NAMESPACE
#include "qnamespace.h"
QT_END_INCLUDE_NAMESPACE
+#if QT_DEPRECATED_SINCE(5, 9)
QSysInfo::MacVersion QSysInfo::macVersion()
{
- const QAppleOperatingSystemVersion version = qt_apple_os_version(); // qtcore_mac_objc.mm
+ const auto version = QOperatingSystemVersion::current();
#if defined(Q_OS_OSX)
- return QSysInfo::MacVersion(Q_MV_OSX(version.major, version.minor));
+ return QSysInfo::MacVersion(Q_MV_OSX(version.majorVersion(), version.minorVersion()));
#elif defined(Q_OS_IOS)
- return QSysInfo::MacVersion(Q_MV_IOS(version.major, version.minor));
+ return QSysInfo::MacVersion(Q_MV_IOS(version.majorVersion(), version.minorVersion()));
#elif defined(Q_OS_TVOS)
- return QSysInfo::MacVersion(Q_MV_TVOS(version.major, version.minor));
+ return QSysInfo::MacVersion(Q_MV_TVOS(version.majorVersion(), version.minorVersion()));
#elif defined(Q_OS_WATCHOS)
- return QSysInfo::MacVersion(Q_MV_WATCHOS(version.major, version.minor));
+ return QSysInfo::MacVersion(Q_MV_WATCHOS(version.majorVersion(), version.minorVersion()));
#else
return QSysInfo::MV_Unknown;
#endif
}
const QSysInfo::MacVersion QSysInfo::MacintoshVersion = QSysInfo::macVersion();
+#endif
-#ifdef Q_OS_OSX
-static const char *osxVer_helper(QAppleOperatingSystemVersion version = qt_apple_os_version())
+#ifdef Q_OS_DARWIN
+static const char *osVer_helper(QOperatingSystemVersion version = QOperatingSystemVersion::current())
{
- if (version.major == 10) {
- switch (version.minor) {
+#ifdef Q_OS_MACOS
+ if (version.majorVersion() == 10) {
+ switch (version.minorVersion()) {
case 9:
return "Mavericks";
case 10:
@@ -1976,6 +1987,9 @@ static const char *osxVer_helper(QAppleOperatingSystemVersion version = qt_apple
}
}
// unknown, future version
+#else
+ Q_UNUSED(version);
+#endif
return 0;
}
#endif
@@ -2016,140 +2030,30 @@ QWindowsSockInit::~QWindowsSockInit()
Q_GLOBAL_STATIC(QWindowsSockInit, winsockInit)
# endif // QT_BOOTSTRAPPED
-#ifdef Q_OS_WINRT
-static inline HMODULE moduleHandleForFunction(LPCVOID address)
-{
- // This is a widely used, decades-old technique for retrieving the handle
- // of a module and is effectively equivalent to GetModuleHandleEx
- // (which is unavailable on WinRT)
- MEMORY_BASIC_INFORMATION mbi = { 0, 0, 0, 0, 0, 0, 0 };
- if (VirtualQuery(address, &mbi, sizeof(mbi)) == 0)
- return 0;
- return reinterpret_cast<HMODULE>(mbi.AllocationBase);
-}
-#endif
-
-static inline OSVERSIONINFOEX determineWinOsVersion()
-{
- OSVERSIONINFOEX result = { sizeof(OSVERSIONINFOEX), 0, 0, 0, 0, {'\0'}, 0, 0, 0, 0, 0};
-
-#define GetProcAddressA GetProcAddress
-
- // GetModuleHandle is not supported in WinRT and linking to it at load time
- // will not pass the Windows App Certification Kit... but it exists and is functional,
- // so use some unusual but widely used techniques to get a pointer to it
-#ifdef Q_OS_WINRT
- // 1. Get HMODULE of kernel32.dll, using the address of some function exported by that DLL
- HMODULE kernelModule = moduleHandleForFunction(reinterpret_cast<LPCVOID>(VirtualQuery));
- if (Q_UNLIKELY(!kernelModule))
- return result;
-
- // 2. Get pointer to GetModuleHandle so we can then load other arbitrary modules (DLLs)
- typedef HMODULE(WINAPI *GetModuleHandleFunction)(LPCWSTR);
- GetModuleHandleFunction pGetModuleHandle = reinterpret_cast<GetModuleHandleFunction>(
- GetProcAddressA(kernelModule, "GetModuleHandleW"));
- if (Q_UNLIKELY(!pGetModuleHandle))
- return result;
-#else
-#define pGetModuleHandle GetModuleHandleW
-#endif
-
-#ifndef Q_OS_WINCE
- HMODULE ntdll = pGetModuleHandle(L"ntdll.dll");
- if (Q_UNLIKELY(!ntdll))
- return result;
-
- // NTSTATUS is not defined on WinRT
- typedef LONG NTSTATUS;
- typedef NTSTATUS (NTAPI *RtlGetVersionFunction)(LPOSVERSIONINFO);
-
- // RtlGetVersion is documented public API but we must load it dynamically
- // because linking to it at load time will not pass the Windows App Certification Kit
- // https://msdn.microsoft.com/en-us/library/windows/hardware/ff561910.aspx
- RtlGetVersionFunction pRtlGetVersion = reinterpret_cast<RtlGetVersionFunction>(
- GetProcAddressA(ntdll, "RtlGetVersion"));
- if (Q_UNLIKELY(!pRtlGetVersion))
- return result;
-
- // GetVersionEx() has been deprecated in Windows 8.1 and will return
- // only Windows 8 from that version on, so use the kernel API function.
- pRtlGetVersion((LPOSVERSIONINFO) &result); // always returns STATUS_SUCCESS
-#else // !Q_OS_WINCE
- GetVersionEx(&result);
-#endif
- return result;
-}
-
-static OSVERSIONINFOEX winOsVersion()
-{
- OSVERSIONINFOEX realResult = determineWinOsVersion();
-#ifdef QT_DEBUG
- {
- if (Q_UNLIKELY(qEnvironmentVariableIsSet("QT_WINVER_OVERRIDE"))) {
- OSVERSIONINFOEX result = realResult;
- result.dwMajorVersion = 0;
- result.dwMinorVersion = 0;
-
- // Erase any build number and service pack information
- result.dwBuildNumber = 0;
- result.szCSDVersion[0] = L'\0';
- result.wServicePackMajor = 0;
- result.wServicePackMinor = 0;
-
- const QByteArray winVerOverride = qgetenv("QT_WINVER_OVERRIDE");
- if (winVerOverride == "WINDOWS7" || winVerOverride == "2008_R2") {
- result.dwMajorVersion = 6;
- result.dwMinorVersion = 1;
- } else if (winVerOverride == "WINDOWS8" || winVerOverride == "2012") {
- result.dwMajorVersion = 6;
- result.dwMinorVersion = 2;
- } else if (winVerOverride == "WINDOWS8_1" || winVerOverride == "2012_R2") {
- result.dwMajorVersion = 6;
- result.dwMinorVersion = 3;
- } else if (winVerOverride == "WINDOWS10" || winVerOverride == "2016") {
- result.dwMajorVersion = 10;
- } else {
- return realResult;
- }
-
- if (winVerOverride == "2008_R2"
- || winVerOverride == "2012"
- || winVerOverride == "2012_R2"
- || winVerOverride == "2016") {
- // If the current host OS is a domain controller and the override OS
- // is also a server type OS, preserve that information
- if (result.wProductType == VER_NT_WORKSTATION)
- result.wProductType = VER_NT_SERVER;
- } else {
- // Any other OS must be a workstation OS type
- result.wProductType = VER_NT_WORKSTATION;
- }
- }
- }
-#endif
- return realResult;
-}
-
+#if QT_DEPRECATED_SINCE(5, 9)
QSysInfo::WinVersion QSysInfo::windowsVersion()
{
- const OSVERSIONINFOEX osver = winOsVersion();
- if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1)
+ const auto version = QOperatingSystemVersion::current();
+ if (version.majorVersion() == 6 && version.minorVersion() == 1)
return QSysInfo::WV_WINDOWS7;
- if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2)
+ if (version.majorVersion() == 6 && version.minorVersion() == 2)
return QSysInfo::WV_WINDOWS8;
- if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3)
+ if (version.majorVersion() == 6 && version.minorVersion() == 3)
return QSysInfo::WV_WINDOWS8_1;
- if (osver.dwMajorVersion == 10 && osver.dwMinorVersion == 0)
+ if (version.majorVersion() == 10 && version.minorVersion() == 0)
return QSysInfo::WV_WINDOWS10;
return QSysInfo::WV_NT_based;
}
+const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion();
+#endif
static QString winSp_helper()
{
- const qint16 major = winOsVersion().wServicePackMajor;
+ const auto osv = qWindowsVersionInfo();
+ const qint16 major = osv.wServicePackMajor;
if (major) {
QString sp = QStringLiteral(" SP ") + QString::number(major);
- const qint16 minor = winOsVersion().wServicePackMinor;
+ const qint16 minor = osv.wServicePackMinor;
if (minor)
sp += QLatin1Char('.') + QString::number(minor);
@@ -2158,9 +2062,10 @@ static QString winSp_helper()
return QString();
}
-static const char *winVer_helper()
+static const char *osVer_helper(QOperatingSystemVersion version = QOperatingSystemVersion::current())
{
- const OSVERSIONINFOEX osver = winOsVersion();
+ Q_UNUSED(version);
+ const OSVERSIONINFOEX osver = qWindowsVersionInfo();
const bool workstation = osver.wProductType == VER_NT_WORKSTATION;
#define Q_WINVER(major, minor) (major << 8 | minor)
@@ -2179,8 +2084,6 @@ static const char *winVer_helper()
return 0;
}
-const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion();
-
#endif
#if defined(Q_OS_UNIX)
# if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || defined(Q_OS_FREEBSD)
@@ -2361,6 +2264,68 @@ static bool findUnixOsVersion(QUnixOSVersion &v)
# endif // USE_ETC_OS_RELEASE
#endif // Q_OS_UNIX
+#ifdef Q_OS_ANDROID
+static const char *osVer_helper(QOperatingSystemVersion)
+{
+/* Data:
+
+
+
+Cupcake
+Donut
+Eclair
+Eclair
+Eclair
+Froyo
+Gingerbread
+Gingerbread
+Honeycomb
+Honeycomb
+Honeycomb
+Ice Cream Sandwich
+Ice Cream Sandwich
+Jelly Bean
+Jelly Bean
+Jelly Bean
+KitKat
+KitKat
+Lollipop
+Lollipop
+Marshmallow
+Nougat
+Nougat
+ */
+ static const char versions_string[] =
+ "\0"
+ "Cupcake\0"
+ "Donut\0"
+ "Eclair\0"
+ "Froyo\0"
+ "Gingerbread\0"
+ "Honeycomb\0"
+ "Ice Cream Sandwich\0"
+ "Jelly Bean\0"
+ "KitKat\0"
+ "Lollipop\0"
+ "Marshmallow\0"
+ "Nougat\0"
+ "\0";
+
+ static const int versions_indices[] = {
+ 0, 0, 0, 1, 9, 15, 15, 15,
+ 22, 28, 28, 40, 40, 40, 50, 50,
+ 69, 69, 69, 80, 80, 87, 87, 96,
+ 108, 108, -1
+ };
+
+ static const int versions_count = (sizeof versions_indices) / (sizeof versions_indices[0]);
+
+ // https://source.android.com/source/build-numbers.html
+ // https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
+ const int sdk_int = QJNIObjectPrivate::getStaticField<jint>("android/os/Build$VERSION", "SDK_INT");
+ return &versions_string[versions_indices[qBound(0, sdk_int, versions_count - 1)]];
+}
+#endif
/*!
\since 5.4
@@ -2609,9 +2574,9 @@ QString QSysInfo::kernelType()
QString QSysInfo::kernelVersion()
{
#ifdef Q_OS_WIN
- const OSVERSIONINFOEX osver = winOsVersion();
- return QString::number(int(osver.dwMajorVersion)) + QLatin1Char('.') + QString::number(int(osver.dwMinorVersion))
- + QLatin1Char('.') + QString::number(int(osver.dwBuildNumber));
+ const auto osver = QOperatingSystemVersion::current();
+ return QString::number(osver.majorVersion()) + QLatin1Char('.') + QString::number(osver.minorVersion())
+ + QLatin1Char('.') + QString::number(osver.microVersion());
#else
struct utsname u;
if (uname(&u) == 0)
@@ -2679,8 +2644,8 @@ QString QSysInfo::productType()
#elif defined(Q_OS_WATCHOS)
return QStringLiteral("watchos");
#elif defined(Q_OS_MACOS)
- const QAppleOperatingSystemVersion version = qt_apple_os_version();
- if (version.major == 10 && version.minor < 12)
+ const auto version = QOperatingSystemVersion::current();
+ if (version.majorVersion() == 10 && version.minorVersion() < 12)
return QStringLiteral("osx");
return QStringLiteral("macos");
#elif defined(Q_OS_DARWIN)
@@ -2720,20 +2685,17 @@ QString QSysInfo::productType()
*/
QString QSysInfo::productVersion()
{
-#if defined(Q_OS_MAC)
- const QAppleOperatingSystemVersion version = qt_apple_os_version();
- return QString::number(version.major) + QLatin1Char('.') + QString::number(version.minor);
+#if defined(Q_OS_ANDROID) || defined(Q_OS_DARWIN)
+ const auto version = QOperatingSystemVersion::current();
+ return QString::number(version.majorVersion()) + QLatin1Char('.') + QString::number(version.minorVersion());
#elif defined(Q_OS_WIN)
- const char *version = winVer_helper();
+ const char *version = osVer_helper();
if (version) {
const QLatin1Char spaceChar(' ');
return QString::fromLatin1(version).remove(spaceChar).toLower() + winSp_helper().remove(spaceChar).toLower();
}
// fall through
-// Android should not fall through to the Unix code
-#elif defined(Q_OS_ANDROID)
- return QJNIObjectPrivate::getStaticObjectField("android/os/Build$VERSION", "RELEASE", "Ljava/lang/String;").toString();
#elif defined(USE_ETC_OS_RELEASE) // Q_OS_UNIX
QUnixOSVersion unixOsVersion;
findUnixOsVersion(unixOsVersion);
@@ -2761,44 +2723,23 @@ QString QSysInfo::productVersion()
*/
QString QSysInfo::prettyProductName()
{
-#if defined(Q_OS_IOS)
- return QLatin1String("iOS ") + productVersion();
-#elif defined(Q_OS_TVOS)
- return QLatin1String("tvOS ") + productVersion();
-#elif defined(Q_OS_WATCHOS)
- return QLatin1String("watchOS ") + productVersion();
-#elif defined(Q_OS_MACOS)
- const QAppleOperatingSystemVersion version = qt_apple_os_version();
- const char *name = osxVer_helper(version);
- if (name) {
- return (version.major == 10 && version.minor < 12
- ? QLatin1String("OS X ")
- : QLatin1String("macOS "))
- + QLatin1String(name)
- + QLatin1String(" (") + QString::number(version.major)
- + QLatin1Char('.') + QString::number(version.minor)
- + QLatin1Char(')');
- } else {
- return QLatin1String("macOS ")
- + QString::number(version.major) + QLatin1Char('.')
- + QString::number(version.minor);
- }
-#elif defined(Q_OS_WINPHONE)
- return QLatin1String("Windows Phone ") + QLatin1String(winVer_helper());
-#elif defined(Q_OS_WIN)
- const char *name = winVer_helper();
- const OSVERSIONINFOEX osver = winOsVersion();
+#if defined(Q_OS_WINPHONE)
+ return QLatin1String("Windows Phone ") + QLatin1String(osVer_helper());
+#elif defined(Q_OS_ANDROID) || defined(Q_OS_DARWIN) || defined(Q_OS_WIN)
+ const auto version = QOperatingSystemVersion::current();
+ const char *name = osVer_helper(version);
if (name)
- return QLatin1String("Windows ") + QLatin1String(name) + winSp_helper()
- + QLatin1String(" (") + QString::number(osver.dwMajorVersion)
- + QLatin1Char('.') + QString::number(osver.dwMinorVersion)
+ return version.name() + QLatin1Char(' ') + QLatin1String(name)
+# if defined(Q_OS_WIN)
+ + winSp_helper()
+# endif
+ + QLatin1String(" (") + QString::number(version.majorVersion())
+ + QLatin1Char('.') + QString::number(version.minorVersion())
+ QLatin1Char(')');
- else
- return QLatin1String("Windows ")
- + QString::number(osver.dwMajorVersion) + QLatin1Char('.')
- + QString::number(osver.dwMinorVersion);
-#elif defined(Q_OS_ANDROID)
- return QLatin1String("Android ") + productVersion();
+ else
+ return version.name() + QLatin1Char(' ')
+ + QString::number(version.majorVersion()) + QLatin1Char('.')
+ + QString::number(version.minorVersion());
#elif defined(Q_OS_HAIKU)
return QLatin1String("Haiku ") + productVersion();
#elif defined(Q_OS_UNIX)
diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp
new file mode 100644
index 0000000000..75d3f99fee
--- /dev/null
+++ b/src/corelib/global/qoperatingsystemversion.cpp
@@ -0,0 +1,423 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore 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 "qoperatingsystemversion.h"
+#if !defined(Q_OS_DARWIN) && !defined(Q_OS_WIN)
+#include "qoperatingsystemversion_p.h"
+#endif
+
+#include <qversionnumber.h>
+
+#if defined(Q_OS_ANDROID)
+#include <private/qjni_p.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QOperatingSystemVersion
+ \inmodule QtCore
+ \since 5.9
+ \brief The QOperatingSystemVersion class provides information about the operating system version.
+
+ Unlike other version functions in QSysInfo, QOperatingSystemVersion provides access to the full
+ version number that \a developers typically use to vary behavior or determine whether to enable
+ APIs or features based on the operating system version (as opposed to the kernel version number
+ or marketing version).
+
+ This class is also a complete replacement for QSysInfo::macVersion and QSysInfo::windowsVersion,
+ additionally providing access to the third (micro) version number component.
+
+ Presently, Android, Apple Platforms (iOS, macOS, tvOS, and watchOS), and Windows are supported.
+
+ The \a majorVersion(), \a minorVersion(), and \a microVersion() functions return the parts of
+ the operating system version number based on:
+
+ \table
+ \header \li Platforms \li Value
+ \row \li Android \li result of parsing
+ \l{https://developer.android.com/reference/android/os/Build.VERSION.html#RELEASE}{"android.os.Build.VERSION.RELEASE"}
+ using QVersionNumber, with a fallback to
+ \l{https://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT}{"android.os.Build.VERSION.SDK_INT"}
+ to determine the major and minor version component if the former fails
+ \row \li Apple Platforms \li majorVersion, minorVersion, and patchVersion from
+ \l{https://developer.apple.com/reference/foundation/nsprocessinfo/1410906-operatingsystemversion?language=objc}{"NSProcessInfo.operatingSystemVersion"}
+ \row \li Windows \li dwMajorVersion, dwMinorVersion, and dwBuildNumber from
+ \l{https://msdn.microsoft.com/en-us/library/mt723418.aspx}{"RtlGetVersion"} -
+ note that this function ALWAYS return the version number of the underlying operating system,
+ as opposed to the shim underneath GetVersionEx that hides the real version number
+ if the application is not manifested for that version of the OS
+ \endtable
+*/
+
+/*!
+ \fn QOperatingSystemVersion::QOperatingSystemVersion(int maj, int min, int mic)
+
+ Constructs a QOperatingSystemVersion consisting of the OS type \a os, and
+ major, minor, and micro version numbers \a maj, \a min and \a mic, respectively.
+*/
+
+/*!
+ \fn QOperatingSystemVersion QOperatingSystemVersion::current()
+
+ Returns a QOperatingSystemVersion indicating the current OS and its version number.
+*/
+#if !defined(Q_OS_DARWIN) && !defined(Q_OS_WIN)
+QOperatingSystemVersion QOperatingSystemVersion::current()
+{
+ QOperatingSystemVersion version;
+ version.m_os = currentType();
+#if defined(Q_OS_ANDROID)
+#ifndef QT_BOOTSTRAPPED
+ const QVersionNumber v = QVersionNumber::fromString(QJNIObjectPrivate::getStaticObjectField(
+ "android/os/Build$VERSION", "RELEASE", "Ljava/lang/String;").toString());
+ if (!v.isNull()) {
+ version.m_major = v.majorVersion();
+ version.m_minor = v.minorVersion();
+ version.m_micro = v.microVersion();
+ return version;
+ }
+#endif
+
+ version.m_major = -1;
+ version.m_minor = -1;
+
+ static const int versions[][2] = {
+ { 1, 0 }, // API level 1
+ { 1, 1 }, // API level 2
+ { 1, 5 }, // API level 3
+ { 1, 6 }, // API level 4
+ { 2, 0 }, // API level 5
+ { 2, 0 }, // API level 6
+ { 2, 1 }, // API level 7
+ { 2, 2 }, // API level 8
+ { 2, 3 }, // API level 9
+ { 2, 3 }, // API level 10
+ { 3, 0 }, // API level 11
+ { 3, 1 }, // API level 12
+ { 3, 2 }, // API level 13
+ { 4, 0 }, // API level 14
+ { 4, 0 }, // API level 15
+ { 4, 1 }, // API level 16
+ { 4, 2 }, // API level 17
+ { 4, 3 }, // API level 18
+ { 4, 4 }, // API level 19
+ { 4, 4 }, // API level 20
+ { 5, 0 }, // API level 21
+ { 5, 1 }, // API level 22
+ { 6, 0 }, // API level 23
+ { 7, 0 }, // API level 24
+ { 7, 1 }, // API level 25
+ };
+
+ // This will give us at least the first 2 version components
+ const size_t versionIdx = size_t(QJNIObjectPrivate::getStaticField<jint>("android/os/Build$VERSION", "SDK_INT")) - 1;
+ if (versionIdx < sizeof(versions) / sizeof(versions[0])) {
+ version.m_major = versions[versionIdx][0];
+ version.m_minor = versions[versionIdx][1];
+ }
+
+ // API level 6 was exactly version 2.0.1
+ version.m_micro = versionIdx == 5 ? 1 : -1;
+#else
+ version.m_major = -1;
+ version.m_minor = -1;
+ version.m_micro = -1;
+#endif
+ return version;
+}
+#endif
+
+static inline int compareVersionComponents(int lhs, int rhs)
+{
+ return lhs >= 0 && rhs >= 0 ? lhs - rhs : 0;
+}
+
+/*!
+ \fn int QOperatingSystemVersion::compare(const QOperatingSystemVersion &v1,
+ const QOperatingSystemVersion &v2)
+
+ Compares \a v1 with \a v2 and returns an integer less than, equal to, or
+ greater than zero, depending on whether \a v1 is less than, equal to, or
+ greater than \a v2, respectively.
+
+ Comparisons are performed by comparing the version number components of
+ \a v1 and \a v2.
+
+ \note This function cannot take the OS type into account; you should use
+ the overloaded comparison operators to compare QOperatingSystemVersions
+ in a safe manner.
+*/
+int QOperatingSystemVersion::compare(const QOperatingSystemVersion &v1, const QOperatingSystemVersion &v2)
+{
+ if (v1.m_major == v2.m_major) {
+ if (v1.m_minor == v2.m_minor) {
+ return compareVersionComponents(v1.m_micro, v2.m_micro);
+ }
+ return compareVersionComponents(v1.m_minor, v2.m_minor);
+ }
+ return compareVersionComponents(v1.m_major, v2.m_major);
+}
+
+#ifndef QT_BOOTSTRAPPED
+/*!
+ \fn QOperatingSystemVersion QOperatingSystemVersion::fromVersionNumber(const QVersionNumber &version,
+ QOperatingSystemVersion::OSType os)
+
+ Returns a QOperatingSystemVersion consisting of the OS type \a os and version number \a version.
+*/
+QOperatingSystemVersion QOperatingSystemVersion::fromVersionNumber(const QVersionNumber &version,
+ QOperatingSystemVersion::OSType os)
+{
+ return QOperatingSystemVersion(os, version.majorVersion(), version.minorVersion(), version.microVersion());
+}
+
+/*!
+ \fn QOperatingSystemVersion QOperatingSystemVersion::toVersionNumber() const
+
+ Returns the QOperatingSystemVersion's version number as a QVersionNumber.
+*/
+QVersionNumber QOperatingSystemVersion::toVersionNumber() const
+{
+ return QVersionNumber(m_major, m_minor, m_micro);
+}
+#endif
+
+/*!
+ \fn int QOperatingSystemVersion::majorVersion() const
+
+ Returns the major version number, that is, the first segment of the operating system's version number.
+
+ See the main class documentation for what the major version number is on a given operating system.
+
+ -1 indicates an unknown or absent version number component.
+
+ \sa minorVersion(), microVersion()
+*/
+
+/*!
+ \fn int QOperatingSystemVersion::minorVersion() const
+
+ Returns the minor version number, that is, the second segment of the operating system's version number.
+
+ See the main class documentation for what the minor version number is on a given operating system.
+
+ -1 indicates an unknown or absent version number component.
+
+ \sa majorVersion(), macro()
+*/
+
+/*!
+ \fn int QOperatingSystemVersion::microVersion() const
+
+ Returns the micro version number, that is, the third segment of the operating system's version number.
+
+ See the main class documentation for what the micro version number is on a given operating system.
+
+ -1 indicates an unknown or absent version number component.
+
+ \sa majorVersion(), minorVersion()
+*/
+
+/*!
+ \fn QOperatingSystemVersion::OSType QOperatingSystemVersion::type() const
+
+ Returns the OS type identified by the QOperatingSystemVersion.
+
+ \sa typeName()
+*/
+
+/*!
+ \fn QString QOperatingSystemVersion::name() const
+
+ Returns a string representation of the OS type identified by the QOperatingSystemVersion.
+
+ \sa type()
+*/
+QString QOperatingSystemVersion::name() const
+{
+ switch (type()) {
+ case QOperatingSystemVersion::Windows:
+ return QStringLiteral("Windows");
+ case QOperatingSystemVersion::MacOS: {
+ if (majorVersion() < 10)
+ return QStringLiteral("Mac OS");
+ if (majorVersion() == 10 && minorVersion() < 8)
+ return QStringLiteral("Mac OS X");
+ if (majorVersion() == 10 && minorVersion() < 12)
+ return QStringLiteral("OS X");
+ return QStringLiteral("macOS");
+ }
+ case QOperatingSystemVersion::IOS: {
+ if (majorVersion() < 4)
+ return QStringLiteral("iPhone OS");
+ return QStringLiteral("iOS");
+ }
+ case QOperatingSystemVersion::TvOS:
+ return QStringLiteral("tvOS");
+ case QOperatingSystemVersion::WatchOS:
+ return QStringLiteral("watchOS");
+ case QOperatingSystemVersion::Android:
+ return QStringLiteral("Android");
+ case QOperatingSystemVersion::Unknown:
+ default:
+ return QString();
+ }
+}
+
+/*!
+ \variable QOperatingSystemVersion::Windows7
+ \brief a version corresponding to Windows 7 (version 6.1).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::Windows7 = QOperatingSystemVersion(QOperatingSystemVersion::Windows, 6, 1);
+
+/*!
+ \variable QOperatingSystemVersion::Windows8
+ \brief a version corresponding to Windows 8 (version 6.2).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::Windows8 = QOperatingSystemVersion(QOperatingSystemVersion::Windows, 6, 2);
+
+/*!
+ \variable QOperatingSystemVersion::Windows8_1
+ \brief a version corresponding to Windows 8.1 (version 6.3).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::Windows8_1 = QOperatingSystemVersion(QOperatingSystemVersion::Windows, 6, 3);
+
+/*!
+ \variable QOperatingSystemVersion::Windows10
+ \brief a version corresponding to Windows 10 (version 10.0).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::Windows10 = QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10);
+
+/*!
+ \variable QOperatingSystemVersion::OSXMavericks
+ \brief a version corresponding to OS X Mavericks (version 10.9).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::OSXMavericks = QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 10, 9);
+
+/*!
+ \variable QOperatingSystemVersion::OSXYosemite
+ \brief a version corresponding to OS X Yosemite (version 10.10).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::OSXYosemite = QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 10, 10);
+
+/*!
+ \variable QOperatingSystemVersion::OSXElCapitan
+ \brief a version corresponding to OS X El Capitan (version 10.11).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::OSXElCapitan = QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 10, 11);
+
+/*!
+ \variable QOperatingSystemVersion::MacOSSierra
+ \brief a version corresponding to macOS Sierra (version 10.12).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::MacOSSierra = QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 10, 12);
+
+/*!
+ \variable QOperatingSystemVersion::AndroidJellyBean
+ \brief a version corresponding to Android Jelly Bean (version 4.1, API level 16).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::AndroidJellyBean = QOperatingSystemVersion(QOperatingSystemVersion::Android, 4, 1);
+
+/*!
+ \variable QOperatingSystemVersion::AndroidJellyBean_MR1
+ \brief a version corresponding to Android Jelly Bean, maintenance release 1 (version 4.2, API level 17).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::AndroidJellyBean_MR1 = QOperatingSystemVersion(QOperatingSystemVersion::Android, 4, 2);
+
+/*!
+ \variable QOperatingSystemVersion::AndroidJellyBean_MR2
+ \brief a version corresponding to Android Jelly Bean, maintenance release 2 (version 4.3, API level 18).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::AndroidJellyBean_MR2 = QOperatingSystemVersion(QOperatingSystemVersion::Android, 4, 3);
+
+/*!
+ \variable QOperatingSystemVersion::AndroidKitKat
+ \brief a version corresponding to Android KitKat (versions 4.4 & 4.4W, API levels 19 & 20).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::AndroidKitKat = QOperatingSystemVersion(QOperatingSystemVersion::Android, 4, 4);
+
+/*!
+ \variable QOperatingSystemVersion::AndroidLollipop
+ \brief a version corresponding to Android Lollipop (version 5.0, API level 21).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::AndroidLollipop = QOperatingSystemVersion(QOperatingSystemVersion::Android, 5, 0);
+
+/*!
+ \variable QOperatingSystemVersion::AndroidLollipop_MR1
+ \brief a version corresponding to Android Lollipop, maintenance release 1 (version 5.1, API level 22).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::AndroidLollipop_MR1 = QOperatingSystemVersion(QOperatingSystemVersion::Android, 5, 1);
+
+/*!
+ \variable QOperatingSystemVersion::AndroidMarshmallow
+ \brief a version corresponding to Android Marshmallow (version 6.0, API level 23).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::AndroidMarshmallow = QOperatingSystemVersion(QOperatingSystemVersion::Android, 6, 0);
+
+/*!
+ \variable QOperatingSystemVersion::AndroidNougat
+ \brief a version corresponding to Android Nougat (version 7.0, API level 24).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::AndroidNougat = QOperatingSystemVersion(QOperatingSystemVersion::Android, 7, 0);
+
+/*!
+ \variable QOperatingSystemVersion::AndroidNougat_MR1
+ \brief a version corresponding to Android Nougat, maintenance release 1 (version 7.0, API level 25).
+ \since 5.9
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::AndroidNougat_MR1 = QOperatingSystemVersion(QOperatingSystemVersion::Android, 7, 1);
+
+QT_END_NAMESPACE
diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h
new file mode 100644
index 0000000000..ef999c6ae4
--- /dev/null
+++ b/src/corelib/global/qoperatingsystemversion.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore 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 <QtCore/qglobal.h>
+
+#ifndef QOPERATINGSYSTEMVERSION_H
+#define QOPERATINGSYSTEMVERSION_H
+
+QT_BEGIN_NAMESPACE
+
+class QString;
+class QVersionNumber;
+
+class Q_CORE_EXPORT QOperatingSystemVersion
+{
+public:
+ enum OSType {
+ Unknown = 0,
+ Windows,
+ MacOS,
+ IOS,
+ TvOS,
+ WatchOS,
+ Android
+ };
+
+ static const QOperatingSystemVersion Windows7;
+ static const QOperatingSystemVersion Windows8;
+ static const QOperatingSystemVersion Windows8_1;
+ static const QOperatingSystemVersion Windows10;
+
+ static const QOperatingSystemVersion OSXMavericks;
+ static const QOperatingSystemVersion OSXYosemite;
+ static const QOperatingSystemVersion OSXElCapitan;
+ static const QOperatingSystemVersion MacOSSierra;
+
+ static const QOperatingSystemVersion AndroidJellyBean;
+ static const QOperatingSystemVersion AndroidJellyBean_MR1;
+ static const QOperatingSystemVersion AndroidJellyBean_MR2;
+ static const QOperatingSystemVersion AndroidKitKat;
+ static const QOperatingSystemVersion AndroidLollipop;
+ static const QOperatingSystemVersion AndroidLollipop_MR1;
+ static const QOperatingSystemVersion AndroidMarshmallow;
+ static const QOperatingSystemVersion AndroidNougat;
+ static const QOperatingSystemVersion AndroidNougat_MR1;
+
+ QOperatingSystemVersion(const QOperatingSystemVersion &other) = default;
+ Q_DECL_CONSTEXPR QOperatingSystemVersion(OSType osType, int vmajor, int vminor = -1, int vmicro = -1)
+ : m_os(osType), m_major(vmajor), m_minor(vminor), m_micro(vmicro) { }
+
+ static QOperatingSystemVersion current();
+
+ static int compare(const QOperatingSystemVersion &v1, const QOperatingSystemVersion &v2);
+
+ QOperatingSystemVersion fromVersionNumber(const QVersionNumber &version, OSType os);
+ QVersionNumber toVersionNumber() const;
+
+ Q_DECL_CONSTEXPR int majorVersion() const { return m_major; }
+ Q_DECL_CONSTEXPR int minorVersion() const { return m_minor; }
+ Q_DECL_CONSTEXPR int microVersion() const { return m_micro; }
+
+ Q_DECL_CONSTEXPR OSType type() const { return m_os; }
+ QString name() const;
+
+private:
+ QOperatingSystemVersion() = default;
+ OSType m_os;
+ int m_major;
+ int m_minor;
+ int m_micro;
+};
+
+inline bool operator>(const QOperatingSystemVersion &lhs, const QOperatingSystemVersion &rhs)
+{ return lhs.type() == rhs.type() && QOperatingSystemVersion::compare(lhs, rhs) > 0; }
+
+inline bool operator>=(const QOperatingSystemVersion &lhs, const QOperatingSystemVersion &rhs)
+{ return lhs.type() == rhs.type() && QOperatingSystemVersion::compare(lhs, rhs) >= 0; }
+
+inline bool operator<(const QOperatingSystemVersion &lhs, const QOperatingSystemVersion &rhs)
+{ return lhs.type() == rhs.type() && QOperatingSystemVersion::compare(lhs, rhs) < 0; }
+
+inline bool operator<=(const QOperatingSystemVersion &lhs, const QOperatingSystemVersion &rhs)
+{ return lhs.type() == rhs.type() && QOperatingSystemVersion::compare(lhs, rhs) <= 0; }
+
+inline bool operator==(const QOperatingSystemVersion &lhs, const QOperatingSystemVersion &rhs)
+{ return lhs.type() == rhs.type() && QOperatingSystemVersion::compare(lhs, rhs) == 0; }
+
+inline bool operator!=(const QOperatingSystemVersion &lhs, const QOperatingSystemVersion &rhs)
+{ return !(lhs == rhs); }
+
+QT_END_NAMESPACE
+
+#endif // QOPERATINGSYSTEMVERSION_H
diff --git a/src/corelib/global/qoperatingsystemversion_darwin.mm b/src/corelib/global/qoperatingsystemversion_darwin.mm
new file mode 100644
index 0000000000..3dd007cbb3
--- /dev/null
+++ b/src/corelib/global/qoperatingsystemversion_darwin.mm
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore 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 "qoperatingsystemversion_p.h"
+#import <Foundation/Foundation.h>
+
+#ifdef Q_OS_IOS
+#import <UIKit/UIKit.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+typedef qint16 (*GestaltFunction)(quint32 selector, qint32 *response);
+
+QOperatingSystemVersion QOperatingSystemVersion::current()
+{
+ QOperatingSystemVersion v;
+ v.m_os = currentType();
+ v.m_major = -1;
+ v.m_minor = -1;
+ v.m_micro = -1;
+#if QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0) || defined(Q_OS_TVOS) || defined(Q_OS_WATCHOS)
+ if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) {
+ NSOperatingSystemVersion osv = NSProcessInfo.processInfo.operatingSystemVersion;
+ v.m_major = osv.majorVersion;
+ v.m_minor = osv.minorVersion;
+ v.m_micro = osv.patchVersion;
+ return v;
+ }
+#endif
+ // 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_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(__MAC_10_10, __IPHONE_8_0)
+#if defined(Q_OS_IOS)
+ @autoreleasepool {
+ NSArray *parts = [UIDevice.currentDevice.systemVersion componentsSeparatedByString:@"."];
+ major = parts.count > 0 ? [[parts objectAtIndex:0] intValue] : 0;
+ minor = parts.count > 1 ? [[parts objectAtIndex:1] intValue] : 0;
+ patch = parts.count > 2 ? [[parts objectAtIndex:2] intValue] : 0;
+ }
+#elif defined(Q_OS_MACOS)
+ static GestaltFunction pGestalt = 0;
+ if (!pGestalt) {
+ CFBundleRef b = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CoreServices"));
+ pGestalt = reinterpret_cast<GestaltFunction>(CFBundleGetFunctionPointerForName(b,
+ CFSTR("Gestalt")));
+ }
+ if (!pGestalt)
+ return v;
+ if (pGestalt('sys1', &major) != 0)
+ return v;
+ if (pGestalt('sys2', &minor) != 0)
+ return v;
+ if (pGestalt('sys3', &patch) != 0)
+ return v;
+#endif
+#endif
+ v.m_major = major;
+ v.m_minor = minor;
+ v.m_micro = patch;
+ return v;
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/global/qoperatingsystemversion_p.h b/src/corelib/global/qoperatingsystemversion_p.h
new file mode 100644
index 0000000000..78d0daf0c6
--- /dev/null
+++ b/src/corelib/global/qoperatingsystemversion_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore 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$
+**
+****************************************************************************/
+
+#ifndef QOPERATINGSYSTEMVERSION_P_H
+#define QOPERATINGSYSTEMVERSION_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 "qoperatingsystemversion.h"
+
+#ifdef Q_OS_WIN
+#include <qt_windows.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#ifdef Q_OS_WIN
+OSVERSIONINFOEX qWindowsVersionInfo();
+#endif
+
+static inline QOperatingSystemVersion::OSType currentType()
+{
+#if defined(Q_OS_WIN)
+ return QOperatingSystemVersion::Windows;
+#elif defined(Q_OS_MACOS)
+ return QOperatingSystemVersion::MacOS;
+#elif defined(Q_OS_IOS)
+ return QOperatingSystemVersion::IOS;
+#elif defined(Q_OS_TVOS)
+ return QOperatingSystemVersion::TvOS;
+#elif defined(Q_OS_WATCHOS)
+ return QOperatingSystemVersion::WatchOS;
+#elif defined(Q_OS_ANDROID)
+ return QOperatingSystemVersion::Android;
+#else
+ return QOperatingSystemVersion::Unknown;
+#endif
+}
+
+QT_END_NAMESPACE
+
+#endif // QOPERATINGSYSTEMVERSION_P_H
diff --git a/src/corelib/global/qoperatingsystemversion_win.cpp b/src/corelib/global/qoperatingsystemversion_win.cpp
new file mode 100644
index 0000000000..060ca2f7da
--- /dev/null
+++ b/src/corelib/global/qoperatingsystemversion_win.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore 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 "qoperatingsystemversion_p.h"
+#include <qt_windows.h>
+#include <qbytearray.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifdef Q_OS_WINRT
+static inline HMODULE moduleHandleForFunction(LPCVOID address)
+{
+ // This is a widely used, decades-old technique for retrieving the handle
+ // of a module and is effectively equivalent to GetModuleHandleEx
+ // (which is unavailable on WinRT)
+ MEMORY_BASIC_INFORMATION mbi = { 0, 0, 0, 0, 0, 0, 0 };
+ if (VirtualQuery(address, &mbi, sizeof(mbi)) == 0)
+ return 0;
+ return reinterpret_cast<HMODULE>(mbi.AllocationBase);
+}
+#endif
+
+static inline OSVERSIONINFOEX determineWinOsVersion()
+{
+ OSVERSIONINFOEX result = { sizeof(OSVERSIONINFOEX), 0, 0, 0, 0, {'\0'}, 0, 0, 0, 0, 0};
+
+#define GetProcAddressA GetProcAddress
+
+ // GetModuleHandle is not supported in WinRT and linking to it at load time
+ // will not pass the Windows App Certification Kit... but it exists and is functional,
+ // so use some unusual but widely used techniques to get a pointer to it
+#ifdef Q_OS_WINRT
+ // 1. Get HMODULE of kernel32.dll, using the address of some function exported by that DLL
+ HMODULE kernelModule = moduleHandleForFunction(reinterpret_cast<LPCVOID>(VirtualQuery));
+ if (Q_UNLIKELY(!kernelModule))
+ return result;
+
+ // 2. Get pointer to GetModuleHandle so we can then load other arbitrary modules (DLLs)
+ typedef HMODULE(WINAPI *GetModuleHandleFunction)(LPCWSTR);
+ GetModuleHandleFunction pGetModuleHandle = reinterpret_cast<GetModuleHandleFunction>(
+ GetProcAddressA(kernelModule, "GetModuleHandleW"));
+ if (Q_UNLIKELY(!pGetModuleHandle))
+ return result;
+#else
+#define pGetModuleHandle GetModuleHandleW
+#endif
+
+#ifndef Q_OS_WINCE
+ HMODULE ntdll = pGetModuleHandle(L"ntdll.dll");
+ if (Q_UNLIKELY(!ntdll))
+ return result;
+
+ // NTSTATUS is not defined on WinRT
+ typedef LONG NTSTATUS;
+ typedef NTSTATUS (NTAPI *RtlGetVersionFunction)(LPOSVERSIONINFO);
+
+ // RtlGetVersion is documented public API but we must load it dynamically
+ // because linking to it at load time will not pass the Windows App Certification Kit
+ // https://msdn.microsoft.com/en-us/library/windows/hardware/ff561910.aspx
+ RtlGetVersionFunction pRtlGetVersion = reinterpret_cast<RtlGetVersionFunction>(
+ GetProcAddressA(ntdll, "RtlGetVersion"));
+ if (Q_UNLIKELY(!pRtlGetVersion))
+ return result;
+
+ // GetVersionEx() has been deprecated in Windows 8.1 and will return
+ // only Windows 8 from that version on, so use the kernel API function.
+ pRtlGetVersion((LPOSVERSIONINFO) &result); // always returns STATUS_SUCCESS
+#else // !Q_OS_WINCE
+ GetVersionEx(&result);
+#endif
+ return result;
+}
+
+OSVERSIONINFOEX qWindowsVersionInfo()
+{
+ OSVERSIONINFOEX realResult = determineWinOsVersion();
+#ifdef QT_DEBUG
+ {
+ if (Q_UNLIKELY(qEnvironmentVariableIsSet("QT_WINVER_OVERRIDE"))) {
+ OSVERSIONINFOEX result = realResult;
+ result.dwMajorVersion = 0;
+ result.dwMinorVersion = 0;
+
+ // Erase any build number and service pack information
+ result.dwBuildNumber = 0;
+ result.szCSDVersion[0] = L'\0';
+ result.wServicePackMajor = 0;
+ result.wServicePackMinor = 0;
+
+ const QByteArray winVerOverride = qgetenv("QT_WINVER_OVERRIDE");
+ if (winVerOverride == "WINDOWS7" || winVerOverride == "2008_R2") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 1;
+ } else if (winVerOverride == "WINDOWS8" || winVerOverride == "2012") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 2;
+ } else if (winVerOverride == "WINDOWS8_1" || winVerOverride == "2012_R2") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 3;
+ } else if (winVerOverride == "WINDOWS10" || winVerOverride == "2016") {
+ result.dwMajorVersion = 10;
+ } else {
+ return realResult;
+ }
+
+ if (winVerOverride == "2008_R2"
+ || winVerOverride == "2012"
+ || winVerOverride == "2012_R2"
+ || winVerOverride == "2016") {
+ // If the current host OS is a domain controller and the override OS
+ // is also a server type OS, preserve that information
+ if (result.wProductType == VER_NT_WORKSTATION)
+ result.wProductType = VER_NT_SERVER;
+ } else {
+ // Any other OS must be a workstation OS type
+ result.wProductType = VER_NT_WORKSTATION;
+ }
+ }
+ }
+#endif
+ return realResult;
+}
+
+QOperatingSystemVersion QOperatingSystemVersion::current()
+{
+ QOperatingSystemVersion v;
+ v.m_os = currentType();
+ const OSVERSIONINFOEX osv = qWindowsVersionInfo();
+ v.m_major = osv.dwMajorVersion;
+ v.m_minor = osv.dwMinorVersion;
+ v.m_micro = osv.dwBuildNumber;
+ return v;
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index 23f412aa6a..3cbcfd3fc9 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -49,6 +49,23 @@ QT_BEGIN_NAMESPACE
System information
*/
+/*
+ * GCC (5-7) has a regression that causes it to emit wrong deprecated warnings:
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77849
+ *
+ * Try to work around it by defining our own macro.
+ */
+
+#ifdef QT_SYSINFO_DEPRECATED_X
+#error "QT_SYSINFO_DEPRECATED_X already defined"
+#endif
+
+#ifdef Q_CC_GNU
+#define QT_SYSINFO_DEPRECATED_X(x)
+#else
+#define QT_SYSINFO_DEPRECATED_X(x) QT_DEPRECATED_X(x)
+#endif
+
class QString;
class Q_CORE_EXPORT QSysInfo {
public:
@@ -79,7 +96,8 @@ public:
# endif
};
#endif
- enum WinVersion {
+#if QT_DEPRECATED_SINCE(5, 9)
+ enum QT_DEPRECATED_X("Use QOperatingSystemVersion") WinVersion {
WV_None = 0x0000,
WV_32s = 0x0001,
@@ -117,19 +135,25 @@ public:
WV_CE_6 = 0x0400,
WV_CE_based = 0x0f00
};
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
+QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
+QT_WARNING_DISABLE_INTEL(1478)
+QT_WARNING_DISABLE_MSVC(4996)
#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
- static const WinVersion WindowsVersion;
- static WinVersion windowsVersion();
+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static const WinVersion WindowsVersion;
+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static WinVersion windowsVersion();
#else
- static const WinVersion WindowsVersion = WV_None;
- static WinVersion windowsVersion() { return WV_None; }
+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static const WinVersion WindowsVersion = WV_None;
+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static WinVersion windowsVersion() { return WV_None; }
#endif
+QT_WARNING_POP
#define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0))
#define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor)
#define Q_MV_TVOS(major, minor) (QSysInfo::MV_TVOS | major << 4 | minor)
#define Q_MV_WATCHOS(major, minor) (QSysInfo::MV_WATCHOS | major << 4 | minor)
- enum MacVersion {
+ enum QT_DEPRECATED_X("Use QOperatingSystemVersion") MacVersion {
MV_None = 0xffff,
MV_Unknown = 0x0000,
@@ -198,13 +222,20 @@ public:
MV_WATCHOS_2_2 = Q_MV_WATCHOS(2, 2),
MV_WATCHOS_3_0 = Q_MV_WATCHOS(3, 0)
};
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
+QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
+QT_WARNING_DISABLE_INTEL(1478)
+QT_WARNING_DISABLE_MSVC(4996)
#if defined(Q_OS_MAC)
- static const MacVersion MacintoshVersion;
- static MacVersion macVersion();
+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static const MacVersion MacintoshVersion;
+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static MacVersion macVersion();
#else
- static const MacVersion MacintoshVersion = MV_None;
- static MacVersion macVersion() { return MV_None; }
+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static const MacVersion MacintoshVersion = MV_None;
+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static MacVersion macVersion() { return MV_None; }
#endif
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(5, 9)
static QString buildCpuArchitecture();
static QString currentCpuArchitecture();
@@ -219,5 +250,7 @@ public:
static QString machineHostName();
};
+#undef QT_SYSINFO_DEPRECATED_X
+
QT_END_NAMESPACE
#endif // QSYSINFO_H
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index ac58677b77..994ed88791 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -95,10 +95,11 @@ public:
Qt_5_6 = 17,
Qt_5_7 = Qt_5_6,
Qt_5_8 = Qt_5_7,
-#if QT_VERSION >= 0x050900
+ Qt_5_9 = Qt_5_8,
+#if QT_VERSION >= 0x050a00
#error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion
#endif
- Qt_DefaultCompiledVersion = Qt_5_8
+ Qt_DefaultCompiledVersion = Qt_5_9
};
enum ByteOrder {
@@ -222,6 +223,98 @@ private:
QDataStream::Status oldStatus;
};
+template <typename Container>
+QDataStream &readArrayBasedContainer(QDataStream &s, Container &c)
+{
+ StreamStateSaver stateSaver(&s);
+
+ c.clear();
+ quint32 n;
+ s >> n;
+ c.reserve(n);
+ for (quint32 i = 0; i < n; ++i) {
+ typename Container::value_type t;
+ s >> t;
+ if (s.status() != QDataStream::Ok) {
+ c.clear();
+ break;
+ }
+ c.append(t);
+ }
+
+ return s;
+}
+
+template <typename Container>
+QDataStream &readListBasedContainer(QDataStream &s, Container &c)
+{
+ StreamStateSaver stateSaver(&s);
+
+ c.clear();
+ quint32 n;
+ s >> n;
+ for (quint32 i = 0; i < n; ++i) {
+ typename Container::value_type t;
+ s >> t;
+ if (s.status() != QDataStream::Ok) {
+ c.clear();
+ break;
+ }
+ c << t;
+ }
+
+ return s;
+}
+
+template <typename Container>
+QDataStream &readAssociativeContainer(QDataStream &s, Container &c)
+{
+ StreamStateSaver stateSaver(&s);
+
+ c.clear();
+ quint32 n;
+ s >> n;
+ for (quint32 i = 0; i < n; ++i) {
+ typename Container::key_type k;
+ typename Container::mapped_type t;
+ s >> k >> t;
+ if (s.status() != QDataStream::Ok) {
+ c.clear();
+ break;
+ }
+ c.insertMulti(k, t);
+ }
+
+ return s;
+}
+
+template <typename Container>
+QDataStream &writeSequentialContainer(QDataStream &s, const Container &c)
+{
+ s << quint32(c.size());
+ for (const typename Container::value_type &t : c)
+ s << t;
+
+ return s;
+}
+
+template <typename Container>
+QDataStream &writeAssociativeContainer(QDataStream &s, const Container &c)
+{
+ s << quint32(c.size());
+ // Deserialization should occur in the reverse order.
+ // Otherwise, value() will return the least recently inserted
+ // value instead of the most recently inserted one.
+ auto it = c.constEnd();
+ auto begin = c.constBegin();
+ while (it != begin) {
+ --it;
+ s << it.key() << it.value();
+ }
+
+ return s;
+}
+
} // QtPrivate namespace
/*****************************************************************************
@@ -265,209 +358,75 @@ inline QDataStream &QDataStream::operator<<(quint64 i)
{ return *this << qint64(i); }
template <typename T>
-QDataStream& operator>>(QDataStream& s, QList<T>& l)
+inline QDataStream &operator>>(QDataStream &s, QList<T> &l)
{
- QtPrivate::StreamStateSaver stateSaver(&s);
-
- l.clear();
- quint32 c;
- s >> c;
- l.reserve(c);
- for(quint32 i = 0; i < c; ++i)
- {
- T t;
- s >> t;
- if (s.status() != QDataStream::Ok) {
- l.clear();
- break;
- }
- l.append(t);
- }
-
- return s;
+ return QtPrivate::readArrayBasedContainer(s, l);
}
template <typename T>
-QDataStream& operator<<(QDataStream& s, const QList<T>& l)
+inline QDataStream &operator<<(QDataStream &s, const QList<T> &l)
{
- s << quint32(l.size());
- for (int i = 0; i < l.size(); ++i)
- s << l.at(i);
- return s;
+ return QtPrivate::writeSequentialContainer(s, l);
}
template <typename T>
-QDataStream& operator>>(QDataStream& s, QLinkedList<T>& l)
+inline QDataStream &operator>>(QDataStream &s, QLinkedList<T> &l)
{
- QtPrivate::StreamStateSaver stateSaver(&s);
-
- l.clear();
- quint32 c;
- s >> c;
- for(quint32 i = 0; i < c; ++i)
- {
- T t;
- s >> t;
- if (s.status() != QDataStream::Ok) {
- l.clear();
- break;
- }
- l.append(t);
- }
-
- return s;
+ return QtPrivate::readListBasedContainer(s, l);
}
template <typename T>
-QDataStream& operator<<(QDataStream& s, const QLinkedList<T>& l)
+inline QDataStream &operator<<(QDataStream &s, const QLinkedList<T> &l)
{
- s << quint32(l.size());
- typename QLinkedList<T>::ConstIterator it = l.constBegin();
- for(; it != l.constEnd(); ++it)
- s << *it;
- return s;
+ return QtPrivate::writeSequentialContainer(s, l);
}
template<typename T>
-QDataStream& operator>>(QDataStream& s, QVector<T>& v)
+inline QDataStream &operator>>(QDataStream &s, QVector<T> &v)
{
- QtPrivate::StreamStateSaver stateSaver(&s);
-
- v.clear();
- quint32 c;
- s >> c;
- v.resize(c);
- for(quint32 i = 0; i < c; ++i) {
- T t;
- s >> t;
- if (s.status() != QDataStream::Ok) {
- v.clear();
- break;
- }
- v[i] = t;
- }
-
- return s;
+ return QtPrivate::readArrayBasedContainer(s, v);
}
template<typename T>
-QDataStream& operator<<(QDataStream& s, const QVector<T>& v)
+inline QDataStream &operator<<(QDataStream &s, const QVector<T> &v)
{
- s << quint32(v.size());
- for (typename QVector<T>::const_iterator it = v.begin(); it != v.end(); ++it)
- s << *it;
- return s;
+ return QtPrivate::writeSequentialContainer(s, v);
}
template <typename T>
-QDataStream &operator>>(QDataStream &in, QSet<T> &set)
+inline QDataStream &operator>>(QDataStream &s, QSet<T> &set)
{
- QtPrivate::StreamStateSaver stateSaver(&in);
-
- set.clear();
- quint32 c;
- in >> c;
- for (quint32 i = 0; i < c; ++i) {
- T t;
- in >> t;
- if (in.status() != QDataStream::Ok) {
- set.clear();
- break;
- }
- set << t;
- }
-
- return in;
+ return QtPrivate::readListBasedContainer(s, set);
}
template <typename T>
-QDataStream& operator<<(QDataStream &out, const QSet<T> &set)
+inline QDataStream &operator<<(QDataStream &s, const QSet<T> &set)
{
- out << quint32(set.size());
- typename QSet<T>::const_iterator i = set.constBegin();
- while (i != set.constEnd()) {
- out << *i;
- ++i;
- }
- return out;
+ return QtPrivate::writeSequentialContainer(s, set);
}
template <class Key, class T>
-Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QHash<Key, T> &hash)
+inline QDataStream &operator>>(QDataStream &s, QHash<Key, T> &hash)
{
- QtPrivate::StreamStateSaver stateSaver(&in);
-
- hash.clear();
- quint32 n;
- in >> n;
-
- for (quint32 i = 0; i < n; ++i) {
- if (in.status() != QDataStream::Ok)
- break;
-
- Key k;
- T t;
- in >> k >> t;
- hash.insertMulti(k, t);
- }
-
- if (in.status() != QDataStream::Ok)
- hash.clear();
- return in;
+ return QtPrivate::readAssociativeContainer(s, hash);
}
template <class Key, class T>
-Q_OUTOFLINE_TEMPLATE QDataStream &operator<<(QDataStream &out, const QHash<Key, T>& hash)
+inline QDataStream &operator<<(QDataStream &s, const QHash<Key, T> &hash)
{
- out << quint32(hash.size());
- typename QHash<Key, T>::ConstIterator it = hash.end();
- typename QHash<Key, T>::ConstIterator begin = hash.begin();
- while (it != begin) {
- --it;
- out << it.key() << it.value();
- }
- return out;
+ return QtPrivate::writeAssociativeContainer(s, hash);
}
-#ifdef Q_QDOC
+
template <class Key, class T>
-Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QMap<Key, T> &map)
-#else
-template <class aKey, class aT>
-Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QMap<aKey, aT> &map)
-#endif
+inline QDataStream &operator>>(QDataStream &s, QMap<Key, T> &map)
{
- QtPrivate::StreamStateSaver stateSaver(&in);
-
- map.clear();
- quint32 n;
- in >> n;
-
- map.detach();
- for (quint32 i = 0; i < n; ++i) {
- if (in.status() != QDataStream::Ok)
- break;
-
- aKey key;
- aT value;
- in >> key >> value;
- map.insertMulti(key, value);
- }
- if (in.status() != QDataStream::Ok)
- map.clear();
- return in;
+ return QtPrivate::readAssociativeContainer(s, map);
}
template <class Key, class T>
-Q_OUTOFLINE_TEMPLATE QDataStream &operator<<(QDataStream &out, const QMap<Key, T> &map)
+inline QDataStream &operator<<(QDataStream &s, const QMap<Key, T> &map)
{
- out << quint32(map.size());
- typename QMap<Key, T>::ConstIterator it = map.end();
- typename QMap<Key, T>::ConstIterator begin = map.begin();
- while (it != begin) {
- --it;
- out << it.key() << it.value();
- }
- return out;
+ return QtPrivate::writeAssociativeContainer(s, map);
}
#ifndef QT_NO_DATASTREAM
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index cdb64d08e1..663d9cd61d 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -38,7 +38,7 @@
****************************************************************************/
#include "qfilesystemengine_p.h"
-
+#include "qoperatingsystemversion.h"
#include "qplatformdefs.h"
#include "qsysinfo.h"
#include "private/qabstractfileengine_p.h"
@@ -637,7 +637,7 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
FILE_SHARE_READ, OPEN_EXISTING, NULL);
#endif // Q_OS_WINRT
if (handle) {
- result = QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8 ?
+ result = QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8 ?
fileIdWin8(handle) : fileId(handle);
CloseHandle(handle);
}
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp
index 2ce7bd7a4b..9140118872 100644
--- a/src/corelib/io/qfilesystemiterator_win.cpp
+++ b/src/corelib/io/qfilesystemiterator_win.cpp
@@ -39,6 +39,7 @@
#include "qfilesystemiterator_p.h"
#include "qfilesystemengine_p.h"
+#include "qoperatingsystemversion.h"
#include "qplatformdefs.h"
#include "qvector.h"
@@ -93,7 +94,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
haveData = true;
int infoLevel = 0 ; // FindExInfoStandard;
DWORD dwAdditionalFlags = 0;
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) {
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows7) {
dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH
infoLevel = 1 ; // FindExInfoBasic;
}
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index a1d90c76f4..612b3fa57c 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -64,6 +64,9 @@
# include "qfilesystemwatcher_fsevents_p.h"
#endif
+#include <algorithm>
+#include <iterator>
+
QT_BEGIN_NAMESPACE
QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent)
@@ -102,6 +105,17 @@ void QFileSystemWatcherPrivate::init()
SIGNAL(directoryChanged(QString,bool)),
q,
SLOT(_q_directoryChanged(QString,bool)));
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+ QObject::connect(static_cast<QWindowsFileSystemWatcherEngine *>(native),
+ &QWindowsFileSystemWatcherEngine::driveLockForRemoval,
+ q, [this] (const QString &p) { _q_winDriveLockForRemoval(p); });
+ QObject::connect(static_cast<QWindowsFileSystemWatcherEngine *>(native),
+ &QWindowsFileSystemWatcherEngine::driveLockForRemovalFailed,
+ q, [this] (const QString &p) { _q_winDriveLockForRemovalFailed(p); });
+ QObject::connect(static_cast<QWindowsFileSystemWatcherEngine *>(native),
+ &QWindowsFileSystemWatcherEngine::driveRemoved,
+ q, [this] (const QString &p) { _q_winDriveRemoved(p); });
+#endif // !Q_OS_WINRT
}
}
@@ -146,7 +160,46 @@ void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool re
emit q->directoryChanged(path, QFileSystemWatcher::QPrivateSignal());
}
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+
+void QFileSystemWatcherPrivate::_q_winDriveLockForRemoval(const QString &path)
+{
+ // Windows: Request to lock a (removable/USB) drive for removal, release
+ // its paths under watch, temporarily storing them should the lock fail.
+ Q_Q(QFileSystemWatcher);
+ QStringList pathsToBeRemoved;
+ auto pred = [&path] (const QString &f) { return !f.startsWith(path, Qt::CaseInsensitive); };
+ std::remove_copy_if(files.cbegin(), files.cend(),
+ std::back_inserter(pathsToBeRemoved), pred);
+ std::remove_copy_if(directories.cbegin(), directories.cend(),
+ std::back_inserter(pathsToBeRemoved), pred);
+ if (!pathsToBeRemoved.isEmpty()) {
+ q->removePaths(pathsToBeRemoved);
+ temporarilyRemovedPaths.insert(path.at(0), pathsToBeRemoved);
+ }
+}
+
+void QFileSystemWatcherPrivate::_q_winDriveLockForRemovalFailed(const QString &path)
+{
+ // Windows: Request to lock a (removable/USB) drive failed (blocked by other
+ // application), restore the watched paths.
+ Q_Q(QFileSystemWatcher);
+ if (!path.isEmpty()) {
+ const auto it = temporarilyRemovedPaths.find(path.at(0));
+ if (it != temporarilyRemovedPaths.end()) {
+ q->addPaths(it.value());
+ temporarilyRemovedPaths.erase(it);
+ }
+ }
+}
+void QFileSystemWatcherPrivate::_q_winDriveRemoved(const QString &path)
+{
+ // Windows: Drive finally removed, clear out paths stored in lock request.
+ if (!path.isEmpty())
+ temporarilyRemovedPaths.remove(path.at(0));
+}
+#endif // Q_OS_WIN && !Q_OS_WINRT
/*!
\class QFileSystemWatcher
diff --git a/src/corelib/io/qfilesystemwatcher_p.h b/src/corelib/io/qfilesystemwatcher_p.h
index 6c64411f92..4220c1db28 100644
--- a/src/corelib/io/qfilesystemwatcher_p.h
+++ b/src/corelib/io/qfilesystemwatcher_p.h
@@ -58,6 +58,7 @@
#include <private/qobject_p.h>
#include <QtCore/qstringlist.h>
+#include <QtCore/qhash.h>
QT_BEGIN_NAMESPACE
@@ -106,6 +107,15 @@ public:
// private slots
void _q_fileChanged(const QString &path, bool removed);
void _q_directoryChanged(const QString &path, bool removed);
+
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+ void _q_winDriveLockForRemoval(const QString &);
+ void _q_winDriveLockForRemovalFailed(const QString &);
+ void _q_winDriveRemoved(const QString &);
+
+private:
+ QHash<QChar, QStringList> temporarilyRemovedPaths;
+#endif // Q_OS_WIN && !Q_OS_WINRT
};
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index be56d8dd1d..c385a82fc5 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -52,6 +52,16 @@
#include <qt_windows.h>
+#ifndef Q_OS_WINRT
+# include <qabstractnativeeventfilter.h>
+# include <qcoreapplication.h>
+# include <qdir.h>
+# include <private/qeventdispatcher_win_p.h>
+# include <dbt.h>
+# include <algorithm>
+# include <vector>
+#endif // !Q_OS_WINRT
+
QT_BEGIN_NAMESPACE
// #define WINQFSW_DEBUG
@@ -61,11 +71,275 @@ QT_BEGIN_NAMESPACE
# define DEBUG if (false) qDebug
#endif
+#ifndef Q_OS_WINRT
+///////////
+// QWindowsRemovableDriveListener
+// Listen for the various WM_DEVICECHANGE message indicating drive addition/removal
+// requests and removals.
+///////////
+class QWindowsRemovableDriveListener : public QObject, public QAbstractNativeEventFilter
+{
+ Q_OBJECT
+public:
+ // Device UUids as declared in ioevent.h (GUID_IO_VOLUME_LOCK, ...)
+ enum VolumeUuid { UnknownUuid, UuidIoVolumeLock, UuidIoVolumeLockFailed,
+ UuidIoVolumeUnlock, UuidIoMediaRemoval };
+
+ struct RemovableDriveEntry {
+ HDEVNOTIFY devNotify;
+ wchar_t drive;
+ };
+
+ explicit QWindowsRemovableDriveListener(QObject *parent = nullptr);
+ ~QWindowsRemovableDriveListener();
+
+ // Call from QFileSystemWatcher::addPaths() to set up notifications on drives
+ void addPath(const QString &path);
+
+ bool nativeEventFilter(const QByteArray &, void *messageIn, long *) override;
+
+signals:
+ void driveAdded();
+ void driveRemoved(const QString &);
+ void driveLockForRemoval(const QString &);
+ void driveLockForRemovalFailed(const QString &);
+
+private:
+ static VolumeUuid volumeUuid(const UUID &needle);
+ void handleDbtCustomEvent(const MSG *msg);
+ void handleDbtDriveArrivalRemoval(const MSG *msg);
+
+ std::vector<RemovableDriveEntry> m_removableDrives;
+ quintptr m_lastMessageHash;
+};
+
+static inline QEventDispatcherWin32 *winEventDispatcher()
+{
+ return static_cast<QEventDispatcherWin32 *>(QCoreApplication::instance()->eventDispatcher());
+}
+
+QWindowsRemovableDriveListener::QWindowsRemovableDriveListener(QObject *parent)
+ : QObject(parent)
+ , m_lastMessageHash(0)
+{
+ winEventDispatcher()->installNativeEventFilter(this);
+}
+
+static void stopDeviceNotification(QWindowsRemovableDriveListener::RemovableDriveEntry &e)
+{
+ UnregisterDeviceNotification(e.devNotify);
+ e.devNotify = 0;
+}
+
+template <class Iterator> // Search sequence of RemovableDriveEntry for HDEVNOTIFY.
+static inline Iterator findByHDevNotify(Iterator i1, Iterator i2, HDEVNOTIFY hdevnotify)
+{
+ return std::find_if(i1, i2,
+ [hdevnotify] (const QWindowsRemovableDriveListener::RemovableDriveEntry &e) { return e.devNotify == hdevnotify; });
+}
+
+QWindowsRemovableDriveListener::~QWindowsRemovableDriveListener()
+{
+ std::for_each(m_removableDrives.begin(), m_removableDrives.end(), stopDeviceNotification);
+}
+
+static QString pathFromEntry(const QWindowsRemovableDriveListener::RemovableDriveEntry &re)
+{
+ QString path = QStringLiteral("A:/");
+ path[0] = QChar::fromLatin1(re.drive);
+ return path;
+}
+
+// Handle WM_DEVICECHANGE+DBT_CUSTOMEVENT, which is sent based on the registration
+// on the volume handle with QEventDispatcherWin32's message window in the class.
+// Capture the GUID_IO_VOLUME_LOCK indicating the drive is to be removed.
+QWindowsRemovableDriveListener::VolumeUuid QWindowsRemovableDriveListener::volumeUuid(const UUID &needle)
+{
+ static const struct VolumeUuidMapping // UUIDs from IoEvent.h (missing in MinGW)
+ {
+ VolumeUuid v;
+ UUID uuid;
+ } mapping[] = {
+ { UuidIoVolumeLock, // GUID_IO_VOLUME_LOCK
+ {0x50708874, 0xc9af, 0x11d1, {0x8f, 0xef, 0x0, 0xa0, 0xc9, 0xa0, 0x6d, 0x32}} },
+ { UuidIoVolumeLockFailed, // GUID_IO_VOLUME_LOCK_FAILED
+ {0xae2eed10, 0x0ba8, 0x11d2, {0x8f, 0xfb, 0x0, 0xa0, 0xc9, 0xa0, 0x6d, 0x32}} },
+ { UuidIoVolumeUnlock, // GUID_IO_VOLUME_UNLOCK
+ {0x9a8c3d68, 0xd0cb, 0x11d1, {0x8f, 0xef, 0x0, 0xa0, 0xc9, 0xa0, 0x6d, 0x32}} },
+ { UuidIoMediaRemoval, // GUID_IO_MEDIA_REMOVAL
+ {0xd07433c1, 0xa98e, 0x11d2, {0x91, 0x7a, 0x0, 0xa0, 0xc9, 0x06, 0x8f, 0xf3}} }
+ };
+
+ static const VolumeUuidMapping *end = mapping + sizeof(mapping) / sizeof(mapping[0]);
+ const VolumeUuidMapping *m =
+ std::find_if(mapping, end, [&needle] (const VolumeUuidMapping &m) { return IsEqualGUID(m.uuid, needle); });
+ return m != end ? m->v : UnknownUuid;
+}
+
+inline void QWindowsRemovableDriveListener::handleDbtCustomEvent(const MSG *msg)
+{
+ const DEV_BROADCAST_HDR *broadcastHeader = reinterpret_cast<const DEV_BROADCAST_HDR *>(msg->lParam);
+ if (broadcastHeader->dbch_devicetype != DBT_DEVTYP_HANDLE)
+ return;
+ const DEV_BROADCAST_HANDLE *broadcastHandle = reinterpret_cast<const DEV_BROADCAST_HANDLE *>(broadcastHeader);
+ const auto it = findByHDevNotify(m_removableDrives.cbegin(), m_removableDrives.cend(),
+ broadcastHandle->dbch_hdevnotify);
+ if (it == m_removableDrives.cend())
+ return;
+ switch (volumeUuid(broadcastHandle->dbch_eventguid)) {
+ case UuidIoVolumeLock: // Received for removable USB media
+ emit driveLockForRemoval(pathFromEntry(*it));
+ break;
+ case UuidIoVolumeLockFailed:
+ emit driveLockForRemovalFailed(pathFromEntry(*it));
+ break;
+ case UuidIoVolumeUnlock:
+ break;
+ case UuidIoMediaRemoval: // Received for optical drives
+ break;
+ default:
+ break;
+ }
+}
+
+// Handle WM_DEVICECHANGE+DBT_DEVICEARRIVAL/DBT_DEVICEREMOVECOMPLETE which are
+// sent to all top level windows and cannot be registered for (that is, their
+// triggering depends on top level windows being present)
+inline void QWindowsRemovableDriveListener::handleDbtDriveArrivalRemoval(const MSG *msg)
+{
+ const DEV_BROADCAST_HDR *broadcastHeader = reinterpret_cast<const DEV_BROADCAST_HDR *>(msg->lParam);
+ switch (broadcastHeader->dbch_devicetype) {
+ case DBT_DEVTYP_HANDLE: // WM_DEVICECHANGE/DBT_DEVTYP_HANDLE is sent for our registered drives.
+ if (msg->wParam == DBT_DEVICEREMOVECOMPLETE) {
+ const DEV_BROADCAST_HANDLE *broadcastHandle = reinterpret_cast<const DEV_BROADCAST_HANDLE *>(broadcastHeader);
+ const auto it = findByHDevNotify(m_removableDrives.begin(), m_removableDrives.end(),
+ broadcastHandle->dbch_hdevnotify);
+ // Emit for removable USB drives we were registered for.
+ if (it != m_removableDrives.end()) {
+ emit driveRemoved(pathFromEntry(*it));
+ stopDeviceNotification(*it);
+ m_removableDrives.erase(it);
+ }
+ }
+ break;
+ case DBT_DEVTYP_VOLUME: {
+ const DEV_BROADCAST_VOLUME *broadcastVolume = reinterpret_cast<const DEV_BROADCAST_VOLUME *>(broadcastHeader);
+ // WM_DEVICECHANGE/DBT_DEVTYP_VOLUME messages are sent to all toplevel windows. Compare a hash value to ensure
+ // it is handled only once.
+ const quintptr newHash = reinterpret_cast<quintptr>(broadcastVolume) + msg->wParam
+ + quintptr(broadcastVolume->dbcv_flags) + quintptr(broadcastVolume->dbcv_unitmask);
+ if (newHash == m_lastMessageHash)
+ return;
+ m_lastMessageHash = newHash;
+ // Check for DBTF_MEDIA (inserted/Removed Optical drives). Ignore for now.
+ if (broadcastVolume->dbcv_flags & DBTF_MEDIA)
+ return;
+ // Continue with plugged in USB media where dbcv_flags=0.
+ switch (msg->wParam) {
+ case DBT_DEVICEARRIVAL:
+ emit driveAdded();
+ break;
+ case DBT_DEVICEREMOVECOMPLETE: // handled by DBT_DEVTYP_HANDLE above
+ break;
+ }
+ }
+ break;
+ }
+}
+
+bool QWindowsRemovableDriveListener::nativeEventFilter(const QByteArray &, void *messageIn, long *)
+{
+ const MSG *msg = reinterpret_cast<const MSG *>(messageIn);
+ if (msg->message == WM_DEVICECHANGE) {
+ switch (msg->wParam) {
+ case DBT_CUSTOMEVENT:
+ handleDbtCustomEvent(msg);
+ break;
+ case DBT_DEVICEARRIVAL:
+ case DBT_DEVICEREMOVECOMPLETE:
+ handleDbtDriveArrivalRemoval(msg);
+ break;
+ }
+ }
+ return false;
+}
+
+// Set up listening for WM_DEVICECHANGE+DBT_CUSTOMEVENT for a removable drive path,
+void QWindowsRemovableDriveListener::addPath(const QString &p)
+{
+ const wchar_t drive = p.size() >= 2 && p.at(0).isLetter() && p.at(1) == QLatin1Char(':')
+ ? wchar_t(p.at(0).toUpper().unicode()) : L'\0';
+ if (!drive)
+ return;
+ // Already listening?
+ if (std::any_of(m_removableDrives.cbegin(), m_removableDrives.cend(),
+ [drive](const RemovableDriveEntry &e) { return e.drive == drive; })) {
+ return;
+ }
+
+ wchar_t devicePath[8] = L"\\\\.\\A:\\";
+ devicePath[4] = drive;
+ RemovableDriveEntry re;
+ re.drive = drive;
+ if (GetDriveTypeW(devicePath + 4) != DRIVE_REMOVABLE)
+ return;
+ const HANDLE volumeHandle =
+ CreateFile(devicePath, FILE_READ_ATTRIBUTES,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 0,
+ OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, // Volume requires BACKUP_SEMANTICS
+ 0);
+ if (volumeHandle == INVALID_HANDLE_VALUE) {
+ qErrnoWarning("CreateFile %s failed.",
+ qPrintable(QString::fromWCharArray(devicePath)));
+ return;
+ }
+
+ DEV_BROADCAST_HANDLE notify;
+ ZeroMemory(&notify, sizeof(notify));
+ notify.dbch_size = sizeof(notify);
+ notify.dbch_devicetype = DBT_DEVTYP_HANDLE;
+ notify.dbch_handle = volumeHandle;
+ re.devNotify = RegisterDeviceNotification(winEventDispatcher()->internalHwnd(),
+ &notify, DEVICE_NOTIFY_WINDOW_HANDLE);
+ // Empirically found: The notifications also work when the handle is immediately
+ // closed. Do it here to avoid having to close/reopen in lock message handling.
+ CloseHandle(volumeHandle);
+ if (!re.devNotify) {
+ qErrnoWarning("RegisterDeviceNotification %s failed.",
+ qPrintable(QString::fromWCharArray(devicePath)));
+ return;
+ }
+
+ m_removableDrives.push_back(re);
+}
+#endif // !Q_OS_WINRT
+
+///////////
+// QWindowsFileSystemWatcherEngine
+///////////
QWindowsFileSystemWatcherEngine::Handle::Handle()
: handle(INVALID_HANDLE_VALUE), flags(0u)
{
}
+QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(QObject *parent)
+ : QFileSystemWatcherEngine(parent)
+#ifndef Q_OS_WINRT
+ , m_driveListener(new QWindowsRemovableDriveListener(this))
+#endif
+{
+#ifndef Q_OS_WINRT
+ parent->setProperty("_q_driveListener",
+ QVariant::fromValue(static_cast<QObject *>(m_driveListener)));
+ QObject::connect(m_driveListener, &QWindowsRemovableDriveListener::driveLockForRemoval,
+ this, &QWindowsFileSystemWatcherEngine::driveLockForRemoval);
+ QObject::connect(m_driveListener, &QWindowsRemovableDriveListener::driveLockForRemovalFailed,
+ this, &QWindowsFileSystemWatcherEngine::driveLockForRemovalFailed);
+ QObject::connect(m_driveListener, &QWindowsRemovableDriveListener::driveRemoved,
+ this, &QWindowsFileSystemWatcherEngine::driveRemoved);
+#endif // !Q_OS_WINRT
+}
+
QWindowsFileSystemWatcherEngine::~QWindowsFileSystemWatcherEngine()
{
for (auto *thread : qAsConst(threads))
@@ -210,6 +484,13 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
}
}
}
+
+#ifndef Q_OS_WINRT
+ for (const QString &path : paths) {
+ if (!p.contains(path))
+ m_driveListener->addPath(path);
+ }
+#endif // !Q_OS_WINRT
return p;
}
@@ -439,4 +720,9 @@ void QWindowsFileSystemWatcherEngineThread::wakeup()
}
QT_END_NAMESPACE
+
+#ifndef Q_OS_WINRT
+# include "qfilesystemwatcher_win.moc"
+#endif
+
#endif // QT_NO_FILESYSTEMWATCHER
diff --git a/src/corelib/io/qfilesystemwatcher_win_p.h b/src/corelib/io/qfilesystemwatcher_win_p.h
index e8f5c49dec..51c7082483 100644
--- a/src/corelib/io/qfilesystemwatcher_win_p.h
+++ b/src/corelib/io/qfilesystemwatcher_win_p.h
@@ -66,6 +66,7 @@
QT_BEGIN_NAMESPACE
class QWindowsFileSystemWatcherEngineThread;
+class QWindowsRemovableDriveListener;
// Even though QWindowsFileSystemWatcherEngine is derived of QThread
// via QFileSystemWatcher, it does not start a thread.
@@ -75,9 +76,7 @@ class QWindowsFileSystemWatcherEngine : public QFileSystemWatcherEngine
{
Q_OBJECT
public:
- inline QWindowsFileSystemWatcherEngine(QObject *parent)
- : QFileSystemWatcherEngine(parent)
- { }
+ explicit QWindowsFileSystemWatcherEngine(QObject *parent);
~QWindowsFileSystemWatcherEngine();
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
@@ -121,9 +120,17 @@ public:
|| lastModified != fileInfo.lastModified());
}
};
+
+signals:
+ void driveLockForRemoval(const QString &);
+ void driveLockForRemovalFailed(const QString &);
+ void driveRemoved(const QString &);
+
private:
QList<QWindowsFileSystemWatcherEngineThread *> threads;
-
+#ifndef Q_OS_WINRT
+ QWindowsRemovableDriveListener *m_driveListener;
+#endif
};
class QFileSystemWatcherPathKey : public QString
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 47108d057b..675b375b22 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -136,7 +136,18 @@ Q_DECLARE_TYPEINFO(QConfFileCustomFormat, Q_MOVABLE_TYPE);
typedef QHash<QString, QConfFile *> ConfFileHash;
typedef QCache<QString, QConfFile> ConfFileCache;
-typedef QHash<int, QString> PathHash;
+namespace {
+ struct Path
+ {
+ // Note: Defining constructors explicitly because of buggy C++11
+ // implementation in MSVC (uniform initialization).
+ Path() {}
+ Path(const QString & p, bool ud) : path(p), userDefined(ud) {}
+ QString path;
+ bool userDefined; //!< true - user defined, overridden by setPath
+ };
+}
+typedef QHash<int, Path> PathHash;
typedef QVector<QConfFileCustomFormat> CustomFormatVector;
Q_GLOBAL_STATIC(ConfFileHash, usedHashFunc)
@@ -228,7 +239,7 @@ void QConfFile::clearCache()
// QSettingsPrivate
QSettingsPrivate::QSettingsPrivate(QSettings::Format format)
- : format(format), scope(QSettings::UserScope /* nothing better to put */), iniCodec(0), spec(0), fallbacks(true),
+ : format(format), scope(QSettings::UserScope /* nothing better to put */), iniCodec(0), fallbacks(true),
pendingChanges(false), status(QSettings::NoError)
{
}
@@ -236,7 +247,7 @@ QSettingsPrivate::QSettingsPrivate(QSettings::Format format)
QSettingsPrivate::QSettingsPrivate(QSettings::Format format, QSettings::Scope scope,
const QString &organization, const QString &application)
: format(format), scope(scope), organizationName(organization), applicationName(application),
- iniCodec(0), spec(0), fallbacks(true), pendingChanges(false), status(QSettings::NoError)
+ iniCodec(0), fallbacks(true), pendingChanges(false), status(QSettings::NoError)
{
}
@@ -948,7 +959,7 @@ void QConfFileSettingsPrivate::initFormat()
void QConfFileSettingsPrivate::initAccess()
{
- if (confFiles[spec]) {
+ if (!confFiles.isEmpty()) {
if (format > QSettings::IniFormat) {
if (!readFunc)
setStatus(QSettings::AccessError);
@@ -1069,22 +1080,22 @@ static void initDefaultPaths(QMutexLocker *locker)
*/
#ifdef Q_OS_WIN
pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope),
- windowsConfigPath(CSIDL_APPDATA) + QDir::separator());
+ Path(windowsConfigPath(CSIDL_APPDATA) + QDir::separator(), false));
pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope),
- windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator());
+ Path(windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator(), false));
#else
const QString userPath = make_user_path();
- pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), userPath);
- pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), systemPath);
+ pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), Path(userPath, false));
+ pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), Path(systemPath, false));
#ifndef Q_OS_MAC
- pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::UserScope), userPath);
- pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::SystemScope), systemPath);
+ pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::UserScope), Path(userPath, false));
+ pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::SystemScope), Path(systemPath, false));
#endif
#endif // Q_OS_WIN
}
}
-static QString getPath(QSettings::Format format, QSettings::Scope scope)
+static Path getPath(QSettings::Format format, QSettings::Scope scope)
{
Q_ASSERT((int)QSettings::NativeFormat == 0);
Q_ASSERT((int)QSettings::IniFormat == 1);
@@ -1094,14 +1105,23 @@ static QString getPath(QSettings::Format format, QSettings::Scope scope)
if (pathHash->isEmpty())
initDefaultPaths(&locker);
- QString result = pathHash->value(pathHashKey(format, scope));
- if (!result.isEmpty())
+ Path result = pathHash->value(pathHashKey(format, scope));
+ if (!result.path.isEmpty())
return result;
// fall back on INI path
return pathHash->value(pathHashKey(QSettings::IniFormat, scope));
}
+#if defined(QT_BUILD_INTERNAL) && defined(Q_XDG_PLATFORM) && !defined(QT_NO_STANDARDPATHS)
+// Note: Suitable only for autotests.
+void Q_AUTOTEST_EXPORT clearDefaultPaths()
+{
+ QMutexLocker locker(&settingsGlobalMutex);
+ pathHashFunc()->clear();
+}
+#endif // QT_BUILD_INTERNAL && Q_XDG_PLATFORM && !QT_NO_STANDARDPATHS
+
QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
QSettings::Scope scope,
const QString &organization,
@@ -1109,7 +1129,6 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
: QSettingsPrivate(format, scope, organization, application),
nextPosition(0x40000000) // big positive number
{
- int i;
initFormat();
QString org = organization;
@@ -1122,22 +1141,43 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
QString orgFile = org + extension;
if (scope == QSettings::UserScope) {
- QString userPath = getPath(format, QSettings::UserScope);
+ Path userPath = getPath(format, QSettings::UserScope);
if (!application.isEmpty())
- confFiles[F_User | F_Application].reset(QConfFile::fromName(userPath + appFile, true));
- confFiles[F_User | F_Organization].reset(QConfFile::fromName(userPath + orgFile, true));
+ confFiles.append(QConfFile::fromName(userPath.path + appFile, true));
+ confFiles.append(QConfFile::fromName(userPath.path + orgFile, true));
}
- QString systemPath = getPath(format, QSettings::SystemScope);
- if (!application.isEmpty())
- confFiles[F_System | F_Application].reset(QConfFile::fromName(systemPath + appFile, false));
- confFiles[F_System | F_Organization].reset(QConfFile::fromName(systemPath + orgFile, false));
-
- for (i = 0; i < NumConfFiles; ++i) {
- if (confFiles[i]) {
- spec = i;
- break;
+ Path systemPath = getPath(format, QSettings::SystemScope);
+#if defined(Q_XDG_PLATFORM) && !defined(QT_NO_STANDARDPATHS)
+ // check if the systemPath wasn't overridden by QSettings::setPath()
+ if (!systemPath.userDefined) {
+ // Note: We can't use QStandardPaths::locateAll() as we need all the
+ // possible files (not just the existing ones) and there is no way
+ // to exclude user specific (XDG_CONFIG_HOME) directory from the search.
+ QStringList dirs = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation);
+ // remove the QStandardLocation::writableLocation() (XDG_CONFIG_HOME)
+ if (!dirs.isEmpty())
+ dirs.takeFirst();
+ QStringList paths;
+ if (!application.isEmpty()) {
+ paths.reserve(dirs.size() * 2);
+ for (const auto &dir : qAsConst(dirs))
+ paths.append(dir + QLatin1Char('/') + appFile);
+ } else {
+ paths.reserve(dirs.size());
}
+ for (const auto &dir : qAsConst(dirs))
+ paths.append(dir + QLatin1Char('/') + orgFile);
+
+ // Note: No check for existence of files is done intentionaly.
+ for (const auto &path : qAsConst(paths))
+ confFiles.append(QConfFile::fromName(path, false));
+ } else
+#endif // Q_XDG_PLATFORM && !QT_NO_STANDARDPATHS
+ {
+ if (!application.isEmpty())
+ confFiles.append(QConfFile::fromName(systemPath.path + appFile, false));
+ confFiles.append(QConfFile::fromName(systemPath.path + orgFile, false));
}
initAccess();
@@ -1150,7 +1190,7 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(const QString &fileName,
{
initFormat();
- confFiles[0].reset(QConfFile::fromName(fileName, true));
+ confFiles.append(QConfFile::fromName(fileName, true));
initAccess();
}
@@ -1161,40 +1201,39 @@ QConfFileSettingsPrivate::~QConfFileSettingsPrivate()
ConfFileHash *usedHash = usedHashFunc();
ConfFileCache *unusedCache = unusedCacheFunc();
- for (int i = 0; i < NumConfFiles; ++i) {
- if (confFiles[i] && !confFiles[i]->ref.deref()) {
- if (confFiles[i]->size == 0) {
- delete confFiles[i].take();
+ for (auto conf_file : qAsConst(confFiles)) {
+ if (!conf_file->ref.deref()) {
+ if (conf_file->size == 0) {
+ delete conf_file;
} else {
if (usedHash)
- usedHash->remove(confFiles[i]->name);
+ usedHash->remove(conf_file->name);
if (unusedCache) {
QT_TRY {
// compute a better size?
- unusedCache->insert(confFiles[i]->name, confFiles[i].data(),
- 10 + (confFiles[i]->originalKeys.size() / 4));
- confFiles[i].take();
+ unusedCache->insert(conf_file->name, conf_file,
+ 10 + (conf_file->originalKeys.size() / 4));
} QT_CATCH(...) {
// out of memory. Do not cache the file.
- delete confFiles[i].take();
+ delete conf_file;
}
} else {
// unusedCache is gone - delete the entry to prevent a memory leak
- delete confFiles[i].take();
+ delete conf_file;
}
}
}
- // prevent the ScopedPointer to deref it again.
- confFiles[i].take();
}
}
void QConfFileSettingsPrivate::remove(const QString &key)
{
- QConfFile *confFile = confFiles[spec].data();
- if (!confFile)
+ if (confFiles.isEmpty())
return;
+ // Note: First config file is always the most specific.
+ QConfFile *confFile = confFiles.at(0);
+
QSettingsKey theKey(key, caseSensitivity);
QSettingsKey prefix(key + QLatin1Char('/'), caseSensitivity);
QMutexLocker locker(&confFile->mutex);
@@ -1218,10 +1257,12 @@ void QConfFileSettingsPrivate::remove(const QString &key)
void QConfFileSettingsPrivate::set(const QString &key, const QVariant &value)
{
- QConfFile *confFile = confFiles[spec].data();
- if (!confFile)
+ if (confFiles.isEmpty())
return;
+ // Note: First config file is always the most specific.
+ QConfFile *confFile = confFiles.at(0);
+
QSettingsKey theKey(key, caseSensitivity, nextPosition++);
QMutexLocker locker(&confFile->mutex);
confFile->removedKeys.remove(theKey);
@@ -1234,29 +1275,27 @@ bool QConfFileSettingsPrivate::get(const QString &key, QVariant *value) const
ParsedSettingsMap::const_iterator j;
bool found = false;
- for (int i = 0; i < NumConfFiles; ++i) {
- if (QConfFile *confFile = confFiles[i].data()) {
- QMutexLocker locker(&confFile->mutex);
+ for (auto confFile : qAsConst(confFiles)) {
+ QMutexLocker locker(&confFile->mutex);
- if (!confFile->addedKeys.isEmpty()) {
- j = confFile->addedKeys.constFind(theKey);
- found = (j != confFile->addedKeys.constEnd());
- }
- if (!found) {
- ensureSectionParsed(confFile, theKey);
- j = confFile->originalKeys.constFind(theKey);
- found = (j != confFile->originalKeys.constEnd()
- && !confFile->removedKeys.contains(theKey));
- }
+ if (!confFile->addedKeys.isEmpty()) {
+ j = confFile->addedKeys.constFind(theKey);
+ found = (j != confFile->addedKeys.constEnd());
+ }
+ if (!found) {
+ ensureSectionParsed(confFile, theKey);
+ j = confFile->originalKeys.constFind(theKey);
+ found = (j != confFile->originalKeys.constEnd()
+ && !confFile->removedKeys.contains(theKey));
+ }
- if (found && value)
- *value = *j;
+ if (found && value)
+ *value = *j;
- if (found)
- return true;
- if (!fallbacks)
- break;
- }
+ if (found)
+ return true;
+ if (!fallbacks)
+ break;
}
return false;
}
@@ -1269,34 +1308,31 @@ QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec
QSettingsKey thePrefix(prefix, caseSensitivity);
int startPos = prefix.size();
- for (int i = 0; i < NumConfFiles; ++i) {
- if (QConfFile *confFile = confFiles[i].data()) {
- QMutexLocker locker(&confFile->mutex);
+ for (auto confFile : qAsConst(confFiles)) {
+ QMutexLocker locker(&confFile->mutex);
- if (thePrefix.isEmpty()) {
- ensureAllSectionsParsed(confFile);
- } else {
- ensureSectionParsed(confFile, thePrefix);
- }
-
- j = const_cast<const ParsedSettingsMap *>(
- &confFile->originalKeys)->lowerBound( thePrefix);
- while (j != confFile->originalKeys.constEnd() && j.key().startsWith(thePrefix)) {
- if (!confFile->removedKeys.contains(j.key()))
- processChild(j.key().originalCaseKey().midRef(startPos), spec, result);
- ++j;
- }
+ if (thePrefix.isEmpty())
+ ensureAllSectionsParsed(confFile);
+ else
+ ensureSectionParsed(confFile, thePrefix);
- j = const_cast<const ParsedSettingsMap *>(
- &confFile->addedKeys)->lowerBound(thePrefix);
- while (j != confFile->addedKeys.constEnd() && j.key().startsWith(thePrefix)) {
+ j = const_cast<const ParsedSettingsMap *>(
+ &confFile->originalKeys)->lowerBound( thePrefix);
+ while (j != confFile->originalKeys.constEnd() && j.key().startsWith(thePrefix)) {
+ if (!confFile->removedKeys.contains(j.key()))
processChild(j.key().originalCaseKey().midRef(startPos), spec, result);
- ++j;
- }
+ ++j;
+ }
- if (!fallbacks)
- break;
+ j = const_cast<const ParsedSettingsMap *>(
+ &confFile->addedKeys)->lowerBound(thePrefix);
+ while (j != confFile->addedKeys.constEnd() && j.key().startsWith(thePrefix)) {
+ processChild(j.key().originalCaseKey().midRef(startPos), spec, result);
+ ++j;
}
+
+ if (!fallbacks)
+ break;
}
std::sort(result.begin(), result.end());
result.erase(std::unique(result.begin(), result.end()),
@@ -1306,10 +1342,12 @@ QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec
void QConfFileSettingsPrivate::clear()
{
- QConfFile *confFile = confFiles[spec].data();
- if (!confFile)
+ if (confFiles.isEmpty())
return;
+ // Note: First config file is always the most specific.
+ QConfFile *confFile = confFiles.at(0);
+
QMutexLocker locker(&confFile->mutex);
ensureAllSectionsParsed(confFile);
confFile->addedKeys.clear();
@@ -1321,12 +1359,9 @@ void QConfFileSettingsPrivate::sync()
// people probably won't be checking the status a whole lot, so in case of
// error we just try to go on and make the best of it
- for (int i = 0; i < NumConfFiles; ++i) {
- QConfFile *confFile = confFiles[i].data();
- if (confFile) {
- QMutexLocker locker(&confFile->mutex);
- syncConfFile(i);
- }
+ for (auto confFile : qAsConst(confFiles)) {
+ QMutexLocker locker(&confFile->mutex);
+ syncConfFile(confFile);
}
}
@@ -1337,10 +1372,11 @@ void QConfFileSettingsPrivate::flush()
QString QConfFileSettingsPrivate::fileName() const
{
- QConfFile *confFile = confFiles[spec].data();
- if (!confFile)
+ if (confFiles.isEmpty())
return QString();
- return confFile->name;
+
+ // Note: First config file is always the most specific.
+ return confFiles.at(0)->name;
}
bool QConfFileSettingsPrivate::isWritable() const
@@ -1348,16 +1384,14 @@ bool QConfFileSettingsPrivate::isWritable() const
if (format > QSettings::IniFormat && !writeFunc)
return false;
- QConfFile *confFile = confFiles[spec].data();
- if (!confFile)
+ if (confFiles.isEmpty())
return false;
- return confFile->isWritable();
+ return confFiles.at(0)->isWritable();
}
-void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
+void QConfFileSettingsPrivate::syncConfFile(QConfFile *confFile)
{
- QConfFile *confFile = confFiles[confFileNo].data();
bool readOnly = confFile->addedKeys.isEmpty() && confFile->removedKeys.isEmpty();
/*
@@ -2187,9 +2221,10 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
\list 1
\li \c{$HOME/.config/MySoft/Star Runner.conf} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft/Star Runner.conf})
\li \c{$HOME/.config/MySoft.conf} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft.conf})
- \li \c{/etc/xdg/MySoft/Star Runner.conf}
- \li \c{/etc/xdg/MySoft.conf}
+ \li for each directory <dir> in $XDG_CONFIG_DIRS: \c{<dir>/MySoft/Star Runner.conf}
+ \li for each directory <dir> in $XDG_CONFIG_DIRS: \c{<dir>/MySoft.conf}
\endlist
+ \note If XDG_CONFIG_DIRS is unset, the default value of \c{/etc/xdg} is used.
On \macos versions 10.2 and 10.3, these files are used by
default:
@@ -2224,9 +2259,10 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
\list 1
\li \c{$HOME/.config/MySoft/Star Runner.ini} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft/Star Runner.ini})
\li \c{$HOME/.config/MySoft.ini} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft.ini})
- \li \c{/etc/xdg/MySoft/Star Runner.ini}
- \li \c{/etc/xdg/MySoft.ini}
+ \li for each directory <dir> in $XDG_CONFIG_DIRS: \c{<dir>/MySoft/Star Runner.ini}
+ \li for each directory <dir> in $XDG_CONFIG_DIRS: \c{<dir>/MySoft.ini}
\endlist
+ \note If XDG_CONFIG_DIRS is unset, the default value of \c{/etc/xdg} is used.
On Windows, the following files are used:
@@ -3378,7 +3414,7 @@ void QSettings::setPath(Format format, Scope scope, const QString &path)
PathHash *pathHash = pathHashFunc();
if (pathHash->isEmpty())
initDefaultPaths(&locker);
- pathHash->insert(pathHashKey(format, scope), path + QDir::separator());
+ pathHash->insert(pathHashKey(format, scope), Path(path + QDir::separator(), true));
}
/*!
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index b79abfb874..dcaefd1613 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -422,20 +422,15 @@ QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString &
javaPackageName.prepend(QLatin1String("com."));
suiteId = javaPackageName;
- if (scope == QSettings::SystemScope)
- spec |= F_System;
-
- if (application.isEmpty()) {
- spec |= F_Organization;
- } else {
+ if (!application.isEmpty()) {
javaPackageName += QLatin1Char('.');
javaPackageName += application;
applicationId = javaPackageName;
}
numDomains = 0;
- for (int i = (spec & F_System) ? 1 : 0; i < 2; ++i) {
- for (int j = (spec & F_Organization) ? 1 : 0; j < 3; ++j) {
+ for (int i = (scope == QSettings::SystemScope) ? 1 : 0; i < 2; ++i) {
+ for (int j = (application.isEmpty()) ? 1 : 0; j < 3; ++j) {
SearchDomain &domain = domains[numDomains++];
domain.userName = (i == 0) ? kCFPreferencesCurrentUser : kCFPreferencesAnyUser;
if (j == 0)
@@ -576,7 +571,7 @@ bool QMacSettingsPrivate::isWritable() const
QString QMacSettingsPrivate::fileName() const
{
QString result;
- if ((spec & F_System) == 0)
+ if (scope == QSettings::UserScope)
result = QDir::homePath();
result += QLatin1String("/Library/Preferences/");
result += QString::fromCFString(domains[0].applicationOrSuiteId);
diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h
index e6d3413bab..639605d8c4 100644
--- a/src/corelib/io/qsettings_p.h
+++ b/src/corelib/io/qsettings_p.h
@@ -236,19 +236,6 @@ public:
QTextCodec *codec);
static QStringList splitArgs(const QString &s, int idx);
- /*
- The numeric values of these enums define their search order. For example,
- F_User | F_Organization is searched before F_System | F_Application,
- because their values are respectively 1 and 2.
- */
- enum {
- F_Application = 0x0,
- F_Organization = 0x1,
- F_User = 0x0,
- F_System = 0x2,
- NumConfFiles = 4
- };
-
QSettings::Format format;
QSettings::Scope scope;
QString organizationName;
@@ -258,7 +245,6 @@ public:
protected:
QStack<QSettingsGroup> groupStack;
QString groupPrefix;
- int spec;
bool fallbacks;
bool pendingChanges;
mutable QSettings::Status status;
@@ -293,7 +279,7 @@ public:
private:
void initFormat();
void initAccess();
- void syncConfFile(int confFileNo);
+ void syncConfFile(QConfFile *confFile);
bool writeIniFile(QIODevice &device, const ParsedSettingsMap &map);
#ifdef Q_OS_MAC
bool readPlistFile(const QByteArray &data, ParsedSettingsMap *map) const;
@@ -302,7 +288,7 @@ private:
void ensureAllSectionsParsed(QConfFile *confFile) const;
void ensureSectionParsed(QConfFile *confFile, const QSettingsKey &key) const;
- QScopedSharedPointer<QConfFile> confFiles[NumConfFiles];
+ QVector<QConfFile *> confFiles;
QSettings::ReadFunc readFunc;
QSettings::WriteFunc writeFunc;
QString extension;
diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp
index 1c10548cbc..edcae16776 100644
--- a/src/corelib/io/qsettings_win.cpp
+++ b/src/corelib/io/qsettings_win.cpp
@@ -138,21 +138,6 @@ static void mergeKeySets(NameSet *dest, const QStringList &src)
** Wrappers for the insane windows registry API
*/
-static QString errorCodeToString(DWORD errorCode)
-{
- wchar_t *data = 0;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 0, errorCode, 0, data, 0, 0);
- QString result = QString::fromWCharArray(data);
-
- if (data != 0)
- LocalFree(data);
-
- if (result.endsWith(QLatin1Char('\n')))
- result.truncate(result.length() - 1);
-
- return result;
-}
-
// Open a key with the specified "perms".
// "access" is to explicitly use the 32- or 64-bit branch.
static HKEY openKey(HKEY parentHandle, REGSAM perms, const QString &rSubKey, REGSAM access = 0)
@@ -184,7 +169,7 @@ static HKEY createOrOpenKey(HKEY parentHandle, REGSAM perms, const QString &rSub
return resultHandle;
//qWarning("QSettings: Failed to create subkey \"%s\": %s",
- // rSubKey.toLatin1().data(), errorCodeToString(res).toLatin1().data());
+ // qPrintable(rSubKey), qPrintable(qt_error_string(int(res))));
return 0;
}
@@ -224,7 +209,7 @@ static QStringList childKeysOrGroups(HKEY parentHandle, QSettingsPrivate::ChildS
&numKeys, &maxKeySize, 0, 0, 0);
if (res != ERROR_SUCCESS) {
- qWarning("QSettings: RegQueryInfoKey() failed: %s", errorCodeToString(res).toLatin1().data());
+ qWarning("QSettings: RegQueryInfoKey() failed: %s", qPrintable(qt_error_string(int(res))));
return result;
}
@@ -258,7 +243,7 @@ static QStringList childKeysOrGroups(HKEY parentHandle, QSettingsPrivate::ChildS
item = QString::fromWCharArray((const wchar_t *)buff.constData(), l);
if (res != ERROR_SUCCESS) {
- qWarning("QSettings: RegEnumValue failed: %s", errorCodeToString(res).toLatin1().data());
+ qWarning("QSettings: RegEnumValue failed: %s", qPrintable(qt_error_string(int(res))));
continue;
}
if (item.isEmpty())
@@ -313,7 +298,7 @@ static void deleteChildGroups(HKEY parentHandle, REGSAM access = 0)
LONG res = RegDeleteKey(parentHandle, reinterpret_cast<const wchar_t *>(group.utf16()));
if (res != ERROR_SUCCESS) {
qWarning("QSettings: RegDeleteKey failed on subkey \"%s\": %s",
- group.toLatin1().data(), errorCodeToString(res).toLatin1().data());
+ qPrintable(group), qPrintable(qt_error_string(int(res))));
return;
}
}
@@ -613,7 +598,7 @@ QWinSettingsPrivate::~QWinSettingsPrivate()
DWORD res = RegDeleteKey(writeHandle(), reinterpret_cast<const wchar_t *>(emptyKey.utf16()));
if (res != ERROR_SUCCESS) {
qWarning("QSettings: Failed to delete key \"%s\": %s",
- regList.at(0).key().toLatin1().data(), errorCodeToString(res).toLatin1().data());
+ qPrintable(regList.at(0).key()), qPrintable(qt_error_string(int(res))));
}
}
@@ -652,7 +637,7 @@ void QWinSettingsPrivate::remove(const QString &uKey)
LONG res = RegDeleteValue(handle, reinterpret_cast<const wchar_t *>(group.utf16()));
if (res != ERROR_SUCCESS) {
qWarning("QSettings: RegDeleteValue failed on subkey \"%s\": %s",
- group.toLatin1().data(), errorCodeToString(res).toLatin1().data());
+ qPrintable(group), qPrintable(qt_error_string(int(res))));
}
}
} else {
@@ -660,7 +645,7 @@ void QWinSettingsPrivate::remove(const QString &uKey)
if (res != ERROR_SUCCESS) {
qWarning("QSettings: RegDeleteKey failed on key \"%s\": %s",
- rKey.toLatin1().data(), errorCodeToString(res).toLatin1().data());
+ qPrintable(rKey), qPrintable(qt_error_string(int(res))));
}
}
RegCloseKey(handle);
@@ -758,7 +743,7 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value)
deleteWriteHandleOnExit = false;
} else {
qWarning("QSettings: failed to set subkey \"%s\": %s",
- rKey.toLatin1().data(), errorCodeToString(res).toLatin1().data());
+ qPrintable(rKey), qPrintable(qt_error_string(int(res))));
setStatus(QSettings::AccessError);
}
diff --git a/src/corelib/io/qstorageinfo.cpp b/src/corelib/io/qstorageinfo.cpp
index 3773b72606..9885da1af9 100644
--- a/src/corelib/io/qstorageinfo.cpp
+++ b/src/corelib/io/qstorageinfo.cpp
@@ -260,7 +260,7 @@ QByteArray QStorageInfo::fileSystemType() const
devpath like \c /dev/sda0 for local storages. On Windows, it returns the UNC
path starting with \c \\\\?\\ for local storages (in other words, the volume GUID).
- \sa rootPath()
+ \sa rootPath(), subvolume()
*/
QByteArray QStorageInfo::device() const
{
@@ -268,6 +268,26 @@ QByteArray QStorageInfo::device() const
}
/*!
+ \since 5.8
+ Returns the subvolume name for this volume.
+
+ Some filesystem types allow multiple subvolumes inside one device, which
+ may be mounted in different paths. If the subvolume could be detected, it
+ is returned here. The format of the subvolume name is specific to each
+ filesystem type.
+
+ If this volume was not mounted from a subvolume of a larger filesystem or
+ if the subvolume could not be detected, this function returns an empty byte
+ array.
+
+ \sa device()
+*/
+QByteArray QStorageInfo::subvolume() const
+{
+ return d->subvolume;
+}
+
+/*!
Returns the human-readable name of a filesystem, usually called \c label.
Not all filesystems support this feature. In this case, the value returned by
diff --git a/src/corelib/io/qstorageinfo.h b/src/corelib/io/qstorageinfo.h
index 8941c11a16..e2d9747ceb 100644
--- a/src/corelib/io/qstorageinfo.h
+++ b/src/corelib/io/qstorageinfo.h
@@ -71,6 +71,7 @@ public:
QString rootPath() const;
QByteArray device() const;
+ QByteArray subvolume() const;
QByteArray fileSystemType() const;
QString name() const;
QString displayName() const;
@@ -100,7 +101,7 @@ inline bool operator==(const QStorageInfo &first, const QStorageInfo &second)
{
if (first.d == second.d)
return true;
- return first.device() == second.device();
+ return first.device() == second.device() && first.rootPath() == second.rootPath();
}
inline bool operator!=(const QStorageInfo &first, const QStorageInfo &second)
diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h
index a14fa8480a..ec5bb785e3 100644
--- a/src/corelib/io/qstorageinfo_p.h
+++ b/src/corelib/io/qstorageinfo_p.h
@@ -85,6 +85,7 @@ protected:
public:
QString rootPath;
QByteArray device;
+ QByteArray subvolume;
QByteArray fileSystemType;
QString name;
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index ae5c42ffd1..fcc7b8ca50 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -120,6 +120,7 @@ public:
inline QString rootPath() const;
inline QByteArray fileSystemType() const;
inline QByteArray device() const;
+ inline QByteArray options() const;
private:
#if defined(Q_OS_BSD4)
QT_STATFSBUF *stat_buf;
@@ -133,6 +134,7 @@ private:
QByteArray m_rootPath;
QByteArray m_fileSystemType;
QByteArray m_device;
+ QByteArray m_options;
#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD)
FILE *fp;
mntent mnt;
@@ -228,6 +230,11 @@ inline QByteArray QStorageIterator::device() const
return QByteArray(stat_buf[currentIndex].f_mntfromname);
}
+inline QByteArray QStorageIterator::options() const
+{
+ return QByteArray();
+}
+
#elif defined(Q_OS_SOLARIS)
static const char pathMounted[] = "/etc/mnttab";
@@ -301,6 +308,7 @@ inline bool QStorageIterator::next()
m_device = data.at(0);
m_rootPath = data.at(1);
m_fileSystemType = data.at(2);
+ m_options = data.at(3);
return true;
}
@@ -320,6 +328,11 @@ inline QByteArray QStorageIterator::device() const
return m_device;
}
+inline QByteArray QStorageIterator::options() const
+{
+ return m_options;
+}
+
#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD)
static const char pathMounted[] = "/etc/mtab";
@@ -363,6 +376,11 @@ inline QByteArray QStorageIterator::device() const
return QByteArray(mnt.mnt_fsname);
}
+inline QByteArray QStorageIterator::options() const
+{
+ return QByteArray(mnt.mnt_opts);
+}
+
#elif defined(Q_OS_HAIKU)
inline QStorageIterator::QStorageIterator()
{
@@ -420,6 +438,11 @@ inline QByteArray QStorageIterator::device() const
return m_device;
}
+inline QByteArray QStorageIterator::options() const
+{
+ return QByteArray();
+}
+
#else
inline QStorageIterator::QStorageIterator()
@@ -455,8 +478,35 @@ inline QByteArray QStorageIterator::device() const
return QByteArray();
}
+inline QByteArray QStorageIterator::options() const
+{
+ return QByteArray();
+}
+
#endif
+static QByteArray extractSubvolume(const QStorageIterator &it)
+{
+#ifdef Q_OS_LINUX
+ if (it.fileSystemType() == "btrfs") {
+ const QByteArrayList opts = it.options().split(',');
+ QByteArray id;
+ for (const QByteArray &opt : opts) {
+ static const char subvol[] = "subvol=";
+ static const char subvolid[] = "subvolid=";
+ if (opt.startsWith(subvol))
+ return std::move(opt).mid(strlen(subvol));
+ if (opt.startsWith(subvolid))
+ id = std::move(opt).mid(strlen(subvolid));
+ }
+
+ // if we didn't find the subvolume name, return the subvolume ID
+ return id;
+ }
+#endif
+ return QByteArray();
+}
+
void QStorageInfoPrivate::initRootPath()
{
rootPath = QFileInfo(rootPath).canonicalFilePath();
@@ -483,6 +533,7 @@ void QStorageInfoPrivate::initRootPath()
rootPath = mountDir;
device = it.device();
fileSystemType = fsName;
+ subvolume = extractSubvolume(it);
}
}
}
diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp
index 6e50a8513e..b2bf9fce97 100644
--- a/src/corelib/io/qtemporarydir.cpp
+++ b/src/corelib/io/qtemporarydir.cpp
@@ -305,6 +305,33 @@ QString QTemporaryDir::path() const
}
/*!
+ \since 5.9
+
+ Returns the path name of a file in the temporary directory.
+ Does \e not check if the file actually exists in the directory.
+ Redundant multiple separators or "." and ".." directories in
+ \a fileName are not removed (see QDir::cleanPath()). Absolute
+ paths are not allowed.
+*/
+QString QTemporaryDir::filePath(const QString &fileName) const
+{
+ if (QDir::isAbsolutePath(fileName)) {
+ qWarning("QTemporaryDir::filePath: Absolute paths are not allowed: %s", qUtf8Printable(fileName));
+ return QString();
+ }
+
+ if (!d_ptr->success)
+ return QString();
+
+ QString ret = d_ptr->pathOrError;
+ if (!fileName.isEmpty()) {
+ ret += QLatin1Char('/');
+ ret += fileName;
+ }
+ return ret;
+}
+
+/*!
Returns \c true if the QTemporaryDir is in auto remove
mode. Auto-remove mode will automatically delete the directory from
disk upon destruction. This makes it very easy to create your
diff --git a/src/corelib/io/qtemporarydir.h b/src/corelib/io/qtemporarydir.h
index 2e70d34ae4..3f6b70a2eb 100644
--- a/src/corelib/io/qtemporarydir.h
+++ b/src/corelib/io/qtemporarydir.h
@@ -65,6 +65,7 @@ public:
bool remove();
QString path() const;
+ QString filePath(const QString &fileName) const;
private:
QScopedPointer<QTemporaryDirPrivate> d_ptr;
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 4fdb1505ff..9b565bff9d 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -2547,6 +2547,7 @@ QTextStream &QTextStream::operator<<(double f)
}
uint flags = 0;
+ const QLocale::NumberOptions numberOptions = locale().numberOptions();
if (numberFlags() & ShowBase)
flags |= QLocaleData::ShowBase;
if (numberFlags() & ForceSign)
@@ -2555,12 +2556,18 @@ QTextStream &QTextStream::operator<<(double f)
flags |= QLocaleData::UppercaseBase;
if (numberFlags() & UppercaseDigits)
flags |= QLocaleData::CapitalEorX;
- if (numberFlags() & ForcePoint)
- flags |= QLocaleData::Alternate;
- if (locale() != QLocale::c() && !(locale().numberOptions() & QLocale::OmitGroupSeparator))
+ if (numberFlags() & ForcePoint) {
+ flags |= QLocaleData::ForcePoint;
+
+ // Only for backwards compatibility
+ flags |= QLocaleData::AddTrailingZeroes | QLocaleData::ShowBase;
+ }
+ if (locale() != QLocale::c() && !(numberOptions & QLocale::OmitGroupSeparator))
flags |= QLocaleData::ThousandsGroup;
- if (!(locale().numberOptions() & QLocale::OmitLeadingZeroInExponent))
+ if (!(numberOptions & QLocale::OmitLeadingZeroInExponent))
flags |= QLocaleData::ZeroPadExponent;
+ if (numberOptions & QLocale::IncludeTrailingZeroesAfterDot)
+ flags |= QLocaleData::AddTrailingZeroes;
const QLocaleData *dd = d->locale.d->m_data;
QString num = dd->doubleToString(f, d->params.realNumberPrecision, form, -1, flags);
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index d7e8d4847a..231afb991c 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -47,14 +47,8 @@
#include <qdebug.h>
-#if defined(Q_OS_IOS)
-#import <UIKit/UIKit.h>
-#endif
-
QT_BEGIN_NAMESPACE
-typedef qint16 (*GestaltFunction)(quint32 selector, qint32 *response);
-
// -------------------------------------------------------------------------
QDebug operator<<(QDebug dbg, const NSObject *nsObject)
@@ -87,54 +81,6 @@ QT_FOR_EACH_MUTABLE_CORE_GRAPHICS_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TY
// -------------------------------------------------------------------------
-QAppleOperatingSystemVersion qt_apple_os_version()
-{
- QAppleOperatingSystemVersion v = {0, 0, 0};
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0) || defined(Q_OS_TVOS) || defined(Q_OS_WATCHOS)
- if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) {
- NSOperatingSystemVersion osv = NSProcessInfo.processInfo.operatingSystemVersion;
- v.major = osv.majorVersion;
- v.minor = osv.minorVersion;
- v.patch = osv.patchVersion;
- return v;
- }
-#endif
- // 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:@"."];
- major = parts.count > 0 ? [[parts objectAtIndex:0] intValue] : 0;
- minor = parts.count > 1 ? [[parts objectAtIndex:1] intValue] : 0;
- patch = parts.count > 2 ? [[parts objectAtIndex:2] intValue] : 0;
- }
-#elif defined(Q_OS_OSX)
- static GestaltFunction pGestalt = 0;
- if (!pGestalt) {
- CFBundleRef b = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CoreServices"));
- pGestalt = reinterpret_cast<GestaltFunction>(CFBundleGetFunctionPointerForName(b,
- CFSTR("Gestalt")));
- }
- if (!pGestalt)
- return v;
- if (pGestalt('sys1', &major) != 0)
- return v;
- if (pGestalt('sys2', &minor) != 0)
- return v;
- if (pGestalt('sys3', &patch) != 0)
- return v;
-#endif
-#endif
- v.major = major;
- v.minor = minor;
- v.patch = patch;
- return v;
-}
-
-// -------------------------------------------------------------------------
-
QMacAutoReleasePool::QMacAutoReleasePool()
: pool([[NSAutoreleasePool alloc] init])
{
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index cb709f9d4b..d0edef33a2 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -131,12 +131,6 @@ private:
QString string;
};
-typedef struct {
- int major, minor, patch;
-} QAppleOperatingSystemVersion;
-
-QAppleOperatingSystemVersion qt_apple_os_version();
-
#ifdef Q_OS_OSX
Q_CORE_EXPORT QChar qt_mac_qtKey2CocoaKey(Qt::Key key);
Q_CORE_EXPORT Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode);
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 1a0efae2dc..75ac104155 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -42,6 +42,7 @@
#include "qcoreapplication.h"
#include <private/qsystemlibrary_p.h>
+#include "qoperatingsystemversion.h"
#include "qpair.h"
#include "qset.h"
#include "qsocketnotifier.h"
@@ -236,7 +237,7 @@ static inline UINT inputTimerMask()
// QTBUG 28513, QTBUG-29097, QTBUG-29435: QS_TOUCH, QS_POINTER became part of
// QS_INPUT in Windows Kit 8. They should not be used when running on pre-Windows 8.
#if WINVER > 0x0601
- if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8)
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8)
result &= ~(QS_TOUCH | QS_POINTER);
#endif // WINVER > 0x0601
return result;
@@ -1058,4 +1059,11 @@ void QEventDispatcherWin32::sendPostedEvents()
QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
}
+HWND QEventDispatcherWin32::internalHwnd()
+{
+ Q_D(QEventDispatcherWin32);
+ createInternalHwnd();
+ return d->internalHwnd;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index 773315c04f..227fcf89ff 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -106,6 +106,8 @@ public:
bool event(QEvent *e);
+ HWND internalHwnd();
+
protected:
QEventDispatcherWin32(QEventDispatcherWin32Private &dd, QObject *parent = 0);
virtual void sendPostedEvents();
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 63b02d2c0c..4ae886150f 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -754,30 +754,6 @@ void QMetaCallEvent::placeMetaCall(QObject *object)
\sa {Object Trees & Ownership}
*/
-/*!
- \relates QObject
-
- Returns a pointer to the object named \a name that inherits \a
- type and with a given \a parent.
-
- Returns 0 if there is no such child.
-
- \snippet code/src_corelib_kernel_qobject.cpp 0
-*/
-
-void *qt_find_obj_child(QObject *parent, const char *type, const QString &name)
-{
- QObjectList list = parent->children();
- if (list.size() == 0) return 0;
- for (int i = 0; i < list.size(); ++i) {
- QObject *obj = list.at(i);
- if (name == obj->objectName() && obj->inherits(type))
- return obj;
- }
- return 0;
-}
-
-
/*****************************************************************************
QObject member functions
*****************************************************************************/
@@ -3941,9 +3917,8 @@ QList<QByteArray> QObject::dynamicPropertyNames() const
QObject debugging output routines.
*****************************************************************************/
-static void dumpRecursive(int level, QObject *object)
+static void dumpRecursive(int level, const QObject *object)
{
-#if defined(QT_DEBUG)
if (object) {
QByteArray buf;
buf.fill(' ', level / 2 * 8);
@@ -3972,45 +3947,65 @@ static void dumpRecursive(int level, QObject *object)
dumpRecursive(level+1, children.at(i));
}
}
-#else
- Q_UNUSED(level)
- Q_UNUSED(object)
-#endif
}
/*!
- Dumps a tree of children to the debug output.
+ \overload
+ \obsolete
- This function is useful for debugging, but does nothing if the
- library has been compiled in release mode (i.e. without debugging
- information).
+ Dumps a tree of children to the debug output.
\sa dumpObjectInfo()
*/
void QObject::dumpObjectTree()
{
+ const_cast<const QObject *>(this)->dumpObjectTree();
+}
+
+/*!
+ Dumps a tree of children to the debug output.
+
+ \note before Qt 5.9, this function was not const.
+
+ \sa dumpObjectInfo()
+*/
+
+void QObject::dumpObjectTree() const
+{
dumpRecursive(0, this);
}
/*!
+ \overload
+ \obsolete
+
Dumps information about signal connections, etc. for this object
to the debug output.
- This function is useful for debugging, but does nothing if the
- library has been compiled in release mode (i.e. without debugging
- information).
-
\sa dumpObjectTree()
*/
void QObject::dumpObjectInfo()
{
-#if defined(QT_DEBUG)
+ const_cast<const QObject *>(this)->dumpObjectInfo();
+}
+
+/*!
+ Dumps information about signal connections, etc. for this object
+ to the debug output.
+
+ \note before Qt 5.9, this function was not const.
+
+ \sa dumpObjectTree()
+*/
+
+void QObject::dumpObjectInfo() const
+{
qDebug("OBJECT %s::%s", metaObject()->className(),
objectName().isEmpty() ? "unnamed" : objectName().toLocal8Bit().data());
- Q_D(QObject);
+ Q_D(const QObject);
QMutexLocker locker(signalSlotLock(this));
// first, look for connections where this object is the sender
@@ -4066,7 +4061,6 @@ void QObject::dumpObjectInfo()
} else {
qDebug(" <None>");
}
-#endif
}
#ifndef QT_NO_USERDATA
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 69b70ad6ec..25acdefeaf 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -375,8 +375,12 @@ public:
#endif //Q_QDOC
- void dumpObjectTree();
- void dumpObjectInfo();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ void dumpObjectTree(); // ### Qt 6: remove
+ void dumpObjectInfo(); // ### Qt 6: remove
+#endif
+ void dumpObjectTree() const;
+ void dumpObjectInfo() const;
#ifndef QT_NO_PROPERTIES
bool setProperty(const char *name, const QVariant &value);
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp
index 55af7256be..a04536b18b 100644
--- a/src/corelib/tools/qarraydata.cpp
+++ b/src/corelib/tools/qarraydata.cpp
@@ -63,6 +63,29 @@ QT_WARNING_POP
static const QArrayData &qt_array_empty = qt_array[0];
static const QArrayData &qt_array_unsharable_empty = qt_array[1];
+static inline size_t calculateBlockSize(size_t &capacity, size_t objectSize, size_t headerSize,
+ uint options)
+{
+ // Calculate the byte size
+ // allocSize = objectSize * capacity + headerSize, but checked for overflow
+ // plus padded to grow in size
+ if (options & QArrayData::Grow) {
+ auto r = qCalculateGrowingBlockSize(capacity, objectSize, headerSize);
+ capacity = r.elementCount;
+ return r.size;
+ } else {
+ return qCalculateBlockSize(capacity, objectSize, headerSize);
+ }
+}
+
+static QArrayData *reallocateData(QArrayData *header, size_t allocSize, uint options)
+{
+ header = static_cast<QArrayData *>(::realloc(header, allocSize));
+ if (header)
+ header->capacityReserved = bool(options & QArrayData::CapacityReserved);
+ return header;
+}
+
QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
size_t capacity, AllocationOptions options) Q_DECL_NOTHROW
{
@@ -91,18 +114,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
if (headerSize > size_t(MaxAllocSize))
return 0;
- // Calculate the byte size
- // allocSize = objectSize * capacity + headerSize, but checked for overflow
- // plus padded to grow in size
- size_t allocSize;
- if (options & Grow) {
- auto r = qCalculateGrowingBlockSize(capacity, objectSize, headerSize);
- capacity = r.elementCount;
- allocSize = r.size;
- } else {
- allocSize = qCalculateBlockSize(capacity, objectSize, headerSize);
- }
-
+ size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options);
QArrayData *header = static_cast<QArrayData *>(::malloc(allocSize));
if (header) {
quintptr data = (quintptr(header) + sizeof(QArrayData) + alignment - 1)
@@ -122,6 +134,21 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
return header;
}
+QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, size_t capacity,
+ AllocationOptions options) Q_DECL_NOTHROW
+{
+ Q_ASSERT(data);
+ Q_ASSERT(data->isMutable());
+ Q_ASSERT(!data->ref.isShared());
+
+ size_t headerSize = sizeof(QArrayData);
+ size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options);
+ QArrayData *header = static_cast<QArrayData *>(reallocateData(data, allocSize, options));
+ if (header)
+ header->alloc = capacity;
+ return header;
+}
+
void QArrayData::deallocate(QArrayData *data, size_t objectSize,
size_t alignment) Q_DECL_NOTHROW
{
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index 5a369baf08..bc20932cca 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -115,6 +115,9 @@ struct Q_CORE_EXPORT QArrayData
static QArrayData *allocate(size_t objectSize, size_t alignment,
size_t capacity, AllocationOptions options = Default)
Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize,
+ size_t newCapacity, AllocationOptions newOptions = Default)
+ Q_DECL_NOTHROW Q_REQUIRED_RESULT;
static void deallocate(QArrayData *data, size_t objectSize,
size_t alignment) Q_DECL_NOTHROW;
@@ -222,6 +225,14 @@ struct QTypedArrayData
Q_ALIGNOF(AlignmentDummy), capacity, options));
}
+ static QTypedArrayData *reallocateUnaligned(QTypedArrayData *data, size_t capacity,
+ AllocationOptions options = Default)
+ {
+ Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
+ return static_cast<QTypedArrayData *>(QArrayData::reallocateUnaligned(data, sizeof(T),
+ capacity, options));
+ }
+
static void deallocate(QArrayData *data)
{
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 9298472305..7d9c5dc325 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -663,6 +663,20 @@ QByteArray qCompress(const uchar* data, int nbytes, int compressionLevel)
*/
#ifndef QT_NO_COMPRESS
+namespace {
+struct QByteArrayDataDeleter
+{
+ static inline void cleanup(QTypedArrayData<char> *d)
+ { if (d) QTypedArrayData<char>::deallocate(d); }
+};
+}
+
+static QByteArray invalidCompressedData()
+{
+ qWarning("qUncompress: Input data is corrupted");
+ return QByteArray();
+}
+
QByteArray qUncompress(const uchar* data, int nbytes)
{
if (!data) {
@@ -677,53 +691,29 @@ QByteArray qUncompress(const uchar* data, int nbytes)
ulong expectedSize = uint((data[0] << 24) | (data[1] << 16) |
(data[2] << 8) | (data[3] ));
ulong len = qMax(expectedSize, 1ul);
- QScopedPointer<QByteArray::Data, QScopedPointerPodDeleter> d;
+ const ulong maxPossibleSize = MaxAllocSize - sizeof(QByteArray::Data);
+ if (Q_UNLIKELY(len >= maxPossibleSize)) {
+ // QByteArray does not support that huge size anyway.
+ return invalidCompressedData();
+ }
+ QScopedPointer<QByteArray::Data, QByteArrayDataDeleter> d(QByteArray::Data::allocate(expectedSize + 1));
+ if (Q_UNLIKELY(d.data() == nullptr))
+ return invalidCompressedData();
+
+ d->size = expectedSize;
forever {
ulong alloc = len;
- if (len >= (1u << 31u) - sizeof(QByteArray::Data)) {
- //QByteArray does not support that huge size anyway.
- qWarning("qUncompress: Input data is corrupted");
- return QByteArray();
- }
- QByteArray::Data *p = static_cast<QByteArray::Data *>(::realloc(d.data(), sizeof(QByteArray::Data) + alloc + 1));
- if (!p) {
- // we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
- qWarning("qUncompress: could not allocate enough memory to uncompress data");
- return QByteArray();
- }
- d.take(); // realloc was successful
- d.reset(p);
- d->offset = sizeof(QByteArrayData);
- d->size = 0; // Shut up valgrind "uninitialized variable" warning
int res = ::uncompress((uchar*)d->data(), &len,
data+4, nbytes-4);
switch (res) {
case Z_OK:
- if (len != alloc) {
- if (len >= (1u << 31u) - sizeof(QByteArray::Data)) {
- //QByteArray does not support that huge size anyway.
- qWarning("qUncompress: Input data is corrupted");
- return QByteArray();
- }
- QByteArray::Data *p = static_cast<QByteArray::Data *>(::realloc(d.data(), sizeof(QByteArray::Data) + len + 1));
- if (!p) {
- // we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
- qWarning("qUncompress: could not allocate enough memory to uncompress data");
- return QByteArray();
- }
- d.take(); // realloc was successful
- d.reset(p);
- }
- d->ref.initializeOwned();
+ Q_ASSERT(len <= alloc);
+ Q_UNUSED(alloc);
d->size = len;
- d->alloc = uint(len) + 1u;
- d->capacityReserved = false;
- d->offset = sizeof(QByteArrayData);
d->data()[len] = 0;
-
{
QByteArrayDataPtr dataPtr = { d.take() };
return QByteArray(dataPtr);
@@ -735,6 +725,17 @@ QByteArray qUncompress(const uchar* data, int nbytes)
case Z_BUF_ERROR:
len *= 2;
+ if (Q_UNLIKELY(len >= maxPossibleSize)) {
+ // QByteArray does not support that huge size anyway.
+ return invalidCompressedData();
+ } else {
+ // grow the block
+ QByteArray::Data *p = QByteArray::Data::reallocateUnaligned(d.data(), len + 1);
+ if (Q_UNLIKELY(p == nullptr))
+ return invalidCompressedData();
+ d.take(); // don't free
+ d.reset(p);
+ }
continue;
case Z_DATA_ERROR:
@@ -1707,19 +1708,8 @@ void QByteArray::reallocData(uint alloc, Data::AllocationOptions options)
Data::deallocate(d);
d = x;
} else {
- size_t blockSize;
- if (options & Data::Grow) {
- auto r = qCalculateGrowingBlockSize(alloc, sizeof(QChar), sizeof(Data));
- blockSize = r.size;
- alloc = uint(r.elementCount);
- } else {
- blockSize = qCalculateBlockSize(alloc, sizeof(QChar), sizeof(Data));
- }
-
- Data *x = static_cast<Data *>(::realloc(d, blockSize));
+ Data *x = Data::reallocateUnaligned(d, alloc, options);
Q_CHECK_PTR(x);
- x->alloc = alloc;
- x->capacityReserved = (options & Data::CapacityReserved) ? 1 : 0;
d = x;
}
}
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index f784aa13fc..896b4a3840 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -929,7 +929,7 @@ QString QDate::toString(Qt::DateFormat format) const
*/
QString QDate::toString(const QString& format) const
{
- return QLocale::system().toString(*this, format);
+ return QLocale::system().toString(*this, format); // QLocale::c() ### Qt6
}
#endif //QT_NO_DATESTRING
@@ -1333,6 +1333,7 @@ QDate QDate::fromString(const QString &string, const QString &format)
QDate date;
#if QT_CONFIG(timezone)
QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString);
+ // dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format))
dt.fromString(string, &date, 0);
#else
@@ -1676,7 +1677,7 @@ QString QTime::toString(Qt::DateFormat format) const
*/
QString QTime::toString(const QString& format) const
{
- return QLocale::system().toString(*this, format);
+ return QLocale::system().toString(*this, format); // QLocale::c() ### Qt6
}
#endif //QT_NO_DATESTRING
/*!
@@ -2030,6 +2031,7 @@ QTime QTime::fromString(const QString &string, const QString &format)
QTime time;
#if QT_CONFIG(timezone)
QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString);
+ // dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format))
dt.fromString(string, 0, &time);
#else
@@ -3896,7 +3898,7 @@ QString QDateTime::toString(Qt::DateFormat format) const
*/
QString QDateTime::toString(const QString& format) const
{
- return QLocale::system().toString(*this, format);
+ return QLocale::system().toString(*this, format); // QLocale::c() ### Qt6
}
#endif //QT_NO_DATESTRING
@@ -4950,6 +4952,7 @@ QDateTime QDateTime::fromString(const QString &string, const QString &format)
QDate date;
QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString);
+ // dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
return QDateTime(date, time);
#else
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 847fc2d55e..ca04c2bd44 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -2018,6 +2018,8 @@ QString QLocale::toString(double i, char f, int prec) const
flags |= QLocaleData::ThousandsGroup;
if (!(d->m_numberOptions & OmitLeadingZeroInExponent))
flags |= QLocaleData::ZeroPadExponent;
+ if (d->m_numberOptions & IncludeTrailingZeroesAfterDot)
+ flags |= QLocaleData::AddTrailingZeroes;
return d->m_data->doubleToString(i, prec, form, -1, flags);
}
@@ -2779,7 +2781,7 @@ QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const Q
reinterpret_cast<ushort *>(digits.data())[i] += z;
}
- bool always_show_decpt = (flags & Alternate || flags & ForcePoint);
+ bool always_show_decpt = (flags & ForcePoint);
switch (form) {
case DFExponent: {
num_str = exponentForm(_zero, decimal, exponential, group, plus, minus,
@@ -2794,7 +2796,7 @@ QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const Q
break;
}
case DFSignificantDigits: {
- PrecisionMode mode = (flags & Alternate) ?
+ PrecisionMode mode = (flags & AddTrailingZeroes) ?
PMSignificantDigits : PMChopTrailingZeros;
int cutoff = precision < 0 ? 6 : precision;
@@ -2899,7 +2901,7 @@ QString QLocaleData::longLongToString(const QChar zero, const QChar group,
for (int i = num_str.length()/* - cnt_thousand_sep*/; i < precision; ++i)
num_str.prepend(base == 10 ? zero : QChar::fromLatin1('0'));
- if ((flags & Alternate || flags & ShowBase)
+ if ((flags & ShowBase)
&& base == 8
&& (num_str.isEmpty() || num_str[0].unicode() != QLatin1Char('0')))
num_str.prepend(QLatin1Char('0'));
@@ -2920,10 +2922,10 @@ QString QLocaleData::longLongToString(const QChar zero, const QChar group,
--num_pad_chars;
// leave space for optional '0x' in hex form
- if (base == 16 && (flags & Alternate || flags & ShowBase))
+ if (base == 16 && (flags & ShowBase))
num_pad_chars -= 2;
// leave space for optional '0b' in binary form
- else if (base == 2 && (flags & Alternate || flags & ShowBase))
+ else if (base == 2 && (flags & ShowBase))
num_pad_chars -= 2;
for (int i = 0; i < num_pad_chars; ++i)
@@ -2933,9 +2935,9 @@ QString QLocaleData::longLongToString(const QChar zero, const QChar group,
if (flags & CapitalEorX)
num_str = num_str.toUpper();
- if (base == 16 && (flags & Alternate || flags & ShowBase))
+ if (base == 16 && (flags & ShowBase))
num_str.prepend(QLatin1String(flags & UppercaseBase ? "0X" : "0x"));
- if (base == 2 && (flags & Alternate || flags & ShowBase))
+ if (base == 2 && (flags & ShowBase))
num_str.prepend(QLatin1String(flags & UppercaseBase ? "0B" : "0b"));
// add sign
@@ -2984,7 +2986,7 @@ QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group,
if (zeroPadding > 0)
num_str.prepend(QString(zeroPadding, resultZero));
- if ((flags & Alternate || flags & ShowBase)
+ if ((flags & ShowBase)
&& base == 8
&& (num_str.isEmpty() || num_str.at(0).unicode() != QLatin1Char('0')))
num_str.prepend(QLatin1Char('0'));
@@ -2999,10 +3001,10 @@ QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group,
int num_pad_chars = width - num_str.length();
// leave space for optional '0x' in hex form
- if (base == 16 && flags & Alternate)
+ if (base == 16 && flags & ShowBase)
num_pad_chars -= 2;
// leave space for optional '0b' in binary form
- else if (base == 2 && flags & Alternate)
+ else if (base == 2 && flags & ShowBase)
num_pad_chars -= 2;
if (num_pad_chars > 0)
@@ -3012,9 +3014,9 @@ QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group,
if (flags & CapitalEorX)
num_str = num_str.toUpper();
- if (base == 16 && (flags & Alternate || flags & ShowBase))
+ if (base == 16 && flags & ShowBase)
num_str.prepend(QLatin1String(flags & UppercaseBase ? "0X" : "0x"));
- else if (base == 2 && (flags & Alternate || flags & ShowBase))
+ else if (base == 2 && flags & ShowBase)
num_str.prepend(QLatin1String(flags & UppercaseBase ? "0B" : "0b"));
// add sign
@@ -3075,25 +3077,37 @@ bool QLocaleData::numberToCLocale(const QChar *str, int len, QLocale::NumberOpti
out = in.toLatin1();
else
break;
+ } else if (out == '.') {
+ // Fail if more than one decimal point or point after e
+ if (decpt_idx != -1 || exponent_idx != -1)
+ return false;
+ decpt_idx = idx;
+ } else if (out == 'e' || out == 'E') {
+ exponent_idx = idx;
}
if (number_options & QLocale::RejectLeadingZeroInExponent) {
- if (out == 'e' || out == 'E') {
- exponent_idx = idx;
- } else if (exponent_idx != -1) {
- if (out >= '1' && out <= '9')
- exponent_idx = -1; // leading digit is not 0, forget exponent_idx
- else if (out == '0' && idx < l - 1)
+ if (exponent_idx != -1 && out == '0' && idx < l - 1) {
+ // After the exponent there can only be '+', '-' or digits.
+ // If we find a '0' directly after some non-digit, then that is a leading zero.
+ if (result->last() < '0' || result->last() > '9')
return false;
}
}
+ if (number_options & QLocale::RejectTrailingZeroesAfterDot) {
+ // If we've seen a decimal point and the last character after the exponent is 0, then
+ // that is a trailing zero.
+ if (decpt_idx >= 0 && idx == exponent_idx && result->last() == '0')
+ return false;
+ }
+
if (!(number_options & QLocale::RejectGroupSeparator)) {
if (start_of_digits_idx == -1 && out >= '0' && out <= '9') {
start_of_digits_idx = idx;
} else if (out == ',') {
- // Don't allow group chars after the decimal point
- if (decpt_idx != -1)
+ // Don't allow group chars after the decimal point or exponent
+ if (decpt_idx != -1 || exponent_idx != -1)
return false;
// check distance from the last separator or from the beginning of the digits
@@ -3110,12 +3124,6 @@ bool QLocaleData::numberToCLocale(const QChar *str, int len, QLocale::NumberOpti
++idx;
continue;
} else if (out == '.' || out == 'e' || out == 'E') {
- // Fail if more than one decimal point
- if (out == '.' && decpt_idx != -1)
- return false;
- if (decpt_idx == -1)
- decpt_idx = idx;
-
// check distance from the last separator
// ### FIXME: Some locales allow other groupings! See https://en.wikipedia.org/wiki/Thousands_separator
if (last_separator_idx != -1 && idx - last_separator_idx != 4)
@@ -3141,6 +3149,12 @@ bool QLocaleData::numberToCLocale(const QChar *str, int len, QLocale::NumberOpti
return false;
}
+ if (number_options & QLocale::RejectTrailingZeroesAfterDot) {
+ // In decimal form, the last character can be a trailing zero if we've seen a decpt.
+ if (decpt_idx != -1 && exponent_idx == -1 && result->last() == '0')
+ return false;
+ }
+
result->append('\0');
return idx == l;
}
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index 657fce9fa1..bd89e48234 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -897,7 +897,9 @@ public:
OmitGroupSeparator = 0x01,
RejectGroupSeparator = 0x02,
OmitLeadingZeroInExponent = 0x04,
- RejectLeadingZeroInExponent = 0x08
+ RejectLeadingZeroInExponent = 0x08,
+ IncludeTrailingZeroesAfterDot = 0x10,
+ RejectTrailingZeroesAfterDot = 0x20
};
Q_DECLARE_FLAGS(NumberOptions, NumberOption)
diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc
index 8c5711fb5e..d419172356 100644
--- a/src/corelib/tools/qlocale.qdoc
+++ b/src/corelib/tools/qlocale.qdoc
@@ -949,7 +949,8 @@
setNumberOptions().
\value DefaultNumberOptions This option represents the default behavior, with
- group separators and with one leading zero in single digit exponents.
+ group separators, with one leading zero in single digit exponents, and
+ without trailing zeroes after the decimal dot.
\value OmitGroupSeparator If this option is set, the number-to-string functions
will not insert group separators in their return values. The default
is to insert group separators.
@@ -964,6 +965,14 @@
functions will fail if they encounter an exponent padded with zeroes when
parsing a floating point number in scientific notation. The default is to
accept such padding.
+ \value IncludeTrailingZeroesAfterDot If this option is set, the number-to-string
+ functions will pad numbers with zeroes to the requested precision in "g"
+ or "most concise" mode, even if the number of significant digits is lower
+ than the requested precision. The default is to omit trailing zeroes.
+ \value RejectTrailingZeroesAfterDot If this option is set, the string-to-number
+ functions will fail if they encounter trailing zeroes after the decimal
+ dot when parsing a number in scientific or decimal representation. The
+ default is to accept trailing zeroes.
\sa setNumberOptions(), numberOptions()
*/
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index c83c9d3333..74d8e5f381 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -193,7 +193,7 @@ public:
enum Flags {
NoFlags = 0,
- Alternate = 0x01,
+ AddTrailingZeroes = 0x01,
ZeroPadded = 0x02,
LeftAdjusted = 0x04,
BlankBeforePositive = 0x08,
@@ -204,7 +204,7 @@ public:
ShowBase = 0x80,
UppercaseBase = 0x100,
ZeroPadExponent = 0x200,
- ForcePoint = Alternate
+ ForcePoint = 0x400
};
enum NumberMode { IntegerMode, DoubleStandardMode, DoubleScientificMode };
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
index cb11e72435..8fa378e935 100644
--- a/src/corelib/tools/qringbuffer.cpp
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -132,7 +132,6 @@ char *QRingBuffer::reserve(qint64 bytes)
char *writePtr = buffers.last().data() + tail;
bufferSize += bytes;
- Q_ASSERT(bytes < MaxByteArraySize);
tail += int(bytes);
return writePtr;
}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 8520bb5740..94d2b5f65e 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -491,6 +491,30 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
return UnrollTailLoop<7>::exec(l, 0, lambda, lambda);
# endif
#endif
+#if defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64) // vaddv is only available on Aarch64
+ if (l >= 8) {
+ const QChar *end = a + l;
+ const uint16x8_t mask = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 };
+ while (a + 8 < end) {
+ uint16x8_t da = vld1q_u16(reinterpret_cast<const uint16_t *>(a));
+ uint16x8_t db = vld1q_u16(reinterpret_cast<const uint16_t *>(b));
+
+ uint8_t r = ~(uint8_t)vaddvq_u16(vandq_u16(vceqq_u16(da, db), mask));
+ if (r) {
+ // found a different QChar
+ uint idx = qCountTrailingZeroBits(r);
+ return (int)a[idx].unicode() - (int)b[idx].unicode();
+ }
+ a += 8;
+ b += 8;
+ }
+ l &= 7;
+ }
+ const auto &lambda = [=](int i) -> int {
+ return a[i].unicode() - b[i].unicode();
+ };
+ return UnrollTailLoop<7>::exec(l, 0, lambda, lambda);
+#endif // __ARM_NEON__
if (!l)
return 0;
@@ -1767,17 +1791,11 @@ void QString::resize(int size, QChar fillChar)
void QString::reallocData(uint alloc, bool grow)
{
- size_t blockSize;
- if (grow) {
- auto r = qCalculateGrowingBlockSize(alloc, sizeof(QChar), sizeof(Data));
- blockSize = r.size;
- alloc = uint(r.elementCount);
- } else {
- blockSize = qCalculateBlockSize(alloc, sizeof(QChar), sizeof(Data));
- }
+ auto allocOptions = d->detachFlags();
+ if (grow)
+ allocOptions |= QArrayData::Grow;
if (d->ref.isShared() || IS_RAW_DATA(d)) {
- Data::AllocationOptions allocOptions(d->capacityReserved ? Data::CapacityReserved : 0);
Data *x = Data::allocate(alloc, allocOptions);
Q_CHECK_PTR(x);
x->size = qMin(int(alloc) - 1, d->size);
@@ -1787,11 +1805,9 @@ void QString::reallocData(uint alloc, bool grow)
Data::deallocate(d);
d = x;
} else {
- Data *p = static_cast<Data *>(::realloc(d, blockSize));
+ Data *p = Data::reallocateUnaligned(d, alloc, allocOptions);
Q_CHECK_PTR(p);
d = p;
- d->alloc = alloc;
- d->offset = sizeof(QStringData);
}
}
@@ -4450,11 +4466,11 @@ bool QString::startsWith(const QStringRef &s, Qt::CaseSensitivity cs) const
\sa startsWith()
*/
-bool QString::endsWith(const QString& s, Qt::CaseSensitivity cs) const
+bool QString::endsWith(const QString &s, Qt::CaseSensitivity cs) const
{
return qt_ends_with(isNull() ? 0 : unicode(), size(),
s.isNull() ? 0 : s.unicode(), s.size(), cs);
- }
+}
/*!
\since 4.8
@@ -5965,7 +5981,10 @@ static uint parse_flag_characters(const char * &c) Q_DECL_NOTHROW
uint flags = QLocaleData::ZeroPadExponent;
while (true) {
switch (*c) {
- case '#': flags |= QLocaleData::Alternate; break;
+ case '#':
+ flags |= QLocaleData::ShowBase | QLocaleData::AddTrailingZeroes
+ | QLocaleData::ForcePoint;
+ break;
case '0': flags |= QLocaleData::ZeroPadded; break;
case '-': flags |= QLocaleData::LeftAdjusted; break;
case ' ': flags |= QLocaleData::BlankBeforePositive; break;
@@ -6223,7 +6242,7 @@ QString QString::vasprintf(const char *cformat, va_list ap)
case 'p': {
void *arg = va_arg(ap, void*);
const quint64 i = reinterpret_cast<quintptr>(arg);
- flags |= QLocaleData::Alternate;
+ flags |= QLocaleData::ShowBase;
subst = QLocaleData::c()->unsLongLongToString(i, precision, 16, width, flags);
++c;
break;
@@ -7798,10 +7817,13 @@ QString QString::arg(double a, int fieldWidth, char fmt, int prec, QChar fillCha
if (d.locale_occurrences > 0) {
QLocale locale;
- if (!(locale.numberOptions() & QLocale::OmitGroupSeparator))
+ const QLocale::NumberOptions numberOptions = locale.numberOptions();
+ if (!(numberOptions & QLocale::OmitGroupSeparator))
flags |= QLocaleData::ThousandsGroup;
- if (!(locale.numberOptions() & QLocale::OmitLeadingZeroInExponent))
+ if (!(numberOptions & QLocale::OmitLeadingZeroInExponent))
flags |= QLocaleData::ZeroPadExponent;
+ if (numberOptions & QLocale::IncludeTrailingZeroesAfterDot)
+ flags |= QLocaleData::AddTrailingZeroes;
locale_arg = locale.d->m_data->doubleToString(a, prec, form, fieldWidth, flags);
}
@@ -8009,33 +8031,12 @@ bool QString::isSimpleText() const
/*! \fn bool QString::isRightToLeft() const
Returns \c true if the string is read right to left.
+
+ \sa QStringRef::isRightToLeft()
*/
bool QString::isRightToLeft() const
{
- const ushort *p = d->data();
- const ushort * const end = p + d->size;
- while (p < end) {
- uint ucs4 = *p;
- if (QChar::isHighSurrogate(ucs4) && p < end - 1) {
- ushort low = p[1];
- if (QChar::isLowSurrogate(low)) {
- ucs4 = QChar::surrogateToUcs4(ucs4, low);
- ++p;
- }
- }
- switch (QChar::direction(ucs4))
- {
- case QChar::DirL:
- return false;
- case QChar::DirR:
- case QChar::DirAL:
- return true;
- default:
- break;
- }
- ++p;
- }
- return false;
+ return QStringRef(this).isRightToLeft();
}
/*! \fn QChar *QString::data()
@@ -8991,7 +8992,7 @@ ownership of it, no memory is freed when instances are destroyed.
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character in
the string.
- \sa cbegin(), end(), rbegin(), rend()
+ \sa cbegin(), constBegin(), end(), constEnd(), rbegin(), rend()
*/
/*!
@@ -9000,7 +9001,16 @@ ownership of it, no memory is freed when instances are destroyed.
Same as begin().
- \sa begin(), cend(), rbegin(), rend()
+ \sa begin(), constBegin(), cend(), constEnd(), rbegin(), rend()
+*/
+
+/*!
+ \fn QStringRef::const_iterator QStringRef::constBegin() const
+ \since 5.9
+
+ Same as begin().
+
+ \sa begin(), cend(), constEnd(), rbegin(), rend()
*/
/*!
@@ -9010,7 +9020,7 @@ ownership of it, no memory is freed when instances are destroyed.
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
character after the last character in the list.
- \sa cbegin(), end(), rbegin(), rend()
+ \sa cbegin(), constBegin(), end(), constEnd(), rbegin(), rend()
*/
/*! \fn QStringRef::const_iterator QStringRef::cend() const
@@ -9018,7 +9028,15 @@ ownership of it, no memory is freed when instances are destroyed.
Same as end().
- \sa end(), cbegin(), rbegin(), rend()
+ \sa end(), constEnd(), cbegin(), constBegin(), rbegin(), rend()
+*/
+
+/*! \fn QStringRef::const_iterator QStringRef::constEnd() const
+ \since 5.9
+
+ Same as end().
+
+ \sa end(), cend(), cbegin(), constBegin(), rbegin(), rend()
*/
/*!
@@ -9942,6 +9960,41 @@ int QStringRef::count(const QStringRef &str, Qt::CaseSensitivity cs) const
}
/*!
+ \since 5.9
+
+ Returns \c true if the string is read right to left.
+
+ \sa QString::isRightToLeft()
+*/
+bool QStringRef::isRightToLeft() const
+{
+ const ushort *p = reinterpret_cast<const ushort*>(unicode());
+ const ushort * const end = p + size();
+ while (p < end) {
+ uint ucs4 = *p;
+ if (QChar::isHighSurrogate(ucs4) && p < end - 1) {
+ ushort low = p[1];
+ if (QChar::isLowSurrogate(low)) {
+ ucs4 = QChar::surrogateToUcs4(ucs4, low);
+ ++p;
+ }
+ }
+ switch (QChar::direction(ucs4))
+ {
+ case QChar::DirL:
+ return false;
+ case QChar::DirR:
+ case QChar::DirAL:
+ return true;
+ default:
+ break;
+ }
+ ++p;
+ }
+ return false;
+}
+
+/*!
\since 4.8
Returns \c true if the string reference starts with \a str; otherwise
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index b50b2ee4e5..b370056d28 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -1400,7 +1400,8 @@ public:
QStringRef(QStringRef &&other) Q_DECL_NOTHROW : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {}
QStringRef &operator=(QStringRef &&other) Q_DECL_NOTHROW { return *this = other; }
#endif
- QStringRef &operator=(const QStringRef &other) Q_DECL_NOTHROW {
+ QStringRef &operator=(const QStringRef &other) Q_DECL_NOTHROW
+ {
m_string = other.m_string; m_position = other.m_position;
m_size = other.m_size; return *this;
}
@@ -1449,6 +1450,8 @@ public:
m_size -= n;
}
+ bool isRightToLeft() const;
+
bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@@ -1461,7 +1464,8 @@ public:
inline QStringRef &operator=(const QString *string);
- inline const QChar *unicode() const {
+ inline const QChar *unicode() const
+ {
if (!m_string)
return reinterpret_cast<const QChar *>(QString::Data::sharedNull()->data());
return m_string->unicode() + m_position;
@@ -1471,8 +1475,10 @@ public:
inline const_iterator begin() const { return unicode(); }
inline const_iterator cbegin() const { return unicode(); }
+ inline const_iterator constBegin() const { return unicode(); }
inline const_iterator end() const { return unicode() + size(); }
inline const_iterator cend() const { return unicode() + size(); }
+ inline const_iterator constEnd() const { return unicode() + size(); }
inline const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
inline const_reverse_iterator crbegin() const { return rbegin(); }
inline const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
diff --git a/src/dbus/qdbusutil_p.h b/src/dbus/qdbusutil_p.h
index 931a374ad9..2f187687b8 100644
--- a/src/dbus/qdbusutil_p.h
+++ b/src/dbus/qdbusutil_p.h
@@ -69,17 +69,17 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil
Q_DBUS_EXPORT bool isValidInterfaceName(const QString &ifaceName);
Q_DBUS_EXPORT bool isValidUniqueConnectionName(const QStringRef &busName);
- bool inline isValidUniqueConnectionName(const QString &busName) { return isValidUniqueConnectionName(QStringRef(&busName)); }
+ inline bool isValidUniqueConnectionName(const QString &busName) { return isValidUniqueConnectionName(QStringRef(&busName)); }
Q_DBUS_EXPORT bool isValidBusName(const QString &busName);
Q_DBUS_EXPORT bool isValidMemberName(const QStringRef &memberName);
- bool inline isValidMemberName(const QString &memberName) { return isValidMemberName(QStringRef(&memberName)); }
+ inline bool isValidMemberName(const QString &memberName) { return isValidMemberName(QStringRef(&memberName)); }
Q_DBUS_EXPORT bool isValidErrorName(const QString &errorName);
Q_DBUS_EXPORT bool isValidPartOfObjectPath(const QStringRef &path);
- bool inline isValidPartOfObjectPath(const QString &path) { return isValidPartOfObjectPath(QStringRef(&path)); }
+ inline bool isValidPartOfObjectPath(const QString &path) { return isValidPartOfObjectPath(QStringRef(&path)); }
Q_DBUS_EXPORT bool isValidObjectPath(const QString &path);
diff --git a/src/gui/configure.json b/src/gui/configure.json
index 6fba8173b4..662e484271 100644
--- a/src/gui/configure.json
+++ b/src/gui/configure.json
@@ -505,7 +505,7 @@
"kms": {
"label": "KMS",
"condition": "libs.drm",
- "output": [ "publicQtConfig" ]
+ "output": [ "publicQtConfig", "privateFeature" ]
},
"libinput": {
"label": "libinput",
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 0d2f55b1c2..e8f2c878c8 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -137,8 +137,8 @@ static qreal qt_effective_device_pixel_ratio(QWindow *window = 0)
return qApp->devicePixelRatio(); // Don't know which window to target.
}
-QIconPrivate::QIconPrivate()
- : engine(0), ref(1),
+QIconPrivate::QIconPrivate(QIconEngine *e)
+ : engine(e), ref(1),
serialNum(serialNumCounter.fetchAndAddRelaxed(1)),
detach_no(0),
is_mask(false)
@@ -673,9 +673,8 @@ QIcon::QIcon(const QString &fileName)
ownership of the engine.
*/
QIcon::QIcon(QIconEngine *engine)
- :d(new QIconPrivate)
+ :d(new QIconPrivate(engine))
{
- d->engine = engine;
}
/*!
@@ -950,8 +949,7 @@ void QIcon::detach()
d = 0;
return;
} else if (d->ref.load() != 1) {
- QIconPrivate *x = new QIconPrivate;
- x->engine = d->engine->clone();
+ QIconPrivate *x = new QIconPrivate(d->engine->clone());
if (!d->ref.deref())
delete d;
d = x;
@@ -974,10 +972,8 @@ void QIcon::addPixmap(const QPixmap &pixmap, Mode mode, State state)
if (pixmap.isNull())
return;
detach();
- if (!d) {
- d = new QIconPrivate;
- d->engine = new QPixmapIconEngine;
- }
+ if (!d)
+ d = new QIconPrivate(new QPixmapIconEngine);
d->engine->addPixmap(pixmap, mode, state);
}
@@ -1037,8 +1033,7 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
if (!engine)
engine = iconEngineFromSuffix(fileName, QMimeDatabase().mimeTypeForFile(info).preferredSuffix());
#endif // !QT_NO_MIMETYPE
- d = new QIconPrivate;
- d->engine = engine ? engine : new QPixmapIconEngine;
+ d = new QIconPrivate(engine ? engine : new QPixmapIconEngine);
}
d->engine->addFile(fileName, size, mode, state);
@@ -1240,12 +1235,10 @@ bool QIcon::hasThemeIcon(const QString &name)
*/
void QIcon::setIsMask(bool isMask)
{
- if (!d) {
- d = new QIconPrivate;
- d->engine = new QPixmapIconEngine;
- } else {
+ if (!d)
+ d = new QIconPrivate(new QPixmapIconEngine);
+ else
detach();
- }
d->is_mask = isMask;
}
@@ -1326,22 +1319,17 @@ QDataStream &operator>>(QDataStream &s, QIcon &icon)
QString key;
s >> key;
if (key == QLatin1String("QPixmapIconEngine")) {
- icon.d = new QIconPrivate;
- QIconEngine *engine = new QPixmapIconEngine;
- icon.d->engine = engine;
- engine->read(s);
+ icon.d = new QIconPrivate(new QPixmapIconEngine);
+ icon.d->engine->read(s);
} else if (key == QLatin1String("QIconLoaderEngine")) {
- icon.d = new QIconPrivate;
- QIconEngine *engine = new QIconLoaderEngine();
- icon.d->engine = engine;
- engine->read(s);
+ icon.d = new QIconPrivate(new QIconLoaderEngine());
+ icon.d->engine->read(s);
} else {
const int index = loader()->indexOf(key);
if (index != -1) {
if (QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))) {
if (QIconEngine *engine= factory->create()) {
- icon.d = new QIconPrivate;
- icon.d->engine = engine;
+ icon.d = new QIconPrivate(engine);
engine->read(s);
} // factory
} // instance
diff --git a/src/gui/image/qicon_p.h b/src/gui/image/qicon_p.h
index a978a72192..aa358e88af 100644
--- a/src/gui/image/qicon_p.h
+++ b/src/gui/image/qicon_p.h
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
class QIconPrivate
{
public:
- QIconPrivate();
+ explicit QIconPrivate(QIconEngine *e);
~QIconPrivate() {
delete engine;
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 254b8926c8..fcb9c14406 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3887,7 +3887,7 @@ QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &tp)
{
QDebugStateSaver saver(dbg);
dbg.nospace();
- dbg << "TouchPoint(" << tp.id() << " (";
+ dbg << "TouchPoint(" << hex << tp.id() << dec << " (";
QtDebugUtils::formatQRect(dbg, tp.rect());
dbg << ") ";
QtDebugUtils::formatQEnum(dbg, tp.state());
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 7beab72ab0..14f94951d0 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -84,6 +84,7 @@
#include "private/qcursor_p.h"
#include "private/qopenglcontext_p.h"
#include "private/qinputdevicemanager_p.h"
+#include "private/qtouchdevice_p.h"
#include "private/qdnd_p.h"
#include <qpa/qplatformthemefactory_p.h>
@@ -1954,7 +1955,8 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
points << point;
QEvent::Type type;
- QList<QTouchEvent::TouchPoint> touchPoints = QWindowSystemInterfacePrivate::fromNativeTouchPoints(points, window, &type);
+ QList<QTouchEvent::TouchPoint> touchPoints =
+ QWindowSystemInterfacePrivate::fromNativeTouchPoints(points, window, QTouchDevicePrivate::get(m_fakeTouchDevice)->id, &type);
QWindowSystemInterfacePrivate::TouchEvent fake(window, e->timestamp, type, m_fakeTouchDevice, touchPoints, e->modifiers);
fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
diff --git a/src/gui/kernel/qtouchdevice.h b/src/gui/kernel/qtouchdevice.h
index 0fb24e47bf..c98aa69236 100644
--- a/src/gui/kernel/qtouchdevice.h
+++ b/src/gui/kernel/qtouchdevice.h
@@ -87,6 +87,7 @@ public:
private:
QTouchDevicePrivate *d;
+ friend class QTouchDevicePrivate;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QTouchDevice::Capabilities)
diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h
index 203d9fca74..18d2af46a7 100644
--- a/src/gui/kernel/qtouchdevice_p.h
+++ b/src/gui/kernel/qtouchdevice_p.h
@@ -64,16 +64,21 @@ public:
: type(QTouchDevice::TouchScreen),
caps(QTouchDevice::Position),
maxTouchPoints(1)
- { }
+ {
+ static quint8 nextId = 2; // device 0 is not used, device 1 is for mouse device
+ id = nextId++;
+ }
QTouchDevice::DeviceType type;
QTouchDevice::Capabilities caps;
QString name;
int maxTouchPoints;
+ quint8 id;
static void registerDevice(const QTouchDevice *dev);
static void unregisterDevice(const QTouchDevice *dev);
static bool isRegistered(const QTouchDevice *dev);
+ static QTouchDevicePrivate *get(QTouchDevice *q) { return q->d; }
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 94a34b5c27..124e997c58 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -343,6 +343,30 @@ void QWindowPrivate::updateVisibility()
emit q->visibilityChanged(visibility);
}
+void QWindowPrivate::updateSiblingPosition(SiblingPosition position)
+{
+ Q_Q(QWindow);
+
+ if (!q->parent())
+ return;
+
+ QObjectList &siblings = q->parent()->d_ptr->children;
+
+ const int siblingCount = siblings.size() - 1;
+ if (siblingCount == 0)
+ return;
+
+ const int currentPosition = siblings.indexOf(q);
+ Q_ASSERT(currentPosition >= 0);
+
+ const int targetPosition = position == PositionTop ? siblingCount : 0;
+
+ if (currentPosition == targetPosition)
+ return;
+
+ siblings.move(currentPosition, targetPosition);
+}
+
inline bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const
{
Q_Q(const QWindow);
@@ -801,6 +825,9 @@ QSurfaceFormat QWindow::format() const
void QWindow::setFlags(Qt::WindowFlags flags)
{
Q_D(QWindow);
+ if (d->windowFlags == flags)
+ return;
+
if (d->platformWindow)
d->platformWindow->setWindowFlags(flags);
d->windowFlags = flags;
@@ -920,6 +947,9 @@ QIcon QWindow::icon() const
void QWindow::raise()
{
Q_D(QWindow);
+
+ d->updateSiblingPosition(QWindowPrivate::PositionTop);
+
if (d->platformWindow)
d->platformWindow->raise();
}
@@ -932,6 +962,9 @@ void QWindow::raise()
void QWindow::lower()
{
Q_D(QWindow);
+
+ d->updateSiblingPosition(QWindowPrivate::PositionBottom);
+
if (d->platformWindow)
d->platformWindow->lower();
}
@@ -1455,6 +1488,8 @@ void QWindow::setSizeIncrement(const QSize &size)
Sets the geometry of the window, excluding its window frame, to a
rectangle constructed from \a posx, \a posy, \a w and \a h.
+ The geometry is in relation to the virtualGeometry() of its screen.
+
\sa geometry()
*/
void QWindow::setGeometry(int posx, int posy, int w, int h)
@@ -1465,6 +1500,8 @@ void QWindow::setGeometry(int posx, int posy, int w, int h)
/*!
\brief Sets the geometry of the window, excluding its window frame, to \a rect.
+ The geometry is in relation to the virtualGeometry() of its screen.
+
\sa geometry()
*/
void QWindow::setGeometry(const QRect &rect)
@@ -1526,6 +1563,8 @@ QScreen *QWindowPrivate::screenForGeometry(const QRect &newGeometry)
/*!
Returns the geometry of the window, excluding its window frame.
+ The geometry is in relation to the virtualGeometry() of its screen.
+
\sa frameMargins(), frameGeometry()
*/
QRect QWindow::geometry() const
@@ -1552,6 +1591,8 @@ QMargins QWindow::frameMargins() const
/*!
Returns the geometry of the window, including its window frame.
+ The geometry is in relation to the virtualGeometry() of its screen.
+
\sa geometry(), frameMargins()
*/
QRect QWindow::frameGeometry() const
@@ -1584,6 +1625,8 @@ QPoint QWindow::framePosition() const
/*!
Sets the upper left position of the window (\a point) including its window frame.
+ The position is in relation to the virtualGeometry() of its screen.
+
\sa setGeometry(), frameGeometry()
*/
void QWindow::setFramePosition(const QPoint &point)
@@ -1601,6 +1644,8 @@ void QWindow::setFramePosition(const QPoint &point)
/*!
\brief set the position of the window on the desktop to \a pt
+ The position is in relation to the virtualGeometry() of its screen.
+
\sa position()
*/
void QWindow::setPosition(const QPoint &pt)
@@ -1611,6 +1656,8 @@ void QWindow::setPosition(const QPoint &pt)
/*!
\brief set the position of the window on the desktop to \a posx, \a posy
+ The position is in relation to the virtualGeometry() of its screen.
+
\sa position()
*/
void QWindow::setPosition(int posx, int posy)
@@ -1787,8 +1834,9 @@ QScreen *QWindow::screen() const
If the window has been created, it will be recreated on the \a newScreen.
- Note that if the screen is part of a virtual desktop of multiple screens,
- the window can appear on any of the screens returned by QScreen::virtualSiblings().
+ \note If the screen is part of a virtual desktop of multiple screens,
+ the window will not move automatically to \a newScreen. To place the
+ window relative to the screen, use the screen's topLeft() position.
This function only works for top level windows.
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index b8a9f5d3de..dd5aa54b4f 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -144,6 +144,9 @@ public:
void updateVisibility();
void _q_clearAlert();
+ enum SiblingPosition { PositionTop, PositionBottom };
+ void updateSiblingPosition(SiblingPosition);
+
bool windowRecreationRequired(QScreen *newScreen) const;
void create(bool recursive);
void setTopLevelScreen(QScreen *newScreen, bool recreate);
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 667304859e..6a9a68f68b 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -59,41 +59,57 @@ QWaitCondition QWindowSystemInterfacePrivate::eventsFlushed;
QMutex QWindowSystemInterfacePrivate::flushEventMutex;
QAtomicInt QWindowSystemInterfacePrivate::eventAccepted;
QWindowSystemEventHandler *QWindowSystemInterfacePrivate::eventHandler;
-
-//------------------------------------------------------------
-//
-// Callback functions for plugins:
-//
-
QWindowSystemInterfacePrivate::WindowSystemEventList QWindowSystemInterfacePrivate::windowSystemEventQueue;
extern QPointer<QWindow> qt_last_mouse_receiver;
+
+// ------------------- QWindowSystemInterfacePrivate -------------------
+
/*!
Handles a window system event asynchronously by posting the event to Qt Gui.
- \sa postWindowSystemEvent()
+ This function posts the event on the window system event queue and wakes the
+ Gui event dispatcher. Qt Gui will then handle the event asynchonously at a
+ later point.
*/
template<>
bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterface::AsynchronousDelivery>(WindowSystemEvent *ev)
{
- QWindowSystemInterfacePrivate::postWindowSystemEvent(ev);
+ windowSystemEventQueue.append(ev);
+ if (QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher())
+ dispatcher->wakeUp();
return true;
}
/*!
Handles a window system event synchronously.
+ Qt Gui will process the event immediately. The return value indicates if Qt
+ accepted the event.
+
If the event is delivered from another thread than the Qt main thread the
window system event queue is flushed, which may deliver other events as
well.
-
- \sa processWindowSystemEvent()
*/
template<>
bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterface::SynchronousDelivery>(WindowSystemEvent *ev)
{
- return QWindowSystemInterfacePrivate::processWindowSystemEvent(ev);
+ bool accepted = true;
+ if (QThread::currentThread() == QGuiApplication::instance()->thread()) {
+ // Process the event immediately on the current thread and return the accepted state.
+ QGuiApplicationPrivate::processWindowSystemEvent(ev);
+ accepted = ev->eventAccepted;
+ delete ev;
+ } else {
+ // Post the event on the Qt main thread queue and flush the queue.
+ // This will wake up the Gui thread which will process the event.
+ // Return the accepted state for the last event on the queue,
+ // which is the event posted by this function.
+ handleWindowSystemEvent<QWindowSystemInterface::AsynchronousDelivery>(ev);
+ accepted = QWindowSystemInterface::flushWindowSystemEvents();
+ }
+ return accepted;
}
/*!
@@ -109,7 +125,7 @@ bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterfa
than the Qt main thread the window system event queue is flushed, which may deliver
other events as well.
- \sa flushWindowSystemEvents(), processWindowSystemEvent(), setSynchronousWindowSystemEvents()
+ \sa flushWindowSystemEvents(), setSynchronousWindowSystemEvents()
*/
template<>
bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterface::DefaultDelivery>(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
@@ -120,6 +136,59 @@ bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterfa
return handleWindowSystemEvent<QWindowSystemInterface::AsynchronousDelivery>(ev);
}
+int QWindowSystemInterfacePrivate::windowSystemEventsQueued()
+{
+ return windowSystemEventQueue.count();
+}
+
+QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate::getWindowSystemEvent()
+{
+ return windowSystemEventQueue.takeFirstOrReturnNull();
+}
+
+QWindowSystemInterfacePrivate::WindowSystemEvent *QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent()
+{
+ return windowSystemEventQueue.takeFirstNonUserInputOrReturnNull();
+}
+
+QWindowSystemInterfacePrivate::WindowSystemEvent *QWindowSystemInterfacePrivate::peekWindowSystemEvent(EventType t)
+{
+ return windowSystemEventQueue.peekAtFirstOfType(t);
+}
+
+void QWindowSystemInterfacePrivate::removeWindowSystemEvent(WindowSystemEvent *event)
+{
+ windowSystemEventQueue.remove(event);
+}
+
+void QWindowSystemInterfacePrivate::installWindowSystemEventHandler(QWindowSystemEventHandler *handler)
+{
+ if (!eventHandler)
+ eventHandler = handler;
+}
+
+void QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(QWindowSystemEventHandler *handler)
+{
+ if (eventHandler == handler)
+ eventHandler = 0;
+}
+
+QWindowSystemEventHandler::~QWindowSystemEventHandler()
+{
+ QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(this);
+}
+
+bool QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
+{
+ QGuiApplicationPrivate::processWindowSystemEvent(e);
+ return true;
+}
+
+//------------------------------------------------------------
+//
+// Callback functions for plugins:
+//
+
#define QT_DEFINE_QPA_EVENT_HANDLER(ReturnType, HandlerName, ...) \
template Q_GUI_EXPORT ReturnType QWindowSystemInterface::HandlerName<QWindowSystemInterface::DefaultDelivery>(__VA_ARGS__); \
template Q_GUI_EXPORT ReturnType QWindowSystemInterface::HandlerName<QWindowSystemInterface::SynchronousDelivery>(__VA_ARGS__); \
@@ -359,6 +428,13 @@ bool QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestam
return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
+QWindowSystemInterfacePrivate::WheelEvent::WheelEvent(QWindow *w, ulong time, const QPointF &local, const QPointF &global, QPoint pixelD,
+ QPoint angleD, int qt4D, Qt::Orientation qt4O, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase, Qt::MouseEventSource src, bool inverted)
+ : InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D),
+ qt4Orientation(qt4O), localPos(local), globalPos(global), phase(phase), source(src), inverted(inverted)
+{
+}
+
void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods) {
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
handleWheelEvent(w, time, local, global, d, o, mods);
@@ -420,97 +496,56 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, con
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
-int QWindowSystemInterfacePrivate::windowSystemEventsQueued()
-{
- return windowSystemEventQueue.count();
-}
-
-QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate::getWindowSystemEvent()
-{
- return windowSystemEventQueue.takeFirstOrReturnNull();
-}
-
-QWindowSystemInterfacePrivate::WindowSystemEvent *QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent()
+void QWindowSystemInterface::registerTouchDevice(const QTouchDevice *device)
{
- return windowSystemEventQueue.takeFirstNonUserInputOrReturnNull();
+ QTouchDevicePrivate::registerDevice(device);
}
-QWindowSystemInterfacePrivate::WindowSystemEvent *QWindowSystemInterfacePrivate::peekWindowSystemEvent(EventType t)
+void QWindowSystemInterface::unregisterTouchDevice(const QTouchDevice *device)
{
- return windowSystemEventQueue.peekAtFirstOfType(t);
+ QTouchDevicePrivate::unregisterDevice(device);
}
-void QWindowSystemInterfacePrivate::removeWindowSystemEvent(WindowSystemEvent *event)
+bool QWindowSystemInterface::isTouchDeviceRegistered(const QTouchDevice *device)
{
- windowSystemEventQueue.remove(event);
+ return QTouchDevicePrivate::isRegistered(device);
}
-/*!
- Posts a window system event to be handled asynchronously by Qt Gui.
-
- This function posts the event on the window system event queue and wakes the
- Gui event dispatcher. Qt Gui will then handle the event asynchonously at a
- later point.
+static int g_nextPointId = 1;
- \sa flushWindowSystemEvents(), processWindowSystemEvent(), handleWindowSystemEvent()
-*/
-void QWindowSystemInterfacePrivate::postWindowSystemEvent(WindowSystemEvent *ev)
-{
- windowSystemEventQueue.append(ev);
- QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher();
- if (dispatcher)
- dispatcher->wakeUp();
-}
+// map from device-independent point id (arbitrary) to "Qt point" ids
+typedef QMap<quint64, int> PointIdMap;
+Q_GLOBAL_STATIC(PointIdMap, g_pointIdMap)
/*!
- Processes a window system event synchronously.
-
- Qt Gui will process the event immediately. The return value indicates if Qt
- accepted the event.
-
- If the event is delivered from another thread than the Qt main thread the
- window system event queue is flushed, which may deliver other events as
- well.
-
- \sa flushWindowSystemEvents(), postWindowSystemEvent(), handleWindowSystemEvent()
+ \internal
+ This function maps potentially arbitrary point ids \a pointId in the 32 bit
+ value space to start from 1 and increase incrementally for each touch point
+ held down. If all touch points are released it will reset the id back to 1
+ for the following touch point.
+
+ We can then assume that the touch points ids will never become too large,
+ and it will then put the device identifier \a deviceId in the upper 8 bits.
+ This leaves us with max 255 devices, and 16.7M taps without full release
+ before we run out of value space.
*/
-bool QWindowSystemInterfacePrivate::processWindowSystemEvent(WindowSystemEvent *ev)
-{
- bool accepted = true;
- if (QThread::currentThread() == QGuiApplication::instance()->thread()) {
- // Process the event immediately on the current thread and return the accepted state.
- QGuiApplicationPrivate::processWindowSystemEvent(ev);
- accepted = ev->eventAccepted;
- delete ev;
+static int acquireCombinedPointId(quint8 deviceId, int pointId)
+{
+ quint64 combinedId64 = (quint64(deviceId) << 32) + pointId;
+ auto it = g_pointIdMap->constFind(combinedId64);
+ int uid;
+ if (it == g_pointIdMap->constEnd()) {
+ uid = g_nextPointId++;
+ g_pointIdMap->insert(combinedId64, uid);
} else {
- // Post the event on the Qt main thread queue and flush the queue.
- // This will wake up the Gui thread which will process the event.
- // Return the accepted state for the last event on the queue,
- // which is the event posted by this function.
- postWindowSystemEvent(ev);
- accepted = QWindowSystemInterface::flushWindowSystemEvents();
+ uid = *it;
}
- return accepted;
-}
-
-void QWindowSystemInterface::registerTouchDevice(const QTouchDevice *device)
-{
- QTouchDevicePrivate::registerDevice(device);
-}
-
-void QWindowSystemInterface::unregisterTouchDevice(const QTouchDevice *device)
-{
- QTouchDevicePrivate::unregisterDevice(device);
-}
-
-bool QWindowSystemInterface::isTouchDeviceRegistered(const QTouchDevice *device)
-{
- return QTouchDevicePrivate::isRegistered(device);
+ return (deviceId << 24) + uid;
}
QList<QTouchEvent::TouchPoint>
QWindowSystemInterfacePrivate::fromNativeTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points,
- const QWindow *window,
+ const QWindow *window, quint8 deviceId,
QEvent::Type *type)
{
QList<QTouchEvent::TouchPoint> touchPoints;
@@ -521,7 +556,7 @@ QList<QTouchEvent::TouchPoint>
QList<QWindowSystemInterface::TouchPoint>::const_iterator point = points.constBegin();
QList<QWindowSystemInterface::TouchPoint>::const_iterator end = points.constEnd();
while (point != end) {
- p.setId(point->id);
+ p.setId(acquireCombinedPointId(deviceId, point->id));
if (point->uniqueId >= 0)
p.setUniqueId(point->uniqueId);
p.setPressure(point->pressure);
@@ -554,6 +589,11 @@ QList<QTouchEvent::TouchPoint>
*type = QEvent::TouchEnd;
}
+ if (states == Qt::TouchPointReleased) {
+ g_nextPointId = 1;
+ g_pointIdMap->clear();
+ }
+
return touchPoints;
}
@@ -595,7 +635,8 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleTouchEvent, QWindow *tlw, ulong timestam
return;
QEvent::Type type;
- QList<QTouchEvent::TouchPoint> touchPoints = QWindowSystemInterfacePrivate::fromNativeTouchPoints(points, tlw, &type);
+ QList<QTouchEvent::TouchPoint> touchPoints =
+ QWindowSystemInterfacePrivate::fromNativeTouchPoints(points, tlw, QTouchDevicePrivate::get(device)->id, &type);
QWindowSystemInterfacePrivate::TouchEvent *e =
new QWindowSystemInterfacePrivate::TouchEvent(tlw, timestamp, type, device, touchPoints, mods);
@@ -652,98 +693,6 @@ void QWindowSystemInterface::handleThemeChange(QWindow *tlw)
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
-void QWindowSystemInterface::deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
-{
- Q_ASSERT(QThread::currentThread() == QGuiApplication::instance()->thread());
-
- QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);
- sendWindowSystemEvents(flags);
- QWindowSystemInterfacePrivate::eventsFlushed.wakeOne();
-}
-
-/*!
- Make Qt Gui process all events on the event queue immediately. Return the
- accepted state for the last event on the queue.
-*/
-bool QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
-{
- const int count = QWindowSystemInterfacePrivate::windowSystemEventQueue.count();
- if (!count)
- return false;
- if (!QGuiApplication::instance()) {
- qWarning().nospace()
- << "QWindowSystemInterface::flushWindowSystemEvents() invoked after "
- "QGuiApplication destruction, discarding " << count << " events.";
- QWindowSystemInterfacePrivate::windowSystemEventQueue.clear();
- return false;
- }
- if (QThread::currentThread() != QGuiApplication::instance()->thread()) {
- // Post a FlushEvents event which will trigger a call back to
- // deferredFlushWindowSystemEvents from the Gui thread.
- QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);
- QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent(flags);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent<AsynchronousDelivery>(e);
- QWindowSystemInterfacePrivate::eventsFlushed.wait(&QWindowSystemInterfacePrivate::flushEventMutex);
- } else {
- sendWindowSystemEvents(flags);
- }
- return QWindowSystemInterfacePrivate::eventAccepted.load() > 0;
-}
-
-bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
-{
- int nevents = 0;
-
- while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) {
- QWindowSystemInterfacePrivate::WindowSystemEvent *event =
- (flags & QEventLoop::ExcludeUserInputEvents) ?
- QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent() :
- QWindowSystemInterfacePrivate::getWindowSystemEvent();
- if (!event)
- break;
-
- if (QWindowSystemInterfacePrivate::eventHandler) {
- if (QWindowSystemInterfacePrivate::eventHandler->sendEvent(event))
- nevents++;
- } else {
- nevents++;
- QGuiApplicationPrivate::processWindowSystemEvent(event);
- }
-
- // Record the accepted state for the processed event
- // (excluding flush events). This state can then be
- // returned by flushWindowSystemEvents().
- if (event->type != QWindowSystemInterfacePrivate::FlushEvents)
- QWindowSystemInterfacePrivate::eventAccepted.store(event->eventAccepted);
-
- delete event;
- }
-
- return (nevents > 0);
-}
-
-void QWindowSystemInterfacePrivate::installWindowSystemEventHandler(QWindowSystemEventHandler *handler)
-{
- if (!eventHandler)
- eventHandler = handler;
-}
-
-void QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(QWindowSystemEventHandler *handler)
-{
- if (eventHandler == handler)
- eventHandler = 0;
-}
-
-void QWindowSystemInterface::setSynchronousWindowSystemEvents(bool enable)
-{
- QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = enable;
-}
-
-int QWindowSystemInterface::windowSystemEventsQueued()
-{
- return QWindowSystemInterfacePrivate::windowSystemEventsQueued();
-}
-
#ifndef QT_NO_DRAGANDDROP
QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions)
{
@@ -780,6 +729,11 @@ void QWindowSystemInterface::handleFileOpenEvent(const QUrl &url)
QGuiApplicationPrivate::processWindowSystemEvent(&e);
}
+void QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(bool v)
+{
+ platformSynthesizesMouse = v;
+}
+
void QWindowSystemInterface::handleTabletEvent(QWindow *w, ulong timestamp, const QPointF &local, const QPointF &global,
int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
qreal tangentialPressure, qreal rotation, int z, qint64 uid,
@@ -915,6 +869,90 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPo
}
#endif
+// ------------------ Event dispatcher functionality ------------------
+
+/*!
+ Make Qt Gui process all events on the event queue immediately. Return the
+ accepted state for the last event on the queue.
+*/
+bool QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
+{
+ const int count = QWindowSystemInterfacePrivate::windowSystemEventQueue.count();
+ if (!count)
+ return false;
+ if (!QGuiApplication::instance()) {
+ qWarning().nospace()
+ << "QWindowSystemInterface::flushWindowSystemEvents() invoked after "
+ "QGuiApplication destruction, discarding " << count << " events.";
+ QWindowSystemInterfacePrivate::windowSystemEventQueue.clear();
+ return false;
+ }
+ if (QThread::currentThread() != QGuiApplication::instance()->thread()) {
+ // Post a FlushEvents event which will trigger a call back to
+ // deferredFlushWindowSystemEvents from the Gui thread.
+ QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);
+ QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent(flags);
+ QWindowSystemInterfacePrivate::handleWindowSystemEvent<AsynchronousDelivery>(e);
+ QWindowSystemInterfacePrivate::eventsFlushed.wait(&QWindowSystemInterfacePrivate::flushEventMutex);
+ } else {
+ sendWindowSystemEvents(flags);
+ }
+ return QWindowSystemInterfacePrivate::eventAccepted.load() > 0;
+}
+
+void QWindowSystemInterface::deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
+{
+ Q_ASSERT(QThread::currentThread() == QGuiApplication::instance()->thread());
+
+ QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);
+ sendWindowSystemEvents(flags);
+ QWindowSystemInterfacePrivate::eventsFlushed.wakeOne();
+}
+
+bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
+{
+ int nevents = 0;
+
+ while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) {
+ QWindowSystemInterfacePrivate::WindowSystemEvent *event =
+ (flags & QEventLoop::ExcludeUserInputEvents) ?
+ QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent() :
+ QWindowSystemInterfacePrivate::getWindowSystemEvent();
+ if (!event)
+ break;
+
+ if (QWindowSystemInterfacePrivate::eventHandler) {
+ if (QWindowSystemInterfacePrivate::eventHandler->sendEvent(event))
+ nevents++;
+ } else {
+ nevents++;
+ QGuiApplicationPrivate::processWindowSystemEvent(event);
+ }
+
+ // Record the accepted state for the processed event
+ // (excluding flush events). This state can then be
+ // returned by flushWindowSystemEvents().
+ if (event->type != QWindowSystemInterfacePrivate::FlushEvents)
+ QWindowSystemInterfacePrivate::eventAccepted.store(event->eventAccepted);
+
+ delete event;
+ }
+
+ return (nevents > 0);
+}
+
+void QWindowSystemInterface::setSynchronousWindowSystemEvents(bool enable)
+{
+ QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = enable;
+}
+
+int QWindowSystemInterface::windowSystemEventsQueued()
+{
+ return QWindowSystemInterfacePrivate::windowSystemEventsQueued();
+}
+
+// --------------------- QtTestLib support ---------------------
+
// The following functions are used by testlib, and need to be synchronous to avoid
// race conditions with plugins delivering native events from secondary threads.
@@ -985,27 +1023,5 @@ Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, w), mods);
}
-QWindowSystemEventHandler::~QWindowSystemEventHandler()
-{
- QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(this);
-}
-
-bool QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
-{
- QGuiApplicationPrivate::processWindowSystemEvent(e);
- return true;
-}
-
-QWindowSystemInterfacePrivate::WheelEvent::WheelEvent(QWindow *w, ulong time, const QPointF &local, const QPointF &global, QPoint pixelD,
- QPoint angleD, int qt4D, Qt::Orientation qt4O, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase, Qt::MouseEventSource src, bool inverted)
- : InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D),
- qt4Orientation(qt4O), localPos(local), globalPos(global), phase(phase), source(src), inverted(inverted)
-{
-}
-
-void QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(bool v)
-{
- platformSynthesizesMouse = v;
-}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 7c9b1f2852..c594369ae5 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -494,10 +494,6 @@ public:
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
static bool handleWindowSystemEvent(WindowSystemEvent *ev);
-private:
- static void postWindowSystemEvent(WindowSystemEvent *ev);
- static bool processWindowSystemEvent(WindowSystemEvent *ev);
-
public:
static QElapsedTimer eventTime;
static bool synchronousWindowSystemEvents;
@@ -508,7 +504,7 @@ public:
static QList<QTouchEvent::TouchPoint>
fromNativeTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points,
- const QWindow *window, QEvent::Type *type = Q_NULLPTR);
+ const QWindow *window, quint8 deviceId, QEvent::Type *type = Q_NULLPTR);
static QList<QWindowSystemInterface::TouchPoint>
toNativeTouchPoints(const QList<QTouchEvent::TouchPoint>& pointList,
const QWindow *window);
diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp
index eb08492254..e61473cb7b 100644
--- a/src/gui/opengl/qopengl.cpp
+++ b/src/gui/opengl/qopengl.cpp
@@ -42,6 +42,7 @@
#include "qopenglcontext.h"
#include "qopenglfunctions.h"
+#include "qoperatingsystemversion.h"
#include "qoffscreensurface.h"
#include <QtCore/QDebug>
@@ -221,29 +222,25 @@ struct OsTypeTerm
static QString hostOsRelease() {
QString ver;
#ifdef Q_OS_WIN
- switch (QSysInfo::windowsVersion()) {
- case QSysInfo::WV_XP:
- case QSysInfo::WV_2003:
- ver = QStringLiteral("xp");
- break;
- case QSysInfo::WV_VISTA:
- ver = QStringLiteral("vista");
- break;
- case QSysInfo::WV_WINDOWS7:
+ const auto osver = QOperatingSystemVersion::current();
+#define Q_WINVER(major, minor) (major << 8 | minor)
+ switch (Q_WINVER(osver.majorVersion(), osver.minorVersion())) {
+ case Q_WINVER(6, 1):
ver = QStringLiteral("7");
break;
- case QSysInfo::WV_WINDOWS8:
+ case Q_WINVER(6, 2):
ver = QStringLiteral("8");
break;
- case QSysInfo::WV_WINDOWS8_1:
+ case Q_WINVER(6, 3):
ver = QStringLiteral("8.1");
break;
- case QSysInfo::WV_WINDOWS10:
+ case Q_WINVER(10, 0):
ver = QStringLiteral("10");
break;
default:
break;
}
+#undef Q_WINVER
#endif
return ver;
}
diff --git a/src/gui/opengl/qopenglfunctions.h b/src/gui/opengl/qopenglfunctions.h
index aad48571b3..f1a717f659 100644
--- a/src/gui/opengl/qopenglfunctions.h
+++ b/src/gui/opengl/qopenglfunctions.h
@@ -591,499 +591,319 @@ struct QOpenGLFunctionsPrivate
inline void QOpenGLFunctions::glBindTexture(GLenum target, GLuint texture)
{
-#ifdef QT_OPENGL_ES_2
- ::glBindTexture(target, texture);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BindTexture(target, texture);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glBlendFunc(GLenum sfactor, GLenum dfactor)
{
-#ifdef QT_OPENGL_ES_2
- ::glBlendFunc(sfactor, dfactor);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BlendFunc(sfactor, dfactor);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glClear(GLbitfield mask)
{
-#ifdef QT_OPENGL_ES_2
- ::glClear(mask);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Clear(mask);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
{
-#ifdef QT_OPENGL_ES_2
- ::glClearColor(red, green, blue, alpha);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.ClearColor(red, green, blue, alpha);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glClearStencil(GLint s)
{
-#ifdef QT_OPENGL_ES_2
- ::glClearStencil(s);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.ClearStencil(s);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
{
-#ifdef QT_OPENGL_ES_2
- ::glColorMask(red, green, blue, alpha);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.ColorMask(red, green, blue, alpha);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
{
-#ifdef QT_OPENGL_ES_2
- ::glCopyTexImage2D(target, level, internalformat, x, y, width,height, border);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.CopyTexImage2D(target, level, internalformat, x, y, width,height, border);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
{
-#ifdef QT_OPENGL_ES_2
- ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glCullFace(GLenum mode)
{
-#ifdef QT_OPENGL_ES_2
- ::glCullFace(mode);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.CullFace(mode);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDeleteTextures(GLsizei n, const GLuint* textures)
{
-#ifdef QT_OPENGL_ES_2
- ::glDeleteTextures(n, textures);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DeleteTextures(n, textures);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDepthFunc(GLenum func)
{
-#ifdef QT_OPENGL_ES_2
- ::glDepthFunc(func);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DepthFunc(func);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDepthMask(GLboolean flag)
{
-#ifdef QT_OPENGL_ES_2
- ::glDepthMask(flag);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DepthMask(flag);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDisable(GLenum cap)
{
-#ifdef QT_OPENGL_ES_2
- ::glDisable(cap);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Disable(cap);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDrawArrays(GLenum mode, GLint first, GLsizei count)
{
-#ifdef QT_OPENGL_ES_2
- ::glDrawArrays(mode, first, count);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DrawArrays(mode, first, count);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
{
-#ifdef QT_OPENGL_ES_2
- ::glDrawElements(mode, count, type, indices);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DrawElements(mode, count, type, indices);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glEnable(GLenum cap)
{
-#ifdef QT_OPENGL_ES_2
- ::glEnable(cap);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Enable(cap);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glFinish()
{
-#ifdef QT_OPENGL_ES_2
- ::glFinish();
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Finish();
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glFlush()
{
-#ifdef QT_OPENGL_ES_2
- ::glFlush();
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Flush();
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glFrontFace(GLenum mode)
{
-#ifdef QT_OPENGL_ES_2
- ::glFrontFace(mode);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.FrontFace(mode);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGenTextures(GLsizei n, GLuint* textures)
{
-#ifdef QT_OPENGL_ES_2
- ::glGenTextures(n, textures);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GenTextures(n, textures);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetBooleanv(GLenum pname, GLboolean* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetBooleanv(pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetBooleanv(pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline GLenum QOpenGLFunctions::glGetError()
{
-#ifdef QT_OPENGL_ES_2
- GLenum result = ::glGetError();
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLenum result = d_ptr->f.GetError();
-#endif
return result;
}
inline void QOpenGLFunctions::glGetFloatv(GLenum pname, GLfloat* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetFloatv(pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetFloatv(pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetIntegerv(GLenum pname, GLint* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetIntegerv(pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetIntegerv(pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline const GLubyte *QOpenGLFunctions::glGetString(GLenum name)
{
-#ifdef QT_OPENGL_ES_2
- const GLubyte *result = ::glGetString(name);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
const GLubyte *result = d_ptr->f.GetString(name);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline void QOpenGLFunctions::glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetTexParameterfv(target, pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetTexParameterfv(target, pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetTexParameteriv(target, pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetTexParameteriv(target, pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glHint(GLenum target, GLenum mode)
{
-#ifdef QT_OPENGL_ES_2
- ::glHint(target, mode);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Hint(target, mode);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline GLboolean QOpenGLFunctions::glIsEnabled(GLenum cap)
{
-#ifdef QT_OPENGL_ES_2
- GLboolean result = ::glIsEnabled(cap);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLboolean result = d_ptr->f.IsEnabled(cap);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline GLboolean QOpenGLFunctions::glIsTexture(GLuint texture)
{
-#ifdef QT_OPENGL_ES_2
- GLboolean result = ::glIsTexture(texture);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLboolean result = d_ptr->f.IsTexture(texture);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline void QOpenGLFunctions::glLineWidth(GLfloat width)
{
-#ifdef QT_OPENGL_ES_2
- ::glLineWidth(width);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.LineWidth(width);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glPixelStorei(GLenum pname, GLint param)
{
-#ifdef QT_OPENGL_ES_2
- ::glPixelStorei(pname, param);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.PixelStorei(pname, param);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glPolygonOffset(GLfloat factor, GLfloat units)
{
-#ifdef QT_OPENGL_ES_2
- ::glPolygonOffset(factor, units);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.PolygonOffset(factor, units);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
{
-#ifdef QT_OPENGL_ES_2
- ::glReadPixels(x, y, width, height, format, type, pixels);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.ReadPixels(x, y, width, height, format, type, pixels);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
{
-#ifdef QT_OPENGL_ES_2
- ::glScissor(x, y, width, height);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Scissor(x, y, width, height);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glStencilFunc(GLenum func, GLint ref, GLuint mask)
{
-#ifdef QT_OPENGL_ES_2
- ::glStencilFunc(func, ref, mask);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.StencilFunc(func, ref, mask);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glStencilMask(GLuint mask)
{
-#ifdef QT_OPENGL_ES_2
- ::glStencilMask(mask);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.StencilMask(mask);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
{
-#ifdef QT_OPENGL_ES_2
- ::glStencilOp(fail, zfail, zpass);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.StencilOp(fail, zfail, zpass);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
{
-#ifdef QT_OPENGL_ES_2
- ::glTexImage2D(target, level, internalformat, width,height, border, format, type, pixels);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.TexImage2D(target, level, internalformat, width,height, border, format, type, pixels);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glTexParameterf(GLenum target, GLenum pname, GLfloat param)
{
-#ifdef QT_OPENGL_ES_2
- ::glTexParameterf(target, pname, param);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.TexParameterf(target, pname, param);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glTexParameterfv(target, pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.TexParameterfv(target, pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glTexParameteri(GLenum target, GLenum pname, GLint param)
{
-#ifdef QT_OPENGL_ES_2
- ::glTexParameteri(target, pname, param);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.TexParameteri(target, pname, param);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glTexParameteriv(target, pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.TexParameteriv(target, pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels)
{
-#ifdef QT_OPENGL_ES_2
- ::glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.TexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
{
-#ifdef QT_OPENGL_ES_2
- ::glViewport(x, y, width, height);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Viewport(x, y, width, height);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
@@ -1091,45 +911,29 @@ inline void QOpenGLFunctions::glViewport(GLint x, GLint y, GLsizei width, GLsize
inline void QOpenGLFunctions::glActiveTexture(GLenum texture)
{
-#ifdef QT_OPENGL_ES_2
- ::glActiveTexture(texture);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.ActiveTexture(texture);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glAttachShader(GLuint program, GLuint shader)
{
-#ifdef QT_OPENGL_ES_2
- ::glAttachShader(program, shader);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.AttachShader(program, shader);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glBindAttribLocation(GLuint program, GLuint index, const char* name)
{
-#ifdef QT_OPENGL_ES_2
- ::glBindAttribLocation(program, index, name);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BindAttribLocation(program, index, name);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glBindBuffer(GLenum target, GLuint buffer)
{
-#ifdef QT_OPENGL_ES_2
- ::glBindBuffer(target, buffer);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BindBuffer(target, buffer);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
@@ -1137,1034 +941,662 @@ inline void QOpenGLFunctions::glBindFramebuffer(GLenum target, GLuint framebuffe
{
if (framebuffer == 0)
framebuffer = QOpenGLContext::currentContext()->defaultFramebufferObject();
-#ifdef QT_OPENGL_ES_2
- ::glBindFramebuffer(target, framebuffer);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BindFramebuffer(target, framebuffer);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glBindRenderbuffer(GLenum target, GLuint renderbuffer)
{
-#ifdef QT_OPENGL_ES_2
- ::glBindRenderbuffer(target, renderbuffer);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BindRenderbuffer(target, renderbuffer);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
{
-#ifdef QT_OPENGL_ES_2
- ::glBlendColor(red, green, blue, alpha);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BlendColor(red, green, blue, alpha);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glBlendEquation(GLenum mode)
{
-#ifdef QT_OPENGL_ES_2
- ::glBlendEquation(mode);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BlendEquation(mode);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
{
-#ifdef QT_OPENGL_ES_2
- ::glBlendEquationSeparate(modeRGB, modeAlpha);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BlendEquationSeparate(modeRGB, modeAlpha);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
{
-#ifdef QT_OPENGL_ES_2
- ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glBufferData(GLenum target, qopengl_GLsizeiptr size, const void* data, GLenum usage)
{
-#ifdef QT_OPENGL_ES_2
- ::glBufferData(target, size, data, usage);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BufferData(target, size, data, usage);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, const void* data)
{
-#ifdef QT_OPENGL_ES_2
- ::glBufferSubData(target, offset, size, data);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.BufferSubData(target, offset, size, data);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline GLenum QOpenGLFunctions::glCheckFramebufferStatus(GLenum target)
{
-#ifdef QT_OPENGL_ES_2
- GLenum result = ::glCheckFramebufferStatus(target);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLenum result = d_ptr->f.CheckFramebufferStatus(target);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline void QOpenGLFunctions::glClearDepthf(GLclampf depth)
{
-#ifndef QT_OPENGL_ES
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.ClearDepthf(depth);
-#else
- ::glClearDepthf(depth);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glCompileShader(GLuint shader)
{
-#ifdef QT_OPENGL_ES_2
- ::glCompileShader(shader);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.CompileShader(shader);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
{
-#ifdef QT_OPENGL_ES_2
- ::glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.CompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
{
-#ifdef QT_OPENGL_ES_2
- ::glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.CompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline GLuint QOpenGLFunctions::glCreateProgram()
{
-#ifdef QT_OPENGL_ES_2
- GLuint result = ::glCreateProgram();
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLuint result = d_ptr->f.CreateProgram();
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline GLuint QOpenGLFunctions::glCreateShader(GLenum type)
{
-#ifdef QT_OPENGL_ES_2
- GLuint result = ::glCreateShader(type);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLuint result = d_ptr->f.CreateShader(type);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline void QOpenGLFunctions::glDeleteBuffers(GLsizei n, const GLuint* buffers)
{
-#ifdef QT_OPENGL_ES_2
- ::glDeleteBuffers(n, buffers);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DeleteBuffers(n, buffers);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
{
-#ifdef QT_OPENGL_ES_2
- ::glDeleteFramebuffers(n, framebuffers);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DeleteFramebuffers(n, framebuffers);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDeleteProgram(GLuint program)
{
-#ifdef QT_OPENGL_ES_2
- ::glDeleteProgram(program);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DeleteProgram(program);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
{
-#ifdef QT_OPENGL_ES_2
- ::glDeleteRenderbuffers(n, renderbuffers);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DeleteRenderbuffers(n, renderbuffers);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDeleteShader(GLuint shader)
{
-#ifdef QT_OPENGL_ES_2
- ::glDeleteShader(shader);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DeleteShader(shader);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDepthRangef(GLclampf zNear, GLclampf zFar)
{
-#ifndef QT_OPENGL_ES
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DepthRangef(zNear, zFar);
-#else
- ::glDepthRangef(zNear, zFar);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDetachShader(GLuint program, GLuint shader)
{
-#ifdef QT_OPENGL_ES_2
- ::glDetachShader(program, shader);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DetachShader(program, shader);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glDisableVertexAttribArray(GLuint index)
{
-#ifdef QT_OPENGL_ES_2
- ::glDisableVertexAttribArray(index);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.DisableVertexAttribArray(index);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glEnableVertexAttribArray(GLuint index)
{
-#ifdef QT_OPENGL_ES_2
- ::glEnableVertexAttribArray(index);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.EnableVertexAttribArray(index);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
{
-#ifdef QT_OPENGL_ES_2
- ::glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.FramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
{
-#ifdef QT_OPENGL_ES_2
- ::glFramebufferTexture2D(target, attachment, textarget, texture, level);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.FramebufferTexture2D(target, attachment, textarget, texture, level);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGenBuffers(GLsizei n, GLuint* buffers)
{
-#ifdef QT_OPENGL_ES_2
- ::glGenBuffers(n, buffers);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GenBuffers(n, buffers);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGenerateMipmap(GLenum target)
{
-#ifdef QT_OPENGL_ES_2
- ::glGenerateMipmap(target);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GenerateMipmap(target);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGenFramebuffers(GLsizei n, GLuint* framebuffers)
{
-#ifdef QT_OPENGL_ES_2
- ::glGenFramebuffers(n, framebuffers);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GenFramebuffers(n, framebuffers);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
{
-#ifdef QT_OPENGL_ES_2
- ::glGenRenderbuffers(n, renderbuffers);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GenRenderbuffers(n, renderbuffers);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetActiveAttrib(program, index, bufsize, length, size, type, name);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetActiveAttrib(program, index, bufsize, length, size, type, name);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetActiveUniform(program, index, bufsize, length, size, type, name);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetActiveUniform(program, index, bufsize, length, size, type, name);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetAttachedShaders(program, maxcount, count, shaders);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetAttachedShaders(program, maxcount, count, shaders);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline GLint QOpenGLFunctions::glGetAttribLocation(GLuint program, const char* name)
{
-#ifdef QT_OPENGL_ES_2
- GLint result = ::glGetAttribLocation(program, name);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLint result = d_ptr->f.GetAttribLocation(program, name);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline void QOpenGLFunctions::glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetBufferParameteriv(target, pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetBufferParameteriv(target, pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetFramebufferAttachmentParameteriv(target, attachment, pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetProgramiv(GLuint program, GLenum pname, GLint* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetProgramiv(program, pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetProgramiv(program, pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetProgramInfoLog(program, bufsize, length, infolog);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetProgramInfoLog(program, bufsize, length, infolog);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetRenderbufferParameteriv(target, pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetRenderbufferParameteriv(target, pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetShaderiv(shader, pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetShaderiv(shader, pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetShaderInfoLog(shader, bufsize, length, infolog);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetShaderInfoLog(shader, bufsize, length, infolog);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetShaderSource(shader, bufsize, length, source);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetShaderSource(shader, bufsize, length, source);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetUniformfv(GLuint program, GLint location, GLfloat* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetUniformfv(program, location, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetUniformfv(program, location, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetUniformiv(GLuint program, GLint location, GLint* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetUniformiv(program, location, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetUniformiv(program, location, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline GLint QOpenGLFunctions::glGetUniformLocation(GLuint program, const char* name)
{
-#ifdef QT_OPENGL_ES_2
- GLint result = ::glGetUniformLocation(program, name);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLint result = d_ptr->f.GetUniformLocation(program, name);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline void QOpenGLFunctions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetVertexAttribfv(index, pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetVertexAttribfv(index, pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetVertexAttribiv(index, pname, params);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetVertexAttribiv(index, pname, params);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
{
-#ifdef QT_OPENGL_ES_2
- ::glGetVertexAttribPointerv(index, pname, pointer);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.GetVertexAttribPointerv(index, pname, pointer);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline GLboolean QOpenGLFunctions::glIsBuffer(GLuint buffer)
{
-#ifdef QT_OPENGL_ES_2
- GLboolean result = ::glIsBuffer(buffer);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLboolean result = d_ptr->f.IsBuffer(buffer);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline GLboolean QOpenGLFunctions::glIsFramebuffer(GLuint framebuffer)
{
-#ifdef QT_OPENGL_ES_2
- GLboolean result = ::glIsFramebuffer(framebuffer);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLboolean result = d_ptr->f.IsFramebuffer(framebuffer);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline GLboolean QOpenGLFunctions::glIsProgram(GLuint program)
{
-#ifdef QT_OPENGL_ES_2
- GLboolean result = ::glIsProgram(program);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLboolean result = d_ptr->f.IsProgram(program);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline GLboolean QOpenGLFunctions::glIsRenderbuffer(GLuint renderbuffer)
{
-#ifdef QT_OPENGL_ES_2
- GLboolean result = ::glIsRenderbuffer(renderbuffer);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLboolean result = d_ptr->f.IsRenderbuffer(renderbuffer);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline GLboolean QOpenGLFunctions::glIsShader(GLuint shader)
{
-#ifdef QT_OPENGL_ES_2
- GLboolean result = ::glIsShader(shader);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
GLboolean result = d_ptr->f.IsShader(shader);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
return result;
}
inline void QOpenGLFunctions::glLinkProgram(GLuint program)
{
-#ifdef QT_OPENGL_ES_2
- ::glLinkProgram(program);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.LinkProgram(program);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glReleaseShaderCompiler()
{
-#ifdef QT_OPENGL_ES_2
- ::glReleaseShaderCompiler();
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.ReleaseShaderCompiler();
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
{
-#ifdef QT_OPENGL_ES_2
- ::glRenderbufferStorage(target, internalformat, width, height);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.RenderbufferStorage(target, internalformat, width, height);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glSampleCoverage(GLclampf value, GLboolean invert)
{
-#ifdef QT_OPENGL_ES_2
- ::glSampleCoverage(value, invert);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.SampleCoverage(value, invert);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length)
{
-#ifdef QT_OPENGL_ES_2
- ::glShaderBinary(n, shaders, binaryformat, binary, length);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.ShaderBinary(n, shaders, binaryformat, binary, length);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
{
-#ifdef QT_OPENGL_ES_2
- ::glShaderSource(shader, count, string, length);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.ShaderSource(shader, count, string, length);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
{
-#ifdef QT_OPENGL_ES_2
- ::glStencilFuncSeparate(face, func, ref, mask);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.StencilFuncSeparate(face, func, ref, mask);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glStencilMaskSeparate(GLenum face, GLuint mask)
{
-#ifdef QT_OPENGL_ES_2
- ::glStencilMaskSeparate(face, mask);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.StencilMaskSeparate(face, mask);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
{
-#ifdef QT_OPENGL_ES_2
- ::glStencilOpSeparate(face, fail, zfail, zpass);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.StencilOpSeparate(face, fail, zfail, zpass);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform1f(GLint location, GLfloat x)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform1f(location, x);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform1f(location, x);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform1fv(location, count, v);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform1fv(location, count, v);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform1i(GLint location, GLint x)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform1i(location, x);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform1i(location, x);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform1iv(GLint location, GLsizei count, const GLint* v)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform1iv(location, count, v);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform1iv(location, count, v);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform2f(GLint location, GLfloat x, GLfloat y)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform2f(location, x, y);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform2f(location, x, y);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform2fv(location, count, v);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform2fv(location, count, v);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform2i(GLint location, GLint x, GLint y)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform2i(location, x, y);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform2i(location, x, y);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform2iv(GLint location, GLsizei count, const GLint* v)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform2iv(location, count, v);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform2iv(location, count, v);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform3f(location, x, y, z);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform3f(location, x, y, z);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform3fv(location, count, v);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform3fv(location, count, v);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform3i(GLint location, GLint x, GLint y, GLint z)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform3i(location, x, y, z);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform3i(location, x, y, z);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform3iv(GLint location, GLsizei count, const GLint* v)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform3iv(location, count, v);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform3iv(location, count, v);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform4f(location, x, y, z, w);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform4f(location, x, y, z, w);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform4fv(location, count, v);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform4fv(location, count, v);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform4i(location, x, y, z, w);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform4i(location, x, y, z, w);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniform4iv(GLint location, GLsizei count, const GLint* v)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniform4iv(location, count, v);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.Uniform4iv(location, count, v);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniformMatrix2fv(location, count, transpose, value);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.UniformMatrix2fv(location, count, transpose, value);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniformMatrix3fv(location, count, transpose, value);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.UniformMatrix3fv(location, count, transpose, value);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
-#ifdef QT_OPENGL_ES_2
- ::glUniformMatrix4fv(location, count, transpose, value);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.UniformMatrix4fv(location, count, transpose, value);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glUseProgram(GLuint program)
{
-#ifdef QT_OPENGL_ES_2
- ::glUseProgram(program);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.UseProgram(program);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glValidateProgram(GLuint program)
{
-#ifdef QT_OPENGL_ES_2
- ::glValidateProgram(program);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.ValidateProgram(program);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glVertexAttrib1f(GLuint indx, GLfloat x)
{
-#ifdef QT_OPENGL_ES_2
- ::glVertexAttrib1f(indx, x);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.VertexAttrib1f(indx, x);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glVertexAttrib1fv(GLuint indx, const GLfloat* values)
{
-#ifdef QT_OPENGL_ES_2
- ::glVertexAttrib1fv(indx, values);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.VertexAttrib1fv(indx, values);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
{
-#ifdef QT_OPENGL_ES_2
- ::glVertexAttrib2f(indx, x, y);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.VertexAttrib2f(indx, x, y);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glVertexAttrib2fv(GLuint indx, const GLfloat* values)
{
-#ifdef QT_OPENGL_ES_2
- ::glVertexAttrib2fv(indx, values);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.VertexAttrib2fv(indx, values);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
{
-#ifdef QT_OPENGL_ES_2
- ::glVertexAttrib3f(indx, x, y, z);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.VertexAttrib3f(indx, x, y, z);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glVertexAttrib3fv(GLuint indx, const GLfloat* values)
{
-#ifdef QT_OPENGL_ES_2
- ::glVertexAttrib3fv(indx, values);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.VertexAttrib3fv(indx, values);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
-#ifdef QT_OPENGL_ES_2
- ::glVertexAttrib4f(indx, x, y, z, w);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.VertexAttrib4f(indx, x, y, z, w);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glVertexAttrib4fv(GLuint indx, const GLfloat* values)
{
-#ifdef QT_OPENGL_ES_2
- ::glVertexAttrib4fv(indx, values);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.VertexAttrib4fv(indx, values);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
inline void QOpenGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
{
-#ifdef QT_OPENGL_ES_2
- ::glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
-#else
Q_ASSERT(QOpenGLFunctions::isInitialized(d_ptr));
d_ptr->f.VertexAttribPointer(indx, size, type, normalized, stride, ptr);
-#endif
Q_OPENGL_FUNCTIONS_DEBUG
}
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
index cd582c5285..b92d97c143 100644
--- a/src/gui/opengl/qopenglshaderprogram.cpp
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
@@ -162,6 +162,79 @@ QT_BEGIN_NAMESPACE
based on the core feature (requires OpenGL >= 4.3).
*/
+
+// For GLES 3.1/3.2
+#ifndef GL_GEOMETRY_SHADER
+#define GL_GEOMETRY_SHADER 0x8DD9
+#endif
+#ifndef GL_TESS_CONTROL_SHADER
+#define GL_TESS_CONTROL_SHADER 0x8E88
+#endif
+#ifndef GL_TESS_EVALUATION_SHADER
+#define GL_TESS_EVALUATION_SHADER 0x8E87
+#endif
+#ifndef GL_COMPUTE_SHADER
+#define GL_COMPUTE_SHADER 0x91B9
+#endif
+#ifndef GL_MAX_GEOMETRY_OUTPUT_VERTICES
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
+#endif
+#ifndef GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
+#endif
+#ifndef GL_PATCH_VERTICES
+#define GL_PATCH_VERTICES 0x8E72
+#endif
+#ifndef GL_PATCH_DEFAULT_OUTER_LEVEL
+#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74
+#endif
+#ifndef GL_PATCH_DEFAULT_INNER_LEVEL
+#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73
+#endif
+
+static inline bool isFormatGLES(const QSurfaceFormat &f)
+{
+ return (f.renderableType() == QSurfaceFormat::OpenGLES);
+}
+
+static inline bool supportsGeometry(const QSurfaceFormat &f)
+{
+#ifndef QT_OPENGL_ES_2
+ if (!isFormatGLES(f))
+ return (f.version() >= qMakePair<int, int>(3, 2));
+ else
+ return false;
+#else
+ Q_UNUSED(f);
+ return false;
+#endif
+}
+
+static inline bool supportsCompute(const QSurfaceFormat &f)
+{
+#ifndef QT_OPENGL_ES_2
+ if (!isFormatGLES(f))
+ return (f.version() >= qMakePair<int, int>(4, 3));
+ else
+ return (f.version() >= qMakePair<int, int>(3, 1));
+#else
+ return (f.version() >= qMakePair<int, int>(3, 1));
+#endif
+}
+
+static inline bool supportsTessellation(const QSurfaceFormat &f)
+{
+#ifndef QT_OPENGL_ES_2
+ if (!isFormatGLES(f))
+ return (f.version() >= qMakePair<int, int>(4, 0));
+ else
+ return false;
+#else
+ Q_UNUSED(f);
+ return false;
+#endif
+}
+
class QOpenGLShaderPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QOpenGLShader)
@@ -171,22 +244,16 @@ public:
, shaderType(type)
, compiled(false)
, glfuncs(new QOpenGLFunctions(ctx))
-#ifndef QT_OPENGL_ES_2
, supportsGeometryShaders(false)
, supportsTessellationShaders(false)
-#endif
+ , supportsComputeShaders(false)
{
-#ifndef QT_OPENGL_ES_2
- if (!ctx->isOpenGLES()) {
- QSurfaceFormat f = ctx->format();
-
- // Geometry shaders require OpenGL >= 3.2
- if (shaderType & QOpenGLShader::Geometry)
- supportsGeometryShaders = (f.version() >= qMakePair<int, int>(3, 2));
- else if (shaderType & (QOpenGLShader::TessellationControl | QOpenGLShader::TessellationEvaluation))
- supportsTessellationShaders = (f.version() >= qMakePair<int, int>(4, 0));
- }
-#endif
+ if (shaderType & QOpenGLShader::Geometry)
+ supportsGeometryShaders = supportsGeometry(ctx->format());
+ else if (shaderType & (QOpenGLShader::TessellationControl | QOpenGLShader::TessellationEvaluation))
+ supportsTessellationShaders = supportsTessellation(ctx->format());
+ else if (shaderType & QOpenGLShader::Compute)
+ supportsComputeShaders = supportsCompute(ctx->format());
}
~QOpenGLShaderPrivate();
@@ -197,13 +264,13 @@ public:
QOpenGLFunctions *glfuncs;
-#ifndef QT_OPENGL_ES_2
// Support for geometry shaders
bool supportsGeometryShaders;
-
// Support for tessellation shaders
bool supportsTessellationShaders;
-#endif
+ // Support for compute shaders
+ bool supportsComputeShaders;
+
bool create();
bool compile(QOpenGLShader *q);
@@ -229,24 +296,18 @@ bool QOpenGLShaderPrivate::create()
QOpenGLContext *context = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());
if (!context)
return false;
- GLuint shader;
+ GLuint shader = 0;
if (shaderType == QOpenGLShader::Vertex) {
shader = glfuncs->glCreateShader(GL_VERTEX_SHADER);
-#if defined(QT_OPENGL_3_2)
} else if (shaderType == QOpenGLShader::Geometry && supportsGeometryShaders) {
shader = glfuncs->glCreateShader(GL_GEOMETRY_SHADER);
-#endif
-#if defined(QT_OPENGL_4)
} else if (shaderType == QOpenGLShader::TessellationControl && supportsTessellationShaders) {
shader = glfuncs->glCreateShader(GL_TESS_CONTROL_SHADER);
} else if (shaderType == QOpenGLShader::TessellationEvaluation && supportsTessellationShaders) {
shader = glfuncs->glCreateShader(GL_TESS_EVALUATION_SHADER);
-#endif
-#if defined(QT_OPENGL_4_3)
- } else if (shaderType == QOpenGLShader::Compute) {
+ } else if (shaderType == QOpenGLShader::Compute && supportsComputeShaders) {
shader = glfuncs->glCreateShader(GL_COMPUTE_SHADER);
-#endif
- } else {
+ } else if (shaderType == QOpenGLShader::Fragment) {
shader = glfuncs->glCreateShader(GL_FRAGMENT_SHADER);
}
if (!shader) {
@@ -3230,10 +3291,8 @@ void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4
int QOpenGLShaderProgram::maxGeometryOutputVertices() const
{
GLint n = 0;
-#if defined(QT_OPENGL_3_2)
Q_D(const QOpenGLShaderProgram);
d->glfuncs->glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, &n);
-#endif
return n;
}
@@ -3257,7 +3316,7 @@ int QOpenGLShaderProgram::maxGeometryOutputVertices() const
*/
void QOpenGLShaderProgram::setPatchVertexCount(int count)
{
-#if defined(QT_OPENGL_4)
+#ifndef QT_OPENGL_ES_2
Q_D(QOpenGLShaderProgram);
if (d->tessellationFuncs)
d->tessellationFuncs->glPatchParameteri(GL_PATCH_VERTICES, count);
@@ -3276,13 +3335,15 @@ void QOpenGLShaderProgram::setPatchVertexCount(int count)
*/
int QOpenGLShaderProgram::patchVertexCount() const
{
+#ifndef QT_OPENGL_ES_2
int patchVertices = 0;
-#if defined(QT_OPENGL_4)
Q_D(const QOpenGLShaderProgram);
if (d->tessellationFuncs)
d->tessellationFuncs->glGetIntegerv(GL_PATCH_VERTICES, &patchVertices);
-#endif
return patchVertices;
+#else
+ return 0;
+#endif
}
/*!
@@ -3304,21 +3365,21 @@ int QOpenGLShaderProgram::patchVertexCount() const
*/
void QOpenGLShaderProgram::setDefaultOuterTessellationLevels(const QVector<float> &levels)
{
-#if defined(QT_OPENGL_4)
- QVector<float> tessLevels = levels;
-
- // Ensure we have the required 4 outer tessellation levels
- // Use default of 1 for missing entries (same as spec)
- const int argCount = 4;
- if (tessLevels.size() < argCount) {
- tessLevels.reserve(argCount);
- for (int i = tessLevels.size(); i < argCount; ++i)
- tessLevels.append(1.0f);
- }
-
+#ifndef QT_OPENGL_ES_2
Q_D(QOpenGLShaderProgram);
- if (d->tessellationFuncs)
+ if (d->tessellationFuncs) {
+ QVector<float> tessLevels = levels;
+
+ // Ensure we have the required 4 outer tessellation levels
+ // Use default of 1 for missing entries (same as spec)
+ const int argCount = 4;
+ if (tessLevels.size() < argCount) {
+ tessLevels.reserve(argCount);
+ for (int i = tessLevels.size(); i < argCount; ++i)
+ tessLevels.append(1.0f);
+ }
d->tessellationFuncs->glPatchParameterfv(GL_PATCH_DEFAULT_OUTER_LEVEL, tessLevels.data());
+ }
#else
Q_UNUSED(levels);
#endif
@@ -3341,13 +3402,15 @@ void QOpenGLShaderProgram::setDefaultOuterTessellationLevels(const QVector<float
*/
QVector<float> QOpenGLShaderProgram::defaultOuterTessellationLevels() const
{
+#ifndef QT_OPENGL_ES_2
QVector<float> tessLevels(4, 1.0f);
-#if defined(QT_OPENGL_4)
Q_D(const QOpenGLShaderProgram);
if (d->tessellationFuncs)
d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_OUTER_LEVEL, tessLevels.data());
-#endif
return tessLevels;
+#else
+ return QVector<float>();
+#endif
}
/*!
@@ -3369,21 +3432,21 @@ QVector<float> QOpenGLShaderProgram::defaultOuterTessellationLevels() const
*/
void QOpenGLShaderProgram::setDefaultInnerTessellationLevels(const QVector<float> &levels)
{
-#if defined(QT_OPENGL_4)
- QVector<float> tessLevels = levels;
-
- // Ensure we have the required 2 inner tessellation levels
- // Use default of 1 for missing entries (same as spec)
- const int argCount = 2;
- if (tessLevels.size() < argCount) {
- tessLevels.reserve(argCount);
- for (int i = tessLevels.size(); i < argCount; ++i)
- tessLevels.append(1.0f);
- }
-
+#ifndef QT_OPENGL_ES_2
Q_D(QOpenGLShaderProgram);
- if (d->tessellationFuncs)
+ if (d->tessellationFuncs) {
+ QVector<float> tessLevels = levels;
+
+ // Ensure we have the required 2 inner tessellation levels
+ // Use default of 1 for missing entries (same as spec)
+ const int argCount = 2;
+ if (tessLevels.size() < argCount) {
+ tessLevels.reserve(argCount);
+ for (int i = tessLevels.size(); i < argCount; ++i)
+ tessLevels.append(1.0f);
+ }
d->tessellationFuncs->glPatchParameterfv(GL_PATCH_DEFAULT_INNER_LEVEL, tessLevels.data());
+ }
#else
Q_UNUSED(levels);
#endif
@@ -3406,13 +3469,15 @@ void QOpenGLShaderProgram::setDefaultInnerTessellationLevels(const QVector<float
*/
QVector<float> QOpenGLShaderProgram::defaultInnerTessellationLevels() const
{
+#ifndef QT_OPENGL_ES_2
QVector<float> tessLevels(2, 1.0f);
-#if defined(QT_OPENGL_4)
Q_D(const QOpenGLShaderProgram);
if (d->tessellationFuncs)
d->tessellationFuncs->glGetFloatv(GL_PATCH_DEFAULT_INNER_LEVEL, tessLevels.data());
-#endif
return tessLevels;
+#else
+ return QVector<float>();
+#endif
}
@@ -3425,16 +3490,11 @@ QVector<float> QOpenGLShaderProgram::defaultInnerTessellationLevels() const
*/
bool QOpenGLShaderProgram::hasOpenGLShaderPrograms(QOpenGLContext *context)
{
-#if !defined(QT_OPENGL_ES_2)
if (!context)
context = QOpenGLContext::currentContext();
if (!context)
return false;
return QOpenGLFunctions(context).hasOpenGLFeature(QOpenGLFunctions::Shaders);
-#else
- Q_UNUSED(context);
- return true;
-#endif
}
/*!
@@ -3465,33 +3525,12 @@ bool QOpenGLShader::hasOpenGLShaders(ShaderType type, QOpenGLContext *context)
if ((type & ~(Geometry | Vertex | Fragment | TessellationControl | TessellationEvaluation | Compute)) || type == 0)
return false;
- QSurfaceFormat format = context->format();
- if (type == Geometry) {
-#ifndef QT_OPENGL_ES_2
- // Geometry shaders require OpenGL 3.2 or newer
- QSurfaceFormat format = context->format();
- return (!context->isOpenGLES())
- && (format.version() >= qMakePair<int, int>(3, 2));
-#else
- // No geometry shader support in OpenGL ES2
- return false;
-#endif
- } else if (type == TessellationControl || type == TessellationEvaluation) {
-#if !defined(QT_OPENGL_ES_2)
- return (!context->isOpenGLES())
- && (format.version() >= qMakePair<int, int>(4, 0));
-#else
- // No tessellation shader support in OpenGL ES2
- return false;
-#endif
- } else if (type == Compute) {
-#if defined(QT_OPENGL_4_3)
- return (format.version() >= qMakePair<int, int>(4, 3));
-#else
- // No compute shader support without OpenGL 4.3 or newer
- return false;
-#endif
- }
+ if (type & QOpenGLShader::Geometry)
+ return supportsGeometry(context->format());
+ else if (type & (QOpenGLShader::TessellationControl | QOpenGLShader::TessellationEvaluation))
+ return supportsTessellation(context->format());
+ else if (type & QOpenGLShader::Compute)
+ return supportsCompute(context->format());
// Unconditional support of vertex and fragment shaders implicitly assumes
// a minimum OpenGL version of 2.0
diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm
index 6af12c19d8..a29d60ca6e 100644
--- a/src/gui/painting/qcoregraphics.mm
+++ b/src/gui/painting/qcoregraphics.mm
@@ -39,6 +39,7 @@
#include <QtGui/private/qpaintengine_p.h>
#include <QtCore/qdebug.h>
#include <QtCore/qcoreapplication.h>
+#include <QtCore/qoperatingsystemversion.h>
QT_BEGIN_NAMESPACE
@@ -119,7 +120,7 @@ QT_END_NAMESPACE
+ (NSGraphicsContext *)qt_graphicsContextWithCGContext:(CGContextRef)graphicsPort flipped:(BOOL)initialFlippedState
{
#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_NA)
- if (QT_PREPEND_NAMESPACE(QSysInfo::MacintoshVersion) >= QT_PREPEND_NAMESPACE(QSysInfo::MV_10_10))
+ if (QT_PREPEND_NAMESPACE(QOperatingSystemVersion::current()) >= QT_PREPEND_NAMESPACE(QOperatingSystemVersion::OSXYosemite))
return [self graphicsContextWithCGContext:graphicsPort flipped:initialFlippedState];
#endif
return [self graphicsContextWithGraphicsPort:graphicsPort flipped:initialFlippedState];
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index df96a993e3..d8aa727328 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -272,6 +272,35 @@ static void qt_debug_path(const QPainterPath &path)
}
#endif
+// QRect::normalized() will change the width/height of the rectangle due to
+// its incusive-integer definition of left/right vs width. This is not
+// something we want to change in QRect as that would potentially introduce
+// regressions all over the place, so we implement a straightforward
+// normalized here. QRectF already does this, so QRectF::normalized() is ok to
+// use.
+static QRect qrect_normalized(const QRect &rect)
+{
+ int x, y, w, h;
+ if (Q_UNLIKELY(rect.width() < 0)) {
+ x = rect.x() + rect.width();
+ w = -rect.width();
+ } else {
+ x = rect.x();
+ w = rect.width();
+ }
+
+ if (Q_UNLIKELY(rect.height() < 0)) {
+ y = rect.y() + rect.height();
+ h = -rect.height();
+ } else {
+ y = rect.y();
+ h = rect.height();
+ }
+
+ return QRect(x, y, w, h);
+}
+
+
QRasterPaintEnginePrivate::QRasterPaintEnginePrivate() :
QPaintEngineExPrivate(),
cachedLines(0)
@@ -1236,7 +1265,9 @@ void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
bool QRasterPaintEngine::setClipRectInDeviceCoords(const QRect &r, Qt::ClipOperation op)
{
Q_D(QRasterPaintEngine);
- QRect clipRect = r & d->deviceRect;
+ // normalize before using the & operator which uses QRect::normalize()
+ // internally which will give us the wrong values.
+ QRect clipRect = qrect_normalized(r) & d->deviceRect;
QRasterPaintEngineState *s = state();
if (op == Qt::ReplaceClip || s->clip == 0) {
@@ -1471,7 +1502,7 @@ void QRasterPaintEngine::drawRects(const QRect *rects, int rectCount)
int offset_x = int(s->matrix.dx());
int offset_y = int(s->matrix.dy());
while (r < lastRect) {
- QRect rect = r->normalized();
+ QRect rect = qrect_normalized(*r);
QRect rr = rect.translated(offset_x, offset_y);
fillRect_normalized(rr, &s->brushData, d);
++r;
@@ -2500,7 +2531,7 @@ void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap,
QRectF rr = r;
rr.translate(s->matrix.dx(), s->matrix.dy());
- fillRect_normalized(rr.toRect().normalized(), &d->image_filler, d);
+ fillRect_normalized(rr.normalized().toRect(), &d->image_filler, d);
}
}
@@ -2880,7 +2911,7 @@ bool QRasterPaintEnginePrivate::isUnclipped(const QRect &rect,
const QRasterPaintEngineState *s = q->state();
const QClipData *cl = clip();
if (!cl) {
- QRect r = rect.normalized();
+ QRect r = qrect_normalized(rect);
// inline contains() for performance (we know the rects are normalized)
const QRect &r1 = deviceRect;
return (r.left() >= r1.left() && r.right() <= r1.right()
@@ -2895,7 +2926,7 @@ bool QRasterPaintEnginePrivate::isUnclipped(const QRect &rect,
if (s->flags.antialiased)
++penWidth;
- QRect r = rect.normalized();
+ QRect r = qrect_normalized(rect);
if (penWidth > 0) {
r.setX(r.x() - penWidth);
r.setY(r.y() - penWidth);
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 0d05fee6ef..5e9fac5f86 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1145,9 +1145,28 @@ void QTextDocument::setMetaInformation(MetaInformation info, const QString &stri
}
/*!
+ Returns the raw text contained in the document without any
+ formatting information. If you want formatting information
+ use a QTextCursor instead.
+
+ \since 5.9
+ \sa toPlainText()
+*/
+QString QTextDocument::toRawText() const
+{
+ Q_D(const QTextDocument);
+ return d->plainText();
+}
+
+/*!
Returns the plain text contained in the document. If you want
formatting information use a QTextCursor instead.
+ This function returns the same as toRawText(), but will replace
+ some unicode characters, such as line separators and non-breaking
+ spaces, with ASCII alternatives. If you need the precise contents
+ of the document, use toRawText() instead.
+
\note Embedded objects, such as images, are represented by a
Unicode value U+FFFC (OBJECT REPLACEMENT CHARACTER).
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index 1888088f0d..c2761a39b9 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -151,6 +151,7 @@ public:
void setHtml(const QString &html);
#endif
+ QString toRawText() const;
QString toPlainText() const;
void setPlainText(const QString &text);
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index d4c43b3069..269e505a56 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -329,17 +329,17 @@ bool operator<(const QTextHtmlEntity &entity1, const QTextHtmlEntity &entity2)
}
#endif
-static bool operator<(const QString &entityStr, const QTextHtmlEntity &entity)
+static bool operator<(const QStringRef &entityStr, const QTextHtmlEntity &entity)
{
return entityStr < QLatin1String(entity.name);
}
-static bool operator<(const QTextHtmlEntity &entity, const QString &entityStr)
+static bool operator<(const QTextHtmlEntity &entity, const QStringRef &entityStr)
{
return QLatin1String(entity.name) < entityStr;
}
-static QChar resolveEntity(const QString &entity)
+static QChar resolveEntity(const QStringRef &entity)
{
const QTextHtmlEntity *start = &entities[0];
const QTextHtmlEntity *end = &entities[MAX_ENTITY];
@@ -801,8 +801,9 @@ void QTextHtmlParser::parseExclamationTag()
// parses an entity after "&", and returns it
QString QTextHtmlParser::parseEntity()
{
- int recover = pos;
- QString entity;
+ const int recover = pos;
+ int entityLen = 0;
+ QStringRef entity;
while (pos < len) {
QChar c = txt.at(pos++);
if (c.isSpace() || pos - recover > 9) {
@@ -810,36 +811,38 @@ QString QTextHtmlParser::parseEntity()
}
if (c == QLatin1Char(';'))
break;
- entity += c;
+ ++entityLen;
}
- {
+ if (entityLen) {
+ entity = QStringRef(&txt, recover, entityLen);
QChar resolved = resolveEntity(entity);
if (!resolved.isNull())
return QString(resolved);
- }
- if (entity.length() > 1 && entity.at(0) == QLatin1Char('#')) {
- entity.remove(0, 1); // removing leading #
- int base = 10;
- bool ok = false;
+ if (entityLen > 1 && entity.at(0) == QLatin1Char('#')) {
+ entity = entity.mid(1); // removing leading #
- if (entity.at(0).toLower() == QLatin1Char('x')) { // hex entity?
- entity.remove(0, 1);
- base = 16;
- }
+ int base = 10;
+ bool ok = false;
- uint uc = entity.toUInt(&ok, base);
- if (ok) {
- if (uc >= 0x80 && uc < 0x80 + (sizeof(windowsLatin1ExtendedCharacters)/sizeof(windowsLatin1ExtendedCharacters[0])))
- uc = windowsLatin1ExtendedCharacters[uc - 0x80];
- QString str;
- if (QChar::requiresSurrogates(uc)) {
- str += QChar(QChar::highSurrogate(uc));
- str += QChar(QChar::lowSurrogate(uc));
- } else {
- str = QChar(uc);
+ if (entity.at(0).toLower() == QLatin1Char('x')) { // hex entity?
+ entity = entity.mid(1);
+ base = 16;
+ }
+
+ uint uc = entity.toUInt(&ok, base);
+ if (ok) {
+ if (uc >= 0x80 && uc < 0x80 + (sizeof(windowsLatin1ExtendedCharacters)/sizeof(windowsLatin1ExtendedCharacters[0])))
+ uc = windowsLatin1ExtendedCharacters[uc - 0x80];
+ QString str;
+ if (QChar::requiresSurrogates(uc)) {
+ str += QChar(QChar::highSurrogate(uc));
+ str += QChar(QChar::lowSurrogate(uc));
+ } else {
+ str = QChar(uc);
+ }
+ return str;
}
- return str;
}
}
error:
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 540bbf5d54..023a1b7f52 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1653,6 +1653,7 @@ namespace {
int maxGlyphs;
int currentPosition;
glyph_t previousGlyph;
+ QFontEngine *previousGlyphFontEngine;
QFixed minw;
QFixed softHyphenWidth;
@@ -1686,13 +1687,14 @@ namespace {
if (currentPosition > 0 &&
logClusters[currentPosition - 1] < glyphs.numGlyphs) {
previousGlyph = currentGlyph(); // needed to calculate right bearing later
+ previousGlyphFontEngine = fontEngine;
}
}
- inline void calculateRightBearing(glyph_t glyph)
+ inline void calculateRightBearing(QFontEngine *engine, glyph_t glyph)
{
qreal rb;
- fontEngine->getGlyphBearings(glyph, 0, &rb);
+ engine->getGlyphBearings(glyph, 0, &rb);
// We only care about negative right bearings, so we limit the range
// of the bearing here so that we can assume it's negative in the rest
@@ -1705,13 +1707,13 @@ namespace {
{
if (currentPosition <= 0)
return;
- calculateRightBearing(currentGlyph());
+ calculateRightBearing(fontEngine, currentGlyph());
}
inline void calculateRightBearingForPreviousGlyph()
{
if (previousGlyph > 0)
- calculateRightBearing(previousGlyph);
+ calculateRightBearing(previousGlyphFontEngine, previousGlyph);
}
static const QFixed RightBearingNotCalculated;
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp
index 085c073bb1..c9747877f7 100644
--- a/src/gui/util/qdesktopservices.cpp
+++ b/src/gui/util/qdesktopservices.cpp
@@ -198,8 +198,15 @@ bool QDesktopServices::openUrl(const QUrl &url)
return false;
QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();
- if (!platformIntegration)
+ if (Q_UNLIKELY(!platformIntegration)) {
+ QCoreApplication *application = QCoreApplication::instance();
+ if (Q_UNLIKELY(!application))
+ qWarning("QDesktopServices::openUrl: Please instantiate the QGuiApplication object "
+ "first");
+ else if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(application)))
+ qWarning("QDesktopServices::openUrl: Application is not a GUI application");
return false;
+ }
QPlatformServices *platformServices = platformIntegration->services();
if (!platformServices) {
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index 24ada3a81f..612abb9044 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -299,6 +299,11 @@ void QHttpNetworkReply::setSpdyWasUsed(bool spdy)
d_func()->spdyUsed = spdy;
}
+qint64 QHttpNetworkReply::removedContentLength() const
+{
+ return d_func()->removedContentLength;
+}
+
bool QHttpNetworkReply::isRedirecting() const
{
return d_func()->isRedirecting();
@@ -326,6 +331,7 @@ QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
currentlyReceivedDataInWindow(0),
currentlyUploadedDataInWindow(0),
totallyUploadedData(0),
+ removedContentLength(-1),
connection(0),
autoDecompress(false), responseData(), requestIsPrepared(false)
,pipeliningUsed(false), spdyUsed(false), downstreamLimited(false)
@@ -398,12 +404,12 @@ void QHttpNetworkReplyPrivate::removeAutoDecompressHeader()
end = fields.end();
while (it != end) {
if (qstricmp(name.constData(), it->first.constData()) == 0) {
+ removedContentLength = strtoull(it->second.constData(), nullptr, 0);
fields.erase(it);
break;
}
++it;
}
-
}
bool QHttpNetworkReplyPrivate::findChallenge(bool forProxy, QByteArray &challenge) const
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h
index f3b007f594..faab03f056 100644
--- a/src/network/access/qhttpnetworkreply_p.h
+++ b/src/network/access/qhttpnetworkreply_p.h
@@ -139,6 +139,7 @@ public:
bool isPipeliningUsed() const;
bool isSpdyUsed() const;
void setSpdyWasUsed(bool spdy);
+ qint64 removedContentLength() const;
bool isRedirecting() const;
@@ -255,6 +256,7 @@ public:
qint32 currentlyReceivedDataInWindow; // only for SPDY
qint32 currentlyUploadedDataInWindow; // only for SPDY
qint64 totallyUploadedData; // only for SPDY
+ qint64 removedContentLength;
QPointer<QHttpNetworkConnection> connection;
QPointer<QHttpNetworkConnectionChannel> connectionChannel;
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp
index 1dca7f02fb..e71911cec2 100644
--- a/src/network/access/qhttpthreaddelegate.cpp
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -234,6 +234,7 @@ QHttpThreadDelegate::QHttpThreadDelegate(QObject *parent) :
, isPipeliningUsed(false)
, isSpdyUsed(false)
, incomingContentLength(-1)
+ , removedContentLength(-1)
, incomingErrorCode(QNetworkReply::NoError)
, downloadBuffer()
, httpConnection(0)
@@ -623,6 +624,7 @@ void QHttpThreadDelegate::headerChangedSlot()
incomingReasonPhrase = httpReply->reasonPhrase();
isPipeliningUsed = httpReply->isPipeliningUsed();
incomingContentLength = httpReply->contentLength();
+ removedContentLength = httpReply->removedContentLength();
isSpdyUsed = httpReply->isSpdyUsed();
emit downloadMetaData(incomingHeaders,
@@ -631,6 +633,7 @@ void QHttpThreadDelegate::headerChangedSlot()
isPipeliningUsed,
downloadBuffer,
incomingContentLength,
+ removedContentLength,
isSpdyUsed);
}
diff --git a/src/network/access/qhttpthreaddelegate_p.h b/src/network/access/qhttpthreaddelegate_p.h
index 64c58cf648..6d1ea11f29 100644
--- a/src/network/access/qhttpthreaddelegate_p.h
+++ b/src/network/access/qhttpthreaddelegate_p.h
@@ -112,6 +112,7 @@ public:
bool isPipeliningUsed;
bool isSpdyUsed;
qint64 incomingContentLength;
+ qint64 removedContentLength;
QNetworkReply::NetworkError incomingErrorCode;
QString incomingErrorDetail;
#ifndef QT_NO_BEARERMANAGEMENT
@@ -141,7 +142,7 @@ signals:
void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *);
#endif
void downloadMetaData(const QList<QPair<QByteArray,QByteArray> > &, int, const QString &, bool,
- QSharedPointer<char>, qint64, bool);
+ QSharedPointer<char>, qint64, qint64, bool);
void downloadProgress(qint64, qint64);
void downloadData(const QByteArray &);
void error(QNetworkReply::NetworkError, const QString &);
diff --git a/src/network/access/qnetworkaccessbackend_p.h b/src/network/access/qnetworkaccessbackend_p.h
index 7f39c942a3..4b5422ce29 100644
--- a/src/network/access/qnetworkaccessbackend_p.h
+++ b/src/network/access/qnetworkaccessbackend_p.h
@@ -63,7 +63,6 @@ class QNetworkProxyQuery;
class QNetworkRequest;
class QStringList;
class QUrl;
-class QUrlInfo;
class QSslConfiguration;
class QNetworkAccessManagerPrivate;
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 6f5e68d9c2..00f3468ebd 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -803,10 +803,11 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
Qt::QueuedConnection);
QObject::connect(delegate, SIGNAL(downloadMetaData(QList<QPair<QByteArray,QByteArray> >,
int, QString, bool,
- QSharedPointer<char>, qint64, bool)),
+ QSharedPointer<char>, qint64, qint64,
+ bool)),
q, SLOT(replyDownloadMetaData(QList<QPair<QByteArray,QByteArray> >,
int, QString, bool,
- QSharedPointer<char>, qint64, bool)),
+ QSharedPointer<char>, qint64, qint64, bool)),
Qt::QueuedConnection);
QObject::connect(delegate, SIGNAL(downloadProgress(qint64,qint64)),
q, SLOT(replyDownloadProgressSlot(qint64,qint64)),
@@ -911,6 +912,7 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
delegate->isPipeliningUsed,
QSharedPointer<char>(),
delegate->incomingContentLength,
+ delegate->removedContentLength,
delegate->isSpdyUsed);
replyDownloadData(delegate->synchronousDownloadData);
httpError(delegate->incomingErrorCode, delegate->incomingErrorDetail);
@@ -922,6 +924,7 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
delegate->isPipeliningUsed,
QSharedPointer<char>(),
delegate->incomingContentLength,
+ delegate->removedContentLength,
delegate->isSpdyUsed);
replyDownloadData(delegate->synchronousDownloadData);
}
@@ -1149,7 +1152,9 @@ void QNetworkReplyHttpImplPrivate::checkForRedirect(const int statusCode)
void QNetworkReplyHttpImplPrivate::replyDownloadMetaData(const QList<QPair<QByteArray,QByteArray> > &hm,
int sc, const QString &rp, bool pu,
QSharedPointer<char> db,
- qint64 contentLength, bool spdyWasUsed)
+ qint64 contentLength,
+ qint64 removedContentLength,
+ bool spdyWasUsed)
{
Q_Q(QNetworkReplyHttpImpl);
Q_UNUSED(contentLength);
@@ -1195,6 +1200,8 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData(const QList<QPair<QByte
q->setAttribute(QNetworkRequest::HttpStatusCodeAttribute, statusCode);
q->setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, reasonPhrase);
+ if (removedContentLength != -1)
+ q->setAttribute(QNetworkRequest::OriginalContentLengthAttribute, removedContentLength);
// is it a redirection?
if (!isHttpRedirectResponse())
diff --git a/src/network/access/qnetworkreplyhttpimpl_p.h b/src/network/access/qnetworkreplyhttpimpl_p.h
index 868fa617b6..255c23006e 100644
--- a/src/network/access/qnetworkreplyhttpimpl_p.h
+++ b/src/network/access/qnetworkreplyhttpimpl_p.h
@@ -114,7 +114,7 @@ public:
Q_PRIVATE_SLOT(d_func(), void replyFinished())
Q_PRIVATE_SLOT(d_func(), void replyDownloadMetaData(QList<QPair<QByteArray,QByteArray> >,
int, QString, bool, QSharedPointer<char>,
- qint64, bool))
+ qint64, qint64, bool))
Q_PRIVATE_SLOT(d_func(), void replyDownloadProgressSlot(qint64,qint64))
Q_PRIVATE_SLOT(d_func(), void httpAuthenticationRequired(const QHttpNetworkRequest &, QAuthenticator *))
Q_PRIVATE_SLOT(d_func(), void httpError(QNetworkReply::NetworkError, const QString &))
@@ -280,7 +280,7 @@ public:
void replyDownloadData(QByteArray);
void replyFinished();
void replyDownloadMetaData(const QList<QPair<QByteArray,QByteArray> > &, int, const QString &,
- bool, QSharedPointer<char>, qint64, bool);
+ bool, QSharedPointer<char>, qint64, qint64, bool);
void replyDownloadProgressSlot(qint64,qint64);
void httpAuthenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *auth);
void httpError(QNetworkReply::NetworkError error, const QString &errorString);
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index 29362b81e2..bc2507ca51 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -282,6 +282,13 @@ QT_BEGIN_NAMESPACE
that is redirecting from "https" to "http" protocol, are not allowed.
(This value was introduced in 5.6.)
+ \value OriginalContentLengthAttribute
+ Replies only, type QMetaType::Int
+ Holds the original content-length attribute before being invalidated and
+ removed from the header when the data is compressed and the request was
+ marked to be decompressed automatically.
+ (This value was introduced in 5.9.)
+
\value User
Special type. Additional information can be passed in
QVariants with types ranging from User to UserMax. The default
diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h
index ad8f5bddd9..9a3a7f0fb5 100644
--- a/src/network/access/qnetworkrequest.h
+++ b/src/network/access/qnetworkrequest.h
@@ -91,6 +91,7 @@ public:
FollowRedirectsAttribute,
HTTP2AllowedAttribute,
HTTP2WasUsedAttribute,
+ OriginalContentLengthAttribute,
User = 1000,
UserMax = 32767
diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri
index 005f000c25..a80b2d387e 100644
--- a/src/network/kernel/kernel.pri
+++ b/src/network/kernel/kernel.pri
@@ -56,8 +56,7 @@ win32: {
mac {
LIBS_PRIVATE += -framework CoreFoundation
- !uikit: LIBS_PRIVATE += -framework CoreServices
- !if(watchos:CONFIG(device, simulator|device)): LIBS_PRIVATE += -framework SystemConfiguration
+ !uikit: LIBS_PRIVATE += -framework CoreServices -framework SystemConfiguration
}
osx:SOURCES += kernel/qnetworkproxy_mac.cpp
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp
index 7e3d2c5d6e..2a905101a4 100644
--- a/src/network/kernel/qhostaddress.cpp
+++ b/src/network/kernel/qhostaddress.cpp
@@ -201,10 +201,10 @@ void QHostAddressPrivate::setAddress(const Q_IPV6ADDR &a_)
static bool parseIp6(const QString &address, QIPAddressUtils::IPv6Address &addr, QString *scopeId)
{
- QString tmp = address;
+ QStringRef tmp(&address);
int scopeIdPos = tmp.lastIndexOf(QLatin1Char('%'));
if (scopeIdPos != -1) {
- *scopeId = tmp.mid(scopeIdPos + 1);
+ *scopeId = tmp.mid(scopeIdPos + 1).toString();
tmp.chop(tmp.size() - scopeIdPos);
} else {
scopeId->clear();
@@ -1086,7 +1086,7 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
return invalid;
int slash = subnet.indexOf(QLatin1Char('/'));
- QString netStr = subnet;
+ QStringRef netStr(&subnet);
if (slash != -1)
netStr.truncate(slash);
@@ -1117,7 +1117,7 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
netmask = 128;
QHostAddress net;
- if (!net.setAddress(netStr))
+ if (!net.setAddress(netStr.toString()))
return invalid; // failed to parse the IP
clearBits(net.d->a6.c, netmask, 128);
@@ -1128,7 +1128,7 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
return invalid; // invalid netmask
// parse the address manually
- auto parts = netStr.splitRef(QLatin1Char('.'));
+ auto parts = netStr.split(QLatin1Char('.'));
if (parts.isEmpty() || parts.count() > 4)
return invalid; // invalid IPv4 address
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 02bba2d293..741bd9a52d 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -1274,11 +1274,11 @@ bool QAbstractSocketPrivate::readFromSocket()
}
if (!socketEngine->isValid()) {
- setErrorAndEmit(socketEngine->error(), socketEngine->errorString());
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::readFromSocket() read failed: %s",
- q->errorString().toLatin1().constData());
+ socketEngine->errorString().toLatin1().constData());
#endif
+ setErrorAndEmit(socketEngine->error(), socketEngine->errorString());
resetSocketLayer();
return false;
}
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index a1a8e4649d..89261ce789 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -54,6 +54,7 @@
#include "qurl.h"
#include "qauthenticator.h"
#include "private/qiodevice_p.h"
+#include "private/qringbuffer_p.h"
#include <qendian.h>
#include <qnetworkinterface.h>
@@ -280,7 +281,7 @@ struct QSocks5Data
struct QSocks5ConnectData : public QSocks5Data
{
- QByteArray readBuffer;
+ QRingBuffer readBuffer;
};
struct QSocks5BindData : public QSocks5Data
@@ -1193,7 +1194,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketReadNotification()
}
if (buf.size()) {
QSOCKS5_DEBUG << dump(buf);
- connectData->readBuffer += buf;
+ connectData->readBuffer.append(buf);
emitReadNotification();
}
break;
@@ -1513,7 +1514,7 @@ qint64 QSocks5SocketEngine::read(char *data, qint64 maxlen)
Q_D(QSocks5SocketEngine);
QSOCKS5_Q_DEBUG << "read( , maxlen = " << maxlen << ')';
if (d->mode == QSocks5SocketEnginePrivate::ConnectMode) {
- if (d->connectData->readBuffer.size() == 0) {
+ if (d->connectData->readBuffer.isEmpty()) {
if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) {
//imitate remote closed
close();
@@ -1525,9 +1526,7 @@ qint64 QSocks5SocketEngine::read(char *data, qint64 maxlen)
return 0; // nothing to be read
}
}
- qint64 copy = qMin<qint64>(d->connectData->readBuffer.size(), maxlen);
- memcpy(data, d->connectData->readBuffer.constData(), copy);
- d->connectData->readBuffer.remove(0, copy);
+ const qint64 copy = d->connectData->readBuffer.read(data, maxlen);
QSOCKS5_DEBUG << "read" << dump(QByteArray(data, copy));
return copy;
#ifndef QT_NO_UDPSOCKET
diff --git a/src/network/ssl/qsslsocket_winrt.cpp b/src/network/ssl/qsslsocket_winrt.cpp
index f5dc9fcdcd..ca65f8a015 100644
--- a/src/network/ssl/qsslsocket_winrt.cpp
+++ b/src/network/ssl/qsslsocket_winrt.cpp
@@ -181,13 +181,7 @@ long QSslSocketPrivate::sslLibraryVersionNumber()
QString QSslSocketPrivate::sslLibraryVersionString()
{
- switch (QSysInfo::windowsVersion()) {
- case QSysInfo::WV_WINDOWS8_1:
- return QStringLiteral("Windows Runtime 8.1 SSL library");
- default:
- break;
- }
- return QStringLiteral("Windows Runtime SSL library");
+ return QStringLiteral("Windows Runtime, ") + QSysInfo::prettyProductName();
}
long QSslSocketPrivate::sslLibraryBuildVersionNumber()
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp
index 5c72dbe7e2..a1575677f5 100644
--- a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp
+++ b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp
@@ -47,7 +47,11 @@
#include <QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
+#ifdef Q_OS_FREEBSD
+#include <dev/evdev/input.h>
+#else
#include <linux/input.h>
+#endif
#include <fcntl.h>
/* android (and perhaps some other linux-derived stuff) don't define everything
diff --git a/src/platformsupport/fbconvenience/qfbcursor.cpp b/src/platformsupport/fbconvenience/qfbcursor.cpp
index 004c586de3..7daf3f4d0c 100644
--- a/src/platformsupport/fbconvenience/qfbcursor.cpp
+++ b/src/platformsupport/fbconvenience/qfbcursor.cpp
@@ -60,8 +60,8 @@ QFbCursor::QFbCursor(QFbScreen *screen)
mScreen(screen),
mDirty(false),
mOnScreen(false),
- mGraphic(0),
- mDeviceListener(0)
+ mCursorImage(nullptr),
+ mDeviceListener(nullptr)
{
QByteArray hideCursorVal = qgetenv("QT_QPA_FB_HIDECURSOR");
if (!hideCursorVal.isEmpty())
@@ -69,7 +69,7 @@ QFbCursor::QFbCursor(QFbScreen *screen)
if (!mVisible)
return;
- mGraphic = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
+ mCursorImage = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
setCursor(Qt::ArrowCursor);
mDeviceListener = new QFbCursorDeviceListener(this);
@@ -85,8 +85,8 @@ QFbCursor::~QFbCursor()
QRect QFbCursor::getCurrentRect()
{
- QRect rect = mGraphic->image()->rect().translated(-mGraphic->hotspot().x(),
- -mGraphic->hotspot().y());
+ QRect rect = mCursorImage->image()->rect().translated(-mCursorImage->hotspot().x(),
+ -mCursorImage->hotspot().y());
rect.translate(m_pos);
QPoint mScreenOffset = mScreen->geometry().topLeft();
rect.translate(-mScreenOffset); // global to local translation
@@ -133,7 +133,7 @@ QRect QFbCursor::drawCursor(QPainter & painter)
return QRect();
mPrevRect = mCurrentRect;
- painter.drawImage(mPrevRect, *mGraphic->image());
+ painter.drawImage(mPrevRect, *mCursorImage->image());
mOnScreen = true;
return mPrevRect;
}
@@ -149,17 +149,17 @@ QRect QFbCursor::dirtyRect()
void QFbCursor::setCursor(Qt::CursorShape shape)
{
- mGraphic->set(shape);
+ mCursorImage->set(shape);
}
void QFbCursor::setCursor(const QImage &image, int hotx, int hoty)
{
- mGraphic->set(image, hotx, hoty);
+ mCursorImage->set(image, hotx, hoty);
}
void QFbCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
{
- mGraphic->set(data, mask, width, height, hotX, hotY);
+ mCursorImage->set(data, mask, width, height, hotX, hotY);
}
#ifndef QT_NO_CURSOR
diff --git a/src/platformsupport/fbconvenience/qfbcursor_p.h b/src/platformsupport/fbconvenience/qfbcursor_p.h
index f08babd45b..beda10a5f3 100644
--- a/src/platformsupport/fbconvenience/qfbcursor_p.h
+++ b/src/platformsupport/fbconvenience/qfbcursor_p.h
@@ -87,11 +87,11 @@ public:
virtual QRect drawCursor(QPainter &painter);
// input methods
- void pointerEvent(const QMouseEvent &event) Q_DECL_OVERRIDE;
- QPoint pos() const Q_DECL_OVERRIDE;
- void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
+ void pointerEvent(const QMouseEvent &event) override;
+ QPoint pos() const override;
+ void setPos(const QPoint &pos) override;
#ifndef QT_NO_CURSOR
- void changeCursor(QCursor *widgetCursor, QWindow *window) Q_DECL_OVERRIDE;
+ void changeCursor(QCursor *widgetCursor, QWindow *window) override;
#endif
virtual void setDirty();
@@ -113,7 +113,7 @@ private:
QRect mPrevRect; // last place the cursor was drawn
bool mDirty;
bool mOnScreen;
- QPlatformCursorImage *mGraphic;
+ QPlatformCursorImage *mCursorImage;
QFbCursorDeviceListener *mDeviceListener;
QPoint m_pos;
};
@@ -121,4 +121,3 @@ private:
QT_END_NAMESPACE
#endif // QFBCURSOR_P_H
-
diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp
index 216f2722a4..757995a1c0 100644
--- a/src/platformsupport/fbconvenience/qfbscreen.cpp
+++ b/src/platformsupport/fbconvenience/qfbscreen.cpp
@@ -51,19 +51,23 @@
QT_BEGIN_NAMESPACE
-QFbScreen::QFbScreen() : mUpdatePending(false), mCursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), mCompositePainter(0), mIsUpToDate(false)
+QFbScreen::QFbScreen()
+ : mUpdatePending(false),
+ mCursor(0),
+ mDepth(16),
+ mFormat(QImage::Format_RGB16),
+ mPainter(nullptr)
{
}
QFbScreen::~QFbScreen()
{
- delete mCompositePainter;
- delete mScreenImage;
+ delete mPainter;
}
void QFbScreen::initializeCompositor()
{
- mScreenImage = new QImage(mGeometry.size(), mFormat);
+ mScreenImage = QImage(mGeometry.size(), mFormat);
scheduleUpdate();
}
@@ -93,7 +97,6 @@ void QFbScreen::addWindow(QFbWindow *window)
}
}
}
- invalidateRectCache();
setDirty(window->geometry());
QWindow *w = topWindow();
QWindowSystemInterface::handleWindowActivated(w);
@@ -103,7 +106,6 @@ void QFbScreen::addWindow(QFbWindow *window)
void QFbScreen::removeWindow(QFbWindow *window)
{
mWindowStack.removeOne(window);
- invalidateRectCache();
setDirty(window->geometry());
QWindow *w = topWindow();
QWindowSystemInterface::handleWindowActivated(w);
@@ -116,7 +118,6 @@ void QFbScreen::raise(QFbWindow *window)
if (index <= 0)
return;
mWindowStack.move(index, 0);
- invalidateRectCache();
setDirty(window->geometry());
QWindow *w = topWindow();
QWindowSystemInterface::handleWindowActivated(w);
@@ -129,7 +130,6 @@ void QFbScreen::lower(QFbWindow *window)
if (index == -1 || index == (mWindowStack.size() - 1))
return;
mWindowStack.move(index, mWindowStack.size() - 1);
- invalidateRectCache();
setDirty(window->geometry());
QWindow *w = topWindow();
QWindowSystemInterface::handleWindowActivated(w);
@@ -142,7 +142,7 @@ QWindow *QFbScreen::topWindow() const
if (fbw->window()->type() == Qt::Window || fbw->window()->type() == Qt::Dialog)
return fbw->window();
}
- return 0;
+ return nullptr;
}
QWindow *QFbScreen::topLevelAt(const QPoint & p) const
@@ -151,14 +151,19 @@ QWindow *QFbScreen::topLevelAt(const QPoint & p) const
if (fbw->geometry().contains(p, false) && fbw->window()->isVisible())
return fbw->window();
}
- return 0;
+ return nullptr;
+}
+
+int QFbScreen::windowCount() const
+{
+ return mWindowStack.count();
}
void QFbScreen::setDirty(const QRect &rect)
{
- QRect intersection = rect.intersected(mGeometry);
- QPoint screenOffset = mGeometry.topLeft();
- mRepaintRegion += intersection.translated(-screenOffset); // global to local translation
+ const QRect intersection = rect.intersected(mGeometry);
+ const QPoint screenOffset = mGeometry.topLeft();
+ mRepaintRegion += intersection.translated(-screenOffset); // global to local translation
scheduleUpdate();
}
@@ -177,141 +182,76 @@ void QFbScreen::setPhysicalSize(const QSize &size)
void QFbScreen::setGeometry(const QRect &rect)
{
- delete mCompositePainter;
- mCompositePainter = 0;
- delete mScreenImage;
+ delete mPainter;
+ mPainter = nullptr;
mGeometry = rect;
- mScreenImage = new QImage(mGeometry.size(), mFormat);
- invalidateRectCache();
+ mScreenImage = QImage(mGeometry.size(), mFormat);
QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), geometry(), availableGeometry());
resizeMaximizedWindows();
}
-void QFbScreen::generateRects()
-{
- mCachedRects.clear();
- QPoint screenOffset = mGeometry.topLeft();
- QRegion remainingScreen(mGeometry.translated(-screenOffset)); // global to local translation
-
- for (int i = 0; i < mWindowStack.length(); i++) {
- if (remainingScreen.isEmpty())
- break;
-#if 0
- if (!mWindowStack[i]->isVisible())
- continue;
- if (mWindowStack[i]->isMinimized())
- continue;
-
- if (!mWindowStack[i]->testAttribute(Qt::WA_TranslucentBackground)) {
- QRect localGeometry = mWindowStack.at(i)->geometry().translated(-screenOffset); // global to local translation
- remainingScreen -= localGeometry;
- QRegion windowRegion(localGeometry);
- windowRegion -= remainingScreen;
- for (const QRect &rect : windowRegion)
- mCachedRects += QPair<QRect, int>(rect, i);
- }
-#endif
- }
- mCachedRects.reserve(mCachedRects.count() + remainingScreen.rectCount());
- for (const QRect &rect : remainingScreen)
- mCachedRects += QPair<QRect, int>(rect, -1);
- mIsUpToDate = true;
-}
-
QRegion QFbScreen::doRedraw()
{
- QPoint screenOffset = mGeometry.topLeft();
+ const QPoint screenOffset = mGeometry.topLeft();
QRegion touchedRegion;
if (mCursor && mCursor->isDirty() && mCursor->isOnScreen()) {
- QRect lastCursor = mCursor->dirtyRect();
+ const QRect lastCursor = mCursor->dirtyRect();
mRepaintRegion += lastCursor;
}
- if (mRepaintRegion.isEmpty() && (!mCursor || !mCursor->isDirty())) {
+ if (mRepaintRegion.isEmpty() && (!mCursor || !mCursor->isDirty()))
return touchedRegion;
- }
-
- QVector<QRect> rects = mRepaintRegion.rects();
- if (!mIsUpToDate)
- generateRects();
-
- if (!mCompositePainter)
- mCompositePainter = new QPainter(mScreenImage);
+ if (!mPainter)
+ mPainter = new QPainter(&mScreenImage);
+ const QVector<QRect> rects = mRepaintRegion.rects();
+ const QRect screenRect = mGeometry.translated(-screenOffset);
for (int rectIndex = 0; rectIndex < mRepaintRegion.rectCount(); rectIndex++) {
- QRegion rectRegion = rects[rectIndex];
+ const QRect rect = rects[rectIndex].intersected(screenRect);
+ if (rect.isEmpty())
+ continue;
- for (int i = 0; i < mCachedRects.length(); i++) {
- QRect screenSubRect = mCachedRects[i].first;
- int layer = mCachedRects[i].second;
- QRegion intersect = rectRegion.intersected(screenSubRect);
+ mPainter->setCompositionMode(QPainter::CompositionMode_Source);
+ mPainter->fillRect(rect, mScreenImage.hasAlphaChannel() ? Qt::transparent : Qt::black);
- if (intersect.isEmpty())
+ for (int layerIndex = mWindowStack.size() - 1; layerIndex != -1; layerIndex--) {
+ if (!mWindowStack[layerIndex]->window()->isVisible())
continue;
- rectRegion -= intersect;
-
- // we only expect one rectangle, but defensive coding...
- for (const QRect &rect : intersect) {
- bool firstLayer = true;
- if (layer == -1) {
- mCompositePainter->setCompositionMode(QPainter::CompositionMode_Source);
- mCompositePainter->fillRect(rect, mScreenImage->hasAlphaChannel() ? Qt::transparent : Qt::black);
- firstLayer = false;
- layer = mWindowStack.size() - 1;
- }
-
- for (int layerIndex = layer; layerIndex != -1; layerIndex--) {
- if (!mWindowStack[layerIndex]->window()->isVisible())
- continue;
- // if (mWindowStack[layerIndex]->isMinimized())
- // continue;
-
- QRect windowRect = mWindowStack[layerIndex]->geometry().translated(-screenOffset);
- QRect windowIntersect = rect.translated(-windowRect.left(),
- -windowRect.top());
-
-
- QFbBackingStore *backingStore = mWindowStack[layerIndex]->backingStore();
-
- if (backingStore) {
- backingStore->lock();
- mCompositePainter->drawImage(rect, backingStore->image(), windowIntersect);
- backingStore->unlock();
- }
- if (firstLayer) {
- firstLayer = false;
- }
- }
+ const QRect windowRect = mWindowStack[layerIndex]->geometry().translated(-screenOffset);
+ const QRect windowIntersect = rect.translated(-windowRect.left(), -windowRect.top());
+ QFbBackingStore *backingStore = mWindowStack[layerIndex]->backingStore();
+ if (backingStore) {
+ backingStore->lock();
+ mPainter->drawImage(rect, backingStore->image(), windowIntersect);
+ backingStore->unlock();
}
}
}
- QRect cursorRect;
if (mCursor && (mCursor->isDirty() || mRepaintRegion.intersects(mCursor->lastPainted()))) {
- mCompositePainter->setCompositionMode(QPainter::CompositionMode_SourceOver);
- cursorRect = mCursor->drawCursor(*mCompositePainter);
- touchedRegion += cursorRect;
+ mPainter->setCompositionMode(QPainter::CompositionMode_SourceOver);
+ touchedRegion += mCursor->drawCursor(*mPainter);
}
touchedRegion += mRepaintRegion;
mRepaintRegion = QRegion();
-
-
-// qDebug() << "QFbScreen::doRedraw" << mWindowStack.size() << mScreenImage->size() << touchedRegion;
-
return touchedRegion;
}
QFbWindow *QFbScreen::windowForId(WId wid) const
{
- for (int i = 0; i < mWindowStack.count(); ++i)
+ for (int i = 0; i < mWindowStack.count(); ++i) {
if (mWindowStack[i]->winId() == wid)
return mWindowStack[i];
+ }
+ return nullptr;
+}
+QFbScreen::Flags QFbScreen::flags() const
+{
return 0;
}
QT_END_NAMESPACE
-
diff --git a/src/platformsupport/fbconvenience/qfbscreen_p.h b/src/platformsupport/fbconvenience/qfbscreen_p.h
index e9b570aa1c..82a660ea09 100644
--- a/src/platformsupport/fbconvenience/qfbscreen_p.h
+++ b/src/platformsupport/fbconvenience/qfbscreen_p.h
@@ -66,7 +66,13 @@ class QFbBackingStore;
class QFbScreen : public QObject, public QPlatformScreen
{
Q_OBJECT
+
public:
+ enum Flag {
+ DontForceFirstWindowToFullScreen = 0x01
+ };
+ Q_DECLARE_FLAGS(Flags, Flag)
+
QFbScreen();
~QFbScreen();
@@ -85,6 +91,8 @@ public:
virtual void raise(QFbWindow *window);
virtual void lower(QFbWindow *window);
virtual void topWindowChanged(QWindow *) {}
+ virtual int windowCount() const;
+ virtual Flags flags() const;
void addPendingBackingStore(QFbBackingStore *bs) { mPendingBackingStores << bs; }
@@ -112,20 +120,17 @@ protected:
int mDepth;
QImage::Format mFormat;
QSizeF mPhysicalSize;
- QImage *mScreenImage;
+ QImage mScreenImage;
private:
- void invalidateRectCache() { mIsUpToDate = false; }
- void generateRects();
-
- QPainter *mCompositePainter;
- QVector<QPair<QRect, int> > mCachedRects;
+ QPainter *mPainter;
QList<QFbBackingStore*> mPendingBackingStores;
friend class QFbWindow;
- bool mIsUpToDate;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QFbScreen::Flags)
+
QT_END_NAMESPACE
#endif // QFBSCREEN_P_H
diff --git a/src/platformsupport/fbconvenience/qfbwindow.cpp b/src/platformsupport/fbconvenience/qfbwindow.cpp
index 2d5570fe5d..0be1dad04a 100644
--- a/src/platformsupport/fbconvenience/qfbwindow.cpp
+++ b/src/platformsupport/fbconvenience/qfbwindow.cpp
@@ -66,7 +66,6 @@ void QFbWindow::setGeometry(const QRect &rect)
// store previous geometry for screen update
mOldGeometry = geometry();
- platformScreen()->invalidateRectCache();
QWindowSystemInterface::handleGeometryChange(window(), rect);
QPlatformWindow::setGeometry(rect);
@@ -74,8 +73,13 @@ void QFbWindow::setGeometry(const QRect &rect)
void QFbWindow::setVisible(bool visible)
{
+ QFbScreen *fbScreen = platformScreen();
if (visible) {
- if (mWindowState & Qt::WindowFullScreen)
+ bool convOk = false;
+ static bool envDisableForceFullScreen = qEnvironmentVariableIntValue("QT_QPA_FB_FORCE_FULLSCREEN", &convOk) == 0 && convOk;
+ const bool platformDisableForceFullScreen = fbScreen->flags().testFlag(QFbScreen::DontForceFirstWindowToFullScreen);
+ const bool forceFullScreen = !envDisableForceFullScreen && !platformDisableForceFullScreen && fbScreen->windowCount() == 0;
+ if (forceFullScreen || (mWindowState & Qt::WindowFullScreen))
setGeometry(platformScreen()->geometry());
else if (mWindowState & Qt::WindowMaximized)
setGeometry(platformScreen()->availableGeometry());
@@ -83,9 +87,9 @@ void QFbWindow::setVisible(bool visible)
QPlatformWindow::setVisible(visible);
if (visible)
- platformScreen()->addWindow(this);
+ fbScreen->addWindow(this);
else
- platformScreen()->removeWindow(this);
+ fbScreen->removeWindow(this);
}
@@ -93,14 +97,11 @@ void QFbWindow::setWindowState(Qt::WindowState state)
{
QPlatformWindow::setWindowState(state);
mWindowState = state;
- platformScreen()->invalidateRectCache();
}
-
void QFbWindow::setWindowFlags(Qt::WindowFlags flags)
{
mWindowFlags = flags;
- platformScreen()->invalidateRectCache();
}
Qt::WindowFlags QFbWindow::windowFlags() const
@@ -120,20 +121,15 @@ void QFbWindow::lower()
void QFbWindow::repaint(const QRegion &region)
{
- QRect currentGeometry = geometry();
-
- QRect dirtyClient = region.boundingRect();
- QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(),
- currentGeometry.top() + dirtyClient.top(),
- dirtyClient.width(),
- dirtyClient.height());
- QRect mOldGeometryLocal = mOldGeometry;
+ const QRect currentGeometry = geometry();
+ const QRect dirtyClient = region.boundingRect();
+ const QRect dirtyRegion = dirtyClient.translated(currentGeometry.topLeft());
+ const QRect oldGeometryLocal = mOldGeometry;
mOldGeometry = currentGeometry;
// If this is a move, redraw the previous location
- if (mOldGeometryLocal != currentGeometry)
- platformScreen()->setDirty(mOldGeometryLocal);
+ if (oldGeometryLocal != currentGeometry)
+ platformScreen()->setDirty(oldGeometryLocal);
platformScreen()->setDirty(dirtyRegion);
}
QT_END_NAMESPACE
-
diff --git a/src/platformsupport/fontdatabases/fontdatabases.pro b/src/platformsupport/fontdatabases/fontdatabases.pro
index 9376c3b702..49dead4668 100644
--- a/src/platformsupport/fontdatabases/fontdatabases.pro
+++ b/src/platformsupport/fontdatabases/fontdatabases.pro
@@ -7,7 +7,7 @@ CONFIG += static internal_module
DEFINES += QT_NO_CAST_FROM_ASCII
PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h
-darwin:!if(watchos:CONFIG(simulator, simulator|device)) {
+darwin {
include($$PWD/mac/coretext.pri)
} else {
qtConfig(freetype) {
diff --git a/src/platformsupport/fontdatabases/mac/coretext.pri b/src/platformsupport/fontdatabases/mac/coretext.pri
index 1caeb2c1ac..df53f56933 100644
--- a/src/platformsupport/fontdatabases/mac/coretext.pri
+++ b/src/platformsupport/fontdatabases/mac/coretext.pri
@@ -14,3 +14,19 @@ else: \
# On Mac OS they are part of the ApplicationServices umbrella framework,
# even in 10.8 where they were also made available stand-alone.
LIBS_PRIVATE += -framework ApplicationServices
+
+# CoreText is documented to be available on watchOS, but the headers aren't present
+# in the watchOS Simulator SDK like they are supposed to be. Work around the problem
+# by adding the device SDK's headers to the search path as a fallback.
+# rdar://25314492, rdar://27844864
+watchos:simulator {
+ simulator_system_frameworks = $$xcodeSDKInfo(Path, $${simulator.sdk})/System/Library/Frameworks
+ device_system_frameworks = $$xcodeSDKInfo(Path, $${device.sdk})/System/Library/Frameworks
+ for (arch, QMAKE_APPLE_SIMULATOR_ARCHS) {
+ QMAKE_CXXFLAGS += \
+ -Xarch_$${arch} \
+ -F$$simulator_system_frameworks \
+ -Xarch_$${arch} \
+ -F$$device_system_frameworks
+ }
+}
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h
index bc0485232d..17bf0fb797 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h
@@ -52,7 +52,11 @@
//
#include "qnamespace.h"
+#ifdef Q_OS_FREEBSD
+#include <dev/evdev/input.h>
+#else
#include "linux/input.h"
+#endif
// no QT_BEGIN_NAMESPACE, since we include it internally...
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
index 0eb6fc0847..5c87cb7c9c 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
@@ -49,7 +49,11 @@
#include <qpa/qwindowsysteminterface.h>
#include <private/qcore_unix_p.h>
+#ifdef Q_OS_FREEBSD
+#include <dev/evdev/input.h>
+#else
#include <linux/input.h>
+#endif
QT_BEGIN_NAMESPACE
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
index d5ea04bee8..9b4bcf1575 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
+++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
@@ -53,8 +53,12 @@
#include <errno.h>
+#ifdef Q_OS_FREEBSD
+#include <dev/evdev/input.h>
+#else
#include <linux/kd.h>
#include <linux/input.h>
+#endif
#define TEST_BIT(array, bit) (array[bit/8] & (1<<(bit%8)))
diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp
index dc03daedda..86f8a00b13 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp
+++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp
@@ -45,7 +45,11 @@
#include <QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
#include <qpa/qwindowsysteminterface.h>
+#ifdef Q_OS_FREEBSD
+#include <dev/evdev/input.h>
+#else
#include <linux/input.h>
+#endif
QT_BEGIN_NAMESPACE
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
index d53a317fc5..6870fd3dde 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
@@ -48,7 +48,11 @@
#include <QtCore/private/qcore_unix_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtGui/private/qguiapplication_p.h>
+#ifdef Q_OS_FREEBSD
+#include <dev/evdev/input.h>
+#else
#include <linux/input.h>
+#endif
#if QT_CONFIG(mtdev)
extern "C" {
diff --git a/src/platformsupport/kmsconvenience/kmsconvenience.pro b/src/platformsupport/kmsconvenience/kmsconvenience.pro
new file mode 100644
index 0000000000..d0ff0d4efb
--- /dev/null
+++ b/src/platformsupport/kmsconvenience/kmsconvenience.pro
@@ -0,0 +1,20 @@
+TARGET = QtKmsSupport
+MODULE = kms_support
+
+QT = core-private gui-private
+CONFIG += static internal_module
+
+DEFINES += QT_NO_CAST_FROM_ASCII
+PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h
+
+HEADERS +=
+ qkmsdevice_p.h
+
+SOURCES += \
+ qkmsdevice.cpp
+
+QMAKE_USE += drm
+
+LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD
+
+load(qt_module)
diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp
new file mode 100644
index 0000000000..c265073214
--- /dev/null
+++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp
@@ -0,0 +1,608 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Pelagicore AG
+** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins 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 "qkmsdevice_p.h"
+
+#include <QtCore/QJsonDocument>
+#include <QtCore/QJsonObject>
+#include <QtCore/QJsonArray>
+#include <QtCore/QFile>
+#include <QtCore/QLoggingCategory>
+
+#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(qLcKmsDebug, "qt.qpa.eglfs.kms")
+
+enum OutputConfiguration {
+ OutputConfigOff,
+ OutputConfigPreferred,
+ OutputConfigCurrent,
+ OutputConfigMode,
+ OutputConfigModeline
+};
+
+int QKmsDevice::crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector)
+{
+ for (int i = 0; i < connector->count_encoders; i++) {
+ drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->encoders[i]);
+ if (!encoder) {
+ qWarning("Failed to get encoder");
+ continue;
+ }
+
+ quint32 possibleCrtcs = encoder->possible_crtcs;
+ drmModeFreeEncoder(encoder);
+
+ for (int j = 0; j < resources->count_crtcs; j++) {
+ bool isPossible = possibleCrtcs & (1 << j);
+ bool isAvailable = !(m_crtc_allocator & 1 << resources->crtcs[j]);
+
+ if (isPossible && isAvailable)
+ return j;
+ }
+ }
+
+ return -1;
+}
+
+static const char * const connector_type_names[] = { // must match DRM_MODE_CONNECTOR_*
+ "None",
+ "VGA",
+ "DVI",
+ "DVI",
+ "DVI",
+ "Composite",
+ "TV",
+ "LVDS",
+ "CTV",
+ "DIN",
+ "DP",
+ "HDMI",
+ "HDMI",
+ "TV",
+ "eDP",
+ "Virtual",
+ "DSI"
+};
+
+static QByteArray nameForConnector(const drmModeConnectorPtr connector)
+{
+ QByteArray connectorName("UNKNOWN");
+
+ if (connector->connector_type < ARRAY_LENGTH(connector_type_names))
+ connectorName = connector_type_names[connector->connector_type];
+
+ connectorName += QByteArray::number(connector->connector_type_id);
+
+ return connectorName;
+}
+
+static bool parseModeline(const QByteArray &text, drmModeModeInfoPtr mode)
+{
+ char hsync[16];
+ char vsync[16];
+ float fclock;
+
+ mode->type = DRM_MODE_TYPE_USERDEF;
+ mode->hskew = 0;
+ mode->vscan = 0;
+ mode->vrefresh = 0;
+ mode->flags = 0;
+
+ if (sscanf(text.constData(), "%f %hd %hd %hd %hd %hd %hd %hd %hd %15s %15s",
+ &fclock,
+ &mode->hdisplay,
+ &mode->hsync_start,
+ &mode->hsync_end,
+ &mode->htotal,
+ &mode->vdisplay,
+ &mode->vsync_start,
+ &mode->vsync_end,
+ &mode->vtotal, hsync, vsync) != 11)
+ return false;
+
+ mode->clock = fclock * 1000;
+
+ if (strcmp(hsync, "+hsync") == 0)
+ mode->flags |= DRM_MODE_FLAG_PHSYNC;
+ else if (strcmp(hsync, "-hsync") == 0)
+ mode->flags |= DRM_MODE_FLAG_NHSYNC;
+ else
+ return false;
+
+ if (strcmp(vsync, "+vsync") == 0)
+ mode->flags |= DRM_MODE_FLAG_PVSYNC;
+ else if (strcmp(vsync, "-vsync") == 0)
+ mode->flags |= DRM_MODE_FLAG_NVSYNC;
+ else
+ return false;
+
+ return true;
+}
+
+QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ drmModeConnectorPtr connector,
+ VirtualDesktopInfo *vinfo)
+{
+ const QByteArray connectorName = nameForConnector(connector);
+
+ const int crtc = crtcForConnector(resources, connector);
+ if (crtc < 0) {
+ qWarning() << "No usable crtc/encoder pair for connector" << connectorName;
+ return Q_NULLPTR;
+ }
+
+ OutputConfiguration configuration;
+ QSize configurationSize;
+ drmModeModeInfo configurationModeline;
+
+ auto userConfig = m_screenConfig->outputSettings();
+ auto userConnectorConfig = userConfig.value(QString::fromUtf8(connectorName));
+ // default to the preferred mode unless overridden in the config
+ const QByteArray mode = userConnectorConfig.value(QStringLiteral("mode"), QStringLiteral("preferred"))
+ .toByteArray().toLower();
+ if (mode == "off") {
+ configuration = OutputConfigOff;
+ } else if (mode == "preferred") {
+ configuration = OutputConfigPreferred;
+ } else if (mode == "current") {
+ configuration = OutputConfigCurrent;
+ } else if (sscanf(mode.constData(), "%dx%d", &configurationSize.rwidth(), &configurationSize.rheight()) == 2) {
+ configuration = OutputConfigMode;
+ } else if (parseModeline(mode, &configurationModeline)) {
+ configuration = OutputConfigModeline;
+ } else {
+ qWarning("Invalid mode \"%s\" for output %s", mode.constData(), connectorName.constData());
+ configuration = OutputConfigPreferred;
+ }
+ if (vinfo) {
+ *vinfo = VirtualDesktopInfo();
+ vinfo->virtualIndex = userConnectorConfig.value(QStringLiteral("virtualIndex"), INT_MAX).toInt();
+ if (userConnectorConfig.contains(QStringLiteral("virtualPos"))) {
+ const QByteArray vpos = userConnectorConfig.value(QStringLiteral("virtualPos")).toByteArray();
+ const QByteArrayList vposComp = vpos.split(',');
+ if (vposComp.count() == 2)
+ vinfo->virtualPos = QPoint(vposComp[0].trimmed().toInt(), vposComp[1].trimmed().toInt());
+ }
+ }
+
+ const uint32_t crtc_id = resources->crtcs[crtc];
+
+ if (configuration == OutputConfigOff) {
+ qCDebug(qLcKmsDebug) << "Turning off output" << connectorName;
+ drmModeSetCrtc(m_dri_fd, crtc_id, 0, 0, 0, 0, 0, Q_NULLPTR);
+ return Q_NULLPTR;
+ }
+
+ // Skip disconnected output
+ if (configuration == OutputConfigPreferred && connector->connection == DRM_MODE_DISCONNECTED) {
+ qCDebug(qLcKmsDebug) << "Skipping disconnected output" << connectorName;
+ return Q_NULLPTR;
+ }
+
+ // Get the current mode on the current crtc
+ drmModeModeInfo crtc_mode;
+ memset(&crtc_mode, 0, sizeof crtc_mode);
+ if (drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->connector_id)) {
+ drmModeCrtcPtr crtc = drmModeGetCrtc(m_dri_fd, encoder->crtc_id);
+ drmModeFreeEncoder(encoder);
+
+ if (!crtc)
+ return Q_NULLPTR;
+
+ if (crtc->mode_valid)
+ crtc_mode = crtc->mode;
+
+ drmModeFreeCrtc(crtc);
+ }
+
+ QList<drmModeModeInfo> modes;
+ modes.reserve(connector->count_modes);
+ qCDebug(qLcKmsDebug) << connectorName << "mode count:" << connector->count_modes;
+ for (int i = 0; i < connector->count_modes; i++) {
+ const drmModeModeInfo &mode = connector->modes[i];
+ qCDebug(qLcKmsDebug) << "mode" << i << mode.hdisplay << "x" << mode.vdisplay
+ << '@' << mode.vrefresh << "hz";
+ modes << connector->modes[i];
+ }
+
+ int preferred = -1;
+ int current = -1;
+ int configured = -1;
+ int best = -1;
+
+ for (int i = modes.size() - 1; i >= 0; i--) {
+ const drmModeModeInfo &m = modes.at(i);
+
+ if (configuration == OutputConfigMode &&
+ m.hdisplay == configurationSize.width() &&
+ m.vdisplay == configurationSize.height()) {
+ configured = i;
+ }
+
+ if (!memcmp(&crtc_mode, &m, sizeof m))
+ current = i;
+
+ if (m.type & DRM_MODE_TYPE_PREFERRED)
+ preferred = i;
+
+ best = i;
+ }
+
+ if (configuration == OutputConfigModeline) {
+ modes << configurationModeline;
+ configured = modes.size() - 1;
+ }
+
+ if (current < 0 && crtc_mode.clock != 0) {
+ modes << crtc_mode;
+ current = mode.size() - 1;
+ }
+
+ if (configuration == OutputConfigCurrent)
+ configured = current;
+
+ int selected_mode = -1;
+
+ if (configured >= 0)
+ selected_mode = configured;
+ else if (preferred >= 0)
+ selected_mode = preferred;
+ else if (current >= 0)
+ selected_mode = current;
+ else if (best >= 0)
+ selected_mode = best;
+
+ if (selected_mode < 0) {
+ qWarning() << "No modes available for output" << connectorName;
+ return Q_NULLPTR;
+ } else {
+ int width = modes[selected_mode].hdisplay;
+ int height = modes[selected_mode].vdisplay;
+ int refresh = modes[selected_mode].vrefresh;
+ qCDebug(qLcKmsDebug) << "Selected mode" << selected_mode << ":" << width << "x" << height
+ << '@' << refresh << "hz for output" << connectorName;
+ }
+
+ // physical size from connector < config values < env vars
+ static const int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH");
+ static const int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT");
+ QSizeF physSize(width, height);
+ if (physSize.isEmpty()) {
+ physSize = QSize(userConnectorConfig.value(QStringLiteral("physicalWidth")).toInt(),
+ userConnectorConfig.value(QStringLiteral("physicalHeight")).toInt());
+ if (physSize.isEmpty()) {
+ physSize.setWidth(connector->mmWidth);
+ physSize.setHeight(connector->mmHeight);
+ }
+ }
+ qCDebug(qLcKmsDebug) << "Physical size is" << physSize << "mm" << "for output" << connectorName;
+
+ QKmsOutput output = {
+ QString::fromUtf8(connectorName),
+ connector->connector_id,
+ crtc_id,
+ physSize,
+ selected_mode,
+ false,
+ drmModeGetCrtc(m_dri_fd, crtc_id),
+ modes,
+ connector->subpixel,
+ connectorProperty(connector, QByteArrayLiteral("DPMS"))
+ };
+
+ m_crtc_allocator |= (1 << output.crtc_id);
+ m_connector_allocator |= (1 << output.connector_id);
+
+ return createScreen(output);
+}
+
+drmModePropertyPtr QKmsDevice::connectorProperty(drmModeConnectorPtr connector, const QByteArray &name)
+{
+ drmModePropertyPtr prop;
+
+ for (int i = 0; i < connector->count_props; i++) {
+ prop = drmModeGetProperty(m_dri_fd, connector->props[i]);
+ if (!prop)
+ continue;
+ if (strcmp(prop->name, name.constData()) == 0)
+ return prop;
+ drmModeFreeProperty(prop);
+ }
+
+ return Q_NULLPTR;
+}
+
+QKmsDevice::QKmsDevice(QKmsScreenConfig *screenConfig, const QString &path)
+ : m_screenConfig(screenConfig)
+ , m_path(path)
+ , m_dri_fd(-1)
+ , m_crtc_allocator(0)
+ , m_connector_allocator(0)
+{
+ if (m_path.isEmpty()) {
+ m_path = m_screenConfig->devicePath();
+ qCDebug(qLcKmsDebug, "Using DRM device %s specified in config file", qPrintable(m_path));
+ if (m_path.isEmpty())
+ qFatal("No DRM device given");
+ } else {
+ qCDebug(qLcKmsDebug, "Using backend-provided DRM device %s", qPrintable(m_path));
+ }
+}
+
+QKmsDevice::~QKmsDevice()
+{
+}
+
+struct OrderedScreen
+{
+ OrderedScreen() : screen(nullptr) { }
+ OrderedScreen(QPlatformScreen *screen, const QKmsDevice::VirtualDesktopInfo &vinfo)
+ : screen(screen), vinfo(vinfo) { }
+ QPlatformScreen *screen;
+ QKmsDevice::VirtualDesktopInfo vinfo;
+};
+
+QDebug operator<<(QDebug dbg, const OrderedScreen &s)
+{
+ QDebugStateSaver saver(dbg);
+ dbg.nospace() << "OrderedScreen(" << s.screen << " : " << s.vinfo.virtualIndex
+ << " / " << s.vinfo.virtualPos << ")";
+ return dbg;
+}
+
+static bool orderedScreenLessThan(const OrderedScreen &a, const OrderedScreen &b)
+{
+ return a.vinfo.virtualIndex < b.vinfo.virtualIndex;
+}
+
+void QKmsDevice::createScreens()
+{
+ drmModeResPtr resources = drmModeGetResources(m_dri_fd);
+ if (!resources) {
+ qWarning("drmModeGetResources failed");
+ return;
+ }
+
+ QVector<OrderedScreen> screens;
+
+ for (int i = 0; i < resources->count_connectors; i++) {
+ drmModeConnectorPtr connector = drmModeGetConnector(m_dri_fd, resources->connectors[i]);
+ if (!connector)
+ continue;
+
+ VirtualDesktopInfo vinfo;
+ QPlatformScreen *screen = createScreenForConnector(resources, connector, &vinfo);
+ if (screen)
+ screens.append(OrderedScreen(screen, vinfo));
+
+ drmModeFreeConnector(connector);
+ }
+
+ drmModeFreeResources(resources);
+
+ // Use stable sort to preserve the original order for outputs with unspecified indices.
+ std::stable_sort(screens.begin(), screens.end(), orderedScreenLessThan);
+ qCDebug(qLcKmsDebug) << "Sorted screen list:" << screens;
+
+ QPoint pos(0, 0);
+ QList<QPlatformScreen *> siblings;
+ QVector<QPoint> virtualPositions;
+
+ for (const OrderedScreen &orderedScreen : screens) {
+ QPlatformScreen *s = orderedScreen.screen;
+ QPoint virtualPos(0, 0);
+ // set up a horizontal or vertical virtual desktop
+ if (orderedScreen.vinfo.virtualPos.isNull()) {
+ virtualPos = pos;
+ if (m_screenConfig->virtualDesktopLayout() == QKmsScreenConfig::VirtualDesktopLayoutVertical)
+ pos.ry() += s->geometry().height();
+ else
+ pos.rx() += s->geometry().width();
+ } else {
+ virtualPos = orderedScreen.vinfo.virtualPos;
+ }
+ qCDebug(qLcKmsDebug) << "Adding screen" << s << "to QPA with geometry" << s->geometry();
+ // The order in qguiapp's screens list will match the order set by
+ // virtualIndex. This is not only handy but also required since for instance
+ // evdevtouch relies on it when performing touch device - screen mapping.
+ if (!m_screenConfig->separateScreens()) {
+ siblings.append(s);
+ virtualPositions.append(virtualPos);
+ } else {
+ registerScreen(s, virtualPos, QList<QPlatformScreen *>() << s);
+ }
+ }
+
+ if (!m_screenConfig->separateScreens()) {
+ // enable the virtual desktop
+ for (int i = 0; i < siblings.count(); ++i)
+ registerScreen(siblings[i], virtualPositions[i], siblings);
+ }
+}
+
+int QKmsDevice::fd() const
+{
+ return m_dri_fd;
+}
+
+QString QKmsDevice::devicePath() const
+{
+ return m_path;
+}
+
+void QKmsDevice::setFd(int fd)
+{
+ m_dri_fd = fd;
+}
+
+QKmsScreenConfig *QKmsDevice::screenConfig() const
+{
+ return m_screenConfig;
+}
+
+QKmsScreenConfig::QKmsScreenConfig()
+ : m_hwCursor(true)
+ , m_separateScreens(false)
+ , m_pbuffers(false)
+ , m_virtualDesktopLayout(VirtualDesktopLayoutHorizontal)
+{
+ loadConfig();
+}
+
+void QKmsScreenConfig::loadConfig()
+{
+ static QByteArray json = qgetenv("QT_QPA_EGLFS_KMS_CONFIG");
+ if (json.isEmpty())
+ return;
+
+ qCDebug(qLcKmsDebug) << "Loading KMS setup from" << json;
+
+ QFile file(QString::fromUtf8(json));
+ if (!file.open(QFile::ReadOnly)) {
+ qCWarning(qLcKmsDebug) << "Could not open config file"
+ << json << "for reading";
+ return;
+ }
+
+ const QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
+ if (!doc.isObject()) {
+ qCWarning(qLcKmsDebug) << "Invalid config file" << json
+ << "- no top-level JSON object";
+ return;
+ }
+
+ const QJsonObject object = doc.object();
+
+ m_hwCursor = object.value(QLatin1String("hwcursor")).toBool(m_hwCursor);
+ m_pbuffers = object.value(QLatin1String("pbuffers")).toBool(m_pbuffers);
+ m_devicePath = object.value(QLatin1String("device")).toString();
+ m_separateScreens = object.value(QLatin1String("separateScreens")).toBool(m_separateScreens);
+
+ const QString vdOriString = object.value(QLatin1String("virtualDesktopLayout")).toString();
+ if (!vdOriString.isEmpty()) {
+ if (vdOriString == QLatin1String("horizontal"))
+ m_virtualDesktopLayout = VirtualDesktopLayoutHorizontal;
+ else if (vdOriString == QLatin1String("vertical"))
+ m_virtualDesktopLayout = VirtualDesktopLayoutVertical;
+ else
+ qCWarning(qLcKmsDebug) << "Unknown virtualDesktopOrientation value" << vdOriString;
+ }
+
+ const QJsonArray outputs = object.value(QLatin1String("outputs")).toArray();
+ for (int i = 0; i < outputs.size(); i++) {
+ const QVariantMap outputSettings = outputs.at(i).toObject().toVariantMap();
+
+ if (outputSettings.contains(QStringLiteral("name"))) {
+ const QString name = outputSettings.value(QStringLiteral("name")).toString();
+
+ if (m_outputSettings.contains(name)) {
+ qCDebug(qLcKmsDebug) << "Output" << name << "configured multiple times!";
+ }
+
+ m_outputSettings.insert(name, outputSettings);
+ }
+ }
+
+ qCDebug(qLcKmsDebug) << "Requested configuration (some settings may be ignored):\n"
+ << "\thwcursor:" << m_hwCursor << "\n"
+ << "\tpbuffers:" << m_pbuffers << "\n"
+ << "\tseparateScreens:" << m_separateScreens << "\n"
+ << "\tvirtualDesktopLayout:" << m_virtualDesktopLayout << "\n"
+ << "\toutputs:" << m_outputSettings;
+}
+
+void QKmsOutput::restoreMode(QKmsDevice *device)
+{
+ if (mode_set && saved_crtc) {
+ drmModeSetCrtc(device->fd(),
+ saved_crtc->crtc_id,
+ saved_crtc->buffer_id,
+ 0, 0,
+ &connector_id, 1,
+ &saved_crtc->mode);
+ mode_set = false;
+ }
+}
+
+void QKmsOutput::cleanup(QKmsDevice *device)
+{
+ if (dpms_prop) {
+ drmModeFreeProperty(dpms_prop);
+ dpms_prop = nullptr;
+ }
+
+ restoreMode(device);
+
+ if (saved_crtc) {
+ drmModeFreeCrtc(saved_crtc);
+ saved_crtc = nullptr;
+ }
+}
+
+QPlatformScreen::SubpixelAntialiasingType QKmsOutput::subpixelAntialiasingTypeHint() const
+{
+ switch (subpixel) {
+ default:
+ case DRM_MODE_SUBPIXEL_UNKNOWN:
+ case DRM_MODE_SUBPIXEL_NONE:
+ return QPlatformScreen::Subpixel_None;
+ case DRM_MODE_SUBPIXEL_HORIZONTAL_RGB:
+ return QPlatformScreen::Subpixel_RGB;
+ case DRM_MODE_SUBPIXEL_HORIZONTAL_BGR:
+ return QPlatformScreen::Subpixel_BGR;
+ case DRM_MODE_SUBPIXEL_VERTICAL_RGB:
+ return QPlatformScreen::Subpixel_VRGB;
+ case DRM_MODE_SUBPIXEL_VERTICAL_BGR:
+ return QPlatformScreen::Subpixel_VBGR;
+ }
+}
+
+void QKmsOutput::setPowerState(QKmsDevice *device, QPlatformScreen::PowerState state)
+{
+ if (dpms_prop)
+ drmModeConnectorSetProperty(device->fd(), connector_id,
+ dpms_prop->prop_id, (int) state);
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/kmsconvenience/qkmsdevice_p.h b/src/platformsupport/kmsconvenience/qkmsdevice_p.h
new file mode 100644
index 0000000000..36aba49ff2
--- /dev/null
+++ b/src/platformsupport/kmsconvenience/qkmsdevice_p.h
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Pelagicore AG
+** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins 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$
+**
+****************************************************************************/
+
+#ifndef QKMSDEVICE_P_H
+#define QKMSDEVICE_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 <qpa/qplatformscreen.h>
+#include <QtCore/QMap>
+#include <QtCore/QVariant>
+
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+
+QT_BEGIN_NAMESPACE
+
+class QKmsDevice;
+
+class QKmsScreenConfig
+{
+public:
+ enum VirtualDesktopLayout {
+ VirtualDesktopLayoutHorizontal,
+ VirtualDesktopLayoutVertical
+ };
+
+ QKmsScreenConfig();
+
+ QString devicePath() const { return m_devicePath; }
+
+ bool hwCursor() const { return m_hwCursor; }
+ bool separateScreens() const { return m_separateScreens; }
+ bool supportsPBuffers() const { return m_pbuffers; }
+ VirtualDesktopLayout virtualDesktopLayout() const { return m_virtualDesktopLayout; }
+
+ QMap<QString, QVariantMap> outputSettings() const { return m_outputSettings; }
+
+private:
+ void loadConfig();
+
+ QString m_devicePath;
+ bool m_hwCursor;
+ bool m_separateScreens;
+ bool m_pbuffers;
+ VirtualDesktopLayout m_virtualDesktopLayout;
+ QMap<QString, QVariantMap> m_outputSettings;
+};
+
+struct QKmsOutput
+{
+ QString name;
+ uint32_t connector_id;
+ uint32_t crtc_id;
+ QSizeF physical_size;
+ int mode; // index of selected mode in list below
+ bool mode_set;
+ drmModeCrtcPtr saved_crtc;
+ QList<drmModeModeInfo> modes;
+ int subpixel;
+ drmModePropertyPtr dpms_prop;
+
+ void restoreMode(QKmsDevice *device);
+ void cleanup(QKmsDevice *device);
+ QPlatformScreen::SubpixelAntialiasingType subpixelAntialiasingTypeHint() const;
+ void setPowerState(QKmsDevice *device, QPlatformScreen::PowerState state);
+};
+
+class QKmsDevice
+{
+public:
+ struct VirtualDesktopInfo {
+ VirtualDesktopInfo() : virtualIndex(0) { }
+ int virtualIndex;
+ QPoint virtualPos;
+ };
+
+ QKmsDevice(QKmsScreenConfig *screenConfig, const QString &path = QString());
+ virtual ~QKmsDevice();
+
+ virtual bool open() = 0;
+ virtual void close() = 0;
+ virtual void *nativeDisplay() const = 0;
+
+ void createScreens();
+
+ int fd() const;
+ QString devicePath() const;
+
+ QKmsScreenConfig *screenConfig() const;
+
+protected:
+ virtual QPlatformScreen *createScreen(const QKmsOutput &output) = 0;
+ virtual void registerScreen(QPlatformScreen *screen,
+ const QPoint &virtualPos,
+ const QList<QPlatformScreen *> &virtualSiblings) = 0;
+
+ void setFd(int fd);
+ int crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector);
+ QPlatformScreen *createScreenForConnector(drmModeResPtr resources,
+ drmModeConnectorPtr connector,
+ VirtualDesktopInfo *vinfo);
+ drmModePropertyPtr connectorProperty(drmModeConnectorPtr connector, const QByteArray &name);
+
+ QKmsScreenConfig *m_screenConfig;
+ QString m_path;
+ int m_dri_fd;
+
+ quint32 m_crtc_allocator;
+ quint32 m_connector_allocator;
+
+private:
+ Q_DISABLE_COPY(QKmsDevice)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro
index 09e2922505..7a97a12bae 100644
--- a/src/platformsupport/platformsupport.pro
+++ b/src/platformsupport/platformsupport.pro
@@ -7,7 +7,7 @@ SUBDIRS = \
fbconvenience \
themes
-qtConfig(freetype)|if(darwin:!if(watchos:CONFIG(simulator, simulator|device)))|win32: \
+qtConfig(freetype)|darwin|win32: \
SUBDIRS += fontdatabases
qtConfig(evdev)|qtConfig(tslib)|qtConfig(libinput) {
@@ -24,6 +24,8 @@ qtConfig(egl): \
SUBDIRS += eglconvenience
qtConfig(xlib):qtConfig(opengl):!qtConfig(opengles2): \
SUBDIRS += glxconvenience
+qtConfig(kms): \
+ SUBDIRS += kmsconvenience
qtConfig(accessibility) {
SUBDIRS += accessibility
diff --git a/src/plugins/platforms/bsdfb/qbsdfbscreen.cpp b/src/plugins/platforms/bsdfb/qbsdfbscreen.cpp
index 0ef57d37e5..03c6f0dbe9 100644
--- a/src/plugins/platforms/bsdfb/qbsdfbscreen.cpp
+++ b/src/plugins/platforms/bsdfb/qbsdfbscreen.cpp
@@ -243,7 +243,7 @@ QRegion QBsdFbScreen::doRedraw()
const auto rects = touched.rects();
for (const QRect &rect : rects)
- m_blitter->drawImage(rect, *mScreenImage, rect);
+ m_blitter->drawImage(rect, mScreenImage, rect);
return touched;
}
diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm
index c5ae4bc2bf..3b950efa55 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplication.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm
@@ -76,6 +76,7 @@
#include "qcocoaintrospection.h"
#include "qcocoaapplicationdelegate.h"
#include "qcocoahelpers.h"
+#include "qcocoawindow.h"
#include <qguiapplication.h>
#include <qdebug.h>
@@ -148,6 +149,21 @@ static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSE
@end
+static void qt_maybeSendKeyEquivalentUpEvent(NSEvent *event)
+{
+ // Cocoa is known for not sending key up events for key
+ // equivalents, regardless of whether it's an actual
+ // recognized key equivalent. We decide to force fate
+ // and forward the key event to the key (focus) window.
+ // However, non-Qt windows will not (and should not) get
+ // any special treatment, only QWindow-owned NSWindows.
+ if (event.type == NSKeyUp && (event.modifierFlags & NSCommandKeyMask)) {
+ NSWindow *targetWindow = event.window;
+ if ([targetWindow.class conformsToProtocol:@protocol(QNSWindowProtocol)])
+ [targetWindow sendEvent:event];
+ }
+}
+
@implementation QT_MANGLE_NAMESPACE(QNSApplication)
- (void)QT_MANGLE_NAMESPACE(qt_sendEvent_original):(NSEvent *)event
@@ -164,16 +180,20 @@ static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSE
// be called instead of sendEvent if redirection occurs.
// 'self' will then be an instance of NSApplication
// (and not QNSApplication)
- if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event])
+ if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event]) {
[self QT_MANGLE_NAMESPACE(qt_sendEvent_original):event];
+ qt_maybeSendKeyEquivalentUpEvent(event);
+ }
}
- (void)sendEvent:(NSEvent *)event
{
// This method will be called if
// no redirection occurs
- if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event])
+ if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event]) {
[super sendEvent:event];
+ qt_maybeSendKeyEquivalentUpEvent(event);
+ }
}
@end
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index a74995319b..1d7ad772dc 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -57,7 +57,8 @@ QCocoaBackingStore::~QCocoaBackingStore()
QImage::Format QCocoaBackingStore::format() const
{
- if (static_cast<QCocoaWindow *>(window()->handle())->m_drawContentBorderGradient)
+ QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window()->handle());
+ if (cocoaWindow && cocoaWindow->m_drawContentBorderGradient)
return QImage::Format_ARGB32_Premultiplied;
return QRasterBackingStore::format();
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm
index 7d11023b78..de4fa95530 100644
--- a/src/plugins/platforms/cocoa/qcocoadrag.mm
+++ b/src/plugins/platforms/cocoa/qcocoadrag.mm
@@ -132,7 +132,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
QPixmap pm = dragPixmap(m_drag, hotSpot);
QSize pmDeviceIndependentSize = pm.size() / pm.devicePixelRatio();
NSImage *nsimage = qt_mac_create_nsimage(pm);
- [nsimage setSize:pmDeviceIndependentSize.toCGSize()];
+ [nsimage setSize:NSSizeFromCGSize(pmDeviceIndependentSize.toCGSize())];
QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacInternalPasteboardMime::MIME_DND);
m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index 234da57f59..41a809cdd2 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -63,6 +63,7 @@
#include <stdlib.h>
#include <qabstracteventdispatcher.h>
#include <qsysinfo.h>
+#include <qoperatingsystemversion.h>
#include <qglobal.h>
#include <QDir>
@@ -164,7 +165,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
[mSavePanel setDelegate:self];
#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_11)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_11)
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::OSXElCapitan)
mOpenPanel.accessoryViewDisclosed = YES;
#endif
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index 01fbb7bad2..fa0365dbf7 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -160,10 +160,8 @@ Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions)
*/
QNSView *qnsview_cast(NSView *view)
{
- if (![view isKindOfClass:[QNSView class]]) {
- qCWarning(lcQpaCocoaWindow) << "NSView is not QNSView, consider checking for Qt::ForeignWindow";
+ if (![view isKindOfClass:[QNSView class]])
return nil;
- }
return static_cast<QNSView *>(view);
}
@@ -235,13 +233,13 @@ QString qt_mac_applicationName()
return appName;
}
-int qt_mac_mainScreenHeight()
+int qt_mac_primaryScreenHeight()
{
QMacAutoReleasePool pool;
NSArray *screens = [NSScreen screens];
if ([screens count] > 0) {
- // The first screen in the screens array is documented
- // to have the (0,0) origin.
+ // The first screen in the screens array is documented to
+ // have the (0,0) origin and is designated the primary screen.
NSRect screenFrame = [[screens objectAtIndex: 0] frame];
return screenFrame.size.height;
}
@@ -250,12 +248,12 @@ int qt_mac_mainScreenHeight()
int qt_mac_flipYCoordinate(int y)
{
- return qt_mac_mainScreenHeight() - y;
+ return qt_mac_primaryScreenHeight() - y;
}
qreal qt_mac_flipYCoordinate(qreal y)
{
- return qt_mac_mainScreenHeight() - y;
+ return qt_mac_primaryScreenHeight() - y;
}
QPointF qt_mac_flipPoint(const NSPoint &p)
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index 32f6fe0af1..5cf8e7d237 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
class QCocoaScreen : public QPlatformScreen
{
public:
- QCocoaScreen(int screenIndex);
+ QCocoaScreen(NSScreen *screen);
~QCocoaScreen();
// ----------------------------------------------------
@@ -84,11 +84,20 @@ public:
// ----------------------------------------------------
// Additional methods
void setVirtualSiblings(const QList<QPlatformScreen *> &siblings) { m_siblings = siblings; }
- NSScreen *osScreen() const;
+ NSScreen *nsScreen() const;
void updateGeometry();
+ QPointF mapToNative(const QPointF &pos) const { return flipCoordinate(pos); }
+ QRectF mapToNative(const QRectF &rect) const { return flipCoordinate(rect); }
+ QPointF mapFromNative(const QPointF &pos) const { return flipCoordinate(pos); }
+ QRectF mapFromNative(const QRectF &rect) const { return flipCoordinate(rect); }
+
+private:
+ QPointF flipCoordinate(const QPointF &pos) const;
+ QRectF flipCoordinate(const QRectF &rect) const;
+
public:
- int m_screenIndex;
+ NSScreen *m_nsScreen;
QRect m_geometry;
QRect m_availableGeometry;
QDpi m_logicalDpi;
@@ -144,7 +153,7 @@ public:
QList<int> possibleKeys(const QKeyEvent *event) const Q_DECL_OVERRIDE;
void updateScreens();
- QCocoaScreen *screenAtIndex(int index);
+ QCocoaScreen *screenForNSScreen(NSScreen *nsScreen);
void setToolbar(QWindow *window, NSToolbar *toolbar);
NSToolbar *toolbar(QWindow *window) const;
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 92fffb4d15..7e9f554520 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -69,8 +69,8 @@ static void initResources()
QT_BEGIN_NAMESPACE
-QCocoaScreen::QCocoaScreen(int screenIndex) :
- QPlatformScreen(), m_screenIndex(screenIndex), m_refreshRate(60.0)
+QCocoaScreen::QCocoaScreen(NSScreen *screen)
+ : QPlatformScreen(), m_nsScreen(screen), m_refreshRate(60.0)
{
updateGeometry();
m_cursor = new QCocoaCursor;
@@ -81,46 +81,63 @@ QCocoaScreen::~QCocoaScreen()
delete m_cursor;
}
-NSScreen *QCocoaScreen::osScreen() const
+NSScreen *QCocoaScreen::nsScreen() const
{
- NSArray *screens = [NSScreen screens];
- return ((NSUInteger)m_screenIndex < [screens count]) ? [screens objectAtIndex:m_screenIndex] : nil;
+ return m_nsScreen;
+}
+
+/*!
+ Flips the Y coordinate of the point between quadrant I and IV.
+
+ The native coordinate system on macOS uses quadrant I, with origin
+ in bottom left, and Qt uses quadrant IV, with origin in top left.
+
+ By flippig the Y coordinate, we can map the position between the
+ two coordinate systems.
+*/
+QPointF QCocoaScreen::flipCoordinate(const QPointF &pos) const
+{
+ return QPointF(pos.x(), m_geometry.height() - pos.y());
+}
+
+/*!
+ Flips the Y coordinate of the rectangle between quadrant I and IV.
+
+ The native coordinate system on macOS uses quadrant I, with origin
+ in bottom left, and Qt uses quadrant IV, with origin in top left.
+
+ By flippig the Y coordinate, we can map the rectangle between the
+ two coordinate systems.
+*/
+QRectF QCocoaScreen::flipCoordinate(const QRectF &rect) const
+{
+ return QRectF(flipCoordinate(rect.topLeft() + QPoint(0, rect.height())), rect.size());
}
void QCocoaScreen::updateGeometry()
{
- NSScreen *nsScreen = osScreen();
- if (!nsScreen)
+ if (!m_nsScreen)
return;
- NSRect frameRect = [nsScreen frame];
+ // At this point the geometry is in native coordinates, but the size
+ // is correct, which we take advantage of next when we map the native
+ // coordinates to the Qt coordinate system.
+ m_geometry = QRectF::fromCGRect(NSRectToCGRect(m_nsScreen.frame)).toRect();
+ m_availableGeometry = QRectF::fromCGRect(NSRectToCGRect(m_nsScreen.visibleFrame)).toRect();
- if (m_screenIndex == 0) {
- m_geometry = QRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width, frameRect.size.height);
- // This is the primary screen, the one that contains the menubar. Its origin should be
- // (0, 0), and it's the only one whose available geometry differs from its full geometry.
- NSRect visibleRect = [nsScreen visibleFrame];
- m_availableGeometry = QRect(visibleRect.origin.x,
- frameRect.size.height - (visibleRect.origin.y + visibleRect.size.height), // invert y
- visibleRect.size.width, visibleRect.size.height);
- } else {
- // NSScreen origin is at the bottom-left corner, QScreen is at the top-left corner.
- // When we get the NSScreen frame rect, we need to re-align its origin y coordinate
- // w.r.t. the primary screen, whose origin is (0, 0).
- NSRect r = [[[NSScreen screens] objectAtIndex:0] frame];
- QRect referenceScreenGeometry = QRect(r.origin.x, r.origin.y, r.size.width, r.size.height);
- m_geometry = QRect(frameRect.origin.x,
- referenceScreenGeometry.height() - (frameRect.origin.y + frameRect.size.height),
- frameRect.size.width, frameRect.size.height);
-
- // Not primary screen. See above.
- m_availableGeometry = m_geometry;
- }
+ // The reference screen for the geometry is always the primary screen, but since
+ // we may be in the process of creating and registering the primary screen, we
+ // must special-case that and assign it direcly.
+ QCocoaScreen *primaryScreen = (m_nsScreen == [[NSScreen screens] firstObject]) ?
+ this : static_cast<QCocoaScreen*>(QGuiApplication::primaryScreen()->handle());
+
+ m_geometry = primaryScreen->mapFromNative(m_geometry).toRect();
+ m_availableGeometry = primaryScreen->mapFromNative(m_availableGeometry).toRect();
m_format = QImage::Format_RGB32;
- m_depth = NSBitsPerPixelFromDepth([nsScreen depth]);
+ m_depth = NSBitsPerPixelFromDepth([m_nsScreen depth]);
- NSDictionary *devDesc = [nsScreen deviceDescription];
+ NSDictionary *devDesc = [m_nsScreen deviceDescription];
CGDirectDisplayID dpy = [[devDesc objectForKey:@"NSScreenNumber"] unsignedIntValue];
CGSize size = CGDisplayScreenSize(dpy);
m_physicalSize = QSizeF(size.width, size.height);
@@ -147,8 +164,7 @@ void QCocoaScreen::updateGeometry()
qreal QCocoaScreen::devicePixelRatio() const
{
QMacAutoReleasePool pool;
- NSScreen * screen = osScreen();
- return qreal(screen ? [screen backingScaleFactor] : 1.0);
+ return qreal(m_nsScreen ? [m_nsScreen backingScaleFactor] : 1.0);
}
QPlatformScreen::SubpixelAntialiasingType QCocoaScreen::subpixelAntialiasingTypeHint() const
@@ -423,7 +439,7 @@ void QCocoaIntegration::updateScreens()
// NSScreen documentation says do not cache the array returned from [NSScreen screens].
// However in practice, we can identify a screen by its pointer: if resolution changes,
// the NSScreen object will be the same instance, just with different values.
- if (existingScr->osScreen() == scr) {
+ if (existingScr->nsScreen() == scr) {
screen = existingScr;
break;
}
@@ -431,7 +447,7 @@ void QCocoaIntegration::updateScreens()
remainingScreens.remove(screen);
screen->updateGeometry();
} else {
- screen = new QCocoaScreen(i);
+ screen = new QCocoaScreen(scr);
mScreens.append(screen);
screenAdded(screen);
}
@@ -451,16 +467,21 @@ void QCocoaIntegration::updateScreens()
}
}
-QCocoaScreen *QCocoaIntegration::screenAtIndex(int index)
+QCocoaScreen *QCocoaIntegration::screenForNSScreen(NSScreen *nsScreen)
{
- if (index >= mScreens.count())
+ NSUInteger index = [[NSScreen screens] indexOfObject:nsScreen];
+ if (index == NSNotFound)
+ return 0;
+
+ if (index >= unsigned(mScreens.count()))
updateScreens();
- // It is possible that the screen got removed while updateScreens was called
- // so we do a sanity check to be certain
- if (index >= mScreens.count())
- return 0;
- return mScreens.at(index);
+ for (QCocoaScreen *screen : mScreens) {
+ if (screen->nsScreen() == nsScreen)
+ return screen;
+ }
+
+ return 0;
}
bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 16639fd8b1..ac5f1a6851 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -96,6 +96,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindowHelper);
@property (nonatomic, readonly) QNSWindowHelper *helper;
- (id)initWithContentRect:(NSRect)contentRect
+ screen:(NSScreen*)screen
styleMask:(NSUInteger)windowStyle
qPlatformWindow:(QCocoaWindow *)qpw;
@@ -111,6 +112,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindow);
@property (nonatomic, readonly) QNSWindowHelper *helper;
- (id)initWithContentRect:(NSRect)contentRect
+ screen:(NSScreen*)screen
styleMask:(NSUInteger)windowStyle
qPlatformWindow:(QCocoaWindow *)qpw;
@@ -141,6 +143,13 @@ QT_BEGIN_NAMESPACE
// See the qt_on_cocoa manual tests for a working example, located
// in tests/manual/cocoa at the time of writing.
+#ifdef Q_MOC_RUN
+#define Q_NOTIFICATION_HANDLER(notification) Q_INVOKABLE Q_COCOA_NOTIFICATION_##notification
+#else
+#define Q_NOTIFICATION_HANDLER(notification)
+#define Q_NOTIFICATION_PREFIX QT_STRINGIFY2(Q_COCOA_NOTIFICATION_)
+#endif
+
class QCocoaMenuBar;
class QCocoaWindow : public QObject, public QPlatformWindow
@@ -187,12 +196,25 @@ public:
void setEmbeddedInForeignView(bool subwindow);
- void windowWillMove();
- void windowDidMove();
- void windowDidResize();
- void windowDidEndLiveResize();
+ Q_NOTIFICATION_HANDLER(NSWindowWillMoveNotification) void windowWillMove();
+ Q_NOTIFICATION_HANDLER(NSWindowDidMoveNotification) void windowDidMove();
+ Q_NOTIFICATION_HANDLER(NSWindowDidResizeNotification) void windowDidResize();
+ Q_NOTIFICATION_HANDLER(NSViewFrameDidChangeNotification) void viewDidChangeFrame();
+ Q_NOTIFICATION_HANDLER(NSViewGlobalFrameDidChangeNotification) void viewDidChangeGlobalFrame();
+ Q_NOTIFICATION_HANDLER(NSWindowDidEndLiveResizeNotification) void windowDidEndLiveResize();
+ Q_NOTIFICATION_HANDLER(NSWindowDidBecomeKeyNotification) void windowDidBecomeKey();
+ Q_NOTIFICATION_HANDLER(NSWindowDidResignKeyNotification) void windowDidResignKey();
+ Q_NOTIFICATION_HANDLER(NSWindowDidMiniaturizeNotification) void windowDidMiniaturize();
+ Q_NOTIFICATION_HANDLER(NSWindowDidDeminiaturizeNotification) void windowDidDeminiaturize();
+ Q_NOTIFICATION_HANDLER(NSWindowDidEnterFullScreenNotification) void windowDidEnterFullScreen();
+ Q_NOTIFICATION_HANDLER(NSWindowDidExitFullScreenNotification) void windowDidExitFullScreen();
+ Q_NOTIFICATION_HANDLER(NSWindowDidOrderOffScreenNotification) void windowDidOrderOffScreen();
+ Q_NOTIFICATION_HANDLER(NSWindowDidOrderOnScreenAndFinishAnimatingNotification) void windowDidOrderOnScreen();
+ Q_NOTIFICATION_HANDLER(NSWindowDidChangeOcclusionStateNotification) void windowDidChangeOcclusionState();
+ Q_NOTIFICATION_HANDLER(NSWindowDidChangeScreenNotification) void windowDidChangeScreen();
+ Q_NOTIFICATION_HANDLER(NSWindowWillCloseNotification) void windowWillClose();
+
bool windowShouldClose();
- void windowWillClose();
bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const;
void setSynchedWindowStateFromWindow();
@@ -239,19 +261,33 @@ public:
static QPoint bottomLeftClippedByNSWindowOffsetStatic(QWindow *window);
QPoint bottomLeftClippedByNSWindowOffset() const;
+
+ enum RecreationReason {
+ RecreationNotNeeded = 0,
+ ParentChanged = 0x1,
+ MissingWindow = 0x2,
+ WindowModalityChanged = 0x4,
+ ChildNSWindowChanged = 0x8,
+ ContentViewChanged = 0x10,
+ PanelChanged = 0x20,
+ };
+ Q_DECLARE_FLAGS(RecreationReasons, RecreationReason)
+ Q_FLAG(RecreationReasons)
+
protected:
- void recreateWindow(const QPlatformWindow *parentWindow);
- QCocoaNSWindow *createNSWindow();
- void setNSWindow(QCocoaNSWindow *window);
+ bool isChildNSWindow() const;
+ bool isContentView() const;
- bool shouldUseNSPanel();
+ void foreachChildNSWindow(void (^block)(QCocoaWindow *));
+
+ void recreateWindowIfNeeded();
+ QCocoaNSWindow *createNSWindow(bool shouldBeChildNSWindow, bool shouldBePanel);
QRect nativeWindowGeometry() const;
QCocoaWindow *parentCocoaWindow() const;
void syncWindowState(Qt::WindowState newState);
void reinsertChildWindow(QCocoaWindow *child);
void removeChildWindow(QCocoaWindow *child);
- bool isNativeWindowTypeInconsistent();
// private:
public: // for QNSView
@@ -268,10 +304,6 @@ public: // for QNSView
bool m_viewIsEmbedded; // true if the m_view is actually embedded in a "foreign" NSView hiearchy
bool m_viewIsToBeEmbedded; // true if the m_view is intended to be embedded in a "foreign" NSView hiearchy
- QCocoaWindow *m_parentCocoaWindow;
- bool m_isNSWindowChild; // this window is a non-top level QWindow with a NSWindow.
- QList<QCocoaWindow *> m_childWindows;
-
Qt::WindowFlags m_windowFlags;
bool m_effectivelyMaximized;
Qt::WindowState m_synchedWindowState;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 602da0a175..0b33b9255f 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -130,8 +130,7 @@ static void qt_closePopups()
[forwardView mouseDragged:theEvent];
}
}
-
- if (!pw->m_isNSWindowChild && theEvent.type == NSLeftMouseDown) {
+ if (pw->window()->isTopLevel() && theEvent.type == NSLeftMouseDown) {
pw->m_forwardWindow.clear();
}
}
@@ -202,13 +201,14 @@ static void qt_closePopups()
@synthesize helper = _helper;
- (id)initWithContentRect:(NSRect)contentRect
+ screen:(NSScreen*)screen
styleMask:(NSUInteger)windowStyle
qPlatformWindow:(QCocoaWindow *)qpw
{
self = [super initWithContentRect:contentRect
styleMask:windowStyle
backing:NSBackingStoreBuffered
- defer:NO]; // Deferring window creation breaks OpenGL (the GL context is
+ defer:NO screen:screen]; // Deferring window creation breaks OpenGL (the GL context is
// set up before the window is shown and needs a proper window)
if (self) {
@@ -222,7 +222,7 @@ static void qt_closePopups()
// Prevent child NSWindows from becoming the key window in
// order keep the active apperance of the top-level window.
QCocoaWindow *pw = self.helper.platformWindow;
- if (!pw || pw->m_isNSWindowChild)
+ if (!pw || !pw->window()->isTopLevel())
return NO;
if (pw->shouldRefuseKeyWindowAndFirstResponder())
@@ -241,7 +241,7 @@ static void qt_closePopups()
// Windows with a transient parent (such as combobox popup windows)
// cannot become the main window:
QCocoaWindow *pw = self.helper.platformWindow;
- if (!pw || pw->m_isNSWindowChild || pw->window()->transientParent())
+ if (!pw || !pw->window()->isTopLevel() || pw->window()->transientParent())
canBecomeMain = NO;
return canBecomeMain;
@@ -284,13 +284,14 @@ static void qt_closePopups()
@synthesize helper = _helper;
- (id)initWithContentRect:(NSRect)contentRect
+ screen:(NSScreen*)screen
styleMask:(NSUInteger)windowStyle
qPlatformWindow:(QCocoaWindow *)qpw
{
self = [super initWithContentRect:contentRect
styleMask:windowStyle
backing:NSBackingStoreBuffered
- defer:NO]; // Deferring window creation breaks OpenGL (the GL context is
+ defer:NO screen:screen]; // Deferring window creation breaks OpenGL (the GL context is
// set up before the window is shown and needs a proper window)
if (self) {
@@ -343,6 +344,63 @@ static void qt_closePopups()
@end
+static void qRegisterNotificationCallbacks()
+{
+ static const QLatin1String notificationHandlerPrefix(Q_NOTIFICATION_PREFIX);
+
+ NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+
+ const QMetaObject *metaObject = QMetaType::metaObjectForType(qRegisterMetaType<QCocoaWindow*>());
+ Q_ASSERT(metaObject);
+
+ for (int i = 0; i < metaObject->methodCount(); ++i) {
+ QMetaMethod method = metaObject->method(i);
+ const QString methodTag = QString::fromLatin1(method.tag());
+ if (!methodTag.startsWith(notificationHandlerPrefix))
+ continue;
+
+ const QString notificationName = methodTag.mid(notificationHandlerPrefix.size());
+ [center addObserverForName:notificationName.toNSString() object:nil queue:nil
+ usingBlock:^(NSNotification *notification) {
+
+ NSView *view = nullptr;
+ if ([notification.object isKindOfClass:[NSWindow class]]) {
+ NSWindow *window = notification.object;
+ // Only top level NSWindows should notify their QNSViews
+ if (window.parentWindow)
+ return;
+
+ if (!window.contentView)
+ return;
+
+ view = window.contentView;
+ } else if ([notification.object isKindOfClass:[NSView class]]) {
+ view = notification.object;
+ } else {
+ qCWarning(lcQpaCocoaWindow) << "Unhandled notifcation"
+ << notification.name << "for" << notification.object;
+ return;
+ }
+ Q_ASSERT(view);
+
+ QCocoaWindow *cocoaWindow = nullptr;
+ if (QNSView *qnsView = qnsview_cast(view))
+ cocoaWindow = qnsView.platformWindow;
+
+ // FIXME: Could be a foreign window, look up by iterating top level QWindows
+
+ if (!cocoaWindow)
+ return;
+
+ if (!method.invoke(cocoaWindow, Qt::DirectConnection)) {
+ qCWarning(lcQpaCocoaWindow) << "Failed to invoke NSNotification callback for"
+ << notification.name << "on" << cocoaWindow;
+ }
+ }];
+ }
+}
+Q_CONSTRUCTOR_FUNCTION(qRegisterNotificationCallbacks)
+
const int QCocoaWindow::NoAlertRequest = -1;
QCocoaWindow::QCocoaWindow(QWindow *tlw)
@@ -351,8 +409,6 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_nsWindow(0)
, m_viewIsEmbedded(false)
, m_viewIsToBeEmbedded(false)
- , m_parentCocoaWindow(0)
- , m_isNSWindowChild(false)
, m_effectivelyMaximized(false)
, m_synchedWindowState(Qt::WindowActive)
, m_windowModality(Qt::NonModal)
@@ -405,7 +461,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
[m_view setWantsLayer:enable];
}
setGeometry(tlw->geometry());
- recreateWindow(QPlatformWindow::parent());
+ recreateWindowIfNeeded();
tlw->setGeometry(geometry());
if (tlw->isTopLevel())
setWindowIcon(tlw->icon());
@@ -420,12 +476,10 @@ QCocoaWindow::~QCocoaWindow()
[m_nsWindow makeFirstResponder:nil];
[m_nsWindow setContentView:nil];
[m_nsWindow.helper detachFromPlatformWindow];
- if (m_isNSWindowChild) {
- if (m_parentCocoaWindow)
- m_parentCocoaWindow->removeChildWindow(this);
- } else if ([m_view superview]) {
+ if (m_view.window.parentWindow)
+ [m_view.window.parentWindow removeChildWindow:m_view.window];
+ else if ([m_view superview])
[m_view removeFromSuperview];
- }
removeMonitor();
@@ -440,10 +494,9 @@ QCocoaWindow::~QCocoaWindow()
QCocoaIntegration::instance()->popupWindowStack()->removeAll(this);
}
- foreach (QCocoaWindow *child, m_childWindows) {
- [m_nsWindow removeChildWindow:child->m_nsWindow];
- child->m_parentCocoaWindow = 0;
- }
+ foreachChildNSWindow(^(QCocoaWindow *childWindow) {
+ [m_nsWindow removeChildWindow:childWindow->m_nsWindow];
+ });
[m_view release];
[m_nsWindow release];
@@ -491,7 +544,7 @@ QRect QCocoaWindow::geometry() const
NSRect screenRect = [[m_view window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
NSPoint screenPoint = screenRect.origin;
QPoint position = qt_mac_flipPoint(screenPoint).toPoint();
- QSize size = QRectF::fromCGRect([m_view bounds]).toRect().size();
+ QSize size = QRectF::fromCGRect(NSRectToCGRect([m_view bounds])).toRect().size();
return QRect(position, size);
}
@@ -512,9 +565,9 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect)
return;
}
- if (m_isNSWindowChild) {
+ if (isChildNSWindow()) {
QPlatformWindow::setGeometry(rect);
- NSWindow *parentNSWindow = m_parentCocoaWindow->m_nsWindow;
+ NSWindow *parentNSWindow = m_view.window.parentWindow;
NSRect parentWindowFrame = [parentNSWindow contentRectForFrameRect:parentNSWindow.frame];
clipWindow(parentWindowFrame);
@@ -536,14 +589,14 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect)
void QCocoaWindow::clipChildWindows()
{
- foreach (QCocoaWindow *childWindow, m_childWindows) {
+ foreachChildNSWindow(^(QCocoaWindow *childWindow) {
childWindow->clipWindow(m_nsWindow.frame);
- }
+ });
}
void QCocoaWindow::clipWindow(const NSRect &clipRect)
{
- if (!m_isNSWindowChild)
+ if (!isChildNSWindow())
return;
NSRect clippedWindowRect = NSZeroRect;
@@ -568,15 +621,15 @@ void QCocoaWindow::clipWindow(const NSRect &clipRect)
m_hiddenByClipping = false;
if (!m_hiddenByAncestor) {
[m_nsWindow orderFront:nil];
- m_parentCocoaWindow->reinsertChildWindow(this);
+ static_cast<QCocoaWindow *>(QPlatformWindow::parent())->reinsertChildWindow(this);
}
}
}
// recurse
- foreach (QCocoaWindow *childWindow, m_childWindows) {
+ foreachChildNSWindow(^(QCocoaWindow *childWindow) {
childWindow->clipWindow(clippedWindowRect);
- }
+ });
}
void QCocoaWindow::hide(bool becauseOfAncestor)
@@ -593,8 +646,9 @@ void QCocoaWindow::hide(bool becauseOfAncestor)
if (!visible) // Could have been clipped before
return;
- foreach (QCocoaWindow *childWindow, m_childWindows)
+ foreachChildNSWindow(^(QCocoaWindow *childWindow) {
childWindow->hide(true);
+ });
[m_nsWindow orderOut:nil];
}
@@ -604,20 +658,21 @@ void QCocoaWindow::show(bool becauseOfAncestor)
if ([m_nsWindow isVisible])
return;
- if (m_parentCocoaWindow && ![m_parentCocoaWindow->m_nsWindow isVisible]) {
+ if (m_view.window.parentWindow && !m_view.window.parentWindow.visible) {
m_hiddenByAncestor = true; // Parent still hidden, don't show now
} else if ((becauseOfAncestor == m_hiddenByAncestor) // Was NEITHER explicitly hidden
&& !m_hiddenByClipping) { // ... NOR clipped
- if (m_isNSWindowChild) {
+ if (isChildNSWindow()) {
m_hiddenByAncestor = false;
setCocoaGeometry(windowGeometry());
}
if (!m_hiddenByClipping) { // setCocoaGeometry() can change the clipping status
[m_nsWindow orderFront:nil];
- if (m_isNSWindowChild)
- m_parentCocoaWindow->reinsertChildWindow(this);
- foreach (QCocoaWindow *childWindow, m_childWindows)
+ if (isChildNSWindow())
+ static_cast<QCocoaWindow *>(QPlatformWindow::parent())->reinsertChildWindow(this);
+ foreachChildNSWindow(^(QCocoaWindow *childWindow) {
childWindow->show(true);
+ });
}
}
}
@@ -626,7 +681,7 @@ void QCocoaWindow::setVisible(bool visible)
{
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setVisible" << window() << visible;
- if (m_isNSWindowChild && m_hiddenByClipping)
+ if (isChildNSWindow() && m_hiddenByClipping)
return;
m_inSetVisible = true;
@@ -638,8 +693,7 @@ void QCocoaWindow::setVisible(bool visible)
if (visible) {
// We need to recreate if the modality has changed as the style mask will need updating
- if (m_windowModality != window()->modality() || isNativeWindowTypeInconsistent())
- recreateWindow(QPlatformWindow::parent());
+ recreateWindowIfNeeded();
// Register popup windows. The Cocoa platform plugin will forward mouse events
// to them and close them when needed.
@@ -700,8 +754,9 @@ void QCocoaWindow::setVisible(bool visible)
else
[m_nsWindow orderFront:nil];
- foreach (QCocoaWindow *childWindow, m_childWindows)
+ foreachChildNSWindow(^(QCocoaWindow *childWindow) {
childWindow->show(true);
+ });
} else {
show();
}
@@ -879,7 +934,7 @@ void QCocoaWindow::setWindowZoomButton(Qt::WindowFlags flags)
void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
{
- if (m_nsWindow && !m_isNSWindowChild) {
+ if (m_nsWindow && !isChildNSWindow()) {
NSUInteger styleMask = windowStyleMask(flags);
NSInteger level = this->windowLevel(flags);
// While setting style mask we can have -updateGeometry calls on a content
@@ -983,19 +1038,16 @@ void QCocoaWindow::raise()
// ### handle spaces (see Qt 4 raise_sys in qwidget_mac.mm)
if (!m_nsWindow)
return;
- if (m_isNSWindowChild) {
- QList<QCocoaWindow *> &siblings = m_parentCocoaWindow->m_childWindows;
- siblings.removeOne(this);
- siblings.append(this);
+ if (isChildNSWindow()) {
if (m_hiddenByClipping)
return;
}
if ([m_nsWindow isVisible]) {
- if (m_isNSWindowChild) {
+ if (isChildNSWindow()) {
// -[NSWindow orderFront:] doesn't work with attached windows.
// The only solution is to remove and add the child window.
// This will place it on top of all the other NSWindows.
- NSWindow *parentNSWindow = m_parentCocoaWindow->m_nsWindow;
+ NSWindow *parentNSWindow = m_view.window.parentWindow;
[parentNSWindow removeChildWindow:m_nsWindow];
[parentNSWindow addChildWindow:m_nsWindow ordered:NSWindowAbove];
} else {
@@ -1021,20 +1073,17 @@ void QCocoaWindow::lower()
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::lower" << window();
if (!m_nsWindow)
return;
- if (m_isNSWindowChild) {
- QList<QCocoaWindow *> &siblings = m_parentCocoaWindow->m_childWindows;
- siblings.removeOne(this);
- siblings.prepend(this);
+ if (isChildNSWindow()) {
if (m_hiddenByClipping)
return;
}
if ([m_nsWindow isVisible]) {
- if (m_isNSWindowChild) {
+ if (isChildNSWindow()) {
// -[NSWindow orderBack:] doesn't work with attached windows.
// The only solution is to remove and add all the child windows except this one.
// This will keep the current window at the bottom while adding the others on top of it,
// hopefully in the same order (this is not documented anywhere in the Cocoa documentation).
- NSWindow *parentNSWindow = m_parentCocoaWindow->m_nsWindow;
+ NSWindow *parentNSWindow = m_view.window.parentWindow;
NSArray *children = [parentNSWindow.childWindows copy];
for (NSWindow *child in children)
if (m_nsWindow != child) {
@@ -1095,7 +1144,7 @@ void QCocoaWindow::propagateSizeHints()
QSize sizeIncrement = windowSizeIncrement();
if (sizeIncrement.isEmpty())
sizeIncrement = QSize(1, 1);
- [m_nsWindow setResizeIncrements:sizeIncrement.toCGSize()];
+ [m_nsWindow setResizeIncrements:NSSizeFromCGSize(sizeIncrement.toCGSize())];
QRect rect = geometry();
QSize baseSize = windowBaseSize();
@@ -1158,7 +1207,7 @@ void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
// recreate the window for compatibility
bool unhideAfterRecreate = parentWindow && !m_viewIsToBeEmbedded && ![m_view isHidden];
- recreateWindow(parentWindow);
+ recreateWindowIfNeeded();
if (unhideAfterRecreate)
[m_view setHidden:NO];
setCocoaGeometry(geometry());
@@ -1182,6 +1231,8 @@ void QCocoaWindow::setEmbeddedInForeignView(bool embedded)
m_nsWindow = 0;
}
+// ----------------------- NSWindow notifications -----------------------
+
void QCocoaWindow::windowWillMove()
{
// Close any open popups on window move
@@ -1190,7 +1241,7 @@ void QCocoaWindow::windowWillMove()
void QCocoaWindow::windowDidMove()
{
- if (m_isNSWindowChild)
+ if (isChildNSWindow())
return;
[qnsview_cast(m_view) updateGeometry];
@@ -1201,13 +1252,30 @@ void QCocoaWindow::windowDidResize()
if (!m_nsWindow)
return;
- if (m_isNSWindowChild)
+ if (isChildNSWindow())
return;
clipChildWindows();
[qnsview_cast(m_view) updateGeometry];
}
+void QCocoaWindow::viewDidChangeFrame()
+{
+ [qnsview_cast(m_view) updateGeometry];
+}
+
+/*!
+ Callback for NSViewGlobalFrameDidChangeNotification.
+
+ Posted whenever an NSView object that has attached surfaces (that is,
+ NSOpenGLContext objects) moves to a different screen, or other cases
+ where the NSOpenGLContext object needs to be updated.
+*/
+void QCocoaWindow::viewDidChangeGlobalFrame()
+{
+ updateExposedGeometry();
+}
+
void QCocoaWindow::windowDidEndLiveResize()
{
if (m_synchedWindowState == Qt::WindowMaximized && ![m_nsWindow isZoomed]) {
@@ -1216,6 +1284,104 @@ void QCocoaWindow::windowDidEndLiveResize()
}
}
+void QCocoaWindow::windowDidBecomeKey()
+{
+ if (window()->type() == Qt::ForeignWindow)
+ return;
+
+ if (m_windowUnderMouse) {
+ QPointF windowPoint;
+ QPointF screenPoint;
+ [qnsview_cast(m_view) convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
+ QWindowSystemInterface::handleEnterEvent(m_enterLeaveTargetWindow, windowPoint, screenPoint);
+ }
+
+ if (!windowIsPopupType() && !qnsview_cast(m_view).isMenuView)
+ QWindowSystemInterface::handleWindowActivated(window());
+}
+
+void QCocoaWindow::windowDidResignKey()
+{
+ if (window()->type() == Qt::ForeignWindow)
+ return;
+
+ // Key window will be non-nil if another window became key, so do not
+ // set the active window to zero here -- the new key window's
+ // NSWindowDidBecomeKeyNotification hander will change the active window.
+ NSWindow *keyWindow = [NSApp keyWindow];
+ if (!keyWindow || keyWindow == m_view.window) {
+ // No new key window, go ahead and set the active window to zero
+ if (!windowIsPopupType() && !qnsview_cast(m_view).isMenuView)
+ QWindowSystemInterface::handleWindowActivated(0);
+ }
+}
+
+void QCocoaWindow::windowDidMiniaturize()
+{
+ [qnsview_cast(m_view) notifyWindowStateChanged:Qt::WindowMinimized];
+}
+
+void QCocoaWindow::windowDidDeminiaturize()
+{
+ [qnsview_cast(m_view) notifyWindowStateChanged:Qt::WindowNoState];
+}
+
+void QCocoaWindow::windowDidEnterFullScreen()
+{
+ [qnsview_cast(m_view) notifyWindowStateChanged:Qt::WindowFullScreen];
+}
+
+void QCocoaWindow::windowDidExitFullScreen()
+{
+ [qnsview_cast(m_view) notifyWindowStateChanged:Qt::WindowNoState];
+}
+
+void QCocoaWindow::windowDidOrderOffScreen()
+{
+ obscureWindow();
+}
+
+void QCocoaWindow::windowDidOrderOnScreen()
+{
+ exposeWindow();
+}
+
+void QCocoaWindow::windowDidChangeOcclusionState()
+{
+ // Several unit tests expect paint and/or expose events for windows that are
+ // sometimes (unpredictably) occluded and some unit tests depend on QWindow::isExposed.
+ // Don't send Expose/Obscure events when running under QTestLib.
+ static const bool onTestLib = qt_mac_resolveOption(false, "QT_QTESTLIB_RUNNING");
+ if (!onTestLib) {
+ if ((NSUInteger)[m_view.window occlusionState] & NSWindowOcclusionStateVisible) {
+ exposeWindow();
+ } else {
+ // Send Obscure events on window occlusion to stop animations.
+ obscureWindow();
+ }
+ }
+}
+
+void QCocoaWindow::windowDidChangeScreen()
+{
+ if (!window())
+ return;
+
+ if (QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenForNSScreen(m_view.window.screen))
+ QWindowSystemInterface::handleWindowScreenChanged(window(), cocoaScreen->screen());
+
+ updateExposedGeometry();
+}
+
+void QCocoaWindow::windowWillClose()
+{
+ // Close any open popups on window closing.
+ if (window() && !windowIsPopupType(window()->type()))
+ qt_closePopups();
+}
+
+// ----------------------- NSWindowDelegate callbacks -----------------------
+
bool QCocoaWindow::windowShouldClose()
{
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::windowShouldClose" << window();
@@ -1229,12 +1395,7 @@ bool QCocoaWindow::windowShouldClose()
return accepted;
}
-void QCocoaWindow::windowWillClose()
-{
- // Close any open popups on window closing.
- if (window() && !windowIsPopupType(window()->type()))
- qt_closePopups();
-}
+// --------------------------------------------------------------------------
void QCocoaWindow::setSynchedWindowStateFromWindow()
{
@@ -1264,62 +1425,141 @@ QCocoaGLContext *QCocoaWindow::currentContext() const
}
#endif
-void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
+/*!
+ Checks if the window is a non-top level QWindow with a NSWindow.
+
+ \sa _q_platform_MacUseNSWindow, QT_MAC_USE_NSWINDOW
+*/
+bool QCocoaWindow::isChildNSWindow() const
{
- qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::recreateWindow" << window()
+ return m_view.window.parentWindow != nil;
+}
+
+/*!
+ Checks if the window is the content view of its immediate NSWindow.
+
+ Being the content view of a NSWindow means the QWindow is
+ the highest accessible NSView object in the window's view
+ hierarchy.
+
+ This can only happen in two cases, either if the QWindow is
+ itself a top level window, or if it's a child NSWindow.
+
+ \sa isChildNSWindow
+*/
+bool QCocoaWindow::isContentView() const
+{
+ return m_view.window.contentView == m_view;
+}
+
+/*!
+ Iterates child NSWindows that have a corresponding QCocoaWindow.
+*/
+void QCocoaWindow::foreachChildNSWindow(void (^block)(QCocoaWindow *))
+{
+ NSArray *windows = m_view.window.childWindows;
+ [windows enumerateObjectsUsingBlock:^(NSWindow *window, NSUInteger index, BOOL *stop) {
+ Q_UNUSED(index);
+ Q_UNUSED(stop);
+ if (QNSView *view = qnsview_cast(window.contentView))
+ block(view.platformWindow);
+ }];
+}
+
+/*!
+ Recreates (or removes) the NSWindow for this QWindow, if needed.
+
+ A QWindow may need a corresponding NSWindow, depending on whether
+ or not it's a top level or not (or explicitly set to be a child
+ NSWindow), whether it is a NSPanel or not, etc.
+*/
+void QCocoaWindow::recreateWindowIfNeeded()
+{
+ QPlatformWindow *parentWindow = QPlatformWindow::parent();
+ qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::recreateWindowIfNeeded" << window()
<< "parent" << (parentWindow ? parentWindow->window() : 0);
- bool wasNSWindowChild = m_isNSWindowChild;
- BOOL requestNSWindowChild = qt_mac_resolveOption(NO, window(), "_q_platform_MacUseNSWindow",
- "QT_MAC_USE_NSWINDOW");
- m_isNSWindowChild = parentWindow && requestNSWindowChild;
- bool needsNSWindow = m_isNSWindowChild || !parentWindow;
+ RecreationReasons recreateReason = RecreationNotNeeded;
+
+ QCocoaWindow *oldParentCocoaWindow = nullptr;
+ if (QNSView *qnsView = qnsview_cast(m_view.superview))
+ oldParentCocoaWindow = qnsView.platformWindow;
+
+ if (parentWindow != oldParentCocoaWindow)
+ recreateReason |= ParentChanged;
+
+ if (!m_view.window)
+ recreateReason |= MissingWindow;
+
+ // If the modality has changed the style mask will need updating
+ if (m_windowModality != window()->modality())
+ recreateReason |= WindowModalityChanged;
+
+ const bool shouldBeChildNSWindow = parentWindow && qt_mac_resolveOption(NO,
+ window(), "_q_platform_MacUseNSWindow", "QT_MAC_USE_NSWINDOW");
+
+ if (isChildNSWindow() != shouldBeChildNSWindow)
+ recreateReason |= ChildNSWindowChanged;
+
+ const bool shouldBeContentView = !parentWindow || shouldBeChildNSWindow;
+ if (isContentView() != shouldBeContentView)
+ recreateReason |= ContentViewChanged;
- QCocoaWindow *oldParentCocoaWindow = m_parentCocoaWindow;
- m_parentCocoaWindow = const_cast<QCocoaWindow *>(static_cast<const QCocoaWindow *>(parentWindow));
- if (m_parentCocoaWindow && m_isNSWindowChild) {
- QWindow *parentQWindow = m_parentCocoaWindow->window();
+ Qt::WindowType type = window()->type();
+ const bool isPanel = isContentView() && [m_view.window isKindOfClass:[QNSPanel class]];
+ const bool shouldBePanel = shouldBeContentView && !shouldBeChildNSWindow &&
+ ((type & Qt::Popup) == Qt::Popup || (type & Qt::Dialog) == Qt::Dialog);
+
+ if (isPanel != shouldBePanel)
+ recreateReason |= PanelChanged;
+
+ if (recreateReason == RecreationNotNeeded) {
+ qCDebug(lcQpaCocoaWindow) << "No need to recreate NSWindow";
+ return;
+ }
+
+ qCDebug(lcQpaCocoaWindow) << "Recreating NSWindow due to" << recreateReason;
+
+ QCocoaWindow *parentCocoaWindow = static_cast<QCocoaWindow *>(parentWindow);
+
+ if (shouldBeChildNSWindow) {
+ QWindow *parentQWindow = parentWindow->window();
+ // Ensure that all parents in the hierarchy are also child NSWindows
if (!parentQWindow->property("_q_platform_MacUseNSWindow").toBool()) {
parentQWindow->setProperty("_q_platform_MacUseNSWindow", QVariant(true));
- m_parentCocoaWindow->recreateWindow(m_parentCocoaWindow->m_parentCocoaWindow);
+ parentCocoaWindow->recreateWindowIfNeeded();
}
}
- bool usesNSPanel = [m_nsWindow isKindOfClass:[QNSPanel class]];
-
- // No child QNSWindow should notify its QNSView
- if (m_nsWindow && (window()->type() != Qt::ForeignWindow) && m_parentCocoaWindow && !oldParentCocoaWindow)
- [[NSNotificationCenter defaultCenter] removeObserver:m_view
- name:nil object:m_nsWindow];
-
// Remove current window (if any)
- if ((m_nsWindow && !needsNSWindow) || (usesNSPanel != shouldUseNSPanel())) {
+ if ((isContentView() && !shouldBeContentView) || (recreateReason & PanelChanged)) {
[m_nsWindow closeAndRelease];
- if (wasNSWindowChild && oldParentCocoaWindow)
- oldParentCocoaWindow->removeChildWindow(this);
+ if (isChildNSWindow())
+ [m_view.window.parentWindow removeChildWindow:m_view.window];
m_nsWindow = 0;
}
- if (needsNSWindow) {
+ if (shouldBeContentView) {
bool noPreviousWindow = m_nsWindow == 0;
if (noPreviousWindow)
- m_nsWindow = createNSWindow();
-
- // Only non-child QNSWindows should notify their QNSViews
- // (but don't register more than once).
- if ((window()->type() != Qt::ForeignWindow) && (noPreviousWindow || (wasNSWindowChild && !m_isNSWindowChild)))
- [[NSNotificationCenter defaultCenter] addObserver:m_view
- selector:@selector(windowNotification:)
- name:nil // Get all notifications
- object:m_nsWindow];
-
- if (oldParentCocoaWindow) {
- if (!m_isNSWindowChild || oldParentCocoaWindow != m_parentCocoaWindow)
- oldParentCocoaWindow->removeChildWindow(this);
+ m_nsWindow = createNSWindow(shouldBeChildNSWindow, shouldBePanel);
+
+ if (m_view.window.parentWindow) {
+ if (!shouldBeChildNSWindow || (recreateReason & ParentChanged))
+ [m_view.window.parentWindow removeChildWindow:m_view.window];
m_forwardWindow = oldParentCocoaWindow;
}
- setNSWindow(m_nsWindow);
+ // Move view to new NSWindow if needed
+ if (m_nsWindow.contentView != m_view) {
+ [m_view setPostsFrameChangedNotifications:NO];
+ [m_view retain];
+ if (m_view.superview) // m_view comes from another NSWindow
+ [m_view removeFromSuperview];
+ [m_nsWindow setContentView:m_view];
+ [m_view release];
+ [m_view setPostsFrameChangedNotifications:YES];
+ }
}
if (m_viewIsToBeEmbedded) {
@@ -1330,7 +1570,13 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
setWindowFlags(window()->flags());
setWindowTitle(window()->title());
setWindowState(window()->windowState());
- } else if (m_isNSWindowChild) {
+ } else if (shouldBeChildNSWindow) {
+ if (!m_hiddenByClipping) {
+ [parentCocoaWindow->m_nsWindow addChildWindow:m_nsWindow ordered:NSWindowAbove];
+ parentCocoaWindow->reinsertChildWindow(this);
+ }
+
+ // Set properties after the window has been made a child NSWindow
m_nsWindow.styleMask = NSBorderlessWindowMask;
m_nsWindow.hasShadow = NO;
m_nsWindow.level = NSNormalWindowLevel;
@@ -1340,22 +1586,12 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
m_nsWindow.animationBehavior = NSWindowAnimationBehaviorNone;
m_nsWindow.collectionBehavior = collectionBehavior;
setCocoaGeometry(windowGeometry());
-
- QList<QCocoaWindow *> &siblings = m_parentCocoaWindow->m_childWindows;
- if (siblings.contains(this)) {
- if (!m_hiddenByClipping)
- m_parentCocoaWindow->reinsertChildWindow(this);
- } else {
- if (!m_hiddenByClipping)
- [m_parentCocoaWindow->m_nsWindow addChildWindow:m_nsWindow ordered:NSWindowAbove];
- siblings.append(this);
- }
} else {
// Child windows have no NSWindow, link the NSViews instead.
if ([m_view superview])
[m_view removeFromSuperview];
- [m_parentCocoaWindow->m_view addSubview:m_view];
+ [parentCocoaWindow->m_view addSubview:m_view];
QRect rect = windowGeometry();
// Prevent setting a (0,0) window size; causes opengl context
// "Invalid Drawable" warnings.
@@ -1381,11 +1617,17 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
void QCocoaWindow::reinsertChildWindow(QCocoaWindow *child)
{
- int childIndex = m_childWindows.indexOf(child);
+ const QObjectList &childWindows = window()->children();
+ int childIndex = childWindows.indexOf(child->window());
Q_ASSERT(childIndex != -1);
- for (int i = childIndex; i < m_childWindows.size(); i++) {
- NSWindow *nsChild = m_childWindows[i]->m_nsWindow;
+ for (int i = childIndex; i < childWindows.size(); ++i) {
+ QWindow *window = static_cast<QWindow *>(childWindows.at(i));
+ QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
+ if (!cocoaWindow)
+ continue;
+
+ NSWindow *nsChild = cocoaWindow->m_nsWindow;
if (i != childIndex)
[m_nsWindow removeChildWindow:nsChild];
[m_nsWindow addChildWindow:nsChild ordered:NSWindowAbove];
@@ -1399,26 +1641,39 @@ void QCocoaWindow::requestActivateWindow()
[window makeKeyWindow];
}
-bool QCocoaWindow::shouldUseNSPanel()
-{
- Qt::WindowType type = window()->type();
-
- return !m_isNSWindowChild &&
- ((type & Qt::Popup) == Qt::Popup || (type & Qt::Dialog) == Qt::Dialog);
-}
-
-QCocoaNSWindow * QCocoaWindow::createNSWindow()
+QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBeChildNSWindow, bool shouldBePanel)
{
QMacAutoReleasePool pool;
QRect rect = initialGeometry(window(), windowGeometry(), defaultWindowWidth, defaultWindowHeight);
- NSRect frame = qt_mac_flipRect(rect);
+
+ QScreen *targetScreen = nullptr;
+ for (QScreen *screen : QGuiApplication::screens()) {
+ if (screen->geometry().contains(rect.topLeft())) {
+ targetScreen = screen;
+ break;
+ }
+ }
+
+ if (!targetScreen) {
+ qCWarning(lcQpaCocoaWindow) << "Window position outside any known screen, using primary screen";
+ targetScreen = QGuiApplication::primaryScreen();
+ }
+
+ rect.translate(-targetScreen->geometry().topLeft());
+ QCocoaScreen *cocoaScreen = static_cast<QCocoaScreen *>(targetScreen->handle());
+ NSRect frame = NSRectFromCGRect(cocoaScreen->mapToNative(rect).toCGRect());
+
+ // Note: The macOS window manager has a bug, where if a screen is rotated, it will not allow
+ // a window to be created within the area of the screen that has a Y coordinate (I quadrant)
+ // higher than the height of the screen in its non-rotated state, unless the window is
+ // created with the NSWindowStyleMaskBorderless style mask.
Qt::WindowType type = window()->type();
Qt::WindowFlags flags = window()->flags();
NSUInteger styleMask;
- if (m_isNSWindowChild) {
+ if (shouldBeChildNSWindow) {
styleMask = NSBorderlessWindowMask;
} else {
styleMask = windowStyleMask(flags);
@@ -1427,32 +1682,28 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
// Use NSPanel for popup-type windows. (Popup, Tool, ToolTip, SplashScreen)
// and dialogs
- if (shouldUseNSPanel()) {
- QNSPanel *window;
- window = [[QNSPanel alloc] initWithContentRect:frame
- styleMask: styleMask
- qPlatformWindow:this];
+ if (shouldBePanel) {
+ QNSPanel *panel = [[QNSPanel alloc] initWithContentRect:frame screen:cocoaScreen->nsScreen()
+ styleMask: styleMask qPlatformWindow:this];
+
if ((type & Qt::Popup) == Qt::Popup)
- [window setHasShadow:YES];
+ [panel setHasShadow:YES];
// Qt::Tool windows hide on app deactivation, unless Qt::WA_MacAlwaysShowToolWindow is set.
QVariant showWithoutActivating = QPlatformWindow::window()->property("_q_macAlwaysShowToolWindow");
bool shouldHideOnDeactivate = ((type & Qt::Tool) == Qt::Tool) &&
!(showWithoutActivating.isValid() && showWithoutActivating.toBool());
- [window setHidesOnDeactivate: shouldHideOnDeactivate];
+ [panel setHidesOnDeactivate: shouldHideOnDeactivate];
// Make popup windows show on the same desktop as the parent full-screen window.
- [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
+ [panel setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
if ((type & Qt::Popup) == Qt::Popup)
- [window setAnimationBehavior:NSWindowAnimationBehaviorUtilityWindow];
+ [panel setAnimationBehavior:NSWindowAnimationBehaviorUtilityWindow];
- createdWindow = window;
+ createdWindow = panel;
} else {
- QNSWindow *window;
- window = [[QNSWindow alloc] initWithContentRect:frame
- styleMask: styleMask
- qPlatformWindow:this];
- createdWindow = window;
+ createdWindow = [[QNSWindow alloc] initWithContentRect:frame screen:cocoaScreen->nsScreen()
+ styleMask: styleMask qPlatformWindow:this];
}
if ([createdWindow respondsToSelector:@selector(setRestorable:)])
@@ -1479,36 +1730,6 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
return createdWindow;
}
-void QCocoaWindow::setNSWindow(QCocoaNSWindow *window)
-{
- if (window.contentView != m_view) {
- [m_view setPostsFrameChangedNotifications:NO];
- [m_view retain];
- if (m_view.superview) // m_view comes from another NSWindow
- [m_view removeFromSuperview];
- [window setContentView:m_view];
- [m_view release];
- [m_view setPostsFrameChangedNotifications:YES];
- }
-}
-
-void QCocoaWindow::removeChildWindow(QCocoaWindow *child)
-{
- m_childWindows.removeOne(child);
- [m_nsWindow removeChildWindow:child->m_nsWindow];
-}
-
-bool QCocoaWindow::isNativeWindowTypeInconsistent()
-{
- if (!m_nsWindow)
- return false;
-
- const bool isPanel = [m_nsWindow isKindOfClass:[QNSPanel class]];
- const bool usePanel = shouldUseNSPanel();
-
- return isPanel != usePanel;
-}
-
void QCocoaWindow::removeMonitor()
{
if (!monitor)
@@ -1520,7 +1741,7 @@ void QCocoaWindow::removeMonitor()
// Returns the current global screen geometry for the nswindow associated with this window.
QRect QCocoaWindow::nativeWindowGeometry() const
{
- if (!m_nsWindow || m_isNSWindowChild)
+ if (!m_nsWindow || isChildNSWindow())
return geometry();
NSRect rect = [m_nsWindow frame];
@@ -1819,12 +2040,8 @@ void QCocoaWindow::exposeWindow()
// time, and we won't get a NSWindowDidChangeScreenNotification
// on show. The case where the window is initially displayed
// on a non-primary screen needs special handling here.
- NSUInteger screenIndex = [[NSScreen screens] indexOfObject:m_nsWindow.screen];
- if (screenIndex != NSNotFound) {
- QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex);
- if (cocoaScreen)
- window()->setScreen(cocoaScreen->screen());
- }
+ if (QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenForNSScreen(m_nsWindow.screen))
+ window()->setScreen(cocoaScreen->screen());
if (!m_isExposed) {
m_isExposed = true;
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index f226547b90..84be7eb797 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -74,7 +74,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
QStringList *currentCustomDragTypes;
bool m_sendUpAsRightButton;
Qt::KeyboardModifiers currentWheelModifiers;
- bool m_subscribesForGlobalFrameNotifications;
#ifndef QT_NO_OPENGL
QCocoaGLContext *m_glContext;
bool m_shouldSetGLContextinDrawRect;
@@ -102,7 +101,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
- (void)drawBackingStoreUsingCoreGraphics:(NSRect)dirtyRect;
- (void)updateGeometry;
- (void)notifyWindowStateChanged:(Qt::WindowState)newState;
-- (void)windowNotification : (NSNotification *) windowNotification;
- (void)notifyWindowWillZoom:(BOOL)willZoom;
- (void)textInputContextKeyboardSelectionDidChangeNotification : (NSNotification *) textInputContextKeyboardSelectionDidChangeNotification;
- (void)viewDidHide;
@@ -152,6 +150,11 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
@end
+@interface QT_MANGLE_NAMESPACE(QNSView) (QtExtras)
+@property (nonatomic, readonly) QCocoaWindow *platformWindow;
+@property (nonatomic, readonly) BOOL isMenuView;
+@end
+
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSView);
#endif //QNSVIEW_H
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index a63bc4d570..689fd06d66 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -149,7 +149,6 @@ static bool _q_dontOverrideCtrlLMB = false;
m_acceptedMouseDowns = Qt::NoButton;
m_frameStrutButtons = Qt::NoButton;
m_sendKeyEvent = false;
- m_subscribesForGlobalFrameNotifications = false;
#ifndef QT_NO_OPENGL
m_glContext = 0;
m_shouldSetGLContextinDrawRect = false;
@@ -181,7 +180,6 @@ static bool _q_dontOverrideCtrlLMB = false;
CGImageRelease(m_maskImage);
[m_trackingArea release];
m_maskImage = 0;
- m_subscribesForGlobalFrameNotifications = false;
[m_inputSource release];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[m_mouseMoveHelper release];
@@ -217,11 +215,6 @@ static bool _q_dontOverrideCtrlLMB = false;
#endif
[self registerDragTypes];
- [self setPostsFrameChangedNotifications : YES];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(updateGeometry)
- name:NSViewFrameDidChangeNotification
- object:self];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(textInputContextKeyboardSelectionDidChangeNotification:)
@@ -240,27 +233,9 @@ static bool _q_dontOverrideCtrlLMB = false;
//was unable to set view
m_shouldSetGLContextinDrawRect = true;
}
-
- if (!m_subscribesForGlobalFrameNotifications) {
- // NSOpenGLContext expects us to repaint (or update) the view when
- // it changes position on screen. Since this happens unnoticed for
- // the view when the parent view moves, we need to register a special
- // notification that lets us handle this case:
- m_subscribesForGlobalFrameNotifications = true;
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(globalFrameChanged:)
- name:NSViewGlobalFrameDidChangeNotification
- object:self];
- }
}
#endif
-- (void) globalFrameChanged:(NSNotification*)notification
-{
- Q_UNUSED(notification);
- m_platformWindow->updateExposedGeometry();
-}
-
- (void)viewDidMoveToSuperview
{
if (!(m_platformWindow->m_viewIsToBeEmbedded))
@@ -281,22 +256,6 @@ static bool _q_dontOverrideCtrlLMB = false;
m_backingStore = Q_NULLPTR;
}
-- (void)viewWillMoveToWindow:(NSWindow *)newWindow
-{
- // ### Merge "normal" window code path with this one for 5.1.
- if (!(m_platformWindow->window()->type() & Qt::SubWindow))
- return;
-
- if (newWindow) {
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(windowNotification:)
- name:nil // Get all notifications
- object:newWindow];
- }
- if ([self window])
- [[NSNotificationCenter defaultCenter] removeObserver:self name:nil object:[self window]];
-}
-
- (QWindow *)topLevelWindow
{
QWindow *focusWindow = m_platformWindow->window();
@@ -316,7 +275,7 @@ static bool _q_dontOverrideCtrlLMB = false;
{
QRect geometry;
- if (m_platformWindow->m_isNSWindowChild) {
+ if (self.window.parentWindow) {
return;
#if 0
//geometry = QRectF::fromCGRect([self frame]).toRect();
@@ -336,10 +295,10 @@ static bool _q_dontOverrideCtrlLMB = false;
geometry = QRect(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height);
} else if (m_platformWindow->m_viewIsToBeEmbedded) {
// embedded child window, use the frame rect ### merge with case below
- geometry = QRectF::fromCGRect([self bounds]).toRect();
+ geometry = QRectF::fromCGRect(NSRectToCGRect([self bounds])).toRect();
} else {
// child window, use the frame rect
- geometry = QRectF::fromCGRect([self frame]).toRect();
+ geometry = QRectF::fromCGRect(NSRectToCGRect([self frame])).toRect();
}
if (m_platformWindow->m_nsWindow && geometry == m_platformWindow->geometry())
@@ -395,64 +354,6 @@ static bool _q_dontOverrideCtrlLMB = false;
m_platformWindow->setSynchedWindowStateFromWindow();
}
-- (void)windowNotification : (NSNotification *) windowNotification
-{
- //qDebug() << "windowNotification" << QString::fromNSString([windowNotification name]);
-
- NSString *notificationName = [windowNotification name];
- if (notificationName == NSWindowDidBecomeKeyNotification) {
- if (!m_platformWindow->windowIsPopupType() && !m_isMenuView)
- QWindowSystemInterface::handleWindowActivated(m_platformWindow->window());
- } else if (notificationName == NSWindowDidResignKeyNotification) {
- // key window will be non-nil if another window became key... do not
- // set the active window to zero here, the new key window's
- // NSWindowDidBecomeKeyNotification hander will change the active window
- NSWindow *keyWindow = [NSApp keyWindow];
- if (!keyWindow || keyWindow == windowNotification.object) {
- // no new key window, go ahead and set the active window to zero
- if (!m_platformWindow->windowIsPopupType() && !m_isMenuView)
- QWindowSystemInterface::handleWindowActivated(0);
- }
- } else if (notificationName == NSWindowDidMiniaturizeNotification
- || notificationName == NSWindowDidDeminiaturizeNotification) {
- Qt::WindowState newState = notificationName == NSWindowDidMiniaturizeNotification ?
- Qt::WindowMinimized : Qt::WindowNoState;
- [self notifyWindowStateChanged:newState];
- } else if ([notificationName isEqualToString: @"NSWindowDidOrderOffScreenNotification"]) {
- m_platformWindow->obscureWindow();
- } else if ([notificationName isEqualToString: @"NSWindowDidOrderOnScreenAndFinishAnimatingNotification"]) {
- m_platformWindow->exposeWindow();
- } else if ([notificationName isEqualToString:NSWindowDidChangeOcclusionStateNotification]) {
- // Several unit tests expect paint and/or expose events for windows that are
- // sometimes (unpredictably) occluded and some unit tests depend on QWindow::isExposed -
- // don't send Expose/Obscure events when running under QTestLib.
- static const bool onTestLib = qt_mac_resolveOption(false, "QT_QTESTLIB_RUNNING");
- if (!onTestLib) {
- if ((NSUInteger)[self.window occlusionState] & NSWindowOcclusionStateVisible) {
- m_platformWindow->exposeWindow();
- } else {
- // Send Obscure events on window occlusion to stop animations.
- m_platformWindow->obscureWindow();
- }
- }
- } else if (notificationName == NSWindowDidChangeScreenNotification) {
- if (m_platformWindow->window()) {
- NSUInteger screenIndex = [[NSScreen screens] indexOfObject:self.window.screen];
- if (screenIndex != NSNotFound) {
- QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex);
- if (cocoaScreen)
- QWindowSystemInterface::handleWindowScreenChanged(m_platformWindow->window(), cocoaScreen->screen());
- m_platformWindow->updateExposedGeometry();
- }
- }
- } else if (notificationName == NSWindowDidEnterFullScreenNotification
- || notificationName == NSWindowDidExitFullScreenNotification) {
- Qt::WindowState newState = notificationName == NSWindowDidEnterFullScreenNotification ?
- Qt::WindowFullScreen : Qt::WindowNoState;
- [self notifyWindowStateChanged:newState];
- }
-}
-
- (void)textInputContextKeyboardSelectionDidChangeNotification : (NSNotification *) textInputContextKeyboardSelectionDidChangeNotification
{
Q_UNUSED(textInputContextKeyboardSelectionDidChangeNotification)
@@ -553,7 +454,7 @@ static bool _q_dontOverrideCtrlLMB = false;
- (void) drawRect:(NSRect)dirtyRect
{
- qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_platformWindow->window() << QRectF::fromCGRect(dirtyRect);
+ qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_platformWindow->window() << QRectF::fromCGRect(NSRectToCGRect(dirtyRect));
#ifndef QT_NO_OPENGL
if (m_glContext && m_shouldSetGLContextinDrawRect) {
@@ -1336,7 +1237,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
- (bool)handleGestureAsBeginEnd:(NSEvent *)event
{
- if (QSysInfo::QSysInfo::MacintoshVersion < QSysInfo::MV_10_11)
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion::OSXElCapitan)
return false;
if ([event phase] == NSEventPhaseBegan) {
@@ -2201,3 +2102,17 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
}
@end
+
+@implementation QT_MANGLE_NAMESPACE(QNSView) (QtExtras)
+
+- (QCocoaWindow*)platformWindow
+{
+ return m_platformWindow.data();;
+}
+
+- (BOOL)isMenuView
+{
+ return m_isMenuView;
+}
+
+@end
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h
index f29aa97b68..a465b249c5 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.h
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h
@@ -49,15 +49,10 @@
QCocoaWindow *m_cocoaWindow;
}
-- (id)initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow;
+- (id)initWithQCocoaWindow:(QCocoaWindow *)cocoaWindow;
-- (void)windowDidBecomeKey:(NSNotification *)notification;
-- (void)windowDidResize:(NSNotification *)notification;
-- (void)windowDidMove:(NSNotification *)notification;
-- (void)windowWillMove:(NSNotification *)notification;
- (BOOL)windowShouldClose:(NSNotification *)notification;
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
-- (void)windowWillClose:(NSNotification *)notification;
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu;
- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard;
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
index 7f988ac963..3781a4cc65 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
@@ -45,57 +45,12 @@
@implementation QNSWindowDelegate
-- (id) initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow
+- (id)initWithQCocoaWindow:(QCocoaWindow *)cocoaWindow
{
- self = [super init];
-
- if (self) {
+ if (self = [super init])
m_cocoaWindow = cocoaWindow;
- }
- return self;
-}
-
-- (void)windowDidBecomeKey:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- if (m_cocoaWindow->m_windowUnderMouse) {
- QPointF windowPoint;
- QPointF screenPoint;
- [qnsview_cast(m_cocoaWindow->view()) convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleEnterEvent(m_cocoaWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint);
- }
-}
-
-- (void)windowDidResize:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- if (m_cocoaWindow) {
- m_cocoaWindow->windowDidResize();
- }
-}
-
-- (void)windowDidEndLiveResize:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- if (m_cocoaWindow) {
- m_cocoaWindow->windowDidEndLiveResize();
- }
-}
-
-- (void)windowWillMove:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- if (m_cocoaWindow) {
- m_cocoaWindow->windowWillMove();
- }
-}
-- (void)windowDidMove:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- if (m_cocoaWindow) {
- m_cocoaWindow->windowDidMove();
- }
+ return self;
}
- (BOOL)windowShouldClose:(NSNotification *)notification
@@ -116,13 +71,6 @@
return YES;
}
-- (void)windowWillClose:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- if (m_cocoaWindow)
- m_cocoaWindow->windowWillClose();
-}
-
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu
{
Q_UNUSED(window);
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp
index b5065ba380..38425f8fa1 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dbitmap.cpp
@@ -55,8 +55,9 @@ class QWindowsDirect2DBitmapPrivate
{
public:
QWindowsDirect2DBitmapPrivate(ID2D1DeviceContext *dc = 0, ID2D1Bitmap1 *bm = 0)
- : bitmap(bm)
- , deviceContext(new QWindowsDirect2DDeviceContext(dc))
+ : deviceContext(new QWindowsDirect2DDeviceContext(dc))
+ , bitmap(bm)
+
{
deviceContext->get()->SetTarget(bm);
}
@@ -83,13 +84,13 @@ public:
UINT32(width), UINT32(height)
};
- HRESULT hr = deviceContext->get()->CreateBitmap(size, data, pitch,
+ HRESULT hr = deviceContext->get()->CreateBitmap(size, data, UINT32(pitch),
bitmapProperties(),
bitmap.ReleaseAndGetAddressOf());
if (SUCCEEDED(hr))
deviceContext->get()->SetTarget(bitmap.Get());
else
- qWarning("%s: Could not create bitmap: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create bitmap: %#lx", __FUNCTION__, hr);
return SUCCEEDED(hr);
}
@@ -107,28 +108,28 @@ public:
D2D1_BITMAP_PROPERTIES1 properties = bitmapProperties();
properties.bitmapOptions = D2D1_BITMAP_OPTIONS_CANNOT_DRAW | D2D1_BITMAP_OPTIONS_CPU_READ;
- hr = deviceContext->get()->CreateBitmap(size, NULL, NULL,
+ hr = deviceContext->get()->CreateBitmap(size, NULL, 0,
properties, &mappingCopy);
if (FAILED(hr)) {
- qWarning("%s: Could not create bitmap: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create bitmap: %#lx", __FUNCTION__, hr);
return QImage();
}
hr = mappingCopy->CopyFromBitmap(NULL, bitmap.Get(), NULL);
if (FAILED(hr)) {
- qWarning("%s: Could not copy from bitmap: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not copy from bitmap: %#lx", __FUNCTION__, hr);
return QImage();
}
D2D1_MAPPED_RECT mappedRect;
hr = mappingCopy->Map(D2D1_MAP_OPTIONS_READ, &mappedRect);
if (FAILED(hr)) {
- qWarning("%s: Could not map: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not map: %#lx", __FUNCTION__, hr);
return QImage();
}
return QImage(static_cast<const uchar *>(mappedRect.bits),
- size.width, size.height, mappedRect.pitch,
+ int(size.width), int(size.height), int(mappedRect.pitch),
QImage::Format_ARGB32_Premultiplied).copy(rect);
}
@@ -197,7 +198,7 @@ QSize QWindowsDirect2DBitmap::size() const
Q_D(const QWindowsDirect2DBitmap);
D2D1_SIZE_U size = d->bitmap->GetPixelSize();
- return QSize(size.width, size.height);
+ return QSize(int(size.width), int(size.height));
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.cpp
index fb5bb43d17..a5817016e6 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.cpp
@@ -84,7 +84,7 @@ public:
}
if (FAILED(hr)) {
- qWarning("%s: Could not create Direct3D Device: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create Direct3D Device: %#lx", __FUNCTION__, hr);
return false;
}
@@ -93,7 +93,7 @@ public:
hr = d3dDevice.As(&dxgiDevice);
if (FAILED(hr)) {
- qWarning("%s: DXGI Device interface query failed on D3D Device: %#x", __FUNCTION__, hr);
+ qWarning("%s: DXGI Device interface query failed on D3D Device: %#lx", __FUNCTION__, hr);
return false;
}
@@ -102,13 +102,13 @@ public:
hr = dxgiDevice->GetAdapter(&dxgiAdapter);
if (FAILED(hr)) {
- qWarning("%s: Failed to probe DXGI Device for parent DXGI Adapter: %#x", __FUNCTION__, hr);
+ qWarning("%s: Failed to probe DXGI Device for parent DXGI Adapter: %#lx", __FUNCTION__, hr);
return false;
}
hr = dxgiAdapter->GetParent(IID_PPV_ARGS(&dxgiFactory));
if (FAILED(hr)) {
- qWarning("%s: Failed to probe DXGI Adapter for parent DXGI Factory: %#x", __FUNCTION__, hr);
+ qWarning("%s: Failed to probe DXGI Adapter for parent DXGI Factory: %#lx", __FUNCTION__, hr);
return false;
}
@@ -121,26 +121,26 @@ public:
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, options, d2dFactory.GetAddressOf());
if (FAILED(hr)) {
- qWarning("%s: Could not create Direct2D Factory: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create Direct2D Factory: %#lx", __FUNCTION__, hr);
return false;
}
hr = d2dFactory->CreateDevice(dxgiDevice.Get(), &d2dDevice);
if (FAILED(hr)) {
- qWarning("%s: Could not create D2D Device: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create D2D Device: %#lx", __FUNCTION__, hr);
return false;
}
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
static_cast<IUnknown **>(&directWriteFactory));
if (FAILED(hr)) {
- qWarning("%s: Could not create DirectWrite factory: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create DirectWrite factory: %#lx", __FUNCTION__, hr);
return false;
}
hr = directWriteFactory->GetGdiInterop(&directWriteGdiInterop);
if (FAILED(hr)) {
- qWarning("%s: Could not create DirectWrite GDI Interop: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create DirectWrite GDI Interop: %#lx", __FUNCTION__, hr);
return false;
}
@@ -161,7 +161,7 @@ QWindowsDirect2DContext::QWindowsDirect2DContext()
{
}
-QWindowsDirect2DContext::~QWindowsDirect2DContext() {}
+QWindowsDirect2DContext::~QWindowsDirect2DContext() = default;
bool QWindowsDirect2DContext::init()
{
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.h b/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.h
index a3478d2d4e..0d42c65964 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.h
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.h
@@ -59,7 +59,7 @@ class QWindowsDirect2DContext
public:
QWindowsDirect2DContext();
- virtual ~QWindowsDirect2DContext();
+ ~QWindowsDirect2DContext();
bool init();
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp
index 30238217dd..8a34f6974f 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2ddevicecontext.cpp
@@ -51,14 +51,13 @@ class QWindowsDirect2DDeviceContextPrivate {
public:
QWindowsDirect2DDeviceContextPrivate(ID2D1DeviceContext *dc)
: deviceContext(dc)
- , refCount(0)
{
if (!dc) {
HRESULT hr = QWindowsDirect2DContext::instance()->d2dDevice()->CreateDeviceContext(
D2D1_DEVICE_CONTEXT_OPTIONS_NONE,
&deviceContext);
if (Q_UNLIKELY(FAILED(hr)))
- qFatal("%s: Couldn't create Direct2D Device Context: %#x", __FUNCTION__, hr);
+ qFatal("%s: Couldn't create Direct2D Device Context: %#lx", __FUNCTION__, hr);
}
Q_ASSERT(deviceContext);
@@ -98,7 +97,7 @@ public:
}
ComPtr<ID2D1DeviceContext> deviceContext;
- int refCount;
+ int refCount = 0;
};
QWindowsDirect2DDeviceContext::QWindowsDirect2DDeviceContext(ID2D1DeviceContext *dc)
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
index da4a4e6ce6..ea51135583 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp
@@ -76,12 +76,7 @@ public:
class Direct2DVersion
{
private:
- Direct2DVersion()
- : partOne(0)
- , partTwo(0)
- , partThree(0)
- , partFour(0)
- {}
+ Direct2DVersion() = default;
Direct2DVersion(int one, int two, int three, int four)
: partOne(one)
@@ -108,13 +103,14 @@ public:
if (_tcscat_s(filename, bufSize, __TEXT("\\d2d1.dll")) == 0) {
DWORD versionInfoSize = GetFileVersionInfoSize(filename, NULL);
if (versionInfoSize) {
- QVarLengthArray<BYTE> info(versionInfoSize);
- if (GetFileVersionInfo(filename, NULL, versionInfoSize, info.data())) {
+ QVarLengthArray<BYTE> info(static_cast<int>(versionInfoSize));
+ if (GetFileVersionInfo(filename, 0, versionInfoSize, info.data())) {
UINT size;
DWORD *fi;
- if (VerQueryValue(info.constData(), __TEXT("\\"), (LPVOID *) &fi, &size) && size) {
- VS_FIXEDFILEINFO *verInfo = (VS_FIXEDFILEINFO *) fi;
+ if (VerQueryValue(info.constData(), __TEXT("\\"),
+ reinterpret_cast<void **>(&fi), &size) && size) {
+ const VS_FIXEDFILEINFO *verInfo = reinterpret_cast<const VS_FIXEDFILEINFO *>(fi);
return Direct2DVersion(HIWORD(verInfo->dwFileVersionMS),
LOWORD(verInfo->dwFileVersionMS),
HIWORD(verInfo->dwFileVersionLS),
@@ -171,7 +167,10 @@ public:
return a - b;
}
- int partOne, partTwo, partThree, partFour;
+ int partOne = 0;
+ int partTwo = 0;
+ int partThree = 0;
+ int partFour = 0;
};
QWindowsDirect2DIntegration *QWindowsDirect2DIntegration::create(const QStringList &paramList)
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintdevice.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintdevice.cpp
index 29b01391e2..3c86168a74 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintdevice.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintdevice.cpp
@@ -93,42 +93,33 @@ int QWindowsDirect2DPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric)
switch (metric) {
case QPaintDevice::PdmWidth:
- return d->bitmap->bitmap()->GetPixelSize().width;
- break;
+ return int(d->bitmap->bitmap()->GetPixelSize().width);
case QPaintDevice::PdmHeight:
- return d->bitmap->bitmap()->GetPixelSize().height;
- break;
+ return int(d->bitmap->bitmap()->GetPixelSize().height);
case QPaintDevice::PdmNumColors:
return INT_MAX;
- break;
case QPaintDevice::PdmDepth:
return 32;
- break;
case QPaintDevice::PdmDpiX:
case QPaintDevice::PdmPhysicalDpiX:
{
FLOAT x, y;
QWindowsDirect2DContext::instance()->d2dFactory()->GetDesktopDpi(&x, &y);
- return x;
+ return qRound(x);
}
- break;
case QPaintDevice::PdmDpiY:
case QPaintDevice::PdmPhysicalDpiY:
{
FLOAT x, y;
QWindowsDirect2DContext::instance()->d2dFactory()->GetDesktopDpi(&x, &y);
- return y;
+ return qRound(y);
}
- break;
case QPaintDevice::PdmDevicePixelRatio:
return 1;
- break;
case QPaintDevice::PdmDevicePixelRatioScaled:
- return 1 * devicePixelRatioFScale();
- break;
+ return qRound(devicePixelRatioFScale());
case QPaintDevice::PdmWidthMM:
case QPaintDevice::PdmHeightMM:
- return -1;
break;
}
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
index 69d2e12778..85f333ac78 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
@@ -87,7 +87,7 @@ enum {
};
//Clipping flags
-enum {
+enum : unsigned {
SimpleSystemClip = 0x1
};
@@ -125,28 +125,30 @@ static inline D2D1_MATRIX_3X2_F transformFromLine(const QLineF &line, qreal penW
static void adjustLine(QPointF *p1, QPointF *p2);
static bool isLinePositivelySloped(const QPointF &p1, const QPointF &p2);
-class Direct2DPathGeometryWriter
+static QVector<D2D1_GRADIENT_STOP> qGradientStopsToD2DStops(const QGradientStops &qstops)
{
-public:
- Direct2DPathGeometryWriter()
- : m_inFigure(false)
- , m_roundCoordinates(false)
- , m_adjustPositivelySlopedLines(false)
- {
-
+ QVector<D2D1_GRADIENT_STOP> stops(qstops.count());
+ for (int i = 0, count = stops.size(); i < count; ++i) {
+ stops[i].position = FLOAT(qstops.at(i).first);
+ stops[i].color = to_d2d_color_f(qstops.at(i).second);
}
+ return stops;
+}
+class Direct2DPathGeometryWriter
+{
+public:
bool begin()
{
HRESULT hr = factory()->CreatePathGeometry(&m_geometry);
if (FAILED(hr)) {
- qWarning("%s: Could not create path geometry: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create path geometry: %#lx", __FUNCTION__, hr);
return false;
}
hr = m_geometry->Open(&m_sink);
if (FAILED(hr)) {
- qWarning("%s: Could not create geometry sink: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create geometry sink: %#lx", __FUNCTION__, hr);
return false;
}
@@ -239,9 +241,9 @@ private:
ComPtr<ID2D1PathGeometry1> m_geometry;
ComPtr<ID2D1GeometrySink> m_sink;
- bool m_inFigure;
- bool m_roundCoordinates;
- bool m_adjustPositivelySlopedLines;
+ bool m_inFigure = false;
+ bool m_roundCoordinates = false;
+ bool m_adjustPositivelySlopedLines = false;
QPointF m_previousPoint;
};
@@ -262,7 +264,6 @@ class QWindowsDirect2DPaintEnginePrivate : public QPaintEngineExPrivate
public:
QWindowsDirect2DPaintEnginePrivate(QWindowsDirect2DBitmap *bm, QWindowsDirect2DPaintEngine::Flags flags)
: bitmap(bm)
- , clipFlags(0)
, flags(flags)
{
pen.reset();
@@ -274,7 +275,7 @@ public:
QWindowsDirect2DBitmap *bitmap;
QImage fallbackImage;
- unsigned int clipFlags;
+ unsigned int clipFlags = 0;
QStack<ClipType> pushedClips;
QWindowsDirect2DPaintEngine::Flags flags;
@@ -348,9 +349,9 @@ public:
void updateOpacity(qreal opacity)
{
if (brush.brush)
- brush.brush->SetOpacity(opacity);
+ brush.brush->SetOpacity(FLOAT(opacity));
if (pen.brush)
- pen.brush->SetOpacity(opacity);
+ pen.brush->SetOpacity(FLOAT(opacity));
}
void pushClip(const QVectorPath &path)
@@ -459,7 +460,7 @@ public:
brush.qbrush = newBrush;
if (brush.brush) {
- brush.brush->SetOpacity(q->state()->opacity);
+ brush.brush->SetOpacity(FLOAT(q->state()->opacity));
applyBrushOrigin(currentBrushOrigin);
}
}
@@ -477,8 +478,8 @@ public:
brush.brush->GetTransform(&transform);
brush.brush->SetTransform(*(D2D1::Matrix3x2F::ReinterpretBaseType(&transform))
- * D2D1::Matrix3x2F::Translation(-currentBrushOrigin.x(),
- -currentBrushOrigin.y()));
+ * D2D1::Matrix3x2F::Translation(FLOAT(-currentBrushOrigin.x()),
+ FLOAT(-currentBrushOrigin.y())));
}
}
@@ -489,7 +490,7 @@ public:
brush.brush->GetTransform(&transform);
brush.brush->SetTransform(*(D2D1::Matrix3x2F::ReinterpretBaseType(&transform))
- * D2D1::Matrix3x2F::Translation(origin.x(), origin.y()));
+ * D2D1::Matrix3x2F::Translation(FLOAT(origin.x()), FLOAT(origin.y())));
}
currentBrushOrigin = origin;
@@ -511,7 +512,7 @@ public:
if (!pen.brush)
return;
- pen.brush->SetOpacity(q->state()->opacity);
+ pen.brush->SetOpacity(FLOAT(q->state()->opacity));
D2D1_STROKE_STYLE_PROPERTIES1 props = {};
@@ -541,8 +542,8 @@ public:
break;
}
- props.miterLimit = newPen.miterLimit() * qreal(2.0); // D2D and Qt miter specs differ
- props.dashOffset = newPen.dashOffset();
+ props.miterLimit = FLOAT(newPen.miterLimit() * qreal(2.0)); // D2D and Qt miter specs differ
+ props.dashOffset = FLOAT(newPen.dashOffset());
if (newPen.widthF() == 0)
props.transformType = D2D1_STROKE_TRANSFORM_TYPE_HAIRLINE;
@@ -577,24 +578,24 @@ public:
qreal penWidth = pen.qpen.widthF();
qreal brushWidth = 0;
for (int i = 0; i < dashes.size(); i++) {
- converted[i] = dashes[i];
+ converted[i] = FLOAT(dashes[i]);
brushWidth += penWidth * dashes[i];
}
- hr = factory()->CreateStrokeStyle(props, converted.constData(), converted.size(), &pen.strokeStyle);
+ hr = factory()->CreateStrokeStyle(props, converted.constData(), UINT32(converted.size()), &pen.strokeStyle);
// Create a combined brush/dash pattern for optimized line drawing
QWindowsDirect2DBitmap bitmap;
- bitmap.resize(ceil(brushWidth), ceil(penWidth));
+ bitmap.resize(int(ceil(brushWidth)), int(ceil(penWidth)));
bitmap.deviceContext()->begin();
bitmap.deviceContext()->get()->SetAntialiasMode(antialiasMode());
bitmap.deviceContext()->get()->SetTransform(D2D1::IdentityMatrix());
bitmap.deviceContext()->get()->Clear();
const qreal offsetX = (qreal(bitmap.size().width()) - brushWidth) / 2;
const qreal offsetY = qreal(bitmap.size().height()) / 2;
- bitmap.deviceContext()->get()->DrawLine(D2D1::Point2F(offsetX, offsetY),
- D2D1::Point2F(brushWidth, offsetY),
- pen.brush.Get(), penWidth, pen.strokeStyle.Get());
+ bitmap.deviceContext()->get()->DrawLine(D2D1::Point2F(FLOAT(offsetX), FLOAT(offsetY)),
+ D2D1::Point2F(FLOAT(brushWidth), FLOAT(offsetY)),
+ pen.brush.Get(), FLOAT(penWidth), pen.strokeStyle.Get());
bitmap.deviceContext()->end();
D2D1_BITMAP_BRUSH_PROPERTIES1 bitmapBrushProperties = D2D1::BitmapBrushProperties1(
D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_CLAMP, D2D1_INTERPOLATION_MODE_LINEAR);
@@ -605,7 +606,7 @@ public:
}
if (FAILED(hr))
- qWarning("%s: Could not create stroke style: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create stroke style: %#lx", __FUNCTION__, hr);
}
ComPtr<ID2D1Brush> to_d2d_brush(const QBrush &newBrush, bool *needsEmulation)
@@ -627,13 +628,13 @@ public:
hr = dc()->CreateSolidColorBrush(to_d2d_color_f(newBrush.color()), &solid);
if (FAILED(hr)) {
- qWarning("%s: Could not create solid color brush: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create solid color brush: %#lx", __FUNCTION__, hr);
break;
}
hr = solid.As(&result);
if (FAILED(hr))
- qWarning("%s: Could not convert solid color brush: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not convert solid color brush: %#lx", __FUNCTION__, hr);
}
break;
@@ -673,13 +674,13 @@ public:
bitmapBrushProperties,
&bitmapBrush);
if (FAILED(hr)) {
- qWarning("%s: Could not create Direct2D bitmap brush for Qt pattern brush: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create Direct2D bitmap brush for Qt pattern brush: %#lx", __FUNCTION__, hr);
break;
}
hr = bitmapBrush.As(&result);
if (FAILED(hr))
- qWarning("%s: Could not convert Direct2D bitmap brush for Qt pattern brush: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not convert Direct2D bitmap brush for Qt pattern brush: %#lx", __FUNCTION__, hr);
}
break;
@@ -693,33 +694,29 @@ public:
D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES linearGradientBrushProperties;
ComPtr<ID2D1GradientStopCollection> gradientStopCollection;
- const QGradientStops &qstops = qlinear->stops();
- QVector<D2D1_GRADIENT_STOP> stops(qstops.count());
-
linearGradientBrushProperties.startPoint = to_d2d_point_2f(qlinear->start());
linearGradientBrushProperties.endPoint = to_d2d_point_2f(qlinear->finalStop());
- for (int i = 0; i < stops.size(); i++) {
- stops[i].position = qstops[i].first;
- stops[i].color = to_d2d_color_f(qstops[i].second);
- }
+ const QVector<D2D1_GRADIENT_STOP> stops = qGradientStopsToD2DStops(qlinear->stops());
- hr = dc()->CreateGradientStopCollection(stops.constData(), stops.size(), &gradientStopCollection);
+ hr = dc()->CreateGradientStopCollection(stops.constData(),
+ UINT32(stops.size()),
+ &gradientStopCollection);
if (FAILED(hr)) {
- qWarning("%s: Could not create gradient stop collection for linear gradient: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create gradient stop collection for linear gradient: %#lx", __FUNCTION__, hr);
break;
}
hr = dc()->CreateLinearGradientBrush(linearGradientBrushProperties, gradientStopCollection.Get(),
&linear);
if (FAILED(hr)) {
- qWarning("%s: Could not create Direct2D linear gradient brush: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create Direct2D linear gradient brush: %#lx", __FUNCTION__, hr);
break;
}
hr = linear.As(&result);
if (FAILED(hr)) {
- qWarning("%s: Could not convert Direct2D linear gradient brush: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not convert Direct2D linear gradient brush: %#lx", __FUNCTION__, hr);
break;
}
}
@@ -735,35 +732,29 @@ public:
D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES radialGradientBrushProperties;
ComPtr<ID2D1GradientStopCollection> gradientStopCollection;
- const QGradientStops &qstops = qradial->stops();
- QVector<D2D1_GRADIENT_STOP> stops(qstops.count());
-
radialGradientBrushProperties.center = to_d2d_point_2f(qradial->center());
radialGradientBrushProperties.gradientOriginOffset = to_d2d_point_2f(qradial->focalPoint() - qradial->center());
- radialGradientBrushProperties.radiusX = qradial->radius();
- radialGradientBrushProperties.radiusY = qradial->radius();
+ radialGradientBrushProperties.radiusX = FLOAT(qradial->radius());
+ radialGradientBrushProperties.radiusY = FLOAT(qradial->radius());
- for (int i = 0; i < stops.size(); i++) {
- stops[i].position = qstops[i].first;
- stops[i].color = to_d2d_color_f(qstops[i].second);
- }
+ const QVector<D2D1_GRADIENT_STOP> stops = qGradientStopsToD2DStops(qradial->stops());
hr = dc()->CreateGradientStopCollection(stops.constData(), stops.size(), &gradientStopCollection);
if (FAILED(hr)) {
- qWarning("%s: Could not create gradient stop collection for radial gradient: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create gradient stop collection for radial gradient: %#lx", __FUNCTION__, hr);
break;
}
hr = dc()->CreateRadialGradientBrush(radialGradientBrushProperties, gradientStopCollection.Get(),
&radial);
if (FAILED(hr)) {
- qWarning("%s: Could not create Direct2D radial gradient brush: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create Direct2D radial gradient brush: %#lx", __FUNCTION__, hr);
break;
}
radial.As(&result);
if (FAILED(hr)) {
- qWarning("%s: Could not convert Direct2D radial gradient brush: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not convert Direct2D radial gradient brush: %#lx", __FUNCTION__, hr);
break;
}
}
@@ -789,13 +780,13 @@ public:
&bitmapBrush);
if (FAILED(hr)) {
- qWarning("%s: Could not create texture brush: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create texture brush: %#lx", __FUNCTION__, hr);
break;
}
hr = bitmapBrush.As(&result);
if (FAILED(hr))
- qWarning("%s: Could not convert texture brush: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not convert texture brush: %#lx", __FUNCTION__, hr);
}
break;
}
@@ -958,7 +949,8 @@ public:
qWarning("%s: Could not convert path to d2d geometry", __FUNCTION__);
return;
}
- dc()->DrawGeometry(geometry.Get(), pen.brush.Get(), pen.qpen.widthF(), pen.strokeStyle.Get());
+ dc()->DrawGeometry(geometry.Get(), pen.brush.Get(),
+ FLOAT(pen.qpen.widthF()), pen.strokeStyle.Get());
return;
}
@@ -998,7 +990,7 @@ public:
dashOffset = pen.dashLength - fmod(lineLength - dashOffset, pen.dashLength);
}
dc()->DrawLine(to_d2d_point_2f(p1), to_d2d_point_2f(p2),
- brush, pen.qpen.widthF(), NULL);
+ brush, FLOAT(pen.qpen.widthF()), NULL);
if (skipJoin)
continue;
@@ -1013,7 +1005,8 @@ public:
writer.lineTo(p1);
writer.lineTo(line.pointAt(patchSegment));
writer.close();
- dc()->DrawGeometry(writer.geometry().Get(), pen.brush.Get(), pen.qpen.widthF(), pen.strokeStyle.Get());
+ dc()->DrawGeometry(writer.geometry().Get(), pen.brush.Get(),
+ FLOAT(pen.qpen.widthF()), pen.strokeStyle.Get());
}
// Record the start position of the next joint
jointStart = line.pointAt(1 - patchSegment);
@@ -1025,7 +1018,8 @@ public:
writer.lineTo(p2);
writer.lineTo(QLineF(p2, QPointF(points[2], points[3])).pointAt(patchSegment));
writer.close();
- dc()->DrawGeometry(writer.geometry().Get(), pen.brush.Get(), pen.qpen.widthF(), pen.strokeStyle.Get());
+ dc()->DrawGeometry(writer.geometry().Get(), pen.brush.Get(),
+ FLOAT(pen.qpen.widthF()), pen.strokeStyle.Get());
}
}
}
@@ -1045,20 +1039,20 @@ public:
const QString nameSubstitute = QSettings(QLatin1String(keyC), QSettings::NativeFormat).value(familyName, familyName).toString();
if (nameSubstitute != familyName) {
const int nameSubstituteLength = qMin(nameSubstitute.length(), LF_FACESIZE - 1);
- memcpy(lf.lfFaceName, nameSubstitute.utf16(), nameSubstituteLength * sizeof(wchar_t));
+ memcpy(lf.lfFaceName, nameSubstitute.utf16(), size_t(nameSubstituteLength) * sizeof(wchar_t));
lf.lfFaceName[nameSubstituteLength] = 0;
}
ComPtr<IDWriteFont> dwriteFont;
HRESULT hr = QWindowsDirect2DContext::instance()->dwriteGdiInterop()->CreateFontFromLOGFONT(&lf, &dwriteFont);
if (FAILED(hr)) {
- qDebug("%s: CreateFontFromLOGFONT failed: %#x", __FUNCTION__, hr);
+ qDebug("%s: CreateFontFromLOGFONT failed: %#lx", __FUNCTION__, hr);
return fontFace;
}
hr = dwriteFont->CreateFontFace(&fontFace);
if (FAILED(hr)) {
- qDebug("%s: CreateFontFace failed: %#x", __FUNCTION__, hr);
+ qDebug("%s: CreateFontFace failed: %#lx", __FUNCTION__, hr);
return fontFace;
}
@@ -1332,7 +1326,8 @@ void QWindowsDirect2DPaintEngine::drawRects(const QRect *rects, int rectCount)
d->dc()->FillRectangle(d2d_rect, d->brush.brush.Get());
if (d->pen.brush)
- d->dc()->DrawRectangle(d2d_rect, d->pen.brush.Get(), d->pen.qpen.widthF(), d->pen.strokeStyle.Get());
+ d->dc()->DrawRectangle(d2d_rect, d->pen.brush.Get(),
+ FLOAT(d->pen.qpen.widthF()), d->pen.strokeStyle.Get());
}
}
}
@@ -1359,7 +1354,8 @@ void QWindowsDirect2DPaintEngine::drawRects(const QRectF *rects, int rectCount)
d->dc()->FillRectangle(d2d_rect, d->brush.brush.Get());
if (d->pen.brush)
- d->dc()->DrawRectangle(d2d_rect, d->pen.brush.Get(), d->pen.qpen.widthF(), d->pen.strokeStyle.Get());
+ d->dc()->DrawRectangle(d2d_rect, d->pen.brush.Get(),
+ FLOAT(d->pen.qpen.widthF()), d->pen.strokeStyle.Get());
}
}
}
@@ -1407,7 +1403,9 @@ void QWindowsDirect2DPaintEngine::drawEllipse(const QRectF &r)
d->dc()->FillEllipse(ellipse, d->brush.brush.Get());
if (d->pen.brush)
- d->dc()->DrawEllipse(ellipse, d->pen.brush.Get(), d->pen.qpen.widthF(), d->pen.strokeStyle.Get());
+ d->dc()->DrawEllipse(ellipse, d->pen.brush.Get(),
+ FLOAT(d->pen.qpen.widthF()),
+ d->pen.strokeStyle.Get());
}
}
@@ -1435,7 +1433,9 @@ void QWindowsDirect2DPaintEngine::drawEllipse(const QRect &r)
d->dc()->FillEllipse(ellipse, d->brush.brush.Get());
if (d->pen.brush)
- d->dc()->DrawEllipse(ellipse, d->pen.brush.Get(), d->pen.qpen.widthF(), d->pen.strokeStyle.Get());
+ d->dc()->DrawEllipse(ellipse, d->pen.brush.Get(),
+ FLOAT(d->pen.qpen.widthF()),
+ d->pen.strokeStyle.Get());
}
}
@@ -1490,12 +1490,12 @@ void QWindowsDirect2DPaintEngine::drawPixmap(const QRectF &r,
// Good, src bitmap != dst bitmap
if (sr.isValid())
d->dc()->DrawBitmap(bitmap->bitmap(),
- to_d2d_rect_f(r), state()->opacity,
+ to_d2d_rect_f(r), FLOAT(state()->opacity),
d->interpolationMode(),
to_d2d_rect_f(sr));
else
d->dc()->DrawBitmap(bitmap->bitmap(),
- to_d2d_rect_f(r), state()->opacity,
+ to_d2d_rect_f(r), FLOAT(state()->opacity),
d->interpolationMode());
} else {
// Ok, so the source pixmap and destination pixmap is the same.
@@ -1504,7 +1504,7 @@ void QWindowsDirect2DPaintEngine::drawPixmap(const QRectF &r,
QWindowsDirect2DBitmap intermediate;
if (sr.isValid()) {
- bool r = intermediate.resize(sr.width(), sr.height());
+ bool r = intermediate.resize(int(sr.width()), int(sr.height()));
if (!r) {
qWarning("%s: Could not resize intermediate bitmap to source rect size", __FUNCTION__);
return;
@@ -1515,7 +1515,7 @@ void QWindowsDirect2DPaintEngine::drawPixmap(const QRectF &r,
bitmap->bitmap(),
&d2d_sr);
if (FAILED(hr)) {
- qWarning("%s: Could not copy source rect area from source bitmap to intermediate bitmap: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not copy source rect area from source bitmap to intermediate bitmap: %#lx", __FUNCTION__, hr);
return;
}
} else {
@@ -1530,13 +1530,13 @@ void QWindowsDirect2DPaintEngine::drawPixmap(const QRectF &r,
bitmap->bitmap(),
NULL);
if (FAILED(hr)) {
- qWarning("%s: Could not copy source bitmap to intermediate bitmap: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not copy source bitmap to intermediate bitmap: %#lx", __FUNCTION__, hr);
return;
}
}
d->dc()->DrawBitmap(intermediate.bitmap(),
- to_d2d_rect_f(r), state()->opacity,
+ to_d2d_rect_f(r), FLOAT(state()->opacity),
d->interpolationMode());
}
}
@@ -1573,9 +1573,9 @@ void QWindowsDirect2DPaintEngine::drawStaticTextItem(QStaticTextItem *staticText
// This looks a little funky because the positions are precalculated
glyphAdvances[i] = 0;
- glyphOffsets[i].advanceOffset = staticTextItem->glyphPositions[i].x.toReal();
+ glyphOffsets[i].advanceOffset = FLOAT(staticTextItem->glyphPositions[i].x.toReal());
// Qt and Direct2D seem to disagree on the direction of the ascender offset...
- glyphOffsets[i].ascenderOffset = staticTextItem->glyphPositions[i].y.toReal() * -1;
+ glyphOffsets[i].ascenderOffset = FLOAT(staticTextItem->glyphPositions[i].y.toReal() * -1);
}
d->drawGlyphRun(D2D1::Point2F(0, 0),
@@ -1618,11 +1618,11 @@ void QWindowsDirect2DPaintEngine::drawTextItem(const QPointF &p, const QTextItem
for (int i = 0; i < ti.glyphs.numGlyphs; i++) {
glyphIndices[i] = UINT16(ti.glyphs.glyphs[i]); // Imperfect conversion here
- glyphAdvances[i] = ti.glyphs.effectiveAdvance(i).toReal();
- glyphOffsets[i].advanceOffset = ti.glyphs.offsets[i].x.toReal();
+ glyphAdvances[i] = FLOAT(ti.glyphs.effectiveAdvance(i).toReal());
+ glyphOffsets[i].advanceOffset = FLOAT(ti.glyphs.offsets[i].x.toReal());
// XXX Should we negate the y value like for static text items?
- glyphOffsets[i].ascenderOffset = ti.glyphs.offsets[i].y.toReal();
+ glyphOffsets[i].ascenderOffset = FLOAT(ti.glyphs.offsets[i].y.toReal());
}
const bool rtl = (ti.flags & QTextItem::RightToLeft);
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.cpp
index e7e2fa4ff7..65e056d312 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.cpp
@@ -57,15 +57,12 @@ public:
: owns_bitmap(true)
, bitmap(new QWindowsDirect2DBitmap)
, device(new QWindowsDirect2DPaintDevice(bitmap, QInternal::Pixmap))
- , devicePixelRatio(1.0)
{}
QWindowsDirect2DPlatformPixmapPrivate(QWindowsDirect2DBitmap *bitmap,
QWindowsDirect2DPaintEngine::Flags flags)
- : owns_bitmap(false)
- , bitmap(bitmap)
+ : bitmap(bitmap)
, device(new QWindowsDirect2DPaintDevice(bitmap, QInternal::Pixmap, flags))
- , devicePixelRatio(1.0)
{}
~QWindowsDirect2DPlatformPixmapPrivate()
@@ -74,10 +71,10 @@ public:
delete bitmap;
}
- bool owns_bitmap;
+ bool owns_bitmap = false;
QWindowsDirect2DBitmap *bitmap;
QScopedPointer<QWindowsDirect2DPaintDevice> device;
- qreal devicePixelRatio;
+ qreal devicePixelRatio = 1.0;
};
static int qt_d2dpixmap_serno = 0;
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
index c750b02078..21294cfb15 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
@@ -54,7 +54,6 @@ QT_BEGIN_NAMESPACE
QWindowsDirect2DWindow::QWindowsDirect2DWindow(QWindow *window, const QWindowsWindowData &data)
: QWindowsWindow(window, data)
- , m_needsFullFlush(true)
, m_directRendering(!(data.flags & Qt::FramelessWindowHint && window->format().hasAlpha()))
{
if (window->type() == Qt::Desktop)
@@ -67,7 +66,7 @@ QWindowsDirect2DWindow::QWindowsDirect2DWindow(QWindow *window, const QWindowsWi
D2D1_DEVICE_CONTEXT_OPTIONS_NONE,
m_deviceContext.GetAddressOf());
if (FAILED(hr))
- qWarning("%s: Couldn't create Direct2D Device context: %#x", __FUNCTION__, hr);
+ qWarning("%s: Couldn't create Direct2D Device context: %#lx", __FUNCTION__, hr);
}
QWindowsDirect2DWindow::~QWindowsDirect2DWindow()
@@ -100,12 +99,12 @@ void QWindowsDirect2DWindow::flush(QWindowsDirect2DBitmap *bitmap, const QRegion
HRESULT hr = m_swapChain->GetDesc1(&desc);
QRect geom = geometry();
- if ((FAILED(hr) || (desc.Width != geom.width()) || (desc.Height != geom.height()))) {
+ if (FAILED(hr) || (desc.Width != UINT(geom.width()) || (desc.Height != UINT(geom.height())))) {
resizeSwapChain(geom.size());
m_swapChain->GetDesc1(&desc);
}
- size.setWidth(desc.Width);
- size.setHeight(desc.Height);
+ size.setWidth(int(desc.Width));
+ size.setHeight(int(desc.Height));
} else {
size = geometry().size();
}
@@ -175,7 +174,7 @@ void QWindowsDirect2DWindow::present(const QRegion &region)
UPDATELAYEREDWINDOWINFO info = { sizeof(UPDATELAYEREDWINDOWINFO), NULL,
&ptDst, &size, hdc, &ptSrc, 0, &blend, ULW_ALPHA, &dirty };
if (!UpdateLayeredWindowIndirect(handle(), &info))
- qErrnoWarning(GetLastError(), "Failed to update the layered window");
+ qErrnoWarning(int(GetLastError()), "Failed to update the layered window");
hr = dxgiSurface->ReleaseDC(NULL);
if (FAILED(hr))
@@ -201,7 +200,7 @@ void QWindowsDirect2DWindow::setupSwapChain()
m_swapChain.ReleaseAndGetAddressOf()); // [out] IDXGISwapChain1 **ppSwapChain
if (FAILED(hr))
- qWarning("%s: Could not create swap chain: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create swap chain: %#lx", __FUNCTION__, hr);
m_needsFullFlush = true;
}
@@ -217,11 +216,11 @@ void QWindowsDirect2DWindow::resizeSwapChain(const QSize &size)
return;
HRESULT hr = m_swapChain->ResizeBuffers(0,
- size.width(), size.height(),
+ UINT(size.width()), UINT(size.height()),
DXGI_FORMAT_UNKNOWN,
0);
if (FAILED(hr))
- qWarning("%s: Could not resize swap chain: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not resize swap chain: %#lx", __FUNCTION__, hr);
}
QSharedPointer<QWindowsDirect2DBitmap> QWindowsDirect2DWindow::copyBackBuffer() const
@@ -248,13 +247,13 @@ QSharedPointer<QWindowsDirect2DBitmap> QWindowsDirect2DWindow::copyBackBuffer()
HRESULT hr = m_deviceContext.Get()->CreateBitmap(size, NULL, 0, properties, &copy);
if (FAILED(hr)) {
- qWarning("%s: Could not create staging bitmap: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create staging bitmap: %#lx", __FUNCTION__, hr);
return null_result;
}
hr = copy.Get()->CopyFromBitmap(NULL, m_bitmap->bitmap(), NULL);
if (FAILED(hr)) {
- qWarning("%s: Could not copy from bitmap! %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not copy from bitmap! %#lx", __FUNCTION__, hr);
return null_result;
}
@@ -277,12 +276,12 @@ void QWindowsDirect2DWindow::setupBitmap()
if (m_directRendering) {
hr = m_swapChain->GetBuffer(0, IID_PPV_ARGS(&backBufferSurface));
if (FAILED(hr)) {
- qWarning("%s: Could not query backbuffer for DXGI Surface: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not query backbuffer for DXGI Surface: %#lx", __FUNCTION__, hr);
return;
}
} else {
const QRect rect = geometry();
- CD3D11_TEXTURE2D_DESC backBufferDesc(DXGI_FORMAT_B8G8R8A8_UNORM, rect.width(), rect.height(), 1, 1);
+ CD3D11_TEXTURE2D_DESC backBufferDesc(DXGI_FORMAT_B8G8R8A8_UNORM, UINT(rect.width()), UINT(rect.height()), 1, 1);
backBufferDesc.BindFlags = D3D11_BIND_RENDER_TARGET;
backBufferDesc.MiscFlags = D3D11_RESOURCE_MISC_GDI_COMPATIBLE;
ComPtr<ID3D11Texture2D> backBufferTexture;
@@ -302,7 +301,7 @@ void QWindowsDirect2DWindow::setupBitmap()
ComPtr<ID2D1Bitmap1> backBufferBitmap;
hr = m_deviceContext->CreateBitmapFromDxgiSurface(backBufferSurface.Get(), NULL, backBufferBitmap.GetAddressOf());
if (FAILED(hr)) {
- qWarning("%s: Could not create Direct2D Bitmap from DXGI Surface: %#x", __FUNCTION__, hr);
+ qWarning("%s: Could not create Direct2D Bitmap from DXGI Surface: %#lx", __FUNCTION__, hr);
return;
}
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.h b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.h
index 2da0e5f507..156d4660d1 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.h
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.h
@@ -74,8 +74,8 @@ private:
Microsoft::WRL::ComPtr<ID2D1DeviceContext> m_deviceContext;
QScopedPointer<QWindowsDirect2DBitmap> m_bitmap;
QScopedPointer<QPixmap> m_pixmap;
- bool m_needsFullFlush;
- bool m_directRendering;
+ bool m_needsFullFlush = true;
+ bool m_directRendering = false;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro
index 255db824b7..e522c0ee1b 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro
@@ -4,7 +4,7 @@ PLUGIN_TYPE = egldeviceintegrations
PLUGIN_CLASS_NAME = QEglFSKmsGbmIntegrationPlugin
load(qt_plugin)
-QT += core-private gui-private eglfsdeviceintegration-private eglfs_kms_support-private
+QT += core-private gui-private eglfsdeviceintegration-private eglfs_kms_support-private kms_support-private
INCLUDEPATH += $$PWD/../../api $$PWD/../eglfs_kms_support
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
index 3a220ec942..2040d6bc0e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
@@ -46,7 +46,6 @@
#include <QtCore/QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
-#include <QtGui/private/qguiapplication_p.h>
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
@@ -65,8 +64,8 @@ void QEglFSKmsGbmDevice::pageFlipHandler(int fd, unsigned int sequence, unsigned
screen->flipFinished();
}
-QEglFSKmsGbmDevice::QEglFSKmsGbmDevice(QEglFSKmsIntegration *integration, const QString &path)
- : QEglFSKmsDevice(integration, path)
+QEglFSKmsGbmDevice::QEglFSKmsGbmDevice(QKmsScreenConfig *screenConfig, const QString &path)
+ : QEglFSKmsDevice(screenConfig, path)
, m_gbm_device(Q_NULLPTR)
, m_globalCursor(Q_NULLPTR)
{
@@ -77,7 +76,6 @@ bool QEglFSKmsGbmDevice::open()
Q_ASSERT(fd() == -1);
Q_ASSERT(m_gbm_device == Q_NULLPTR);
- qCDebug(qLcEglfsKmsDebug) << "Opening device" << devicePath();
int fd = qt_safe_open(devicePath().toLocal8Bit().constData(), O_RDWR | O_CLOEXEC);
if (fd == -1) {
qErrnoWarning("Could not open DRM device %s", qPrintable(devicePath()));
@@ -101,6 +99,8 @@ bool QEglFSKmsGbmDevice::open()
void QEglFSKmsGbmDevice::close()
{
+ // Note: screens are gone at this stage.
+
if (m_gbm_device) {
gbm_device_destroy(m_gbm_device);
m_gbm_device = Q_NULLPTR;
@@ -110,15 +110,11 @@ void QEglFSKmsGbmDevice::close()
qt_safe_close(fd());
setFd(-1);
}
-
- if (m_globalCursor)
- m_globalCursor->deleteLater();
- m_globalCursor = Q_NULLPTR;
}
-EGLNativeDisplayType QEglFSKmsGbmDevice::nativeDisplay() const
+void *QEglFSKmsGbmDevice::nativeDisplay() const
{
- return reinterpret_cast<EGLNativeDisplayType>(m_gbm_device);
+ return m_gbm_device;
}
gbm_device * QEglFSKmsGbmDevice::gbmDevice() const
@@ -131,6 +127,17 @@ QPlatformCursor *QEglFSKmsGbmDevice::globalCursor() const
return m_globalCursor;
}
+// Cannot do this from close(), it may be too late.
+// Call this from the last screen dtor instead.
+void QEglFSKmsGbmDevice::destroyGlobalCursor()
+{
+ if (m_globalCursor) {
+ qCDebug(qLcEglfsKmsDebug, "Destroying global GBM mouse cursor");
+ delete m_globalCursor;
+ m_globalCursor = Q_NULLPTR;
+ }
+}
+
void QEglFSKmsGbmDevice::handleDrmEvent()
{
drmEventContext drmEvent = {
@@ -142,14 +149,13 @@ void QEglFSKmsGbmDevice::handleDrmEvent()
drmHandleEvent(fd(), &drmEvent);
}
-QEglFSKmsScreen *QEglFSKmsGbmDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output)
+QPlatformScreen *QEglFSKmsGbmDevice::createScreen(const QKmsOutput &output)
{
- static bool firstScreen = true;
- QEglFSKmsGbmScreen *screen = new QEglFSKmsGbmScreen(integration, device, output);
+ QEglFSKmsGbmScreen *screen = new QEglFSKmsGbmScreen(this, output);
- if (firstScreen && integration->hwCursor()) {
+ if (!m_globalCursor && screenConfig()->hwCursor()) {
+ qCDebug(qLcEglfsKmsDebug, "Creating new global GBM mouse cursor");
m_globalCursor = new QEglFSKmsGbmCursor(screen);
- firstScreen = false;
}
return screen;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
index 7c0af84422..25284c6468 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
@@ -43,7 +43,7 @@
#define QEGLFSKMSGBMDEVICE_H
#include "qeglfskmsgbmcursor.h"
-#include "qeglfskmsdevice.h"
+#include <qeglfskmsdevice.h>
#include <gbm.h>
@@ -54,21 +54,20 @@ class QEglFSKmsScreen;
class QEglFSKmsGbmDevice: public QEglFSKmsDevice
{
public:
- QEglFSKmsGbmDevice(QEglFSKmsIntegration *integration, const QString &path);
+ QEglFSKmsGbmDevice(QKmsScreenConfig *screenConfig, const QString &path);
bool open() Q_DECL_OVERRIDE;
void close() Q_DECL_OVERRIDE;
- EGLNativeDisplayType nativeDisplay() const Q_DECL_OVERRIDE;
+ void *nativeDisplay() const Q_DECL_OVERRIDE;
gbm_device *gbmDevice() const;
QPlatformCursor *globalCursor() const;
+ void destroyGlobalCursor();
void handleDrmEvent();
- virtual QEglFSKmsScreen *createScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output) Q_DECL_OVERRIDE;
+ QPlatformScreen *createScreen(const QKmsOutput &output) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(QEglFSKmsGbmDevice)
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
index 38419a55c8..16767114ab 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
@@ -63,8 +63,9 @@ QT_BEGIN_NAMESPACE
QMutex QEglFSKmsGbmScreen::m_waitForFlipMutex;
QEglFSKmsGbmIntegration::QEglFSKmsGbmIntegration()
- : QEglFSKmsIntegration()
-{}
+{
+ qCDebug(qLcEglfsKmsDebug, "New DRM/KMS via GBM integration created");
+}
EGLNativeWindowType QEglFSKmsGbmIntegration::createNativeWindow(QPlatformWindow *platformWindow,
const QSize &size,
@@ -104,10 +105,12 @@ void QEglFSKmsGbmIntegration::destroyNativeWindow(EGLNativeWindowType window)
QPlatformCursor *QEglFSKmsGbmIntegration::createCursor(QPlatformScreen *screen) const
{
- if (hwCursor())
- return Q_NULLPTR;
- else
+ if (screenConfig()->hwCursor()) {
+ return nullptr;
+ } else {
+ qCDebug(qLcEglfsKmsDebug, "Using plain OpenGL mouse cursor");
return new QEglFSCursor(screen);
+ }
}
void QEglFSKmsGbmIntegration::presentBuffer(QPlatformSurface *surface)
@@ -118,13 +121,12 @@ void QEglFSKmsGbmIntegration::presentBuffer(QPlatformSurface *surface)
screen->flip();
}
-QEglFSKmsDevice *QEglFSKmsGbmIntegration::createDevice(const QString &devicePath)
+QKmsDevice *QEglFSKmsGbmIntegration::createDevice()
{
- QString path = devicePath;
- if (!devicePath.isEmpty()) {
- qCDebug(qLcEglfsKmsDebug) << "Using DRM device" << path << "specified in config file";
+ QString path = screenConfig()->devicePath();
+ if (!path.isEmpty()) {
+ qCDebug(qLcEglfsKmsDebug) << "GBM: Using DRM device" << path << "specified in config file";
} else {
-
QDeviceDiscovery *d = QDeviceDiscovery::create(QDeviceDiscovery::Device_VideoMask);
const QStringList devices = d->scanConnectedDevices();
qCDebug(qLcEglfsKmsDebug) << "Found the following video devices:" << devices;
@@ -137,7 +139,7 @@ QEglFSKmsDevice *QEglFSKmsGbmIntegration::createDevice(const QString &devicePath
qCDebug(qLcEglfsKmsDebug) << "Using" << path;
}
- return new QEglFSKmsGbmDevice(this, path);
+ return new QEglFSKmsGbmDevice(screenConfig(), path);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.h
index 727571d3e3..fa2e494a89 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.h
@@ -65,7 +65,7 @@ public:
void presentBuffer(QPlatformSurface *surface) Q_DECL_OVERRIDE;
protected:
- QEglFSKmsDevice *createDevice(const QString &devicePath) Q_DECL_OVERRIDE;
+ QKmsDevice *createDevice() Q_DECL_OVERRIDE;
private:
};
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
index bed775ff81..ebce0a4776 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
@@ -92,10 +92,8 @@ QEglFSKmsGbmScreen::FrameBuffer *QEglFSKmsGbmScreen::framebufferForBufferObject(
return fb.take();
}
-QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output)
- : QEglFSKmsScreen(integration, device, output)
+QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QKmsDevice *device, const QKmsOutput &output)
+ : QEglFSKmsScreen(device, output)
, m_gbm_surface(Q_NULLPTR)
, m_gbm_bo_current(Q_NULLPTR)
, m_gbm_bo_next(Q_NULLPTR)
@@ -105,12 +103,17 @@ QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QEglFSKmsIntegration *integration,
QEglFSKmsGbmScreen::~QEglFSKmsGbmScreen()
{
+ const int remainingScreenCount = qGuiApp->screens().count();
+ qCDebug(qLcEglfsKmsDebug, "Screen dtor. Remaining screens: %d", remainingScreenCount);
+ if (!remainingScreenCount && !device()->screenConfig()->separateScreens())
+ static_cast<QEglFSKmsGbmDevice *>(device())->destroyGlobalCursor();
}
QPlatformCursor *QEglFSKmsGbmScreen::cursor() const
{
- if (integration()->hwCursor()) {
- if (!integration()->separateScreens())
+ QKmsScreenConfig *config = device()->screenConfig();
+ if (config->hwCursor()) {
+ if (!config->separateScreens())
return static_cast<QEglFSKmsGbmDevice *>(device())->globalCursor();
if (m_cursor.isNull()) {
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
index d7ad348291..ffc96955d4 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
@@ -54,9 +54,7 @@ class QEglFSKmsGbmCursor;
class QEglFSKmsGbmScreen : public QEglFSKmsScreen
{
public:
- QEglFSKmsGbmScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output);
+ QEglFSKmsGbmScreen(QKmsDevice *device, const QKmsOutput &output);
~QEglFSKmsGbmScreen();
QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro
index a625021aba..a2dc9c4a50 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro
@@ -1,6 +1,6 @@
TARGET = qeglfs-kms-egldevice-integration
-QT += core-private gui-private eglfsdeviceintegration-private eglfs_kms_support-private
+QT += core-private gui-private eglfsdeviceintegration-private eglfs_kms_support-private kms_support-private
INCLUDEPATH += $$PWD/../../api $$PWD/../eglfs_kms_support
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp
index 60989e2bd0..f0bf59466e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp
@@ -40,14 +40,16 @@
#include "qeglfskmsegldevice.h"
#include "qeglfskmsegldevicescreen.h"
#include "qeglfskmsegldeviceintegration.h"
+#include "private/qeglfsintegration_p.h"
#include "private/qeglfscursor_p.h"
#include <QtCore/private/qcore_unix_p.h>
QT_BEGIN_NAMESPACE
-QEglFSKmsEglDevice::QEglFSKmsEglDevice(QEglFSKmsIntegration *integration, const QString &path)
- : QEglFSKmsDevice(integration, path),
+QEglFSKmsEglDevice::QEglFSKmsEglDevice(QEglFSKmsEglDeviceIntegration *devInt, QKmsScreenConfig *screenConfig, const QString &path)
+ : QEglFSKmsDevice(screenConfig, path),
+ m_devInt(devInt),
m_globalCursor(nullptr)
{
}
@@ -56,11 +58,9 @@ bool QEglFSKmsEglDevice::open()
{
Q_ASSERT(fd() == -1);
- qCDebug(qLcEglfsKmsDebug, "Opening DRM device %s", qPrintable(devicePath()));
-
int fd = drmOpen(devicePath().toLocal8Bit().constData(), Q_NULLPTR);
if (Q_UNLIKELY(fd < 0))
- qFatal("Could not open DRM device");
+ qFatal("Could not open DRM (NV) device");
setFd(fd);
@@ -69,25 +69,24 @@ bool QEglFSKmsEglDevice::open()
void QEglFSKmsEglDevice::close()
{
- qCDebug(qLcEglfsKmsDebug, "Closing DRM device");
+ // Note: screens are gone at this stage.
if (qt_safe_close(fd()) == -1)
- qErrnoWarning("Could not close DRM device");
+ qErrnoWarning("Could not close DRM (NV) device");
setFd(-1);
}
EGLNativeDisplayType QEglFSKmsEglDevice::nativeDisplay() const
{
- return reinterpret_cast<EGLNativeDisplayType>(static_cast<QEglFSKmsEglDeviceIntegration *>(m_integration)->eglDevice());
+ return reinterpret_cast<EGLNativeDisplayType>(m_devInt->eglDevice());
}
-QEglFSKmsScreen *QEglFSKmsEglDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device,
- QEglFSKmsOutput output)
+QPlatformScreen *QEglFSKmsEglDevice::createScreen(const QKmsOutput &output)
{
- QEglFSKmsScreen *screen = new QEglFSKmsEglDeviceScreen(integration, device, output);
+ QEglFSKmsScreen *screen = new QEglFSKmsEglDeviceScreen(this, output);
- if (!m_globalCursor && !integration->separateScreens()) {
+ if (!m_globalCursor && !screenConfig()->separateScreens()) {
qCDebug(qLcEglfsKmsDebug, "Creating new global mouse cursor");
m_globalCursor = new QEglFSCursor(screen);
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h
index 8c8f79f70c..b9304b8502 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h
@@ -45,25 +45,25 @@
QT_BEGIN_NAMESPACE
class QPlatformCursor;
+class QEglFSKmsEglDeviceIntegration;
class QEglFSKmsEglDevice: public QEglFSKmsDevice
{
public:
- QEglFSKmsEglDevice(QEglFSKmsIntegration *integration, const QString &path);
+ QEglFSKmsEglDevice(QEglFSKmsEglDeviceIntegration *devInt, QKmsScreenConfig *screenConfig, const QString &path);
- virtual bool open() Q_DECL_OVERRIDE;
- virtual void close() Q_DECL_OVERRIDE;
+ bool open() Q_DECL_OVERRIDE;
+ void close() Q_DECL_OVERRIDE;
- virtual EGLNativeDisplayType nativeDisplay() const Q_DECL_OVERRIDE;
+ void *nativeDisplay() const Q_DECL_OVERRIDE;
- virtual QEglFSKmsScreen *createScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output) Q_DECL_OVERRIDE;
+ QPlatformScreen *createScreen(const QKmsOutput &output) Q_DECL_OVERRIDE;
QPlatformCursor *globalCursor() { return m_globalCursor; }
void destroyGlobalCursor();
private:
+ QEglFSKmsEglDeviceIntegration *m_devInt;
QPlatformCursor *m_globalCursor;
};
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
index d0c9c9565e..36fbfbd05c 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
@@ -50,8 +50,7 @@
QT_BEGIN_NAMESPACE
QEglFSKmsEglDeviceIntegration::QEglFSKmsEglDeviceIntegration()
- : QEglFSKmsIntegration()
- , m_egl_device(EGL_NO_DEVICE_EXT)
+ : m_egl_device(EGL_NO_DEVICE_EXT)
, m_funcs(Q_NULLPTR)
{
qCDebug(qLcEglfsKmsDebug, "New DRM/KMS on EGLDevice integration created");
@@ -101,10 +100,10 @@ bool QEglFSKmsEglDeviceIntegration::supportsPBuffers() const
return true;
}
-class QEglJetsonTK1Window : public QEglFSWindow
+class QEglFSKmsEglDeviceWindow : public QEglFSWindow
{
public:
- QEglJetsonTK1Window(QWindow *w, const QEglFSKmsEglDeviceIntegration *integration)
+ QEglFSKmsEglDeviceWindow(QWindow *w, const QEglFSKmsEglDeviceIntegration *integration)
: QEglFSWindow(w)
, m_integration(integration)
, m_egl_stream(EGL_NO_STREAM_KHR)
@@ -118,13 +117,13 @@ public:
EGLint m_latency;
};
-void QEglJetsonTK1Window::invalidateSurface()
+void QEglFSKmsEglDeviceWindow::invalidateSurface()
{
QEglFSWindow::invalidateSurface();
m_integration->m_funcs->destroy_stream(screen()->display(), m_egl_stream);
}
-void QEglJetsonTK1Window::resetSurface()
+void QEglFSKmsEglDeviceWindow::resetSurface()
{
qCDebug(qLcEglfsKmsDebug, "Creating stream");
@@ -213,7 +212,7 @@ void QEglJetsonTK1Window::resetSurface()
QEglFSWindow *QEglFSKmsEglDeviceIntegration::createWindow(QWindow *window) const
{
- QEglJetsonTK1Window *eglWindow = new QEglJetsonTK1Window(window, this);
+ QEglFSKmsEglDeviceWindow *eglWindow = new QEglFSKmsEglDeviceWindow(window, this);
m_funcs->initialize(eglWindow->screen()->display());
if (Q_UNLIKELY(!(m_funcs->has_egl_output_base && m_funcs->has_egl_output_drm && m_funcs->has_egl_stream &&
@@ -223,10 +222,8 @@ QEglFSWindow *QEglFSKmsEglDeviceIntegration::createWindow(QWindow *window) const
return eglWindow;
}
-QEglFSKmsDevice *QEglFSKmsEglDeviceIntegration::createDevice(const QString &devicePath)
+QKmsDevice *QEglFSKmsEglDeviceIntegration::createDevice()
{
- Q_UNUSED(devicePath)
-
if (Q_UNLIKELY(!query_egl_device()))
qFatal("Could not set up EGL device!");
@@ -234,7 +231,7 @@ QEglFSKmsDevice *QEglFSKmsEglDeviceIntegration::createDevice(const QString &devi
if (Q_UNLIKELY(!deviceName))
qFatal("Failed to query device name from EGLDevice");
- return new QEglFSKmsEglDevice(this, deviceName);
+ return new QEglFSKmsEglDevice(this, screenConfig(), deviceName);
}
bool QEglFSKmsEglDeviceIntegration::query_egl_device()
@@ -261,7 +258,7 @@ bool QEglFSKmsEglDeviceIntegration::query_egl_device()
QPlatformCursor *QEglFSKmsEglDeviceIntegration::createCursor(QPlatformScreen *screen) const
{
- return separateScreens() ? new QEglFSCursor(screen) : nullptr;
+ return screenConfig()->separateScreens() ? new QEglFSCursor(screen) : nullptr;
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h
index cddfdbd5c6..a274474433 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h
@@ -64,7 +64,7 @@ public:
EGLDeviceEXT eglDevice() const { return m_egl_device; }
protected:
- QEglFSKmsDevice *createDevice(const QString &devicePath) Q_DECL_OVERRIDE;
+ QKmsDevice *createDevice() Q_DECL_OVERRIDE;
QPlatformCursor *createCursor(QPlatformScreen *screen) const Q_DECL_OVERRIDE;
private:
@@ -72,10 +72,9 @@ private:
bool query_egl_device();
EGLDeviceEXT m_egl_device;
-
- friend class QEglJetsonTK1Window;
- // EGLStream infrastructure
QEGLStreamConvenience *m_funcs;
+
+ friend class QEglFSKmsEglDeviceWindow;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
index 1f672afeb4..532ec0b440 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
@@ -40,11 +40,14 @@
#include "qeglfskmsegldevicescreen.h"
#include "qeglfskmsegldevice.h"
#include <QGuiApplication>
+#include <QLoggingCategory>
QT_BEGIN_NAMESPACE
-QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output)
- : QEglFSKmsScreen(integration, device, output)
+Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
+
+QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QKmsDevice *device, const QKmsOutput &output)
+ : QEglFSKmsScreen(device, output)
{
}
@@ -52,7 +55,7 @@ QEglFSKmsEglDeviceScreen::~QEglFSKmsEglDeviceScreen()
{
const int remainingScreenCount = qGuiApp->screens().count();
qCDebug(qLcEglfsKmsDebug, "Screen dtor. Remaining screens: %d", remainingScreenCount);
- if (!remainingScreenCount && !m_integration->separateScreens())
+ if (!remainingScreenCount && !device()->screenConfig()->separateScreens())
static_cast<QEglFSKmsEglDevice *>(device())->destroyGlobalCursor();
}
@@ -62,7 +65,10 @@ QPlatformCursor *QEglFSKmsEglDeviceScreen::cursor() const
// in its ctor. With separateScreens just use that. Otherwise
// there's a virtual desktop and the device has a global cursor
// and the base class has no dedicated cursor at all.
- return m_integration->separateScreens() ? QEglFSScreen::cursor() : static_cast<QEglFSKmsEglDevice *>(device())->globalCursor();
+ // config->hwCursor() is ignored for now, just use the standard OpenGL cursor.
+ return device()->screenConfig()->separateScreens()
+ ? QEglFSScreen::cursor()
+ : static_cast<QEglFSKmsEglDevice *>(device())->globalCursor();
}
void QEglFSKmsEglDeviceScreen::waitForFlip()
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
index c57f52c6b7..1655a3f038 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
@@ -47,9 +47,7 @@ QT_BEGIN_NAMESPACE
class QEglFSKmsEglDeviceScreen : public QEglFSKmsScreen
{
public:
- QEglFSKmsEglDeviceScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output);
+ QEglFSKmsEglDeviceScreen(QKmsDevice *device, const QKmsOutput &output);
~QEglFSKmsEglDeviceScreen();
QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
index 487edb569e..3c0a0ce30f 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
@@ -2,7 +2,7 @@ TARGET = QtEglFsKmsSupport
CONFIG += no_module_headers internal_module
load(qt_module)
-QT += core-private gui-private eglfsdeviceintegration-private
+QT += core-private gui-private eglfsdeviceintegration-private kms_support-private
INCLUDEPATH += $$PWD/../../api
@@ -15,8 +15,8 @@ QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
SOURCES += $$PWD/qeglfskmsintegration.cpp \
$$PWD/qeglfskmsdevice.cpp \
- $$PWD/qeglfskmsscreen.cpp \
+ $$PWD/qeglfskmsscreen.cpp
HEADERS += $$PWD/qeglfskmsintegration.h \
$$PWD/qeglfskmsdevice.h \
- $$PWD/qeglfskmsscreen.h \
+ $$PWD/qeglfskmsscreen.h
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
index f6b58d1ba6..e99a6957a8 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
@@ -1,6 +1,5 @@
/****************************************************************************
**
-** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2016 Pelagicore AG
** Contact: https://www.qt.io/licensing/
@@ -41,432 +40,24 @@
#include "qeglfskmsdevice.h"
#include "qeglfskmsscreen.h"
-
-#include "qeglfsintegration_p.h"
-
-#include <QtCore/QLoggingCategory>
-#include <QtCore/private/qcore_unix_p.h>
+#include "private/qeglfsintegration_p.h"
#include <QtGui/private/qguiapplication_p.h>
-#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
-
QT_BEGIN_NAMESPACE
-Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
-
-enum OutputConfiguration {
- OutputConfigOff,
- OutputConfigPreferred,
- OutputConfigCurrent,
- OutputConfigMode,
- OutputConfigModeline
-};
-
-int QEglFSKmsDevice::crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector)
-{
- for (int i = 0; i < connector->count_encoders; i++) {
- drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->encoders[i]);
- if (!encoder) {
- qWarning("Failed to get encoder");
- continue;
- }
-
- quint32 possibleCrtcs = encoder->possible_crtcs;
- drmModeFreeEncoder(encoder);
-
- for (int j = 0; j < resources->count_crtcs; j++) {
- bool isPossible = possibleCrtcs & (1 << j);
- bool isAvailable = !(m_crtc_allocator & 1 << resources->crtcs[j]);
-
- if (isPossible && isAvailable)
- return j;
- }
- }
-
- return -1;
-}
-
-static const char * const connector_type_names[] = { // must match DRM_MODE_CONNECTOR_*
- "None",
- "VGA",
- "DVI",
- "DVI",
- "DVI",
- "Composite",
- "TV",
- "LVDS",
- "CTV",
- "DIN",
- "DP",
- "HDMI",
- "HDMI",
- "TV",
- "eDP",
- "Virtual",
- "DSI"
-};
-
-static QByteArray nameForConnector(const drmModeConnectorPtr connector)
-{
- QByteArray connectorName("UNKNOWN");
-
- if (connector->connector_type < ARRAY_LENGTH(connector_type_names))
- connectorName = connector_type_names[connector->connector_type];
-
- connectorName += QByteArray::number(connector->connector_type_id);
-
- return connectorName;
-}
-
-static bool parseModeline(const QByteArray &text, drmModeModeInfoPtr mode)
-{
- char hsync[16];
- char vsync[16];
- float fclock;
-
- mode->type = DRM_MODE_TYPE_USERDEF;
- mode->hskew = 0;
- mode->vscan = 0;
- mode->vrefresh = 0;
- mode->flags = 0;
-
- if (sscanf(text.constData(), "%f %hd %hd %hd %hd %hd %hd %hd %hd %15s %15s",
- &fclock,
- &mode->hdisplay,
- &mode->hsync_start,
- &mode->hsync_end,
- &mode->htotal,
- &mode->vdisplay,
- &mode->vsync_start,
- &mode->vsync_end,
- &mode->vtotal, hsync, vsync) != 11)
- return false;
-
- mode->clock = fclock * 1000;
-
- if (strcmp(hsync, "+hsync") == 0)
- mode->flags |= DRM_MODE_FLAG_PHSYNC;
- else if (strcmp(hsync, "-hsync") == 0)
- mode->flags |= DRM_MODE_FLAG_NHSYNC;
- else
- return false;
-
- if (strcmp(vsync, "+vsync") == 0)
- mode->flags |= DRM_MODE_FLAG_PVSYNC;
- else if (strcmp(vsync, "-vsync") == 0)
- mode->flags |= DRM_MODE_FLAG_NVSYNC;
- else
- return false;
-
- return true;
-}
-
-QEglFSKmsScreen *QEglFSKmsDevice::createScreenForConnector(drmModeResPtr resources,
- drmModeConnectorPtr connector,
- VirtualDesktopInfo *vinfo)
-{
- const QByteArray connectorName = nameForConnector(connector);
-
- const int crtc = crtcForConnector(resources, connector);
- if (crtc < 0) {
- qWarning() << "No usable crtc/encoder pair for connector" << connectorName;
- return Q_NULLPTR;
- }
-
- OutputConfiguration configuration;
- QSize configurationSize;
- drmModeModeInfo configurationModeline;
-
- auto userConfig = m_integration->outputSettings();
- auto userConnectorConfig = userConfig.value(QString::fromUtf8(connectorName));
- // default to the preferred mode unless overridden in the config
- const QByteArray mode = userConnectorConfig.value(QStringLiteral("mode"), QStringLiteral("preferred"))
- .toByteArray().toLower();
- if (mode == "off") {
- configuration = OutputConfigOff;
- } else if (mode == "preferred") {
- configuration = OutputConfigPreferred;
- } else if (mode == "current") {
- configuration = OutputConfigCurrent;
- } else if (sscanf(mode.constData(), "%dx%d", &configurationSize.rwidth(), &configurationSize.rheight()) == 2) {
- configuration = OutputConfigMode;
- } else if (parseModeline(mode, &configurationModeline)) {
- configuration = OutputConfigModeline;
- } else {
- qWarning("Invalid mode \"%s\" for output %s", mode.constData(), connectorName.constData());
- configuration = OutputConfigPreferred;
- }
- if (vinfo) {
- *vinfo = VirtualDesktopInfo();
- vinfo->virtualIndex = userConnectorConfig.value(QStringLiteral("virtualIndex"), INT_MAX).toInt();
- if (userConnectorConfig.contains(QStringLiteral("virtualPos"))) {
- const QByteArray vpos = userConnectorConfig.value(QStringLiteral("virtualPos")).toByteArray();
- const QByteArrayList vposComp = vpos.split(',');
- if (vposComp.count() == 2)
- vinfo->virtualPos = QPoint(vposComp[0].trimmed().toInt(), vposComp[1].trimmed().toInt());
- }
- }
-
- const uint32_t crtc_id = resources->crtcs[crtc];
-
- if (configuration == OutputConfigOff) {
- qCDebug(qLcEglfsKmsDebug) << "Turning off output" << connectorName;
- drmModeSetCrtc(m_dri_fd, crtc_id, 0, 0, 0, 0, 0, Q_NULLPTR);
- return Q_NULLPTR;
- }
-
- // Skip disconnected output
- if (configuration == OutputConfigPreferred && connector->connection == DRM_MODE_DISCONNECTED) {
- qCDebug(qLcEglfsKmsDebug) << "Skipping disconnected output" << connectorName;
- return Q_NULLPTR;
- }
-
- // Get the current mode on the current crtc
- drmModeModeInfo crtc_mode;
- memset(&crtc_mode, 0, sizeof crtc_mode);
- if (drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->connector_id)) {
- drmModeCrtcPtr crtc = drmModeGetCrtc(m_dri_fd, encoder->crtc_id);
- drmModeFreeEncoder(encoder);
-
- if (!crtc)
- return Q_NULLPTR;
-
- if (crtc->mode_valid)
- crtc_mode = crtc->mode;
-
- drmModeFreeCrtc(crtc);
- }
-
- QList<drmModeModeInfo> modes;
- modes.reserve(connector->count_modes);
- qCDebug(qLcEglfsKmsDebug) << connectorName << "mode count:" << connector->count_modes;
- for (int i = 0; i < connector->count_modes; i++) {
- const drmModeModeInfo &mode = connector->modes[i];
- qCDebug(qLcEglfsKmsDebug) << "mode" << i << mode.hdisplay << "x" << mode.vdisplay
- << '@' << mode.vrefresh << "hz";
- modes << connector->modes[i];
- }
-
- int preferred = -1;
- int current = -1;
- int configured = -1;
- int best = -1;
-
- for (int i = modes.size() - 1; i >= 0; i--) {
- const drmModeModeInfo &m = modes.at(i);
-
- if (configuration == OutputConfigMode &&
- m.hdisplay == configurationSize.width() &&
- m.vdisplay == configurationSize.height()) {
- configured = i;
- }
-
- if (!memcmp(&crtc_mode, &m, sizeof m))
- current = i;
-
- if (m.type & DRM_MODE_TYPE_PREFERRED)
- preferred = i;
-
- best = i;
- }
-
- if (configuration == OutputConfigModeline) {
- modes << configurationModeline;
- configured = modes.size() - 1;
- }
-
- if (current < 0 && crtc_mode.clock != 0) {
- modes << crtc_mode;
- current = mode.size() - 1;
- }
-
- if (configuration == OutputConfigCurrent)
- configured = current;
-
- int selected_mode = -1;
-
- if (configured >= 0)
- selected_mode = configured;
- else if (preferred >= 0)
- selected_mode = preferred;
- else if (current >= 0)
- selected_mode = current;
- else if (best >= 0)
- selected_mode = best;
-
- if (selected_mode < 0) {
- qWarning() << "No modes available for output" << connectorName;
- return Q_NULLPTR;
- } else {
- int width = modes[selected_mode].hdisplay;
- int height = modes[selected_mode].vdisplay;
- int refresh = modes[selected_mode].vrefresh;
- qCDebug(qLcEglfsKmsDebug) << "Selected mode" << selected_mode << ":" << width << "x" << height
- << '@' << refresh << "hz for output" << connectorName;
- }
-
- // physical size from connector < config values < env vars
- static const int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH");
- static const int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT");
- QSizeF physSize(width, height);
- if (physSize.isEmpty()) {
- physSize = QSize(userConnectorConfig.value(QStringLiteral("physicalWidth")).toInt(),
- userConnectorConfig.value(QStringLiteral("physicalHeight")).toInt());
- if (physSize.isEmpty()) {
- physSize.setWidth(connector->mmWidth);
- physSize.setHeight(connector->mmHeight);
- }
- }
- qCDebug(qLcEglfsKmsDebug) << "Physical size is" << physSize << "mm" << "for output" << connectorName;
-
- QEglFSKmsOutput output = {
- QString::fromUtf8(connectorName),
- connector->connector_id,
- crtc_id,
- physSize,
- selected_mode,
- false,
- drmModeGetCrtc(m_dri_fd, crtc_id),
- modes,
- connector->subpixel,
- connectorProperty(connector, QByteArrayLiteral("DPMS"))
- };
-
- m_crtc_allocator |= (1 << output.crtc_id);
- m_connector_allocator |= (1 << output.connector_id);
-
- return createScreen(m_integration, this, output);
-}
-
-drmModePropertyPtr QEglFSKmsDevice::connectorProperty(drmModeConnectorPtr connector, const QByteArray &name)
-{
- drmModePropertyPtr prop;
-
- for (int i = 0; i < connector->count_props; i++) {
- prop = drmModeGetProperty(m_dri_fd, connector->props[i]);
- if (!prop)
- continue;
- if (strcmp(prop->name, name.constData()) == 0)
- return prop;
- drmModeFreeProperty(prop);
- }
-
- return Q_NULLPTR;
-}
-
-QEglFSKmsDevice::QEglFSKmsDevice(QEglFSKmsIntegration *integration, const QString &path)
- : m_integration(integration)
- , m_path(path)
- , m_dri_fd(-1)
- , m_crtc_allocator(0)
- , m_connector_allocator(0)
-{
-}
-
-QEglFSKmsDevice::~QEglFSKmsDevice()
-{
-}
-
-struct OrderedScreen
-{
- OrderedScreen() : screen(nullptr) { }
- OrderedScreen(QEglFSKmsScreen *screen, const QEglFSKmsDevice::VirtualDesktopInfo &vinfo)
- : screen(screen), vinfo(vinfo) { }
- QEglFSKmsScreen *screen;
- QEglFSKmsDevice::VirtualDesktopInfo vinfo;
-};
-
-QDebug operator<<(QDebug dbg, const OrderedScreen &s)
-{
- QDebugStateSaver saver(dbg);
- dbg.nospace() << "OrderedScreen(" << s.screen << " : " << s.vinfo.virtualIndex
- << " / " << s.vinfo.virtualPos << ")";
- return dbg;
-}
-
-static bool orderedScreenLessThan(const OrderedScreen &a, const OrderedScreen &b)
-{
- return a.vinfo.virtualIndex < b.vinfo.virtualIndex;
-}
-
-void QEglFSKmsDevice::createScreens()
-{
- drmModeResPtr resources = drmModeGetResources(m_dri_fd);
- if (!resources) {
- qWarning("drmModeGetResources failed");
- return;
- }
-
- QVector<OrderedScreen> screens;
-
- for (int i = 0; i < resources->count_connectors; i++) {
- drmModeConnectorPtr connector = drmModeGetConnector(m_dri_fd, resources->connectors[i]);
- if (!connector)
- continue;
-
- VirtualDesktopInfo vinfo;
- QEglFSKmsScreen *screen = createScreenForConnector(resources, connector, &vinfo);
- if (screen)
- screens.append(OrderedScreen(screen, vinfo));
-
- drmModeFreeConnector(connector);
- }
-
- drmModeFreeResources(resources);
-
- // Use stable sort to preserve the original order for outputs with unspecified indices.
- std::stable_sort(screens.begin(), screens.end(), orderedScreenLessThan);
- qCDebug(qLcEglfsKmsDebug) << "Sorted screen list:" << screens;
-
- QPoint pos(0, 0);
- QList<QPlatformScreen *> siblings;
- QEglFSIntegration *qpaIntegration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration());
-
- for (const OrderedScreen &orderedScreen : screens) {
- QEglFSKmsScreen *s = orderedScreen.screen;
- // set up a horizontal or vertical virtual desktop
- if (orderedScreen.vinfo.virtualPos.isNull()) {
- s->setVirtualPosition(pos);
- if (m_integration->virtualDesktopLayout() == QEglFSKmsIntegration::VirtualDesktopLayoutVertical)
- pos.ry() += s->geometry().height();
- else
- pos.rx() += s->geometry().width();
- } else {
- s->setVirtualPosition(orderedScreen.vinfo.virtualPos);
- }
- qCDebug(qLcEglfsKmsDebug) << "Adding screen" << s << "to QPA with geometry" << s->geometry();
- // The order in qguiapp's screens list will match the order set by
- // virtualIndex. This is not only handy but also required since for instance
- // evdevtouch relies on it when performing touch device - screen mapping.
- qpaIntegration->addScreen(s);
- siblings << s;
- }
-
- if (!m_integration->separateScreens()) {
- // enable the virtual desktop
- Q_FOREACH (QPlatformScreen *screen, siblings)
- static_cast<QEglFSKmsScreen *>(screen)->setVirtualSiblings(siblings);
- }
-}
-
-int QEglFSKmsDevice::fd() const
-{
- return m_dri_fd;
-}
-
-QString QEglFSKmsDevice::devicePath() const
-{
- return m_path;
-}
-
-QEglFSKmsScreen *QEglFSKmsDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output)
+QEglFSKmsDevice::QEglFSKmsDevice(QKmsScreenConfig *screenConfig, const QString &path)
+ : QKmsDevice(screenConfig, path)
{
- return new QEglFSKmsScreen(integration, device, output);
}
-void QEglFSKmsDevice::setFd(int fd)
+void QEglFSKmsDevice::registerScreen(QPlatformScreen *screen,
+ const QPoint &virtualPos,
+ const QList<QPlatformScreen *> &virtualSiblings)
{
- m_dri_fd = fd;
+ QEglFSKmsScreen *s = static_cast<QEglFSKmsScreen *>(screen);
+ s->setVirtualPosition(virtualPos);
+ s->setVirtualSiblings(virtualSiblings);
+ static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration())->addScreen(s);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
index 3e7ac7e3f0..1bbea250bb 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
@@ -1,6 +1,5 @@
/****************************************************************************
**
-** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2016 Pelagicore AG
** Contact: https://www.qt.io/licensing/
@@ -42,64 +41,21 @@
#ifndef QEGLFSKMSDEVICE_H
#define QEGLFSKMSDEVICE_H
-#include "qeglfskmsintegration.h"
-#include "qeglfskmsscreen.h"
-
-#include <xf86drm.h>
-#include <xf86drmMode.h>
+#include "private/qeglfsglobal_p.h"
+#include <QtKmsSupport/private/qkmsdevice_p.h>
QT_BEGIN_NAMESPACE
-class Q_EGLFS_EXPORT QEglFSKmsDevice
+class Q_EGLFS_EXPORT QEglFSKmsDevice : public QKmsDevice
{
public:
- struct VirtualDesktopInfo {
- VirtualDesktopInfo() : virtualIndex(0) { }
- int virtualIndex;
- QPoint virtualPos;
- };
-
- QEglFSKmsDevice(QEglFSKmsIntegration *integration, const QString &path);
- virtual ~QEglFSKmsDevice();
-
- virtual bool open() = 0;
- virtual void close() = 0;
-
- virtual void createScreens();
-
- virtual EGLNativeDisplayType nativeDisplay() const = 0;
- int fd() const;
- QString devicePath() const;
-
-protected:
- virtual QEglFSKmsScreen *createScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output);
- void setFd(int fd);
-
- QEglFSKmsIntegration *m_integration;
- QString m_path;
- int m_dri_fd;
-
- quint32 m_crtc_allocator;
- quint32 m_connector_allocator;
-
- int crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector);
- QEglFSKmsScreen *createScreenForConnector(drmModeResPtr resources,
- drmModeConnectorPtr connector,
- VirtualDesktopInfo *vinfo);
- drmModePropertyPtr connectorProperty(drmModeConnectorPtr connector, const QByteArray &name);
-
- static void pageFlipHandler(int fd,
- unsigned int sequence,
- unsigned int tv_sec,
- unsigned int tv_usec,
- void *user_data);
+ QEglFSKmsDevice(QKmsScreenConfig *screenConfig, const QString &path);
-private:
- Q_DISABLE_COPY(QEglFSKmsDevice)
+ void registerScreen(QPlatformScreen *screen,
+ const QPoint &virtualPos,
+ const QList<QPlatformScreen *> &virtualSiblings) override;
};
QT_END_NAMESPACE
-#endif
+#endif // QEGLFSKMSDEVICE_H
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
index 5368a6d031..c77151181e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
@@ -40,13 +40,10 @@
****************************************************************************/
#include "qeglfskmsintegration.h"
-#include "qeglfskmsdevice.h"
#include "qeglfskmsscreen.h"
-#include <QtCore/QJsonDocument>
-#include <QtCore/QJsonObject>
-#include <QtCore/QJsonArray>
-#include <QtCore/QFile>
+#include <QtKmsSupport/private/qkmsdevice_p.h>
+
#include <QtGui/qpa/qplatformwindow.h>
#include <QtGui/QScreen>
@@ -58,28 +55,27 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(qLcEglfsKmsDebug, "qt.qpa.eglfs.kms")
QEglFSKmsIntegration::QEglFSKmsIntegration()
- : m_device(Q_NULLPTR)
- , m_hwCursor(false)
- , m_pbuffers(false)
- , m_separateScreens(false)
- , m_virtualDesktopLayout(VirtualDesktopLayoutHorizontal)
-{}
-
-void QEglFSKmsIntegration::platformInit()
+ : m_device(Q_NULLPTR),
+ m_screenConfig(new QKmsScreenConfig)
{
- loadConfig();
+}
- if (!m_devicePath.isEmpty()) {
- qCDebug(qLcEglfsKmsDebug) << "Using DRM device" << m_devicePath << "specified in config file";
- }
+QEglFSKmsIntegration::~QEglFSKmsIntegration()
+{
+ delete m_screenConfig;
+}
- m_device = createDevice(m_devicePath);
+void QEglFSKmsIntegration::platformInit()
+{
+ qCDebug(qLcEglfsKmsDebug, "platformInit: Opening DRM device");
+ m_device = createDevice();
if (Q_UNLIKELY(!m_device->open()))
- qFatal("Could not open device %s - aborting!", qPrintable(m_devicePath));
+ qFatal("Could not open DRM device");
}
void QEglFSKmsIntegration::platformDestroy()
{
+ qCDebug(qLcEglfsKmsDebug, "platformDestroy: Closing DRM device");
m_device->close();
delete m_device;
m_device = Q_NULLPTR;
@@ -88,7 +84,7 @@ void QEglFSKmsIntegration::platformDestroy()
EGLNativeDisplayType QEglFSKmsIntegration::platformDisplay() const
{
Q_ASSERT(m_device);
- return m_device->nativeDisplay();
+ return (EGLNativeDisplayType) m_device->nativeDisplay();
}
bool QEglFSKmsIntegration::usesDefaultScreen()
@@ -134,94 +130,17 @@ void QEglFSKmsIntegration::waitForVSync(QPlatformSurface *surface) const
bool QEglFSKmsIntegration::supportsPBuffers() const
{
- return m_pbuffers;
-}
-
-bool QEglFSKmsIntegration::hwCursor() const
-{
- return m_hwCursor;
-}
-
-bool QEglFSKmsIntegration::separateScreens() const
-{
- return m_separateScreens;
-}
-
-QEglFSKmsIntegration::VirtualDesktopLayout QEglFSKmsIntegration::virtualDesktopLayout() const
-{
- return m_virtualDesktopLayout;
+ return m_screenConfig->supportsPBuffers();
}
-QMap<QString, QVariantMap> QEglFSKmsIntegration::outputSettings() const
-{
- return m_outputSettings;
-}
-
-QEglFSKmsDevice *QEglFSKmsIntegration::device() const
+QKmsDevice *QEglFSKmsIntegration::device() const
{
return m_device;
}
-void QEglFSKmsIntegration::loadConfig()
+QKmsScreenConfig *QEglFSKmsIntegration::screenConfig() const
{
- static QByteArray json = qgetenv("QT_QPA_EGLFS_KMS_CONFIG");
- if (json.isEmpty())
- return;
-
- qCDebug(qLcEglfsKmsDebug) << "Loading KMS setup from" << json;
-
- QFile file(QString::fromUtf8(json));
- if (!file.open(QFile::ReadOnly)) {
- qCWarning(qLcEglfsKmsDebug) << "Could not open config file"
- << json << "for reading";
- return;
- }
-
- const QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
- if (!doc.isObject()) {
- qCWarning(qLcEglfsKmsDebug) << "Invalid config file" << json
- << "- no top-level JSON object";
- return;
- }
-
- const QJsonObject object = doc.object();
-
- m_hwCursor = object.value(QLatin1String("hwcursor")).toBool(m_hwCursor);
- m_pbuffers = object.value(QLatin1String("pbuffers")).toBool(m_pbuffers);
- m_devicePath = object.value(QLatin1String("device")).toString();
- m_separateScreens = object.value(QLatin1String("separateScreens")).toBool(m_separateScreens);
-
- const QString vdOriString = object.value(QLatin1String("virtualDesktopLayout")).toString();
- if (!vdOriString.isEmpty()) {
- if (vdOriString == QLatin1String("horizontal"))
- m_virtualDesktopLayout = VirtualDesktopLayoutHorizontal;
- else if (vdOriString == QLatin1String("vertical"))
- m_virtualDesktopLayout = VirtualDesktopLayoutVertical;
- else
- qCWarning(qLcEglfsKmsDebug) << "Unknown virtualDesktopOrientation value" << vdOriString;
- }
-
- const QJsonArray outputs = object.value(QLatin1String("outputs")).toArray();
- for (int i = 0; i < outputs.size(); i++) {
- const QVariantMap outputSettings = outputs.at(i).toObject().toVariantMap();
-
- if (outputSettings.contains(QStringLiteral("name"))) {
- const QString name = outputSettings.value(QStringLiteral("name")).toString();
-
- if (m_outputSettings.contains(name)) {
- qCDebug(qLcEglfsKmsDebug) << "Output" << name << "configured multiple times!";
- }
-
- m_outputSettings.insert(name, outputSettings);
- }
- }
-
- qCDebug(qLcEglfsKmsDebug) << "Configuration:\n"
- << "\thwcursor:" << m_hwCursor << "\n"
- << "\tpbuffers:" << m_pbuffers << "\n"
- << "\tseparateScreens:" << m_separateScreens << "\n"
- << "\tvirtualDesktopLayout:" << m_virtualDesktopLayout << "\n"
- << "\toutputs:" << m_outputSettings;
+ return m_screenConfig;
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h
index ba49945715..21347d9131 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h
@@ -49,19 +49,16 @@
QT_BEGIN_NAMESPACE
-class QEglFSKmsDevice;
+class QKmsDevice;
+class QKmsScreenConfig;
Q_EGLFS_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
class Q_EGLFS_EXPORT QEglFSKmsIntegration : public QEglFSDeviceIntegration
{
public:
- enum VirtualDesktopLayout {
- VirtualDesktopLayoutHorizontal,
- VirtualDesktopLayoutVertical
- };
-
QEglFSKmsIntegration();
+ ~QEglFSKmsIntegration();
void platformInit() Q_DECL_OVERRIDE;
void platformDestroy() Q_DECL_OVERRIDE;
@@ -73,25 +70,14 @@ public:
void waitForVSync(QPlatformSurface *surface) const Q_DECL_OVERRIDE;
bool supportsPBuffers() const Q_DECL_OVERRIDE;
- virtual bool hwCursor() const;
- virtual bool separateScreens() const;
- virtual VirtualDesktopLayout virtualDesktopLayout() const;
- QMap<QString, QVariantMap> outputSettings() const;
-
- QEglFSKmsDevice *device() const;
+ QKmsDevice *device() const;
+ QKmsScreenConfig *screenConfig() const;
protected:
- virtual QEglFSKmsDevice *createDevice(const QString &devicePath) = 0;
-
- void loadConfig();
+ virtual QKmsDevice *createDevice() = 0;
- QEglFSKmsDevice *m_device;
- bool m_hwCursor;
- bool m_pbuffers;
- bool m_separateScreens;
- VirtualDesktopLayout m_virtualDesktopLayout;
- QString m_devicePath;
- QMap<QString, QVariantMap> m_outputSettings;
+ QKmsDevice *m_device;
+ QKmsScreenConfig *m_screenConfig;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
index 4021609407..a2af586947 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include "qeglfskmsscreen.h"
-#include "qeglfskmsdevice.h"
#include "qeglfsintegration_p.h"
#include <QtCore/QLoggingCategory>
@@ -69,30 +68,19 @@ private:
QEglFSKmsScreen *m_screen;
};
-QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output)
- : QEglFSScreen(eglGetDisplay(device->nativeDisplay()))
- , m_integration(integration)
+QEglFSKmsScreen::QEglFSKmsScreen(QKmsDevice *device, const QKmsOutput &output)
+ : QEglFSScreen(eglGetDisplay((EGLNativeDisplayType) device->nativeDisplay()))
, m_device(device)
, m_output(output)
, m_powerState(PowerStateOn)
, m_interruptHandler(new QEglFSKmsInterruptHandler(this))
{
- m_siblings << this; // gets overridden by QEglFSKmsDevice later if !separateScreens
+ m_siblings << this; // gets overridden later
}
QEglFSKmsScreen::~QEglFSKmsScreen()
{
- if (m_output.dpms_prop) {
- drmModeFreeProperty(m_output.dpms_prop);
- m_output.dpms_prop = Q_NULLPTR;
- }
- restoreMode();
- if (m_output.saved_crtc) {
- drmModeFreeCrtc(m_output.saved_crtc);
- m_output.saved_crtc = Q_NULLPTR;
- }
+ m_output.cleanup(m_device);
delete m_interruptHandler;
}
@@ -171,16 +159,7 @@ void QEglFSKmsScreen::flipFinished()
void QEglFSKmsScreen::restoreMode()
{
- if (m_output.mode_set && m_output.saved_crtc) {
- drmModeSetCrtc(m_device->fd(),
- m_output.saved_crtc->crtc_id,
- m_output.saved_crtc->buffer_id,
- 0, 0,
- &m_output.connector_id, 1,
- &m_output.saved_crtc->mode);
-
- m_output.mode_set = false;
- }
+ m_output.restoreMode(m_device);
}
qreal QEglFSKmsScreen::refreshRate() const
@@ -191,20 +170,7 @@ qreal QEglFSKmsScreen::refreshRate() const
QPlatformScreen::SubpixelAntialiasingType QEglFSKmsScreen::subpixelAntialiasingTypeHint() const
{
- switch (m_output.subpixel) {
- default:
- case DRM_MODE_SUBPIXEL_UNKNOWN:
- case DRM_MODE_SUBPIXEL_NONE:
- return Subpixel_None;
- case DRM_MODE_SUBPIXEL_HORIZONTAL_RGB:
- return Subpixel_RGB;
- case DRM_MODE_SUBPIXEL_HORIZONTAL_BGR:
- return Subpixel_BGR;
- case DRM_MODE_SUBPIXEL_VERTICAL_RGB:
- return Subpixel_VRGB;
- case DRM_MODE_SUBPIXEL_VERTICAL_BGR:
- return Subpixel_VBGR;
- }
+ return m_output.subpixelAntialiasingTypeHint();
}
QPlatformScreen::PowerState QEglFSKmsScreen::powerState() const
@@ -214,11 +180,7 @@ QPlatformScreen::PowerState QEglFSKmsScreen::powerState() const
void QEglFSKmsScreen::setPowerState(QPlatformScreen::PowerState state)
{
- if (!m_output.dpms_prop)
- return;
-
- drmModeConnectorSetProperty(m_device->fd(), m_output.connector_id,
- m_output.dpms_prop->prop_id, (int)state);
+ m_output.setPowerState(m_device, state);
m_powerState = state;
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
index 2b6a0ffe6c..25740697d7 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
@@ -42,39 +42,20 @@
#ifndef QEGLFSKMSSCREEN_H
#define QEGLFSKMSSCREEN_H
-#include "qeglfskmsintegration.h"
#include "private/qeglfsscreen_p.h"
#include <QtCore/QList>
#include <QtCore/QMutex>
-#include <xf86drm.h>
-#include <xf86drmMode.h>
+#include <QtKmsSupport/private/qkmsdevice_p.h>
QT_BEGIN_NAMESPACE
-class QEglFSKmsDevice;
class QEglFSKmsInterruptHandler;
-struct QEglFSKmsOutput
-{
- QString name;
- uint32_t connector_id;
- uint32_t crtc_id;
- QSizeF physical_size;
- int mode; // index of selected mode in list below
- bool mode_set;
- drmModeCrtcPtr saved_crtc;
- QList<drmModeModeInfo> modes;
- int subpixel;
- drmModePropertyPtr dpms_prop;
-};
-
class Q_EGLFS_EXPORT QEglFSKmsScreen : public QEglFSScreen
{
public:
- QEglFSKmsScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output);
+ QEglFSKmsScreen(QKmsDevice *device, const QKmsOutput &output);
~QEglFSKmsScreen();
void setVirtualPosition(const QPoint &pos);
@@ -96,8 +77,7 @@ public:
QList<QPlatformScreen *> virtualSiblings() const Q_DECL_OVERRIDE { return m_siblings; }
void setVirtualSiblings(QList<QPlatformScreen *> sl) { m_siblings = sl; }
- QEglFSKmsIntegration *integration() const { return m_integration; }
- QEglFSKmsDevice *device() const { return m_device; }
+ QKmsDevice *device() const { return m_device; }
void destroySurface();
@@ -105,7 +85,7 @@ public:
virtual void flip();
virtual void flipFinished();
- QEglFSKmsOutput &output() { return m_output; }
+ QKmsOutput &output() { return m_output; }
void restoreMode();
SubpixelAntialiasingType subpixelAntialiasingTypeHint() const Q_DECL_OVERRIDE;
@@ -114,10 +94,9 @@ public:
void setPowerState(QPlatformScreen::PowerState state) Q_DECL_OVERRIDE;
protected:
- QEglFSKmsIntegration *m_integration;
- QEglFSKmsDevice *m_device;
+ QKmsDevice *m_device;
- QEglFSKmsOutput m_output;
+ QKmsOutput m_output;
QPoint m_pos;
QList<QPlatformScreen *> m_siblings;
diff --git a/src/plugins/platforms/ios/kernel.pro b/src/plugins/platforms/ios/kernel.pro
index caafe89730..71257d09f7 100644
--- a/src/plugins/platforms/ios/kernel.pro
+++ b/src/plugins/platforms/ios/kernel.pro
@@ -1,5 +1,10 @@
TARGET = qios
+# QTBUG-42937: Work around linker errors caused by circular
+# dependencies between the iOS platform plugin and the user
+# application's main() when the plugin is a shared library.
+qtConfig(shared): CONFIG += static
+
QT += \
core-private gui-private \
clipboard_support-private fontdatabase_support-private graphics_support-private
diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/nsphotolibrarysupport.pro b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/nsphotolibrarysupport.pro
index f4588dda03..7379765599 100644
--- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/nsphotolibrarysupport.pro
+++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/nsphotolibrarysupport.pro
@@ -1,7 +1,11 @@
TARGET = qiosnsphotolibrarysupport
+# QTBUG-42937: Since the iOS plugin (kernel) is
+# static, this plugin needs to be static as well.
+qtConfig(shared): CONFIG += static
+
QT += core gui gui-private
-LIBS += -framework UIKit -framework AssetsLibrary
+LIBS += -framework Foundation -framework UIKit -framework AssetsLibrary
HEADERS = \
qiosfileengineassetslibrary.h \
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index e5b4d6da85..fbf167b514 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -61,6 +61,7 @@
#include <QtFontDatabaseSupport/private/qcoretextfontdatabase_p.h>
#include <QtClipboardSupport/private/qmacmime_p.h>
#include <QDir>
+#include <QOperatingSystemVersion>
#import <AudioToolbox/AudioServices.h>
@@ -119,7 +120,7 @@ QIOSIntegration::QIOSIntegration()
m_touchDevice = new QTouchDevice;
m_touchDevice->setType(QTouchDevice::TouchScreen);
QTouchDevice::Capabilities touchCapabilities = QTouchDevice::Position | QTouchDevice::NormalizedPosition;
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_9_0) {
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 9)) {
if (mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
touchCapabilities |= QTouchDevice::Pressure;
}
diff --git a/src/plugins/platforms/ios/qiosmessagedialog.mm b/src/plugins/platforms/ios/qiosmessagedialog.mm
index 50d5442f17..4f0c667861 100644
--- a/src/plugins/platforms/ios/qiosmessagedialog.mm
+++ b/src/plugins/platforms/ios/qiosmessagedialog.mm
@@ -39,6 +39,7 @@
#import <UIKit/UIKit.h>
+#include <QtCore/qoperatingsystemversion.h>
#include <QtGui/qwindow.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h>
@@ -109,7 +110,7 @@ bool QIOSMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality win
if (m_alertController // Ensure that the dialog is not showing already
|| !options() // Some message dialogs don't have options (QErrorMessage)
|| windowModality == Qt::NonModal // We can only do modal dialogs
- || QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_8_0) // API limitation
+ || QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) // API limitation
return false;
m_alertController = [[UIAlertController
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index c518f9111d..49268ee076 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -45,6 +45,7 @@
#include "qiosapplicationdelegate.h"
#include "qiosviewcontroller.h"
#include "quiview.h"
+#include <QtCore/qoperatingsystemversion.h>
#include <QtGui/private/qwindow_p.h>
#include <private/qcoregraphics_p.h>
@@ -274,7 +275,7 @@ void QIOSScreen::updateProperties()
if (m_uiScreen == [UIScreen mainScreen]) {
Qt::ScreenOrientation statusBarOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation));
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_8_0) {
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) {
// On iOS < 8.0 the UIScreen geometry is always in portait, and the system applies
// the screen rotation to the root view-controller's view instead of directly to the
// screen, like iOS 8 and above does.
@@ -302,7 +303,7 @@ void QIOSScreen::updateProperties()
if (m_geometry != previousGeometry) {
QRectF physicalGeometry;
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0) {
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) {
// We can't use the primaryOrientation of screen(), as we haven't reported the new geometry yet
Qt::ScreenOrientation primaryOrientation = m_geometry.width() >= m_geometry.height() ?
Qt::LandscapeOrientation : Qt::PortraitOrientation;
@@ -407,7 +408,7 @@ Qt::ScreenOrientation QIOSScreen::nativeOrientation() const
{
CGRect nativeBounds =
#if !defined(Q_OS_TVOS) && QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_8_0)
- QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0 ? m_uiScreen.nativeBounds :
+ QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8) ? m_uiScreen.nativeBounds :
#endif
m_uiScreen.bounds;
diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm
index 238d7addf6..48262dad10 100644
--- a/src/plugins/platforms/ios/qiostextinputoverlay.mm
+++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm
@@ -219,7 +219,7 @@ static void executeBlockWithoutAnimation(Block block)
borderLayer.borderColor = [[UIColor lightGrayColor] CGColor];
[self addSublayer:borderLayer];
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_7_0) {
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 7)) {
// [UIView snapshotViewAfterScreenUpdates:] is available since iOS 7.0.
// Just silently ignore showing the loupe for older versions.
self.hidden = YES;
@@ -267,7 +267,7 @@ static void executeBlockWithoutAnimation(Block block)
- (void)display
{
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_7_0)
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 7))
return;
// Take a snapshow of the target view, magnify the area around the focal
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index 2a1444e9e5..259070216e 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -48,6 +48,7 @@
#include "qiosmenu.h"
#endif
+#include <QtCore/qoperatingsystemversion.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qwindow_p.h>
#include <qpa/qwindowsysteminterface_p.h>
@@ -291,7 +292,7 @@
QTouchDevice *touchDevice = QIOSIntegration::instance()->touchDevice();
QTouchDevice::Capabilities touchCapabilities = touchDevice->capabilities();
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_9_0) {
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 9)) {
if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
touchCapabilities |= QTouchDevice::Pressure;
else
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
index 246c959fd3..dc7ea08dc5 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
@@ -414,7 +414,7 @@ QRegion QLinuxFbScreen::doRedraw()
mBlitter->setCompositionMode(QPainter::CompositionMode_Source);
for (const QRect &rect : touched)
- mBlitter->drawImage(rect, *mScreenImage, rect);
+ mBlitter->drawImage(rect, mScreenImage, rect);
return touched;
}
diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro
index 9da3d6811b..0b052adf0f 100644
--- a/src/plugins/platforms/qnx/qnx.pro
+++ b/src/plugins/platforms/qnx/qnx.pro
@@ -7,8 +7,6 @@ QT += \
# Uncomment this to build with support for IMF once it becomes available in the BBNDK
#CONFIG += qqnx_imf
-CONFIG += qqnx_screeneventthread
-
# Uncomment these to enable debugging output for various aspects of the plugin
#DEFINES += QQNXBUFFER_DEBUG
#DEFINES += QQNXBUTTON_DEBUG
@@ -47,7 +45,8 @@ SOURCES = main.cpp \
qqnxservices.cpp \
qqnxcursor.cpp \
qqnxrasterwindow.cpp \
- qqnxglobal.cpp
+ qqnxglobal.cpp \
+ qqnxscreeneventthread.cpp
HEADERS = main.h \
qqnxbuffer.h \
@@ -67,13 +66,8 @@ HEADERS = main.h \
qqnxrasterwindow.h \
qqnxscreeneventfilter.h \
qqnxglobal.h \
- qqnxlgmon.h
-
-CONFIG(qqnx_screeneventthread) {
- DEFINES += QQNX_SCREENEVENTTHREAD
- SOURCES += qqnxscreeneventthread.cpp
- HEADERS += qqnxscreeneventthread.h
-}
+ qqnxlgmon.h \
+ qqnxscreeneventthread.h
LIBS += -lscreen
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index 7229d7d2a8..eee0581709 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -40,9 +40,7 @@
#include "qqnxglobal.h"
#include "qqnxintegration.h"
-#if defined(QQNX_SCREENEVENTTHREAD)
#include "qqnxscreeneventthread.h"
-#endif
#include "qqnxnativeinterface.h"
#include "qqnxrasterbackingstore.h"
#include "qqnxscreen.h"
@@ -125,9 +123,7 @@ static inline QQnxIntegration::Options parseOptions(const QStringList &paramList
QQnxIntegration::QQnxIntegration(const QStringList &paramList)
: QPlatformIntegration()
-#if defined(QQNX_SCREENEVENTTHREAD)
, m_screenEventThread(0)
-#endif
, m_navigatorEventHandler(new QQnxNavigatorEventHandler())
, m_virtualKeyboard(0)
#if defined(QQNX_PPS)
@@ -169,10 +165,8 @@ QQnxIntegration::QQnxIntegration(const QStringList &paramList)
#endif
// Create/start event thread
-#if defined(QQNX_SCREENEVENTTHREAD)
m_screenEventThread = new QQnxScreenEventThread(ms_screenContext, m_screenEventHandler);
m_screenEventThread->start();
-#endif
#if defined(QQNX_PPS)
// Create/start the keyboard class.
@@ -235,10 +229,8 @@ QQnxIntegration::~QQnxIntegration()
#endif
delete m_navigatorEventHandler;
-#if defined(QQNX_SCREENEVENTTHREAD)
// Stop/destroy screen event thread
delete m_screenEventThread;
-#endif
// In case the event-dispatcher was never transferred to QCoreApplication
delete m_eventDispatcher;
diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h
index f543b0d102..3b43837dec 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.h
+++ b/src/plugins/platforms/qnx/qqnxintegration.h
@@ -48,9 +48,7 @@
QT_BEGIN_NAMESPACE
-#if defined(QQNX_SCREENEVENTTHREAD)
class QQnxScreenEventThread;
-#endif
class QQnxFileDialogHelper;
class QQnxNativeInterface;
class QQnxWindow;
@@ -142,9 +140,7 @@ private:
static void removeWindow(screen_window_t qnxWindow);
static screen_context_t ms_screenContext;
-#if defined(QQNX_SCREENEVENTTHREAD)
QQnxScreenEventThread *m_screenEventThread;
-#endif
QQnxNavigatorEventHandler *m_navigatorEventHandler;
QQnxAbstractVirtualKeyboard *m_virtualKeyboard;
#if defined(QQNX_PPS)
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
index beda6e1a49..5d230e2145 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
@@ -40,9 +40,7 @@
#include "qqnxglobal.h"
#include "qqnxscreeneventhandler.h"
-#if defined(QQNX_SCREENEVENTTHREAD)
#include "qqnxscreeneventthread.h"
-#endif
#include "qqnxintegration.h"
#include "qqnxkeytranslator.h"
#include "qqnxscreen.h"
@@ -67,9 +65,7 @@ QQnxScreenEventHandler::QQnxScreenEventHandler(QQnxIntegration *integration)
, m_lastButtonState(Qt::NoButton)
, m_lastMouseWindow(0)
, m_touchDevice(0)
-#if defined(QQNX_SCREENEVENTTHREAD)
, m_eventThread(0)
-#endif
, m_focusLostTimer(-1)
{
// Create a touch device
@@ -198,7 +194,6 @@ void QQnxScreenEventHandler::injectKeyboardEvent(int flags, int sym, int modifie
}
}
-#if defined(QQNX_SCREENEVENTTHREAD)
void QQnxScreenEventHandler::setScreenEventThread(QQnxScreenEventThread *eventThread)
{
m_eventThread = eventThread;
@@ -233,7 +228,6 @@ void QQnxScreenEventHandler::processEventsFromScreenThread()
m_eventThread->unlock();
}
-#endif
void QQnxScreenEventHandler::handleKeyboardEvent(screen_event_t event)
{
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h
index 6b234e8d8f..78b089764f 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h
@@ -48,9 +48,7 @@ QT_BEGIN_NAMESPACE
class QQnxIntegration;
class QQnxScreenEventFilter;
-#if defined(QQNX_SCREENEVENTTHREAD)
class QQnxScreenEventThread;
-#endif
class QQnxScreenEventHandler : public QObject
{
@@ -66,9 +64,7 @@ public:
static void injectKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
-#if defined(QQNX_SCREENEVENTTHREAD)
void setScreenEventThread(QQnxScreenEventThread *eventThread);
-#endif
Q_SIGNALS:
void newWindowCreated(void *window);
@@ -77,10 +73,8 @@ Q_SIGNALS:
protected:
void timerEvent(QTimerEvent *event);
-#if defined(QQNX_SCREENEVENTTHREAD)
private Q_SLOTS:
void processEventsFromScreenThread();
-#endif
private:
void handleKeyboardEvent(screen_event_t event);
@@ -105,9 +99,7 @@ private:
QTouchDevice *m_touchDevice;
QWindowSystemInterface::TouchPoint m_touchPoints[MaximumTouchPoints];
QList<QQnxScreenEventFilter*> m_eventFilters;
-#if defined(QQNX_SCREENEVENTTHREAD)
QQnxScreenEventThread *m_eventThread;
-#endif
int m_focusLostTimer;
};
diff --git a/src/plugins/platforms/vnc/qvncscreen.cpp b/src/plugins/platforms/vnc/qvncscreen.cpp
index 34def45767..91a8933dba 100644
--- a/src/plugins/platforms/vnc/qvncscreen.cpp
+++ b/src/plugins/platforms/vnc/qvncscreen.cpp
@@ -150,10 +150,10 @@ QPixmap QVncScreen::grabWindow(WId wid, int x, int y, int width, int height) con
{
if (!wid) {
if (width < 0)
- width = mScreenImage->width() - x;
+ width = mScreenImage.width() - x;
if (height < 0)
- height = mScreenImage->height() - y;
- return QPixmap::fromImage(*mScreenImage).copy(x, y, width, height);
+ height = mScreenImage.height() - y;
+ return QPixmap::fromImage(mScreenImage).copy(x, y, width, height);
}
QFbWindow *window = windowForId(wid);
@@ -165,7 +165,7 @@ QPixmap QVncScreen::grabWindow(WId wid, int x, int y, int width, int height) con
height = geom.height() - y;
QRect rect(geom.topLeft() + QPoint(x, y), QSize(width, height));
rect &= window->geometry();
- return QPixmap::fromImage(*mScreenImage).copy(rect);
+ return QPixmap::fromImage(mScreenImage).copy(rect);
}
return QPixmap();
@@ -183,5 +183,10 @@ bool QVNCScreen::swapBytes() const
}
#endif
+QFbScreen::Flags QVncScreen::flags() const
+{
+ return QFbScreen::DontForceFirstWindowToFullScreen;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/vnc/qvncscreen.h b/src/plugins/platforms/vnc/qvncscreen.h
index 785abd6dc2..4b7171b5a9 100644
--- a/src/plugins/platforms/vnc/qvncscreen.h
+++ b/src/plugins/platforms/vnc/qvncscreen.h
@@ -64,12 +64,14 @@ public:
QPixmap grabWindow(WId wid, int x, int y, int width, int height) const Q_DECL_OVERRIDE;
QRegion doRedraw() Q_DECL_OVERRIDE;
- QImage *image() const { return mScreenImage; }
+ QImage *image() { return &mScreenImage; }
void enableClientCursor(QVncClient *client);
void disableClientCursor(QVncClient *client);
QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
+ Flags flags() const Q_DECL_OVERRIDE;
+
void clearDirty() { dirtyRegion = QRegion(); }
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
index 9803dedb1e..06d481b3af 100644
--- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
+++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
@@ -1052,11 +1052,24 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::get_accValue(VARIANT varID, BS
return S_FALSE;
}
-HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::put_accValue(VARIANT, BSTR)
+HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::put_accValue(VARIANT, BSTR value)
{
QAccessibleInterface *accessible = accessibleInterface();
accessibleDebugClientCalls(accessible);
- return DISP_E_MEMBERNOTFOUND;
+
+ if (!accessible || !accessible->isValid()) {
+ return E_FAIL;
+ }
+
+ QString qstrValue = QString::fromWCharArray(value);
+
+ if (accessible->valueInterface()) {
+ accessible->valueInterface()->setCurrentValue(qstrValue);
+ } else {
+ accessible->setText(QAccessible::Value, qstrValue);
+ }
+
+ return S_OK;
}
// moz: [important]
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 1a03df6ac2..40d4cb1497 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -68,6 +68,7 @@
#include <QtCore/QHash>
#include <QtCore/QStringList>
#include <QtCore/QDebug>
+#include <QtCore/QOperatingSystemVersion>
#include <QtCore/QSysInfo>
#include <QtCore/QScopedArrayPointer>
#include <QtCore/private/qsystemlibrary_p.h>
@@ -185,7 +186,7 @@ QWindowsShcoreDLL::QWindowsShcoreDLL()
void QWindowsShcoreDLL::init()
{
- if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS8_1)
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8_1)
return;
QSystemLibrary library(QStringLiteral("SHCore"));
getProcessDpiAwareness = (GetProcessDpiAwareness)library.resolve("GetProcessDpiAwareness");
diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp
index 26a5131927..9519b509bc 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -190,6 +190,20 @@ static inline Qt::KeyboardModifiers toQtKeyboardModifiers(DWORD keyState)
return modifiers;
}
+static inline Qt::MouseButtons toQtMouseButtons(DWORD keyState)
+{
+ Qt::MouseButtons buttons = Qt::NoButton;
+
+ if (keyState & MK_LBUTTON)
+ buttons |= Qt::LeftButton;
+ if (keyState & MK_RBUTTON)
+ buttons |= Qt::RightButton;
+ if (keyState & MK_MBUTTON)
+ buttons |= Qt::MidButton;
+
+ return buttons;
+}
+
/*!
\class QWindowsOleDropSource
\brief Implementation of IDropSource
@@ -405,16 +419,7 @@ QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
break;
}
- // grfKeyState is broken on CE & some Windows XP versions,
- // therefore we need to check the state manually
- if ((GetAsyncKeyState(VK_LBUTTON) == 0)
- && (GetAsyncKeyState(VK_MBUTTON) == 0)
- && (GetAsyncKeyState(VK_RBUTTON) == 0)) {
- hr = ResultFromScode(DRAGDROP_S_DROP);
- break;
- }
-
- const Qt::MouseButtons buttons = QWindowsMouseHandler::keyStateToMouseButtons(grfKeyState);
+ const Qt::MouseButtons buttons = toQtMouseButtons(grfKeyState);
if (m_currentButtons == Qt::NoButton) {
m_currentButtons = buttons;
} else {
@@ -538,7 +543,7 @@ void QWindowsOleDropTarget::handleDrag(QWindow *window, DWORD grfKeyState,
QWindowsDrag *windowsDrag = QWindowsDrag::instance();
const Qt::DropActions actions = translateToQDragDropActions(*pdwEffect);
QGuiApplicationPrivate::modifier_buttons = toQtKeyboardModifiers(grfKeyState);
- QGuiApplicationPrivate::mouse_buttons = QWindowsMouseHandler::keyStateToMouseButtons(grfKeyState);
+ QGuiApplicationPrivate::mouse_buttons = toQtMouseButtons(grfKeyState);
const QPlatformDragQtResponse response =
QWindowSystemInterface::handleDrag(window, windowsDrag->dropData(), m_lastPoint, actions);
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index a9b061ad73..2d9a683da6 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -114,6 +114,35 @@ static QByteArray debugWinExStyle(DWORD exStyle)
return rc;
}
+static QByteArray debugWinSwpPos(UINT flags)
+{
+ QByteArray rc = "0x";
+ rc += QByteArray::number(flags, 16);
+ if (flags & SWP_FRAMECHANGED)
+ rc += " SWP_FRAMECHANGED";
+ if (flags & SWP_HIDEWINDOW)
+ rc += " SWP_HIDEWINDOW";
+ if (flags & SWP_NOACTIVATE)
+ rc += " SWP_NOACTIVATE";
+ if (flags & SWP_NOCOPYBITS)
+ rc += " SWP_NOCOPYBITS";
+ if (flags & SWP_NOMOVE)
+ rc += " SWP_NOMOVE";
+ if (flags & SWP_NOOWNERZORDER)
+ rc += " SWP_NOOWNERZORDER";
+ if (flags & SWP_NOREDRAW)
+ rc += " SWP_NOREDRAW";
+ if (flags & SWP_NOSENDCHANGING)
+ rc += " SWP_NOSENDCHANGING";
+ if (flags & SWP_NOSIZE)
+ rc += " SWP_NOSIZE";
+ if (flags & SWP_NOZORDER)
+ rc += " SWP_NOZORDER";
+ if (flags & SWP_SHOWWINDOW)
+ rc += " SWP_SHOWWINDOW";
+ return rc;
+}
+
static inline QSize qSizeOfRect(const RECT &rect)
{
return QSize(rect.right -rect.left, rect.bottom - rect.top);
@@ -137,8 +166,9 @@ QDebug operator<<(QDebug d, const RECT &r)
{
QDebugStateSaver saver(d);
d.nospace();
- d << "RECT: left/top=" << r.left << ',' << r.top
- << " right/bottom=" << r.right << ',' << r.bottom;
+ d << "RECT(left=" << r.left << ", top=" << r.top
+ << ", right=" << r.right << ", bottom=" << r.bottom
+ << " (" << r.right - r.left << 'x' << r.bottom - r.top << "))";
return d;
}
@@ -148,12 +178,23 @@ QDebug operator<<(QDebug d, const POINT &p)
return d;
}
+QDebug operator<<(QDebug d, const WINDOWPOS &wp)
+{
+ QDebugStateSaver saver(d);
+ d.nospace();
+ d.noquote();
+ d << "WINDOWPOS(flags=" << debugWinSwpPos(wp.flags) << ", hwnd="
+ << wp.hwnd << ", hwndInsertAfter=" << wp.hwndInsertAfter << ", x=" << wp.x
+ << ", y=" << wp.y << ", cx=" << wp.cx << ", cy=" << wp.cy << ')';
+ return d;
+}
+
QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p)
{
QDebugStateSaver saver(d);
d.nospace();
- d << "NCCALCSIZE_PARAMS " << qrectFromRECT(p.rgrc[0])
- << ' ' << qrectFromRECT(p.rgrc[1]) << ' ' << qrectFromRECT(p.rgrc[2]);
+ d << "NCCALCSIZE_PARAMS(rgrc=[" << p.rgrc[0] << ' ' << p.rgrc[1] << ' '
+ << p.rgrc[2] << "], lppos=" << *p.lppos << ')';
return d;
}
@@ -173,6 +214,7 @@ QDebug operator<<(QDebug d, const WINDOWPLACEMENT &wp)
{
QDebugStateSaver saver(d);
d.nospace();
+ d.noquote();
d << "WINDOWPLACEMENT(flags=0x" << hex << wp.flags << dec << ", showCmd="
<< wp.showCmd << ", ptMinPosition=" << wp.ptMinPosition << ", ptMaxPosition=" << wp.ptMaxPosition
<< ", rcNormalPosition=" << wp.rcNormalPosition;
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index 924f242e6e..90b0940813 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -357,6 +357,7 @@ QDebug operator<<(QDebug d, const POINT &);
QDebug operator<<(QDebug d, const MINMAXINFO &i);
QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p);
QDebug operator<<(QDebug d, const WINDOWPLACEMENT &);
+QDebug operator<<(QDebug d, const WINDOWPOS &);
#endif // !QT_NO_DEBUG_STREAM
// ---------- QWindowsGeometryHint inline functions.
diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri
index d97e49309f..5071cd8e21 100644
--- a/src/plugins/platforms/windows/windows.pri
+++ b/src/plugins/platforms/windows/windows.pri
@@ -97,5 +97,5 @@ RESOURCES += $$PWD/openglblacklists.qrc
qtConfig(accessibility): include($$PWD/accessible/accessible.pri)
-DEFINES *= LIBEGL_NAME=$${LIBEGL_NAME}
-DEFINES *= LIBGLESV2_NAME=$${LIBGLESV2_NAME}
+DEFINES *= LIBEGL_NAME=$${LIBQTANGLE_NAME}
+DEFINES *= LIBGLESV2_NAME=$${LIBQTANGLE_NAME}
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 7bd233f387..57ce357a17 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -131,7 +131,7 @@ typedef struct qt_xcb_ge_event_t {
static inline bool isXIEvent(xcb_generic_event_t *event, int opCode)
{
- qt_xcb_ge_event_t *e = (qt_xcb_ge_event_t *)event;
+ qt_xcb_ge_event_t *e = reinterpret_cast<qt_xcb_ge_event_t *>(event);
return e->extension == opCode;
}
#endif // XCB_USE_XINPUT2
@@ -251,7 +251,7 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event)
// Find a fake screen
const auto scrs = virtualDesktop->screens();
for (QPlatformScreen *scr : scrs) {
- QXcbScreen *xcbScreen = (QXcbScreen *)scr;
+ QXcbScreen *xcbScreen = static_cast<QXcbScreen *>(scr);
if (xcbScreen->output() == XCB_NONE) {
screen = xcbScreen;
break;
@@ -377,7 +377,7 @@ void QXcbConnection::destroyScreen(QXcbScreen *screen)
// When primary screen is removed, set the new primary screen
// which belongs to the primary virtual desktop.
if (screen->isPrimary()) {
- QXcbScreen *newPrimary = (QXcbScreen *)virtualDesktop->screens().at(0);
+ QXcbScreen *newPrimary = static_cast<QXcbScreen *>(virtualDesktop->screens().at(0));
newPrimary->setPrimary(true);
const int idx = m_screens.indexOf(newPrimary);
if (idx > 0)
@@ -711,7 +711,7 @@ QXcbConnection::~QXcbConnection()
delete m_glIntegration;
#ifdef XCB_USE_XLIB
- XCloseDisplay((Display *)m_xlib_display);
+ XCloseDisplay(static_cast<Display *>(m_xlib_display));
#else
xcb_disconnect(xcb_connection());
#endif
@@ -754,7 +754,7 @@ QXcbWindow *QXcbConnection::platformWindowFromId(xcb_window_t id)
#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, windowMember, handler) \
{ \
- event_t *e = (event_t *)event; \
+ event_t *e = reinterpret_cast<event_t *>(event); \
if (QXcbWindowEventListener *eventListener = windowEventListenerFromId(e->windowMember)) { \
handled = eventListener->handleGenericEvent(event, &result); \
if (!handled) \
@@ -765,7 +765,7 @@ break;
#define HANDLE_KEYBOARD_EVENT(event_t, handler) \
{ \
- event_t *e = (event_t *)event; \
+ event_t *e = reinterpret_cast<event_t *>(event); \
if (QXcbWindowEventListener *eventListener = windowEventListenerFromId(e->event)) { \
handled = eventListener->handleGenericEvent(event, &result); \
if (!handled) \
@@ -1184,11 +1184,11 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
m_keyboard->updateXKBStateFromCore(((xcb_key_release_event_t *)event)->state);
HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent);
case XCB_MAPPING_NOTIFY:
- m_keyboard->handleMappingNotifyEvent((xcb_mapping_notify_event_t *)event);
+ m_keyboard->handleMappingNotifyEvent(reinterpret_cast<xcb_mapping_notify_event_t *>(event));
break;
case XCB_SELECTION_REQUEST:
{
- xcb_selection_request_event_t *sr = (xcb_selection_request_event_t *)event;
+ xcb_selection_request_event_t *sr = reinterpret_cast<xcb_selection_request_event_t *>(event);
#ifndef QT_NO_DRAGANDDROP
if (sr->selection == atom(QXcbAtom::XdndSelection))
m_drag->handleSelectionRequest(sr);
@@ -1202,19 +1202,19 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
break;
}
case XCB_SELECTION_CLEAR:
- setTime(((xcb_selection_clear_event_t *)event)->time);
+ setTime((reinterpret_cast<xcb_selection_clear_event_t *>(event))->time);
#ifndef QT_NO_CLIPBOARD
- m_clipboard->handleSelectionClearRequest((xcb_selection_clear_event_t *)event);
+ m_clipboard->handleSelectionClearRequest(reinterpret_cast<xcb_selection_clear_event_t *>(event));
#endif
handled = true;
break;
case XCB_SELECTION_NOTIFY:
- setTime(((xcb_selection_notify_event_t *)event)->time);
+ setTime((reinterpret_cast<xcb_selection_notify_event_t *>(event))->time);
handled = false;
break;
case XCB_PROPERTY_NOTIFY:
{
- xcb_property_notify_event_t *pn = (xcb_property_notify_event_t *)event;
+ xcb_property_notify_event_t *pn = reinterpret_cast<xcb_property_notify_event_t *>(event);
if (pn->atom == atom(QXcbAtom::_NET_WORKAREA)) {
QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(pn->window);
if (virtualDesktop)
@@ -1239,7 +1239,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
if (!handled) {
if (response_type == xfixes_first_event + XCB_XFIXES_SELECTION_NOTIFY) {
- xcb_xfixes_selection_notify_event_t *notify_event = (xcb_xfixes_selection_notify_event_t *)event;
+ xcb_xfixes_selection_notify_event_t *notify_event = reinterpret_cast<xcb_xfixes_selection_notify_event_t *>(event);
setTime(notify_event->timestamp);
#ifndef QT_NO_CLIPBOARD
m_clipboard->handleXFixesSelectionRequest(notify_event);
@@ -1249,10 +1249,10 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
handled = true;
} else if (has_randr_extension && response_type == xrandr_first_event + XCB_RANDR_NOTIFY) {
- updateScreens((xcb_randr_notify_event_t *)event);
+ updateScreens(reinterpret_cast<xcb_randr_notify_event_t *>(event));
handled = true;
} else if (has_randr_extension && response_type == xrandr_first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY) {
- xcb_randr_screen_change_notify_event_t *change_event = (xcb_randr_screen_change_notify_event_t *)event;
+ xcb_randr_screen_change_notify_event_t *change_event = reinterpret_cast<xcb_randr_screen_change_notify_event_t *>(event);
for (QXcbScreen *s : qAsConst(m_screens)) {
if (s->root() == change_event->root )
s->handleScreenChange(change_event);
@@ -1361,7 +1361,7 @@ void QXcbEventReader::run()
void QXcbEventReader::addEvent(xcb_generic_event_t *event)
{
if ((event->response_type & ~0x80) == XCB_CLIENT_MESSAGE
- && ((xcb_client_message_event_t *)event)->type == m_connection->atom(QXcbAtom::_QT_CLOSE_CONNECTION))
+ && (reinterpret_cast<xcb_client_message_event_t *>(event))->type == m_connection->atom(QXcbAtom::_QT_CLOSE_CONNECTION))
m_connection = 0;
m_events << event;
}
@@ -1427,7 +1427,7 @@ void QXcbConnection::sendConnectionEvent(QXcbAtom::Atom a, uint id)
event.type = atom(a);
event.data.data32[0] = id;
- Q_XCB_CALL(xcb_send_event(xcb_connection(), false, eventListener, XCB_EVENT_MASK_NO_EVENT, (const char *)&event));
+ Q_XCB_CALL(xcb_send_event(xcb_connection(), false, eventListener, XCB_EVENT_MASK_NO_EVENT, reinterpret_cast<const char *>(&event)));
Q_XCB_CALL(xcb_destroy_window(m_connection, eventListener));
xcb_flush(xcb_connection());
}
@@ -1447,7 +1447,7 @@ namespace
if ((event->response_type & ~0x80) != type) {
return false;
} else {
- xcb_property_notify_event_t *pn = (xcb_property_notify_event_t *)event;
+ xcb_property_notify_event_t *pn = reinterpret_cast<xcb_property_notify_event_t *>(event);
if ((pn->window == window) && (pn->atom == atom))
return true;
}
@@ -1475,7 +1475,7 @@ xcb_timestamp_t QXcbConnection::getTimestamp()
event = checkEvent(checker);
}
- xcb_property_notify_event_t *pn = (xcb_property_notify_event_t *)event;
+ xcb_property_notify_event_t *pn = reinterpret_cast<xcb_property_notify_event_t *>(event);
xcb_timestamp_t timestamp = pn->time;
free(event);
@@ -1499,7 +1499,8 @@ xcb_window_t QXcbConnection::getQtSelectionOwner()
{
if (!m_qtSelectionOwner) {
xcb_screen_t *xcbScreen = primaryVirtualDesktop()->screen();
- int x = 0, y = 0, w = 3, h = 3;
+ int16_t x = 0, y = 0;
+ uint16_t w = 3, h = 3;
m_qtSelectionOwner = xcb_generate_id(xcb_connection());
Q_XCB_CALL(xcb_create_window(xcb_connection(),
XCB_COPY_FROM_PARENT, // depth -- same as root
@@ -1688,7 +1689,7 @@ bool QXcbConnection::compressEvent(xcb_generic_event_t *event, int currentIndex,
for (int j = nextIndex; j < eventqueue->size(); ++j) {
xcb_generic_event_t *next = eventqueue->at(j);
if (isValid(next) && next->response_type == XCB_CONFIGURE_NOTIFY
- && ((xcb_configure_notify_event_t *)next)->event == ((xcb_configure_notify_event_t*)event)->event)
+ && reinterpret_cast<xcb_configure_notify_event_t *>(next)->event == reinterpret_cast<xcb_configure_notify_event_t *>(event)->event)
{
return true;
}
@@ -1717,7 +1718,7 @@ void QXcbConnection::processXcbEvents()
(*eventqueue)[i] = 0;
if (!(event->response_type & ~0x80)) {
- handleXcbError((xcb_generic_error_t *)event);
+ handleXcbError(reinterpret_cast<xcb_generic_error_t *>(event));
continue;
}
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index f6ba828a15..c9fc27997b 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -694,7 +694,7 @@ Q_DECLARE_TYPEINFO(QXcbConnection::TabletData, Q_MOVABLE_TYPE);
#endif
#endif
-#define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display()))
+#define DISPLAY_FROM_XCB(object) (reinterpret_cast<Display *>(object->connection()->xlib_display()))
#define CREATE_VISUALINFO_FROM_DEFAULT_VISUALID(object) ((XVisualInfo *)(object->connection()->createVisualInfoForDefaultVisualId()))
template<typename T>
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 1c13f8edc2..c175967054 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -103,6 +103,9 @@
#if defined(Q_OS_MACX)
#include <IOKit/pwr_mgt/IOPMLib.h>
+#include <mach/task.h>
+#include <mach/mach_init.h>
+#include <CoreFoundation/CFPreferences.h>
#endif
#include <vector>
@@ -137,6 +140,40 @@ static bool debuggerPresent()
return pid != 0;
#elif defined(Q_OS_WIN)
return IsDebuggerPresent();
+#elif defined(Q_OS_MACOS)
+ auto equals = [](CFStringRef str1, CFStringRef str2) -> bool {
+ return CFStringCompare(str1, str2, kCFCompareCaseInsensitive) == kCFCompareEqualTo;
+ };
+
+ // Check if there is an exception handler for the process:
+ mach_msg_type_number_t portCount = 0;
+ exception_mask_t masks[EXC_TYPES_COUNT];
+ mach_port_t ports[EXC_TYPES_COUNT];
+ exception_behavior_t behaviors[EXC_TYPES_COUNT];
+ thread_state_flavor_t flavors[EXC_TYPES_COUNT];
+ exception_mask_t mask = EXC_MASK_ALL & ~(EXC_MASK_RESOURCE | EXC_MASK_GUARD);
+ kern_return_t result = task_get_exception_ports(mach_task_self(), mask, masks, &portCount,
+ ports, behaviors, flavors);
+ if (result == KERN_SUCCESS) {
+ for (mach_msg_type_number_t portIndex = 0; portIndex < portCount; ++portIndex) {
+ if (MACH_PORT_VALID(ports[portIndex])) {
+ return true;
+ }
+ }
+ }
+
+ // Ok, no debugger attached. So, let's see if CrashReporter will throw up a dialog. If so, we
+ // leave it to the OS to do the stack trace.
+ CFStringRef crashReporterType = static_cast<CFStringRef>(
+ CFPreferencesCopyAppValue(CFSTR("DialogType"), CFSTR("com.apple.CrashReporter")));
+ if (crashReporterType == nullptr)
+ return true;
+
+ const bool createsStackTrace =
+ !equals(crashReporterType, CFSTR("server")) &&
+ !equals(crashReporterType, CFSTR("none"));
+ CFRelease(crashReporterType);
+ return createsStackTrace;
#else
// TODO
return false;
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index d51f9e98a4..0a61497588 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -28,6 +28,7 @@ SOURCES += \
../../corelib/global/qlogging.cpp \
../../corelib/global/qmalloc.cpp \
../../corelib/global/qnumeric.cpp \
+ ../../corelib/global/qoperatingsystemversion.cpp \
../../corelib/io/qabstractfileengine.cpp \
../../corelib/io/qbuffer.cpp \
../../corelib/io/qdatastream.cpp \
@@ -96,7 +97,8 @@ unix:SOURCES += ../../corelib/io/qfilesystemengine_unix.cpp \
../../corelib/io/qfilesystemiterator_unix.cpp \
../../corelib/io/qfsfileengine_unix.cpp
-win32:SOURCES += ../../corelib/io/qfilesystemengine_win.cpp \
+win32:SOURCES += ../../corelib/global/qoperatingsystemversion_win.cpp \
+ ../../corelib/io/qfilesystemengine_win.cpp \
../../corelib/io/qfilesystemiterator_win.cpp \
../../corelib/io/qfsfileengine_win.cpp \
../../corelib/kernel/qcoreapplication_win.cpp \
@@ -107,6 +109,7 @@ mac {
../../corelib/kernel/qcoreapplication_mac.cpp \
../../corelib/kernel/qcore_mac.cpp
OBJECTIVE_SOURCES += \
+ ../../corelib/global/qoperatingsystemversion_darwin.mm \
../../corelib/kernel/qcore_mac_objc.mm \
../../corelib/kernel/qcore_foundation.mm
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index 11bf8d7937..f5639ffe31 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -1005,22 +1005,20 @@ static void mergeStringLiterals(Symbols *_symbols)
}
}
-QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteArray &relativeTo)
+static QByteArray searchIncludePaths(const QList<Parser::IncludePath> &includepaths,
+ const QByteArray &include)
{
- // #### stringery
QFileInfo fi;
- if (!relativeTo.isEmpty())
- fi.setFile(QFileInfo(QString::fromLocal8Bit(relativeTo.constData())).dir(), QString::fromLocal8Bit(include.constData()));
- for (int j = 0; j < Preprocessor::includes.size() && !fi.exists(); ++j) {
- const IncludePath &p = Preprocessor::includes.at(j);
+ for (int j = 0; j < includepaths.size() && !fi.exists(); ++j) {
+ const Parser::IncludePath &p = includepaths.at(j);
if (p.isFrameworkPath) {
const int slashPos = include.indexOf('/');
if (slashPos == -1)
continue;
fi.setFile(QString::fromLocal8Bit(p.path + '/' + include.left(slashPos) + ".framework/Headers/"),
- QString::fromLocal8Bit(include.mid(slashPos + 1).constData()));
+ QString::fromLocal8Bit(include.mid(slashPos + 1)));
} else {
- fi.setFile(QString::fromLocal8Bit(p.path.constData()), QString::fromLocal8Bit(include.constData()));
+ fi.setFile(QString::fromLocal8Bit(p.path), QString::fromLocal8Bit(include));
}
// try again, maybe there's a file later in the include paths with the same name
// (186067)
@@ -1035,6 +1033,21 @@ QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteAr
return fi.canonicalFilePath().toLocal8Bit();
}
+QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteArray &relativeTo)
+{
+ if (!relativeTo.isEmpty()) {
+ QFileInfo fi;
+ fi.setFile(QFileInfo(QString::fromLocal8Bit(relativeTo)).dir(), QString::fromLocal8Bit(include));
+ if (fi.exists() && !fi.isDir())
+ return fi.canonicalFilePath().toLocal8Bit();
+ }
+
+ auto it = nonlocalIncludePathResolutionCache.find(include);
+ if (it == nonlocalIncludePathResolutionCache.end())
+ it = nonlocalIncludePathResolutionCache.insert(include, searchIncludePaths(includes, include));
+ return it.value();
+}
+
void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed)
{
currentFilenames.push(filename);
diff --git a/src/tools/moc/preprocessor.h b/src/tools/moc/preprocessor.h
index a7eb1a19e1..39f56d6e92 100644
--- a/src/tools/moc/preprocessor.h
+++ b/src/tools/moc/preprocessor.h
@@ -61,6 +61,7 @@ public:
static bool preprocessOnly;
QList<QByteArray> frameworks;
QSet<QByteArray> preprocessedIncludes;
+ QHash<QByteArray, QByteArray> nonlocalIncludePathResolutionCache;
Macros macros;
QByteArray resolveInclude(const QByteArray &filename, const QByteArray &relativeTo);
Symbols preprocessed(const QByteArray &filename, QFile *device);
diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp
index a99d6adf07..dcbe400224 100644
--- a/src/tools/uic/cpp/cppwriteincludes.cpp
+++ b/src/tools/uic/cpp/cppwriteincludes.cpp
@@ -114,8 +114,9 @@ void WriteIncludes::acceptUI(DomUI *node)
TreeWalker::acceptUI(node);
- if (!m_uic->option().includeFile.isEmpty())
- m_globalIncludes.insert(m_uic->option().includeFile, true);
+ const auto includeFile = m_uic->option().includeFile;
+ if (!includeFile.isEmpty())
+ m_globalIncludes.insert(includeFile);
writeHeaders(m_globalIncludes, true);
writeHeaders(m_localIncludes, false);
@@ -272,10 +273,11 @@ void WriteIncludes::insertInclude(const QString &header, bool global)
fprintf(stderr, "%s %s %d\n", Q_FUNC_INFO, qPrintable(header), global);
OrderedSet &includes = global ? m_globalIncludes : m_localIncludes;
- if (includes.contains(header))
+ // Insert (if not already done).
+ const bool isNewHeader = includes.insert(header).second;
+ if (!isNewHeader)
return;
- // Insert. Also remember base name for quick check of suspicious custom plugins
- includes.insert(header, false);
+ // Also remember base name for quick check of suspicious custom plugins
const QString lowerBaseName = QFileInfo(header).completeBaseName ().toLower();
m_includeBaseNames.insert(lowerBaseName);
}
@@ -286,13 +288,11 @@ void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global)
const QChar closingQuote = global ? QLatin1Char('>') : QLatin1Char('"');
// Check for the old headers 'qslider.h' and replace by 'QtGui/QSlider'
- const OrderedSet::const_iterator cend = headers.constEnd();
- for (OrderedSet::const_iterator sit = headers.constBegin(); sit != cend; ++sit) {
- const StringMap::const_iterator hit = m_oldHeaderToNewHeader.constFind(sit.key());
- const bool mapped = hit != m_oldHeaderToNewHeader.constEnd();
- const QString header = mapped ? hit.value() : sit.key();
- if (!QStringRef(&header).trimmed().isEmpty())
- m_output << "#include " << openingQuote << header << closingQuote << QLatin1Char('\n');
+ for (const QString &header : headers) {
+ const QString value = m_oldHeaderToNewHeader.value(header, header);
+ const auto trimmed = QStringRef(&value).trimmed();
+ if (!trimmed.isEmpty())
+ m_output << "#include " << openingQuote << trimmed << closingQuote << QLatin1Char('\n');
}
}
diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h
index 397c6a26e1..7a6a499536 100644
--- a/src/tools/uic/cpp/cppwriteincludes.h
+++ b/src/tools/uic/cpp/cppwriteincludes.h
@@ -35,6 +35,8 @@
#include <qset.h>
#include <qstring.h>
+#include <set>
+
QT_BEGIN_NAMESPACE
class QTextStream;
@@ -72,7 +74,7 @@ private:
void add(const QString &className, bool determineHeader = true, const QString &header = QString(), bool global = false);
private:
- typedef QMap<QString, bool> OrderedSet;
+ typedef std::set<QString> OrderedSet;
void insertIncludeForClass(const QString &className, QString header = QString(), bool global = false);
void insertInclude(const QString &header, bool global);
void writeHeaders(const OrderedSet &headers, bool global);
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp
index e6fda103fb..bd9f0c6e01 100644
--- a/src/widgets/accessible/simplewidgets.cpp
+++ b/src/widgets/accessible/simplewidgets.cpp
@@ -468,21 +468,15 @@ QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >
QAccessibleDisplay::relations(QAccessible::Relation match /* = QAccessible::AllRelations */) const
{
QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > rels = QAccessibleWidget::relations(match);
- if (match & QAccessible::Labelled) {
- QVarLengthArray<QObject *, 4> relatedObjects;
-
#ifndef QT_NO_SHORTCUT
+ if (match & QAccessible::Labelled) {
if (QLabel *label = qobject_cast<QLabel*>(object())) {
- relatedObjects.append(label->buddy());
- }
-#endif
- for (int i = 0; i < relatedObjects.count(); ++i) {
const QAccessible::Relation rel = QAccessible::Labelled;
- QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(relatedObjects.at(i));
- if (iface)
+ if (QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(label->buddy()))
rels.append(qMakePair(iface, rel));
}
}
+#endif
return rels;
}
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index 6df020dd58..08c5a40c7c 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -65,6 +65,18 @@ Q_AUTOTEST_EXPORT bool qt_test_isFetchedRoot()
}
#endif
+static QString translateDriveName(const QFileInfo &drive)
+{
+ QString driveName = drive.absoluteFilePath();
+#ifdef Q_OS_WIN
+ if (driveName.startsWith(QLatin1Char('/'))) // UNC host
+ return drive.fileName();
+ if (driveName.endsWith(QLatin1Char('/')))
+ driveName.chop(1);
+#endif // Q_OS_WIN
+ return driveName;
+}
+
/*!
Creates thread
*/
@@ -82,6 +94,16 @@ QFileInfoGatherer::QFileInfoGatherer(QObject *parent)
watcher = new QFileSystemWatcher(this);
connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString)));
connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));
+
+# if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+ const QVariant listener = watcher->property("_q_driveListener");
+ if (listener.canConvert<QObject *>()) {
+ if (QObject *driveListener = listener.value<QObject *>()) {
+ connect(driveListener, SIGNAL(driveAdded()), this, SLOT(driveAdded()));
+ connect(driveListener, SIGNAL(driveRemoved(QString)), this, SLOT(driveRemoved()));
+ }
+ }
+# endif // Q_OS_WIN && !Q_OS_WINRT
#endif
start(LowPriority);
}
@@ -106,6 +128,20 @@ void QFileInfoGatherer::setResolveSymlinks(bool enable)
#endif
}
+void QFileInfoGatherer::driveAdded()
+{
+ fetchExtendedInformation(QString(), QStringList());
+}
+
+void QFileInfoGatherer::driveRemoved()
+{
+ QStringList drives;
+ const QFileInfoList driveInfoList = QDir::drives();
+ for (const QFileInfo &fi : driveInfoList)
+ drives.append(translateDriveName(fi));
+ newListOfFiles(QString(), drives);
+}
+
bool QFileInfoGatherer::resolveSymlinks() const
{
#ifdef Q_OS_WIN
@@ -260,18 +296,6 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
return info;
}
-static QString translateDriveName(const QFileInfo &drive)
-{
- QString driveName = drive.absoluteFilePath();
-#if defined(Q_OS_WIN)
- if (driveName.startsWith(QLatin1Char('/'))) // UNC host
- return drive.fileName();
- if (driveName.endsWith(QLatin1Char('/')))
- driveName.chop(1);
-#endif
- return driveName;
-}
-
/*
Get specific file info's, batch the files so update when we have 100
items and every 200ms after that
diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h
index 3186e9d015..0018b6c387 100644
--- a/src/widgets/dialogs/qfileinfogatherer_p.h
+++ b/src/widgets/dialogs/qfileinfogatherer_p.h
@@ -180,6 +180,10 @@ public Q_SLOTS:
void setResolveSymlinks(bool enable);
void setIconProvider(QFileIconProvider *provider);
+private Q_SLOTS:
+ void driveAdded();
+ void driveRemoved();
+
private:
void run() Q_DECL_OVERRIDE;
// called by run():
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index 9d8e7c4b66..1a38f43d35 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -46,6 +46,7 @@
#include "qwizard.h"
#include "qpaintengine.h"
#include "qapplication.h"
+#include <QtCore/QOperatingSystemVersion>
#include <QtCore/QVariant>
#include <QtCore/QDebug>
#include <QtGui/QMouseEvent>
@@ -715,7 +716,7 @@ int QVistaHelper::topOffset()
if (vistaState() != VistaAero)
return titleBarSize() + 3;
static const int aeroOffset =
- QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS7 ?
+ QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8 ?
QStyleHelper::dpiScaled(4) : QStyleHelper::dpiScaled(13);
return aeroOffset + titleBarSize();
}
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index 6e10d18e11..6a9036997c 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -2575,10 +2575,12 @@ void QGraphicsAnchorLayoutPrivate::identifyFloatItems(const QSet<AnchorData *> &
for (const AnchorData *ad : visited)
identifyNonFloatItems_helper(ad, &nonFloating);
- QSet<QGraphicsLayoutItem *> allItems;
- foreach (QGraphicsLayoutItem *item, items)
- allItems.insert(item);
- m_floatItems[orientation] = allItems - nonFloating;
+ QSet<QGraphicsLayoutItem *> floatItems;
+ for (QGraphicsLayoutItem *item : qAsConst(items)) {
+ if (!nonFloating.contains(item))
+ floatItems.insert(item);
+ }
+ m_floatItems[orientation] = std::move(floatItems);
}
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 0788e0287a..d19e5d9a9f 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -2335,13 +2335,7 @@ void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)
bool QListModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)
{
doStaticLayout(info);
- if (batchStartRow > max) { // stop items layout
- flowPositions.resize(flowPositions.count());
- segmentPositions.resize(segmentPositions.count());
- segmentStartRows.resize(segmentStartRows.count());
- return true; // done
- }
- return false; // not done
+ return batchStartRow > max; // returning true stops items layout
}
QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) const
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 3bef773187..2a7859b056 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -91,12 +91,6 @@ extern Q_GUI_EXPORT bool qt_is_gui_used;
extern QClipboard *qt_clipboard;
#endif
-#if defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN)
-extern QSysInfo::WinVersion qt_winver;
-#elif defined (Q_OS_MAC)
-extern QSysInfo::MacVersion qt_macver;
-#endif
-
typedef QHash<QByteArray, QFont> FontHash;
FontHash *qt_app_fonts_hash();
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 007ce20175..2d1de790c4 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -84,6 +84,7 @@
#include <qtoolbutton.h>
#include <qtreeview.h>
#include <qtableview.h>
+#include <qoperatingsystemversion.h>
#include <qwizard.h>
#include <qdebug.h>
#include <qlibrary.h>
@@ -1312,7 +1313,7 @@ void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThem
bdi->adornment = kThemeAdornmentFocus;
if (combo->activeSubControls & QStyle::SC_ComboBoxArrow)
bdi->state = kThemeStatePressed;
- else if (tds == kThemeStateInactive && QSysInfo::MacintoshVersion < QSysInfo::MV_10_10)
+ else if (tds == kThemeStateInactive && QOperatingSystemVersion::current() < QOperatingSystemVersion::OSXYosemite)
bdi->state = kThemeStateActive;
else
bdi->state = tds;
@@ -1634,7 +1635,7 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti
|| slider->tickPosition == QSlider::TicksBothSides;
tdi->bounds = qt_hirectForQRect(slider->rect);
- if (isScrollbar || QSysInfo::MacintoshVersion < QSysInfo::MV_10_10) {
+ if (isScrollbar || QOperatingSystemVersion::current() < QOperatingSystemVersion::OSXYosemite) {
tdi->min = slider->minimum;
tdi->max = slider->maximum;
tdi->value = slider->sliderPosition;
@@ -1946,7 +1947,7 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
const bool button = opt->type == QStyleOption::SO_Button;
const bool viewItem = opt->type == QStyleOption::SO_ViewItem;
const bool pressed = bdi->state == kThemeStatePressed;
- const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10;
+ const bool usingYosemiteOrLater = QOperatingSystemVersion::current() >= QOperatingSystemVersion::OSXYosemite;
if (button && pressed) {
if (bdi->kind == kThemePushButton) {
@@ -3581,7 +3582,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
QWindow *window = w && w->window() ? w->window()->windowHandle() :
QStyleHelper::styleObjectWindow(opt->styleObject);
const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window);
- const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10;
+ const bool usingYosemiteOrLater = QOperatingSystemVersion::current() >= QOperatingSystemVersion::OSXYosemite;
switch (ce) {
case CE_HeaderSection:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
@@ -3973,7 +3974,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
bool hasIcon = !btn.icon.isNull();
bool hasText = !btn.text.isEmpty();
- if (!hasMenu && QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10) {
+ if (!hasMenu && QOperatingSystemVersion::current() >= QOperatingSystemVersion::OSXYosemite) {
if (tds == kThemeStatePressed
|| (tds == kThemeStateActive
&& ((btn.features & QStyleOptionButton::DefaultButton && !d->autoDefaultButton)
@@ -4078,8 +4079,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
QStyleOptionComboBox comboCopy = *cb;
comboCopy.direction = Qt::LeftToRight;
if (opt->state & QStyle::State_Small)
- comboCopy.rect.translate(0, w ? 0 : (QSysInfo::macVersion() >= QSysInfo::MV_10_10 ? 0 : -2)); // Supports Qt Quick Controls
- else if (QSysInfo::macVersion() == QSysInfo::MV_10_9)
+ comboCopy.rect.translate(0, w ? 0 : (QOperatingSystemVersion::current() >= QOperatingSystemVersion::OSXYosemite ? 0 : -2)); // Supports Qt Quick Controls
+ else if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::OSXMavericks
+ && QOperatingSystemVersion::current() < QOperatingSystemVersion::OSXYosemite)
comboCopy.rect.translate(0, 1);
QCommonStyle::drawControl(CE_ComboBoxLabel, &comboCopy, p, w);
}
@@ -5287,7 +5289,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
QWindow *window = widget && widget->window() ? widget->window()->windowHandle() :
QStyleHelper::styleObjectWindow(opt->styleObject);
const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window);
- const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10;
+ const bool usingYosemiteOrLater = QOperatingSystemVersion::current() >= QOperatingSystemVersion::OSXYosemite;
switch (cc) {
case CC_Slider:
case CC_ScrollBar:
@@ -5931,7 +5933,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
drawToolbarButtonArrow(tb->rect, tds, cg);
}
if (tb->state & State_On) {
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10) {
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::OSXYosemite) {
QWindow *window = 0;
if (widget && widget->window())
window = widget->window()->windowHandle();
@@ -6295,7 +6297,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
switch (sc) {
case SC_ComboBoxEditField:{
ret = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10)
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::OSXYosemite)
ret.setHeight(ret.height() - 1);
break; }
case SC_ComboBoxArrow:{
@@ -6754,7 +6756,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_ComboBox: {
sz.rwidth() += 50;
const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt);
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_10 || (cb && !cb->editable))
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion::OSXYosemite || (cb && !cb->editable))
sz.rheight() += 2;
break;
}
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index bf5aad0187..8c91e3a420 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -39,6 +39,7 @@
#include "qwindowsvistastyle_p.h"
#include "qwindowsvistastyle_p_p.h"
+#include <qoperatingsystemversion.h>
#include <qscreen.h>
#include <qwindow.h>
#include <private/qstyleanimation_p.h>
@@ -1752,7 +1753,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
theme.stateId = stateId;
d->drawBackground(theme);
- if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8) {
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8) {
const QRect gripperBounds = QWindowsXPStylePrivate::scrollBarGripperBounds(flags, widget, &theme);
// Draw gripper if there is enough space
if (!gripperBounds.isEmpty() && flags & State_Enabled) {
diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp
index 224ffeb6e2..64daad87ae 100644
--- a/src/widgets/util/qsystemtrayicon.cpp
+++ b/src/widgets/util/qsystemtrayicon.cpp
@@ -59,6 +59,25 @@
QT_BEGIN_NAMESPACE
+static QIcon messageIcon2qIcon(QSystemTrayIcon::MessageIcon icon)
+{
+ QStyle::StandardPixmap stdIcon = QStyle::SP_CustomBase; // silence gcc 4.9.0 about uninited variable
+ switch (icon) {
+ case QSystemTrayIcon::Information:
+ stdIcon = QStyle::SP_MessageBoxInformation;
+ break;
+ case QSystemTrayIcon::Warning:
+ stdIcon = QStyle::SP_MessageBoxWarning;
+ break;
+ case QSystemTrayIcon::Critical:
+ stdIcon = QStyle::SP_MessageBoxCritical;
+ break;
+ case QSystemTrayIcon::NoIcon:
+ return QIcon();
+ }
+ return QApplication::style()->standardIcon(stdIcon);
+}
+
/*!
\class QSystemTrayIcon
\brief The QSystemTrayIcon class provides an icon for an application in the system tray.
@@ -382,11 +401,29 @@ bool QSystemTrayIcon::supportsMessages()
\sa show(), supportsMessages()
*/
void QSystemTrayIcon::showMessage(const QString& title, const QString& msg,
- QSystemTrayIcon::MessageIcon icon, int msecs)
+ QSystemTrayIcon::MessageIcon msgIcon, int msecs)
{
Q_D(QSystemTrayIcon);
if (d->visible)
- d->showMessage_sys(title, msg, icon, msecs);
+ d->showMessage_sys(title, msg, messageIcon2qIcon(msgIcon), msgIcon, msecs);
+}
+
+/*!
+ \fn void QSystemTrayIcon::showMessage(const QString &title, const QString &message, const QIcon &icon, int millisecondsTimeoutHint)
+
+ \overload showMessage()
+
+ Shows a balloon message for the entry with the given \a title, \a message,
+ and custom icon \a icon for the time specified in \a millisecondsTimeoutHint.
+
+ \since 5.9
+*/
+void QSystemTrayIcon::showMessage(const QString &title, const QString &msg,
+ const QIcon &icon, int msecs)
+{
+ Q_D(QSystemTrayIcon);
+ if (d->visible)
+ d->showMessage_sys(title, msg, icon, QSystemTrayIcon::NoIcon, msecs);
}
void QSystemTrayIconPrivate::_q_emitActivated(QPlatformSystemTrayIcon::ActivationReason reason)
@@ -398,9 +435,9 @@ void QSystemTrayIconPrivate::_q_emitActivated(QPlatformSystemTrayIcon::Activatio
//////////////////////////////////////////////////////////////////////
static QBalloonTip *theSolitaryBalloonTip = 0;
-void QBalloonTip::showBalloon(QSystemTrayIcon::MessageIcon icon, const QString& title,
- const QString& message, QSystemTrayIcon *trayIcon,
- const QPoint& pos, int timeout, bool showArrow)
+void QBalloonTip::showBalloon(const QIcon &icon, const QString &title,
+ const QString &message, QSystemTrayIcon *trayIcon,
+ const QPoint &pos, int timeout, bool showArrow)
{
hideBalloon();
if (message.isEmpty() && title.isEmpty())
@@ -434,8 +471,8 @@ bool QBalloonTip::isBalloonVisible()
return theSolitaryBalloonTip;
}
-QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title,
- const QString& message, QSystemTrayIcon *ti)
+QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
+ const QString &message, QSystemTrayIcon *ti)
: QWidget(0, Qt::ToolTip), trayIcon(ti), timerId(-1)
{
setAttribute(Qt::WA_DeleteOnClose);
@@ -482,26 +519,10 @@ QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title
msgLabel->setFixedSize(limit, msgLabel->heightForWidth(limit));
}
- QIcon si;
- switch (icon) {
- case QSystemTrayIcon::Warning:
- si = style()->standardIcon(QStyle::SP_MessageBoxWarning);
- break;
- case QSystemTrayIcon::Critical:
- si = style()->standardIcon(QStyle::SP_MessageBoxCritical);
- break;
- case QSystemTrayIcon::Information:
- si = style()->standardIcon(QStyle::SP_MessageBoxInformation);
- break;
- case QSystemTrayIcon::NoIcon:
- default:
- break;
- }
-
QGridLayout *layout = new QGridLayout;
- if (!si.isNull()) {
+ if (!icon.isNull()) {
QLabel *iconLabel = new QLabel;
- iconLabel->setPixmap(si.pixmap(iconSize, iconSize));
+ iconLabel->setPixmap(icon.pixmap(iconSize, iconSize));
iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
iconLabel->setMargin(2);
layout->addWidget(iconLabel, 0, 0);
@@ -678,52 +699,6 @@ void QSystemTrayIconPrivate::remove_sys_qpa()
qpa_sys->cleanup();
}
-QRect QSystemTrayIconPrivate::geometry_sys_qpa() const
-{
- return qpa_sys->geometry();
-}
-
-void QSystemTrayIconPrivate::updateIcon_sys_qpa()
-{
- qpa_sys->updateIcon(icon);
-}
-
-void QSystemTrayIconPrivate::updateMenu_sys_qpa()
-{
- if (menu) {
- addPlatformMenu(menu);
- qpa_sys->updateMenu(menu->platformMenu());
- }
-}
-
-void QSystemTrayIconPrivate::updateToolTip_sys_qpa()
-{
- qpa_sys->updateToolTip(toolTip);
-}
-
-void QSystemTrayIconPrivate::showMessage_sys_qpa(const QString &title,
- const QString &message,
- QSystemTrayIcon::MessageIcon icon,
- int msecs)
-{
- QIcon notificationIcon;
- switch (icon) {
- case QSystemTrayIcon::Information:
- notificationIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation);
- break;
- case QSystemTrayIcon::Warning:
- notificationIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning);
- break;
- case QSystemTrayIcon::Critical:
- notificationIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
- break;
- default:
- break;
- }
- qpa_sys->showMessage(title, message, notificationIcon,
- static_cast<QPlatformSystemTrayIcon::MessageIcon>(icon), msecs);
-}
-
void QSystemTrayIconPrivate::addPlatformMenu(QMenu *menu) const
{
if (menu->platformMenu())
diff --git a/src/widgets/util/qsystemtrayicon.h b/src/widgets/util/qsystemtrayicon.h
index fb238c92b0..918dd0478e 100644
--- a/src/widgets/util/qsystemtrayicon.h
+++ b/src/widgets/util/qsystemtrayicon.h
@@ -101,6 +101,7 @@ public Q_SLOTS:
void setVisible(bool visible);
inline void show() { setVisible(true); }
inline void hide() { setVisible(false); }
+ void showMessage(const QString &title, const QString &msg, const QIcon &icon, int msecs = 10000);
void showMessage(const QString &title, const QString &msg,
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int msecs = 10000);
diff --git a/src/widgets/util/qsystemtrayicon_p.h b/src/widgets/util/qsystemtrayicon_p.h
index 79e824f4b7..3f5cab40be 100644
--- a/src/widgets/util/qsystemtrayicon_p.h
+++ b/src/widgets/util/qsystemtrayicon_p.h
@@ -84,7 +84,8 @@ public:
void updateToolTip_sys();
void updateMenu_sys();
QRect geometry_sys() const;
- void showMessage_sys(const QString &title, const QString &msg, QSystemTrayIcon::MessageIcon icon, int secs);
+ void showMessage_sys(const QString &title, const QString &msg, const QIcon &icon,
+ QSystemTrayIcon::MessageIcon msgIcon, int msecs);
static bool isSystemTrayAvailable_sys();
static bool supportsMessages_sys();
@@ -101,11 +102,7 @@ public:
private:
void install_sys_qpa();
void remove_sys_qpa();
- void updateIcon_sys_qpa();
- void updateToolTip_sys_qpa();
- void updateMenu_sys_qpa();
- QRect geometry_sys_qpa() const;
- void showMessage_sys_qpa(const QString &title, const QString &msg, QSystemTrayIcon::MessageIcon icon, int secs);
+
void addPlatformMenu(QMenu *menu) const;
};
@@ -113,16 +110,16 @@ class QBalloonTip : public QWidget
{
Q_OBJECT
public:
- static void showBalloon(QSystemTrayIcon::MessageIcon icon, const QString& title,
- const QString& msg, QSystemTrayIcon *trayIcon,
- const QPoint& pos, int timeout, bool showArrow = true);
+ static void showBalloon(const QIcon &icon, const QString &title,
+ const QString &msg, QSystemTrayIcon *trayIcon,
+ const QPoint &pos, int timeout, bool showArrow = true);
static void hideBalloon();
static bool isBalloonVisible();
static void updateBalloonPosition(const QPoint& pos);
private:
- QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title,
- const QString& msg, QSystemTrayIcon *trayIcon);
+ QBalloonTip(const QIcon &icon, const QString &title,
+ const QString &msg, QSystemTrayIcon *trayIcon);
~QBalloonTip();
void balloon(const QPoint&, int, bool);
diff --git a/src/widgets/util/qsystemtrayicon_qpa.cpp b/src/widgets/util/qsystemtrayicon_qpa.cpp
index 643f17a5fe..8399732a4a 100644
--- a/src/widgets/util/qsystemtrayicon_qpa.cpp
+++ b/src/widgets/util/qsystemtrayicon_qpa.cpp
@@ -76,7 +76,7 @@ void QSystemTrayIconPrivate::remove_sys()
QRect QSystemTrayIconPrivate::geometry_sys() const
{
if (qpa_sys)
- return geometry_sys_qpa();
+ return qpa_sys->geometry();
else
return QRect();
}
@@ -84,19 +84,21 @@ QRect QSystemTrayIconPrivate::geometry_sys() const
void QSystemTrayIconPrivate::updateIcon_sys()
{
if (qpa_sys)
- updateIcon_sys_qpa();
+ qpa_sys->updateIcon(icon);
}
void QSystemTrayIconPrivate::updateMenu_sys()
{
- if (qpa_sys)
- updateMenu_sys_qpa();
+ if (qpa_sys && menu) {
+ addPlatformMenu(menu);
+ qpa_sys->updateMenu(menu->platformMenu());
+ }
}
void QSystemTrayIconPrivate::updateToolTip_sys()
{
if (qpa_sys)
- updateToolTip_sys_qpa();
+ qpa_sys->updateToolTip(toolTip);
}
bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys()
@@ -118,10 +120,11 @@ bool QSystemTrayIconPrivate::supportsMessages_sys()
}
void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message,
- QSystemTrayIcon::MessageIcon icon, int msecs)
+ const QIcon &icon, QSystemTrayIcon::MessageIcon msgIcon, int msecs)
{
if (qpa_sys)
- showMessage_sys_qpa(title, message, icon, msecs);
+ qpa_sys->showMessage(title, message, icon,
+ static_cast<QPlatformSystemTrayIcon::MessageIcon>(msgIcon), msecs);
}
QT_END_NAMESPACE
diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp
index 2da24e482b..638d2050fb 100644
--- a/src/widgets/util/qsystemtrayicon_win.cpp
+++ b/src/widgets/util/qsystemtrayicon_win.cpp
@@ -81,11 +81,14 @@ struct Q_NOTIFYICONIDENTIFIER {
# define NIN_BALLOONTIMEOUT (WM_USER + 4)
# define NIN_BALLOONUSERCLICK (WM_USER + 5)
# define NIF_SHOWTIP 0x00000080
+# define NIIF_LARGE_ICON 0x00000020
# define NOTIFYICON_VERSION_4 4
#endif
#define Q_MSGFLT_ALLOW 1
+Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
+
typedef HRESULT (WINAPI *PtrShell_NotifyIconGetRect)(const Q_NOTIFYICONIDENTIFIER* identifier, RECT* iconLocation);
typedef BOOL (WINAPI *PtrChangeWindowMessageFilter)(UINT message, DWORD dwFlag);
typedef BOOL (WINAPI *PtrChangeWindowMessageFilterEx)(HWND hWnd, UINT message, DWORD action, void* pChangeFilterStruct);
@@ -107,7 +110,7 @@ public:
~QSystemTrayIconSys();
bool trayMessage(DWORD msg);
void setIconContents(NOTIFYICONDATA &data);
- bool showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs);
+ bool showMessage(const QString &title, const QString &message, const QIcon &icon, uint uSecs);
QRect findIconGeometry(UINT iconId);
HICON createIcon();
bool winEvent(MSG *m, long *result);
@@ -184,7 +187,7 @@ static inline HWND createTrayIconMessageWindow()
QSystemTrayIconSys::QSystemTrayIconSys(HWND hwnd, QSystemTrayIcon *object)
: m_hwnd(hwnd), hIcon(0), q(object)
- , notifyIconSize(NOTIFYICONDATA_V2_SIZE), version(NOTIFYICON_VERSION)
+ , notifyIconSize(sizeof(NOTIFYICONDATA)), version(NOTIFYICON_VERSION_4)
, ignoreNextMouseRelease(false)
{
@@ -237,11 +240,7 @@ void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd)
qStringToLimitedWCharArray(tip, tnd.szTip, sizeof(tnd.szTip)/sizeof(wchar_t));
}
-#ifndef NIIF_LARGE_ICON
-# define NIIF_LARGE_ICON 0x00000020
-#endif
-
-bool QSystemTrayIconSys::showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs)
+bool QSystemTrayIconSys::showMessage(const QString &title, const QString &message, const QIcon &icon, uint uSecs)
{
NOTIFYICONDATA tnd;
memset(&tnd, 0, notifyIconSize);
@@ -249,23 +248,32 @@ bool QSystemTrayIconSys::showMessage(const QString &title, const QString &messag
qStringToLimitedWCharArray(title, tnd.szInfoTitle, 64);
tnd.uID = q_uNOTIFYICONID;
- switch (type) {
- case QSystemTrayIcon::Information:
+ tnd.dwInfoFlags = NIIF_USER;
+
+ HICON *phIcon = &tnd.hIcon;
+ QSize size(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
+ if (version == NOTIFYICON_VERSION_4) {
+ const QSize largeIcon(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
+ QSize more = icon.actualSize(largeIcon);
+ if (more.height() > (largeIcon.height() * 3/4) || more.width() > (largeIcon.width() * 3/4)) {
+ tnd.dwInfoFlags |= NIIF_LARGE_ICON;
+ size = largeIcon;
+ }
+ phIcon = &tnd.hBalloonIcon;
+ }
+ QPixmap pm = icon.pixmap(size);
+ if (pm.isNull()) {
tnd.dwInfoFlags = NIIF_INFO;
- break;
- case QSystemTrayIcon::Warning:
- tnd.dwInfoFlags = NIIF_WARNING;
- break;
- case QSystemTrayIcon::Critical:
- tnd.dwInfoFlags = NIIF_ERROR;
- break;
- case QSystemTrayIcon::NoIcon:
- tnd.dwInfoFlags = hIcon ? NIIF_USER : NIIF_NONE;
- break;
+ } else {
+ if (pm.size() != size) {
+ qWarning("QSystemTrayIcon::showMessage: Wrong icon size (%dx%d), please add standard one: %dx%d",
+ pm.size().width(), pm.size().height(), size.width(), size.height());
+ pm = pm.scaled(size, Qt::IgnoreAspectRatio);
+ }
+ *phIcon = qt_pixmapToWinHICON(pm);
}
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
- tnd.dwInfoFlags |= NIIF_LARGE_ICON;
tnd.cbSize = notifyIconSize;
+ tnd.uVersion = version;
tnd.hWnd = m_hwnd;
tnd.uTimeout = uSecs;
tnd.uFlags = NIF_INFO | NIF_SHOWTIP;
@@ -296,8 +304,6 @@ bool QSystemTrayIconSys::trayMessage(DWORD msg)
return success;
}
-Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
-
HICON QSystemTrayIconSys::createIcon()
{
const HICON oldIcon = hIcon;
@@ -509,7 +515,8 @@ QRect QSystemTrayIconSys::findIconGeometry(UINT iconId)
void QSystemTrayIconPrivate::showMessage_sys(const QString &title,
const QString &messageIn,
- QSystemTrayIcon::MessageIcon type,
+ const QIcon &icon,
+ QSystemTrayIcon::MessageIcon,
int timeOut)
{
if (!sys || !allowsMessages())
@@ -522,7 +529,7 @@ void QSystemTrayIconPrivate::showMessage_sys(const QString &title,
if (message.isEmpty() && !title.isEmpty())
message.append(QLatin1Char(' '));
- sys->showMessage(title, message, type, uSecs);
+ sys->showMessage(title, message, icon, uSecs);
}
QRect QSystemTrayIconPrivate::geometry_sys() const
diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp
index ea0604b6ed..20ab0f6377 100644
--- a/src/widgets/util/qsystemtrayicon_x11.cpp
+++ b/src/widgets/util/qsystemtrayicon_x11.cpp
@@ -284,7 +284,7 @@ void QSystemTrayIconPrivate::install_sys()
QRect QSystemTrayIconPrivate::geometry_sys() const
{
if (qpa_sys)
- return geometry_sys_qpa();
+ return qpa_sys->geometry();
if (!sys)
return QRect();
return sys->globalGeometry();
@@ -307,7 +307,7 @@ void QSystemTrayIconPrivate::remove_sys()
void QSystemTrayIconPrivate::updateIcon_sys()
{
if (qpa_sys) {
- updateIcon_sys_qpa();
+ qpa_sys->updateIcon(icon);
return;
}
if (sys)
@@ -316,14 +316,16 @@ void QSystemTrayIconPrivate::updateIcon_sys()
void QSystemTrayIconPrivate::updateMenu_sys()
{
- if (qpa_sys)
- updateMenu_sys_qpa();
+ if (qpa_sys && menu) {
+ addPlatformMenu(menu);
+ qpa_sys->updateMenu(menu->platformMenu());
+ }
}
void QSystemTrayIconPrivate::updateToolTip_sys()
{
if (qpa_sys) {
- updateToolTip_sys_qpa();
+ qpa_sys->updateToolTip(toolTip);
return;
}
if (!sys)
@@ -357,10 +359,11 @@ bool QSystemTrayIconPrivate::supportsMessages_sys()
}
void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message,
- QSystemTrayIcon::MessageIcon icon, int msecs)
+ const QIcon &icon, QSystemTrayIcon::MessageIcon msgIcon, int msecs)
{
if (qpa_sys) {
- showMessage_sys_qpa(title, message, icon, msecs);
+ qpa_sys->showMessage(title, message, icon,
+ static_cast<QPlatformSystemTrayIcon::MessageIcon>(msgIcon), msecs);
return;
}
if (!sys)
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 63fe09f77e..6b0c2fd621 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -1492,6 +1492,7 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event)
case QEvent::FocusIn:
case QEvent::FocusOut:
case QEvent::ActivationChange:
+ case QEvent::Shortcut:
d->altPressed = false;
qApp->removeEventFilter(this);
break;
diff --git a/sync.profile b/sync.profile
index ef2779ae48..add6766c49 100644
--- a/sync.profile
+++ b/sync.profile
@@ -25,6 +25,7 @@
"QtEglSupport" => "$basedir/src/platformsupport/eglconvenience",
"QtFbSupport" => "$basedir/src/platformsupport/fbconvenience",
"QtGlxSupport" => "$basedir/src/platformsupport/glxconvenience",
+ "QtKmsSupport" => "$basedir/src/platformsupport/kmsconvenience",
"QtPlatformHeaders" => "$basedir/src/platformheaders",
"QtANGLE/KHR" => "!$basedir/src/3rdparty/angle/include/KHR",
"QtANGLE/GLES2" => "!$basedir/src/3rdparty/angle/include/GLES2",
diff --git a/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro b/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro
index 056d940da7..21bb040b8d 100644
--- a/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro
+++ b/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro
@@ -5,7 +5,6 @@ QT -= gui
TARGET = tst_qglobalstatic
CONFIG += console
-CONFIG -= app_bundle
CONFIG += exceptions
SOURCES += tst_qglobalstatic.cpp
diff --git a/tests/auto/corelib/global/qlogging/test/test.pro b/tests/auto/corelib/global/qlogging/test/test.pro
index 93eee7307a..7c46ae9d16 100644
--- a/tests/auto/corelib/global/qlogging/test/test.pro
+++ b/tests/auto/corelib/global/qlogging/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
qtConfig(c++11): CONFIG += c++11
qtConfig(c++14): CONFIG += c++14
TARGET = ../tst_qlogging
diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro
index c0c4b9d5d2..5f1963cf5f 100644
--- a/tests/auto/corelib/io/qfile/test/test.pro
+++ b/tests/auto/corelib/io/qfile/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core-private core testlib
qtHaveModule(network): QT += network
else: DEFINES += QT_NO_NETWORK
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
index 7b83d5dbe8..7a304fe779 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle
TARGET = tst_qlockfile
SOURCES += tst_qlockfile.cpp
diff --git a/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro b/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
index e46e7e1100..8e46320e0c 100644
--- a/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
+++ b/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
@@ -1,4 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core testlib
SOURCES = tst_qprocessnoapplication.cpp
diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro
index 96d105a4b4..7d6a7973dc 100644
--- a/tests/auto/corelib/io/qprocess/test/test.pro
+++ b/tests/auto/corelib/io/qprocess/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core-private testlib network
SOURCES = ../tst_qprocess.cpp
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index dadf4b612e..fcff13b416 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -183,6 +183,7 @@ private slots:
void embeddedZeroByte_data();
void embeddedZeroByte();
+ void testXdg();
private:
void cleanupTestFiles();
@@ -3557,5 +3558,77 @@ void tst_QSettings::consistentRegistryStorage()
}
#endif
+#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS)
+QT_BEGIN_NAMESPACE
+extern void clearDefaultPaths();
+QT_END_NAMESPACE
+#endif
+void tst_QSettings::testXdg()
+{
+#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS)
+ // Note: The XDG_CONFIG_DIRS test must be done before overriding the system path
+ // by QSettings::setPath/setSystemIniPath (used in cleanupTestFiles()).
+ clearDefaultPaths();
+
+ // Initialize the env. variable & populate testing files.
+ const QStringList config_dirs = { settingsPath("xdg_1st"), settingsPath("xdg_2nd"), settingsPath("xdg_3rd") };
+ qputenv("XDG_CONFIG_DIRS", config_dirs.join(':').toUtf8());
+ QList<QSettings *> xdg_orgs, xdg_apps;
+ for (const auto & dir : config_dirs) {
+ xdg_orgs << new QSettings{dir + "/software.org.conf", QSettings::NativeFormat};
+ xdg_apps << new QSettings{dir + "/software.org/KillerAPP.conf", QSettings::NativeFormat};
+ }
+ Q_ASSERT(config_dirs.size() == 3 && xdg_orgs.size() == 3 && xdg_apps.size() == 3);
+ for (int i = 0; i < 3; ++i) {
+ xdg_orgs[i]->setValue("all", QString{"all_org%1"}.arg(i));
+ xdg_apps[i]->setValue("all", QString{"all_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("all_only_org", QString{"all_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("all_only_app", QString{"all_only_app%1"}.arg(i));
+
+ if (i > 0) {
+ xdg_orgs[i]->setValue("from2nd", QString{"from2nd_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from2nd", QString{"from2nd_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("from2nd_only_org", QString{"from2nd_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from2nd_only_app", QString{"from2nd_only_app%1"}.arg(i));
+ }
+
+ if (i > 1) {
+ xdg_orgs[i]->setValue("from3rd", QString{"from3rd_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from3rd", QString{"from3rd_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("from3rd_only_org", QString{"from3rd_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from3rd_only_app", QString{"from3rd_only_app%1"}.arg(i));
+ }
+ }
+ qDeleteAll(xdg_apps);
+ qDeleteAll(xdg_orgs);
+
+ // Do the test.
+ QSettings app{QSettings::SystemScope, "software.org", "KillerAPP"}, org{QSettings::SystemScope, "software.org"};
+
+ QVERIFY(app.value("all").toString() == "all_app0");
+ QVERIFY(org.value("all").toString() == "all_org0");
+ QVERIFY(app.value("all_only_org").toString() == "all_only_org0");
+ QVERIFY(org.value("all_only_org").toString() == "all_only_org0");
+ QVERIFY(app.value("all_only_app").toString() == "all_only_app0");
+ QVERIFY(org.value("all_only_app").toString() == QString{});
+
+ QVERIFY(app.value("from2nd").toString() == "from2nd_app1");
+ QVERIFY(org.value("from2nd").toString() == "from2nd_org1");
+ QVERIFY(app.value("from2nd_only_org").toString() == "from2nd_only_org1");
+ QVERIFY(org.value("from2nd_only_org").toString() == "from2nd_only_org1");
+ QVERIFY(app.value("from2nd_only_app").toString() == "from2nd_only_app1");
+ QVERIFY(org.value("from2nd_only_app").toString() == QString{});
+
+ QVERIFY(app.value("from3rd").toString() == "from3rd_app2");
+ QVERIFY(org.value("from3rd").toString() == "from3rd_org2");
+ QVERIFY(app.value("from3rd_only_org").toString() == "from3rd_only_org2");
+ QVERIFY(org.value("from3rd_only_org").toString() == "from3rd_only_org2");
+ QVERIFY(app.value("from3rd_only_app").toString() == "from3rd_only_app2");
+ QVERIFY(org.value("from3rd_only_app").toString() == QString{});
+#else
+ QSKIP("This test is performed in QT_BUILD_INTERNAL on Q_XDG_PLATFORM with use of standard paths only.");
+#endif
+}
+
QTEST_MAIN(tst_QSettings)
#include "tst_qsettings.moc"
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 5b18ab9d68..0b536f26de 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -372,7 +372,7 @@ void tst_qstandardpaths::testFindExecutable_data()
QTest::newRow("win-cmd-nosuffix")
<< QString() << QString::fromLatin1("cmd") << cmdPath;
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8) {
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8) {
// The logo executable on Windows 8 is perfectly suited for testing that the
// suffix mechanism is not thrown off by dots in the name.
const QString logo = QLatin1String("microsoft.windows.softwarelogo.showdesktop");
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
index 487c13be94..758bbead84 100644
--- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
+++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
@@ -57,6 +57,8 @@ private slots:
void fileTemplate_data();
void getSetCheck();
void fileName();
+ void filePath_data();
+ void filePath();
void autoRemove();
void nonWritableCurrentDir();
void openOnRootDrives();
@@ -204,6 +206,29 @@ void tst_QTemporaryDir::fileName()
QCOMPARE(absoluteFilePath, absoluteTempPath);
}
+void tst_QTemporaryDir::filePath_data()
+{
+ QTest::addColumn<QString>("templatePath");
+ QTest::addColumn<QString>("fileName");
+
+ QTest::newRow("0") << QString() << "/tmpfile";
+ QTest::newRow("1") << QString() << "tmpfile";
+ QTest::newRow("2") << "XXXXX" << "tmpfile";
+ QTest::newRow("3") << "YYYYY" << "subdir/file";
+}
+
+void tst_QTemporaryDir::filePath()
+{
+ QFETCH(QString, templatePath);
+ QFETCH(QString, fileName);
+
+ QTemporaryDir dir(templatePath);
+ const QString filePath = dir.filePath(fileName);
+ const QString expectedFilePath = QDir::isAbsolutePath(fileName) ?
+ QString() : dir.path() + QLatin1Char('/') + fileName;
+ QCOMPARE(filePath, expectedFilePath);
+}
+
void tst_QTemporaryDir::autoRemove()
{
// Test auto remove
diff --git a/tests/auto/corelib/json/json.pro b/tests/auto/corelib/json/json.pro
index 16c2ae2fb7..8fa17c5c38 100644
--- a/tests/auto/corelib/json/json.pro
+++ b/tests/auto/corelib/json/json.pro
@@ -1,6 +1,5 @@
TARGET = tst_json
QT = core-private testlib
-CONFIG -= app_bundle
CONFIG += testcase
!android:TESTDATA += bom.json test.json test.bjson test3.json test2.json
diff --git a/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro b/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro
index a42cd60236..9dfa29b0fc 100644
--- a/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro
+++ b/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro
@@ -2,4 +2,3 @@ CONFIG += testcase
TARGET = tst_qmetamethod
QT = core testlib
SOURCES = tst_qmetamethod.cpp
-mac:CONFIG -= app_bundle
diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro b/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro
index f3153b3fd4..4da90c1096 100644
--- a/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro
+++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro
@@ -2,4 +2,3 @@ CONFIG += testcase
TARGET = tst_qmetaobjectbuilder
QT = core-private testlib
SOURCES = tst_qmetaobjectbuilder.cpp
-mac:CONFIG -= app_bundle
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 0f7f75fb2e..fea185c48f 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -3401,14 +3401,12 @@ void tst_QObject::dumpObjectInfo()
QObject a, b;
QObject::connect(&a, SIGNAL(destroyed(QObject*)), &b, SLOT(deleteLater()));
a.disconnect(&b);
-#ifdef QT_DEBUG
QTest::ignoreMessage(QtDebugMsg, "OBJECT QObject::unnamed");
QTest::ignoreMessage(QtDebugMsg, " SIGNALS OUT");
QTest::ignoreMessage(QtDebugMsg, " signal: destroyed(QObject*)");
QTest::ignoreMessage(QtDebugMsg, " <Disconnected receiver>");
QTest::ignoreMessage(QtDebugMsg, " SIGNALS IN");
QTest::ignoreMessage(QtDebugMsg, " <None>");
-#endif
a.dumpObjectInfo(); // should not crash
}
diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/test.pro b/tests/auto/corelib/kernel/qsharedmemory/test/test.pro
index fabd2cf7a3..61124c27ee 100644
--- a/tests/auto/corelib/kernel/qsharedmemory/test/test.pro
+++ b/tests/auto/corelib/kernel/qsharedmemory/test/test.pro
@@ -2,7 +2,6 @@ CONFIG += testcase
QT = core-private testlib
-mac:CONFIG -= app_bundle
linux:LIBS += -lrt
SOURCES += tst_qsharedmemory.cpp
diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro b/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro
index a0f63741d3..f60207eb01 100644
--- a/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro
+++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro
@@ -2,7 +2,6 @@ CONFIG += testcase
QT = core testlib
win32: CONFIG += console
-mac:CONFIG -= app_bundle
SOURCES += tst_qsystemsemaphore.cpp
TARGET = tst_qsystemsemaphore
diff --git a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
index 3345651730..9338f4ecc9 100644
--- a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
+++ b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
@@ -17,8 +17,6 @@ win32 {
}
}
-mac: CONFIG -= app_bundle
-
!qtConfig(library) {
LIBS += -L ../bin/ -lplugin1 -lplugin2
}
diff --git a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
index d59cd738bf..6e71ec8ff9 100644
--- a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
+++ b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle
TARGET = ../tst_qlibrary
QT = core testlib
SOURCES = ../tst_qlibrary.cpp
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
index e3d5bff5ff..7f7caa7f76 100644
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
@@ -6,11 +6,16 @@ OTHER_FILES += \
# Needs explicit load()ing due to aux template. Relies on QT being non-empty.
load(qt)
+i386_d.target = good.i386.dylib
+i386_d.depends = EXPORT_VALID_ARCHS=i386
i386.target = good.i386.dylib
-i386.commands = $(CXX) $(CXXFLAGS) -shared -arch i386 -o $@ -I$(INCPATH) $<
+i386.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $<
i386.depends += $$PWD/../fakeplugin.cpp
+
+x86_64_d.target = good.x86_64.dylib
+x86_64_d.depends = EXPORT_VALID_ARCHS=x86_64
x86_64.target = good.x86_64.dylib
-x86_64.commands = $(CXX) $(CXXFLAGS) -shared -arch x86_64 -o $@ -I$(INCPATH) $<
+x86_64.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $<
x86_64.depends += $$PWD/../fakeplugin.cpp
# Current Mac OS X toolchains have no compiler for PPC anymore
@@ -49,7 +54,7 @@ bad.depends += $$PWD/generate-bad.pl
MYTARGETS = $$fat_all.depends fat_all fat_no_x86_64 fat_no_i386 \
fat_stub_i386 fat_stub_x86_64 bad
all.depends += $$MYTARGETS
-QMAKE_EXTRA_TARGETS += $$MYTARGETS all
+QMAKE_EXTRA_TARGETS += i386_d x86_64_d $$MYTARGETS all
QMAKE_CLEAN += $$i386.target $$x86_64.target $$ppc64.target $$fat_all.target \
$$fat_no_i386.target $$fat_no_x86_64.target \
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
index 5f9fa6664b..c20e56ba4c 100644
--- a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
@@ -4,7 +4,6 @@ QT = core testlib
qtConfig(private_tests): QT += core-private
SOURCES = ../tst_qpluginloader.cpp ../fakeplugin.cpp
HEADERS = ../theplugin/plugininterface.h
-CONFIG -= app_bundle
win32 {
CONFIG(debug, debug|release) {
diff --git a/tests/auto/corelib/thread/qthreadstorage/test/test.pro b/tests/auto/corelib/thread/qthreadstorage/test/test.pro
index b9d661a9af..1a1fede186 100644
--- a/tests/auto/corelib/thread/qthreadstorage/test/test.pro
+++ b/tests/auto/corelib/thread/qthreadstorage/test/test.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = ../tst_qthreadstorage
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
CONFIG += console
QT = core testlib
SOURCES = ../tst_qthreadstorage.cpp
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index 0c41f66357..65887e50d3 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -65,6 +65,8 @@ private slots:
void simpleVectorReserve();
void allocate_data();
void allocate();
+ void reallocate_data() { allocate_data(); }
+ void reallocate();
void alignment_data();
void alignment();
void typedData();
@@ -742,6 +744,54 @@ void tst_QArrayData::allocate()
}
}
+void tst_QArrayData::reallocate()
+{
+ QFETCH(size_t, objectSize);
+ QFETCH(size_t, alignment);
+ QFETCH(QArrayData::AllocationOptions, allocateOptions);
+ QFETCH(bool, isCapacityReserved);
+ QFETCH(const QArrayData *, commonEmpty);
+
+ // Maximum alignment that can be requested is that of QArrayData,
+ // otherwise, we can't use reallocate().
+ Q_ASSERT(alignment <= Q_ALIGNOF(QArrayData));
+
+ // Minimum alignment that can be requested is that of QArrayData.
+ // Typically, this alignment is sizeof(void *) and ensured by malloc.
+ size_t minAlignment = qMax(alignment, Q_ALIGNOF(QArrayData));
+
+ int capacity = 10;
+ Deallocator keeper(objectSize, minAlignment);
+ QArrayData *data = QArrayData::allocate(objectSize, minAlignment, capacity,
+ QArrayData::AllocationOptions(allocateOptions) & ~QArrayData::Grow);
+ keeper.headers.append(data);
+
+ memset(data->data(), 'A', objectSize * capacity);
+ data->size = capacity;
+
+ // now try to reallocate
+ int newCapacity = 40;
+ data = QArrayData::reallocateUnaligned(data, objectSize, newCapacity,
+ QArrayData::AllocationOptions(allocateOptions));
+ QVERIFY(data);
+ keeper.headers.clear();
+ keeper.headers.append(data);
+
+ QCOMPARE(data->size, capacity);
+ if (allocateOptions & QArrayData::Grow)
+ QVERIFY(data->alloc > uint(newCapacity));
+ else
+ QCOMPARE(data->alloc, uint(newCapacity));
+ QCOMPARE(data->capacityReserved, uint(isCapacityReserved));
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
+ QFETCH(bool, isSharable);
+ QCOMPARE(data->ref.isSharable(), isSharable);
+#endif
+
+ for (int i = 0; i < capacity; ++i)
+ QCOMPARE(static_cast<char *>(data->data())[i], 'A');
+}
+
class Unaligned
{
char dummy[8];
diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro
index 595ee258e7..c87e29e764 100644
--- a/tests/auto/corelib/tools/qlocale/test/test.pro
+++ b/tests/auto/corelib/tools/qlocale/test/test.pro
@@ -1,5 +1,4 @@
CONFIG += console testcase
-CONFIG -= app_bundle
QT = core testlib core-private
embedded: QT += gui
SOURCES = ../tst_qlocale.cpp
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 8d9a789507..7681f4755c 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -1754,6 +1754,30 @@ void tst_QLocale::numberOptions()
QVERIFY(ok);
locale.toDouble(QString("1.24e+01"), &ok);
QVERIFY(!ok);
+
+ QCOMPARE(locale.toString(12.4, 'g', 5), QString("12.4"));
+ locale.setNumberOptions(QLocale::IncludeTrailingZeroesAfterDot);
+ QCOMPARE(locale.numberOptions(), QLocale::IncludeTrailingZeroesAfterDot);
+ QCOMPARE(locale.toString(12.4, 'g', 5), QString("12.400"));
+
+ locale.toDouble(QString("1.24e+01"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("1.2400e+01"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("12.4"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("12.400"), &ok);
+ QVERIFY(ok);
+ locale.setNumberOptions(QLocale::RejectTrailingZeroesAfterDot);
+ QCOMPARE(locale.numberOptions(), QLocale::RejectTrailingZeroesAfterDot);
+ locale.toDouble(QString("1.24e+01"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("1.2400e+01"), &ok);
+ QVERIFY(!ok);
+ locale.toDouble(QString("12.4"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("12.400"), &ok);
+ QVERIFY(!ok);
}
void tst_QLocale::negativeNumbers()
diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
index e6fd67e3a8..a3de9ee5b5 100644
--- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
@@ -36,6 +36,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qwindowsysteminterface_p.h>
#include <private/qhighdpiscaling_p.h>
+#include <private/qtouchdevice_p.h>
class tst_QTouchEventWidget : public QWidget
{
@@ -199,6 +200,7 @@ private slots:
void touchBeginPropagatesWhenIgnored();
void touchUpdateAndEndNeverPropagate();
void basicRawEventTranslation();
+ void basicRawEventTranslationOfIds();
void multiPointRawEventTranslationOnTouchScreen();
void multiPointRawEventTranslationOnTouchPad();
void deleteInEventHandler();
@@ -602,7 +604,8 @@ void tst_QTouchEvent::basicRawEventTranslation()
QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
QTouchEvent::TouchPoint touchBeginPoint = touchWidget.touchBeginPoints.first();
- QCOMPARE(touchBeginPoint.id(), rawTouchPoint.id());
+ const int touchPointId = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1;
+ QCOMPARE(touchBeginPoint.id(), touchPointId);
QCOMPARE(touchBeginPoint.state(), rawTouchPoint.state());
QCOMPARE(touchBeginPoint.pos(), pos);
QCOMPARE(touchBeginPoint.startPos(), pos);
@@ -637,7 +640,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QVERIFY(!touchWidget.seenTouchEnd);
QCOMPARE(touchWidget.touchUpdatePoints.count(), 1);
QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first();
- QCOMPARE(touchUpdatePoint.id(), rawTouchPoint.id());
+ QCOMPARE(touchUpdatePoint.id(), touchPointId);
QCOMPARE(touchUpdatePoint.state(), rawTouchPoint.state());
QCOMPARE(touchUpdatePoint.pos(), pos + delta);
QCOMPARE(touchUpdatePoint.startPos(), pos);
@@ -669,7 +672,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QVERIFY(touchWidget.seenTouchEnd);
QCOMPARE(touchWidget.touchEndPoints.count(), 1);
QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first();
- QCOMPARE(touchEndPoint.id(), rawTouchPoint.id());
+ QCOMPARE(touchEndPoint.id(), touchPointId);
QCOMPARE(touchEndPoint.state(), rawTouchPoint.state());
QCOMPARE(touchEndPoint.pos(), pos + delta + delta);
QCOMPARE(touchEndPoint.startPos(), pos);
@@ -745,9 +748,11 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QVERIFY(!rightWidget.seenTouchEnd);
QCOMPARE(leftWidget.touchBeginPoints.count(), 1);
QCOMPARE(rightWidget.touchBeginPoints.count(), 1);
+ const int touchPointId0 = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1;
+ const int touchPointId1 = touchPointId0 + 1;
{
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchBeginPoints.first();
- QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id());
+ QCOMPARE(leftTouchPoint.id(), touchPointId0);
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
QCOMPARE(leftTouchPoint.pos(), leftPos);
QCOMPARE(leftTouchPoint.startPos(), leftPos);
@@ -767,7 +772,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(leftTouchPoint.pressure(), qreal(1.));
QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchBeginPoints.first();
- QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id());
+ QCOMPARE(rightTouchPoint.id(), touchPointId1);
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
QCOMPARE(rightTouchPoint.pos(), rightPos);
QCOMPARE(rightTouchPoint.startPos(), rightPos);
@@ -811,7 +816,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(rightWidget.touchUpdatePoints.count(), 1);
{
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchUpdatePoints.first();
- QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id());
+ QCOMPARE(leftTouchPoint.id(), touchPointId0);
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(leftTouchPoint.startPos(), leftPos);
@@ -831,7 +836,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(leftTouchPoint.pressure(), qreal(1.));
QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchUpdatePoints.first();
- QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id());
+ QCOMPARE(rightTouchPoint.id(), touchPointId1);
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
QCOMPARE(rightTouchPoint.pos(), QPointF(rightWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(rightTouchPoint.startPos(), rightPos);
@@ -875,7 +880,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(rightWidget.touchEndPoints.count(), 1);
{
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchEndPoints.first();
- QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id());
+ QCOMPARE(leftTouchPoint.id(), touchPointId0);
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(leftTouchPoint.startPos(), leftPos);
@@ -895,7 +900,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(leftTouchPoint.pressure(), qreal(0.));
QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchEndPoints.first();
- QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id());
+ QCOMPARE(rightTouchPoint.id(), touchPointId1);
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
QCOMPARE(rightTouchPoint.pos(), QPointF(rightWidget.mapFromParent(centerPos.toPoint())));
QCOMPARE(rightTouchPoint.startPos(), rightPos);
@@ -1145,6 +1150,126 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
}
}
+void tst_QTouchEvent::basicRawEventTranslationOfIds()
+{
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("Wayland: This fails. Figure out why.");
+
+ tst_QTouchEventWidget touchWidget;
+ touchWidget.setWindowTitle(QTest::currentTestFunction());
+ touchWidget.setAttribute(Qt::WA_AcceptTouchEvents);
+ touchWidget.setGeometry(100, 100, 400, 300);
+ touchWidget.show();
+ QVERIFY(QTest::qWaitForWindowActive(&touchWidget));
+
+ QVarLengthArray<QPointF, 2> pos;
+ QVarLengthArray<QPointF, 2> screenPos;
+ for (int i = 0; i < 2; ++i) {
+ pos << touchWidget.rect().center() + QPointF(20*i, 20*i);
+ screenPos << touchWidget.mapToGlobal(pos[i].toPoint());
+ }
+ QPointF delta(10, 10);
+ QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
+
+ QVector<QPointF> rawPosList;
+ rawPosList << QPointF(12, 34) << QPointF(56, 78);
+
+ QList<QTouchEvent::TouchPoint> rawTouchPoints;
+
+ // Press both points, this should be translated to a TouchBegin
+ for (int i = 0; i < 2; ++i) {
+ QTouchEvent::TouchPoint rawTouchPoint;
+ rawTouchPoint.setId(i);
+ rawTouchPoint.setState(Qt::TouchPointPressed);
+ rawTouchPoint.setScreenPos(screenPos[i]);
+ rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry));
+ rawTouchPoint.setRawScreenPositions(rawPosList);
+ rawTouchPoints << rawTouchPoint;
+ }
+ QTouchEvent::TouchPoint &p0 = rawTouchPoints[0];
+ QTouchEvent::TouchPoint &p1 = rawTouchPoints[1];
+
+ const ulong timestamp = 1234;
+ QWindow *window = touchWidget.windowHandle();
+ QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, timestamp, touchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(touchWidget.seenTouchBegin);
+ QVERIFY(!touchWidget.seenTouchUpdate);
+ QVERIFY(!touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchBeginPoints.count(), 2);
+
+ const int initialTouchPointId = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1;
+
+ for (int i = 0; i < touchWidget.touchBeginPoints.count(); ++i) {
+ QTouchEvent::TouchPoint touchBeginPoint = touchWidget.touchBeginPoints.at(i);
+ QCOMPARE(touchBeginPoint.id(), initialTouchPointId + i);
+ QCOMPARE(touchBeginPoint.state(), rawTouchPoints[i].state());
+ }
+
+ // moving the point should translate to TouchUpdate
+ for (int i = 0; i < rawTouchPoints.count(); ++i) {
+ QTouchEvent::TouchPoint &p = rawTouchPoints[i];
+ p.setState(Qt::TouchPointMoved);
+ p.setScreenPos(p.screenPos() + delta);
+ p.setNormalizedPos(normalized(p.pos(), screenGeometry));
+ }
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(touchWidget.seenTouchBegin);
+ QVERIFY(touchWidget.seenTouchUpdate);
+ QVERIFY(!touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.at(0).id(), initialTouchPointId);
+ QCOMPARE(touchWidget.touchUpdatePoints.at(1).id(), initialTouchPointId + 1);
+
+ // release last point
+ p0.setState(Qt::TouchPointStationary);
+ p1.setState(Qt::TouchPointReleased);
+
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(touchWidget.seenTouchBegin);
+ QVERIFY(touchWidget.seenTouchUpdate);
+ QVERIFY(!touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints[0].id(), initialTouchPointId);
+ QCOMPARE(touchWidget.touchUpdatePoints[1].id(), initialTouchPointId + 1);
+
+ // Press last point again, id should increase
+ p1.setState(Qt::TouchPointPressed);
+ p1.setId(42); // new id
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(touchWidget.seenTouchBegin);
+ QVERIFY(touchWidget.seenTouchUpdate);
+ QVERIFY(!touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints[0].id(), initialTouchPointId);
+ QCOMPARE(touchWidget.touchUpdatePoints[1].id(), initialTouchPointId + 2);
+
+ // release everything
+ p0.setState(Qt::TouchPointReleased);
+ p1.setState(Qt::TouchPointReleased);
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
+ QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(touchWidget.seenTouchBegin);
+ QVERIFY(touchWidget.seenTouchUpdate);
+ QVERIFY(touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints[0].id(), initialTouchPointId);
+ QCOMPARE(touchWidget.touchUpdatePoints[1].id(), initialTouchPointId + 2);
+}
+
void tst_QTouchEvent::deleteInEventHandler()
{
if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 6ec0268d96..a08f1896bb 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -65,6 +65,7 @@ private slots:
void positioningDuringMinimized();
void childWindowPositioning_data();
void childWindowPositioning();
+ void childWindowLevel();
void platformSurface();
void isExposed();
void isActive();
@@ -596,6 +597,29 @@ void tst_QWindow::childWindowPositioning()
QCOMPARE(childWindowAfter.framePosition(), topLeftOrigin);
}
+void tst_QWindow::childWindowLevel()
+{
+ ColoredWindow topLevel(Qt::green);
+ topLevel.setObjectName("topLevel");
+ ColoredWindow yellowChild(Qt::yellow, &topLevel);
+ yellowChild.setObjectName("yellowChild");
+ ColoredWindow redChild(Qt::red, &topLevel);
+ redChild.setObjectName("redChild");
+ ColoredWindow blueChild(Qt::blue, &topLevel);
+ blueChild.setObjectName("blueChild");
+
+ const QObjectList &siblings = topLevel.children();
+
+ QCOMPARE(siblings.constFirst(), &yellowChild);
+ QCOMPARE(siblings.constLast(), &blueChild);
+
+ yellowChild.raise();
+ QCOMPARE(siblings.constLast(), &yellowChild);
+
+ blueChild.lower();
+ QCOMPARE(siblings.constFirst(), &blueChild);
+}
+
// QTBUG-49709: Verify that the normal geometry is correctly restored
// when executing a sequence of window state changes. So far, Windows
// only where state changes have immediate effect.
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index de5b2a8676..ef1ad76161 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -135,6 +135,7 @@ private slots:
void setPlainText();
void toPlainText();
+ void toRawText();
void deleteTextObjectsOnClear();
@@ -2396,6 +2397,16 @@ void tst_QTextDocument::toPlainText()
QCOMPARE(doc->toPlainText(), QLatin1String("Hello World"));
}
+void tst_QTextDocument::toRawText()
+{
+ doc->setHtml("&nbsp;");
+
+ QString rawText = doc->toRawText();
+ QCOMPARE(rawText.size(), 1);
+ QCOMPARE(rawText.at(0).unicode(), ushort(QChar::Nbsp));
+}
+
+
void tst_QTextDocument::deleteTextObjectsOnClear()
{
QPointer<QTextTable> table = cursor.insertTable(2, 2);
diff --git a/tests/auto/network/access/qnetworkreply/test/test.pro b/tests/auto/network/access/qnetworkreply/test/test.pro
index 45a5734305..8aeec88fd2 100644
--- a/tests/auto/network/access/qnetworkreply/test/test.pro
+++ b/tests/auto/network/access/qnetworkreply/test/test.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
testcase.timeout = 600 # this test is slow
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
SOURCES += ../tst_qnetworkreply.cpp
TARGET = ../tst_qnetworkreply
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 649278d48b..b3c8a4f66b 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -104,10 +104,10 @@ class tst_QNetworkReply: public QObject
Q_OBJECT
#ifndef QT_NO_NETWORKPROXY
- struct ProxyData {
+ struct ProxyData
+ {
ProxyData(const QNetworkProxy &p, const QByteArray &t, bool auth)
- : tag(t), proxy(p), requiresAuthentication(auth)
- { }
+ : tag(t), proxy(p), requiresAuthentication(auth) {}
QByteArray tag;
QNetworkProxy proxy;
bool requiresAuthentication;
@@ -115,7 +115,8 @@ class tst_QNetworkReply: public QObject
#endif // !QT_NO_NETWORKPROXY
static bool seedCreated;
- static QString createUniqueExtension() {
+ static QString createUniqueExtension()
+ {
if (!seedCreated) {
qsrand(QTime(0,0,0).msecsTo(QTime::currentTime()) + QCoreApplication::applicationPid());
seedCreated = true; // not thread-safe, but who cares
@@ -495,7 +496,7 @@ bool tst_QNetworkReply::seedCreated = false;
QString errorMsg = call; \
if (!errorMsg.isEmpty()) \
QFAIL(qPrintable(errorMsg)); \
- } while (0);
+ } while (0)
#ifndef QT_NO_SSL
static void setupSslServer(QSslSocket* serverSocket)
@@ -507,6 +508,7 @@ static void setupSslServer(QSslSocket* serverSocket)
serverSocket->setProtocol(QSsl::AnyProtocol);
serverSocket->setLocalCertificate(testDataDir + "/certs/server.pem");
serverSocket->setPrivateKey(testDataDir + "/certs/server.key");
+ serverSocket->startServerEncryption();
}
#endif
@@ -553,31 +555,30 @@ protected:
void incomingConnection(qintptr socketDescriptor)
{
//qDebug() << "incomingConnection" << socketDescriptor << "doSsl:" << doSsl << "ipv6:" << ipv6;
- if (!doSsl) {
- client = new QTcpSocket;
- client->setSocketDescriptor(socketDescriptor);
- connectSocketSignals();
- } else {
#ifndef QT_NO_SSL
- QSslSocket *serverSocket = new QSslSocket;
- serverSocket->setParent(this);
- if (serverSocket->setSocketDescriptor(socketDescriptor)) {
- connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)));
- setupSslServer(serverSocket);
- serverSocket->startServerEncryption();
- client = serverSocket;
- connectSocketSignals();
- } else {
+ if (doSsl) {
+ QSslSocket *serverSocket = new QSslSocket(this);
+ if (!serverSocket->setSocketDescriptor(socketDescriptor)) {
delete serverSocket;
return;
}
+ connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)));
+ // connect(serverSocket, &QSslSocket::encrypted, this, &SslServer::ready); ?
+ setupSslServer(serverSocket);
+ client = serverSocket;
+ } else
#endif
+ {
+ client = new QTcpSocket;
+ client->setSocketDescriptor(socketDescriptor);
}
+ connectSocketSignals();
client->setParent(this);
++totalConnections;
}
- virtual void reply() {
+ virtual void reply()
+ {
Q_ASSERT(!client.isNull());
// we need to emulate the bytesWrittenSlot call if the data is empty.
if (dataToTransmit.size() == 0) {
@@ -634,7 +635,8 @@ public slots:
}
}
- void bytesWrittenSlot() {
+ void bytesWrittenSlot()
+ {
Q_ASSERT(!client.isNull());
// Disconnect and delete in next cycle (else Windows clients will fail with RemoteHostClosedError).
if (doClose && client->bytesToWrite() == 0) {
@@ -879,7 +881,8 @@ class BlockingTcpServer : public QTcpServer
public:
BlockingTcpServer(bool ssl) : doSsl(ssl), sslSocket(0) {}
- QTcpSocket* waitForNextConnectionSocket() {
+ QTcpSocket* waitForNextConnectionSocket()
+ {
waitForNewConnection(-1);
if (doSsl) {
if (!sslSocket)
@@ -900,7 +903,6 @@ public:
serverSocket->setSocketDescriptor(socketDescriptor);
connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)));
setupSslServer(serverSocket);
- serverSocket->startServerEncryption();
sslSocket = serverSocket;
} else
#endif
@@ -1381,14 +1383,12 @@ static QByteArray msgWaitForFinished(QNetworkReplyPtr &reply)
QString result;
QDebug debug(&result);
debug << reply->url();
- if (reply->isFinished()) {
- if (reply->error() == QNetworkReply::NoError)
- debug << "finished.";
- else
- debug << "failed: #" << reply->error() << reply->errorString();
- } else {
+ if (!reply->isFinished())
debug << "timed out.";
- }
+ else if (reply->error() == QNetworkReply::NoError)
+ debug << "finished.";
+ else
+ debug << "failed: #" << reply->error() << reply->errorString();
return result.toLocal8Bit();
}
@@ -1403,7 +1403,7 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply)
QSignalSpy spy(reply.data(), SIGNAL(downloadProgress(qint64,qint64)));
while (!reply->isFinished()) {
QTimer::singleShot(5000, loop, SLOT(quit()));
- if ( loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) {
+ if (loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) {
returnCode = Timeout;
break;
}
@@ -1417,12 +1417,14 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply)
void tst_QNetworkReply::finished()
{
- loop->exit(returnCode = Success);
+ if (loop)
+ loop->exit(returnCode = Success);
}
void tst_QNetworkReply::gotError()
{
- loop->exit(returnCode = Failure);
+ if (loop)
+ loop->exit(returnCode = Failure);
disconnect(QObject::sender(), SIGNAL(finished()), this, 0);
}
@@ -4725,11 +4727,13 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag()
}
#ifndef QT_NO_SSL
-class SslServer : public QTcpServer {
+class SslServer : public QTcpServer
+{
Q_OBJECT
public:
SslServer() : socket(0), m_ssl(true) {}
- void incomingConnection(qintptr socketDescriptor) {
+ void incomingConnection(qintptr socketDescriptor)
+ {
QSslSocket *serverSocket = new QSslSocket;
serverSocket->setParent(this);
@@ -4739,16 +4743,9 @@ public:
emit newPlainConnection(serverSocket);
return;
}
- QString testDataDir = QFileInfo(QFINDTESTDATA("rfc3252.txt")).absolutePath();
- if (testDataDir.isEmpty())
- testDataDir = QCoreApplication::applicationDirPath();
-
connect(serverSocket, SIGNAL(encrypted()), this, SLOT(encryptedSlot()));
- serverSocket->setProtocol(QSsl::AnyProtocol);
connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), serverSocket, SLOT(ignoreSslErrors()));
- serverSocket->setLocalCertificate(testDataDir + "/certs/server.pem");
- serverSocket->setPrivateKey(testDataDir + "/certs/server.key");
- serverSocket->startServerEncryption();
+ setupSslServer(serverSocket);
} else {
delete serverSocket;
}
@@ -4757,11 +4754,13 @@ signals:
void newEncryptedConnection(QSslSocket *s);
void newPlainConnection(QSslSocket *s);
public slots:
- void encryptedSlot() {
+ void encryptedSlot()
+ {
socket = (QSslSocket*) sender();
emit newEncryptedConnection(socket);
}
- void readyReadSlot() {
+ void readyReadSlot()
+ {
// for the incoming sockets, not the server socket
//qDebug() << static_cast<QSslSocket*>(sender())->bytesAvailable() << static_cast<QSslSocket*>(sender())->encryptedBytesAvailable();
}
@@ -4807,7 +4806,7 @@ void tst_QNetworkReply::ioPostToHttpsUploadProgress()
disconnect(&server, SIGNAL(newEncryptedConnection(QSslSocket*)), &QTestEventLoop::instance(), SLOT(exitLoop()));
- incomingSocket->setReadBufferSize(1*1024);
+ incomingSocket->setReadBufferSize(1024);
// some progress should have been made
QTRY_VERIFY(!spy.isEmpty());
QList<QVariant> args = spy.last();
@@ -4911,7 +4910,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp()
QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), (qint64)testData.size());
if (reader.data.size() < testData.size()) { // oops?
- QCOMPARE(reader.data, testData.mid(0, reader.data.size()));
+ QCOMPARE(reader.data, testData.left(reader.data.size()));
qDebug() << "The data is incomplete, the last" << testData.size() - reader.data.size() << "bytes are missing";
}
QCOMPARE(reader.data.size(), testData.size());
@@ -4958,7 +4957,7 @@ void tst_QNetworkReply::ioPostToHttpUploadProgress()
QVERIFY(incomingSocket);
disconnect(&server, SIGNAL(newConnection()), &QTestEventLoop::instance(), SLOT(exitLoop()));
- incomingSocket->setReadBufferSize(1*1024);
+ incomingSocket->setReadBufferSize(1024);
QTestEventLoop::instance().enterLoop(5);
// some progress should have been made
QVERIFY(!spy.isEmpty());
@@ -5660,12 +5659,14 @@ void tst_QNetworkReply::httpProxyCommands()
QCOMPARE(uaheader, QByteArray("User-Agent: QNetworkReplyAutoTest/1.0"));
}
-class ProxyChangeHelper : public QObject {
+class ProxyChangeHelper : public QObject
+{
Q_OBJECT
public:
ProxyChangeHelper() : QObject(), signalCount(0) {};
public slots:
- void finishedSlot() {
+ void finishedSlot()
+ {
signalCount++;
if (signalCount == 2)
QMetaObject::invokeMethod(&QTestEventLoop::instance(), "exitLoop", Qt::QueuedConnection);
@@ -5911,7 +5912,8 @@ void tst_QNetworkReply::httpReUsingConnectionSequential()
reply2->deleteLater();
}
-class HttpReUsingConnectionFromFinishedSlot : public QObject {
+class HttpReUsingConnectionFromFinishedSlot : public QObject
+{
Q_OBJECT
public:
QNetworkReply* reply1;
@@ -5919,7 +5921,8 @@ public:
QUrl url;
QNetworkAccessManager manager;
public slots:
- void finishedSlot() {
+ void finishedSlot()
+ {
QVERIFY(!reply1->error());
QFETCH(bool, doDeleteLater);
@@ -5967,7 +5970,8 @@ void tst_QNetworkReply::httpReUsingConnectionFromFinishedSlot()
QCOMPARE(server.totalConnections, 1);
}
-class HttpRecursiveCreationHelper : public QObject {
+class HttpRecursiveCreationHelper : public QObject
+{
Q_OBJECT
public:
@@ -5983,7 +5987,8 @@ public:
int requestsStartedCount_readyRead;
int requestsFinishedCount;
public slots:
- void finishedSlot() {
+ void finishedSlot()
+ {
requestsFinishedCount++;
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
@@ -6002,7 +6007,8 @@ public slots:
reply->deleteLater();
}
- void readyReadSlot() {
+ void readyReadSlot()
+ {
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
QVERIFY(!reply->error());
@@ -6011,7 +6017,8 @@ public slots:
requestsStartedCount_readyRead++;
}
}
- void startOne() {
+ void startOne()
+ {
QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/fluke.gif";
QNetworkRequest request(url);
QNetworkReply *reply = manager.get(request);
@@ -6380,7 +6387,8 @@ void tst_QNetworkReply::getFromHttpIntoBuffer()
}
// FIXME we really need to consolidate all those server implementations
-class GetFromHttpIntoBuffer2Server : QObject {
+class GetFromHttpIntoBuffer2Server : QObject
+{
Q_OBJECT
qint64 dataSize;
qint64 dataSent;
@@ -6390,26 +6398,28 @@ class GetFromHttpIntoBuffer2Server : QObject {
bool chunkedEncoding;
public:
- GetFromHttpIntoBuffer2Server (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0),
- client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) {
+ GetFromHttpIntoBuffer2Server (qint64 ds, bool sscl, bool ce)
+ : dataSize(ds), dataSent(0), client(0),
+ serverSendsContentLength(sscl), chunkedEncoding(ce)
+ {
server.listen();
connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot()));
}
- int serverPort() {
- return server.serverPort();
- }
+ int serverPort() { return server.serverPort(); }
public slots:
- void newConnectionSlot() {
+ void newConnectionSlot()
+ {
client = server.nextPendingConnection();
client->setParent(this);
connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64)));
}
- void readyReadSlot() {
+ void readyReadSlot()
+ {
client->readAll();
client->write("HTTP/1.0 200 OK\n");
if (serverSendsContentLength)
@@ -6419,7 +6429,8 @@ public slots:
client->write("Connection: close\n\n");
}
- void bytesWrittenSlot(qint64 amount) {
+ void bytesWrittenSlot(qint64 amount)
+ {
Q_UNUSED(amount);
if (dataSent == dataSize && client) {
// close eventually
@@ -6453,7 +6464,8 @@ public slots:
}
};
-class GetFromHttpIntoBuffer2Client : QObject {
+class GetFromHttpIntoBuffer2Client : QObject
+{
Q_OBJECT
private:
bool useDownloadBuffer;
@@ -6470,7 +6482,8 @@ public:
}
public slots:
- void metaDataChangedSlot() {
+ void metaDataChangedSlot()
+ {
if (useDownloadBuffer) {
QSharedPointer<char> sharedPointer = qvariant_cast<QSharedPointer<char> >(reply->attribute(QNetworkRequest::DownloadBufferAttribute));
QVERIFY(!sharedPointer.isNull()); // It will be 0 if it failed
@@ -6480,7 +6493,8 @@ public:
QVERIFY(bytesAvailableList.isEmpty());
}
- void readyReadSlot() {
+ void readyReadSlot()
+ {
QVERIFY(!reply->isFinished());
qint64 bytesAvailable = reply->bytesAvailable();
@@ -6502,7 +6516,8 @@ public:
// Add bytesAvailable to a list an parse
}
- void finishedSlot() {
+ void finishedSlot()
+ {
// We should have already received all readyRead
QVERIFY(!bytesAvailableList.isEmpty());
QCOMPARE(bytesAvailableList.last(), uploadSize);
@@ -6908,17 +6923,17 @@ void tst_QNetworkReply::authenticationWithDifferentRealm()
}
#endif // !QT_NO_NETWORKPROXY
-class QtBug13431Helper : public QObject {
+class QtBug13431Helper : public QObject
+{
Q_OBJECT
public:
QNetworkReply* m_reply;
QTimer m_dlTimer;
public slots:
- void replyFinished(QNetworkReply*) {
- QTestEventLoop::instance().exitLoop();
- }
+ void replyFinished(QNetworkReply*) { QTestEventLoop::instance().exitLoop(); }
- void onReadAndReschedule() {
+ void onReadAndReschedule()
+ {
const qint64 bytesReceived = m_reply->bytesAvailable();
if (bytesReceived && m_reply->readBufferSize()) {
QByteArray data = m_reply->read(bytesReceived);
@@ -7066,7 +7081,8 @@ void tst_QNetworkReply::qtbug22660gzipNoContentLengthEmptyContent()
QCOMPARE(reply->readAll(), QByteArray());
}
-class QtBug27161Helper : public QObject {
+class QtBug27161Helper : public QObject
+{
Q_OBJECT
public:
QtBug27161Helper(MiniHttpServer & server, const QByteArray & data):
@@ -7076,16 +7092,19 @@ public:
connect(&m_server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot()));
}
public slots:
- void newConnectionSlot(){
+ void newConnectionSlot()
+ {
connect(m_server.client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot()));
}
- void bytesWrittenSlot(){
+ void bytesWrittenSlot()
+ {
disconnect(m_server.client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot()));
m_Timer.singleShot(100, this, SLOT(timeoutSlot()));
}
- void timeoutSlot(){
+ void timeoutSlot()
+ {
m_server.doClose = true;
// we need to emulate the bytesWrittenSlot call if the data is empty.
if (m_data.size() == 0)
@@ -7514,10 +7533,12 @@ void tst_QNetworkReply::httpUserAgent()
void tst_QNetworkReply::synchronousAuthenticationCache()
{
- class MiniAuthServer : public MiniHttpServer {
+ class MiniAuthServer : public MiniHttpServer
+ {
public:
- MiniAuthServer(QThread *thread) : MiniHttpServer(QByteArray(), false, thread) {};
- virtual void reply() {
+ MiniAuthServer(QThread *thread) : MiniHttpServer(QByteArray(), false, thread) {}
+ virtual void reply()
+ {
dataToTransmit =
"HTTP/1.0 401 Unauthorized\r\n"
@@ -7929,7 +7950,8 @@ public:
qint64 bandwidthQuota;
QTimer timer;
- RateLimitedUploadDevice(QByteArray d) : QIODevice(),data(d),read(0),bandwidthQuota(0) {
+ RateLimitedUploadDevice(QByteArray d) : QIODevice(),data(d),read(0),bandwidthQuota(0)
+ {
buffer.setData(data);
buffer.open(QIODevice::ReadOnly);
timer.setInterval(200);
@@ -7937,12 +7959,14 @@ public:
timer.start();
}
- virtual qint64 writeData(const char* , qint64 ) {
+ virtual qint64 writeData(const char* , qint64 )
+ {
Q_ASSERT(false);
return 0;
}
- virtual qint64 readData(char* data, qint64 maxlen) {
+ virtual qint64 readData(char* data, qint64 maxlen)
+ {
//qDebug() << Q_FUNC_INFO << maxlen << bandwidthQuota;
maxlen = qMin(maxlen, buffer.bytesAvailable());
maxlen = qMin(maxlen, bandwidthQuota);
@@ -7959,24 +7983,17 @@ public:
//qDebug() << Q_FUNC_INFO << maxlen << bandwidthQuota << read << ret << buffer.bytesAvailable();
return ret;
}
- virtual bool atEnd() const {
- return buffer.atEnd();
- }
- virtual qint64 size() const{
- return data.length();
- }
+ virtual bool atEnd() const { return buffer.atEnd(); }
+ virtual qint64 size() const { return data.length(); }
qint64 bytesAvailable() const
{
return buffer.bytesAvailable() + QIODevice::bytesAvailable();
}
- virtual bool isSequential() const{ // random access, we can seek
- return false;
- }
- virtual bool seek ( qint64 pos ) {
- return buffer.seek(pos);
- }
+ virtual bool isSequential() const { return false; } // random access, we can seek
+ virtual bool seek (qint64 pos) { return buffer.seek(pos); }
protected slots:
- void timeoutSlot() {
+ void timeoutSlot()
+ {
//qDebug() << Q_FUNC_INFO;
bandwidthQuota = 8*1024; // fill quota
emit readyRead();
@@ -8166,9 +8183,7 @@ signals:
void corruptFileUploadReceived();
public slots:
- void closeDelayed() {
- m_socket->close();
- }
+ void closeDelayed() { m_socket->close(); }
void readyReadSlot()
{
@@ -8193,17 +8208,18 @@ public slots:
// We had received some data but it is corrupt!
qDebug() << "CORRUPT" << m_receivedData.count();
- // Use this to track down the pattern of the corruption and conclude the source
-// QFile a("/tmp/corrupt");
-// a.open(QIODevice::WriteOnly);
-// a.write(m_receivedData);
-// a.close();
+#if 0 // Use this to track down the pattern of the corruption and conclude the source
+ QFile a("/tmp/corrupt");
+ a.open(QIODevice::WriteOnly);
+ a.write(m_receivedData);
+ a.close();
-// QFile b("/tmp/correct");
-// b.open(QIODevice::WriteOnly);
-// b.write(m_expectedData);
-// b.close();
+ QFile b("/tmp/correct");
+ b.open(QIODevice::WriteOnly);
+ b.write(m_expectedData);
+ b.close();
//exit(1);
+#endif
emit corruptFileUploadReceived();
} else {
emit correctFileUploadReceived();
@@ -8220,26 +8236,26 @@ public:
int m_repliesFinished;
int m_expectedReplies;
QByteArray m_expectedData;
- PutWithServerClosingConnectionImmediatelyServer() : SslServer(), m_correctUploads(0), m_corruptUploads(0), m_repliesFinished(0), m_expectedReplies(0)
+ PutWithServerClosingConnectionImmediatelyServer()
+ : SslServer(), m_correctUploads(0), m_corruptUploads(0),
+ m_repliesFinished(0), m_expectedReplies(0)
{
QObject::connect(this, SIGNAL(newEncryptedConnection(QSslSocket*)), this, SLOT(createHandlerForConnection(QSslSocket*)));
QObject::connect(this, SIGNAL(newPlainConnection(QSslSocket*)), this, SLOT(createHandlerForConnection(QSslSocket*)));
}
public slots:
- void createHandlerForConnection(QSslSocket* s) {
+ void createHandlerForConnection(QSslSocket* s)
+ {
PutWithServerClosingConnectionImmediatelyHandler *handler = new PutWithServerClosingConnectionImmediatelyHandler(s, m_expectedData);
handler->setParent(this);
QObject::connect(handler, SIGNAL(correctFileUploadReceived()), this, SLOT(increaseCorrect()));
QObject::connect(handler, SIGNAL(corruptFileUploadReceived()), this, SLOT(increaseCorrupt()));
}
- void increaseCorrect() {
- m_correctUploads++;
- }
- void increaseCorrupt() {
- m_corruptUploads++;
- }
- void replyFinished() {
+ void increaseCorrect() { m_correctUploads++; }
+ void increaseCorrupt() { m_corruptUploads++; }
+ void replyFinished()
+ {
m_repliesFinished++;
if (m_repliesFinished == m_expectedReplies) {
QTestEventLoop::instance().exitLoop();
diff --git a/tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro b/tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro
index a2fe44060e..23d57f3fbf 100644
--- a/tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro
+++ b/tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro
@@ -1,5 +1,4 @@
CONFIG += testcase console
-CONFIG -= app_bundle
TARGET = tst_qnetworkdatagram
SOURCES += tst_qnetworkdatagram.cpp
QT = core network testlib
diff --git a/tests/auto/other/atwrapper/.gitignore b/tests/auto/other/atwrapper/.gitignore
deleted file mode 100644
index 162ad53af6..0000000000
--- a/tests/auto/other/atwrapper/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-tst_atwrapper
diff --git a/tests/auto/other/atwrapper/TODO b/tests/auto/other/atwrapper/TODO
deleted file mode 100644
index 23a70c3c9e..0000000000
--- a/tests/auto/other/atwrapper/TODO
+++ /dev/null
@@ -1,17 +0,0 @@
-* Get rid of "Keep baseline" on test failure page (Lars) !! DONE !!
-* Make to autotest (Simon) !! DONE !!
-* Add visual diff (Everyone ;)) !! DONE !!
-* Add flicker (Simon/Jesper) !! DONE !!
-* Add third image -- base-baseline (Lars) !! DONE !!
-* Add "view baselines" gallery, including the "base base line" (Lars) !! DONE !!
-* Add PS printer driver engine test thingy (Eskil) !! DONE !!
-* Add platform by platform comparison perl script. (Morton)
-* Fix the QDateTime.fromString() weirdness on win32 in xmldata.cpp (Jesper)
-* Have one result per page view (Lars) !! DONE !!
-* Have "platform - hostname" on test overview (Lars) !! DONE !!
-* Have the links on the overview page only show failures for that host.(All)!! DONE !!
-* "onion skin" diff. (Jesper)
-* Promote all to baseline
-* Switch all to flicker/onion/whatever
-* Add javascript confirmation for "make baseline"
-* Make "single view" more stable
diff --git a/tests/auto/other/atwrapper/atWrapper.cpp b/tests/auto/other/atwrapper/atWrapper.cpp
deleted file mode 100644
index 8f623538f9..0000000000
--- a/tests/auto/other/atwrapper/atWrapper.cpp
+++ /dev/null
@@ -1,636 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <atWrapper.h>
-#include <datagenerator/datagenerator.h>
-
-#include <QString>
-#include <QHash>
-#include <QFile>
-#include <QFtp>
-#include <QObject>
-#include <QHostInfo>
-#include <QWidget>
-#include <QImage>
-#include <QtTest/QSignalSpy>
-#include <QLibraryInfo>
-
-static const char *ArthurDir = "../../arthur";
-
-#include <string.h>
-
-atWrapper::atWrapper()
-{
-
- // initTests();
-
-}
-
-bool atWrapper::initTests(bool *haveBaseline)
-{
- qDebug() << "Running test on buildkey:" << QLibraryInfo::buildKey() << " qt version:" << qVersion();
-
- qDebug( "Initializing tests..." );
-
- if (!loadConfig( QHostInfo::localHostName().split( "." ).first() + ".ini" ))
- return false;
-
- //Reset the FTP environment where the results are stored
- *haveBaseline = setupFTP();
-
- // Retrieve the latest test result baseline from the FTP server.
- downloadBaseline();
- return true;
-}
-
-void atWrapper::downloadBaseline()
-{
-
- qDebug() << "Now downloading baseline...";
-
- QFtp ftp;
-
- QObject::connect( &ftp, SIGNAL(listInfo(QUrlInfo)), this, SLOT(ftpMgetAddToList(QUrlInfo)) );
-
- //Making sure that the needed local directories exist.
-
- QHashIterator<QString, QString> j(enginesToTest);
-
- while ( j.hasNext() )
- {
- j.next();
-
- QDir dir( output );
-
- if ( !dir.cd( j.key() + ".baseline" ) )
- dir.mkdir( j.key() + ".baseline" );
-
- }
-
- //FTP to the host specified in the config file, and retrieve the test result baseline.
- ftp.connectToHost( ftpHost );
- ftp.login( ftpUser, ftpPass );
-
- ftp.cd( ftpBaseDir );
-
- QHashIterator<QString, QString> i(enginesToTest);
- while ( i.hasNext() )
- {
- i.next();
- mgetDirList.clear();
- mgetDirList << i.key() + ".baseline";
- ftp.cd( i.key() + ".baseline" );
- ftp.list();
- ftp.cd( ".." );
-
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
-
- ftpMgetDone( true );
- }
-
- ftp.close();
- ftp.close();
-
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
-
-}
-
-void atWrapper::ftpMgetAddToList( const QUrlInfo &urlInfo )
-{
- //Simply adding to the list of files to download.
- mgetDirList << urlInfo.name();
-
-}
-
-void atWrapper::ftpMgetDone( bool error)
-{
- Q_UNUSED( error );
-
- //Downloading the files listed in mgetDirList...
- QFtp ftp;
- ftp.connectToHost( ftpHost );
- ftp.login( ftpUser, ftpPass );
-
- QFile* file;
-
- if ( mgetDirList.size() > 1 )
- for ( int i = 1; i < mgetDirList.size(); ++i )
- {
- file = new QFile( QString( output ) + QLatin1Char('/') + mgetDirList.at( 0 )
- + QLatin1Char('/') + mgetDirList.at( i ) );
- if (file->open(QIODevice::WriteOnly)) {
- ftp.get( ftpBaseDir + QLatin1Char('/') + mgetDirList.at( 0 ) + QLatin1Char('/') + mgetDirList.at( i ), file );
- ftp.list(); //Only there to fill up a slot in the pendingCommands queue.
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
- file->close();
- } else {
- qDebug() << "Couldn't open file for writing: " << file->fileName();
- }
- }
-
-
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
-}
-
-void atWrapper::uploadFailed( QString dir, QString filename, QByteArray filedata )
-{
- //Upload a failed test case image to the FTP server.
- QFtp ftp;
- ftp.connectToHost( ftpHost );
- ftp.login( ftpUser, ftpPass );
-
- ftp.cd( ftpBaseDir );
- ftp.cd( dir );
-
- ftp.put( filedata, filename, QFtp::Binary );
-
- ftp.close();
-
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
-}
-
-// returns false if no baseline exists
-bool atWrapper::setupFTP()
-{
- qDebug( "Setting up FTP environment" );
-
- QString dir = "";
- ftpMkDir( ftpBaseDir );
-
- ftpBaseDir += QLatin1Char('/') + QLibraryInfo::buildKey();
-
- ftpMkDir( ftpBaseDir );
-
- ftpBaseDir += QLatin1Char('/') + QString( qVersion() );
-
- ftpMkDir( ftpBaseDir );
-
- QHashIterator<QString, QString> i(enginesToTest);
- QHashIterator<QString, QString> j(enginesToTest);
-
- bool haveBaseline = true;
- //Creating the baseline directories for each engine
- while ( i.hasNext() )
- {
- i.next();
- //qDebug() << "Creating dir with key:" << i.key();
- ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".failed" );
- ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".diff" );
- if (!ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".baseline" ))
- haveBaseline = false;
- }
-
-
- QFtp ftp;
- ftp.connectToHost( ftpHost );
- ftp.login( ftpUser, ftpPass );
-
- ftp.cd( ftpBaseDir );
- //Deleting previous failed directory and all the files in it, then recreating it.
- while ( j.hasNext() )
- {
- j.next();
- rmDirList.clear();
- rmDirList << ftpBaseDir + QLatin1Char('/') + j.key() + ".failed/";
- ftpRmDir( j.key() + ".failed" );
- ftp.rmdir( j.key() + ".failed" );
- ftp.mkdir( j.key() + ".failed" );
- ftp.list();
-
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
-
- rmDirList.clear();
- rmDirList << ftpBaseDir + QLatin1Char('/') + j.key() + ".diff/";
- ftpRmDir( j.key() + ".diff" );
- ftp.rmdir( j.key() + ".diff" );
- ftp.mkdir( j.key() + ".diff" );
- ftp.list();
-
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
-
- }
-
- ftp.close();
-
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
-
- return haveBaseline;
-}
-
-void atWrapper::ftpRmDir( QString dir )
-{
- //Hack to remove a populated directory. (caveat: containing only files and empty dirs, not recursive!)
- qDebug() << "Now removing directory: " << dir;
- QFtp ftp;
- QObject::connect( &ftp, SIGNAL(listInfo(QUrlInfo)), this, SLOT(ftpRmDirAddToList(QUrlInfo)) );
- QObject::connect( &ftp, SIGNAL(done(bool)), this, SLOT(ftpRmDirDone(bool)) );
-
- ftp.connectToHost( ftpHost );
- ftp.login( ftpUser, ftpPass );
-
- ftp.list( ftpBaseDir + "/" + dir );
- ftp.close();
- ftp.close();
-
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
-}
-
-void atWrapper::ftpRmDirDone( bool error )
-{
- //Deleting each file in the directory listning, rmDirList.
- Q_UNUSED( error );
-
- QFtp ftp;
- ftp.connectToHost( ftpHost );
- ftp.login( ftpUser, ftpPass );
-
- if ( rmDirList.size() > 1 )
- for (int i = 1; i < rmDirList.size(); ++i)
- ftp.remove( rmDirList.at(0) + rmDirList.at( i ) );
-
- ftp.close();
-
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
-}
-
-// returns false if the directory already exists
-bool atWrapper::ftpMkDir( QString dir )
-{
- //Simply used to avoid QFTP from bailing out and loosing a queue of commands.
- // IE: conveniance.
- QFtp ftp;
-
- QSignalSpy commandSpy(&ftp, SIGNAL(commandFinished(int,bool)));
-
- ftp.connectToHost( ftpHost );
- ftp.login( ftpUser, ftpPass );
- const int command = ftp.mkdir( dir );
- ftp.close();
-
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
-
- for (int i = 0; i < commandSpy.count(); ++i)
- if (commandSpy.at(i).at(0) == command)
- return commandSpy.at(i).at(1).toBool();
-
- return false;
-}
-
-
-void atWrapper::ftpRmDirAddToList( const QUrlInfo &urlInfo )
-{
- //Just adding the file to the list for deletion
- rmDirList << urlInfo.name();
-}
-
-
-bool atWrapper::executeTests()
-{
- qDebug("Executing the tests...");
-
- QHashIterator<QString, QString> i(enginesToTest);
-
- DataGenerator generator;
-
- //Running datagenerator against all the frameworks specified in the config file.
- while ( i.hasNext() )
- {
-
- i.next();
-
- qDebug( "Now testing: " + i.key().toLatin1() );
-
- char* params[13];
- //./bin/datagenerator -framework data/framework.ini -engine OpenGL -suite 1.1 -output outtest
-
-
- QByteArray eng = i.key().toLatin1();
- QByteArray fwk = framework.toLatin1();
- QByteArray sut = suite.toLatin1();
- QByteArray out = output.toLatin1();
- QByteArray siz = size.toLatin1();
- QByteArray fill = fillColor.toLatin1();
-
- params[1] = "-framework";
- params[2] = fwk.data();
- params[3] = "-engine";
- params[4] = eng.data();
- params[5] = "-suite";
- params[6] = sut.data();
- params[7] = "-output";
- params[8] = out.data();
- params[9] = "-size";
- params[10] = siz.data();
- params[11] = "-fill";
- params[12] = fill.data();
-
- generator.run( 13, params );
- }
-
- return true;
-}
-
-void atWrapper::createBaseline()
-{
- qDebug( "Now uploading a baseline of only the latest test values" );
-
- QHashIterator<QString, QString> i(enginesToTest);
-
- QDir dir( output );
- QFtp ftp;
- ftp.connectToHost( ftpHost );
- ftp.login( ftpUser, ftpPass );
- ftp.cd( ftpBaseDir );
- //Upload all the latest test results to the FTP server's baseline directory.
- while ( i.hasNext() )
- {
-
- i.next();
- dir.cd( i.key() );
- ftp.cd( i.key() + ".baseline" );
- dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
- dir.setNameFilters( QStringList() << "*.png" );
- QFileInfoList list = dir.entryInfoList();
- dir.cd( ".." );
- for (int n = 0; n < list.size(); n++)
- {
- QFileInfo fileInfo = list.at( n );
- QFile file( QString( output ) + QLatin1Char('/') + i.key() + QLatin1Char('/') + fileInfo.fileName() );
- file.open( QIODevice::ReadOnly );
- QByteArray fileData = file.readAll();
- //qDebug() << "Sending up:" << fileInfo.fileName() << "with file size" << fileData.size();
- file.close();
- ftp.put( fileData, fileInfo.fileName(), QFtp::Binary );
- }
-
- ftp.cd( ".." );
- }
-
- ftp.close();
-
- while ( ftp.hasPendingCommands() )
- QCoreApplication::instance()->processEvents();
-}
-
-bool atWrapper::compare()
-{
- qDebug( "Now comparing the results to the baseline" );
-
- QHashIterator<QString, QString> i(enginesToTest);
-
- while ( i.hasNext() )
- {
- i.next();
-
- compareDirs( output , i.key() );
-
- }
-
- return true;
-}
-
-void atWrapper::compareDirs( QString basedir, QString target )
-{
-
- QDir dir( basedir );
-
- /* The following should be redundant now.
-
- if ( !dir.cd( target + ".failed" ) )
- dir.mkdir( target + ".failed" );
- else
- dir.cdUp();
-
- */
-
- if ( !dir.cd( target + ".diff" ) )
- dir.mkdir( target + ".diff" );
- else
- dir.cdUp();
-
-
-
- //Perform comparisons between the two directories.
-
- dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
- dir.setNameFilters( QStringList() << "*.png" );
- dir.cd( target + ".baseline" );
- QFileInfoList list = dir.entryInfoList();
-
- for (int i = 0; i < list.size(); ++i)
- {
- QFileInfo fileInfo = list.at(i);
- diff ( basedir, target, fileInfo.fileName() );
- }
-}
-
-bool atWrapper::diff( QString basedir, QString dir, QString target )
-{
- //Comparing the two specified files, and then uploading them to
- //the ftp server if they differ
-
- basedir += QLatin1Char('/') + dir;
- QString one = basedir + ".baseline/" + target;
- QString two = basedir + QLatin1Char('/') + target;
-
- QFile file( one );
-
- file.open( QIODevice::ReadOnly );
- QByteArray contentsOfOne = file.readAll();
- file.close();
-
- file.setFileName( two );
-
- file.open( QIODevice::ReadOnly );
- QByteArray contentsOfTwo = file.readAll();
- file.close();
-
- if ( contentsOfTwo.size() == 0 )
- {
- qDebug() << "No test result found for baseline: " << one;
- file.setFileName( one );
- file.open( QIODevice::ReadOnly );
- file.copy( basedir + ".failed/" + target + "_missing" );
- uploadFailed( dir + ".failed", target + "_missing", contentsOfTwo );
- return false;
- }
-
-
- if ( ( memcmp( contentsOfOne, contentsOfTwo, contentsOfOne.size() ) ) == 0 )
- return true;
- else
- {
- qDebug() << "Sorry, the result did not match: " << one;
- file.setFileName( two );
- file.open( QIODevice::ReadOnly );
- file.copy( basedir + ".failed/" + target );
- file.close();
- uploadFailed( dir + ".failed", target, contentsOfTwo );
- uploadDiff( basedir, dir, target );
- return false;
- }
-}
-
-void atWrapper::uploadDiff( QString basedir, QString dir, QString filename )
-{
-
- qDebug() << basedir;
- QImage im1( basedir + ".baseline/" + filename );
- QImage im2( basedir + QLatin1Char('/') + filename );
-
- QImage im3(im1.size(), QImage::Format_ARGB32);
-
- im1 = im1.convertToFormat(QImage::Format_ARGB32);
- im2 = im2.convertToFormat(QImage::Format_ARGB32);
-
- for ( int y=0; y<im1.height(); ++y )
- {
- uint *s = (uint *) im1.scanLine(y);
- uint *d = (uint *) im2.scanLine(y);
- uint *w = (uint *) im3.scanLine(y);
-
- for ( int x=0; x<im1.width(); ++x )
- {
- if (*s != *d)
- *w = 0xff000000;
- else
- *w = 0xffffffff;
- w++;
- s++;
- d++;
- }
- }
-
- im3.save( basedir + ".diff/" + filename ,"PNG");
-
- QFile file( basedir + ".diff/" + filename );
- file.open( QIODevice::ReadOnly );
- QByteArray contents = file.readAll();
- file.close();
-
- uploadFailed( dir + ".diff", filename, contents );
-
-}
-
-bool atWrapper::loadConfig( QString path )
-{
- qDebug() << "Loading config file from ... " << path;
- configPath = path;
- //If there is no config file, don't proceed;
- if ( !QFile::exists( path ) )
- {
- return false;
- }
-
-
- QSettings settings( path, QSettings::IniFormat, this );
-
-
- //FIXME: Switch to QStringList or something, hash is not needed!
- int numEngines = settings.beginReadArray("engines");
-
- for ( int i = 0; i < numEngines; ++i )
- {
- settings.setArrayIndex(i);
- enginesToTest.insert( settings.value( "engine" ).toString(), "Info here please :p" );
- }
-
- settings.endArray();
-
- framework = QString(ArthurDir) + QDir::separator() + settings.value( "framework" ).toString();
- suite = settings.value( "suite" ).toString();
- output = settings.value( "output" ).toString();
- size = settings.value( "size", "480,360" ).toString();
- fillColor = settings.value( "fill", "white" ).toString();
- ftpUser = settings.value( "ftpUser" ).toString();
- ftpPass = settings.value( "ftpPass" ).toString();
- ftpHost = settings.value( "ftpHost" ).toString();
- ftpBaseDir = settings.value( "ftpBaseDir" ).toString();
-
-
- QDir::current().mkdir( output );
-
- output += QLatin1Char('/') + QLibraryInfo::buildKey();
-
- QDir::current().mkdir( output );
-
- output += QLatin1Char('/') + QString( qVersion() );
-
- QDir::current().mkdir( output );
-
-
- ftpBaseDir += QLatin1Char('/') + QHostInfo::localHostName().split( QLatin1Char('.') ).first();
-
-
-/*
- framework = "data/framework.ini";
- suite = "1.1";
- output = "testresults";
- ftpUser = "anonymous";
- ftpPass = "anonymouspass";
- ftpHost = "kramer.troll.no";
- ftpBaseDir = "/arthurtest";
-*/
- return true;
-}
-
-bool atWrapper::runAutoTests()
-{
- //SVG needs this widget...
- QWidget dummy;
-
- bool haveBaseline = false;
-
- if (!initTests(&haveBaseline))
- return false;
- executeTests();
-
- if ( !haveBaseline )
- {
- qDebug( " First run! Creating baseline..." );
- createBaseline();
- }
- else
- {
- qDebug( " Comparing results..." );
- compare();
- }
- return true;
-}
diff --git a/tests/auto/other/atwrapper/atWrapper.h b/tests/auto/other/atwrapper/atWrapper.h
deleted file mode 100644
index dab2b579e3..0000000000
--- a/tests/auto/other/atwrapper/atWrapper.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef ATWRAPPER_H
-#define ATWRAPPER_H
-
-#include <QHash>
-#include <QString>
-#include <QUrlInfo>
-#include <QColor>
-
-class atWrapper : public QObject
-{
- Q_OBJECT
-
- public:
- atWrapper();
- bool runAutoTests();
-
- private:
- bool executeTests();
- bool initTests(bool *haveBaseline);
- bool compare();
- void createBaseline();
- bool loadConfig( QString );
- void compareDirs( QString, QString );
- bool diff( QString, QString, QString );
- void downloadBaseline();
- void uploadFailed( QString, QString, QByteArray );
- bool ftpMkDir( QString );
- void ftpRmDir( QString );
- bool setupFTP();
- void uploadDiff( QString, QString, QString );
-
- QHash<QString, QString> enginesToTest;
- QString framework;
- QString suite;
- QString output;
- QString size;
- QString ftpUser;
- QString ftpPass;
- QString ftpHost;
- QString ftpBaseDir;
- QList<QString> rmDirList;
- QList<QString> mgetDirList;
- QString configPath;
- QString fillColor;
-
- private slots:
- void ftpRmDirAddToList( const QUrlInfo &urlInfo );
- void ftpRmDirDone( bool );
- void ftpMgetAddToList( const QUrlInfo &urlInfo );
- void ftpMgetDone( bool );
-};
-
-#endif
diff --git a/tests/auto/other/atwrapper/atWrapper.pro b/tests/auto/other/atwrapper/atWrapper.pro
deleted file mode 100644
index 1617ae89d1..0000000000
--- a/tests/auto/other/atwrapper/atWrapper.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-ARTHUR=$$QT_SOURCE_TREE/tests/arthur
-COMMON_FOLDER = $$ARTHUR/common
-include($$ARTHUR/arthurtester.pri)
-INCLUDEPATH += $$ARTHUR
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-QT += xml svg network testlib
-
-qtHaveModule(opengl): QT += opengl
-
-include($$ARTHUR/datagenerator/datagenerator.pri)
-
-CONFIG += testcase
-
-HEADERS += atWrapper.h
-SOURCES += atWrapperAutotest.cpp atWrapper.cpp
-
-TARGET = tst_atwrapper
-
-#include($$COMMON_FOLDER/common.pri)
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/other/atwrapper/atWrapperAutotest.cpp b/tests/auto/other/atwrapper/atWrapperAutotest.cpp
deleted file mode 100644
index ea40cc92b9..0000000000
--- a/tests/auto/other/atwrapper/atWrapperAutotest.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtTest/QtTest>
-#include "atWrapper.h"
-#include <QApplication>
-
-class atWrapperAutotest: public QObject
-{
-
-Q_OBJECT
-
-public slots:
- void init();
-
-private slots:
- void runTest();
-};
-
-void atWrapperAutotest::init()
-{
-#ifndef Q_OS_IRIX
- QDir::setCurrent(SRCDIR);
-#endif
-}
-
-void atWrapperAutotest::runTest()
-{
-
- //QApplication app(argc, argv);
-
- atWrapper wrapper;
- if (!wrapper.runAutoTests())
- QSKIP("Arthur not tested on this machine");
- QVERIFY(true);
-}
-
-QTEST_MAIN(atWrapperAutotest)
-#include "atWrapperAutotest.moc"
diff --git a/tests/auto/other/atwrapper/desert.ini b/tests/auto/other/atwrapper/desert.ini
deleted file mode 100644
index 6d8605252d..0000000000
--- a/tests/auto/other/atwrapper/desert.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-[General]
-framework=data/framework.ini
-ftpBaseDir=/arthurtest
-ftpHost=kramer.troll.no
-ftpPass=anonymouspass
-ftpUser=anonymous
-output=testresults
-suite=1.1
-
-[engines]
-1\engine=NativeXRender
-2\engine=PDF
-3\engine=Raster
-size=3
diff --git a/tests/auto/other/atwrapper/ephron.ini b/tests/auto/other/atwrapper/ephron.ini
deleted file mode 100644
index eeccb3b6ef..0000000000
--- a/tests/auto/other/atwrapper/ephron.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-[General]
-framework=data/framework.ini
-ftpBaseDir=/arthurtest
-ftpHost=kramer.troll.no
-ftpPass=anonymouspass
-ftpUser=anonymous
-output=testresults
-suite=oxygen
-size=256
-fill=transparent
-
-[engines]
-1\engine=Raster
-size=1
diff --git a/tests/auto/other/atwrapper/gullgubben.ini b/tests/auto/other/atwrapper/gullgubben.ini
deleted file mode 100644
index 3a664dddd5..0000000000
--- a/tests/auto/other/atwrapper/gullgubben.ini
+++ /dev/null
@@ -1,12 +0,0 @@
-[General]
-framework=data/framework.ini
-ftpBaseDir=/arthurtest
-ftpHost=kramer.troll.no
-ftpPass=anonymouspass
-ftpUser=anonymous
-output=testresults
-suite=1.1
-
-[engines]
-1\engine=OpenGL
-size=1
diff --git a/tests/auto/other/atwrapper/honshu.ini b/tests/auto/other/atwrapper/honshu.ini
deleted file mode 100644
index 3b7751a128..0000000000
--- a/tests/auto/other/atwrapper/honshu.ini
+++ /dev/null
@@ -1,16 +0,0 @@
-[General]
-framework=data/framework.ini
-ftpBaseDir=/arthurtest
-ftpHost=kramer.troll.no
-ftpPass=anonymouspass
-ftpUser=anonymous
-output=testresults
-suite=1.1
-
-[engines]
-1\engine=NativeWin32
-2\engine=PDF
-3\engine=Raster
-4\engine=OpenGL
-5\engine=WinPrint
-size=5
diff --git a/tests/auto/other/atwrapper/kramer.ini b/tests/auto/other/atwrapper/kramer.ini
deleted file mode 100644
index 289d8a8b7e..0000000000
--- a/tests/auto/other/atwrapper/kramer.ini
+++ /dev/null
@@ -1,12 +0,0 @@
-[General]
-framework=data/framework.ini
-ftpBaseDir=/arthurtest
-ftpHost=kramer.troll.no
-ftpPass=anonymouspass
-ftpUser=anonymous
-output=testresults
-suite=1.1
-
-[engines]
-1\engine=Raster
-size=1
diff --git a/tests/auto/other/atwrapper/scruffy.ini b/tests/auto/other/atwrapper/scruffy.ini
deleted file mode 100644
index 329f537e6f..0000000000
--- a/tests/auto/other/atwrapper/scruffy.ini
+++ /dev/null
@@ -1,15 +0,0 @@
-[General]
-framework=data/framework.ini
-ftpBaseDir=/arthurtest
-ftpHost=kramer.nokia.troll.no
-ftpPass=anonymouspass
-ftpUser=anonymous
-output=testresults
-suite=1.1
-
-[engines]
-1\engine=NativeMac
-2\engine=PDF
-3\engine=Raster
-4\engine=OpenGL
-size=4
diff --git a/tests/auto/other/atwrapper/spareribs.ini b/tests/auto/other/atwrapper/spareribs.ini
deleted file mode 100644
index 78ff9e985f..0000000000
--- a/tests/auto/other/atwrapper/spareribs.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-[General]
-framework=data/framework.ini
-ftpBaseDir=/arthurtest
-ftpHost=kramer.troll.no
-ftpPass=anonymouspass
-ftpUser=anonymous
-output=testresults
-suite=1.1
-
-[engines]
-1\engine=NativeWin32
-2\engine=PDF
-3\engine=Raster
-size=3
diff --git a/tests/auto/other/atwrapper/titan.ini b/tests/auto/other/atwrapper/titan.ini
deleted file mode 100644
index 3a0b0dfd31..0000000000
--- a/tests/auto/other/atwrapper/titan.ini
+++ /dev/null
@@ -1,13 +0,0 @@
-[General]
-framework=data/framework.ini
-ftpBaseDir=/arthurtest
-ftpHost=kramer.troll.no
-ftpPass=anonymouspass
-ftpUser=anonymous
-output=testresults
-suite=1.1
-
-[engines]
-1\engine=NativeXRender
-2\engine=OpenGL
-size=2
diff --git a/tests/auto/other/lancelot/lancelot.pro b/tests/auto/other/lancelot/lancelot.pro
index e9c9af7143..798482f02c 100644
--- a/tests/auto/other/lancelot/lancelot.pro
+++ b/tests/auto/other/lancelot/lancelot.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle
TARGET = tst_lancelot
QT += xml testlib
diff --git a/tests/auto/other/macplist/tst_macplist.cpp b/tests/auto/other/macplist/tst_macplist.cpp
index 0f07095b67..755cc462f5 100644
--- a/tests/auto/other/macplist/tst_macplist.cpp
+++ b/tests/auto/other/macplist/tst_macplist.cpp
@@ -155,9 +155,12 @@ void tst_MacPlist::test_plist()
QString infoPlist = QLatin1String("Info.plist");
QDir dir(QCoreApplication::applicationDirPath());
+#ifndef Q_OS_MACOS
+ // macOS builds tests as single executables, iOS/tvOS/watchOS does not
QVERIFY(dir.cdUp());
QVERIFY(dir.cdUp());
QVERIFY(dir.cdUp());
+#endif
QVERIFY(dir.cd(QLatin1String("app")));
QVERIFY(dir.cd(QLatin1String("app.app")));
QVERIFY(dir.cd(QLatin1String("Contents")));
diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro
index 0babac4b6f..a12f08488d 100644
--- a/tests/auto/other/other.pro
+++ b/tests/auto/other/other.pro
@@ -2,7 +2,6 @@ TEMPLATE=subdirs
QT_FOR_CONFIG += gui-private
SUBDIRS=\
- # atwrapper \ # QTBUG-19452
compiler \
gestures \
lancelot \
diff --git a/tests/auto/test.pl b/tests/auto/test.pl
deleted file mode 100755
index 4df8c40e9e..0000000000
--- a/tests/auto/test.pl
+++ /dev/null
@@ -1,223 +0,0 @@
-#!/usr/bin/env perl
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## 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 General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## 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-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-use strict;
-use Cwd;
-use warnings;
-
-# Usage: test.pl <SearchPath> <ExecutionMode> <TestResults> <Timeout [Default 300 seconds]>
-# Variable declarations to keep strict happy
-our $SEARCH_PATH;
-our $EXEC_MODE;
-our $EXE_PREFIX;
-our $EXE_SUFFIX;
-our $TIMEOUT;
-our $REPORTDIR;
-our $buryChildren;
-our $timeoutChildren;
-our $totalExecuted;
-our $totalStarted;
-our $totalTimedOut;
-our $currentDirectory;
-our $testRoot;
-
-# Where do we run this script? What directory?
-$SEARCH_PATH=$ARGV[0];
-if(!$SEARCH_PATH)
-{
- print "Please specify the search directory! \n";
- exit(0);
-}
-
-# We have four options:
-# 'U': Unix
-# 'W': Windows
-# 'M': Mac
-# 'E': Embedded
-$EXEC_MODE=$ARGV[1];
-if($EXEC_MODE =~ /^U$/)
-{
- print "Using Unix execution mode\n";
- $EXE_PREFIX="./";
- $EXE_SUFFIX="";
-} elsif($EXEC_MODE =~ /^W$/)
-{
- print "Using Windows execution mode\n";
- $EXE_PREFIX="";
- $EXE_SUFFIX=".exe";
-} elsif($EXEC_MODE =~ /^M$/)
-{
- print "Using OSX execution mode\n";
- $EXE_PREFIX="/Contents/MacOS/";
- $EXE_SUFFIX=".app";
-} elsif($EXEC_MODE =~ /^E$/)
-{
- print "Using embedded execution mode\n";
- $EXE_PREFIX="./";
- $EXE_SUFFIX="";
-} else {
- print "Unknown execution mode: $EXEC_MODE \n";
- print "Use: 'U' (Unix), 'W' (Windows), 'M' (MacOSX)\n";
- exit(0);
-}
-# We get the current directory, we 'll need it afterwards
-$currentDirectory = getcwd();
-
-$testRoot = Cwd::abs_path($SEARCH_PATH);
-
-# We assume that by default goes to "reports" unless the user specifies it.
-$REPORTDIR = $ARGV[2];
-if(!$REPORTDIR)
-{
- $REPORTDIR = $testRoot."/reports";
- mkdir $REPORTDIR;
-} else {
- mkdir $REPORTDIR;
- $REPORTDIR = Cwd::abs_path($REPORTDIR);
-}
-
-# If given we use it, otherwise we default to 300 seconds.
-$TIMEOUT = $ARGV[3];
-if(!$TIMEOUT)
-{
- $TIMEOUT=300;
-}
-print "Timeout value: $TIMEOUT\n";
-
-# Initialize 'global' variables
-$buryChildren = 0;
-$timeoutChildren = 0;
-$totalExecuted = 0;
-$totalStarted = 0;
-$totalTimedOut = 0;
-
-# Install signal handlers and pray for the best
-$SIG{'CHLD'} = 'handleDeath';
-$SIG{'ALRM'} = 'handleTimeout';
-
-handleDir($testRoot);
-
-print " ** Statistics ** \n";
-print " Tests started: $totalStarted \n";
-print " Tests executed: $totalExecuted \n";
-print " Tests timed out: $totalTimedOut \n";
-
-sub handleDir {
-
- my ($dir) = @_;
- my $currentDir = getcwd();
-
- opendir(DIR, $dir);
- my @files = readdir(DIR);
- closedir DIR;
- my $file;
- foreach $file (@files) {
- #skip hidden files
- next if (substr($file,0,1) eq ".");
-
- if ( -d $dir."/".$file) {
- handleDir($dir."/".$file)
- } elsif ( $file =~ /^tst_/ and -x $dir."/".$file ) {
- chdir($dir) || die("Could not chdir to $dir");
- executeTestCurrentDir($file);
- chdir($currentDir);
- }
- }
-}
-
-sub executeTestCurrentDir {
- my ($command) = @_;
- print "Executing $command \n";
- my $myPid;
- $myPid = fork();
- if($myPid == 0)
- {
- my $realCommand;
- if($EXEC_MODE =~/^M$/)
- {
- $realCommand = "./".$command.$EXE_SUFFIX.$EXE_PREFIX.$command;
- } else {
- $realCommand = $EXE_PREFIX.$command.$EXE_SUFFIX;
- }
- my $outputRedirection = $REPORTDIR."/".$command.$EXE_SUFFIX.".xml";
-
- if($EXEC_MODE =~ /^E$/)
- {
- exec($realCommand, "-qws", "-xml", "-o", $outputRedirection);
- } else {
- exec($realCommand, "-xml", "-o", $outputRedirection);
- }
- exit(0);
- } elsif($myPid > 0 )
- {
- $totalStarted++;
- alarm($TIMEOUT);
- while(!$buryChildren && !$timeoutChildren)
- {
- sleep 10;
- }
- if($buryChildren)
- {
- my $value;
- $value = waitpid($myPid , 0);
- $buryChildren = 0;
- $totalExecuted++;
- } elsif($timeoutChildren)
- {
- kill 'INT', $myPid;
- $timeoutChildren = 0;
- $totalTimedOut++;
- } else {
- # What?? If we get here we need to abort, this is totally unexpected
- print "Wrong condition evaluated, aborting to avoid damages\n";
- exit(0);
- }
- # We need to handle children killed because of timeout
- if($buryChildren)
- {
- my $value;
- $value = waitpid($myPid , 0);
- $buryChildren = 0;
- }
- } else {
- print "Problems trying to execute $command";
- }
-
-}
-
-# This procedure takes care of handling dead children on due time
-sub handleDeath {
- $buryChildren = 1;
-}
-
-# This takes care of timeouts
-sub handleTimeout {
- $timeoutChildren = 1;
-}
-
diff --git a/tests/auto/widgets/kernel/qapplication/test/test.pro b/tests/auto/widgets/kernel/qapplication/test/test.pro
index 92409e4bfe..7f75501474 100644
--- a/tests/auto/widgets/kernel/qapplication/test/test.pro
+++ b/tests/auto/widgets/kernel/qapplication/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT += widgets widgets-private testlib
QT += core-private gui-private
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro b/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro
index 17fc1d28b5..50069b7e3e 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro
+++ b/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-mac:CONFIG -= app_bundle
TARGET = tst_qwindowcontainer
QT += widgets testlib
SOURCES += tst_qwindowcontainer.cpp
diff --git a/tests/auto/widgets/widgets/qmenubar/BLACKLIST b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
index 4f9508266c..d5c3bdb93f 100644
--- a/tests/auto/widgets/widgets/qmenubar/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
@@ -5,3 +5,5 @@ ubuntu-14.04
redhatenterpriselinuxworkstation-6.6
[task256322_highlight]
osx
+[taskQTBUG46812_doNotLeaveMenubarHighlighted]
+osx
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 3a4c4545df..52e631ef57 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -130,6 +130,7 @@ private slots:
void cornerWidgets_data();
void cornerWidgets();
void taskQTBUG53205_crashReparentNested();
+ void taskQTBUG46812_doNotLeaveMenubarHighlighted();
#ifdef Q_OS_MACOS
void taskQTBUG56275_reinsertMenuInParentlessQMenuBar();
#endif
@@ -227,9 +228,14 @@ TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb)
menu = mb->addMenu(QStringLiteral("accel1"));
action = menu->addAction(QStringLiteral("&Open...") );
action->setShortcut(Qt::Key_O);
+ result.actions << action;
+
+ action = menu->addAction(QStringLiteral("action"));
+ action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Z));
+ result.actions << action;
+
result.menus << menu;
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*)));
- result.actions << action;
m_lastSimpleAcceleratorId = 0;
m_simpleActivatedCount = 0;
@@ -1518,6 +1524,38 @@ void tst_QMenuBar::slotForTaskQTBUG53205()
taskQTBUG53205MenuBar->setParent(parent);
}
+void tst_QMenuBar::taskQTBUG46812_doNotLeaveMenubarHighlighted()
+{
+ QMainWindow mainWindow;
+ QWidget *centralWidget = new QWidget;
+ centralWidget->setFocusPolicy(Qt::StrongFocus);
+ mainWindow.setCentralWidget(centralWidget);
+ initWindowWithSimpleMenuBar(mainWindow);
+
+ mainWindow.show();
+ QApplication::setActiveWindow(&mainWindow);
+ QVERIFY(QTest::qWaitForWindowActive(&mainWindow));
+
+ QVERIFY(!mainWindow.menuBar()->hasFocus());
+ QCOMPARE(m_simpleActivatedCount, 0);
+
+ QTest::keyPress(&mainWindow, Qt::Key_Alt, Qt::AltModifier);
+ QVERIFY(!mainWindow.menuBar()->hasFocus());
+ QCOMPARE(m_simpleActivatedCount, 0);
+
+ QTest::keyPress(&mainWindow, Qt::Key_Z, Qt::AltModifier);
+ QVERIFY(!mainWindow.menuBar()->hasFocus());
+ QCOMPARE(m_simpleActivatedCount, 2); // the action AND the menu will activate
+
+ QTest::keyRelease(&mainWindow, Qt::Key_Alt, Qt::NoModifier);
+ QVERIFY(!mainWindow.menuBar()->hasFocus());
+ QCOMPARE(m_simpleActivatedCount, 2);
+
+ QTest::keyRelease(&mainWindow, Qt::Key_Z, Qt::NoModifier);
+ QVERIFY(!mainWindow.menuBar()->hasFocus());
+ QCOMPARE(m_simpleActivatedCount, 2);
+}
+
#ifdef Q_OS_MACOS
extern bool tst_qmenubar_taskQTBUG56275(QMenuBar *);
diff --git a/tests/baselineserver/shared/baselineprotocol.cpp b/tests/baselineserver/shared/baselineprotocol.cpp
index 3335ff8ffc..be060ef745 100644
--- a/tests/baselineserver/shared/baselineprotocol.cpp
+++ b/tests/baselineserver/shared/baselineprotocol.cpp
@@ -90,19 +90,14 @@ PlatformInfo PlatformInfo::localHostInfo()
#endif
#if defined(Q_OS_LINUX)
pi.insert(PI_OSName, QLS("Linux"));
- QProcess uname;
- uname.start(QLS("uname"), QStringList() << QLS("-r"));
- if (uname.waitForFinished(3000))
- pi.insert(PI_OSVersion, QString::fromLocal8Bit(uname.readAllStandardOutput().constData()).simplified());
#elif defined(Q_OS_WIN)
pi.insert(PI_OSName, QLS("Windows"));
- pi.insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion()));
-#elif defined(Q_OS_MAC)
- pi.insert(PI_OSName, QLS("MacOS"));
- pi.insert(PI_OSVersion, QString::number(QSysInfo::macVersion()));
+#elif defined(Q_OS_DARWIN)
+ pi.insert(PI_OSName, QLS("Darwin"));
#else
pi.insert(PI_OSName, QLS("Other"));
#endif
+ pi.insert(PI_OSVersion, QSysInfo::kernelVersion());
#ifndef QT_NO_PROCESS
QProcess git;
diff --git a/tests/manual/qstorageinfo/printvolumes.cpp b/tests/manual/qstorageinfo/printvolumes.cpp
index 1b1660b433..31047c2fcd 100644
--- a/tests/manual/qstorageinfo/printvolumes.cpp
+++ b/tests/manual/qstorageinfo/printvolumes.cpp
@@ -48,11 +48,15 @@ void printVolumes(const QList<QStorageInfo> &volumes, int (*printer)(const char
if (info.fileSystemType() != fsAndType)
fsAndType += " (" + info.fileSystemType() + ')';
- printf("%-19s R%c ", fsAndType.constData(), info.isReadOnly() ? 'O' : 'W');
+ printer("%-19s R%c ", fsAndType.constData(), info.isReadOnly() ? 'O' : 'W');
if (fsAndType.size() > 19)
- printf("\n%23s", "");
+ printer("\n%23s", "");
- printf("%10llu %10llu %5u ", info.bytesTotal() / 1024, info.bytesFree() / 1024, info.blockSize());
- printf("%-16s %s\n", qPrintable(info.name()), qPrintable(info.rootPath()));
+ printer("%10llu %10llu %5u ", info.bytesTotal() / 1024, info.bytesFree() / 1024, info.blockSize());
+ if (!info.subvolume().isEmpty())
+ printer("subvol=%-18s ", qPrintable(info.subvolume()));
+ else
+ printer("%-25s ", qPrintable(info.name()));
+ printer("%s\n", qPrintable(info.rootPath()));
}
}
diff --git a/tests/manual/qsysinfo/main.cpp b/tests/manual/qsysinfo/main.cpp
index 5add1e4f74..5b391e5dfd 100644
--- a/tests/manual/qsysinfo/main.cpp
+++ b/tests/manual/qsysinfo/main.cpp
@@ -27,11 +27,12 @@
****************************************************************************/
#include <QCoreApplication>
+#include <QOperatingSystemVersion>
#include <QSysInfo>
#include <stdio.h>
-// I'm lazy
+#if QT_DEPRECATED_SINCE(5, 9)
#define CASE_VERSION(v) case QSysInfo::v: return QT_STRINGIFY(v)
QByteArray windowsVersionToString(QSysInfo::WinVersion v)
@@ -108,6 +109,7 @@ QByteArray macVersionToString(QSysInfo::MacVersion v)
}
return "MacVersion(Q_MV_OSX(10, " + QByteArray::number(v - 2) + "))";
}
+#endif
int main(int argc, char *argv[])
{
@@ -116,10 +118,12 @@ int main(int argc, char *argv[])
printf("QSysInfo::WordSize = %d\n", QSysInfo::WordSize);
printf("QSysInfo::ByteOrder = QSysInfo::%sEndian\n",
QSysInfo::ByteOrder == QSysInfo::LittleEndian ? "Little" : "Big");
+#if QT_DEPRECATED_SINCE(5, 9)
printf("QSysInfo::WindowsVersion = QSysInfo::%s\n",
windowsVersionToString(QSysInfo::WindowsVersion).constData());
printf("QSysInfo::MacintoshVersion = QSysInfo::%s\n",
macVersionToString(QSysInfo::MacintoshVersion).constData());
+#endif
printf("QSysInfo::buildCpuArchitecture() = %s\n", qPrintable(QSysInfo::buildCpuArchitecture()));
printf("QSysInfo::currentCpuArchitecture() = %s\n", qPrintable(QSysInfo::currentCpuArchitecture()));
printf("QSysInfo::buildAbi() = %s\n", qPrintable(QSysInfo::buildAbi()));
@@ -130,5 +134,12 @@ int main(int argc, char *argv[])
printf("QSysInfo::prettyProductName() = %s\n", qPrintable(QSysInfo::prettyProductName()));
printf("QSysInfo::machineHostName() = %s\n", qPrintable(QSysInfo::machineHostName()));
+ const auto osv = QOperatingSystemVersion::current();
+ printf("QOperatingSystemVersion::current() = %s %d.%d.%d\n",
+ qPrintable(osv.name()),
+ osv.majorVersion(),
+ osv.minorVersion(),
+ osv.microVersion());
+
return 0;
}
diff --git a/tests/manual/windowchildgeometry/controllerwidget.cpp b/tests/manual/windowchildgeometry/controllerwidget.cpp
index afea71f171..1d18c5d51b 100644
--- a/tests/manual/windowchildgeometry/controllerwidget.cpp
+++ b/tests/manual/windowchildgeometry/controllerwidget.cpp
@@ -284,7 +284,7 @@ public:
{
setObjectName(QStringLiteral("window"));
setTitle(tr("TestWindow"));
- setFlags(flags() | Qt::MacUseNSWindow);
+ setProperty("_q_platform_MacUseNSWindow", QVariant(true));
}
protected:
@@ -317,7 +317,7 @@ void Window::mousePressEvent(QMouseEvent * ev)
m_mouseDownPosition = ev->pos();
}
-void Window::mouseReleaseEvent(QMouseEvent * e)
+void Window::mouseReleaseEvent(QMouseEvent *)
{
m_mouseDownPosition = QPoint();
}
@@ -408,7 +408,6 @@ WindowControl::WindowControl(QWindow *w )
void WindowControl::refresh()
{
- const QWindow *w = static_cast<const QWindow *>(m_object);
BaseWindowControl::refresh();
}
diff --git a/tools/configure/Makefile.mingw b/tools/configure/Makefile.mingw
index ff960115f9..724084e0c8 100644
--- a/tools/configure/Makefile.mingw
+++ b/tools/configure/Makefile.mingw
@@ -48,6 +48,8 @@ OBJECTS = \
qfsfileengine_win.o \
qfsfileengine_iterator.o \
qiodevice.o \
+ qoperatingsystemversion.o \
+ qoperatingsystemversion_win.o \
qringbuffer.o \
qdebug.o \
qtextstream.o \
diff --git a/tools/configure/Makefile.win32 b/tools/configure/Makefile.win32
index 8ed2ffd23f..80e2a2e5fc 100644
--- a/tools/configure/Makefile.win32
+++ b/tools/configure/Makefile.win32
@@ -37,6 +37,8 @@ OBJECTS = \
qtextcodec.obj \
qglobal.obj \
qnumeric.obj \
+ qoperatingsystemversion.obj \
+ qoperatingsystemversion_win.obj \
qbuffer.obj \
qdatastream.obj \
qdir.obj \
@@ -114,6 +116,8 @@ qutfcodec.obj: $(CORESRC)\codecs\qutfcodec.cpp $(PCH)
qtextcodec.obj: $(CORESRC)\codecs\qtextcodec.cpp $(PCH)
qglobal.obj: $(CORESRC)\global\qglobal.cpp $(PCH)
qnumeric.obj: $(CORESRC)\global\qnumeric.cpp $(PCH)
+qoperatingsystemversion.obj: $(CORESRC)\global\qoperatingsystemversion.cpp $(PCH)
+qoperatingsystemversion_win.obj: $(CORESRC)\global\qoperatingsystemversion_win.cpp $(PCH)
qbuffer.obj: $(CORESRC)\io\qbuffer.cpp $(PCH)
qdatastream.obj: $(CORESRC)\io\qdatastream.cpp $(PCH)
qdir.obj: $(CORESRC)\io\qdir.cpp $(PCH)
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 8716fa88f7..d6ad95c97d 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -895,10 +895,12 @@ void Configure::buildQmake()
<< " qfilesystemiterator_win.o \\" << endl
<< " qfsfileengine_win.o \\" << endl
<< " qlocale_win.o \\" << endl
+ << " qoperatingsystemversion_win.o \\" << endl
<< " qsettings_win.o \\" << endl
<< " qsystemlibrary.o \\" << endl
<< " registry.o" << endl
- << "QTSRCS=\"$(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp\" \\" << endl
+ << "QTSRCS=\"$(SOURCE_PATH)/src/corelib/global/qoperatingsystemversion_win.cpp\" \\" << endl
+ << " \"$(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp\" \\" << endl
<< " \"$(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_win.cpp\" \\" << endl
<< " \"$(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp\" \\" << endl
<< " \"$(SOURCE_PATH)/src/corelib/io/qsettings_win.cpp\" \\" << endl