summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-06-09 13:59:07 +0200
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-06-09 13:59:07 +0200
commit0963be63ce741ef6c7585358c3f3b1cb806b66e8 (patch)
tree6f4964c196b8a52cb15e9efc0388b6a549574460 /src
parent9e6a1351823b3ee3d7e380248f6ef42ff383b014 (diff)
parenteacfbbf64ef90dad8c5cb6b2c812ad64c1100779 (diff)
Merge remote-tracking branch 'qt/dev' into dev-highdpi
Conflicts: src/gui/kernel/qsimpledrag.cpp src/gui/kernel/qwindowsysteminterface.cpp src/gui/kernel/qwindowsysteminterface_p.h src/plugins/platforms/xcb/qxcbwindow.cpp Change-Id: Icd887552ade61d6a2b2527383970f7145aa00faf
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp2
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h4
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp28
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp2
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp5
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp2
-rw-r--r--src/3rdparty/forkfd/forkfd.c56
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-thai.c4
-rw-r--r--src/3rdparty/md4/md4.cpp2
-rw-r--r--src/3rdparty/pcre/AUTHORS6
-rw-r--r--src/3rdparty/pcre/LICENCE9
-rw-r--r--src/3rdparty/pcre/pcre.h4
-rw-r--r--src/3rdparty/pcre/pcre_compile.c10
-rw-r--r--src/3rdparty/pcre/pcre_internal.h9
-rw-r--r--src/3rdparty/pcre/pcre_jit_compile.c7
-rw-r--r--src/3rdparty/pcre/pcre_study.c60
-rw-r--r--src/3rdparty/pcre/sljit/sljitNativeARM_64.c37
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-32-rvk.macros0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-32.macros0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-64.macros0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-int-set.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-interface.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-opt32-settings.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-opt32.c0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-opt64-settings.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakF-1600-unrolling.macros0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakNISTInterface.c0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakNISTInterface.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakSponge.c0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/KeccakSponge.h0
-rw-r--r--[-rwxr-xr-x]src/3rdparty/sha3/brg_endian.h0
-rw-r--r--src/3rdparty/sqlite/sqlite3.c2
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java4
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java25
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtNative.java64
-rw-r--r--src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java2
-rw-r--r--src/android/templates/AndroidManifest.xml4
-rw-r--r--src/angle/patches/0006-ANGLE-Allow-Windows-Phone-to-communicate-swap-region.patch145
-rw-r--r--src/angle/patches/0007-ANGLE-Fix-compilation-without-d3d11.patch57
-rw-r--r--src/angle/src/common/common.pri2
-rw-r--r--src/angle/src/libGLESv2/libGLESv2.pro2
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in10
-rw-r--r--src/corelib/Qt5CoreMacros.cmake6
-rw-r--r--src/corelib/codecs/qicucodec.cpp2
-rw-r--r--src/corelib/codecs/qtextcodec.cpp23
-rw-r--r--src/corelib/codecs/qwindowscodec.cpp4
-rw-r--r--src/corelib/doc/qtcore.qdocconf3
-rw-r--r--src/corelib/doc/snippets/code/doc_src_resources.cpp4
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp5
-rw-r--r--src/corelib/doc/src/statemachine.qdoc32
-rw-r--r--src/corelib/global/qglobal.cpp88
-rw-r--r--src/corelib/global/qglobal.h69
-rw-r--r--src/corelib/global/qlogging.cpp6
-rw-r--r--src/corelib/global/qnamespace.h31
-rw-r--r--src/corelib/global/qnamespace.qdoc65
-rw-r--r--src/corelib/global/qtypetraits.h21
-rw-r--r--src/corelib/io/io.pri2
-rw-r--r--src/corelib/io/qdir.cpp12
-rw-r--r--src/corelib/io/qdir.h11
-rw-r--r--src/corelib/io/qfileselector.cpp12
-rw-r--r--src/corelib/io/qfilesystementry.cpp16
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp4
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents.mm31
-rw-r--r--src/corelib/io/qiodevice.cpp57
-rw-r--r--src/corelib/io/qlockfile.cpp12
-rw-r--r--src/corelib/io/qlockfile_p.h1
-rw-r--r--src/corelib/io/qlockfile_unix.cpp58
-rw-r--r--src/corelib/io/qlockfile_win.cpp73
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice.cpp18
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice_p.h4
-rw-r--r--src/corelib/io/qprocess.cpp1
-rw-r--r--src/corelib/io/qprocess.h11
-rw-r--r--src/corelib/io/qsettings.cpp6
-rw-r--r--src/corelib/io/qstandardpaths.cpp37
-rw-r--r--src/corelib/io/qstandardpaths_ios.mm29
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp24
-rw-r--r--src/corelib/io/qtemporaryfile.cpp4
-rw-r--r--src/corelib/io/qtemporaryfile_p.h2
-rw-r--r--src/corelib/io/qtextstream.cpp12
-rw-r--r--src/corelib/io/qurl.h4
-rw-r--r--src/corelib/io/qwindowspipereader.cpp102
-rw-r--r--src/corelib/io/qwindowspipereader_p.h4
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp5
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel_p.h2
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm17
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp10
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt.cpp12
-rw-r--r--src/corelib/kernel/qfunctions_winrt.h8
-rw-r--r--src/corelib/kernel/qjni.cpp472
-rw-r--r--src/corelib/kernel/qjni_p.h1
-rw-r--r--src/corelib/kernel/qmetatype.h15
-rw-r--r--src/corelib/kernel/qobject.cpp10
-rw-r--r--src/corelib/kernel/qobject_p.h4
-rw-r--r--src/corelib/kernel/qobjectdefs.h1
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp1
-rw-r--r--src/corelib/kernel/qsystemerror.cpp2
-rw-r--r--src/corelib/kernel/qsystemerror_p.h10
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp6
-rw-r--r--src/corelib/mimetypes/qmimetype_p.h2
-rw-r--r--src/corelib/plugin/plugin.pri1
-rw-r--r--src/corelib/plugin/qfactoryinterface.cpp (renamed from src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm)13
-rw-r--r--src/corelib/plugin/qfactoryinterface.h2
-rw-r--r--src/corelib/statemachine/qabstracttransition.cpp46
-rw-r--r--src/corelib/statemachine/qabstracttransition.h10
-rw-r--r--src/corelib/statemachine/qabstracttransition_p.h1
-rw-r--r--src/corelib/statemachine/qeventtransition.cpp4
-rw-r--r--src/corelib/statemachine/qeventtransition_p.h3
-rw-r--r--src/corelib/statemachine/qstate_p.h2
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp341
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h21
-rw-r--r--src/corelib/thread/qexception.cpp16
-rw-r--r--src/corelib/thread/qexception.h10
-rw-r--r--src/corelib/thread/qrunnable.cpp11
-rw-r--r--src/corelib/thread/qrunnable.h9
-rw-r--r--src/corelib/thread/qthread_p.h14
-rw-r--r--src/corelib/tools/qbytearray.cpp7
-rw-r--r--src/corelib/tools/qcollator.cpp22
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp8
-rw-r--r--src/corelib/tools/qcontiguouscache.h2
-rw-r--r--src/corelib/tools/qdatetimeparser.cpp14
-rw-r--r--src/corelib/tools/qdatetimeparser_p.h3
-rw-r--r--src/corelib/tools/qhash.h25
-rw-r--r--src/corelib/tools/qlist.h10
-rw-r--r--src/corelib/tools/qlocale_mac.mm14
-rw-r--r--src/corelib/tools/qpair.qdoc54
-rw-r--r--src/corelib/tools/qregularexpression.cpp20
-rw-r--r--src/corelib/tools/qringbuffer.cpp309
-rw-r--r--src/corelib/tools/qringbuffer_p.h266
-rw-r--r--src/corelib/tools/qscopedpointer.cpp7
-rw-r--r--src/corelib/tools/qset.h30
-rw-r--r--src/corelib/tools/qset.qdoc25
-rw-r--r--src/corelib/tools/qsimd.cpp4
-rw-r--r--src/corelib/tools/qsize.h20
-rw-r--r--src/corelib/tools/qstring.cpp112
-rw-r--r--src/corelib/tools/qstring.h2
-rw-r--r--src/corelib/tools/qvector.cpp22
-rw-r--r--src/corelib/tools/qvector.h2
-rw-r--r--src/corelib/tools/tools.pri1
-rw-r--r--src/dbus/qdbus_symbols_p.h3
-rw-r--r--src/dbus/qdbusunixfiledescriptor.cpp6
-rw-r--r--src/dbus/qdbusvirtualobject.cpp6
-rw-r--r--src/gui/accessible/qaccessible.cpp128
-rw-r--r--src/gui/accessible/qaccessible.h38
-rw-r--r--src/gui/image/qicon.cpp2
-rw-r--r--src/gui/image/qicon.h12
-rw-r--r--src/gui/image/qimage.cpp16
-rw-r--r--src/gui/image/qimage.h9
-rw-r--r--src/gui/image/qimageiohandler.cpp37
-rw-r--r--src/gui/image/qimageiohandler.h19
-rw-r--r--src/gui/image/qimagereader.cpp63
-rw-r--r--src/gui/image/qimagereader.h5
-rw-r--r--src/gui/image/qimagewriter.cpp39
-rw-r--r--src/gui/image/qimagewriter.h3
-rw-r--r--src/gui/image/qjpeghandler.cpp122
-rw-r--r--src/gui/image/qpicture.h5
-rw-r--r--src/gui/image/qpixmap.h5
-rw-r--r--src/gui/image/qpixmap_win.cpp5
-rw-r--r--src/gui/image/qpnghandler.cpp7
-rw-r--r--src/gui/kernel/qevent.cpp35
-rw-r--r--src/gui/kernel/qevent.h14
-rw-r--r--src/gui/kernel/qgenericpluginfactory.cpp8
-rw-r--r--src/gui/kernel/qguiapplication.cpp19
-rw-r--r--src/gui/kernel/qinputdevicemanager.cpp1
-rw-r--r--src/gui/kernel/qinputdevicemanager_p.h2
-rw-r--r--src/gui/kernel/qkeysequence.cpp11
-rw-r--r--src/gui/kernel/qkeysequence.h6
-rw-r--r--src/gui/kernel/qopenglwindow.cpp244
-rw-r--r--src/gui/kernel/qpalette.h8
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp6
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h1
-rw-r--r--src/gui/kernel/qplatforminputcontextplugin_p.h2
-rw-r--r--src/gui/kernel/qplatformintegrationplugin.h2
-rw-r--r--src/gui/kernel/qplatformmenu.cpp5
-rw-r--r--src/gui/kernel/qplatformmenu.h1
-rw-r--r--src/gui/kernel/qplatformopenglcontext.cpp4
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow.cpp10
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow_p.h2
-rw-r--r--src/gui/kernel/qsimpledrag.cpp15
-rw-r--r--src/gui/kernel/qtouchdevice.cpp23
-rw-r--r--src/gui/kernel/qtouchdevice.h9
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp85
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h13
-rw-r--r--src/gui/math3d/qgenericmatrix.h2
-rw-r--r--src/gui/math3d/qquaternion.cpp14
-rw-r--r--src/gui/math3d/qquaternion.h22
-rw-r--r--src/gui/math3d/qvector2d.h2
-rw-r--r--src/gui/math3d/qvector4d.h2
-rw-r--r--src/gui/opengl/qopengl.cpp13
-rw-r--r--src/gui/opengl/qopenglengineshadermanager.cpp2
-rw-r--r--src/gui/opengl/qopenglextensions_p.h3
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp66
-rw-r--r--src/gui/opengl/qopenglpaintdevice.cpp4
-rw-r--r--src/gui/opengl/qopenglpaintdevice_p.h2
-rw-r--r--src/gui/painting/qbrush.cpp2
-rw-r--r--src/gui/painting/qbrush.h5
-rw-r--r--src/gui/painting/qcolor.cpp8
-rw-r--r--src/gui/painting/qdrawhelper.cpp6
-rw-r--r--src/gui/painting/qdrawhelper_p.h4
-rw-r--r--src/gui/painting/qimagescale.cpp213
-rw-r--r--src/gui/painting/qimagescale_sse4.cpp42
-rw-r--r--src/gui/painting/qpagedpaintdevice.cpp4
-rw-r--r--src/gui/painting/qpagedpaintdevice_p.h4
-rw-r--r--src/gui/painting/qpaintdevice.cpp2
-rw-r--r--src/gui/painting/qpaintdevice.h2
-rw-r--r--src/gui/painting/qpaintengine.cpp4
-rw-r--r--src/gui/painting/qpaintengine_p.h3
-rw-r--r--src/gui/painting/qpaintengineex.cpp8
-rw-r--r--src/gui/painting/qpainter.cpp4
-rw-r--r--src/gui/painting/qpainterpath.cpp19
-rw-r--r--src/gui/painting/qpainterpath.h22
-rw-r--r--src/gui/painting/qpdf.cpp2
-rw-r--r--src/gui/painting/qplatformbackingstore.cpp129
-rw-r--r--src/gui/painting/qplatformbackingstore.h17
-rw-r--r--src/gui/painting/qpolygon.h8
-rw-r--r--src/gui/painting/qregion.h4
-rw-r--r--src/gui/painting/qstroker_p.h2
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp10
-rw-r--r--src/gui/painting/qtextureglyphcache_p.h4
-rw-r--r--src/gui/painting/qtransform.cpp2
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.cpp9
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.h2
-rw-r--r--src/gui/text/qabstracttextdocumentlayout_p.h3
-rw-r--r--src/gui/text/qfont.h2
-rw-r--r--src/gui/text/qfontdatabase.cpp74
-rw-r--r--src/gui/text/qfontdatabase.h2
-rw-r--r--src/gui/text/qfontengine.cpp2
-rw-r--r--src/gui/text/qfontengine_ft.cpp2
-rw-r--r--src/gui/text/qfontengine_qpf2.cpp2
-rw-r--r--src/gui/text/qfontengineglyphcache.cpp (renamed from src/plugins/platforms/cocoa/qcocoaautoreleasepool.h)22
-rw-r--r--src/gui/text/qfontengineglyphcache_p.h4
-rw-r--r--src/gui/text/qfontmetrics.h5
-rw-r--r--src/gui/text/qglyphrun.cpp1
-rw-r--r--src/gui/text/qrawfont.cpp1
-rw-r--r--src/gui/text/qstatictext.cpp5
-rw-r--r--src/gui/text/qstatictext_p.h5
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp8
-rw-r--r--src/gui/text/qtextdocument.cpp2
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp2
-rw-r--r--src/gui/text/qtextengine.cpp10
-rw-r--r--src/gui/text/qtextengine_p.h8
-rw-r--r--src/gui/text/qtextlayout.cpp44
-rw-r--r--src/gui/text/qtextlayout.h8
-rw-r--r--src/gui/text/qtexttable.cpp6
-rw-r--r--src/gui/text/qzip.cpp2
-rw-r--r--src/gui/text/text.pri2
-rw-r--r--src/network/access/qftp.cpp5
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp35
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel_p.h2
-rw-r--r--src/network/access/qhttpprotocolhandler.cpp7
-rw-r--r--src/network/access/qhttpthreaddelegate_p.h36
-rw-r--r--src/network/access/qnetworkaccessauthenticationmanager_p.h2
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp41
-rw-r--r--src/network/access/qnetworkcookie.cpp2
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp25
-rw-r--r--src/network/access/qnetworkreplyhttpimpl_p.h7
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp1
-rw-r--r--src/network/doc/src/ssl.qdoc2
-rw-r--r--src/network/kernel/qhostinfo_winrt.cpp1
-rw-r--r--src/network/socket/qabstractsocket.cpp1
-rw-r--r--src/network/socket/qabstractsocket_p.h1
-rw-r--r--src/network/socket/qnativesocketengine_winrt_p.h1
-rw-r--r--src/network/ssl/qasn1element.cpp52
-rw-r--r--src/network/ssl/qsslcertificate.cpp2
-rw-r--r--src/network/ssl/qsslellipticcurve_dummy.cpp2
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp31
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager.cpp2
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp18
-rw-r--r--src/platformheaders/helper/helper.pri2
-rw-r--r--src/platformheaders/helper/qplatformheaderhelper.h (renamed from src/platformheaders/xcbfunctions/qxcbfunctionshelper.h)13
-rw-r--r--src/platformheaders/platformheaders.pro1
-rw-r--r--src/platformheaders/xcbfunctions/qxcbintegrationfunctions.h4
-rw-r--r--src/platformheaders/xcbfunctions/qxcbwindowfunctions.h12
-rw-r--r--src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc2
-rw-r--r--src/platformsupport/dbusmenu/qdbusplatformmenu.cpp9
-rw-r--r--src/platformsupport/dbusmenu/qdbusplatformmenu_p.h4
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm14
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositor.cpp31
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp3
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm37
-rw-r--r--src/plugins/generic/evdevkeyboard/main.cpp2
-rw-r--r--src/plugins/generic/evdevmouse/main.cpp2
-rw-r--r--src/plugins/generic/evdevtablet/main.cpp2
-rw-r--r--src/plugins/generic/evdevtouch/main.cpp2
-rw-r--r--src/plugins/generic/libinput/main.cpp2
-rw-r--r--src/plugins/generic/tslib/main.cpp2
-rw-r--r--src/plugins/generic/tuiotouch/main.cpp2
-rw-r--r--src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontextmain.cpp2
-rw-r--r--src/plugins/platforminputcontexts/ibus/main.cpp2
-rw-r--r--src/plugins/platforms/android/androidjniinput.cpp47
-rw-r--r--src/plugins/platforms/android/androidplatformplugin.cpp2
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp2
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro2
-rw-r--r--src/plugins/platforms/cocoa/main.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.mm1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm11
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm35
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoainputcontext.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm53
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm9
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaprintdevice.h5
-rw-r--r--src/plugins/platforms/cocoa/qcocoaprintdevice.mm28
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemsettings.mm3
-rw-r--r--[-rwxr-xr-x]src/plugins/platforms/cocoa/qcocoasystemtrayicon.h0
-rw-r--r--[-rwxr-xr-x]src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm0
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm78
-rw-r--r--src/plugins/platforms/cocoa/qmacclipboard.mm3
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm76
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm7
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac_p.h2
-rw-r--r--src/plugins/platforms/cocoa/qt_mac_p.h11
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp22
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dplatformplugin.cpp2
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp2
-rw-r--r--src/plugins/platforms/directfb/main.cpp2
-rw-r--r--src/plugins/platforms/directfb/qdirectfbconvenience.cpp2
-rw-r--r--[-rwxr-xr-x]src/plugins/platforms/eglfs/cursor-atlas.pngbin2236 -> 2236 bytes
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp45
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp25
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.h6
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp9
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h3
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp5
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h7
-rw-r--r--src/plugins/platforms/eglfs/qeglfsmain.cpp2
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.cpp2
-rw-r--r--src/plugins/platforms/haiku/main.h2
-rw-r--r--src/plugins/platforms/haiku/qhaikuwindow.cpp13
-rw-r--r--src/plugins/platforms/ios/plugin.mm2
-rw-r--r--src/plugins/platforms/ios/qiosapplicationstate.mm12
-rw-r--r--src/plugins/platforms/ios/qiosbackingstore.h8
-rw-r--r--src/plugins/platforms/ios/qiosbackingstore.mm109
-rw-r--r--src/plugins/platforms/ios/qiosclipboard.mm4
-rw-r--r--src/plugins/platforms/ios/qioscontext.mm6
-rw-r--r--src/plugins/platforms/ios/qioseventdispatcher.mm6
-rw-r--r--src/plugins/platforms/ios/qiosfileengineassetslibrary.h7
-rw-r--r--src/plugins/platforms/ios/qiosfileengineassetslibrary.mm320
-rw-r--r--src/plugins/platforms/ios/qiosglobal.h2
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm4
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm2
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm15
-rw-r--r--src/plugins/platforms/ios/qiosmenu.mm4
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm8
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm34
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.mm6
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm6
-rw-r--r--src/plugins/platforms/ios/quiaccessibilityelement.h4
-rw-r--r--src/plugins/platforms/ios/quiaccessibilityelement.mm26
-rw-r--r--src/plugins/platforms/ios/quiview.mm14
-rw-r--r--src/plugins/platforms/kms/main.cpp2
-rw-r--r--src/plugins/platforms/linuxfb/main.cpp2
-rw-r--r--src/plugins/platforms/minimal/main.cpp2
-rw-r--r--src/plugins/platforms/minimalegl/main.cpp2
-rw-r--r--src/plugins/platforms/offscreen/main.cpp2
-rw-r--r--src/plugins/platforms/openwfd/main.cpp2
-rw-r--r--src/plugins/platforms/qnx/main.h2
-rw-r--r--src/plugins/platforms/windows/accessible/iaccessible2.cpp2
-rw-r--r--src/plugins/platforms/windows/main.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp16
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.h3
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.h2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp2
-rw-r--r--src/plugins/platforms/winrt/main.cpp25
-rw-r--r--src/plugins/platforms/winrt/qwinrtbackingstore.cpp23
-rw-r--r--src/plugins/platforms/winrt/qwinrtbackingstore.h23
-rw-r--r--src/plugins/platforms/winrt/qwinrtcursor.cpp28
-rw-r--r--src/plugins/platforms/winrt/qwinrtcursor.h27
-rw-r--r--src/plugins/platforms/winrt/qwinrteglcontext.cpp37
-rw-r--r--src/plugins/platforms/winrt/qwinrteglcontext.h24
-rw-r--r--src/plugins/platforms/winrt/qwinrteventdispatcher.cpp23
-rw-r--r--src/plugins/platforms/winrt/qwinrteventdispatcher.h23
-rw-r--r--src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp23
-rw-r--r--src/plugins/platforms/winrt/qwinrtfiledialoghelper.h23
-rw-r--r--src/plugins/platforms/winrt/qwinrtfileengine.cpp23
-rw-r--r--src/plugins/platforms/winrt/qwinrtfileengine.h27
-rw-r--r--src/plugins/platforms/winrt/qwinrtfontdatabase.cpp112
-rw-r--r--src/plugins/platforms/winrt/qwinrtfontdatabase.h29
-rw-r--r--src/plugins/platforms/winrt/qwinrtinputcontext.cpp23
-rw-r--r--src/plugins/platforms/winrt/qwinrtinputcontext.h23
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.cpp23
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.h23
-rw-r--r--src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp23
-rw-r--r--src/plugins/platforms/winrt/qwinrtmessagedialoghelper.h23
-rw-r--r--src/plugins/platforms/winrt/qwinrtscreen.cpp23
-rw-r--r--src/plugins/platforms/winrt/qwinrtscreen.h23
-rw-r--r--src/plugins/platforms/winrt/qwinrtservices.cpp23
-rw-r--r--src/plugins/platforms/winrt/qwinrtservices.h27
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.cpp23
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.h23
-rw-r--r--src/plugins/platforms/winrt/qwinrtwindow.cpp23
-rw-r--r--src/plugins/platforms/winrt/qwinrtwindow.h23
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro2
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp79
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h34
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp450
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp31
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbmain.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp124
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h10
-rw-r--r--src/plugins/platforms/xcb/xcb_qpa_lib.pro5
-rw-r--r--src/plugins/platformthemes/gtk2/main.cpp2
-rw-r--r--src/plugins/printsupport/cocoa/main.cpp2
-rw-r--r--src/plugins/printsupport/cups/main.cpp2
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.cpp24
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.h7
-rw-r--r--src/plugins/printsupport/windows/main.cpp2
-rw-r--r--src/plugins/printsupport/windows/qwindowsprintdevice.cpp17
-rw-r--r--src/plugins/printsupport/windows/qwindowsprintdevice.h7
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/button/core_button_inactive.pngbin2428 -> 2428 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/button/core_button_pressed.pngbin3221 -> 3221 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.pngbin2776 -> 2776 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.pngbin1315 -> 1315 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.pngbin394 -> 394 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/listitem/core_listitem_active.pngbin164 -> 164 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.pngbin135 -> 135 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.pngbin1802 -> 1802 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.pngbin4245 -> 4245 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.pngbin5460 -> 5460 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.pngbin1242 -> 1242 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.pngbin6577 -> 6577 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/button/core_button_inactive.pngbin2262 -> 2262 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/button/core_button_pressed.pngbin2853 -> 2853 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.pngbin2478 -> 2478 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.pngbin1315 -> 1315 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.pngbin394 -> 394 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/listitem/core_listitem_active.pngbin164 -> 164 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.pngbin136 -> 136 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.pngbin1724 -> 1724 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.pngbin3968 -> 3968 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.pngbin4777 -> 4777 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.pngbin1245 -> 1245 bytes
-rw-r--r--[-rwxr-xr-x]src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.pngbin6593 -> 6593 bytes
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_mac.mm3
-rw-r--r--src/printsupport/dialogs/qprintdialog_mac.mm3
-rw-r--r--src/printsupport/kernel/qplatformprintdevice.cpp5
-rw-r--r--src/printsupport/kernel/qplatformprintdevice.h7
-rw-r--r--src/printsupport/kernel/qplatformprintplugin.h2
-rw-r--r--src/printsupport/kernel/qprintdevice.cpp2
-rw-r--r--src/printsupport/kernel/qprintdevice_p.h2
-rw-r--r--src/printsupport/kernel/qprinter.cpp4
-rw-r--r--src/printsupport/widgets/qprintpreviewwidget.cpp4
-rw-r--r--src/sql/kernel/qsqlresult.cpp3
-rw-r--r--src/sql/models/qsqltablemodel.cpp8
-rw-r--r--src/testlib/doc/qttestlib.qdocconf3
-rw-r--r--src/testlib/qtest.h31
-rw-r--r--src/testlib/qtestblacklist.cpp27
-rw-r--r--src/testlib/qtestblacklist_p.h6
-rw-r--r--src/testlib/qtestcase.cpp24
-rw-r--r--src/testlib/qtestcase.h2
-rw-r--r--src/testlib/qtestmouse.cpp47
-rw-r--r--src/testlib/qtestmouse.h80
-rw-r--r--src/testlib/testlib.pro1
-rw-r--r--src/tools/bootstrap/bootstrap.pro1
-rw-r--r--src/tools/moc/generator.cpp6
-rw-r--r--src/tools/moc/preprocessor.cpp8
-rw-r--r--src/tools/qdoc/atom.cpp4
-rw-r--r--src/tools/qdoc/atom.h2
-rw-r--r--src/tools/qdoc/codeparser.cpp27
-rw-r--r--src/tools/qdoc/cppcodeparser.cpp34
-rw-r--r--src/tools/qdoc/cppcodeparser.h1
-rw-r--r--src/tools/qdoc/doc.cpp23
-rw-r--r--src/tools/qdoc/doc/qdoc-manual-cmdindex.qdoc1
-rw-r--r--src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc40
-rw-r--r--src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc14
-rw-r--r--src/tools/qdoc/htmlgenerator.cpp65
-rw-r--r--src/tools/qdoc/location.cpp4
-rw-r--r--src/tools/qdoc/node.cpp12
-rw-r--r--src/tools/qdoc/puredocparser.cpp4
-rw-r--r--src/tools/qdoc/qdocdatabase.cpp4
-rw-r--r--src/tools/qdoc/qmlcodeparser.cpp2
-rw-r--r--src/tools/qdoc/qmlvisitor.cpp3
-rw-r--r--src/tools/qdoc/tree.cpp8
-rw-r--r--src/widgets/accessible/itemviews.cpp3
-rw-r--r--src/widgets/dialogs/qdialog.cpp5
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp6
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp2
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp6
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp50
-rw-r--r--src/widgets/dialogs/qwizard_win_p.h1
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/images/listview.pngbin9695 -> 9695 bytes
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/images/modelview-combobox.pngbin5022 -> 5022 bytes
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/images/tableview.pngbin10102 -> 10102 bytes
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/snippets/macmainwindow.mm0
-rw-r--r--src/widgets/effects/qgraphicseffect.cpp4
-rw-r--r--src/widgets/effects/qgraphicseffect_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp3
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.h4
-rw-r--r--src/widgets/graphicsview/qgraphicstransform.cpp5
-rw-r--r--src/widgets/graphicsview/qgraphicstransform_p.h4
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsview_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicswidget_p.cpp4
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp3
-rw-r--r--src/widgets/itemviews/qabstractitemview_p.h14
-rw-r--r--src/widgets/itemviews/qcolumnview.cpp4
-rw-r--r--src/widgets/itemviews/qcolumnview_p.h10
-rw-r--r--src/widgets/itemviews/qfileiconprovider.cpp1
-rw-r--r--src/widgets/itemviews/qheaderview.cpp14
-rw-r--r--src/widgets/itemviews/qlistview.cpp57
-rw-r--r--src/widgets/itemviews/qlistview.h3
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp18
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp17
-rw-r--r--src/widgets/itemviews/qtreeview.cpp1
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp8
-rw-r--r--src/widgets/kernel/kernel.pri1
-rw-r--r--src/widgets/kernel/qapplication.cpp23
-rw-r--r--src/widgets/kernel/qapplication_p.h2
-rw-r--r--src/widgets/kernel/qgesture.cpp50
-rw-r--r--src/widgets/kernel/qlayout.cpp81
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp19
-rw-r--r--src/widgets/kernel/qopenglwidget.cpp8
-rw-r--r--src/widgets/kernel/qsizepolicy.cpp (renamed from src/widgets/kernel/qsizepolicy.qdoc)140
-rw-r--r--src/widgets/kernel/qsizepolicy.h3
-rw-r--r--src/widgets/kernel/qwidget.cpp10
-rw-r--r--src/widgets/kernel/qwidgetbackingstore.cpp5
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp13
-rw-r--r--src/widgets/styles/qcommonstylepixmaps_p.h2
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm22
-rw-r--r--src/widgets/styles/qstyle.cpp2
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp2
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp9
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp6
-rw-r--r--src/widgets/util/qflickgesture.cpp14
-rw-r--r--src/widgets/util/qscroller_mac.mm3
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp4
-rw-r--r--src/widgets/widgets/qabstractscrollarea_p.h3
-rw-r--r--src/widgets/widgets/qcombobox.cpp2
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp4
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp12
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp82
-rw-r--r--src/widgets/widgets/qdockarealayout_p.h4
-rw-r--r--src/widgets/widgets/qdockwidget.cpp153
-rw-r--r--src/widgets/widgets/qdockwidget_p.h3
-rw-r--r--src/widgets/widgets/qframe.cpp6
-rw-r--r--src/widgets/widgets/qframe_p.h4
-rw-r--r--src/widgets/widgets/qlabel.cpp4
-rw-r--r--src/widgets/widgets/qlabel_p.h1
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp8
-rw-r--r--src/widgets/widgets/qlineedit_p.h2
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.h1
-rw-r--r--src/widgets/widgets/qmainwindow.cpp9
-rw-r--r--src/widgets/widgets/qmainwindow.h3
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp519
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h24
-rw-r--r--src/widgets/widgets/qmenu.cpp15
-rw-r--r--src/widgets/widgets/qmenubar.cpp2
-rw-r--r--src/widgets/widgets/qsplitter.cpp4
-rw-r--r--src/widgets/widgets/qsplitter_p.h1
-rw-r--r--src/widgets/widgets/qstackedwidget.cpp4
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp2
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp7
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp12
-rw-r--r--src/winmain/qtmain_win.cpp2
-rw-r--r--src/winmain/qtmain_winrt.cpp38
-rw-r--r--src/xml/doc/qtxml.qdocconf3
567 files changed, 7363 insertions, 3487 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp
index 4fde295443..4a87488014 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp
@@ -189,6 +189,7 @@ egl::Error SurfaceD3D::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
return egl::Error(EGL_SUCCESS);
}
+#if !defined(ANGLE_ENABLE_WINDOWS_STORE) || (defined(ANGLE_ENABLE_WINDOWS_STORE) && WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) // Qt WP: eglPostSubBufferNV comes here
if (x + width > mWidth)
{
width = mWidth - x;
@@ -198,6 +199,7 @@ egl::Error SurfaceD3D::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
{
height = mHeight - y;
}
+#endif
if (width == 0 || height == 0)
{
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h
index 81b9ea748d..0f70fe4615 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h
@@ -38,7 +38,7 @@ class InspectableNativeWindow;
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
-#else
+#elif defined(ANGLE_ENABLE_D3D11)
typedef IDXGISwapChain DXGISwapChain;
typedef IDXGIFactory DXGIFactory;
#endif
@@ -60,9 +60,11 @@ class NativeWindow
#endif
static bool isValidNativeWindow(EGLNativeWindowType window);
+#if defined(ANGLE_ENABLE_D3D11)
HRESULT createSwapChain(ID3D11Device* device, DXGIFactory* factory,
DXGI_FORMAT format, UINT width, UINT height,
DXGISwapChain** swapChain);
+#endif
inline EGLNativeWindowType getNativeWindow() const { return mWindow; }
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
index 298f3ccbd2..dc539cf66e 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
@@ -552,18 +552,18 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
d3d11::PositionTexCoordVertex *vertices = static_cast<d3d11::PositionTexCoordVertex*>(mappedResource.pData);
+#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
// Create a quad in homogeneous coordinates
- float x1 = (x / float(mWidth)) * 2.0f - 1.0f;
- float y1 = (y / float(mHeight)) * 2.0f - 1.0f;
- float x2 = ((x + width) / float(mWidth)) * 2.0f - 1.0f;
- float y2 = ((y + height) / float(mHeight)) * 2.0f - 1.0f;
+ float x1 = -1.0f;
+ float y1 = -1.0f;
+ float x2 = 1.0f;
+ float y2 = 1.0f;
-#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
const float dim = std::max(mWidth, mHeight);
- float u1 = x / dim;
- float v1 = y / dim;
- float u2 = (x + width) / dim;
- float v2 = (y + height) / dim;
+ float u1 = 0;
+ float v1 = 0;
+ float u2 = float(width) / dim;
+ float v2 = float(height) / dim;
const NativeWindow::RotationFlags flags = mNativeWindow.rotationFlags();
const bool rotateL = flags == NativeWindow::RotateLeft;
@@ -573,6 +573,12 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
d3d11::SetPositionTexCoordVertex(&vertices[2], x2, y1, rotateR ? u1 : u2, rotateL ? v2 : v1);
d3d11::SetPositionTexCoordVertex(&vertices[3], x2, y2, rotateL ? u1 : u2, rotateR ? v1 : v2);
#else
+ // Create a quad in homogeneous coordinates
+ float x1 = (x / float(mWidth)) * 2.0f - 1.0f;
+ float y1 = (y / float(mHeight)) * 2.0f - 1.0f;
+ float x2 = ((x + width) / float(mWidth)) * 2.0f - 1.0f;
+ float y2 = ((y + height) / float(mHeight)) * 2.0f - 1.0f;
+
float u1 = x / float(mWidth);
float v1 = y / float(mHeight);
float u2 = (x + width) / float(mWidth);
@@ -613,8 +619,8 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
- viewport.Width = (rotateL || rotateR) ? mHeight : mWidth;
- viewport.Height = (rotateL || rotateR) ? mWidth : mHeight;
+ viewport.Width = (rotateL || rotateR) ? height : width;
+ viewport.Height = (rotateL || rotateR) ? width : height;
#else
viewport.Width = mWidth;
viewport.Height = mHeight;
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp
index 9d8f0bb96c..0a4f45b5b7 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp
@@ -37,6 +37,7 @@ bool NativeWindow::isValidNativeWindow(EGLNativeWindowType window)
return IsWindow(window) == TRUE;
}
+#if defined(ANGLE_ENABLE_D3D11)
HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory,
DXGI_FORMAT format, unsigned int width, unsigned int height,
DXGISwapChain** swapChain)
@@ -65,4 +66,5 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory
return factory->CreateSwapChain(device, &swapChainDesc, swapChain);
}
+#endif
}
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
index 350526c867..fa9a69c5a1 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
@@ -100,6 +100,7 @@ bool CoreWindowNativeWindow::registerForSizeChangeEvents()
if (SUCCEEDED(result))
{
result = mDisplayInformation->add_OrientationChanged(orientationChangedHandler.Get(), &mOrientationChangedEventToken);
+ orientationChangedHandler->Invoke(mDisplayInformation.Get(), nullptr);
}
#endif
@@ -135,8 +136,8 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device, DXGIFactor
}
DXGI_SWAP_CHAIN_DESC1 swapChainDesc = { 0 };
- swapChainDesc.Width = width;
- swapChainDesc.Height = height;
+ swapChainDesc.Width = mRotationFlags ? height : width;
+ swapChainDesc.Height = mRotationFlags ? width : height;
swapChainDesc.Format = format;
swapChainDesc.Stereo = FALSE;
swapChainDesc.SampleDesc.Count = 1;
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp b/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
index ded73dbb48..62f3ca1207 100644
--- a/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
@@ -101,12 +101,14 @@ EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLin
return EGL_FALSE;
}
+#if !defined(ANGLE_ENABLE_WINDOWS_STORE) || (defined(ANGLE_ENABLE_WINDOWS_STORE) && WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) // Qt WP: Allow this entry point as a workaround
if (!display->getExtensions().postSubBuffer)
{
// Spec is not clear about how this should be handled.
SetGlobalError(Error(EGL_SUCCESS));
return EGL_TRUE;
}
+#endif
error = eglSurface->postSubBuffer(x, y, width, height);
if (error.isError())
diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c
index 017ae0741e..8d08f403ec 100644
--- a/src/3rdparty/forkfd/forkfd.c
+++ b/src/3rdparty/forkfd/forkfd.c
@@ -63,7 +63,7 @@
# include <Availability.h>
# include <AvailabilityMacros.h>
# if MAC_OS_X_VERSION_MIN_REQUIRED <= 1070
-# define HAVE_BROKEN_WAITID_ALL 1
+# define HAVE_BROKEN_WAITID 1
# endif
#endif
@@ -109,10 +109,10 @@ static struct sigaction old_sigaction;
static pthread_once_t forkfd_initialization = PTHREAD_ONCE_INIT;
static ffd_atomic_int forkfd_status = FFD_ATOMIC_INIT(0);
-#ifdef HAVE_BROKEN_WAITID_ALL
-static int waitid_p_all_works = 0;
+#ifdef HAVE_BROKEN_WAITID
+static int waitid_works = 0;
#else
-static const int waitid_p_all_works = 1;
+static const int waitid_works = 1;
#endif
static ProcessInfo *tryAllocateInSection(Header *header, ProcessInfo entries[], int maxCount)
@@ -183,10 +183,13 @@ static int tryReaping(pid_t pid, siginfo_t *info)
{
/* reap the child */
#ifdef HAVE_WAITID
- // we have waitid(2), which fills in siginfo_t for us
- info->si_pid = 0;
- return waitid(P_PID, pid, info, WEXITED | WNOHANG) == 0 && info->si_pid == pid;
-#else
+ if (waitid_works) {
+ // we have waitid(2), which fills in siginfo_t for us
+ info->si_pid = 0;
+ return waitid(P_PID, pid, info, WEXITED | WNOHANG) == 0 && info->si_pid == pid;
+ }
+#endif
+
int status;
if (waitpid(pid, &status, WNOHANG) <= 0)
return 0; // child did not change state
@@ -206,7 +209,6 @@ static int tryReaping(pid_t pid, siginfo_t *info)
}
return 1;
-#endif
}
static void freeInfo(Header *header, ProcessInfo *entry)
@@ -246,7 +248,7 @@ static void sigchld_handler(int signum)
memset(&info, 0, sizeof info);
#ifdef HAVE_WAITID
- if (!waitid_p_all_works)
+ if (!waitid_works)
goto search_arrays;
/* be optimistic: try to see if we can get the child that exited */
@@ -310,12 +312,14 @@ search_arrays:
if (pid <= 0)
continue;
#ifdef HAVE_WAITID
- /* The child might have been reaped by the block above in another thread,
- * so first check if it's ready and, if it is, lock it */
- if (!isChildReady(pid, &info) ||
- !ffd_atomic_compare_exchange(&children.entries[i].pid, &pid, -1,
- FFD_ATOMIC_RELAXED, FFD_ATOMIC_RELAXED))
- continue;
+ if (waitid_works) {
+ /* The child might have been reaped by the block above in another thread,
+ * so first check if it's ready and, if it is, lock it */
+ if (!isChildReady(pid, &info) ||
+ !ffd_atomic_compare_exchange(&children.entries[i].pid, &pid, -1,
+ FFD_ATOMIC_RELAXED, FFD_ATOMIC_RELAXED))
+ continue;
+ }
#endif
if (tryReaping(pid, &info)) {
/* this is our child, send notification and free up this entry */
@@ -331,12 +335,14 @@ search_arrays:
if (pid <= 0)
continue;
#ifdef HAVE_WAITID
- /* The child might have been reaped by the block above in another thread,
- * so first check if it's ready and, if it is, lock it */
- if (!isChildReady(pid, &info) ||
- !ffd_atomic_compare_exchange(&array->entries[i].pid, &pid, -1,
- FFD_ATOMIC_RELAXED, FFD_ATOMIC_RELAXED))
- continue;
+ if (waitid_works) {
+ /* The child might have been reaped by the block above in another thread,
+ * so first check if it's ready and, if it is, lock it */
+ if (!isChildReady(pid, &info) ||
+ !ffd_atomic_compare_exchange(&array->entries[i].pid, &pid, -1,
+ FFD_ATOMIC_RELAXED, FFD_ATOMIC_RELAXED))
+ continue;
+ }
#endif
if (tryReaping(pid, &info)) {
/* this is our child, send notification and free up this entry */
@@ -357,17 +363,19 @@ chain_handler:
static void forkfd_initialize()
{
-#if defined(HAVE_BROKEN_WAITID_ALL)
+#if defined(HAVE_BROKEN_WAITID)
pid_t pid = fork();
if (pid == 0) {
_exit(0);
} else if (pid > 0) {
siginfo_t info;
waitid(P_ALL, 0, &info, WNOWAIT | WEXITED);
- waitid_p_all_works = (info.si_pid != 0);
+ waitid_works = (info.si_pid != 0);
+ info.si_pid = 0;
// now really reap the child
waitid(P_PID, pid, &info, WEXITED);
+ waitid_works = waitid_works && (info.si_pid != 0);
}
#endif
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c
index 7438d5994c..2d4627e4f7 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c
@@ -241,7 +241,7 @@ static HB_Bool HB_ThaiConvertStringToGlyphIndices (HB_ShaperItem *item)
int lgn = 0;
HB_Bool haveSaraAm = false;
- cell_length = th_next_cell ((const unsigned char *)cstr + i, len - i, &tis_cell, true); /* !item->fixedPitch); */
+ cell_length = (int)(th_next_cell ((const unsigned char *)cstr + i, len - i, &tis_cell, true)); /* !item->fixedPitch); */
haveSaraAm = (cstr[i + cell_length - 1] == (char)0xd3);
/* set shaper item's log_clusters */
@@ -432,7 +432,7 @@ static void HB_ThaiAssignAttributes(const HB_UChar16 *string, hb_uint32 len, HB_
/* manage grapheme boundaries */
i = 0;
while (i < len) {
- cell_length = th_next_cell((const unsigned char *)cstr + i, len - i, &tis_cell, true);
+ cell_length = (hb_uint32)(th_next_cell((const unsigned char *)cstr + i, len - i, &tis_cell, true));
attributes[i].graphemeBoundary = true;
for (j = 1; j < cell_length; j++)
diff --git a/src/3rdparty/md4/md4.cpp b/src/3rdparty/md4/md4.cpp
index 94ac6adf58..ec74958d69 100644
--- a/src/3rdparty/md4/md4.cpp
+++ b/src/3rdparty/md4/md4.cpp
@@ -180,7 +180,7 @@ static void md4_update(struct md4_context *ctx, const unsigned char *data, size_
saved_lo = ctx->lo;
if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
ctx->hi++;
- ctx->hi += size >> 29;
+ ctx->hi += (quint32)(size >> 29);
used = saved_lo & 0x3f;
diff --git a/src/3rdparty/pcre/AUTHORS b/src/3rdparty/pcre/AUTHORS
index 5eee1af4c6..d33723f198 100644
--- a/src/3rdparty/pcre/AUTHORS
+++ b/src/3rdparty/pcre/AUTHORS
@@ -8,7 +8,7 @@ Email domain: cam.ac.uk
University of Cambridge Computing Service,
Cambridge, England.
-Copyright (c) 1997-2014 University of Cambridge
+Copyright (c) 1997-2015 University of Cambridge
All rights reserved
@@ -19,7 +19,7 @@ Written by: Zoltan Herczeg
Email local part: hzmester
Emain domain: freemail.hu
-Copyright(c) 2010-2014 Zoltan Herczeg
+Copyright(c) 2010-2015 Zoltan Herczeg
All rights reserved.
@@ -30,7 +30,7 @@ Written by: Zoltan Herczeg
Email local part: hzmester
Emain domain: freemail.hu
-Copyright(c) 2009-2014 Zoltan Herczeg
+Copyright(c) 2009-2015 Zoltan Herczeg
All rights reserved.
diff --git a/src/3rdparty/pcre/LICENCE b/src/3rdparty/pcre/LICENCE
index 602e4ae680..9f6f98e477 100644
--- a/src/3rdparty/pcre/LICENCE
+++ b/src/3rdparty/pcre/LICENCE
@@ -6,7 +6,8 @@ and semantics are as close as possible to those of the Perl 5 language.
Release 8 of PCRE is distributed under the terms of the "BSD" licence, as
specified below. The documentation for PCRE, supplied in the "doc"
-directory, is distributed under the same terms as the software itself.
+directory, is distributed under the same terms as the software itself. The data
+in the testdata directory is not copyrighted and is in the public domain.
The basic library functions are written in C and are freestanding. Also
included in the distribution is a set of C++ wrapper functions, and a
@@ -24,7 +25,7 @@ Email domain: cam.ac.uk
University of Cambridge Computing Service,
Cambridge, England.
-Copyright (c) 1997-2014 University of Cambridge
+Copyright (c) 1997-2015 University of Cambridge
All rights reserved.
@@ -35,7 +36,7 @@ Written by: Zoltan Herczeg
Email local part: hzmester
Emain domain: freemail.hu
-Copyright(c) 2010-2014 Zoltan Herczeg
+Copyright(c) 2010-2015 Zoltan Herczeg
All rights reserved.
@@ -46,7 +47,7 @@ Written by: Zoltan Herczeg
Email local part: hzmester
Emain domain: freemail.hu
-Copyright(c) 2009-2014 Zoltan Herczeg
+Copyright(c) 2009-2015 Zoltan Herczeg
All rights reserved.
diff --git a/src/3rdparty/pcre/pcre.h b/src/3rdparty/pcre/pcre.h
index 20f04ebed4..58ed46a2a3 100644
--- a/src/3rdparty/pcre/pcre.h
+++ b/src/3rdparty/pcre/pcre.h
@@ -43,8 +43,8 @@ POSSIBILITY OF SUCH DAMAGE.
#define PCRE_MAJOR 8
#define PCRE_MINOR 37
-#define PCRE_PRERELEASE -RC1
-#define PCRE_DATE 2015-02-03
+#define PCRE_PRERELEASE
+#define PCRE_DATE 2015-04-28
/* When an application links to a PCRE DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE, the appropriate
diff --git a/src/3rdparty/pcre/pcre_compile.c b/src/3rdparty/pcre/pcre_compile.c
index 6510835c17..0efad2645d 100644
--- a/src/3rdparty/pcre/pcre_compile.c
+++ b/src/3rdparty/pcre/pcre_compile.c
@@ -866,14 +866,6 @@ static const pcre_uint8 opcode_possessify[] = {
};
-/* Structure for mutual recursion detection. */
-
-typedef struct recurse_check {
- struct recurse_check *prev;
- const pcre_uchar *group;
-} recurse_check;
-
-
/*************************************************
* Find an error text *
@@ -5532,13 +5524,13 @@ for (;; ptr++)
PUT(previous, 1, (int)(code - previous));
break; /* End of class handling */
}
-#endif
/* Even though any XCLASS list is now discarded, we must allow for
its memory. */
if (lengthptr != NULL)
*lengthptr += (int)(class_uchardata - class_uchardata_base);
+#endif
/* If there are no characters > 255, or they are all to be included or
excluded, set the opcode to OP_CLASS or OP_NCLASS, depending on whether the
diff --git a/src/3rdparty/pcre/pcre_internal.h b/src/3rdparty/pcre/pcre_internal.h
index 1c5f4cefd6..dd0ac7fc91 100644
--- a/src/3rdparty/pcre/pcre_internal.h
+++ b/src/3rdparty/pcre/pcre_internal.h
@@ -2446,7 +2446,7 @@ typedef struct compile_data {
BOOL had_pruneorskip; /* (*PRUNE) or (*SKIP) encountered */
BOOL check_lookbehind; /* Lookbehinds need later checking */
BOOL dupnames; /* Duplicate names exist */
- BOOL iscondassert; /* Next assert is a condition */
+ BOOL iscondassert; /* Next assert is a condition */
int nltype; /* Newline type */
int nllen; /* Newline string length */
pcre_uchar nl[4]; /* Newline string when fixed length */
@@ -2460,6 +2460,13 @@ typedef struct branch_chain {
pcre_uchar *current_branch;
} branch_chain;
+/* Structure for mutual recursion detection. */
+
+typedef struct recurse_check {
+ struct recurse_check *prev;
+ const pcre_uchar *group;
+} recurse_check;
+
/* Structure for items in a linked list that represents an explicit recursive
call within the pattern; used by pcre_exec(). */
diff --git a/src/3rdparty/pcre/pcre_jit_compile.c b/src/3rdparty/pcre/pcre_jit_compile.c
index dd378e097b..debdf6ef45 100644
--- a/src/3rdparty/pcre/pcre_jit_compile.c
+++ b/src/3rdparty/pcre/pcre_jit_compile.c
@@ -1533,7 +1533,11 @@ while (cc < ccend)
{
case OP_KET:
if (PRIVATE_DATA(cc) != 0)
+ {
private_data_length++;
+ SLJIT_ASSERT(PRIVATE_DATA(cc + 1) != 0);
+ cc += PRIVATE_DATA(cc + 1);
+ }
cc += 1 + LINK_SIZE;
break;
@@ -1548,6 +1552,7 @@ while (cc < ccend)
case OP_SBRAPOS:
case OP_SCOND:
private_data_length++;
+ SLJIT_ASSERT(PRIVATE_DATA(cc) != 0);
cc += 1 + LINK_SIZE;
break;
@@ -1710,6 +1715,8 @@ do
{
count = 1;
srcw[0] = PRIVATE_DATA(cc);
+ SLJIT_ASSERT(PRIVATE_DATA(cc + 1) != 0);
+ cc += PRIVATE_DATA(cc + 1);
}
cc += 1 + LINK_SIZE;
break;
diff --git a/src/3rdparty/pcre/pcre_study.c b/src/3rdparty/pcre/pcre_study.c
index a2458c4c96..998fe2325e 100644
--- a/src/3rdparty/pcre/pcre_study.c
+++ b/src/3rdparty/pcre/pcre_study.c
@@ -70,7 +70,7 @@ Arguments:
code pointer to start of group (the bracket)
startcode pointer to start of the whole pattern's code
options the compiling options
- int RECURSE depth
+ recurses chain of recurse_check to catch mutual recursion
Returns: the minimum length
-1 if \C in UTF-8 mode or (*ACCEPT) was encountered
@@ -80,12 +80,13 @@ Returns: the minimum length
static int
find_minlength(const REAL_PCRE *re, const pcre_uchar *code,
- const pcre_uchar *startcode, int options, int recurse_depth)
+ const pcre_uchar *startcode, int options, recurse_check *recurses)
{
int length = -1;
/* PCRE_UTF16 has the same value as PCRE_UTF8. */
BOOL utf = (options & PCRE_UTF8) != 0;
BOOL had_recurse = FALSE;
+recurse_check this_recurse;
register int branchlength = 0;
register pcre_uchar *cc = (pcre_uchar *)code + 1 + LINK_SIZE;
@@ -130,7 +131,7 @@ for (;;)
case OP_SBRAPOS:
case OP_ONCE:
case OP_ONCE_NC:
- d = find_minlength(re, cc, startcode, options, recurse_depth);
+ d = find_minlength(re, cc, startcode, options, recurses);
if (d < 0) return d;
branchlength += d;
do cc += GET(cc, 1); while (*cc == OP_ALT);
@@ -393,7 +394,7 @@ for (;;)
ce = cs = (pcre_uchar *)PRIV(find_bracket)(startcode, utf, GET2(slot, 0));
if (cs == NULL) return -2;
do ce += GET(ce, 1); while (*ce == OP_ALT);
- if ((cc > cs && cc < ce) || recurse_depth > 10)
+ if (cc > cs && cc < ce) /* Simple recursion */
{
d = 0;
had_recurse = TRUE;
@@ -401,8 +402,22 @@ for (;;)
}
else
{
- int dd = find_minlength(re, cs, startcode, options, recurse_depth+1);
- if (dd < d) d = dd;
+ recurse_check *r = recurses;
+ for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break;
+ if (r != NULL) /* Mutual recursion */
+ {
+ d = 0;
+ had_recurse = TRUE;
+ break;
+ }
+ else
+ {
+ int dd;
+ this_recurse.prev = recurses;
+ this_recurse.group = cs;
+ dd = find_minlength(re, cs, startcode, options, &this_recurse);
+ if (dd < d) d = dd;
+ }
}
slot += re->name_entry_size;
}
@@ -418,14 +433,26 @@ for (;;)
ce = cs = (pcre_uchar *)PRIV(find_bracket)(startcode, utf, GET2(cc, 1));
if (cs == NULL) return -2;
do ce += GET(ce, 1); while (*ce == OP_ALT);
- if ((cc > cs && cc < ce) || recurse_depth > 10)
+ if (cc > cs && cc < ce) /* Simple recursion */
{
d = 0;
had_recurse = TRUE;
}
else
{
- d = find_minlength(re, cs, startcode, options, recurse_depth + 1);
+ recurse_check *r = recurses;
+ for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break;
+ if (r != NULL) /* Mutual recursion */
+ {
+ d = 0;
+ had_recurse = TRUE;
+ }
+ else
+ {
+ this_recurse.prev = recurses;
+ this_recurse.group = cs;
+ d = find_minlength(re, cs, startcode, options, &this_recurse);
+ }
}
}
else d = 0;
@@ -474,12 +501,21 @@ for (;;)
case OP_RECURSE:
cs = ce = (pcre_uchar *)startcode + GET(cc, 1);
do ce += GET(ce, 1); while (*ce == OP_ALT);
- if ((cc > cs && cc < ce) || recurse_depth > 10)
+ if (cc > cs && cc < ce) /* Simple recursion */
had_recurse = TRUE;
else
{
- branchlength += find_minlength(re, cs, startcode, options,
- recurse_depth + 1);
+ recurse_check *r = recurses;
+ for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break;
+ if (r != NULL) /* Mutual recursion */
+ had_recurse = TRUE;
+ else
+ {
+ this_recurse.prev = recurses;
+ this_recurse.group = cs;
+ branchlength += find_minlength(re, cs, startcode, options,
+ &this_recurse);
+ }
}
cc += 1 + LINK_SIZE;
break;
@@ -1503,7 +1539,7 @@ if ((re->options & PCRE_ANCHORED) == 0 &&
/* Find the minimum length of subject string. */
-switch(min = find_minlength(re, code, code, re->options, 0))
+switch(min = find_minlength(re, code, code, re->options, NULL))
{
case -2: *errorptr = "internal error: missing capturing bracket"; return NULL;
case -3: *errorptr = "internal error: opcode not recognized"; return NULL;
diff --git a/src/3rdparty/pcre/sljit/sljitNativeARM_64.c b/src/3rdparty/pcre/sljit/sljitNativeARM_64.c
index c5251be53d..b66455f756 100644
--- a/src/3rdparty/pcre/sljit/sljitNativeARM_64.c
+++ b/src/3rdparty/pcre/sljit/sljitNativeARM_64.c
@@ -1081,12 +1081,13 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10)));
offs = (local_size - saved_regs_size) << (15 - 3);
} else {
- compiler->local_size += 2 * sizeof(sljit_sw);
- local_size -= saved_regs_size;
- saved_regs_size += 2 * sizeof(sljit_sw);
- FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR)
- | RN(TMP_SP) | ((-(saved_regs_size >> 3) & 0x7f) << 15)));
- offs = 2 << 15;
+ offs = 0 << 15;
+ if (saved_regs_size & 0x8) {
+ offs = 1 << 15;
+ saved_regs_size += sizeof(sljit_sw);
+ }
+ local_size -= saved_regs_size + SLJIT_LOCALS_OFFSET;
+ FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
}
tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
@@ -1122,6 +1123,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
}
if (local_size)
FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10)));
+ FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR)
+ | RN(TMP_SP) | ((-(16 >> 3) & 0x7f) << 15)));
FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10)));
}
@@ -1145,8 +1148,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compi
local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 0) + SLJIT_LOCALS_OFFSET;
local_size = (local_size + 15) & ~0xf;
- if (local_size > (63 * sizeof(sljit_sw)))
- local_size += 2 * sizeof(sljit_sw);
compiler->local_size = local_size;
return SLJIT_SUCCESS;
}
@@ -1167,16 +1168,20 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
if (local_size <= (63 * sizeof(sljit_sw)))
offs = (local_size - saved_regs_size) << (15 - 3);
else {
- saved_regs_size += 2 * sizeof(sljit_sw);
- local_size -= saved_regs_size;
+ FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
+ | RN(TMP_SP) | (((16 >> 3) & 0x7f) << 15)));
+ offs = 0 << 15;
+ if (saved_regs_size & 0x8) {
+ offs = 1 << 15;
+ saved_regs_size += sizeof(sljit_sw);
+ }
+ local_size -= saved_regs_size + SLJIT_LOCALS_OFFSET;
if (local_size > 0xfff) {
FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22)));
local_size &= 0xfff;
}
if (local_size)
FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10)));
- local_size = saved_regs_size;
- offs = 2 << 15;
}
tmp = compiler->saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - compiler->saveds) : SLJIT_FIRST_SAVED_REG;
@@ -1204,8 +1209,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
if (prev != -1)
FAIL_IF(push_inst(compiler, LDRI | RT(prev) | RN(TMP_SP) | (offs >> 5)));
- FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
- | RN(TMP_SP) | (((local_size >> 3) & 0x7f) << 15)));
+ if (compiler->local_size <= (63 * sizeof(sljit_sw))) {
+ FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
+ | RN(TMP_SP) | (((local_size >> 3) & 0x7f) << 15)));
+ } else {
+ FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
+ }
FAIL_IF(push_inst(compiler, RET | RN(TMP_LR)));
return SLJIT_SUCCESS;
diff --git a/src/3rdparty/sha3/KeccakF-1600-32-rvk.macros b/src/3rdparty/sha3/KeccakF-1600-32-rvk.macros
index c0c9029873..c0c9029873 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-32-rvk.macros
+++ b/src/3rdparty/sha3/KeccakF-1600-32-rvk.macros
diff --git a/src/3rdparty/sha3/KeccakF-1600-32.macros b/src/3rdparty/sha3/KeccakF-1600-32.macros
index 9ade600067..9ade600067 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-32.macros
+++ b/src/3rdparty/sha3/KeccakF-1600-32.macros
diff --git a/src/3rdparty/sha3/KeccakF-1600-64.macros b/src/3rdparty/sha3/KeccakF-1600-64.macros
index 0c20bca40f..0c20bca40f 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-64.macros
+++ b/src/3rdparty/sha3/KeccakF-1600-64.macros
diff --git a/src/3rdparty/sha3/KeccakF-1600-int-set.h b/src/3rdparty/sha3/KeccakF-1600-int-set.h
index 0ed1d802e3..0ed1d802e3 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-int-set.h
+++ b/src/3rdparty/sha3/KeccakF-1600-int-set.h
diff --git a/src/3rdparty/sha3/KeccakF-1600-interface.h b/src/3rdparty/sha3/KeccakF-1600-interface.h
index ce2710eeb2..ce2710eeb2 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-interface.h
+++ b/src/3rdparty/sha3/KeccakF-1600-interface.h
diff --git a/src/3rdparty/sha3/KeccakF-1600-opt32-settings.h b/src/3rdparty/sha3/KeccakF-1600-opt32-settings.h
index b135918ca9..b135918ca9 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-opt32-settings.h
+++ b/src/3rdparty/sha3/KeccakF-1600-opt32-settings.h
diff --git a/src/3rdparty/sha3/KeccakF-1600-opt32.c b/src/3rdparty/sha3/KeccakF-1600-opt32.c
index 4e32dca9cb..4e32dca9cb 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-opt32.c
+++ b/src/3rdparty/sha3/KeccakF-1600-opt32.c
diff --git a/src/3rdparty/sha3/KeccakF-1600-opt64-settings.h b/src/3rdparty/sha3/KeccakF-1600-opt64-settings.h
index 8f16ada636..8f16ada636 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-opt64-settings.h
+++ b/src/3rdparty/sha3/KeccakF-1600-opt64-settings.h
diff --git a/src/3rdparty/sha3/KeccakF-1600-unrolling.macros b/src/3rdparty/sha3/KeccakF-1600-unrolling.macros
index 83c694ca48..83c694ca48 100755..100644
--- a/src/3rdparty/sha3/KeccakF-1600-unrolling.macros
+++ b/src/3rdparty/sha3/KeccakF-1600-unrolling.macros
diff --git a/src/3rdparty/sha3/KeccakNISTInterface.c b/src/3rdparty/sha3/KeccakNISTInterface.c
index e530a11db5..e530a11db5 100755..100644
--- a/src/3rdparty/sha3/KeccakNISTInterface.c
+++ b/src/3rdparty/sha3/KeccakNISTInterface.c
diff --git a/src/3rdparty/sha3/KeccakNISTInterface.h b/src/3rdparty/sha3/KeccakNISTInterface.h
index cd85f24aa7..cd85f24aa7 100755..100644
--- a/src/3rdparty/sha3/KeccakNISTInterface.h
+++ b/src/3rdparty/sha3/KeccakNISTInterface.h
diff --git a/src/3rdparty/sha3/KeccakSponge.c b/src/3rdparty/sha3/KeccakSponge.c
index 6f3da95dbb..6f3da95dbb 100755..100644
--- a/src/3rdparty/sha3/KeccakSponge.c
+++ b/src/3rdparty/sha3/KeccakSponge.c
diff --git a/src/3rdparty/sha3/KeccakSponge.h b/src/3rdparty/sha3/KeccakSponge.h
index 8bb11a8a1d..8bb11a8a1d 100755..100644
--- a/src/3rdparty/sha3/KeccakSponge.h
+++ b/src/3rdparty/sha3/KeccakSponge.h
diff --git a/src/3rdparty/sha3/brg_endian.h b/src/3rdparty/sha3/brg_endian.h
index 7226eb3bec..7226eb3bec 100755..100644
--- a/src/3rdparty/sha3/brg_endian.h
+++ b/src/3rdparty/sha3/brg_endian.h
diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c
index 086fb3bcd6..71f6c1036d 100644
--- a/src/3rdparty/sqlite/sqlite3.c
+++ b/src/3rdparty/sqlite/sqlite3.c
@@ -34875,6 +34875,7 @@ static void winLogIoerr(int nRetry){
** create a substitute.
*/
/* #include <time.h> */
+# if _WIN32_WCE < 0x800
struct tm *__cdecl localtime(const time_t *t)
{
static struct tm y;
@@ -34896,6 +34897,7 @@ struct tm *__cdecl localtime(const time_t *t)
y.tm_sec = pTm.wSecond;
return &y;
}
+# endif
#endif
#define HANDLE_TO_WINFILE(a) (winFile*)&((char*)a)[-(int)offsetof(winFile,h)]
diff --git a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java
index 4df70796bd..ff0032d623 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java
@@ -1111,7 +1111,9 @@ public class ExtractStyle {
{
try {
InsetDrawable d = (InsetDrawable)drawable;
- Object mInsetStateObject = getAccessibleField(InsetDrawable.class, "mInsetState").get(d);
+ // mInsetState changed to mState in Android 5.1 (22)
+ Object mInsetStateObject = getAccessibleField(InsetDrawable.class, (Build.VERSION.SDK_INT > 21) ? "mState"
+ : "mInsetState").get(d);
Rect _padding = new Rect();
boolean hasPadding = d.getPadding(_padding);
return getDrawable(getAccessibleField(mInsetStateObject.getClass(), "mDrawable").get(mInsetStateObject), filename, hasPadding ? _padding : null);
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
index da52369de0..18fa2f8fde 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -65,7 +65,6 @@ import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
-import android.widget.LinearLayout;
import java.io.BufferedReader;
import java.io.DataOutputStream;
@@ -790,29 +789,7 @@ public class QtActivityDelegate
metrics.xdpi, metrics.ydpi,
metrics.scaledDensity, metrics.density);
}
-
- ViewGroup layout = null;
m_layout = new QtLayout(m_activity);
- if (Build.VERSION.SDK_INT >= 14) {
- try {
- ActivityInfo activityInfo = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(),
- PackageManager.GET_META_DATA);
- if (activityInfo.metaData == null
- || !activityInfo.metaData.containsKey("android.app.allow_overlapping_system_ui")
- || !activityInfo.metaData.getBoolean("android.app.allow_overlapping_system_ui")) {
- layout = new LinearLayout(m_activity);
- layout.setFitsSystemWindows(true);
- layout.addView(m_layout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- if (layout == null)
- layout = m_layout;
-
m_editText = new QtEditText(m_activity, this);
m_imm = (InputMethodManager)m_activity.getSystemService(Context.INPUT_METHOD_SERVICE);
m_surfaces = new HashMap<Integer, QtSurface>();
@@ -835,7 +812,7 @@ public class QtActivityDelegate
Log.w("Qt A11y", "Unknown exception: " + e.toString());
}
- m_activity.setContentView(layout,
+ m_activity.setContentView(m_layout,
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
index 6855a47554..b7363e5d87 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
@@ -43,6 +43,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.ClipboardManager;
+import android.os.Build;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Menu;
@@ -306,32 +307,49 @@ public class QtNative
static public void sendTouchEvent(MotionEvent event, int id)
{
- //@ANDROID-5
- touchBegin(id);
- for (int i=0;i<event.getPointerCount();i++) {
- touchAdd(id,
- event.getPointerId(i),
- getAction(i, event),
- i == 0,
- (int)event.getX(i),
- (int)event.getY(i),
- event.getSize(i),
- event.getPressure(i));
- }
+ int pointerType = 0;
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- touchEnd(id,0);
+ if (Build.VERSION.SDK_INT >= 14) {
+ switch (event.getToolType(0)) {
+ case MotionEvent.TOOL_TYPE_STYLUS:
+ pointerType = 1; // QTabletEvent::Pen
break;
-
- case MotionEvent.ACTION_UP:
- touchEnd(id,2);
+ case MotionEvent.TOOL_TYPE_ERASER:
+ pointerType = 3; // QTabletEvent::Eraser
break;
+ // TODO TOOL_TYPE_MOUSE
+ }
+ }
- default:
- touchEnd(id,1);
+ if (pointerType != 0) {
+ tabletEvent(id, event.getDeviceId(), event.getEventTime(), event.getAction(), pointerType,
+ event.getButtonState(), event.getX(), event.getY(), event.getPressure());
+ } else {
+ touchBegin(id);
+ for (int i = 0; i < event.getPointerCount(); ++i) {
+ touchAdd(id,
+ event.getPointerId(i),
+ getAction(i, event),
+ i == 0,
+ (int)event.getX(i),
+ (int)event.getY(i),
+ event.getSize(i),
+ event.getPressure(i));
+ }
+
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ touchEnd(id, 0);
+ break;
+
+ case MotionEvent.ACTION_UP:
+ touchEnd(id, 2);
+ break;
+
+ default:
+ touchEnd(id, 1);
+ }
}
- //@ANDROID-5
}
static public void sendTrackballEvent(MotionEvent event, int id)
@@ -598,6 +616,10 @@ public class QtNative
public static native void longPress(int winId, int x, int y);
// pointer methods
+ // tablet methods
+ public static native void tabletEvent(int winId, int deviceId, long time, int action, int pointerType, int buttonState, float x, float y, float pressure);
+ // tablet methods
+
// keyboard methods
public static native void keyDown(int key, int unicode, int modifier, boolean autoRepeat);
public static native void keyUp(int key, int unicode, int modifier, boolean autoRepeat);
diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
index 95af3c87ad..23e08f537a 100644
--- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
+++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
@@ -187,7 +187,7 @@ public class QtActivity extends Activity
QT_ANDROID_THEMES = new String[] {"Theme_Light"};
QT_ANDROID_DEFAULT_THEME = "Theme_Light";
}
- else if ((Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 13) || Build.VERSION.SDK_INT == 21){
+ else if ((Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 13) || Build.VERSION.SDK_INT >= 21){
QT_ANDROID_THEMES = new String[] {"Theme_Holo_Light"};
QT_ANDROID_DEFAULT_THEME = "Theme_Holo_Light";
} else {
diff --git a/src/android/templates/AndroidManifest.xml b/src/android/templates/AndroidManifest.xml
index 779612cdaf..60c612976f 100644
--- a/src/android/templates/AndroidManifest.xml
+++ b/src/android/templates/AndroidManifest.xml
@@ -44,10 +44,6 @@
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
-
- <!-- Show translucent UI on top of Qt's surface when system theme mandates it -->
- <meta-data android:name="android.app.allow_overlapping_system_ui" android:value="false"/>
- <!-- Show translucent UI on top of Qt's surface when system theme mandates it -->
</activity>
</application>
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14"/>
diff --git a/src/angle/patches/0006-ANGLE-Allow-Windows-Phone-to-communicate-swap-region.patch b/src/angle/patches/0006-ANGLE-Allow-Windows-Phone-to-communicate-swap-region.patch
new file mode 100644
index 0000000000..5c6ef7b036
--- /dev/null
+++ b/src/angle/patches/0006-ANGLE-Allow-Windows-Phone-to-communicate-swap-region.patch
@@ -0,0 +1,145 @@
+From f0fb8d75bd2c7a894df1cb7e7d3dcd1ad0fd88d0 Mon Sep 17 00:00:00 2001
+From: Andrew Knight <andrew.knight@intopalo.com>
+Date: Sun, 3 May 2015 20:55:04 +0300
+Subject: [PATCH] ANGLE: Allow Windows Phone to communicate swap region
+
+eglPostSubBufferNV is used to communicate the size of the window, as
+otherwise there is no way for the renderer to know if the last frame was
+rendered in landscape or portrait, causing rendering glitches when the
+orientation changes. The rotation flags are utilized in a few additional
+places now to fix some corner cases where the rotation was not applied.
+
+This patch should be squashed into "ANGLE-Improve-Windows-Phone-Support"
+during the next ANGLE rebase.
+
+Task-number: QTBUG-44333
+Task-number: QTBUG-43502
+Change-Id: Iec37f7531854184819c30c87eab82d96d56ff133
+---
+ .../angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp | 2 ++
+ .../libANGLE/renderer/d3d/d3d11/SwapChain11.cpp | 28 +++++++++++++---------
+ .../d3d/d3d11/winrt/CoreWindowNativeWindow.cpp | 5 ++--
+ .../angle/src/libGLESv2/entry_points_egl_ext.cpp | 2 ++
+ 4 files changed, 24 insertions(+), 13 deletions(-)
+
+diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp
+index 4fde295..4a87488 100644
+--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp
++++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/SurfaceD3D.cpp
+@@ -189,6 +189,7 @@ egl::Error SurfaceD3D::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
+ return egl::Error(EGL_SUCCESS);
+ }
+
++#if !defined(ANGLE_ENABLE_WINDOWS_STORE) || (defined(ANGLE_ENABLE_WINDOWS_STORE) && WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) // Qt WP: eglPostSubBufferNV comes here
+ if (x + width > mWidth)
+ {
+ width = mWidth - x;
+@@ -198,6 +199,7 @@ egl::Error SurfaceD3D::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
+ {
+ height = mHeight - y;
+ }
++#endif
+
+ if (width == 0 || height == 0)
+ {
+diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
+index 298f3cc..dc539cf 100644
+--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
++++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
+@@ -552,18 +552,18 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
+
+ d3d11::PositionTexCoordVertex *vertices = static_cast<d3d11::PositionTexCoordVertex*>(mappedResource.pData);
+
++#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+ // Create a quad in homogeneous coordinates
+- float x1 = (x / float(mWidth)) * 2.0f - 1.0f;
+- float y1 = (y / float(mHeight)) * 2.0f - 1.0f;
+- float x2 = ((x + width) / float(mWidth)) * 2.0f - 1.0f;
+- float y2 = ((y + height) / float(mHeight)) * 2.0f - 1.0f;
++ float x1 = -1.0f;
++ float y1 = -1.0f;
++ float x2 = 1.0f;
++ float y2 = 1.0f;
+
+-#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+ const float dim = std::max(mWidth, mHeight);
+- float u1 = x / dim;
+- float v1 = y / dim;
+- float u2 = (x + width) / dim;
+- float v2 = (y + height) / dim;
++ float u1 = 0;
++ float v1 = 0;
++ float u2 = float(width) / dim;
++ float v2 = float(height) / dim;
+
+ const NativeWindow::RotationFlags flags = mNativeWindow.rotationFlags();
+ const bool rotateL = flags == NativeWindow::RotateLeft;
+@@ -573,6 +573,12 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
+ d3d11::SetPositionTexCoordVertex(&vertices[2], x2, y1, rotateR ? u1 : u2, rotateL ? v2 : v1);
+ d3d11::SetPositionTexCoordVertex(&vertices[3], x2, y2, rotateL ? u1 : u2, rotateR ? v1 : v2);
+ #else
++ // Create a quad in homogeneous coordinates
++ float x1 = (x / float(mWidth)) * 2.0f - 1.0f;
++ float y1 = (y / float(mHeight)) * 2.0f - 1.0f;
++ float x2 = ((x + width) / float(mWidth)) * 2.0f - 1.0f;
++ float y2 = ((y + height) / float(mHeight)) * 2.0f - 1.0f;
++
+ float u1 = x / float(mWidth);
+ float v1 = y / float(mHeight);
+ float u2 = (x + width) / float(mWidth);
+@@ -613,8 +619,8 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
+ viewport.TopLeftX = 0;
+ viewport.TopLeftY = 0;
+ #if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+- viewport.Width = (rotateL || rotateR) ? mHeight : mWidth;
+- viewport.Height = (rotateL || rotateR) ? mWidth : mHeight;
++ viewport.Width = (rotateL || rotateR) ? height : width;
++ viewport.Height = (rotateL || rotateR) ? width : height;
+ #else
+ viewport.Width = mWidth;
+ viewport.Height = mHeight;
+diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
+index 350526c..fa9a69c 100644
+--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
++++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
+@@ -100,6 +100,7 @@ bool CoreWindowNativeWindow::registerForSizeChangeEvents()
+ if (SUCCEEDED(result))
+ {
+ result = mDisplayInformation->add_OrientationChanged(orientationChangedHandler.Get(), &mOrientationChangedEventToken);
++ orientationChangedHandler->Invoke(mDisplayInformation.Get(), nullptr);
+ }
+ #endif
+
+@@ -135,8 +136,8 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device, DXGIFactor
+ }
+
+ DXGI_SWAP_CHAIN_DESC1 swapChainDesc = { 0 };
+- swapChainDesc.Width = width;
+- swapChainDesc.Height = height;
++ swapChainDesc.Width = mRotationFlags ? height : width;
++ swapChainDesc.Height = mRotationFlags ? width : height;
+ swapChainDesc.Format = format;
+ swapChainDesc.Stereo = FALSE;
+ swapChainDesc.SampleDesc.Count = 1;
+diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp b/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
+index ded73db..62f3ca1 100644
+--- a/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
++++ b/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
+@@ -101,12 +101,14 @@ EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLin
+ return EGL_FALSE;
+ }
+
++#if !defined(ANGLE_ENABLE_WINDOWS_STORE) || (defined(ANGLE_ENABLE_WINDOWS_STORE) && WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) // Qt WP: Allow this entry point as a workaround
+ if (!display->getExtensions().postSubBuffer)
+ {
+ // Spec is not clear about how this should be handled.
+ SetGlobalError(Error(EGL_SUCCESS));
+ return EGL_TRUE;
+ }
++#endif
+
+ error = eglSurface->postSubBuffer(x, y, width, height);
+ if (error.isError())
+--
+1.9.5.msysgit.0
+
diff --git a/src/angle/patches/0007-ANGLE-Fix-compilation-without-d3d11.patch b/src/angle/patches/0007-ANGLE-Fix-compilation-without-d3d11.patch
new file mode 100644
index 0000000000..eca7d0e162
--- /dev/null
+++ b/src/angle/patches/0007-ANGLE-Fix-compilation-without-d3d11.patch
@@ -0,0 +1,57 @@
+From 1f993a2492a618becd4bf89ef0d6cb5d2c9aa67a Mon Sep 17 00:00:00 2001
+From: Kai Koehne <kai.koehne@theqtcompany.com>
+Date: Mon, 11 May 2015 15:17:12 +0200
+Subject: [PATCH] ANGLE: Fix compilation without d3d11
+
+Change-Id: I0b772698cf521083e5ecf35a395af57100a50131
+---
+ src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h | 4 +++-
+ .../angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp | 2 ++
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h
+index 81b9ea7..0f70fe4 100644
+--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h
++++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h
+@@ -38,7 +38,7 @@ class InspectableNativeWindow;
+ using namespace Microsoft::WRL;
+ using namespace Microsoft::WRL::Wrappers;
+
+-#else
++#elif defined(ANGLE_ENABLE_D3D11)
+ typedef IDXGISwapChain DXGISwapChain;
+ typedef IDXGIFactory DXGIFactory;
+ #endif
+@@ -60,9 +60,11 @@ class NativeWindow
+ #endif
+ static bool isValidNativeWindow(EGLNativeWindowType window);
+
++#if defined(ANGLE_ENABLE_D3D11)
+ HRESULT createSwapChain(ID3D11Device* device, DXGIFactory* factory,
+ DXGI_FORMAT format, UINT width, UINT height,
+ DXGISwapChain** swapChain);
++#endif
+
+ inline EGLNativeWindowType getNativeWindow() const { return mWindow; }
+
+diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp
+index 9d8f0bb..0a4f45b 100644
+--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp
++++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp
+@@ -37,6 +37,7 @@ bool NativeWindow::isValidNativeWindow(EGLNativeWindowType window)
+ return IsWindow(window) == TRUE;
+ }
+
++#if defined(ANGLE_ENABLE_D3D11)
+ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory,
+ DXGI_FORMAT format, unsigned int width, unsigned int height,
+ DXGISwapChain** swapChain)
+@@ -65,4 +66,5 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory
+
+ return factory->CreateSwapChain(device, &swapChainDesc, swapChain);
+ }
++#endif
+ }
+--
+1.9.5.msysgit.0
+
diff --git a/src/angle/src/common/common.pri b/src/angle/src/common/common.pri
index 63b80347d1..735c841ad8 100644
--- a/src/angle/src/common/common.pri
+++ b/src/angle/src/common/common.pri
@@ -13,7 +13,7 @@ lib_replace.CONFIG = path
QMAKE_PRL_INSTALL_REPLACE += lib_replace
# DirectX is included in the Windows 8 Kit, but everything else requires the DX SDK.
-win32-msvc2012|win32-msvc2013|winrt {
+winrt|if(msvc:!win32-msvc2005:!win32-msvc2008:!win32-msvc2010) {
FXC = fxc.exe
} else {
DX_DIR = $$(DXSDK_DIR)
diff --git a/src/angle/src/libGLESv2/libGLESv2.pro b/src/angle/src/libGLESv2/libGLESv2.pro
index 1bf9af0436..5979b68098 100644
--- a/src/angle/src/libGLESv2/libGLESv2.pro
+++ b/src/angle/src/libGLESv2/libGLESv2.pro
@@ -329,6 +329,8 @@ angle_d3d11 {
!static {
DEF_FILE = $$ANGLE_DIR/src/libGLESv2/$${TARGET}.def
mingw:equals(QT_ARCH, i386): DEF_FILE = $$ANGLE_DIR/src/libGLESv2/$${TARGET}_mingw32.def
+} else {
+ DEFINES += DllMain=DllMain_ANGLE # prevent symbol from conflicting with the user's DllMain
}
float_converter.target = float_converter
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 7213a844f5..65fd1f9383 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -70,8 +70,14 @@ set(_qt5_corelib_extra_includes)
# Qt5_POSITION_INDEPENDENT_CODE variable is used in the # qt5_use_module
# macro to add it.
set(Qt5_POSITION_INDEPENDENT_CODE True)
-set_property(TARGET Qt5::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\")
-set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIE\")
+set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIC\")
+if (CMAKE_VERSION VERSION_LESS 2.8.12
+ AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\"
+ OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
+ set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\")
+else()
+ set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $$QMAKE_CXXFLAGS_APP)
+endif()
!!IF !isEmpty(QT_NAMESPACE)
list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index a94caf0d25..18563764ad 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -333,8 +333,10 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.9)
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG)
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG)
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG)
-
- if (Qt5_POSITION_INDEPENDENT_CODE)
+ if (Qt5_POSITION_INDEPENDENT_CODE
+ AND (CMAKE_VERSION VERSION_LESS 2.8.12
+ AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\"
+ OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)))
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE})
endif()
endforeach()
diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp
index 65cc337708..b375999aeb 100644
--- a/src/corelib/codecs/qicucodec.cpp
+++ b/src/corelib/codecs/qicucodec.cpp
@@ -121,7 +121,7 @@ struct MibToName {
short index;
};
-static MibToName mibToName[] = {
+static const MibToName mibToName[] = {
{ 3, 0 },
{ 4, 9 },
{ 5, 20 },
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 050f8f207f..8fef333a77 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -1147,13 +1147,30 @@ QTextCodec *QTextCodec::codecForUtfText(const QByteArray &ba)
return codecForUtfText(ba, QTextCodec::codecForMib(/*Latin 1*/ 4));
}
+/*!
+ \fn QTextCodec * QTextCodec::codecForTr ()
+ \obsolete
+
+ Returns the codec used by QObject::tr() on its argument. If this
+ function returns 0 (the default), tr() assumes Latin-1.
+
+ \sa setCodecForTr()
+*/
+
+/*!
+ \fn QTextCodec::setCodecForTr ( QTextCodec * c )
+ \obsolete
+
+ Sets the codec used by QObject::tr() on its argument to c. If c
+ is 0 (the default), tr() assumes Latin-1.
+*/
/*!
\internal
\since 4.3
- Determines whether the decoder encountered a failure while decoding the input. If
- an error was encountered, the produced result is undefined, and gets converted as according
- to the conversion flags.
+ Determines whether the decoder encountered a failure while decoding the
+ input. If an error was encountered, the produced result is undefined, and
+ gets converted as according to the conversion flags.
*/
bool QTextDecoder::hasFailure() const
{
diff --git a/src/corelib/codecs/qwindowscodec.cpp b/src/corelib/codecs/qwindowscodec.cpp
index cf427c64b6..dded93ccb5 100644
--- a/src/corelib/codecs/qwindowscodec.cpp
+++ b/src/corelib/codecs/qwindowscodec.cpp
@@ -172,7 +172,7 @@ QString QWindowsLocalCodec::convertToUnicodeCharByChar(const char *chars, int le
}
#else
QString s;
- int size = mbstowcs(NULL, mb, length);
+ size_t size = mbstowcs(NULL, mb, length);
if (size < 0) {
Q_ASSERT("Error in CE TextCodec");
return QString();
@@ -181,7 +181,7 @@ QString QWindowsLocalCodec::convertToUnicodeCharByChar(const char *chars, int le
ws[size +1] = 0;
ws[size] = 0;
size = mbstowcs(ws, mb, length);
- for (int i=0; i< size; i++)
+ for (size_t i = 0; i < size; i++)
s.append(QChar(ws[i]));
delete [] ws;
#endif
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index df1ee4afea..502689e4c2 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -43,5 +43,8 @@ imagedirs += images
excludedirs += snippets
+excludefiles += ../../../examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc \
+ ../../../examples/widgets/tools/codecs/doc/src/codecs.qdoc
+
navigation.landingpage = "Qt Core"
navigation.cppclassespage = "Qt Core C++ Classes"
diff --git a/src/corelib/doc/snippets/code/doc_src_resources.cpp b/src/corelib/doc/snippets/code/doc_src_resources.cpp
index 430c0c92c1..ab97f609ac 100644
--- a/src/corelib/doc/snippets/code/doc_src_resources.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_resources.cpp
@@ -48,7 +48,7 @@ MyClass::MyClass() : BaseClass()
{
Q_INIT_RESOURCE(resources);
- QFile file("qrc:/myfile.dat");
+ QFile file(":/myfile.dat");
...
}
//! [5]
@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
Q_INIT_RESOURCE(graphlib);
- QFile file("qrc:/graph.png");
+ QFile file(":/graph.png");
...
return app.exec();
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
index 77ec85cc36..e3d76453d0 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
@@ -51,8 +51,9 @@ sem.release(2); // resources available == 3
//! [1]
QSystemSemaphore sem("market", 5, QSystemSemaphore::Create);
-sem.acquire(5); // acquire all 5 resources
-sem.release(5); // release the 5 resources
+for (int i = 0; i < 5; ++i) // acquire all 5 resources
+ sem.acquire();
+sem.release(5); // release the 5 resources
//! [1]
diff --git a/src/corelib/doc/src/statemachine.qdoc b/src/corelib/doc/src/statemachine.qdoc
index 037b09810f..e44a603959 100644
--- a/src/corelib/doc/src/statemachine.qdoc
+++ b/src/corelib/doc/src/statemachine.qdoc
@@ -63,7 +63,7 @@
used to effectively embed the elements and semantics of statecharts in Qt
applications. The framework integrates tightly with Qt's meta-object system;
for example, transitions between states can be triggered by signals, and
- states can be configured to set properties and invoke methods on QObjects.
+ states can be configured to set properties and invoke methods on {QObject}s.
Qt's event system is used to drive the state machines.
The state graph in the State Machine framework is hierarchical. States can be nested inside of
@@ -126,9 +126,9 @@
The QState::entered() signal is emitted when the state is entered, and the
QState::exited() signal is emitted when the state is exited. In the
- following snippet, the button's showMaximized() slot will be called when
- state \c s3 is entered, and the button's showMinimized() slot will be called
- when \c s3 is exited:
+ following snippet, the button's \l {QPushButton::}{showMaximized()} slot
+ will be called when state \c s3 is entered, and the button's \l {QPushButton::}{showMinimized()}
+ slot will be called when \c s3 is exited:
\snippet statemachine/main.cpp 5
@@ -151,7 +151,7 @@
Assume we wanted the user to be able to quit the application at any time by
clicking a Quit button. In order to achieve this, we need to create a final
state and make it the target of a transition associated with the Quit
- button's clicked() signal. We could add a transition from each of \c s1, \c
+ button's \l{QPushButton::}{clicked()} signal. We could add a transition from each of \c s1, \c
s2 and \c s3; however, this seems redundant, and one would also have to
remember to add such a transition from every new state that is added in the
future.
@@ -184,8 +184,8 @@
\snippet statemachine/main2.cpp 1
In this case we want the application to quit when the state machine is
- finished, so the machine's finished() signal is connected to the
- application's quit() slot.
+ finished, so the machine's \l {QStateMachine::}{finished()} signal is connected to the
+ application's \l {QCoreApplication::}{quit()} slot.
A child state can override an inherited transition. For example, the
following code adds a transition that effectively causes the Quit button to
@@ -290,7 +290,7 @@
\endomit
When \c s1 's final state is entered, \c s1 will automatically emit
- finished(). We use a signal transition to cause this event to trigger a
+ \l {QState::}{finished()}. We use a signal transition to cause this event to trigger a
state change:
\snippet statemachine/main3.cpp 1
@@ -302,7 +302,7 @@
encapsulation mechanism when building complex (deeply nested) state
machines. (In the above example, you could of course create a transition
directly from \c s1 's \c done state rather than relying on \c s1 's
- finished() signal, but with the consequence that implementation details of
+ \l {QState::}{finished()} signal, but with the consequence that implementation details of
\c s1 are exposed and depended on).
For parallel state groups, the QState::finished() signal is emitted when \e
@@ -365,8 +365,8 @@
\snippet statemachine/main4.cpp 1
- In the eventTest() reimplementation, we first check if the event type is the
- desired one; if so, we cast the event to a StringEvent and perform the
+ In the \l {QAbstractTransition::}{eventTest()} reimplementation, we first check if the event type is the
+ desired one; if so, we cast the event to a \c StringEvent and perform the
string comparison.
The following is a statechart that uses the custom event and transition:
@@ -486,7 +486,7 @@
message box will pop up before the geometry of the button has actually been set.
To ensure that the message box does not pop up until the geometry actually reaches its final
- value, we can use the state's propertiesAssigned() signal. The propertiesAssigned() signal will be
+ value, we can use the state's \l {QState::}{propertiesAssigned()} signal. The \l {QState::}{propertiesAssigned()} signal will be
emitted when the property is assigned its final value, whether this is done immediately or
after the animation has finished playing.
@@ -503,14 +503,14 @@
has been assigned the defined value.
If the global restore policy is set to QStateMachine::RestoreProperties, the state will not emit
- the propertiesAssigned() signal until these have been executed as well.
+ the \l {QState::}{propertiesAssigned()} signal until these have been executed as well.
\section1 What Happens If A State Is Exited Before The Animation Has Finished
If a state has property assignments, and the transition into the state has animations for the
properties, the state can potentially be exited before the properties have been assigned to the
values defines by the state. This is true in particular when there are transitions out from the
- state that do not depend on the propertiesAssigned signal, as described in the previous section.
+ state that do not depend on the \l {QState::}{propertiesAssigned()} signal, as described in the previous section.
The State Machine API guarantees that a property assigned by the state machine either:
\list
@@ -563,13 +563,13 @@
The parent state machine treats the child machine as an \e atomic state in the state machine
algorithm. The child state machine is self-contained; it maintains its own event queue and
- configuration. In particular, note that the \l{QStateMachine::configuration()}{configuration}
+ configuration. In particular, note that the \l{QStateMachine::}{configuration()}
of the child machine is not part of the parent machine's configuration (only the child machine
itself is).
States of the child state machine cannot be specified as targets of transitions in the parent
state machine; only the child state machine itself can. Conversely, states of the parent state
machine cannot be specified as targets of transitions in the child state machine. The child
- state machine's \l{QState::finished()}{finished}() signal can be used to trigger a transition
+ state machine's \l{QState::}{finished}() signal can be used to trigger a transition
in the parent machine.
*/
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 2176a148b0..91e8699472 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2124,9 +2124,9 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
# define USE_ETC_OS_RELEASE
struct QUnixOSVersion
{
- // from /etc/os-release older /etc/lsb-release
- QString productType; // $ID $DISTRIB_ID
- QString productVersion; // $VERSION_ID $DISTRIB_RELEASE
+ // from /etc/os-release older /etc/lsb-release // redhat /etc/redhat-release // debian /etc/debian_version
+ QString productType; // $ID $DISTRIB_ID // single line file containing: // Debian
+ QString productVersion; // $VERSION_ID $DISTRIB_RELEASE // <Vendor_ID release Version_ID> // single line file <Release_ID/sid>
QString prettyName; // $PRETTY_NAME $DISTRIB_DESCRIPTION
};
@@ -2138,24 +2138,32 @@ static QString unquote(const char *begin, const char *end)
}
return QString::fromLatin1(begin, end - begin);
}
-
-static bool readEtcFile(QUnixOSVersion &v, const char *filename,
- const QByteArray &idKey, const QByteArray &versionKey, const QByteArray &prettyNameKey)
+static QByteArray getEtcFileContent(const char *filename)
{
// we're avoiding QFile here
int fd = qt_safe_open(filename, O_RDONLY);
if (fd == -1)
- return false;
+ return QByteArray();
QT_STATBUF sbuf;
if (QT_FSTAT(fd, &sbuf) == -1) {
qt_safe_close(fd);
- return false;
+ return QByteArray();
}
QByteArray buffer(sbuf.st_size, Qt::Uninitialized);
buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size));
qt_safe_close(fd);
+ return buffer;
+}
+
+static bool readEtcFile(QUnixOSVersion &v, const char *filename,
+ const QByteArray &idKey, const QByteArray &versionKey, const QByteArray &prettyNameKey)
+{
+
+ QByteArray buffer = getEtcFileContent(filename);
+ if (buffer.isEmpty())
+ return false;
const char *ptr = buffer.constData();
const char *end = buffer.constEnd();
@@ -2219,14 +2227,72 @@ static bool readEtcLsbRelease(QUnixOSVersion &v)
}
}
- return ok;
+ // some distributions have a /etc/lsb-release file that does not provide the values
+ // we are looking for, i.e. DISTRIB_ID, DISTRIB_RELEASE and DISTRIB_DESCRIPTION.
+ // Assuming that neither DISTRIB_ID nor DISTRIB_RELEASE were found, or contained valid values,
+ // returning false for readEtcLsbRelease will allow further /etc/<lowercasename>-release parsing.
+ return ok && !(v.productType.isEmpty() && v.productVersion.isEmpty());
}
+#if defined(Q_OS_LINUX)
+static QByteArray getEtcFileFirstLine(const char *fileName)
+{
+ QByteArray buffer = getEtcFileContent(fileName);
+ if (buffer.isEmpty())
+ return QByteArray();
+
+ const char *ptr = buffer.constData();
+ int eol = buffer.indexOf("\n");
+ return QByteArray(ptr, eol).trimmed();
+}
+
+static bool readEtcRedHatRelease(QUnixOSVersion &v)
+{
+ // /etc/redhat-release analysed should be a one line file
+ // the format of its content is <Vendor_ID release Version>
+ // i.e. "Red Hat Enterprise Linux Workstation release 6.5 (Santiago)"
+ QByteArray line = getEtcFileFirstLine("/etc/redhat-release");
+ if (line.isEmpty())
+ return false;
+
+ v.prettyName = QString::fromLatin1(line);
+
+ const char keyword[] = "release ";
+ int releaseIndex = line.indexOf(keyword);
+ v.productType = QString::fromLatin1(line.mid(0, releaseIndex)).remove(QLatin1Char(' '));
+ int spaceIndex = line.indexOf(' ', releaseIndex + strlen(keyword));
+ v.productVersion = QString::fromLatin1(line.mid(releaseIndex + strlen(keyword), spaceIndex > -1 ? spaceIndex - releaseIndex - strlen(keyword) : -1));
+ return true;
+}
+
+static bool readEtcDebianVersion(QUnixOSVersion &v)
+{
+ // /etc/debian_version analysed should be a one line file
+ // the format of its content is <Release_ID/sid>
+ // i.e. "jessie/sid"
+ QByteArray line = getEtcFileFirstLine("/etc/debian_version");
+ if (line.isEmpty())
+ return false;
+
+ v.productType = QStringLiteral("Debian");
+ v.productVersion = QString::fromLatin1(line);
+ return true;
+}
+#endif
+
static bool findUnixOsVersion(QUnixOSVersion &v)
{
if (readEtcOsRelease(v))
return true;
- return readEtcLsbRelease(v);
+ if (readEtcLsbRelease(v))
+ return true;
+#if defined(Q_OS_LINUX)
+ if (readEtcRedHatRelease(v))
+ return true;
+ if (readEtcDebianVersion(v))
+ return true;
+#endif
+ return false;
}
# endif // USE_ETC_OS_RELEASE
#endif // Q_OS_UNIX
@@ -2955,7 +3021,7 @@ namespace {
// depending on the return type
static inline Q_DECL_UNUSED QString fromstrerror_helper(int, const QByteArray &buf)
{
- return QString::fromLocal8Bit(buf);
+ return QString::fromLocal8Bit(buf.constData());
}
static inline Q_DECL_UNUSED QString fromstrerror_helper(const char *str, const QByteArray &)
{
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index c4e2f7609c..4eeee0fef4 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -322,6 +322,15 @@ typedef double qreal;
#endif
/*
+ Some classes do not permit copies to be made of an object. These
+ classes contains a private copy constructor and assignment
+ operator to disable copying (the compiler gives an error message).
+*/
+#define Q_DISABLE_COPY(Class) \
+ Class(const Class &) Q_DECL_EQ_DELETE;\
+ Class &operator=(const Class &) Q_DECL_EQ_DELETE;
+
+/*
No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols
for Qt's internal unit tests. If you want slower loading times and more
symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL.
@@ -543,7 +552,21 @@ template <typename T>
Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max)
{ return qMax(min, qMin(max, val)); }
-#ifdef Q_OS_DARWIN
+#ifndef Q_FORWARD_DECLARE_OBJC_CLASS
+# ifdef __OBJC__
+# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) @class classname
+# else
+# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) typedef struct objc_object classname
+# endif
+#endif
+#ifndef Q_FORWARD_DECLARE_CF_TYPE
+# define Q_FORWARD_DECLARE_CF_TYPE(type) typedef const struct __ ## type * type ## Ref
+#endif
+#ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
+# define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
+#endif
+
+#ifdef Q_OS_MAC
# define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) \
((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= osx) || \
(defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios))
@@ -561,7 +584,21 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max
QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios)
# define QT_OSX_DEPLOYMENT_TARGET_BELOW(osx) \
QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, __IPHONE_NA)
-#endif
+
+Q_FORWARD_DECLARE_OBJC_CLASS(NSAutoreleasePool);
+
+// Implemented in qcore_mac_objc.mm
+class Q_CORE_EXPORT QMacAutoReleasePool
+{
+public:
+ QMacAutoReleasePool();
+ ~QMacAutoReleasePool();
+private:
+ Q_DISABLE_COPY(QMacAutoReleasePool);
+ NSAutoreleasePool *pool;
+};
+
+#endif // Q_OS_MAC
/*
Data stream functions are provided by many classes (defined in qdatastream.h)
@@ -1033,15 +1070,6 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
{ return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; }
#endif
-/*
- Some classes do not permit copies to be made of an object. These
- classes contains a private copy constructor and assignment
- operator to disable copying (the compiler gives an error message).
-*/
-#define Q_DISABLE_COPY(Class) \
- Class(const Class &) Q_DECL_EQ_DELETE;\
- Class &operator=(const Class &) Q_DECL_EQ_DELETE;
-
class QByteArray;
Q_CORE_EXPORT QByteArray qgetenv(const char *varName);
Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value);
@@ -1062,9 +1090,10 @@ Q_CORE_EXPORT int qrand();
#define QT_MODULE(x)
-#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__)
+#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && \
+ (!defined(__PIC__) || (defined(__PIE__) && defined(Q_CC_GNU) && Q_CC_GNU >= 500))
# error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\
- "Compile your code with -fPIC or -fPIE."
+ "Compile your code with -fPIC (-fPIE is not enough)."
#endif
namespace QtPrivate {
@@ -1076,20 +1105,6 @@ template <bool B, typename T, typename F> struct QConditional { typedef T Type;
template <typename T, typename F> struct QConditional<false, T, F> { typedef F Type; };
}
-#ifndef Q_FORWARD_DECLARE_OBJC_CLASS
-# ifdef __OBJC__
-# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) @class classname
-# else
-# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) typedef struct objc_object classname
-# endif
-#endif
-#ifndef Q_FORWARD_DECLARE_CF_TYPE
-# define Q_FORWARD_DECLARE_CF_TYPE(type) typedef const struct __ ## type * type ## Ref
-#endif
-#ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
-# define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
-#endif
-
QT_END_NAMESPACE
// We need to keep QTypeInfo, QSysInfo, QFlags, qDebug & family in qglobal.h for compatibility with Qt 4.
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index d9d21c535c..88882bbe8f 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -972,8 +972,8 @@ struct QMessagePattern {
QElapsedTimer timer;
#endif
#ifdef QLOGGING_HAVE_BACKTRACE
- int backtraceDepth;
QString backtraceSeparator;
+ int backtraceDepth;
#endif
bool fromEnvironment;
@@ -986,8 +986,8 @@ QMessagePattern::QMessagePattern()
: literals(0)
, tokens(0)
#ifdef QLOGGING_HAVE_BACKTRACE
- , backtraceDepth(5)
, backtraceSeparator(QLatin1Char('|'))
+ , backtraceDepth(5)
#endif
, fromEnvironment(false)
{
@@ -1737,7 +1737,7 @@ void qErrnoWarning(int code, const char *msg, ...)
Example:
\code
- QT_MESSAGE_PATTERN="[%{time yyyyMMdd h:mm:ss.zzz t} %{if-debug}D{%endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}"
+ QT_MESSAGE_PATTERN="[%{time yyyyMMdd h:mm:ss.zzz t} %{if-debug}D%{endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}"
\endcode
The default \a pattern is "%{if-category}%{category}: %{endif}%{message}".
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 123e2edf0e..fc5207fa25 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -294,10 +294,13 @@ public:
WindowCloseButtonHint = 0x08000000,
MacWindowToolBarButtonHint = 0x10000000,
BypassGraphicsProxyWidget = 0x20000000,
- WindowOkButtonHint = 0x00080000,
- WindowCancelButtonHint = 0x00100000,
NoDropShadowWindowHint = 0x40000000,
- WindowFullscreenButtonHint = 0x80000000
+ WindowFullscreenButtonHint = 0x80000000,
+
+ // The following enums have overlapping values with other enums.
+ // This was not intentional, but it's too late to change now.
+ WindowOkButtonHint = 0x00080000, // WindowTransparentForInput
+ WindowCancelButtonHint = 0x00100000 // WindowOverridesSystemGestures
};
Q_DECLARE_FLAGS(WindowFlags, WindowType)
@@ -1323,7 +1326,7 @@ public:
ImAbsolutePosition = 0x400,
ImTextBeforeCursor = 0x800,
ImTextAfterCursor = 0x1000,
- ImReturnKeyType = 0x2000,
+ ImEnterKeyType = 0x2000,
ImPlatformData = 0x80000000,
ImQueryInput = ImCursorRectangle | ImCursorPosition | ImSurroundingText |
@@ -1363,15 +1366,15 @@ public:
};
Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)
- enum ReturnKeyType {
- ReturnKeyDefault,
- ReturnKeyEnter,
- ReturnKeyDone,
- ReturnKeyGo,
- ReturnKeySend,
- ReturnKeySearch,
- ReturnKeyNext,
- ReturnKeyPrevious
+ enum EnterKeyType {
+ EnterKeyDefault,
+ EnterKeyReturn,
+ EnterKeyDone,
+ EnterKeyGo,
+ EnterKeySend,
+ EnterKeySearch,
+ EnterKeyNext,
+ EnterKeyPrevious
};
enum ToolButtonStyle {
@@ -1697,7 +1700,7 @@ public:
QT_Q_ENUM(InputMethodHint)
QT_Q_ENUM(InputMethodQuery)
QT_Q_FLAG(InputMethodHints)
- QT_Q_ENUM(ReturnKeyType)
+ QT_Q_ENUM(EnterKeyType)
QT_Q_FLAG(InputMethodQueries)
QT_Q_FLAG(TouchPointStates)
QT_Q_ENUM(ScreenOrientation)
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index d4d7b631ad..970e1b1f42 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2527,7 +2527,7 @@
but \b{must} not return an empty string unless the cursor is at the start of the document.
\value ImTextAfterCursor The plain text after the cursor. The widget can decide how much text to return,
but \b{must} not return an empty string unless the cursor is at the end of the document.
- \value ImReturnKeyType The return key type.
+ \value ImEnterKeyType The Enter key type.
Masks:
@@ -2538,31 +2538,32 @@
*/
/*!
- \enum Qt::ReturnKeyType
+ \enum Qt::EnterKeyType
This can be used to alter the appearance of the Return key on an on screen keyboard.
- Note that not all of these values are supported on all platforms.
-
- \value ReturnKeyDefault The default return key.
- This can either be a button closing the keyboard, or a Return button
- causing a new line in case of a multi-line input field.
- \value ReturnKeyEnter Show a Return button that inserts a new line.
- The keyboard will not close when this button is pressed.
- \value ReturnKeyDone Show a "Done" button.
- The keyboard will close when this button is pressed.
- \value ReturnKeyGo Show a "Go" button.
- Typically used in an address bar when entering an URL; the keyboard
- will close when this button is pressed.
- \value ReturnKeySend Show a "Send" button.
- The keyboard will close when this button is pressed.
- \value ReturnKeySearch Show a "Search" button.
- The keyboard will close when this button is pressed.
- \value ReturnKeyNext Show a "Next" button.
- Typically used in a form to allow navigating to the next input field;
- the keyboard will not close when this button is pressed.
- \value ReturnKeyPrevious Show a "Previous" button.
- The keyboard will not close when this button is pressed.
+ \note Not all of these values are supported on all platforms.
+ For unsuppoted values the default key will be used instead.
+
+ \value EnterKeyDefault The default Enter key.
+ This can either be a button closing the keyboard, or a Return button
+ causing a new line in case of a multi-line input field.
+ \value EnterKeyReturn Show a Return button that inserts a new line.
+ The keyboard will not close when this button is pressed.
+ \value EnterKeyDone Show a "Done" button.
+ The keyboard will close when this button is pressed.
+ \value EnterKeyGo Show a "Go" button.
+ Typically used in an address bar when entering a URL; the keyboard
+ will close when this button is pressed.
+ \value EnterKeySend Show a "Send" button.
+ The keyboard will close when this button is pressed.
+ \value EnterKeySearch Show a "Search" button.
+ The keyboard will close when this button is pressed.
+ \value EnterKeyNext Show a "Next" button.
+ Typically used in a form to allow navigating to the next input field;
+ the keyboard will not close when this button is pressed.
+ \value EnterKeyPrevious Show a "Previous" button.
+ The keyboard will not close when this button is pressed.
\since 5.6
*/
@@ -2955,15 +2956,19 @@
\enum Qt::NativeGestureType
\since 5.2
- \value BeginNativeGesture
- \value EndNativeGesture
- \value PanNativeGesture
- \value ZoomNativeGesture
- \value SmartZoomNativeGesture
- \value RotateNativeGesture
- \value SwipeNativeGesture
+ This enum returns the gesture type.
+
+ \value BeginNativeGesture Sent before gesture event stream.
+ \value EndNativeGesture Sent after gesture event stream.
+ \value PanNativeGesture Sent after a panning gesture.
+ Similar to a click-and-drag mouse movement.
+ \value ZoomNativeGesture Specifies the magnification delta in percent.
+ \value SmartZoomNativeGesture Boolean magnification state.
+ \value RotateNativeGesture Rotation delta in degrees.
+ \value SwipeNativeGesture Sent after a swipe movements.
*/
+
/*!
\enum Qt::NavigationMode
\since 4.6
diff --git a/src/corelib/global/qtypetraits.h b/src/corelib/global/qtypetraits.h
index 3a305713e6..488e257e0f 100644
--- a/src/corelib/global/qtypetraits.h
+++ b/src/corelib/global/qtypetraits.h
@@ -506,6 +506,27 @@ Q_STATIC_ASSERT((!is_unsigned<qint64>::value));
Q_STATIC_ASSERT((!is_signed<quint64>::value));
Q_STATIC_ASSERT(( is_signed<qint64>::value));
+template<class T = void> struct is_default_constructible;
+
+template<> struct is_default_constructible<void>
+{
+protected:
+ template<bool> struct test { typedef char type; };
+public:
+ static bool const value = false;
+};
+template<> struct is_default_constructible<>::test<true> { typedef double type; };
+
+template<class T> struct is_default_constructible : is_default_constructible<>
+{
+private:
+ template<class U> static typename test<!!sizeof(::new U())>::type sfinae(U*);
+ template<class U> static char sfinae(...);
+public:
+ static bool const value = sizeof(sfinae<T>(0)) > 1;
+};
+
+
} // namespace QtPrivate
QT_END_NAMESPACE
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index 4c189bfe57..207de2a85b 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -187,7 +187,7 @@ win32 {
}
!nacl {
- freebsd-*|mac|darwin-*|openbsd-*:{
+ freebsd-*|mac|darwin-*|openbsd-*|netbsd-*:{
SOURCES += io/qfilesystemwatcher_kqueue.cpp
HEADERS += io/qfilesystemwatcher_kqueue_p.h
}
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 9b1ec3917a..8b3dd5d82f 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1826,6 +1826,8 @@ QFileInfoList QDir::drives()
underlying operating system. If you want to display paths to the
user using their operating system's separator use
toNativeSeparators().
+
+ \sa listSeparator()
*/
QChar QDir::separator()
{
@@ -1837,6 +1839,16 @@ QChar QDir::separator()
}
/*!
+ \fn QDir::listSeparator()
+ \since 5.6
+
+ Returns the native path list separator: ':' under Unix
+ and ';' under Windows.
+
+ \sa separator()
+*/
+
+/*!
Sets the application's current working directory to \a path.
Returns \c true if the directory was successfully changed; otherwise
returns \c false.
diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h
index e622011f98..b6946eba65 100644
--- a/src/corelib/io/qdir.h
+++ b/src/corelib/io/qdir.h
@@ -177,7 +177,16 @@ public:
static QFileInfoList drives();
- static QChar separator();
+ Q_DECL_CONSTEXPR static inline QChar listSeparator() Q_DECL_NOTHROW
+ {
+#if defined(Q_OS_WIN)
+ return QLatin1Char(';');
+#else
+ return QLatin1Char(':');
+#endif
+ }
+
+ static QChar separator(); // ### Qt6: Make it inline
static bool setCurrent(const QString &path);
static inline QDir current() { return QDir(currentPath()); }
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index 4ca07ba41d..cddd70f908 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -225,9 +225,13 @@ QString QFileSelector::select(const QString &filePath) const
return d->select(filePath);
}
-static QString qrcScheme()
+static bool isLocalScheme(const QString &file)
{
- return QStringLiteral("qrc");
+ bool local = file == QStringLiteral("qrc");
+#ifdef Q_OS_ANDROID
+ local |= file == QStringLiteral("assets");
+#endif
+ return local;
}
/*!
@@ -240,10 +244,10 @@ static QString qrcScheme()
QUrl QFileSelector::select(const QUrl &filePath) const
{
Q_D(const QFileSelector);
- if (filePath.scheme() != qrcScheme() && !filePath.isLocalFile())
+ if (!isLocalScheme(filePath.scheme()) && !filePath.isLocalFile())
return filePath;
QUrl ret(filePath);
- if (filePath.scheme() == qrcScheme()) {
+ if (isLocalScheme(filePath.scheme())) {
QString equivalentPath = QLatin1Char(':') + filePath.path();
QString selectedPath = d->select(equivalentPath);
ret.setPath(selectedPath.remove(0, 1));
diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp
index faaf7a00af..79f16a0839 100644
--- a/src/corelib/io/qfilesystementry.cpp
+++ b/src/corelib/io/qfilesystementry.cpp
@@ -255,15 +255,15 @@ QString QFileSystemEntry::completeSuffix() const
bool QFileSystemEntry::isRelative() const
{
resolveFilePath();
- return (m_filePath.isEmpty() || (!m_filePath.isEmpty() && (m_filePath[0].unicode() != '/')
- && (!(m_filePath.length() >= 2 && m_filePath[1].unicode() == ':'))));
+ return (m_filePath.isEmpty() || (!m_filePath.isEmpty() && (m_filePath.at(0).unicode() != '/')
+ && (!(m_filePath.length() >= 2 && m_filePath.at(1).unicode() == ':'))));
}
bool QFileSystemEntry::isAbsolute() const
{
resolveFilePath();
return (!m_filePath.isEmpty() && ((m_filePath.length() >= 3
- && (m_filePath[0].isLetter() && m_filePath[1].unicode() == ':' && m_filePath[2].unicode() == '/'))
+ && (m_filePath.at(0).isLetter() && m_filePath.at(1).unicode() == ':' && m_filePath.at(2).unicode() == '/'))
|| (m_filePath.length() >= 2 && (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/')))
));
}
@@ -276,7 +276,7 @@ bool QFileSystemEntry::isRelative() const
bool QFileSystemEntry::isAbsolute() const
{
resolveFilePath();
- return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/'));
+ return (!m_filePath.isEmpty() && (m_filePath.at(0).unicode() == '/'));
}
#endif
@@ -337,10 +337,10 @@ void QFileSystemEntry::findFileNameSeparators() const
int i = m_filePath.size() - 1;
for (; i >= stop; --i) {
- if (m_filePath[i].unicode() == '.') {
+ if (m_filePath.at(i).unicode() == '.') {
firstDotInFileName = lastDotInFileName = i;
break;
- } else if (m_filePath[i].unicode() == '/') {
+ } else if (m_filePath.at(i).unicode() == '/') {
lastSeparator = i;
break;
}
@@ -348,9 +348,9 @@ void QFileSystemEntry::findFileNameSeparators() const
if (lastSeparator != i) {
for (--i; i >= stop; --i) {
- if (m_filePath[i].unicode() == '.')
+ if (m_filePath.at(i).unicode() == '.')
firstDotInFileName = i;
- else if (m_filePath[i].unicode() == '/') {
+ else if (m_filePath.at(i).unicode() == '/') {
lastSeparator = i;
break;
}
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 0bd46400d3..3a8f7bd0a9 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -52,7 +52,7 @@
# include "qfilesystemwatcher_win_p.h"
#elif defined(USE_INOTIFY)
# include "qfilesystemwatcher_inotify_p.h"
-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_IOS)
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_IOS)
# include "qfilesystemwatcher_kqueue_p.h"
#elif defined(Q_OS_OSX)
# include "qfilesystemwatcher_fsevents_p.h"
@@ -68,7 +68,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject
// there is a chance that inotify may fail on Linux pre-2.6.13 (August
// 2005), so we can't just new inotify directly.
return QInotifyFileSystemWatcherEngine::create(parent);
-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_IOS)
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_IOS)
return QKqueueFileSystemWatcherEngine::create(parent);
#elif defined(Q_OS_OSX)
return QFseventsFileSystemWatcherEngine::create(parent);
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm
index 8a028c91e1..7656530a46 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents.mm
+++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm
@@ -56,25 +56,6 @@
QT_BEGIN_NAMESPACE
-namespace {
-class RaiiAutoreleasePool
-{
- Q_DISABLE_COPY(RaiiAutoreleasePool)
-
-public:
- RaiiAutoreleasePool()
- : pool([[NSAutoreleasePool alloc] init])
- {}
-
- ~RaiiAutoreleasePool()
- { [pool release]; }
-
-private:
- NSAutoreleasePool *pool;
-};
-#define Q_AUTORELEASE_POOL(pool) RaiiAutoreleasePool pool; Q_UNUSED(pool);
-}
-
static void callBackFunction(ConstFSEventStreamRef streamRef,
void *clientCallBackInfo,
size_t numEvents,
@@ -82,7 +63,7 @@ static void callBackFunction(ConstFSEventStreamRef streamRef,
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[])
{
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
char **paths = static_cast<char **>(eventPaths);
QFseventsFileSystemWatcherEngine *engine = static_cast<QFseventsFileSystemWatcherEngine *>(clientCallBackInfo);
@@ -297,7 +278,7 @@ void QFseventsFileSystemWatcherEngine::doEmitDirectoryChanged(const QString &pat
void QFseventsFileSystemWatcherEngine::restartStream()
{
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
QMutexLocker locker(&lock);
stopStream();
startStream();
@@ -328,7 +309,7 @@ QFseventsFileSystemWatcherEngine::QFseventsFileSystemWatcherEngine(QObject *pare
QFseventsFileSystemWatcherEngine::~QFseventsFileSystemWatcherEngine()
{
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
if (stream)
FSEventStreamStop(stream);
@@ -344,7 +325,7 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
QStringList *files,
QStringList *directories)
{
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
if (stream) {
DEBUG("Flushing, last id is %llu", FSEventStreamGetLatestEventId(stream));
@@ -432,7 +413,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
QStringList *files,
QStringList *directories)
{
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
QMutexLocker locker(&lock);
@@ -489,7 +470,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
bool QFseventsFileSystemWatcherEngine::startStream()
{
Q_ASSERT(stream == 0);
- Q_AUTORELEASE_POOL(pool)
+ QMacAutoReleasePool pool;
if (stream) // This shouldn't happen, but let's be nice and handle it.
stopStream();
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index e73a200fb4..07a2ff8f6b 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -38,9 +38,9 @@
#include "qiodevice_p.h"
#include "qfile.h"
#include "qstringlist.h"
+#include "qdir.h"
#include <algorithm>
-#include <limits.h>
#ifdef QIODEVICE_DEBUG
# include <ctype.h>
@@ -80,10 +80,29 @@ void debugBinaryString(const char *data, qint64 maxlen)
#define Q_VOID
+static void checkWarnMessage(const QIODevice *device, const char *function, const char *what)
+{
+ QDebug d = qWarning();
+ d.noquote();
+ d.nospace();
+ d << "QIODevice::" << function;
+#ifndef QT_NO_QOBJECT
+ d << " (" << device->metaObject()->className();
+ if (!device->objectName().isEmpty())
+ d << ", \"" << device->objectName() << '"';
+ if (const QFile *f = qobject_cast<const QFile *>(device))
+ d << ", \"" << QDir::toNativeSeparators(f->fileName()) << '"';
+ d << ')';
+#else
+ Q_UNUSED(device)
+#endif // !QT_NO_QOBJECT
+ d << ": " << what;
+}
+
#define CHECK_MAXLEN(function, returnType) \
do { \
if (maxSize < 0) { \
- qWarning("QIODevice::"#function": Called with maxSize < 0"); \
+ checkWarnMessage(this, #function, "Called with maxSize < 0"); \
return returnType; \
} \
} while (0)
@@ -92,10 +111,10 @@ void debugBinaryString(const char *data, qint64 maxlen)
do { \
if ((d->openMode & WriteOnly) == 0) { \
if (d->openMode == NotOpen) { \
- qWarning("QIODevice::"#function": device not open"); \
+ checkWarnMessage(this, #function, "device not open"); \
return returnType; \
} \
- qWarning("QIODevice::"#function": ReadOnly device"); \
+ checkWarnMessage(this, #function, "ReadOnly device"); \
return returnType; \
} \
} while (0)
@@ -104,10 +123,10 @@ void debugBinaryString(const char *data, qint64 maxlen)
do { \
if ((d->openMode & ReadOnly) == 0) { \
if (d->openMode == NotOpen) { \
- qWarning("QIODevice::"#function": device not open"); \
+ checkWarnMessage(this, #function, "device not open"); \
return returnType; \
} \
- qWarning("QIODevice::"#function": WriteOnly device"); \
+ checkWarnMessage(this, #function, "WriteOnly device"); \
return returnType; \
} \
} while (0)
@@ -462,7 +481,7 @@ void QIODevice::setTextModeEnabled(bool enabled)
{
Q_D(QIODevice);
if (!isOpen()) {
- qWarning("QIODevice::setTextModeEnabled: The device is not open");
+ checkWarnMessage(this, "setTextModeEnabled", "The device is not open");
return;
}
if (enabled)
@@ -621,11 +640,11 @@ bool QIODevice::seek(qint64 pos)
{
Q_D(QIODevice);
if (d->isSequential()) {
- qWarning("QIODevice::seek: Cannot call seek on a sequential device");
+ checkWarnMessage(this, "seek", "Cannot call seek on a sequential device");
return false;
}
if (d->openMode == NotOpen) {
- qWarning("QIODevice::seek: The device is not open");
+ checkWarnMessage(this, "seek", "The device is not open");
return false;
}
if (pos < 0) {
@@ -922,9 +941,9 @@ QByteArray QIODevice::read(qint64 maxSize)
Q_UNUSED(d);
#endif
- if (maxSize != qint64(int(maxSize))) {
- qWarning("QIODevice::read: maxSize argument exceeds QByteArray size limit");
- maxSize = INT_MAX;
+ if (quint64(maxSize) >= QByteArray::MaxSize) {
+ checkWarnMessage(this, "read", "maxSize argument exceeds QByteArray size limit");
+ maxSize = QByteArray::MaxSize - 1;
}
qint64 readBytes = 0;
@@ -976,7 +995,7 @@ QByteArray QIODevice::readAll()
// flush internal read buffer
if (!(d->openMode & Text) && !d->buffer.isEmpty()) {
- if (d->buffer.size() >= INT_MAX)
+ if (quint64(d->buffer.size()) >= QByteArray::MaxSize)
return QByteArray();
result = d->buffer.readAll();
readBytes = result.size();
@@ -989,7 +1008,7 @@ QByteArray QIODevice::readAll()
// Size is unknown, read incrementally.
qint64 readResult;
do {
- if (quint64(readBytes) + QIODEVICE_BUFFERSIZE > QByteArray::MaxSize) {
+ if (quint64(readBytes) + QIODEVICE_BUFFERSIZE >= QByteArray::MaxSize) {
// If resize would fail, don't read more, return what we have.
break;
}
@@ -1001,7 +1020,7 @@ QByteArray QIODevice::readAll()
} else {
// Read it all in one go.
// If resize fails, don't read anything.
- if (quint64(readBytes + theSize - d->pos) > QByteArray::MaxSize)
+ if (quint64(readBytes + theSize - d->pos) >= QByteArray::MaxSize)
return QByteArray();
result.resize(int(readBytes + theSize - d->pos));
readBytes += read(result.data() + readBytes, result.size() - readBytes);
@@ -1055,7 +1074,7 @@ qint64 QIODevice::readLine(char *data, qint64 maxSize)
{
Q_D(QIODevice);
if (maxSize < 2) {
- qWarning("QIODevice::readLine: Called with maxSize < 2");
+ checkWarnMessage(this, "readLine", "Called with maxSize < 2");
return qint64(-1);
}
@@ -1159,9 +1178,9 @@ QByteArray QIODevice::readLine(qint64 maxSize)
Q_UNUSED(d);
#endif
- if (maxSize > INT_MAX) {
+ if (quint64(maxSize) >= QByteArray::MaxSize) {
qWarning("QIODevice::read: maxSize argument exceeds QByteArray size limit");
- maxSize = INT_MAX;
+ maxSize = QByteArray::MaxSize - 1;
}
result.resize(int(maxSize));
@@ -1169,7 +1188,7 @@ QByteArray QIODevice::readLine(qint64 maxSize)
if (!result.size()) {
// If resize fails or maxSize == 0, read incrementally
if (maxSize == 0)
- maxSize = INT_MAX;
+ maxSize = QByteArray::MaxSize - 1;
// The first iteration needs to leave an extra byte for the terminating null
result.resize(1);
diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp
index 4f5aeff395..2bd996d213 100644
--- a/src/corelib/io/qlockfile.cpp
+++ b/src/corelib/io/qlockfile.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 David Faure <faure+bluesystems@kde.org>
+** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -66,9 +67,12 @@ QT_BEGIN_NAMESPACE
If the process holding the lock crashes, the lock file stays on disk and can prevent
any other process from accessing the shared resource, ever. For this reason, QLockFile
- tries to detect such a "stale" lock file, based on the process ID written into the file,
- and (in case that process ID got reused meanwhile), on the last modification time of
- the lock file (30s by default, for the use case of a short-lived operation).
+ tries to detect such a "stale" lock file, based on the process ID written into the file.
+ To cover the situation that the process ID got reused meanwhile, the current process name is
+ compared to the name of the process that corresponds to the process ID from the lock file.
+ If the process names differ, the lock file is considered stale.
+ Additionally, the last modification time of the lock file (30s by default, for the use case of a
+ short-lived operation) is taken into account.
If the lock file is found to be stale, it will be deleted.
For the use case of protecting a resource over a long time, you should therefore call
@@ -122,7 +126,7 @@ QLockFile::~QLockFile()
The value of \a staleLockTime is used by lock() and tryLock() in order
to determine when an existing lock file is considered stale, i.e. left over
by a crashed process. This is useful for the case where the PID got reused
- meanwhile, so the only way to detect a stale lock file is by the fact that
+ meanwhile, so one way to detect a stale lock file is by the fact that
it has been around for a long time.
\sa staleLockTime()
diff --git a/src/corelib/io/qlockfile_p.h b/src/corelib/io/qlockfile_p.h
index 0cfaa42849..168062f467 100644
--- a/src/corelib/io/qlockfile_p.h
+++ b/src/corelib/io/qlockfile_p.h
@@ -75,6 +75,7 @@ public:
// Returns \c true if the lock belongs to dead PID, or is old.
// The attempt to delete it will tell us if it was really stale or not, though.
bool isApparentlyStale() const;
+ static QString processNameByPid(qint64 pid);
#ifdef Q_OS_UNIX
static int checkFcntlWorksAfterFlock();
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index b817a24c74..d6ea2f1f2d 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 David Faure <faure+bluesystems@kde.org>
+** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -48,6 +49,15 @@
#include <signal.h> // kill
#include <unistd.h> // gethostname
+#if defined(Q_OS_OSX)
+# include <libproc.h>
+#elif defined(Q_OS_LINUX)
+# include <unistd.h>
+# include <cstdio>
+#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+# include <sys/user.h>
+#endif
+
QT_BEGIN_NAMESPACE
static QByteArray localHostName() // from QHostInfo::localHostName(), modified to return a QByteArray
@@ -185,16 +195,54 @@ bool QLockFilePrivate::isApparentlyStale() const
{
qint64 pid;
QString hostname, appname;
- if (!getLockInfo(&pid, &hostname, &appname))
- return false;
- if (hostname.isEmpty() || hostname == QString::fromLocal8Bit(localHostName())) {
- if (::kill(pid, 0) == -1 && errno == ESRCH)
- return true; // PID doesn't exist anymore
+ if (getLockInfo(&pid, &hostname, &appname)) {
+ if (hostname.isEmpty() || hostname == QString::fromLocal8Bit(localHostName())) {
+ if (::kill(pid, 0) == -1 && errno == ESRCH)
+ return true; // PID doesn't exist anymore
+ const QString processName = processNameByPid(pid);
+ if (!processName.isEmpty()) {
+ QFileInfo fi(appname);
+ if (fi.isSymLink())
+ fi.setFile(fi.symLinkTarget());
+ if (processName != fi.fileName())
+ return true; // PID got reused by a different application.
+ }
+ }
}
const qint64 age = QFileInfo(fileName).lastModified().msecsTo(QDateTime::currentDateTime());
return staleLockTime > 0 && age > staleLockTime;
}
+QString QLockFilePrivate::processNameByPid(qint64 pid)
+{
+#if defined(Q_OS_OSX)
+ char name[1024];
+ proc_name(pid, name, sizeof(name) / sizeof(char));
+ return QString::fromUtf8(name);
+#elif defined(Q_OS_LINUX)
+ if (!QFile::exists(QStringLiteral("/proc/version")))
+ return QString();
+ char exePath[64];
+ char buf[PATH_MAX];
+ memset(buf, 0, sizeof(buf));
+ sprintf(exePath, "/proc/%lld/exe", pid);
+ if (readlink(exePath, buf, sizeof(buf)) < 0) {
+ // The pid is gone. Return some invalid process name to fail the test.
+ return QStringLiteral("/ERROR/");
+ }
+ return QFileInfo(QString::fromUtf8(buf)).fileName();
+#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+ kinfo_proc *proc = kinfo_getproc(pid);
+ if (!proc)
+ return QString();
+ QString name = QString::fromUtf8(proc->ki_comm);
+ free(proc);
+ return name;
+#else
+ return QString();
+#endif
+}
+
void QLockFile::unlock()
{
Q_D(QLockFile);
diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp
index 9fe86e1ad8..5bd1ba04c9 100644
--- a/src/corelib/io/qlockfile_win.cpp
+++ b/src/corelib/io/qlockfile_win.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 David Faure <faure+bluesystems@kde.org>
+** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -126,27 +127,75 @@ bool QLockFilePrivate::isApparentlyStale() const
{
qint64 pid;
QString hostname, appname;
- if (!getLockInfo(&pid, &hostname, &appname))
- return false;
// On WinRT there seems to be no way of obtaining information about other
// processes due to sandboxing
#ifndef Q_OS_WINRT
- if (hostname == QString::fromLocal8Bit(localHostName())) {
- HANDLE procHandle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
- if (!procHandle)
- return true;
- // We got a handle but check if process is still alive
- DWORD dwR = ::WaitForSingleObject(procHandle, 0);
- ::CloseHandle(procHandle);
- if (dwR == WAIT_TIMEOUT)
- return true;
+ if (getLockInfo(&pid, &hostname, &appname)) {
+ if (hostname.isEmpty() || hostname == QString::fromLocal8Bit(localHostName())) {
+ HANDLE procHandle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
+ if (!procHandle)
+ return true;
+ // We got a handle but check if process is still alive
+ DWORD dwR = ::WaitForSingleObject(procHandle, 0);
+ ::CloseHandle(procHandle);
+ if (dwR == WAIT_TIMEOUT)
+ return true;
+ const QString processName = processNameByPid(pid);
+ if (!processName.isEmpty() && processName != appname)
+ return true; // PID got reused by a different application.
+ }
}
-#endif // !Q_OS_WINRT
+#else // !Q_OS_WINRT
+ Q_UNUSED(pid);
+ Q_UNUSED(hostname);
+ Q_UNUSED(appname);
+#endif // Q_OS_WINRT
const qint64 age = QFileInfo(fileName).lastModified().msecsTo(QDateTime::currentDateTime());
return staleLockTime > 0 && age > staleLockTime;
}
+QString QLockFilePrivate::processNameByPid(qint64 pid)
+{
+#if !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
+ typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+
+ HMODULE hPsapi = LoadLibraryA("psapi");
+ if (!hPsapi)
+ return QString();
+
+ GetModuleFileNameExFunc qGetModuleFileNameEx
+ = (GetModuleFileNameExFunc)GetProcAddress(hPsapi, "GetModuleFileNameExW");
+ if (!qGetModuleFileNameEx) {
+ FreeLibrary(hPsapi);
+ return QString();
+ }
+
+ HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, DWORD(pid));
+ if (!hProcess) {
+ FreeLibrary(hPsapi);
+ return QString();
+ }
+ wchar_t buf[MAX_PATH];
+ const DWORD length = qGetModuleFileNameEx(hProcess, NULL, buf, sizeof(buf) / sizeof(wchar_t));
+ CloseHandle(hProcess);
+ FreeLibrary(hPsapi);
+ if (!length)
+ return QString();
+ QString name = QString::fromWCharArray(buf, length);
+ int i = name.lastIndexOf(QLatin1Char('\\'));
+ if (i >= 0)
+ name.remove(0, i + 1);
+ i = name.lastIndexOf(QLatin1Char('.'));
+ if (i >= 0)
+ name.truncate(i);
+ return name;
+#else
+ Q_UNUSED(pid);
+ return QString();
+#endif
+}
+
void QLockFile::unlock()
{
Q_D(QLockFile);
diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp
index c17b42ef81..af1bb56fe9 100644
--- a/src/corelib/io/qnoncontiguousbytedevice.cpp
+++ b/src/corelib/io/qnoncontiguousbytedevice.cpp
@@ -216,6 +216,11 @@ qint64 QNonContiguousByteDeviceByteArrayImpl::size()
return byteArray->size();
}
+qint64 QNonContiguousByteDeviceByteArrayImpl::pos()
+{
+ return currentPosition;
+}
+
QNonContiguousByteDeviceRingBufferImpl::QNonContiguousByteDeviceRingBufferImpl(QSharedPointer<QRingBuffer> rb)
: QNonContiguousByteDevice(), currentPosition(0)
{
@@ -253,6 +258,11 @@ bool QNonContiguousByteDeviceRingBufferImpl::atEnd()
return currentPosition >= size();
}
+qint64 QNonContiguousByteDeviceRingBufferImpl::pos()
+{
+ return currentPosition;
+}
+
bool QNonContiguousByteDeviceRingBufferImpl::reset()
{
currentPosition = 0;
@@ -381,6 +391,14 @@ qint64 QNonContiguousByteDeviceIoDeviceImpl::size()
return device->size() - initialPosition;
}
+qint64 QNonContiguousByteDeviceIoDeviceImpl::pos()
+{
+ if (device->isSequential())
+ return -1;
+
+ return device->pos();
+}
+
QByteDeviceWrappingIoDevice::QByteDeviceWrappingIoDevice(QNonContiguousByteDevice *bd) : QIODevice((QObject*)0)
{
byteDevice = bd;
diff --git a/src/corelib/io/qnoncontiguousbytedevice_p.h b/src/corelib/io/qnoncontiguousbytedevice_p.h
index 8b5bf3080a..38089dedd7 100644
--- a/src/corelib/io/qnoncontiguousbytedevice_p.h
+++ b/src/corelib/io/qnoncontiguousbytedevice_p.h
@@ -61,6 +61,7 @@ public:
virtual const char* readPointer(qint64 maximumLength, qint64 &len) = 0;
virtual bool advanceReadPointer(qint64 amount) = 0;
virtual bool atEnd() = 0;
+ virtual qint64 pos() { return -1; }
virtual bool reset() = 0;
virtual qint64 size() = 0;
@@ -103,6 +104,7 @@ public:
bool atEnd() Q_DECL_OVERRIDE;
bool reset() Q_DECL_OVERRIDE;
qint64 size() Q_DECL_OVERRIDE;
+ qint64 pos() Q_DECL_OVERRIDE;
protected:
QByteArray* byteArray;
qint64 currentPosition;
@@ -118,6 +120,7 @@ public:
bool atEnd() Q_DECL_OVERRIDE;
bool reset() Q_DECL_OVERRIDE;
qint64 size() Q_DECL_OVERRIDE;
+ qint64 pos() Q_DECL_OVERRIDE;
protected:
QSharedPointer<QRingBuffer> ringBuffer;
qint64 currentPosition;
@@ -135,6 +138,7 @@ public:
bool atEnd() Q_DECL_OVERRIDE;
bool reset() Q_DECL_OVERRIDE;
qint64 size() Q_DECL_OVERRIDE;
+ qint64 pos() Q_DECL_OVERRIDE;
protected:
QIODevice* device;
QByteArray* currentReadBuffer;
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 38bd588c37..da6e0c87af 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -110,7 +110,6 @@ QT_BEGIN_NAMESPACE
\ingroup io
\ingroup misc
\ingroup shared
- \mainclass
\reentrant
\since 4.6
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index 078217ea0b..32fa4aa866 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -104,15 +104,21 @@ public:
WriteError,
UnknownError
};
+ Q_ENUM(ProcessError)
+
enum ProcessState {
NotRunning,
Starting,
Running
};
+ Q_ENUM(ProcessState)
+
enum ProcessChannel {
StandardOutput,
StandardError
};
+ Q_ENUM(ProcessChannel)
+
enum ProcessChannelMode {
SeparateChannels,
MergedChannels,
@@ -120,14 +126,19 @@ public:
ForwardedOutputChannel,
ForwardedErrorChannel
};
+ Q_ENUM(ProcessChannelMode)
+
enum InputChannelMode {
ManagedInputChannel,
ForwardedInputChannel
};
+ Q_ENUM(InputChannelMode)
+
enum ExitStatus {
NormalExit,
CrashExit
};
+ Q_ENUM(ExitStatus)
explicit QProcess(QObject *parent = 0);
virtual ~QProcess();
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index cb6de29532..251b10ea89 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -104,6 +104,10 @@ using namespace ABI::Windows::Storage;
#define Q_XDG_PLATFORM
#endif
+#if !defined(QT_NO_STANDARDPATHS) && (defined(Q_XDG_PLATFORM) || defined(Q_OS_IOS))
+#define QSETTINGS_USE_QSTANDARDPATHS
+#endif
+
// ************************************************************************
// QConfFile
@@ -1044,7 +1048,7 @@ static void initDefaultPaths(QMutexLocker *locker)
windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator());
#else
-#if defined(QT_NO_STANDARDPATHS) || !defined(Q_XDG_PLATFORM)
+#ifndef QSETTINGS_USE_QSTANDARDPATHS
// Non XDG platforms (OS X, iOS, Blackberry, Android...) have used this code path erroneously
// for some time now. Moving away from that would require migrating existing settings.
QString userPath;
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index 5f764549e0..04848a38e5 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -274,45 +274,67 @@ QT_BEGIN_NAMESPACE
\endtable
\table
- \header \li Path type \li Android
+ \header \li Path type \li Android \li iOS
\row \li DesktopLocation
\li "<APPROOT>/files"
+ \li "<APPROOT>/<APPDIR>" (not writable)
\row \li DocumentsLocation
\li "<USER>/Documents", "<USER>/<APPNAME>/Documents"
+ \li "<APPROOT>/Documents"
\row \li FontsLocation
\li "/system/fonts" (not writable)
+ \li "<APPROOT>/Documents/.fonts"
\row \li ApplicationsLocation
\li not supported (directory not readable)
+ \li not supported
\row \li MusicLocation
\li "<USER>/Music", "<USER>/<APPNAME>/Music"
+ \li "<APPROOT>/Documents/Music"
\row \li MoviesLocation
\li "<USER>/Movies", "<USER>/<APPNAME>/Movies"
+ \li "<APPROOT>/Documents/Movies"
\row \li PicturesLocation
\li "<USER>/Pictures", "<USER>/<APPNAME>/Pictures"
+ \li "<APPROOT>/Documents/Pictures", "assets-library://"
\row \li TempLocation
\li "<APPROOT>/cache"
+ \li "<APPROOT>/tmp"
\row \li HomeLocation
\li "<APPROOT>/files"
+ \li "<APPROOT>/<APPDIR>" (not writable)
\row \li DataLocation
\li "<APPROOT>/files", "<USER>/<APPNAME>/files"
+ \li "<APPROOT>/Library/Application Support"
\row \li CacheLocation
\li "<APPROOT>/cache", "<USER>/<APPNAME>/cache"
+ \li "<APPROOT>/Library/Caches"
\row \li GenericDataLocation
\li "<USER>"
+ \li "<APPROOT>/Documents"
\row \li RuntimeLocation
\li "<APPROOT>/cache"
+ \li not supported
\row \li ConfigLocation
\li "<APPROOT>/files/settings"
+ \li "<APPROOT>/Documents"
\row \li GenericConfigLocation
\li "<APPROOT>/files/settings" (there is no shared settings)
+ \li "<APPROOT>/Documents"
\row \li DownloadLocation
\li "<USER>/Downloads", "<USER>/<APPNAME>/Downloads"
+ \li "<APPROOT>/Documents/Download"
\row \li GenericCacheLocation
\li "<APPROOT>/cache" (there is no shared cache)
+ \li "<APPROOT>/Library/Caches"
\row \li AppDataLocation
\li "<APPROOT>/files", "<USER>/<APPNAME>/files"
+ \li "<APPROOT>/Library/Application Support"
\row \li AppConfigLocation
\li "<APPROOT>/files/settings"
+ \li "<APPROOT>/Documents"
+ \row \li AppLocalDataLocation
+ \li "<APPROOT>/files", "<USER>/<APPNAME>/files"
+ \li "<APPROOT>/Library/Application Support"
\endtable
In the table above, \c <APPNAME> is usually the organization name, the
@@ -327,6 +349,12 @@ QT_BEGIN_NAMESPACE
\note On Android, applications with open files on the external storage (<USER> locations),
will be killed if the external storage is unmounted.
+ \note On iOS, if you do pass \c {QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()}
+ as argument to \l{QFileDialog::setDirectory()},
+ a native image picker dialog will be used for accessing the user's photo album.
+ The filename returned can be loaded using QFile and related APIs.
+ This feature was added in Qt 5.5.
+
\sa writableLocation(), standardLocations(), displayName(), locate(), locateAll()
*/
@@ -494,13 +522,8 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
QStringList searchPaths = paths;
if (paths.isEmpty()) {
QByteArray pEnv = qgetenv("PATH");
-#if defined(Q_OS_WIN)
- const QLatin1Char pathSep(';');
-#else
- const QLatin1Char pathSep(':');
-#endif
// Remove trailing slashes, which occur on Windows.
- const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(pathSep, QString::SkipEmptyParts);
+ const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(QDir::listSeparator(), QString::SkipEmptyParts);
searchPaths.reserve(rawPaths.size());
foreach (const QString &rawPath, rawPaths) {
QString cleanPath = QDir::cleanPath(rawPath);
diff --git a/src/corelib/io/qstandardpaths_ios.mm b/src/corelib/io/qstandardpaths_ios.mm
index 27d28526c2..eb85e2fd23 100644
--- a/src/corelib/io/qstandardpaths_ios.mm
+++ b/src/corelib/io/qstandardpaths_ios.mm
@@ -55,30 +55,31 @@ QString QStandardPaths::writableLocation(StandardLocation type)
QString location;
switch (type) {
- case DesktopLocation:
- location = pathForDirectory(NSDesktopDirectory);
- break;
case DocumentsLocation:
location = pathForDirectory(NSDocumentDirectory);
break;
case FontsLocation:
- location = bundlePath() + QLatin1String("/.fonts");
+ location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/.fonts");
break;
case ApplicationsLocation:
- location = pathForDirectory(NSApplicationDirectory);
+ // NSApplicationDirectory points to a non-existing write-protected path.
break;
case MusicLocation:
- location = pathForDirectory(NSMusicDirectory);
+ // NSMusicDirectory points to a non-existing write-protected path. Use sensible fallback.
+ location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Music");
break;
case MoviesLocation:
- location = pathForDirectory(NSMoviesDirectory);
+ // NSMoviesDirectory points to a non-existing write-protected path. Use sensible fallback.
+ location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Movies");
break;
case PicturesLocation:
- location = pathForDirectory(NSPicturesDirectory);
+ // NSPicturesDirectory points to a non-existing write-protected path. Use sensible fallback.
+ location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Pictures");
break;
case TempLocation:
location = QString::fromNSString(NSTemporaryDirectory());
break;
+ case DesktopLocation:
case HomeLocation:
location = bundlePath();
break;
@@ -99,20 +100,12 @@ QString QStandardPaths::writableLocation(StandardLocation type)
location = pathForDirectory(NSDocumentDirectory);
break;
case DownloadLocation:
- location = pathForDirectory(NSDownloadsDirectory);
- break;
- default:
+ // NSDownloadsDirectory points to a non-existing write-protected path.
+ location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Download");
break;
- }
-
- switch (type) {
case RuntimeLocation:
break;
default:
- // All other types must return something, so use the document directory
- // as a reasonable fall-back (which will always exist).
- if (location.isEmpty())
- location = pathForDirectory(NSDocumentDirectory);
break;
}
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 7823787711..f82d0ff0a1 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -67,8 +67,20 @@
#endif
#if defined(Q_OS_BSD4)
-# define QT_STATFSBUF struct statvfs
-# define QT_STATFS ::statvfs
+# if defined(Q_OS_NETBSD)
+ define QT_STATFSBUF struct statvfs
+ define QT_STATFS ::statvfs
+# else
+# define QT_STATFSBUF struct statfs
+# define QT_STATFS ::statfs
+# endif
+
+# if !defined(ST_RDONLY)
+# define ST_RDONLY MNT_RDONLY
+# endif
+# if !defined(_STATFS_F_FLAGS)
+# define _STATFS_F_FLAGS 1
+# endif
#elif defined(Q_OS_ANDROID)
# define QT_STATFS ::statfs
# define QT_STATFSBUF struct statfs
@@ -122,11 +134,7 @@ public:
inline QByteArray device() const;
private:
#if defined(Q_OS_BSD4)
-# if defined(Q_OS_NETBSD)
- struct statvfs *stat_buf;
-# else
- struct statfs *stat_buf;
-# endif
+ QT_STATFSBUF *stat_buf;
int entryCount;
int currentIndex;
#elif defined(Q_OS_SOLARIS)
@@ -502,7 +510,7 @@ void QStorageInfoPrivate::retrieveVolumeInfo()
bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize;
bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize;
bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize;
-#if defined(Q_OS_ANDROID)
+#if defined(Q_OS_ANDROID) || defined (Q_OS_BSD4)
#if defined(_STATFS_F_FLAGS)
readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0;
#endif
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 556bc6e760..bdf4392275 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -236,9 +236,9 @@ QTemporaryFileEngine::~QTemporaryFileEngine()
QFSFileEngine::close();
}
-bool QTemporaryFileEngine::isReallyOpen()
+bool QTemporaryFileEngine::isReallyOpen() const
{
- Q_D(QFSFileEngine);
+ Q_D(const QFSFileEngine);
if (!((0 == d->fh) && (-1 == d->fd)
#if defined Q_OS_WIN
diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h
index 475298f264..341ae9bd3f 100644
--- a/src/corelib/io/qtemporaryfile_p.h
+++ b/src/corelib/io/qtemporaryfile_p.h
@@ -95,7 +95,7 @@ public:
~QTemporaryFileEngine();
- bool isReallyOpen();
+ bool isReallyOpen() const;
void setFileName(const QString &file);
void setFileTemplate(const QString &fileTemplate);
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 5fe4cfef9d..47b96d708f 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -464,7 +464,7 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
}
#if defined (QTEXTSTREAM_DEBUG)
qDebug("QTextStreamPrivate::fillReadBuffer(), using %s codec",
- codec->name().constData());
+ codec ? codec->name().constData() : "no");
#endif
#endif
@@ -476,9 +476,10 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
int oldReadBufferSize = readBuffer.size();
#ifndef QT_NO_TEXTCODEC
// convert to unicode
- readBuffer += codec->toUnicode(buf, bytesRead, &readConverterState);
+ readBuffer += Q_LIKELY(codec) ? codec->toUnicode(buf, bytesRead, &readConverterState)
+ : QString::fromLatin1(buf, bytesRead);
#else
- readBuffer += QString::fromLatin1(QByteArray(buf, bytesRead).constData());
+ readBuffer += QString::fromLatin1(buf, bytesRead);
#endif
// reset the Text flag.
@@ -564,7 +565,8 @@ void QTextStreamPrivate::flushWriteBuffer()
codec = QTextCodec::codecForLocale();
#if defined (QTEXTSTREAM_DEBUG)
qDebug("QTextStreamPrivate::flushWriteBuffer(), using %s codec (%s generating BOM)",
- codec->name().constData(), writeConverterState.flags & QTextCodec::IgnoreHeader ? "not" : "");
+ codec ? codec->name().constData() : "no",
+ !codec || (writeConverterState.flags & QTextCodec::IgnoreHeader) ? "not" : "");
#endif
// convert from unicode to raw data
@@ -572,7 +574,7 @@ void QTextStreamPrivate::flushWriteBuffer()
QByteArray data = Q_LIKELY(codec) ? codec->fromUnicode(writeBuffer.data(), writeBuffer.size(), &writeConverterState)
: writeBuffer.toLatin1();
#else
- QByteArray data = writeBuffer.toLocal8Bit();
+ QByteArray data = writeBuffer.toLatin1();
#endif
writeBuffer.clear();
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 945b7df930..e6c570d1db 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -186,7 +186,7 @@ public:
QString url(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toDisplayString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
- QUrl adjusted(FormattingOptions options) const;
+ QUrl adjusted(FormattingOptions options) const Q_REQUIRED_RESULT;
QByteArray toEncoded(FormattingOptions options = FullyEncoded) const;
static QUrl fromEncoded(const QByteArray &url, ParsingMode mode = TolerantMode);
@@ -243,7 +243,7 @@ public:
QString fragment(ComponentFormattingOptions options = PrettyDecoded) const;
void setFragment(const QString &fragment, ParsingMode mode = TolerantMode);
- QUrl resolved(const QUrl &relative) const;
+ QUrl resolved(const QUrl &relative) const Q_REQUIRED_RESULT;
bool isRelative() const;
bool isParentOf(const QUrl &url) const;
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index 1502e5dada..2cc5741250 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -36,7 +36,6 @@
#include <qdebug.h>
#include <qelapsedtimer.h>
#include <qeventloop.h>
-#include <qtimer.h>
QT_BEGIN_NAMESPACE
@@ -45,13 +44,11 @@ QWindowsPipeReader::QWindowsPipeReader(QObject *parent)
handle(INVALID_HANDLE_VALUE),
readBufferMaxSize(0),
actualReadBufferSize(0),
- emitReadyReadTimer(new QTimer(this)),
+ stopped(true),
readSequenceStarted(false),
pipeBroken(false),
readyReadEmitted(false)
{
- emitReadyReadTimer->setSingleShot(true);
- connect(emitReadyReadTimer, SIGNAL(timeout()), SIGNAL(readyRead()));
dataReadNotifier = new QWinOverlappedIoNotifier(this);
connect(dataReadNotifier, &QWinOverlappedIoNotifier::notified, this, &QWindowsPipeReader::notified);
}
@@ -73,12 +70,7 @@ static bool qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped)
QWindowsPipeReader::~QWindowsPipeReader()
{
- if (readSequenceStarted) {
- if (qt_cancelIo(handle, &overlapped))
- dataReadNotifier->waitForNotified(-1, &overlapped);
- else
- qErrnoWarning("QWindowsPipeReader: qt_cancelIo on handle %x failed.", handle);
- }
+ stop();
}
/*!
@@ -89,9 +81,9 @@ void QWindowsPipeReader::setHandle(HANDLE hPipeReadEnd)
readBuffer.clear();
actualReadBufferSize = 0;
handle = hPipeReadEnd;
- ZeroMemory(&overlapped, sizeof(overlapped));
pipeBroken = false;
readyReadEmitted = false;
+ stopped = false;
if (hPipeReadEnd != INVALID_HANDLE_VALUE) {
dataReadNotifier->setHandle(hPipeReadEnd);
dataReadNotifier->setEnabled(true);
@@ -100,13 +92,24 @@ void QWindowsPipeReader::setHandle(HANDLE hPipeReadEnd)
/*!
Stops the asynchronous read sequence.
- This function assumes that the file already has been closed.
- It does not cancel any I/O operation.
+ If the read sequence is running then the I/O operation is canceled.
*/
void QWindowsPipeReader::stop()
{
- dataReadNotifier->setEnabled(false);
+ stopped = true;
+ if (readSequenceStarted) {
+ if (qt_cancelIo(handle, &overlapped)) {
+ dataReadNotifier->waitForNotified(-1, &overlapped);
+ } else {
+ const DWORD dwError = GetLastError();
+ if (dwError != ERROR_NOT_FOUND) {
+ qErrnoWarning(dwError, "QWindowsPipeReader: qt_cancelIo on handle %x failed.",
+ handle);
+ }
+ }
+ }
readSequenceStarted = false;
+ dataReadNotifier->setEnabled(false);
handle = INVALID_HANDLE_VALUE;
}
@@ -119,7 +122,7 @@ qint64 QWindowsPipeReader::bytesAvailable() const
}
/*!
- Stops the asynchronous read sequence.
+ Copies at most \c{maxlen} bytes from the internal read buffer to \c{data}.
*/
qint64 QWindowsPipeReader::read(char *data, qint64 maxlen)
{
@@ -147,9 +150,7 @@ qint64 QWindowsPipeReader::read(char *data, qint64 maxlen)
}
if (!pipeBroken) {
- if (!actualReadBufferSize)
- emitReadyReadTimer->stop();
- if (!readSequenceStarted)
+ if (!readSequenceStarted && !stopped)
startAsyncRead();
if (readSoFar == 0)
return -2; // signal EWOULDBLOCK
@@ -172,13 +173,41 @@ void QWindowsPipeReader::notified(quint32 numberOfBytesRead, quint32 errorCode,
{
if (&overlapped != notifiedOverlapped)
return;
- if (!completeAsyncRead(numberOfBytesRead, errorCode)) {
+
+ switch (errorCode) {
+ case ERROR_SUCCESS:
+ break;
+ case ERROR_MORE_DATA:
+ // This is not an error. We're connected to a message mode
+ // pipe and the message didn't fit into the pipe's system
+ // buffer. We will read the remaining data in the next call.
+ break;
+ case ERROR_BROKEN_PIPE:
+ case ERROR_PIPE_NOT_CONNECTED:
pipeBroken = true;
+ break;
+ default:
+ emit winError(errorCode, QLatin1String("QWindowsPipeReader::completeAsyncRead"));
+ pipeBroken = true;
+ break;
+ }
+
+ readSequenceStarted = false;
+
+ // After the reader was stopped, the only reason why this function can be called is the
+ // completion of a cancellation. No signals should be emitted, and no new read sequence should
+ // be started in this case.
+ if (stopped)
+ return;
+
+ if (pipeBroken) {
emit pipeClosed();
return;
}
+
+ actualReadBufferSize += numberOfBytesRead;
+ readBuffer.truncate(actualReadBufferSize);
startAsyncRead();
- emitReadyReadTimer->stop();
readyReadEmitted = true;
emit readyRead();
}
@@ -206,6 +235,7 @@ void QWindowsPipeReader::startAsyncRead()
char *ptr = readBuffer.reserve(bytesToRead);
readSequenceStarted = true;
+ ZeroMemory(&overlapped, sizeof(overlapped));
if (ReadFile(handle, ptr, bytesToRead, NULL, &overlapped)) {
// We get notified by the QWinOverlappedIoNotifier - even in the synchronous case.
return;
@@ -241,38 +271,6 @@ void QWindowsPipeReader::startAsyncRead()
/*!
\internal
- Sets the correct size of the read buffer after a read operation.
- Returns \c false, if an error occurred or the connection dropped.
- */
-bool QWindowsPipeReader::completeAsyncRead(DWORD bytesRead, DWORD errorCode)
-{
- readSequenceStarted = false;
-
- switch (errorCode) {
- case ERROR_SUCCESS:
- break;
- case ERROR_MORE_DATA:
- // This is not an error. We're connected to a message mode
- // pipe and the message didn't fit into the pipe's system
- // buffer. We will read the remaining data in the next call.
- break;
- case ERROR_BROKEN_PIPE:
- case ERROR_PIPE_NOT_CONNECTED:
- return false;
- default:
- emit winError(errorCode, QLatin1String("QWindowsPipeReader::completeAsyncRead"));
- return false;
- }
-
- actualReadBufferSize += bytesRead;
- readBuffer.truncate(actualReadBufferSize);
- if (!emitReadyReadTimer->isActive())
- emitReadyReadTimer->start();
- return true;
-}
-
-/*!
- \internal
Returns the number of available bytes in the pipe.
Sets QWindowsPipeReader::pipeBroken to true if the connection is broken.
*/
diff --git a/src/corelib/io/qwindowspipereader_p.h b/src/corelib/io/qwindowspipereader_p.h
index 53872e2552..c8a66d9511 100644
--- a/src/corelib/io/qwindowspipereader_p.h
+++ b/src/corelib/io/qwindowspipereader_p.h
@@ -47,7 +47,6 @@
#include <qbytearray.h>
#include <qobject.h>
-#include <qtimer.h>
#include <private/qringbuffer_p.h>
#include <qt_windows.h>
@@ -89,7 +88,6 @@ private Q_SLOTS:
void notified(quint32 numberOfBytesRead, quint32 errorCode, OVERLAPPED *notifiedOverlapped);
private:
- bool completeAsyncRead(DWORD bytesRead, DWORD errorCode);
DWORD checkPipeState();
private:
@@ -99,7 +97,7 @@ private:
qint64 readBufferMaxSize;
QRingBuffer readBuffer;
qint64 actualReadBufferSize;
- QTimer *emitReadyReadTimer;
+ bool stopped;
bool readSequenceStarted;
bool pipeBroken;
bool readyReadEmitted;
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 60ac75133c..2f3cfc1c0a 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -479,6 +479,11 @@ public:
Q_GLOBAL_STATIC(QEmptyItemModel, qEmptyModel)
+
+QAbstractItemModelPrivate::~QAbstractItemModelPrivate()
+{
+}
+
QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel()
{
return qEmptyModel();
diff --git a/src/corelib/itemmodels/qabstractitemmodel_p.h b/src/corelib/itemmodels/qabstractitemmodel_p.h
index 075e6a9018..acf376eff1 100644
--- a/src/corelib/itemmodels/qabstractitemmodel_p.h
+++ b/src/corelib/itemmodels/qabstractitemmodel_p.h
@@ -71,6 +71,8 @@ class Q_CORE_EXPORT QAbstractItemModelPrivate : public QObjectPrivate
public:
QAbstractItemModelPrivate() : QObjectPrivate(), supportedDragActions(-1), roleNames(defaultRoleNames()) {}
+ ~QAbstractItemModelPrivate();
+
void removePersistentIndexData(QPersistentModelIndexData *data);
void movePersistentIndexes(const QVector<QPersistentModelIndexData *> &indexes, int change, const QModelIndex &parent, Qt::Orientation orientation);
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last);
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index a215557aed..14c0f803b9 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -131,5 +131,22 @@ QAppleOperatingSystemVersion qt_apple_os_version()
return v;
}
+// -------------------------------------------------------------------------
+
+QMacAutoReleasePool::QMacAutoReleasePool()
+ : pool([[NSAutoreleasePool alloc] init])
+{
+}
+
+QMacAutoReleasePool::~QMacAutoReleasePool()
+{
+ // Drain behaves the same as release, with the advantage that
+ // if we're ever used in a garbage-collected environment, the
+ // drain acts as a hint to the garbage collector to collect.
+ [pool drain];
+}
+
+// -------------------------------------------------------------------------
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 05d58ac028..524bfd26cc 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -325,6 +325,7 @@ struct QCoreApplicationData {
#ifndef QT_NO_LIBRARY
app_libpaths = 0;
#endif
+ applicationNameSet = false;
}
~QCoreApplicationData() {
#ifndef QT_NO_LIBRARY
@@ -369,8 +370,8 @@ struct QCoreApplicationData {
QString orgName, orgDomain;
QString application; // application name, initially from argv[0], can then be modified.
- QString applicationNameCompat; // for QDesktopServices. Only set explicitly.
QString applicationVersion;
+ bool applicationNameSet; // true if setApplicationName was called
#ifndef QT_NO_LIBRARY
QStringList *app_libpaths;
@@ -752,7 +753,8 @@ void QCoreApplication::init()
QCoreApplication::self = this;
// Store app name (so it's still available after QCoreApplication is destroyed)
- coreappdata()->application = d_func()->appName();
+ if (!coreappdata()->applicationNameSet)
+ coreappdata()->application = d_func()->appName();
QLoggingRegistry::instance()->init();
@@ -2349,13 +2351,13 @@ QString QCoreApplication::organizationDomain()
*/
void QCoreApplication::setApplicationName(const QString &application)
{
+ coreappdata()->applicationNameSet = !application.isEmpty();
QString newAppName = application;
if (newAppName.isEmpty() && QCoreApplication::self)
newAppName = QCoreApplication::self->d_func()->appName();
if (coreappdata()->application == newAppName)
return;
coreappdata()->application = newAppName;
- coreappdata()->applicationNameCompat = newAppName;
#ifndef QT_NO_QOBJECT
if (QCoreApplication::self)
emit QCoreApplication::self->applicationNameChanged();
@@ -2373,7 +2375,7 @@ QString QCoreApplication::applicationName()
// Exported for QDesktopServices (Qt4 behavior compatibility)
Q_CORE_EXPORT QString qt_applicationName_noFallback()
{
- return coreappdata()->applicationNameCompat;
+ return coreappdata()->applicationNameSet ? coreappdata()->application : QString();
}
/*!
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp
index cc8e961be1..1509996199 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt.cpp
+++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp
@@ -203,9 +203,9 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags)
}
}
- // Dispatch accumulated user events
- if (sendPostedEvents(flags))
- return true;
+ // Additional user events have to be handled before timer events, but the function may not
+ // return yet.
+ const bool userEventsSent = sendPostedEvents(flags);
emit aboutToBlock();
const QVector<HANDLE> timerHandles = d->timerIdToHandle.values().toVector();
@@ -228,6 +228,9 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags)
return true;
}
emit awake();
+
+ if (userEventsSent)
+ return true;
} while (flags & QEventLoop::WaitForMoreEvents);
return false;
}
@@ -484,7 +487,8 @@ bool QEventDispatcherWinRT::event(QEvent *e)
QEventDispatcherWinRTPrivate::QEventDispatcherWinRTPrivate()
{
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
- HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPoolTimer).Get(), &timerFactory);
+ HRESULT hr;
+ hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPoolTimer).Get(), &timerFactory);
Q_ASSERT_SUCCEEDED(hr);
HANDLE interruptHandle = CreateEventEx(NULL, NULL, NULL, SYNCHRONIZE|EVENT_MODIFY_STATE);
timerIdToHandle.insert(INTERRUPT_HANDLE, interruptHandle);
diff --git a/src/corelib/kernel/qfunctions_winrt.h b/src/corelib/kernel/qfunctions_winrt.h
index 3fff52a22c..7efd042456 100644
--- a/src/corelib/kernel/qfunctions_winrt.h
+++ b/src/corelib/kernel/qfunctions_winrt.h
@@ -131,9 +131,13 @@ generate_inline_return_func2(_putenv_s, errno_t, const char *, const char *)
generate_inline_return_func0(tzset, void)
generate_inline_return_func0(_tzset, void)
-QT_BEGIN_NAMESPACE
+namespace Microsoft {
+ namespace WRL {
+ template <typename T> class ComPtr;
+ }
+}
-namespace Microsoft { namespace WRL { template <typename T> class ComPtr; } }
+QT_BEGIN_NAMESPACE
namespace QWinRTFunctions {
diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp
index 097f641d19..108a01aab7 100644
--- a/src/corelib/kernel/qjni.cpp
+++ b/src/corelib/kernel/qjni.cpp
@@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE
static inline QString keyBase()
{
- return QStringLiteral("%1%2%3");
+ return QStringLiteral("%1%2:%3");
}
static QString qt_convertJString(jstring string)
@@ -72,15 +72,15 @@ typedef QHash<QString, jclass> JClassHash;
Q_GLOBAL_STATIC(JClassHash, cachedClasses)
Q_GLOBAL_STATIC(QReadWriteLock, cachedClassesLock)
-static QString toDotEncodedClassName(const char *className)
+static QByteArray toBinaryEncClassName(const QByteArray &className)
{
- return QString::fromLatin1(className).replace(QLatin1Char('/'), QLatin1Char('.'));
+ return QByteArray(className).replace('/', '.');
}
-static jclass getCachedClass(const QString &classDotEnc, bool *isCached = 0)
+static jclass getCachedClass(const QByteArray &classBinEnc, bool *isCached = 0)
{
QReadLocker locker(cachedClassesLock);
- const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(classDotEnc);
+ const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(QString::fromLatin1(classBinEnc));
const bool found = (it != cachedClasses->constEnd());
if (isCached != 0)
@@ -89,10 +89,12 @@ static jclass getCachedClass(const QString &classDotEnc, bool *isCached = 0)
return found ? it.value() : 0;
}
-static jclass loadClassDotEnc(const QString &classDotEnc, JNIEnv *env)
+inline static jclass loadClass(const QByteArray &className, JNIEnv *env, bool binEncoded = false)
{
+ const QByteArray &binEncClassName = binEncoded ? className : toBinaryEncClassName(className);
+
bool isCached = false;
- jclass clazz = getCachedClass(classDotEnc, &isCached);
+ jclass clazz = getCachedClass(binEncClassName, &isCached);
if (clazz != 0 || isCached)
return clazz;
@@ -102,11 +104,12 @@ static jclass loadClassDotEnc(const QString &classDotEnc, JNIEnv *env)
QWriteLocker locker(cachedClassesLock);
// did we lose the race?
- const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(classDotEnc);
+ const QLatin1String key(binEncClassName);
+ const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(key);
if (it != cachedClasses->constEnd())
return it.value();
- QJNIObjectPrivate stringName = QJNIObjectPrivate::fromString(classDotEnc);
+ QJNIObjectPrivate stringName = QJNIObjectPrivate::fromString(key);
QJNIObjectPrivate classObject = classLoader.callObjectMethod("loadClass",
"(Ljava/lang/String;)Ljava/lang/Class;",
stringName.object());
@@ -114,27 +117,40 @@ static jclass loadClassDotEnc(const QString &classDotEnc, JNIEnv *env)
if (!exceptionCheckAndClear(env) && classObject.isValid())
clazz = static_cast<jclass>(env->NewGlobalRef(classObject.object()));
- cachedClasses->insert(classDotEnc, clazz);
+ cachedClasses->insert(key, clazz);
return clazz;
}
-inline static jclass loadClass(const char *className, JNIEnv *env)
-{
- return loadClassDotEnc(toDotEncodedClassName(className), env);
-}
-
typedef QHash<QString, jmethodID> JMethodIDHash;
Q_GLOBAL_STATIC(JMethodIDHash, cachedMethodID)
Q_GLOBAL_STATIC(QReadWriteLock, cachedMethodIDLock)
+static inline jmethodID getMethodID(JNIEnv *env,
+ jclass clazz,
+ const char *name,
+ const char *sig,
+ bool isStatic = false)
+{
+ jmethodID id = isStatic ? env->GetStaticMethodID(clazz, name, sig)
+ : env->GetMethodID(clazz, name, sig);
+
+ if (exceptionCheckAndClear(env))
+ return 0;
+
+ return id;
+}
+
static jmethodID getCachedMethodID(JNIEnv *env,
jclass clazz,
+ const QByteArray &className,
const char *name,
const char *sig,
bool isStatic = false)
{
- // TODO: We need to use something else then the ref. from clazz to avoid collisions.
- const QString key = keyBase().arg(size_t(clazz)).arg(QLatin1String(name)).arg(QLatin1String(sig));
+ if (className.isEmpty())
+ return getMethodID(env, clazz, name, sig, isStatic);
+
+ const QString key = keyBase().arg(QLatin1String(className)).arg(QLatin1String(name)).arg(QLatin1String(sig));
QHash<QString, jmethodID>::const_iterator it;
{
@@ -150,14 +166,7 @@ static jmethodID getCachedMethodID(JNIEnv *env,
if (it != cachedMethodID->constEnd())
return it.value();
- jmethodID id = 0;
- if (isStatic)
- id = env->GetStaticMethodID(clazz, name, sig);
- else
- id = env->GetMethodID(clazz, name, sig);
-
- if (exceptionCheckAndClear(env))
- id = 0;
+ jmethodID id = getMethodID(env, clazz, name, sig, isStatic);
cachedMethodID->insert(key, id);
return id;
@@ -168,13 +177,32 @@ typedef QHash<QString, jfieldID> JFieldIDHash;
Q_GLOBAL_STATIC(JFieldIDHash, cachedFieldID)
Q_GLOBAL_STATIC(QReadWriteLock, cachedFieldIDLock)
+static inline jfieldID getFieldID(JNIEnv *env,
+ jclass clazz,
+ const char *name,
+ const char *sig,
+ bool isStatic = false)
+{
+ jfieldID id = isStatic ? env->GetStaticFieldID(clazz, name, sig)
+ : env->GetFieldID(clazz, name, sig);
+
+ if (exceptionCheckAndClear(env))
+ return 0;
+
+ return id;
+}
+
static jfieldID getCachedFieldID(JNIEnv *env,
jclass clazz,
+ const QByteArray &className,
const char *name,
const char *sig,
bool isStatic = false)
{
- const QString key = keyBase().arg(size_t(clazz)).arg(QLatin1String(name)).arg(QLatin1String(sig));
+ if (className.isNull())
+ return getFieldID(env, clazz, name, sig, isStatic);
+
+ const QString key = keyBase().arg(QLatin1String(className)).arg(QLatin1String(name)).arg(QLatin1String(sig));
QHash<QString, jfieldID>::const_iterator it;
{
@@ -190,14 +218,7 @@ static jfieldID getCachedFieldID(JNIEnv *env,
if (it != cachedFieldID->constEnd())
return it.value();
- jfieldID id = 0;
- if (isStatic)
- id = env->GetStaticFieldID(clazz, name, sig);
- else
- id = env->GetFieldID(clazz, name, sig);
-
- if (exceptionCheckAndClear(env))
- id = 0;
+ jfieldID id = getFieldID(env, clazz, name, sig, isStatic);
cachedFieldID->insert(key, id);
return id;
@@ -251,7 +272,7 @@ JNIEnv *QJNIEnvironmentPrivate::operator->()
jclass QJNIEnvironmentPrivate::findClass(const char *className, JNIEnv *env)
{
- const QString &classDotEnc = toDotEncodedClassName(className);
+ const QByteArray &classDotEnc = toBinaryEncClassName(className);
bool isCached = false;
jclass clazz = getCachedClass(classDotEnc, &isCached);
@@ -260,9 +281,10 @@ jclass QJNIEnvironmentPrivate::findClass(const char *className, JNIEnv *env)
if (found)
return clazz;
+ const QLatin1String key(classDotEnc);
if (env != 0) { // We got an env. pointer (We expect this to be the right env. and call FindClass())
QWriteLocker locker(cachedClassesLock);
- const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(classDotEnc);
+ const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(key);
// Did we lose the race?
if (it != cachedClasses->constEnd())
return it.value();
@@ -274,11 +296,11 @@ jclass QJNIEnvironmentPrivate::findClass(const char *className, JNIEnv *env)
}
if (clazz != 0)
- cachedClasses->insert(classDotEnc, clazz);
+ cachedClasses->insert(key, clazz);
}
if (clazz == 0) // We didn't get an env. pointer or we got one with the WRONG class loader...
- clazz = loadClassDotEnc(classDotEnc, QJNIEnvironmentPrivate());
+ clazz = loadClass(classDotEnc, QJNIEnvironmentPrivate(), true);
return clazz;
}
@@ -319,11 +341,12 @@ QJNIObjectPrivate::QJNIObjectPrivate(const char *className)
: d(new QJNIObjectData())
{
QJNIEnvironmentPrivate env;
- d->m_jclass = loadClass(className, env);
+ d->m_className = toBinaryEncClassName(className);
+ d->m_jclass = loadClass(d->m_className, env, true);
d->m_own_jclass = false;
if (d->m_jclass) {
// get default constructor
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", "()V");
+ jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", "()V");
if (constructorId) {
jobject obj = env->NewObject(d->m_jclass, constructorId);
if (obj) {
@@ -338,10 +361,11 @@ QJNIObjectPrivate::QJNIObjectPrivate(const char *className, const char *sig, ...
: d(new QJNIObjectData())
{
QJNIEnvironmentPrivate env;
- d->m_jclass = loadClass(className, env);
+ d->m_className = toBinaryEncClassName(className);
+ d->m_jclass = loadClass(d->m_className, env, true);
d->m_own_jclass = false;
if (d->m_jclass) {
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", sig);
+ jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", sig);
if (constructorId) {
va_list args;
va_start(args, sig);
@@ -359,10 +383,11 @@ QJNIObjectPrivate::QJNIObjectPrivate(const char *className, const char *sig, con
: d(new QJNIObjectData())
{
QJNIEnvironmentPrivate env;
- d->m_jclass = loadClass(className, env);
+ d->m_className = toBinaryEncClassName(className);
+ d->m_jclass = loadClass(d->m_className, env, true);
d->m_own_jclass = false;
if (d->m_jclass) {
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", sig);
+ jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", sig);
if (constructorId) {
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
if (obj) {
@@ -380,7 +405,7 @@ QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz)
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
if (d->m_jclass) {
// get default constructor
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", "()V");
+ jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", "()V");
if (constructorId) {
jobject obj = env->NewObject(d->m_jclass, constructorId);
if (obj) {
@@ -398,7 +423,7 @@ QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz, const char *sig, ...)
if (clazz) {
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
if (d->m_jclass) {
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", sig);
+ jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", sig);
if (constructorId) {
va_list args;
va_start(args, sig);
@@ -420,7 +445,7 @@ QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz, const char *sig, const QVaLis
if (clazz) {
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
if (d->m_jclass) {
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", sig);
+ jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", sig);
if (constructorId) {
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
if (obj) {
@@ -440,15 +465,15 @@ QJNIObjectPrivate::QJNIObjectPrivate(jobject obj)
QJNIEnvironmentPrivate env;
d->m_jobject = env->NewGlobalRef(obj);
- jclass objectClass = env->GetObjectClass(d->m_jobject);
- d->m_jclass = static_cast<jclass>(env->NewGlobalRef(objectClass));
- env->DeleteLocalRef(objectClass);
+ jclass cls = env->GetObjectClass(obj);
+ d->m_jclass = static_cast<jclass>(env->NewGlobalRef(cls));
+ env->DeleteLocalRef(cls);
}
template <>
void QJNIObjectPrivate::callMethodV<void>(const char *methodName, const char *sig, va_list args) const
{
QJNIEnvironmentPrivate env;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
env->CallVoidMethodV(d->m_jobject, id, args);
}
@@ -468,7 +493,7 @@ jboolean QJNIObjectPrivate::callMethodV<jboolean>(const char *methodName, const
{
QJNIEnvironmentPrivate env;
jboolean res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallBooleanMethodV(d->m_jobject, id, args);
}
@@ -490,7 +515,7 @@ jbyte QJNIObjectPrivate::callMethodV<jbyte>(const char *methodName, const char *
{
QJNIEnvironmentPrivate env;
jbyte res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallByteMethodV(d->m_jobject, id, args);
}
@@ -512,7 +537,7 @@ jchar QJNIObjectPrivate::callMethodV<jchar>(const char *methodName, const char *
{
QJNIEnvironmentPrivate env;
jchar res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallCharMethodV(d->m_jobject, id, args);
}
@@ -534,7 +559,7 @@ jshort QJNIObjectPrivate::callMethodV<jshort>(const char *methodName, const char
{
QJNIEnvironmentPrivate env;
jshort res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallShortMethodV(d->m_jobject, id, args);
}
@@ -556,7 +581,7 @@ jint QJNIObjectPrivate::callMethodV<jint>(const char *methodName, const char *si
{
QJNIEnvironmentPrivate env;
jint res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallIntMethodV(d->m_jobject, id, args);
}
@@ -578,7 +603,7 @@ jlong QJNIObjectPrivate::callMethodV<jlong>(const char *methodName, const char *
{
QJNIEnvironmentPrivate env;
jlong res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallLongMethodV(d->m_jobject, id, args);
}
@@ -600,7 +625,7 @@ jfloat QJNIObjectPrivate::callMethodV<jfloat>(const char *methodName, const char
{
QJNIEnvironmentPrivate env;
jfloat res = 0.f;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallFloatMethodV(d->m_jobject, id, args);
}
@@ -622,7 +647,7 @@ jdouble QJNIObjectPrivate::callMethodV<jdouble>(const char *methodName, const ch
{
QJNIEnvironmentPrivate env;
jdouble res = 0.;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallDoubleMethodV(d->m_jobject, id, args);
}
@@ -702,7 +727,7 @@ void QJNIObjectPrivate::callStaticMethodV<void>(const char *className,
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
env->CallStaticVoidMethodV(clazz, id, args);
}
@@ -728,7 +753,7 @@ void QJNIObjectPrivate::callStaticMethodV<void>(jclass clazz,
va_list args)
{
QJNIEnvironmentPrivate env;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
env->CallStaticVoidMethodV(clazz, id, args);
}
@@ -756,7 +781,7 @@ jboolean QJNIObjectPrivate::callStaticMethodV<jboolean>(const char *className,
jboolean res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticBooleanMethodV(clazz, id, args);
}
@@ -786,7 +811,7 @@ jboolean QJNIObjectPrivate::callStaticMethodV<jboolean>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jboolean res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticBooleanMethodV(clazz, id, args);
}
@@ -817,7 +842,7 @@ jbyte QJNIObjectPrivate::callStaticMethodV<jbyte>(const char *className,
jbyte res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticByteMethodV(clazz, id, args);
}
@@ -847,7 +872,7 @@ jbyte QJNIObjectPrivate::callStaticMethodV<jbyte>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jbyte res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticByteMethodV(clazz, id, args);
}
@@ -878,7 +903,7 @@ jchar QJNIObjectPrivate::callStaticMethodV<jchar>(const char *className,
jchar res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticCharMethodV(clazz, id, args);
}
@@ -908,7 +933,7 @@ jchar QJNIObjectPrivate::callStaticMethodV<jchar>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jchar res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticCharMethodV(clazz, id, args);
}
@@ -939,7 +964,7 @@ jshort QJNIObjectPrivate::callStaticMethodV<jshort>(const char *className,
jshort res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticShortMethodV(clazz, id, args);
}
@@ -969,7 +994,7 @@ jshort QJNIObjectPrivate::callStaticMethodV<jshort>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jshort res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticShortMethodV(clazz, id, args);
}
@@ -1000,7 +1025,7 @@ jint QJNIObjectPrivate::callStaticMethodV<jint>(const char *className,
jint res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticIntMethodV(clazz, id, args);
}
@@ -1030,7 +1055,7 @@ jint QJNIObjectPrivate::callStaticMethodV<jint>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jint res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticIntMethodV(clazz, id, args);
}
@@ -1061,7 +1086,7 @@ jlong QJNIObjectPrivate::callStaticMethodV<jlong>(const char *className,
jlong res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticLongMethodV(clazz, id, args);
}
@@ -1091,7 +1116,7 @@ jlong QJNIObjectPrivate::callStaticMethodV<jlong>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jlong res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticLongMethodV(clazz, id, args);
}
@@ -1122,7 +1147,7 @@ jfloat QJNIObjectPrivate::callStaticMethodV<jfloat>(const char *className,
jfloat res = 0.f;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticFloatMethodV(clazz, id, args);
}
@@ -1152,7 +1177,7 @@ jfloat QJNIObjectPrivate::callStaticMethodV<jfloat>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jfloat res = 0.f;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticFloatMethodV(clazz, id, args);
}
@@ -1183,7 +1208,7 @@ jdouble QJNIObjectPrivate::callStaticMethodV<jdouble>(const char *className,
jdouble res = 0.;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticDoubleMethodV(clazz, id, args);
}
@@ -1213,7 +1238,7 @@ jdouble QJNIObjectPrivate::callStaticMethodV<jdouble>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jdouble res = 0.;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticDoubleMethodV(clazz, id, args);
}
@@ -1348,7 +1373,7 @@ QJNIObjectPrivate QJNIObjectPrivate::callObjectMethodV(const char *methodName,
{
QJNIEnvironmentPrivate env;
jobject res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallObjectMethodV(d->m_jobject, id, args);
if (res && env->ExceptionCheck())
@@ -1428,7 +1453,7 @@ QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethodV(const char *classNa
jobject res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticObjectMethodV(clazz, id, args);
if (res && env->ExceptionCheck())
@@ -1460,7 +1485,7 @@ QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethodV(jclass clazz,
{
QJNIEnvironmentPrivate env;
jobject res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticObjectMethodV(clazz, id, args);
if (res && env->ExceptionCheck())
@@ -1489,7 +1514,7 @@ jboolean QJNIObjectPrivate::getField<jboolean>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jboolean res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "Z");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "Z");
if (id)
res = env->GetBooleanField(d->m_jobject, id);
@@ -1501,7 +1526,7 @@ jbyte QJNIObjectPrivate::getField<jbyte>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jbyte res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "B");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "B");
if (id)
res = env->GetByteField(d->m_jobject, id);
@@ -1513,7 +1538,7 @@ jchar QJNIObjectPrivate::getField<jchar>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jchar res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "C");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "C");
if (id)
res = env->GetCharField(d->m_jobject, id);
@@ -1525,7 +1550,7 @@ jshort QJNIObjectPrivate::getField<jshort>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jshort res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "S");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "S");
if (id)
res = env->GetShortField(d->m_jobject, id);
@@ -1537,7 +1562,7 @@ jint QJNIObjectPrivate::getField<jint>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jint res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "I");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "I");
if (id)
res = env->GetIntField(d->m_jobject, id);
@@ -1549,7 +1574,7 @@ jlong QJNIObjectPrivate::getField<jlong>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jlong res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "J");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "J");
if (id)
res = env->GetLongField(d->m_jobject, id);
@@ -1561,7 +1586,7 @@ jfloat QJNIObjectPrivate::getField<jfloat>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jfloat res = 0.f;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "F");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "F");
if (id)
res = env->GetFloatField(d->m_jobject, id);
@@ -1573,7 +1598,7 @@ jdouble QJNIObjectPrivate::getField<jdouble>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jdouble res = 0.;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "D");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "D");
if (id)
res = env->GetDoubleField(d->m_jobject, id);
@@ -1585,7 +1610,7 @@ jboolean QJNIObjectPrivate::getStaticField<jboolean>(jclass clazz, const char *f
{
QJNIEnvironmentPrivate env;
jboolean res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "Z", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "Z", true);
if (id)
res = env->GetStaticBooleanField(clazz, id);
@@ -1596,12 +1621,15 @@ template <>
jboolean QJNIObjectPrivate::getStaticField<jboolean>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jboolean res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jboolean>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "Z", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticBooleanField(clazz, id);
}
template <>
@@ -1609,7 +1637,7 @@ jbyte QJNIObjectPrivate::getStaticField<jbyte>(jclass clazz, const char *fieldNa
{
QJNIEnvironmentPrivate env;
jbyte res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "B", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "B", true);
if (id)
res = env->GetStaticByteField(clazz, id);
@@ -1620,12 +1648,15 @@ template <>
jbyte QJNIObjectPrivate::getStaticField<jbyte>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jbyte res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jbyte>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "B", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticByteField(clazz, id);
}
template <>
@@ -1633,7 +1664,7 @@ jchar QJNIObjectPrivate::getStaticField<jchar>(jclass clazz, const char *fieldNa
{
QJNIEnvironmentPrivate env;
jchar res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "C", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "C", true);
if (id)
res = env->GetStaticCharField(clazz, id);
@@ -1644,12 +1675,15 @@ template <>
jchar QJNIObjectPrivate::getStaticField<jchar>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jchar res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jchar>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "C", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticCharField(clazz, id);
}
template <>
@@ -1657,7 +1691,7 @@ jshort QJNIObjectPrivate::getStaticField<jshort>(jclass clazz, const char *field
{
QJNIEnvironmentPrivate env;
jshort res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "S", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "S", true);
if (id)
res = env->GetStaticShortField(clazz, id);
@@ -1668,12 +1702,15 @@ template <>
jshort QJNIObjectPrivate::getStaticField<jshort>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jshort res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jshort>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "S", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticShortField(clazz, id);
}
template <>
@@ -1681,7 +1718,7 @@ jint QJNIObjectPrivate::getStaticField<jint>(jclass clazz, const char *fieldName
{
QJNIEnvironmentPrivate env;
jint res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "I", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "I", true);
if (id)
res = env->GetStaticIntField(clazz, id);
@@ -1692,12 +1729,15 @@ template <>
jint QJNIObjectPrivate::getStaticField<jint>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jint res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jint>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "I", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticIntField(clazz, id);
}
template <>
@@ -1705,7 +1745,7 @@ jlong QJNIObjectPrivate::getStaticField<jlong>(jclass clazz, const char *fieldNa
{
QJNIEnvironmentPrivate env;
jlong res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "J", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "J", true);
if (id)
res = env->GetStaticLongField(clazz, id);
@@ -1716,12 +1756,15 @@ template <>
jlong QJNIObjectPrivate::getStaticField<jlong>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jlong res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jlong>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "J", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticLongField(clazz, id);
}
template <>
@@ -1729,7 +1772,7 @@ jfloat QJNIObjectPrivate::getStaticField<jfloat>(jclass clazz, const char *field
{
QJNIEnvironmentPrivate env;
jfloat res = 0.f;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "F", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "F", true);
if (id)
res = env->GetStaticFloatField(clazz, id);
@@ -1740,12 +1783,15 @@ template <>
jfloat QJNIObjectPrivate::getStaticField<jfloat>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jfloat res = 0.f;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jfloat>(clazz, fieldName);
+ if (clazz == 0)
+ return 0.f;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "F", true);
+ if (id == 0)
+ return 0.f;
+
+ return env->GetStaticFloatField(clazz, id);
}
template <>
@@ -1753,7 +1799,7 @@ jdouble QJNIObjectPrivate::getStaticField<jdouble>(jclass clazz, const char *fie
{
QJNIEnvironmentPrivate env;
jdouble res = 0.;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "D", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "D", true);
if (id)
res = env->GetStaticDoubleField(clazz, id);
@@ -1764,12 +1810,15 @@ template <>
jdouble QJNIObjectPrivate::getStaticField<jdouble>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jdouble res = 0.;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jdouble>(clazz, fieldName);
+ if (clazz == 0)
+ return 0.;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "D", true);
+ if (id == 0)
+ return 0.;
+
+ return env->GetStaticDoubleField(clazz, id);
}
QJNIObjectPrivate QJNIObjectPrivate::getObjectField(const char *fieldName,
@@ -1777,7 +1826,7 @@ QJNIObjectPrivate QJNIObjectPrivate::getObjectField(const char *fieldName,
{
QJNIEnvironmentPrivate env;
jobject res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, sig);
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, sig);
if (id) {
res = env->GetObjectField(d->m_jobject, id);
if (res && env->ExceptionCheck())
@@ -1794,12 +1843,21 @@ QJNIObjectPrivate QJNIObjectPrivate::getStaticObjectField(const char *className,
const char *sig)
{
QJNIEnvironmentPrivate env;
- QJNIObjectPrivate res;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticObjectField(clazz, fieldName, sig);
+ if (clazz == 0)
+ return QJNIObjectPrivate();
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, sig, true);
+ if (id == 0)
+ return QJNIObjectPrivate();
+
+ jobject res = env->GetStaticObjectField(clazz, id);
+ if (res && env->ExceptionCheck())
+ res = 0;
+
+ QJNIObjectPrivate obj(res);
+ env->DeleteLocalRef(res);
+ return obj;
}
QJNIObjectPrivate QJNIObjectPrivate::getStaticObjectField(jclass clazz,
@@ -1808,7 +1866,7 @@ QJNIObjectPrivate QJNIObjectPrivate::getStaticObjectField(jclass clazz,
{
QJNIEnvironmentPrivate env;
jobject res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, sig, true);
+ jfieldID id = getFieldID(env, clazz, fieldName, sig, true);
if (id) {
res = env->GetStaticObjectField(clazz, id);
if (res && env->ExceptionCheck())
@@ -1824,7 +1882,7 @@ template <>
void QJNIObjectPrivate::setField<jboolean>(const char *fieldName, jboolean value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "Z");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "Z");
if (id)
env->SetBooleanField(d->m_jobject, id, value);
@@ -1834,7 +1892,7 @@ template <>
void QJNIObjectPrivate::setField<jbyte>(const char *fieldName, jbyte value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "B");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "B");
if (id)
env->SetByteField(d->m_jobject, id, value);
@@ -1844,7 +1902,7 @@ template <>
void QJNIObjectPrivate::setField<jchar>(const char *fieldName, jchar value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "C");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "C");
if (id)
env->SetCharField(d->m_jobject, id, value);
@@ -1854,7 +1912,7 @@ template <>
void QJNIObjectPrivate::setField<jshort>(const char *fieldName, jshort value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "S");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "S");
if (id)
env->SetShortField(d->m_jobject, id, value);
@@ -1864,7 +1922,7 @@ template <>
void QJNIObjectPrivate::setField<jint>(const char *fieldName, jint value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "I");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "I");
if (id)
env->SetIntField(d->m_jobject, id, value);
@@ -1874,7 +1932,7 @@ template <>
void QJNIObjectPrivate::setField<jlong>(const char *fieldName, jlong value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "J");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "J");
if (id)
env->SetLongField(d->m_jobject, id, value);
@@ -1884,7 +1942,7 @@ template <>
void QJNIObjectPrivate::setField<jfloat>(const char *fieldName, jfloat value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "F");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "F");
if (id)
env->SetFloatField(d->m_jobject, id, value);
@@ -1894,7 +1952,7 @@ template <>
void QJNIObjectPrivate::setField<jdouble>(const char *fieldName, jdouble value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "D");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "D");
if (id)
env->SetDoubleField(d->m_jobject, id, value);
@@ -1904,7 +1962,7 @@ template <>
void QJNIObjectPrivate::setField<jbooleanArray>(const char *fieldName, jbooleanArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[Z");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[Z");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1914,7 +1972,7 @@ template <>
void QJNIObjectPrivate::setField<jbyteArray>(const char *fieldName, jbyteArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[B");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[B");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1924,7 +1982,7 @@ template <>
void QJNIObjectPrivate::setField<jcharArray>(const char *fieldName, jcharArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[C");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[C");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1934,7 +1992,7 @@ template <>
void QJNIObjectPrivate::setField<jshortArray>(const char *fieldName, jshortArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[S");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[S");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1944,7 +2002,7 @@ template <>
void QJNIObjectPrivate::setField<jintArray>(const char *fieldName, jintArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[I");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[I");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1954,7 +2012,7 @@ template <>
void QJNIObjectPrivate::setField<jlongArray>(const char *fieldName, jlongArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[J");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[J");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1964,7 +2022,7 @@ template <>
void QJNIObjectPrivate::setField<jfloatArray>(const char *fieldName, jfloatArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[F");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[F");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1974,7 +2032,7 @@ template <>
void QJNIObjectPrivate::setField<jdoubleArray>(const char *fieldName, jdoubleArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[D");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[D");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1984,7 +2042,7 @@ template <>
void QJNIObjectPrivate::setField<jstring>(const char *fieldName, jstring value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "Ljava/lang/String;");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "Ljava/lang/String;");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1996,7 +2054,7 @@ void QJNIObjectPrivate::setField<jobject>(const char *fieldName,
jobject value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, sig);
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, sig);
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -2008,7 +2066,7 @@ void QJNIObjectPrivate::setField<jobjectArray>(const char *fieldName,
jobjectArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, sig);
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, sig);
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -2020,7 +2078,7 @@ void QJNIObjectPrivate::setStaticField<jboolean>(jclass clazz,
jboolean value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "Z", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "Z", true);
if (id)
env->SetStaticBooleanField(clazz, id, value);
}
@@ -2032,8 +2090,14 @@ void QJNIObjectPrivate::setStaticField<jboolean>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jboolean>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "Z", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticBooleanField(clazz, id, value);
}
template <>
@@ -2042,7 +2106,7 @@ void QJNIObjectPrivate::setStaticField<jbyte>(jclass clazz,
jbyte value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "B", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "B", true);
if (id)
env->SetStaticByteField(clazz, id, value);
}
@@ -2054,8 +2118,14 @@ void QJNIObjectPrivate::setStaticField<jbyte>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jbyte>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "B", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticByteField(clazz, id, value);
}
template <>
@@ -2064,7 +2134,7 @@ void QJNIObjectPrivate::setStaticField<jchar>(jclass clazz,
jchar value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "C", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "C", true);
if (id)
env->SetStaticCharField(clazz, id, value);
}
@@ -2076,8 +2146,14 @@ void QJNIObjectPrivate::setStaticField<jchar>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jchar>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "C", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticCharField(clazz, id, value);
}
template <>
@@ -2086,7 +2162,7 @@ void QJNIObjectPrivate::setStaticField<jshort>(jclass clazz,
jshort value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "S", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "S", true);
if (id)
env->SetStaticShortField(clazz, id, value);
}
@@ -2098,8 +2174,14 @@ void QJNIObjectPrivate::setStaticField<jshort>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jshort>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "S", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticShortField(clazz, id, value);
}
template <>
@@ -2108,7 +2190,7 @@ void QJNIObjectPrivate::setStaticField<jint>(jclass clazz,
jint value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "I", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "I", true);
if (id)
env->SetStaticIntField(clazz, id, value);
}
@@ -2120,8 +2202,14 @@ void QJNIObjectPrivate::setStaticField<jint>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jint>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "I", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticIntField(clazz, id, value);
}
template <>
@@ -2130,7 +2218,7 @@ void QJNIObjectPrivate::setStaticField<jlong>(jclass clazz,
jlong value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "J", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "J", true);
if (id)
env->SetStaticLongField(clazz, id, value);
}
@@ -2142,8 +2230,14 @@ void QJNIObjectPrivate::setStaticField<jlong>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jlong>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "J", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticLongField(clazz, id, value);
}
template <>
@@ -2152,7 +2246,7 @@ void QJNIObjectPrivate::setStaticField<jfloat>(jclass clazz,
jfloat value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "F", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "F", true);
if (id)
env->SetStaticFloatField(clazz, id, value);
}
@@ -2164,8 +2258,14 @@ void QJNIObjectPrivate::setStaticField<jfloat>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jfloat>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "F", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticFloatField(clazz, id, value);
}
template <>
@@ -2174,7 +2274,7 @@ void QJNIObjectPrivate::setStaticField<jdouble>(jclass clazz,
jdouble value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "D", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "D", true);
if (id)
env->SetStaticDoubleField(clazz, id, value);
}
@@ -2186,8 +2286,14 @@ void QJNIObjectPrivate::setStaticField<jdouble>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jdouble>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "D", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticDoubleField(clazz, id, value);
}
template <>
@@ -2197,7 +2303,7 @@ void QJNIObjectPrivate::setStaticField<jobject>(jclass clazz,
jobject value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, sig, true);
+ jfieldID id = getFieldID(env, clazz, fieldName, sig, true);
if (id)
env->SetStaticObjectField(clazz, id, value);
}
@@ -2210,8 +2316,14 @@ void QJNIObjectPrivate::setStaticField<jobject>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jobject>(clazz, fieldName, sig, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, sig, true);
+ if (id == 0)
+ return;
+
+ env->SetStaticObjectField(clazz, id, value);
}
QJNIObjectPrivate QJNIObjectPrivate::fromString(const QString &string)
diff --git a/src/corelib/kernel/qjni_p.h b/src/corelib/kernel/qjni_p.h
index ae9c7c3a7e..1c23f2ab76 100644
--- a/src/corelib/kernel/qjni_p.h
+++ b/src/corelib/kernel/qjni_p.h
@@ -82,6 +82,7 @@ public:
jobject m_jobject;
jclass m_jclass;
bool m_own_jclass;
+ QByteArray m_className;
};
class Q_CORE_EXPORT QJNIObjectPrivate
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 1e2a860d8c..1b214e9f74 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -1357,12 +1357,16 @@ namespace QtPrivate
enum { Value = sizeof(checkType(static_cast<T*>(0))) == sizeof(yes_type) };
};
+ template<typename T, typename Enable = void>
+ struct IsGadgetHelper { enum { Value = false }; };
+
template<typename T>
- struct IsGadgetHelper
+ struct IsGadgetHelper<T, typename T::QtGadgetHelper>
{
- template<typename X> static typename X::QtGadgetHelper *checkType(X*);
- static char checkType(void*);
- enum { Value = sizeof(checkType(static_cast<T*>(0))) == sizeof(void*) };
+ template <typename X>
+ static char checkType(void (X::*)());
+ static void *checkType(void (T::*)());
+ enum { Value = sizeof(checkType(&T::qt_check_for_QGADGET_macro)) == sizeof(void *) };
};
@@ -1381,6 +1385,7 @@ QT_WARNING_DISABLE_CLANG("-Wlocal-type-template-args")
// qt_getEnumMetaObject(T) which returns 'char'
enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) };
};
+ template<> struct IsQEnumHelper<void> { enum { Value = false }; };
QT_WARNING_POP
template<typename T, typename Enable = void>
@@ -1768,7 +1773,7 @@ template <typename T>
struct QMetaTypeIdQObject<T, QMetaType::IsGadget>
{
enum {
- Defined = 1
+ Defined = QtPrivate::is_default_constructible<T>::value
};
static int qt_metatype_id()
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index fb4c5cceb9..3ca9c890e8 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -65,6 +65,16 @@ QT_BEGIN_NAMESPACE
static int DIRECT_CONNECTION_ONLY = 0;
+
+QDynamicMetaObjectData::~QDynamicMetaObjectData()
+{
+}
+
+QAbstractDynamicMetaObject::~QAbstractDynamicMetaObject()
+{
+}
+
+
struct QSlotObjectBaseDeleter { // for use with QScopedPointer<QSlotObjectBase,...>
static void cleanup(QtPrivate::QSlotObjectBase *slot) {
if (slot) slot->destroyIfLastRef();
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 1b64103e40..bd5ee006bf 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -406,7 +406,7 @@ void Q_CORE_EXPORT qDeleteInEventHandler(QObject *o);
struct QAbstractDynamicMetaObject;
struct Q_CORE_EXPORT QDynamicMetaObjectData
{
- virtual ~QDynamicMetaObjectData() {}
+ virtual ~QDynamicMetaObjectData();
virtual void objectDestroyed(QObject *) { delete this; }
virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) = 0;
@@ -415,6 +415,8 @@ struct Q_CORE_EXPORT QDynamicMetaObjectData
struct Q_CORE_EXPORT QAbstractDynamicMetaObject : public QDynamicMetaObjectData, public QMetaObject
{
+ ~QAbstractDynamicMetaObject();
+
virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) Q_DECL_OVERRIDE { return this; }
virtual int createProperty(const char *, const char *) { return -1; }
virtual int metaCall(QObject *, QMetaObject::Call c, int _id, void **a) Q_DECL_OVERRIDE
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 31e8a670e9..4d01264906 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -172,6 +172,7 @@ private: \
#define Q_GADGET \
public: \
static const QMetaObject staticMetaObject; \
+ void qt_check_for_QGADGET_macro(); \
typedef void QtGadgetHelper; \
private: \
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);
diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp
index 4d37368b2e..5cc54b1def 100644
--- a/src/corelib/kernel/qsharedmemory_win.cpp
+++ b/src/corelib/kernel/qsharedmemory_win.cpp
@@ -163,6 +163,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
#if defined(Q_OS_WINPHONE)
Q_UNIMPLEMENTED();
Q_UNUSED(mode)
+ Q_UNUSED(permissions)
memory = 0;
#elif defined(Q_OS_WINRT)
memory = (void *)MapViewOfFileFromApp(handle(), permissions, 0, 0);
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 19d84c2b3e..e333104add 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -145,7 +145,7 @@ static QString standardLibraryErrorString(int errorCode)
return ret.trimmed();
}
-QString QSystemError::toString()
+QString QSystemError::toString() const
{
switch(errorScope) {
case NativeError:
diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h
index e7efb9bbf3..29e9e440e4 100644
--- a/src/corelib/kernel/qsystemerror_p.h
+++ b/src/corelib/kernel/qsystemerror_p.h
@@ -62,9 +62,9 @@ public:
inline QSystemError(int error, ErrorScope scope);
inline QSystemError();
- QString toString();
- inline ErrorScope scope();
- inline int error();
+ QString toString() const;
+ inline ErrorScope scope() const;
+ inline int error() const;
//data members
int errorCode;
@@ -83,12 +83,12 @@ QSystemError::QSystemError()
}
-QSystemError::ErrorScope QSystemError::scope()
+QSystemError::ErrorScope QSystemError::scope() const
{
return errorScope;
}
-int QSystemError::error()
+int QSystemError::error() const
{
return errorCode;
}
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp
index ed856a538c..3206ff66e3 100644
--- a/src/corelib/mimetypes/qmimetype.cpp
+++ b/src/corelib/mimetypes/qmimetype.cpp
@@ -54,12 +54,12 @@ QMimeTypePrivate::QMimeTypePrivate()
{}
QMimeTypePrivate::QMimeTypePrivate(const QMimeType &other)
- : name(other.d->name),
+ : loaded(other.d->loaded),
+ name(other.d->name),
localeComments(other.d->localeComments),
genericIconName(other.d->genericIconName),
iconName(other.d->iconName),
- globPatterns(other.d->globPatterns),
- loaded(other.d->loaded)
+ globPatterns(other.d->globPatterns)
{}
void QMimeTypePrivate::clear()
diff --git a/src/corelib/mimetypes/qmimetype_p.h b/src/corelib/mimetypes/qmimetype_p.h
index bf533bbcb0..2161dd8901 100644
--- a/src/corelib/mimetypes/qmimetype_p.h
+++ b/src/corelib/mimetypes/qmimetype_p.h
@@ -66,12 +66,12 @@ public:
void addGlobPattern(const QString &pattern);
+ bool loaded; // QSharedData leaves a 4 byte gap, so don't put 8 byte members first
QString name;
LocaleHash localeComments;
QString genericIconName;
QString iconName;
QStringList globPatterns;
- bool loaded;
};
QT_END_NAMESPACE
diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri
index 338b3d0972..8b64f93467 100644
--- a/src/corelib/plugin/plugin.pri
+++ b/src/corelib/plugin/plugin.pri
@@ -13,6 +13,7 @@ HEADERS += \
plugin/qmachparser_p.h
SOURCES += \
+ plugin/qfactoryinterface.cpp \
plugin/qpluginloader.cpp \
plugin/qfactoryloader.cpp \
plugin/quuid.cpp \
diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm b/src/corelib/plugin/qfactoryinterface.cpp
index 8f30365186..0307d58315 100644
--- a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm
+++ b/src/corelib/plugin/qfactoryinterface.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@@ -31,18 +31,13 @@
**
****************************************************************************/
-#include "qcocoaautoreleasepool.h"
+#include "qfactoryinterface.h"
QT_BEGIN_NAMESPACE
-QCocoaAutoReleasePool::QCocoaAutoReleasePool()
+QFactoryInterface::~QFactoryInterface()
{
- pool = [[NSAutoreleasePool alloc] init];
-}
-
-QCocoaAutoReleasePool::~QCocoaAutoReleasePool()
-{
- [pool release];
+ // must be empty until ### Qt 6
}
QT_END_NAMESPACE
diff --git a/src/corelib/plugin/qfactoryinterface.h b/src/corelib/plugin/qfactoryinterface.h
index e20864cd31..86a46fabfa 100644
--- a/src/corelib/plugin/qfactoryinterface.h
+++ b/src/corelib/plugin/qfactoryinterface.h
@@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE
struct Q_CORE_EXPORT QFactoryInterface
{
- virtual ~QFactoryInterface() {}
+ virtual ~QFactoryInterface();
virtual QStringList keys() const = 0;
};
diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp
index f128acd54e..81b38ea4c4 100644
--- a/src/corelib/statemachine/qabstracttransition.cpp
+++ b/src/corelib/statemachine/qabstracttransition.cpp
@@ -101,7 +101,35 @@ QT_BEGIN_NAMESPACE
parallel group state.
*/
+/*!
+ \property QAbstractTransition::transitionType
+
+ \brief indicates whether this transition is an internal transition, or an external transition.
+
+ Internal and external transitions behave the same, except for the case of a transition whose
+ source state is a compound state and whose target(s) is a descendant of the source. In such a
+ case, an internal transition will not exit and re-enter its source state, while an external one
+ will.
+
+ By default, the type is an external transition.
+*/
+
+/*!
+ \enum QAbstractTransition::TransitionType
+
+ This enum specifies the kind of transition. By default, the type is an external transition.
+
+ \value ExternalTransition Any state that is the source state of a transition (which is not a
+ target-less transition) is left, and re-entered when necessary.
+ \value InternalTransition If the target state of a transition is a sub-state of a compound state,
+ and that compound state is the source state, an internal transition will
+ not leave the source state.
+
+ \sa QAbstractTransition::transitionType
+*/
+
QAbstractTransitionPrivate::QAbstractTransitionPrivate()
+ : transitionType(QAbstractTransition::ExternalTransition)
{
}
@@ -249,6 +277,24 @@ void QAbstractTransition::setTargetStates(const QList<QAbstractState*> &targets)
}
/*!
+ Returns the type of the transition.
+*/
+QAbstractTransition::TransitionType QAbstractTransition::transitionType() const
+{
+ Q_D(const QAbstractTransition);
+ return d->transitionType;
+}
+
+/*!
+ Sets the type of the transition to \a type.
+*/
+void QAbstractTransition::setTransitionType(TransitionType type)
+{
+ Q_D(QAbstractTransition);
+ d->transitionType = type;
+}
+
+/*!
Returns the state machine that this transition is part of, or 0 if the
transition is not part of a state machine.
*/
diff --git a/src/corelib/statemachine/qabstracttransition.h b/src/corelib/statemachine/qabstracttransition.h
index 768a364a4b..bf32b3e825 100644
--- a/src/corelib/statemachine/qabstracttransition.h
+++ b/src/corelib/statemachine/qabstracttransition.h
@@ -59,7 +59,14 @@ class Q_CORE_EXPORT QAbstractTransition : public QObject
Q_PROPERTY(QState* sourceState READ sourceState)
Q_PROPERTY(QAbstractState* targetState READ targetState WRITE setTargetState NOTIFY targetStateChanged)
Q_PROPERTY(QList<QAbstractState*> targetStates READ targetStates WRITE setTargetStates NOTIFY targetStatesChanged)
+ Q_PROPERTY(TransitionType transitionType READ transitionType WRITE setTransitionType)
public:
+ enum TransitionType {
+ ExternalTransition,
+ InternalTransition
+ };
+ Q_ENUM(TransitionType)
+
QAbstractTransition(QState *sourceState = 0);
virtual ~QAbstractTransition();
@@ -69,6 +76,9 @@ public:
QList<QAbstractState*> targetStates() const;
void setTargetStates(const QList<QAbstractState*> &targets);
+ TransitionType transitionType() const;
+ void setTransitionType(TransitionType type);
+
QStateMachine *machine() const;
#ifndef QT_NO_ANIMATION
diff --git a/src/corelib/statemachine/qabstracttransition_p.h b/src/corelib/statemachine/qabstracttransition_p.h
index d89d057497..4b0644acd9 100644
--- a/src/corelib/statemachine/qabstracttransition_p.h
+++ b/src/corelib/statemachine/qabstracttransition_p.h
@@ -73,6 +73,7 @@ public:
void emitTriggered();
QList<QPointer<QAbstractState> > targetStates;
+ QAbstractTransition::TransitionType transitionType;
#ifndef QT_NO_ANIMATION
QList<QAbstractAnimation*> animations;
diff --git a/src/corelib/statemachine/qeventtransition.cpp b/src/corelib/statemachine/qeventtransition.cpp
index 096d667bc3..c10127fa68 100644
--- a/src/corelib/statemachine/qeventtransition.cpp
+++ b/src/corelib/statemachine/qeventtransition.cpp
@@ -102,6 +102,10 @@ QEventTransitionPrivate::QEventTransitionPrivate()
registered = false;
}
+QEventTransitionPrivate::~QEventTransitionPrivate()
+{
+}
+
QEventTransitionPrivate *QEventTransitionPrivate::get(QEventTransition *q)
{
return q->d_func();
diff --git a/src/corelib/statemachine/qeventtransition_p.h b/src/corelib/statemachine/qeventtransition_p.h
index 64ab945187..3e430d86a9 100644
--- a/src/corelib/statemachine/qeventtransition_p.h
+++ b/src/corelib/statemachine/qeventtransition_p.h
@@ -55,14 +55,15 @@ class Q_CORE_EXPORT QEventTransitionPrivate : public QAbstractTransitionPrivate
Q_DECLARE_PUBLIC(QEventTransition)
public:
QEventTransitionPrivate();
+ ~QEventTransitionPrivate();
static QEventTransitionPrivate *get(QEventTransition *q);
void unregister();
void maybeRegister();
- bool registered;
QObject *object;
+ bool registered;
QEvent::Type eventType;
};
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index 28bb176b56..2ce0c13522 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -103,8 +103,8 @@ public:
QAbstractState *initialState;
QState::ChildMode childMode;
mutable bool childStatesListNeedsRefresh;
- mutable QList<QAbstractState*> childStatesList;
mutable bool transitionsListNeedsRefresh;
+ mutable QList<QAbstractState*> childStatesList;
mutable QList<QAbstractTransition*> transitionsList;
#ifndef QT_NO_PROPERTIES
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 3d2da77390..3a1a852ef5 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -177,6 +177,100 @@ QT_BEGIN_NAMESPACE
// #define QSTATEMACHINE_DEBUG
// #define QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG
+struct CalculationCache {
+ struct TransitionInfo {
+ QList<QAbstractState*> effectiveTargetStates;
+ QSet<QAbstractState*> exitSet;
+ QAbstractState *transitionDomain;
+
+ bool effectiveTargetStatesIsKnown: 1;
+ bool exitSetIsKnown : 1;
+ bool transitionDomainIsKnown : 1;
+
+ TransitionInfo()
+ : transitionDomain(0)
+ , effectiveTargetStatesIsKnown(false)
+ , exitSetIsKnown(false)
+ , transitionDomainIsKnown(false)
+ {}
+ };
+
+ typedef QHash<QAbstractTransition *, TransitionInfo> TransitionInfoCache;
+ TransitionInfoCache cache;
+
+ bool effectiveTargetStates(QAbstractTransition *t, QList<QAbstractState *> *targets) const
+ {
+ Q_ASSERT(targets);
+
+ TransitionInfoCache::const_iterator cacheIt = cache.find(t);
+ if (cacheIt == cache.end() || !cacheIt->effectiveTargetStatesIsKnown)
+ return false;
+
+ *targets = cacheIt->effectiveTargetStates;
+ return true;
+ }
+
+ void insert(QAbstractTransition *t, const QList<QAbstractState *> &targets)
+ {
+ TransitionInfoCache::iterator cacheIt = cache.find(t);
+ TransitionInfo &ti = cacheIt == cache.end()
+ ? *cache.insert(t, TransitionInfo())
+ : *cacheIt;
+
+ Q_ASSERT(!ti.effectiveTargetStatesIsKnown);
+ ti.effectiveTargetStates = targets;
+ ti.effectiveTargetStatesIsKnown = true;
+ }
+
+ bool exitSet(QAbstractTransition *t, QSet<QAbstractState *> *exits) const
+ {
+ Q_ASSERT(exits);
+
+ TransitionInfoCache::const_iterator cacheIt = cache.find(t);
+ if (cacheIt == cache.end() || !cacheIt->exitSetIsKnown)
+ return false;
+
+ *exits = cacheIt->exitSet;
+ return true;
+ }
+
+ void insert(QAbstractTransition *t, const QSet<QAbstractState *> &exits)
+ {
+ TransitionInfoCache::iterator cacheIt = cache.find(t);
+ TransitionInfo &ti = cacheIt == cache.end()
+ ? *cache.insert(t, TransitionInfo())
+ : *cacheIt;
+
+ Q_ASSERT(!ti.exitSetIsKnown);
+ ti.exitSet = exits;
+ ti.exitSetIsKnown = true;
+ }
+
+ bool transitionDomain(QAbstractTransition *t, QAbstractState **domain) const
+ {
+ Q_ASSERT(domain);
+
+ TransitionInfoCache::const_iterator cacheIt = cache.find(t);
+ if (cacheIt == cache.end() || !cacheIt->transitionDomainIsKnown)
+ return false;
+
+ *domain = cacheIt->transitionDomain;
+ return true;
+ }
+
+ void insert(QAbstractTransition *t, QAbstractState *domain)
+ {
+ TransitionInfoCache::iterator cacheIt = cache.find(t);
+ TransitionInfo &ti = cacheIt == cache.end()
+ ? *cache.insert(t, TransitionInfo())
+ : *cacheIt;
+
+ Q_ASSERT(!ti.transitionDomainIsKnown);
+ ti.transitionDomain = domain;
+ ti.transitionDomainIsKnown = true;
+ }
+};
+
/* The function as described in http://www.w3.org/TR/2014/WD-scxml-20140529/ :
function isDescendant(state1, state2)
@@ -205,6 +299,17 @@ static bool containsDecendantOf(const QSet<QAbstractState *> &states, const QAbs
return false;
}
+static int descendantDepth(const QAbstractState *state, const QAbstractState *ancestor)
+{
+ int depth = 0;
+ for (const QAbstractState *it = state; it != 0; it = it->parentState()) {
+ if (it == ancestor)
+ break;
+ ++depth;
+ }
+ return depth;
+}
+
/* The function as described in http://www.w3.org/TR/2014/WD-scxml-20140529/ :
function getProperAncestors(state1, state2)
@@ -245,8 +350,14 @@ function getEffectiveTargetStates(transition)
targets.add(s)
return targets
*/
-static QSet<QAbstractState *> getEffectiveTargetStates(QAbstractTransition *transition)
+static QList<QAbstractState *> getEffectiveTargetStates(QAbstractTransition *transition, CalculationCache *cache)
{
+ Q_ASSERT(cache);
+
+ QList<QAbstractState *> targetsList;
+ if (cache->effectiveTargetStates(transition, &targetsList))
+ return targetsList;
+
QSet<QAbstractState *> targets;
foreach (QAbstractState *s, transition->targetStates()) {
if (QHistoryState *historyState = QStateMachinePrivate::toHistoryState(s)) {
@@ -266,7 +377,10 @@ static QSet<QAbstractState *> getEffectiveTargetStates(QAbstractTransition *tran
targets.insert(s);
}
}
- return targets;
+
+ targetsList = targets.toList();
+ cache->insert(transition, targetsList);
+ return targetsList;
}
template <class T>
@@ -348,10 +462,25 @@ static int indexOfDescendant(QState *s, QAbstractState *desc)
bool QStateMachinePrivate::transitionStateEntryLessThan(QAbstractTransition *t1, QAbstractTransition *t2)
{
QState *s1 = t1->sourceState(), *s2 = t2->sourceState();
- if (s1 == s2)
- return QStatePrivate::get(s1)->transitions().indexOf(t1) < QStatePrivate::get(s2)->transitions().indexOf(t2);
- else
- return stateEntryLessThan(t1->sourceState(), t2->sourceState());
+ if (s1 == s2) {
+ QList<QAbstractTransition*> transitions = QStatePrivate::get(s1)->transitions();
+ return transitions.indexOf(t1) < transitions.indexOf(t2);
+ } else if (isDescendant(s1, s2)) {
+ return true;
+ } else if (isDescendant(s2, s1)) {
+ return false;
+ } else {
+ Q_ASSERT(s1->machine() != 0);
+ QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine());
+ QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2);
+ Q_ASSERT(lca != 0);
+ int s1Depth = descendantDepth(s1, lca);
+ int s2Depth = descendantDepth(s2, lca);
+ if (s1Depth == s2Depth)
+ return (indexOfDescendant(lca, s1) < indexOfDescendant(lca, s2));
+ else
+ return s1Depth > s2Depth;
+ }
}
bool QStateMachinePrivate::stateEntryLessThan(QAbstractState *s1, QAbstractState *s2)
@@ -417,8 +546,9 @@ QState *QStateMachinePrivate::findLCCA(const QList<QAbstractState*> &states) con
return findLCA(states, true);
}
-QList<QAbstractTransition*> QStateMachinePrivate::selectTransitions(QEvent *event)
+QList<QAbstractTransition*> QStateMachinePrivate::selectTransitions(QEvent *event, CalculationCache *cache)
{
+ Q_ASSERT(cache);
Q_Q(const QStateMachine);
QVarLengthArray<QAbstractState *> configuration_sorted;
@@ -453,7 +583,7 @@ QList<QAbstractTransition*> QStateMachinePrivate::selectTransitions(QEvent *even
}
if (!enabledTransitions.isEmpty()) {
- removeConflictingTransitions(enabledTransitions);
+ removeConflictingTransitions(enabledTransitions, cache);
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": enabled transitions after removing conflicts:" << enabledTransitions;
#endif
@@ -486,15 +616,20 @@ function removeConflictingTransitions(enabledTransitions):
Note: the implementation below does not build the transitionsToRemove, but removes them in-place.
*/
-void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions)
+void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions, CalculationCache *cache)
{
+ Q_ASSERT(cache);
+
+ if (enabledTransitions.size() < 2)
+ return; // There is no transition to conflict with.
+
QList<QAbstractTransition*> filteredTransitions;
filteredTransitions.reserve(enabledTransitions.size());
std::sort(enabledTransitions.begin(), enabledTransitions.end(), transitionStateEntryLessThan);
foreach (QAbstractTransition *t1, enabledTransitions) {
bool t1Preempted = false;
- QSet<QAbstractState*> exitSetT1 = computeExitSet_Unordered(QList<QAbstractTransition*>() << t1);
+ QSet<QAbstractState*> exitSetT1 = computeExitSet_Unordered(t1, cache);
QList<QAbstractTransition*>::iterator t2It = filteredTransitions.begin();
while (t2It != filteredTransitions.end()) {
QAbstractTransition *t2 = *t2It;
@@ -505,7 +640,7 @@ void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransitio
break;
}
- QSet<QAbstractState*> exitSetT2 = computeExitSet_Unordered(QList<QAbstractTransition*>() << t2);
+ QSet<QAbstractState*> exitSetT2 = computeExitSet_Unordered(t2, cache);
if (exitSetT1.intersect(exitSetT2).isEmpty()) {
// No conflict, no cry. Next patient please.
++t2It;
@@ -529,17 +664,20 @@ void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransitio
enabledTransitions = filteredTransitions;
}
-void QStateMachinePrivate::microstep(QEvent *event, const QList<QAbstractTransition*> &enabledTransitions)
+void QStateMachinePrivate::microstep(QEvent *event, const QList<QAbstractTransition*> &enabledTransitions,
+ CalculationCache *cache)
{
+ Q_ASSERT(cache);
+
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q_func() << ": begin microstep( enabledTransitions:" << enabledTransitions << ')';
qDebug() << q_func() << ": configuration before exiting states:" << configuration;
#endif
- QList<QAbstractState*> exitedStates = computeExitSet(enabledTransitions);
+ QList<QAbstractState*> exitedStates = computeExitSet(enabledTransitions, cache);
QHash<RestorableId, QVariant> pendingRestorables = computePendingRestorables(exitedStates);
QSet<QAbstractState*> statesForDefaultEntry;
- QList<QAbstractState*> enteredStates = computeEntrySet(enabledTransitions, statesForDefaultEntry);
+ QList<QAbstractState*> enteredStates = computeEntrySet(enabledTransitions, statesForDefaultEntry, cache);
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q_func() << ": computed exit set:" << exitedStates;
@@ -598,42 +736,61 @@ function computeExitSet(transitions)
statesToExit.add(s)
return statesToExit
*/
-QList<QAbstractState*> QStateMachinePrivate::computeExitSet(const QList<QAbstractTransition*> &enabledTransitions)
+QList<QAbstractState*> QStateMachinePrivate::computeExitSet(const QList<QAbstractTransition*> &enabledTransitions,
+ CalculationCache *cache)
{
- QList<QAbstractState*> statesToExit_sorted = computeExitSet_Unordered(enabledTransitions).toList();
+ Q_ASSERT(cache);
+
+ QList<QAbstractState*> statesToExit_sorted = computeExitSet_Unordered(enabledTransitions, cache).toList();
std::sort(statesToExit_sorted.begin(), statesToExit_sorted.end(), stateExitLessThan);
return statesToExit_sorted;
}
-QSet<QAbstractState*> QStateMachinePrivate::computeExitSet_Unordered(const QList<QAbstractTransition*> &enabledTransitions)
+QSet<QAbstractState*> QStateMachinePrivate::computeExitSet_Unordered(const QList<QAbstractTransition*> &enabledTransitions,
+ CalculationCache *cache)
{
+ Q_ASSERT(cache);
+
QSet<QAbstractState*> statesToExit;
- for (int i = 0; i < enabledTransitions.size(); ++i) {
- QAbstractTransition *t = enabledTransitions.at(i);
- QList<QAbstractState *> effectiveTargetStates = getEffectiveTargetStates(t).toList();
- QAbstractState *domain = getTransitionDomain(t, effectiveTargetStates);
- if (domain == Q_NULLPTR && !t->targetStates().isEmpty()) {
- // So we didn't find the least common ancestor for the source and target states of the
- // transition. If there were not target states, that would be fine: then the transition
- // will fire any events or signals, but not exit the state.
- //
- // However, there are target states, so it's either a node without a parent (or parent's
- // parent, etc), or the state belongs to a different state machine. Either way, this
- // makes the state machine invalid.
- if (error == QStateMachine::NoError)
- setError(QStateMachine::NoCommonAncestorForTransitionError, t->sourceState());
- QList<QAbstractState *> lst = pendingErrorStates.toList();
- lst.prepend(t->sourceState());
-
- domain = findLCCA(lst);
- Q_ASSERT(domain != 0);
- }
+ foreach (QAbstractTransition *t, enabledTransitions)
+ statesToExit.unite(computeExitSet_Unordered(t, cache));
+ return statesToExit;
+}
- foreach (QAbstractState* s, configuration) {
- if (isDescendant(s, domain))
- statesToExit.insert(s);
- }
- }
+QSet<QAbstractState*> QStateMachinePrivate::computeExitSet_Unordered(QAbstractTransition *t,
+ CalculationCache *cache)
+{
+ Q_ASSERT(cache);
+
+ QSet<QAbstractState*> statesToExit;
+ if (cache->exitSet(t, &statesToExit))
+ return statesToExit;
+
+ QList<QAbstractState *> effectiveTargetStates = getEffectiveTargetStates(t, cache);
+ QAbstractState *domain = getTransitionDomain(t, effectiveTargetStates, cache);
+ if (domain == Q_NULLPTR && !t->targetStates().isEmpty()) {
+ // So we didn't find the least common ancestor for the source and target states of the
+ // transition. If there were not target states, that would be fine: then the transition
+ // will fire any events or signals, but not exit the state.
+ //
+ // However, there are target states, so it's either a node without a parent (or parent's
+ // parent, etc), or the state belongs to a different state machine. Either way, this
+ // makes the state machine invalid.
+ if (error == QStateMachine::NoError)
+ setError(QStateMachine::NoCommonAncestorForTransitionError, t->sourceState());
+ QList<QAbstractState *> lst = pendingErrorStates.toList();
+ lst.prepend(t->sourceState());
+
+ domain = findLCCA(lst);
+ Q_ASSERT(domain != 0);
+ }
+
+ foreach (QAbstractState* s, configuration) {
+ if (isDescendant(s, domain))
+ statesToExit.insert(s);
+ }
+
+ cache->insert(t, statesToExit);
return statesToExit;
}
@@ -695,8 +852,11 @@ void QStateMachinePrivate::executeTransitionContent(QEvent *event, const QList<Q
}
QList<QAbstractState*> QStateMachinePrivate::computeEntrySet(const QList<QAbstractTransition *> &enabledTransitions,
- QSet<QAbstractState *> &statesForDefaultEntry)
+ QSet<QAbstractState *> &statesForDefaultEntry,
+ CalculationCache *cache)
{
+ Q_ASSERT(cache);
+
QSet<QAbstractState*> statesToEnter;
if (pendingErrorStates.isEmpty()) {
foreach (QAbstractTransition *t, enabledTransitions) {
@@ -704,8 +864,8 @@ QList<QAbstractState*> QStateMachinePrivate::computeEntrySet(const QList<QAbstra
addDescendantStatesToEnter(s, statesToEnter, statesForDefaultEntry);
}
- QList<QAbstractState *> effectiveTargetStates = getEffectiveTargetStates(t).toList();
- QAbstractState *ancestor = getTransitionDomain(t, effectiveTargetStates);
+ QList<QAbstractState *> effectiveTargetStates = getEffectiveTargetStates(t, cache);
+ QAbstractState *ancestor = getTransitionDomain(t, effectiveTargetStates, cache);
foreach (QAbstractState *s, effectiveTargetStates) {
addAncestorStatesToEnter(s, ancestor, statesToEnter, statesForDefaultEntry);
}
@@ -742,33 +902,42 @@ function getTransitionDomain(t)
else:
return findLCCA([t.source].append(tstates))
*/
-QAbstractState *QStateMachinePrivate::getTransitionDomain(QAbstractTransition *t, const QList<QAbstractState *> &effectiveTargetStates) const
+QAbstractState *QStateMachinePrivate::getTransitionDomain(QAbstractTransition *t,
+ const QList<QAbstractState *> &effectiveTargetStates,
+ CalculationCache *cache) const
{
+ Q_ASSERT(cache);
+
if (effectiveTargetStates.isEmpty())
return 0;
-#if 0
- // Qt only has external transitions, so skip the special case for the internal transitions
- if (QState *tSource = t->sourceState()) {
- if (isCompound(tSource)) {
- bool allDescendants = true;
- foreach (QAbstractState *s, effectiveTargetStates) {
- if (!isDescendant(s, tSource)) {
- allDescendants = false;
- break;
+ QAbstractState *domain = Q_NULLPTR;
+ if (cache->transitionDomain(t, &domain))
+ return domain;
+
+ if (t->transitionType() == QAbstractTransition::InternalTransition) {
+ if (QState *tSource = t->sourceState()) {
+ if (isCompound(tSource)) {
+ bool allDescendants = true;
+ foreach (QAbstractState *s, effectiveTargetStates) {
+ if (!isDescendant(s, tSource)) {
+ allDescendants = false;
+ break;
+ }
}
- }
- if (allDescendants)
- return tSource;
+ if (allDescendants)
+ return tSource;
+ }
}
}
-#endif
QList<QAbstractState *> states(effectiveTargetStates);
if (QAbstractState *src = t->sourceState())
states.prepend(src);
- return findLCCA(states);
+ domain = findLCCA(states);
+ cache->insert(t, domain);
+ return domain;
}
void QStateMachinePrivate::enterStates(QEvent *event, const QList<QAbstractState*> &exitedStates_sorted,
@@ -1676,6 +1845,8 @@ void QStateMachinePrivate::_q_start()
registerMultiThreadedSignalTransitions();
+ startupHook();
+
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": starting";
#endif
@@ -1683,6 +1854,7 @@ void QStateMachinePrivate::_q_start()
processingScheduled = true; // we call _q_process() below
QList<QAbstractTransition*> transitions;
+ CalculationCache calculationCache;
QAbstractTransition *initialTransition = createInitialTransition();
transitions.append(initialTransition);
@@ -1690,7 +1862,7 @@ void QStateMachinePrivate::_q_start()
executeTransitionContent(&nullEvent, transitions);
QList<QAbstractState*> exitedStates = QList<QAbstractState*>();
QSet<QAbstractState*> statesForDefaultEntry;
- QList<QAbstractState*> enteredStates = computeEntrySet(transitions, statesForDefaultEntry);
+ QList<QAbstractState*> enteredStates = computeEntrySet(transitions, statesForDefaultEntry, &calculationCache);
QHash<RestorableId, QVariant> pendingRestorables;
QHash<QAbstractState*, QList<QPropertyAssignment> > assignmentsForEnteredStates =
computePropertyAssignments(enteredStates, pendingRestorables);
@@ -1745,50 +1917,46 @@ void QStateMachinePrivate::_q_process()
break;
}
QList<QAbstractTransition*> enabledTransitions;
+ CalculationCache calculationCache;
+
QEvent *e = new QEvent(QEvent::None);
- enabledTransitions = selectTransitions(e);
+ enabledTransitions = selectTransitions(e, &calculationCache);
if (enabledTransitions.isEmpty()) {
delete e;
e = 0;
}
- if (enabledTransitions.isEmpty() && ((e = dequeueInternalEvent()) != 0)) {
+ while (enabledTransitions.isEmpty() && ((e = dequeueInternalEvent()) != 0)) {
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": dequeued internal event" << e << "of type" << e->type();
#endif
- enabledTransitions = selectTransitions(e);
+ enabledTransitions = selectTransitions(e, &calculationCache);
if (enabledTransitions.isEmpty()) {
delete e;
e = 0;
}
}
- if (enabledTransitions.isEmpty()) {
- if ((e = dequeueExternalEvent()) != 0) {
+ while (enabledTransitions.isEmpty() && ((e = dequeueExternalEvent()) != 0)) {
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": dequeued external event" << e << "of type" << e->type();
#endif
- enabledTransitions = selectTransitions(e);
+ enabledTransitions = selectTransitions(e, &calculationCache);
if (enabledTransitions.isEmpty()) {
delete e;
e = 0;
}
- } else {
- if (isInternalEventQueueEmpty()) {
- processing = false;
- stopProcessingReason = EventQueueEmpty;
- }
- }
}
- if (!enabledTransitions.isEmpty()) {
- didChange = true;
- q->beginMicrostep(e);
- microstep(e, enabledTransitions);
- q->endMicrostep(e);
- }
- else {
+ if (enabledTransitions.isEmpty()) {
+ processing = false;
+ stopProcessingReason = EventQueueEmpty;
noMicrostep();
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": no transitions enabled";
#endif
+ } else {
+ didChange = true;
+ q->beginMicrostep(e);
+ microstep(e, enabledTransitions, &calculationCache);
+ q->endMicrostep(e);
}
delete e;
}
@@ -1976,12 +2144,17 @@ void QStateMachinePrivate::emitStateFinished(QState *forState, QFinalState *guil
Q_ASSERT(guiltyState);
#ifdef QSTATEMACHINE_DEBUG
+ Q_Q(QStateMachine);
qDebug() << q << ": emitting finished signal for" << forState;
#endif
QStatePrivate::get(forState)->emitFinished();
}
+void QStateMachinePrivate::startupHook()
+{
+}
+
namespace _QStateMachine_Internal{
class GoToStateTransition : public QAbstractTransition
@@ -2554,14 +2727,18 @@ void QStateMachine::setRunning(bool running)
event queue. Events are processed in the order posted. The state machine
takes ownership of the event and deletes it once it has been processed.
- You can only post events when the state machine is running.
+ You can only post events when the state machine is running or when it is starting up.
\sa postDelayedEvent()
*/
void QStateMachine::postEvent(QEvent *event, EventPriority priority)
{
Q_D(QStateMachine);
- if (d->state != QStateMachinePrivate::Running) {
+ switch (d->state) {
+ case QStateMachinePrivate::Running:
+ case QStateMachinePrivate::Starting:
+ break;
+ default:
qWarning("QStateMachine::postEvent: cannot post event when the state machine is not running");
return;
}
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index a66232ee88..426f2732df 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -75,6 +75,7 @@ class QState;
class QAbstractAnimation;
#endif
+struct CalculationCache;
class QStateMachine;
class Q_CORE_EXPORT QStateMachinePrivate : public QStatePrivate
{
@@ -124,17 +125,18 @@ public:
void clearHistory();
QAbstractTransition *createInitialTransition() const;
- void removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions);
- void microstep(QEvent *event, const QList<QAbstractTransition*> &transitionList);
+ void removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions, CalculationCache *cache);
+ void microstep(QEvent *event, const QList<QAbstractTransition*> &transitionList, CalculationCache *cache);
+ QList<QAbstractTransition *> selectTransitions(QEvent *event, CalculationCache *cache);
virtual void noMicrostep();
virtual void processedPendingEvents(bool didChange);
virtual void beginMacrostep();
virtual void endMacrostep(bool didChange);
- QList<QAbstractTransition *> selectTransitions(QEvent *event);
void exitStates(QEvent *event, const QList<QAbstractState *> &statesToExit_sorted,
const QHash<QAbstractState*, QList<QPropertyAssignment> > &assignmentsForEnteredStates);
- QList<QAbstractState*> computeExitSet(const QList<QAbstractTransition*> &enabledTransitions);
- QSet<QAbstractState*> computeExitSet_Unordered(const QList<QAbstractTransition*> &enabledTransitions);
+ QList<QAbstractState*> computeExitSet(const QList<QAbstractTransition*> &enabledTransitions, CalculationCache *cache);
+ QSet<QAbstractState*> computeExitSet_Unordered(const QList<QAbstractTransition*> &enabledTransitions, CalculationCache *cache);
+ QSet<QAbstractState*> computeExitSet_Unordered(QAbstractTransition *t, CalculationCache *cache);
void executeTransitionContent(QEvent *event, const QList<QAbstractTransition*> &transitionList);
void enterStates(QEvent *event, const QList<QAbstractState*> &exitedStates_sorted,
const QList<QAbstractState*> &statesToEnter_sorted,
@@ -145,9 +147,10 @@ public:
#endif
);
QList<QAbstractState*> computeEntrySet(const QList<QAbstractTransition*> &enabledTransitions,
- QSet<QAbstractState*> &statesForDefaultEntry);
+ QSet<QAbstractState*> &statesForDefaultEntry, CalculationCache *cache);
QAbstractState *getTransitionDomain(QAbstractTransition *t,
- const QList<QAbstractState *> &effectiveTargetStates) const;
+ const QList<QAbstractState *> &effectiveTargetStates,
+ CalculationCache *cache) const;
void addDescendantStatesToEnter(QAbstractState *state,
QSet<QAbstractState*> &statesToEnter,
QSet<QAbstractState*> &statesForDefaultEntry);
@@ -199,6 +202,7 @@ public:
void cancelAllDelayedEvents();
virtual void emitStateFinished(QState *forState, QFinalState *guiltyState);
+ virtual void startupHook();
#ifndef QT_NO_PROPERTIES
class RestorableId {
@@ -206,7 +210,8 @@ public:
QObject *obj;
QByteArray prop;
// two overloads because friends can't have default arguments
- friend uint qHash(const RestorableId &key, uint seed) Q_DECL_NOEXCEPT_EXPR(noexcept(std::declval<QByteArray>()))
+ friend uint qHash(const RestorableId &key, uint seed)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(std::declval<QByteArray>())))
{ return qHash(qMakePair(key.obj, key.prop), seed); }
friend uint qHash(const RestorableId &key) Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(key, 0U)))
{ return qHash(key, 0U); }
diff --git a/src/corelib/thread/qexception.cpp b/src/corelib/thread/qexception.cpp
index acc3663936..01bbe70c88 100644
--- a/src/corelib/thread/qexception.cpp
+++ b/src/corelib/thread/qexception.cpp
@@ -107,6 +107,14 @@ QT_BEGIN_NAMESPACE
\internal
*/
+QException::~QException()
+#ifndef Q_COMPILER_NOEXCEPT
+ throw()
+#endif
+{
+ // must stay empty until ### Qt 6
+}
+
void QException::raise() const
{
QException e = *this;
@@ -118,6 +126,14 @@ QException *QException::clone() const
return new QException(*this);
}
+QUnhandledException::~QUnhandledException()
+#ifndef Q_COMPILER_NOEXCEPT
+ throw()
+#endif
+{
+ // must stay empty until ### Qt 6
+}
+
void QUnhandledException::raise() const
{
QUnhandledException e = *this;
diff --git a/src/corelib/thread/qexception.h b/src/corelib/thread/qexception.h
index 55fc441020..edf361ebd3 100644
--- a/src/corelib/thread/qexception.h
+++ b/src/corelib/thread/qexception.h
@@ -53,6 +53,11 @@ QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QException : public std::exception
{
public:
+ ~QException()
+#ifndef Q_COMPILER_NOEXCEPT
+ throw()
+#endif
+ ;
virtual void raise() const;
virtual QException *clone() const;
};
@@ -60,6 +65,11 @@ public:
class Q_CORE_EXPORT QUnhandledException : public QException
{
public:
+ ~QUnhandledException()
+#ifndef Q_COMPILER_NOEXCEPT
+ throw()
+#endif
+;
void raise() const Q_DECL_OVERRIDE;
QUnhandledException *clone() const Q_DECL_OVERRIDE;
};
diff --git a/src/corelib/thread/qrunnable.cpp b/src/corelib/thread/qrunnable.cpp
index 64a2613d27..04aa39a81e 100644
--- a/src/corelib/thread/qrunnable.cpp
+++ b/src/corelib/thread/qrunnable.cpp
@@ -31,6 +31,15 @@
**
****************************************************************************/
+#include "qrunnable.h"
+
+QT_BEGIN_NAMESPACE
+
+QRunnable::~QRunnable()
+{
+ // Must be empty until ### Qt 6
+}
+
/*!
\class QRunnable
\inmodule QtCore
@@ -98,3 +107,5 @@
\sa autoDelete(), QThreadPool
*/
+
+QT_END_NAMESPACE
diff --git a/src/corelib/thread/qrunnable.h b/src/corelib/thread/qrunnable.h
index f00c58d51d..28d14a46c0 100644
--- a/src/corelib/thread/qrunnable.h
+++ b/src/corelib/thread/qrunnable.h
@@ -38,20 +38,21 @@
QT_BEGIN_NAMESPACE
-
-class QRunnable
+class Q_CORE_EXPORT QRunnable
{
int ref;
friend class QThreadPool;
friend class QThreadPoolPrivate;
friend class QThreadPoolThread;
-
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ Q_DISABLE_COPY(QRunnable)
+#endif
public:
virtual void run() = 0;
QRunnable() : ref(0) { }
- virtual ~QRunnable() { }
+ virtual ~QRunnable();
bool autoDelete() const { return ref != -1; }
void setAutoDelete(bool _autoDelete) { ref = _autoDelete ? 0 : -1; }
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index b8544b1f0a..2008f76621 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -57,6 +57,16 @@
#include <algorithm>
+#ifdef Q_OS_WINRT
+namespace ABI {
+ namespace Windows {
+ namespace Foundation {
+ struct IAsyncAction;
+ }
+ }
+}
+#endif // Q_OS_WINRT
+
QT_BEGIN_NAMESPACE
class QAbstractEventDispatcher;
@@ -125,10 +135,6 @@ private:
#ifndef QT_NO_THREAD
-#ifdef Q_OS_WINRT
-namespace ABI { namespace Windows { namespace Foundation { struct IAsyncAction; } } }
-#endif
-
class QThreadPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QThread)
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index da5d00311a..36c1f42995 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -124,7 +124,7 @@ int qFindByteArray(
int qAllocMore(int alloc, int extra) Q_DECL_NOTHROW
{
Q_ASSERT(alloc >= 0 && extra >= 0);
- Q_ASSERT_X(uint(alloc) < QByteArray::MaxSize, "qAllocMore", "Requested size is too large!");
+ Q_ASSERT_X(uint(alloc) <= QByteArray::MaxSize, "qAllocMore", "Requested size is too large!");
unsigned nalloc = qNextPowerOfTwo(alloc + extra);
@@ -842,8 +842,9 @@ static inline char qToLower(char c)
\internal
\since 5.4
- The maximum size of a QByteArray, in bytes. Also applies to a the maximum
- storage size of QString and QVector, though not the number of elements.
+ The maximum size of a QByteArray (including a '\0' terminator), in bytes.
+ Also applies to the maximum storage size of QString and QVector, though
+ not the number of elements.
*/
/*!
diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp
index 9148ecf6fc..615b7a4e3e 100644
--- a/src/corelib/tools/qcollator.cpp
+++ b/src/corelib/tools/qcollator.cpp
@@ -87,7 +87,7 @@ QCollator::QCollator(const QCollator &other)
}
/*!
- Destroys the collator.
+ Destructor for QCollator.
*/
QCollator::~QCollator()
{
@@ -109,8 +109,8 @@ QCollator &QCollator::operator=(const QCollator &other)
return *this;
}
-/*
- \fn void QCollator::QCollator(QCollator &&other)
+/*!
+ \fn QCollator::QCollator(QCollator &&other)
Move constructor. Moves from \a other into this collator.
@@ -119,8 +119,8 @@ QCollator &QCollator::operator=(const QCollator &other)
one of the assignment operators is undefined.
*/
-/*
- \fn QCollator &QCollator::operator=(QCollator &&other)
+/*!
+ \fn QCollator & QCollator::operator=(QCollator && other)
Move-assigns from \a other to this collator.
@@ -367,6 +367,12 @@ QCollatorSortKey& QCollatorSortKey::operator=(const QCollatorSortKey &other)
}
/*!
+ \fn QCollatorSortKey &QCollatorSortKey::operator=(QCollatorSortKey && other)
+
+ Move-assigns \a other to this collator key.
+*/
+
+/*!
\fn bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
\relates QCollatorSortKey
@@ -377,6 +383,12 @@ QCollatorSortKey& QCollatorSortKey::operator=(const QCollatorSortKey &other)
*/
/*!
+ \fn void QCollatorSortKey::swap(QCollatorSortKey & other)
+
+ Swaps this collator key with \a other.
+*/
+
+/*!
\fn int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
Compares the key to \a otherKey. Returns a negative value if the key
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index 7e49253f9b..4cc3a2c293 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -119,8 +119,8 @@ public:
QStringList QCommandLineParserPrivate::aliases(const QString &optionName) const
{
- const NameHash_t::const_iterator it = nameHash.find(optionName);
- if (it == nameHash.end()) {
+ const NameHash_t::const_iterator it = nameHash.constFind(optionName);
+ if (it == nameHash.cend()) {
qWarning("QCommandLineParser: option not defined: \"%s\"", qPrintable(optionName));
return QStringList();
}
@@ -847,8 +847,8 @@ QString QCommandLineParser::value(const QString &optionName) const
QStringList QCommandLineParser::values(const QString &optionName) const
{
d->checkParsed("values");
- const NameHash_t::const_iterator it = d->nameHash.find(optionName);
- if (it != d->nameHash.end()) {
+ const NameHash_t::const_iterator it = d->nameHash.constFind(optionName);
+ if (it != d->nameHash.cend()) {
const int optionOffset = *it;
QStringList values = d->optionValuesHash.value(optionOffset);
if (values.isEmpty())
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h
index fc4fb1e7cb..41d198f9bc 100644
--- a/src/corelib/tools/qcontiguouscache.h
+++ b/src/corelib/tools/qcontiguouscache.h
@@ -291,7 +291,7 @@ QContiguousCache<T> &QContiguousCache<T>::operator=(const QContiguousCache<T> &o
{
other.d->ref.ref();
if (!d->ref.deref())
- freeData(d);
+ freeData(p);
d = other.d;
if (!d->sharable)
detach_helper();
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp
index 255e9557e2..eaa695ef27 100644
--- a/src/corelib/tools/qdatetimeparser.cpp
+++ b/src/corelib/tools/qdatetimeparser.cpp
@@ -1362,11 +1362,11 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex
\internal
returns
- 0 if str == QDateTimeEdit::tr("AM")
- 1 if str == QDateTimeEdit::tr("PM")
- 2 if str can become QDateTimeEdit::tr("AM")
- 3 if str can become QDateTimeEdit::tr("PM")
- 4 if str can become QDateTimeEdit::tr("PM") and can become QDateTimeEdit::tr("AM")
+ 0 if str == tr("AM")
+ 1 if str == tr("PM")
+ 2 if str can become tr("AM")
+ 3 if str can become tr("PM")
+ 4 if str can become tr("PM") and can become tr("AM")
-1 can't become anything sensible
*/
@@ -1737,9 +1737,9 @@ QDateTime QDateTimeParser::getMaximum() const
QString QDateTimeParser::getAmPmText(AmPm ap, Case cs) const
{
if (ap == AmText) {
- return (cs == UpperCase ? QLatin1String("AM") : QLatin1String("am"));
+ return (cs == UpperCase ? tr("AM") : tr("am"));
} else {
- return (cs == UpperCase ? QLatin1String("PM") : QLatin1String("pm"));
+ return (cs == UpperCase ? tr("PM") : tr("pm"));
}
}
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h
index 55dc3bf7a0..9457e35ad5 100644
--- a/src/corelib/tools/qdatetimeparser_p.h
+++ b/src/corelib/tools/qdatetimeparser_p.h
@@ -54,7 +54,7 @@
# include "QtCore/qvariant.h"
#endif
#include "QtCore/qvector.h"
-
+#include "QtCore/qcoreapplication.h"
#define QDATETIMEEDIT_TIME_MIN QTime(0, 0, 0, 0)
#define QDATETIMEEDIT_TIME_MAX QTime(23, 59, 59, 999)
@@ -72,6 +72,7 @@ QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QDateTimeParser
{
+ Q_DECLARE_TR_FUNCTIONS(QDateTimeParser)
public:
enum Context {
FromString,
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index c4c8c8f3cc..2080a22e23 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -353,6 +353,7 @@ public:
class const_iterator
{
friend class iterator;
+ friend class QSet<Key>;
QHashData::Node *i;
public:
@@ -451,6 +452,7 @@ private:
void detach_helper();
void freeData(QHashData *d);
Node **findNode(const Key &key, uint *hp = 0) const;
+ Node **findNode(const Key &key, uint h) const;
Node *createNode(uint h, const Key &key, const T &value, Node **nextNode);
void deleteNode(Node *node);
static void deleteNode2(QHashData::Node *node);
@@ -846,17 +848,10 @@ Q_INLINE_TEMPLATE bool QHash<Key, T>::contains(const Key &akey) const
}
template <class Key, class T>
-Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::Node **QHash<Key, T>::findNode(const Key &akey,
- uint *ahp) const
+Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::Node **QHash<Key, T>::findNode(const Key &akey, uint h) const
{
Node **node;
- uint h = 0;
- if (d->numBuckets || ahp) {
- h = qHash(akey, d->seed);
- if (ahp)
- *ahp = h;
- }
if (d->numBuckets) {
node = reinterpret_cast<Node **>(&d->buckets[h % d->numBuckets]);
Q_ASSERT(*node == e || (*node)->next);
@@ -869,6 +864,20 @@ Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::Node **QHash<Key, T>::findNode(cons
}
template <class Key, class T>
+Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::Node **QHash<Key, T>::findNode(const Key &akey,
+ uint *ahp) const
+{
+ uint h = 0;
+
+ if (d->numBuckets || ahp) {
+ h = qHash(akey, d->seed);
+ if (ahp)
+ *ahp = h;
+ }
+ return findNode(akey, h);
+}
+
+template <class Key, class T>
Q_OUTOFLINE_TEMPLATE bool QHash<Key, T>::operator==(const QHash &other) const
{
if (size() != other.size())
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 1e002633df..e446a6625b 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -221,6 +221,11 @@ public:
inline iterator() : i(0) {}
inline iterator(Node *n) : i(n) {}
+#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
+ // can't remove it in Qt 5, since doing so would make the type trivial,
+ // which changes the way it's passed to functions by value.
+ inline iterator(const iterator &o): i(o.i){}
+#endif
inline T &operator*() const { return i->t(); }
inline T *operator->() const { return &i->t(); }
inline T &operator[](difference_type j) const { return i[j].t(); }
@@ -268,6 +273,11 @@ public:
inline const_iterator() : i(0) {}
inline const_iterator(Node *n) : i(n) {}
+#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
+ // can't remove it in Qt 5, since doing so would make the type trivial,
+ // which changes the way it's passed to functions by value.
+ inline const_iterator(const const_iterator &o): i(o.i) {}
+#endif
#ifdef QT_STRICT_ITERATORS
inline explicit const_iterator(const iterator &o): i(o.i) {}
#else
diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm
index 37a63a2ca4..c0818f07d7 100644
--- a/src/corelib/tools/qlocale_mac.mm
+++ b/src/corelib/tools/qlocale_mac.mm
@@ -44,18 +44,6 @@
QT_BEGIN_NAMESPACE
-namespace {
-class AutoReleasePool
-{
-public:
- AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
- ~AutoReleasePool() { [pool release]; }
-
-private:
- NSAutoreleasePool *pool;
-};
-}
-
/******************************************************************************
** Wrappers for Mac locale system functions
*/
@@ -426,7 +414,7 @@ QLocale QSystemLocale::fallbackUiLocale() const
QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
{
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
switch(type) {
// case Name:
// return getMacLocaleName();
diff --git a/src/corelib/tools/qpair.qdoc b/src/corelib/tools/qpair.qdoc
index 48555ed6d1..4452d2f0b8 100644
--- a/src/corelib/tools/qpair.qdoc
+++ b/src/corelib/tools/qpair.qdoc
@@ -96,6 +96,30 @@
\sa qMakePair()
*/
+\fn void QPair::swap(QPair &other)
+
+ \since 5.5
+ Swaps this pair with \a other.
+
+ Equivalent to
+ \code
+ qSwap(this->first, other.first);
+ qSwap(this->second, other.second);
+ \endcode
+
+ Swap overloads are found in namespace \c std as well as via
+ argument-dependent lookup (ADL) in \c{T}'s namespace.
+*/
+
+/*!
+\fn void swap(QPair<T1, T2> &lhs, QPair<T1, T2> &rhs)
+ \overload
+ \relates QPair
+ \since 5.5
+
+ Swaps \a lhs with \a rhs.
+*/
+
/*!
\fn QPair::QPair(const QPair<TT1, TT2> &p)
\since 5.2
@@ -108,37 +132,27 @@
*/
/*!
- \fn QPair &QPair::operator=(const QPair<TT1, TT2> &p)
+ \fn QPair::QPair(QPair<TT1, TT2> &&p)
\since 5.2
- Copies the pair \a p onto this pair.
-
- \sa qMakePair()
+ Move-constructs a QPair instance, making it point to the same object that
+ \a p was pointing to.
*/
/*!
- \fn void QPair::swap(QPair &other)
- \since 5.5
-
- Swaps this pair with \a other.
+ \fn QPair & QPair::operator=(const QPair<TT1, TT2> &p)
+ \since 5.2
- Equivalent to
- \code
- qSwap(this->first, other.first);
- qSwap(this->second, other.second);
- \endcode
+ Copies pair \a p into this pair.
- Swap overloads are found in namespace \c std as well as via
- argument-dependent lookup (ADL) in \c{T}'s namespace.
+ \sa qMakePair()
*/
/*!
- \fn void swap(QPair<T1, T2> &lhs, QPair<T1, T2> &rhs)
- \overload
- \relates QPair
- \since 5.5
+ \fn QPair & QPair::operator=(QPair<TT1, TT2> &&p)
+ \since 5.2
- Swaps \a lhs with \a rhs.
+ Move-assigns pair \a p into this pair instance.
*/
/*! \fn bool operator==(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 18dd2d12c2..47cad6349c 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -1830,6 +1830,13 @@ bool QRegularExpression::operator==(const QRegularExpression &re) const
}
/*!
+ \fn QRegularExpression & QRegularExpression::operator=(QRegularExpression && re)
+
+ Move-assigns the regular expression \a re to this object, and returns a reference
+ to the copy. Both the pattern and the pattern options are copied.
+*/
+
+/*!
\fn bool QRegularExpression::operator!=(const QRegularExpression &re) const
Returns \c true if the regular expression is different from \a re, or
@@ -1956,6 +1963,13 @@ QRegularExpressionMatch &QRegularExpressionMatch::operator=(const QRegularExpres
}
/*!
+ \fn QRegularExpressionMatch &QRegularExpressionMatch::operator=(QRegularExpressionMatch &&match)
+
+ Move-assigns the match result \a match to this object, and returns a reference
+ to the copy.
+*/
+
+/*!
\fn void QRegularExpressionMatch::swap(QRegularExpressionMatch &other)
Swaps the match result \a other with this match result. This
@@ -2320,6 +2334,12 @@ QRegularExpressionMatchIterator &QRegularExpressionMatchIterator::operator=(cons
}
/*!
+ \fn QRegularExpressionMatchIterator &QRegularExpressionMatchIterator::operator=(QRegularExpressionMatchIterator &&iterator)
+
+ Move-assigns the \a iterator to this object.
+*/
+
+/*!
\fn void QRegularExpressionMatchIterator::swap(QRegularExpressionMatchIterator &other)
Swaps the iterator \a other with this iterator object. This operation is
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
new file mode 100644
index 0000000000..bcf6d2646e
--- /dev/null
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -0,0 +1,309 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Alex Trotsenko <alex1973tr@gmail.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qringbuffer_p.h"
+#include <string.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \internal
+
+ Access the bytes at a specified position the out-variable length will
+ contain the amount of bytes readable from there, e.g. the amount still
+ the same QByteArray
+*/
+const char *QRingBuffer::readPointerAtPosition(qint64 pos, qint64 &length) const
+{
+ if (pos >= 0) {
+ pos += head;
+ for (int i = 0; i < buffers.size(); ++i) {
+ length = (i == tailBuffer ? tail : buffers[i].size());
+ if (length > pos) {
+ length -= pos;
+ return buffers[i].constData() + pos;
+ }
+ pos -= length;
+ }
+ }
+
+ length = 0;
+ return 0;
+}
+
+void QRingBuffer::free(qint64 bytes)
+{
+ while (bytes > 0) {
+ const qint64 blockSize = buffers.first().size() - head;
+
+ if (tailBuffer == 0 || blockSize > bytes) {
+ // keep a single block around if it does not exceed
+ // the basic block size, to avoid repeated allocations
+ // between uses of the buffer
+ if (bufferSize <= bytes) {
+ if (buffers.first().size() <= basicBlockSize) {
+ bufferSize = 0;
+ head = tail = 0;
+ } else {
+ clear(); // try to minify/squeeze us
+ }
+ } else {
+ Q_ASSERT(quint64(bytes) < QByteArray::MaxSize);
+ head += int(bytes);
+ bufferSize -= bytes;
+ }
+ return;
+ }
+
+ bufferSize -= blockSize;
+ bytes -= blockSize;
+ buffers.removeFirst();
+ --tailBuffer;
+ head = 0;
+ }
+}
+
+char *QRingBuffer::reserve(qint64 bytes)
+{
+ if (bytes <= 0 || quint64(bytes) >= QByteArray::MaxSize)
+ return 0;
+
+ const qint64 newSize = bytes + tail;
+ // if need buffer reallocation
+ if (newSize > buffers.last().size()) {
+ if (newSize > buffers.last().capacity() && (tail >= basicBlockSize
+ || quint64(newSize) >= QByteArray::MaxSize)) {
+ // shrink this buffer to its current size
+ buffers.last().resize(tail);
+
+ // create a new QByteArray
+ buffers.append(QByteArray());
+ ++tailBuffer;
+ tail = 0;
+ }
+ buffers.last().resize(qMax(basicBlockSize, tail + int(bytes)));
+ }
+
+ char *writePtr = buffers.last().data() + tail;
+ bufferSize += bytes;
+ Q_ASSERT(quint64(bytes) < QByteArray::MaxSize);
+ tail += int(bytes);
+ return writePtr;
+}
+
+/*!
+ \internal
+
+ Allocate data at buffer head
+*/
+char *QRingBuffer::reserveFront(qint64 bytes)
+{
+ if (bytes <= 0 || quint64(bytes) >= QByteArray::MaxSize)
+ return 0;
+
+ if (head < bytes) {
+ buffers.first().remove(0, head);
+ if (tailBuffer == 0)
+ tail -= head;
+
+ buffers.prepend(QByteArray());
+ head = qMax(basicBlockSize, int(bytes));
+ buffers.first().resize(head);
+ ++tailBuffer;
+ }
+
+ head -= int(bytes);
+ bufferSize += bytes;
+ return buffers.first().data() + head;
+}
+
+void QRingBuffer::chop(qint64 bytes)
+{
+ while (bytes > 0) {
+ if (tailBuffer == 0 || tail > bytes) {
+ // keep a single block around if it does not exceed
+ // the basic block size, to avoid repeated allocations
+ // between uses of the buffer
+ if (bufferSize <= bytes) {
+ if (buffers.first().size() <= basicBlockSize) {
+ bufferSize = 0;
+ head = tail = 0;
+ } else {
+ clear(); // try to minify/squeeze us
+ }
+ } else {
+ Q_ASSERT(quint64(bytes) < QByteArray::MaxSize);
+ tail -= int(bytes);
+ bufferSize -= bytes;
+ }
+ return;
+ }
+
+ bufferSize -= tail;
+ bytes -= tail;
+ buffers.removeLast();
+ --tailBuffer;
+ tail = buffers.last().size();
+ }
+}
+
+void QRingBuffer::clear()
+{
+ buffers.erase(buffers.begin() + 1, buffers.end());
+ buffers.first().clear();
+
+ head = tail = 0;
+ tailBuffer = 0;
+ bufferSize = 0;
+}
+
+qint64 QRingBuffer::indexOf(char c, qint64 maxLength) const
+{
+ qint64 index = 0;
+ qint64 j = head;
+ for (int i = 0; index < maxLength && i < buffers.size(); ++i) {
+ const char *ptr = buffers[i].constData() + j;
+ j = qMin(index + (i == tailBuffer ? tail : buffers[i].size()) - j, maxLength);
+
+ while (index < j) {
+ if (*ptr++ == c)
+ return index;
+ ++index;
+ }
+ j = 0;
+ }
+ return -1;
+}
+
+qint64 QRingBuffer::read(char *data, qint64 maxLength)
+{
+ const qint64 bytesToRead = qMin(size(), maxLength);
+ qint64 readSoFar = 0;
+ while (readSoFar < bytesToRead) {
+ const qint64 bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar,
+ nextDataBlockSize());
+ if (data)
+ memcpy(data + readSoFar, readPointer(), bytesToReadFromThisBlock);
+ readSoFar += bytesToReadFromThisBlock;
+ free(bytesToReadFromThisBlock);
+ }
+ return readSoFar;
+}
+
+/*!
+ \internal
+
+ Read an unspecified amount (will read the first buffer)
+*/
+QByteArray QRingBuffer::read()
+{
+ if (bufferSize == 0)
+ return QByteArray();
+
+ QByteArray qba(buffers.takeFirst());
+
+ qba.reserve(0); // avoid that resizing needlessly reallocates
+ if (tailBuffer == 0) {
+ qba.resize(tail);
+ tail = 0;
+ buffers.append(QByteArray());
+ } else {
+ --tailBuffer;
+ }
+ qba.remove(0, head); // does nothing if head is 0
+ head = 0;
+ bufferSize -= qba.size();
+ return qba;
+}
+
+/*!
+ \internal
+
+ Peek the bytes from a specified position
+*/
+qint64 QRingBuffer::peek(char *data, qint64 maxLength, qint64 pos) const
+{
+ qint64 readSoFar = 0;
+
+ if (pos >= 0) {
+ pos += head;
+ for (int i = 0; readSoFar < maxLength && i < buffers.size(); ++i) {
+ qint64 blockLength = (i == tailBuffer ? tail : buffers[i].size());
+
+ if (pos < blockLength) {
+ blockLength = qMin(blockLength - pos, maxLength - readSoFar);
+ memcpy(data + readSoFar, buffers[i].constData() + pos, blockLength);
+ readSoFar += blockLength;
+ pos = 0;
+ } else {
+ pos -= blockLength;
+ }
+ }
+ }
+
+ return readSoFar;
+}
+
+/*!
+ \internal
+
+ Append a new buffer to the end
+*/
+void QRingBuffer::append(const QByteArray &qba)
+{
+ if (tail == 0) {
+ buffers.last() = qba;
+ } else {
+ buffers.last().resize(tail);
+ buffers.append(qba);
+ ++tailBuffer;
+ }
+ tail = qba.size();
+ bufferSize += tail;
+}
+
+qint64 QRingBuffer::readLine(char *data, qint64 maxLength)
+{
+ if (!data || --maxLength <= 0)
+ return -1;
+
+ qint64 i = indexOf('\n', maxLength);
+ i = read(data, i >= 0 ? (i + 1) : maxLength);
+
+ // Terminate it.
+ data[i] = '\0';
+ return i;
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index 9ca14d2987..68509a6a80 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -66,117 +66,17 @@ public:
return bufferSize == 0 ? Q_NULLPTR : (buffers.first().constData() + head);
}
- // access the bytes at a specified position
- // the out-variable length will contain the amount of bytes readable
- // from there, e.g. the amount still the same QByteArray
- inline const char *readPointerAtPosition(qint64 pos, qint64 &length) const {
- if (pos >= 0) {
- pos += head;
- for (int i = 0; i < buffers.size(); ++i) {
- length = (i == tailBuffer ? tail : buffers[i].size());
- if (length > pos) {
- length -= pos;
- return buffers[i].constData() + pos;
- }
- pos -= length;
- }
- }
-
- length = 0;
- return 0;
- }
-
- inline void free(qint64 bytes) {
- while (bytes > 0) {
- const qint64 blockSize = buffers.first().size() - head;
-
- if (tailBuffer == 0 || blockSize > bytes) {
- // keep a single block around if it does not exceed
- // the basic block size, to avoid repeated allocations
- // between uses of the buffer
- if (bufferSize <= bytes) {
- if (buffers.first().size() <= basicBlockSize) {
- bufferSize = 0;
- head = tail = 0;
- } else {
- clear(); // try to minify/squeeze us
- }
- } else {
- Q_ASSERT(quint64(bytes) < QByteArray::MaxSize);
- head += int(bytes);
- bufferSize -= bytes;
- }
- return;
- }
-
- bufferSize -= blockSize;
- bytes -= blockSize;
- buffers.removeFirst();
- --tailBuffer;
- head = 0;
- }
- }
-
- inline char *reserve(qint64 bytes) {
- if (bytes <= 0 || quint64(bytes) >= QByteArray::MaxSize)
- return 0;
-
- const qint64 newSize = bytes + tail;
- // if need buffer reallocation
- if (newSize > buffers.last().size()) {
- if (newSize > buffers.last().capacity() && (tail >= basicBlockSize
- || quint64(newSize) >= QByteArray::MaxSize)) {
- // shrink this buffer to its current size
- buffers.last().resize(tail);
-
- // create a new QByteArray
- buffers.append(QByteArray());
- ++tailBuffer;
- tail = 0;
- }
- buffers.last().resize(qMax(basicBlockSize, tail + int(bytes)));
- }
-
- char *writePtr = buffers.last().data() + tail;
- bufferSize += bytes;
- Q_ASSERT(quint64(bytes) < QByteArray::MaxSize);
- tail += int(bytes);
- return writePtr;
- }
+ Q_CORE_EXPORT const char *readPointerAtPosition(qint64 pos, qint64 &length) const;
+ Q_CORE_EXPORT void free(qint64 bytes);
+ Q_CORE_EXPORT char *reserve(qint64 bytes);
+ Q_CORE_EXPORT char *reserveFront(qint64 bytes);
inline void truncate(qint64 pos) {
if (pos < size())
chop(size() - pos);
}
- inline void chop(qint64 bytes) {
- while (bytes > 0) {
- if (tailBuffer == 0 || tail > bytes) {
- // keep a single block around if it does not exceed
- // the basic block size, to avoid repeated allocations
- // between uses of the buffer
- if (bufferSize <= bytes) {
- if (buffers.first().size() <= basicBlockSize) {
- bufferSize = 0;
- head = tail = 0;
- } else {
- clear(); // try to minify/squeeze us
- }
- } else {
- Q_ASSERT(quint64(bytes) < QByteArray::MaxSize);
- tail -= int(bytes);
- bufferSize -= bytes;
- }
- return;
- }
-
- bufferSize -= tail;
- bytes -= tail;
- buffers.removeLast();
- --tailBuffer;
- tail = buffers.last().size();
- }
- }
+ Q_CORE_EXPORT void chop(qint64 bytes);
inline bool isEmpty() const {
return bufferSize == 0;
@@ -195,156 +95,36 @@ public:
*ptr = c;
}
- inline void ungetChar(char c) {
- --head;
- if (head < 0) {
- if (bufferSize != 0) {
- buffers.prepend(QByteArray());
- ++tailBuffer;
- } else {
- tail = basicBlockSize;
- }
- buffers.first().resize(basicBlockSize);
- head = basicBlockSize - 1;
- }
- buffers.first()[head] = c;
- ++bufferSize;
- }
-
- inline qint64 size() const {
- return bufferSize;
- }
-
- inline void clear() {
- buffers.erase(buffers.begin() + 1, buffers.end());
- buffers.first().clear();
-
- head = tail = 0;
- tailBuffer = 0;
- bufferSize = 0;
- }
-
- inline qint64 indexOf(char c) const {
- qint64 index = 0;
- qint64 j = head;
- for (int i = 0; i < buffers.size(); ++i) {
- const char *ptr = buffers[i].constData() + j;
- j = index + (i == tailBuffer ? tail : buffers[i].size()) - j;
-
- while (index < j) {
- if (*ptr++ == c)
- return index;
- ++index;
- }
- j = 0;
- }
- return -1;
- }
-
- inline qint64 indexOf(char c, qint64 maxLength) const {
- qint64 index = 0;
- qint64 j = head;
- for (int i = 0; index < maxLength && i < buffers.size(); ++i) {
- const char *ptr = buffers[i].constData() + j;
- j = qMin(index + (i == tailBuffer ? tail : buffers[i].size()) - j, maxLength);
-
- while (index < j) {
- if (*ptr++ == c)
- return index;
- ++index;
- }
- j = 0;
- }
- return -1;
- }
-
- inline qint64 read(char *data, qint64 maxLength) {
- const qint64 bytesToRead = qMin(size(), maxLength);
- qint64 readSoFar = 0;
- while (readSoFar < bytesToRead) {
- const qint64 bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar,
- nextDataBlockSize());
- if (data)
- memcpy(data + readSoFar, readPointer(), bytesToReadFromThisBlock);
- readSoFar += bytesToReadFromThisBlock;
- free(bytesToReadFromThisBlock);
- }
- return readSoFar;
- }
-
- // read an unspecified amount (will read the first buffer)
- inline QByteArray read() {
- if (bufferSize == 0)
- return QByteArray();
-
- QByteArray qba(buffers.takeFirst());
-
- qba.reserve(0); // avoid that resizing needlessly reallocates
- if (tailBuffer == 0) {
- qba.resize(tail);
- tail = 0;
- buffers.append(QByteArray());
+ void ungetChar(char c)
+ {
+ if (head > 0) {
+ --head;
+ buffers.first()[head] = c;
+ ++bufferSize;
} else {
- --tailBuffer;
+ char *ptr = reserveFront(1);
+ *ptr = c;
}
- qba.remove(0, head); // does nothing if head is 0
- head = 0;
- bufferSize -= qba.size();
- return qba;
}
- // peek the bytes from a specified position
- inline qint64 peek(char *data, qint64 maxLength, qint64 pos = 0) const
- {
- qint64 readSoFar = 0;
-
- if (pos >= 0) {
- pos += head;
- for (int i = 0; readSoFar < maxLength && i < buffers.size(); ++i) {
- qint64 blockLength = (i == tailBuffer ? tail : buffers[i].size());
-
- if (pos < blockLength) {
- blockLength = qMin(blockLength - pos, maxLength - readSoFar);
- memcpy(data + readSoFar, buffers[i].constData() + pos, blockLength);
- readSoFar += blockLength;
- pos = 0;
- } else {
- pos -= blockLength;
- }
- }
- }
- return readSoFar;
+ inline qint64 size() const {
+ return bufferSize;
}
- // append a new buffer to the end
- inline void append(const QByteArray &qba) {
- if (tail == 0) {
- buffers.last() = qba;
- } else {
- buffers.last().resize(tail);
- buffers.append(qba);
- ++tailBuffer;
- }
- tail = qba.size();
- bufferSize += tail;
- }
+ Q_CORE_EXPORT void clear();
+ inline qint64 indexOf(char c) const { return indexOf(c, size()); }
+ Q_CORE_EXPORT qint64 indexOf(char c, qint64 maxLength) const;
+ Q_CORE_EXPORT qint64 read(char *data, qint64 maxLength);
+ Q_CORE_EXPORT QByteArray read();
+ Q_CORE_EXPORT qint64 peek(char *data, qint64 maxLength, qint64 pos = 0) const;
+ Q_CORE_EXPORT void append(const QByteArray &qba);
inline qint64 skip(qint64 length) {
return read(0, length);
}
- inline qint64 readLine(char *data, qint64 maxLength) {
- if (!data || --maxLength <= 0)
- return -1;
-
- qint64 i = indexOf('\n', maxLength);
- i = read(data, i >= 0 ? (i + 1) : maxLength);
-
- // Terminate it.
- data[i] = '\0';
- return i;
- }
+ Q_CORE_EXPORT qint64 readLine(char *data, qint64 maxLength);
inline bool canReadLine() const {
return indexOf('\n') >= 0;
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 35551f4061..c113c38aa2 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -255,6 +255,13 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn QScopedArrayPointer::QScopedArrayPointer(D * p, QtPrivate::QScopedArrayEnsureSameType<T, D>::Type = 0)
+ \internal
+
+ Constructs a QScopedArrayPointer and stores the array of objects.
+*/
+
+/*!
\fn T *QScopedArrayPointer::operator[](int i)
Provides access to entry \a i of the scoped pointer's array of
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index e4688711d6..5a9c75fe07 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -137,6 +137,7 @@ public:
typedef QHash<T, QHashDummyValue> Hash;
typename Hash::const_iterator i;
friend class iterator;
+ friend class QSet<T>;
public:
typedef std::bidirectional_iterator_tag iterator_category;
@@ -191,6 +192,7 @@ public:
inline const_iterator constFind(const T &value) const { return find(value); }
QSet<T> &unite(const QSet<T> &other);
QSet<T> &intersect(const QSet<T> &other);
+ bool intersects(const QSet<T> &other) const;
QSet<T> &subtract(const QSet<T> &other);
// STL compatibility
@@ -284,6 +286,34 @@ Q_INLINE_TEMPLATE QSet<T> &QSet<T>::intersect(const QSet<T> &other)
}
template <class T>
+Q_INLINE_TEMPLATE bool QSet<T>::intersects(const QSet<T> &other) const
+{
+ const bool otherIsBigger = other.size() > size();
+ const QSet &smallestSet = otherIsBigger ? *this : other;
+ const QSet &biggestSet = otherIsBigger ? other : *this;
+ const bool equalSeeds = q_hash.d->seed == other.q_hash.d->seed;
+ typename QSet::const_iterator i = smallestSet.cbegin();
+ typename QSet::const_iterator e = smallestSet.cend();
+
+ if (Q_LIKELY(equalSeeds)) {
+ // If seeds are equal we take the fast path so no hash is recalculated.
+ while (i != e) {
+ if (*biggestSet.q_hash.findNode(*i, i.i.i->h) != biggestSet.q_hash.e)
+ return true;
+ ++i;
+ }
+ } else {
+ while (i != e) {
+ if (biggestSet.contains(*i))
+ return true;
+ ++i;
+ }
+ }
+
+ return false;
+}
+
+template <class T>
Q_INLINE_TEMPLATE QSet<T> &QSet<T>::subtract(const QSet<T> &other)
{
QSet<T> copy1(*this);
diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc
index 94cfa729f5..495329b90d 100644
--- a/src/corelib/tools/qset.qdoc
+++ b/src/corelib/tools/qset.qdoc
@@ -127,6 +127,13 @@
*/
/*!
+ \fn QSet::QSet(QSet && other)
+
+ Move-constructs a QSet instance, making it point to the same object that \a other was pointing to.
+*/
+
+
+/*!
\fn QSet<T> &QSet::operator=(const QSet<T> &other)
Assigns the \a other set to this set and returns a reference to
@@ -134,6 +141,12 @@
*/
/*!
+ \fn QSet<T> &QSet::operator=(QSet<T> &&other)
+
+ Move-assigns the \a other set to this set.
+*/
+
+/*!
\fn void QSet::swap(QSet<T> &other)
Swaps set \a other with this set. This operation is very fast and
@@ -490,7 +503,17 @@
Removes all items from this set that are not contained in the
\a other set. A reference to this set is returned.
- \sa operator&=(), unite(), subtract()
+ \sa intersects(), operator&=(), unite(), subtract()
+*/
+
+/*!
+ \fn bool QSet::intersects(const QSet<T> &other) const
+ \since 5.6
+
+ Returns \c true if this set has at least one item in common with
+ \a other.
+
+ \sa contains(), intersect()
*/
/*!
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index 52ffc161bf..d572dd209c 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -39,7 +39,9 @@
#if defined(Q_OS_WIN)
# if defined(Q_OS_WINCE)
# include <qt_windows.h>
-# include <cmnintrin.h>
+# if _WIN32_WCE < 0x800
+# include <cmnintrin.h>
+# endif
# endif
# if !defined(Q_CC_GNU)
# ifndef Q_OS_WINCE
diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h
index 6e7ed40dff..e71eeb607e 100644
--- a/src/corelib/tools/qsize.h
+++ b/src/corelib/tools/qsize.h
@@ -54,15 +54,15 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) Q_DECL_NOTHROW;
void transpose() Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW;
+ Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
inline void scale(int w, int h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
inline void scale(const QSize &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
- QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
- QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
+ QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW;
+ Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
Q_DECL_RELAXED_CONSTEXPR inline int &rwidth() Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline int &rheight() Q_DECL_NOTHROW;
@@ -214,15 +214,15 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) Q_DECL_NOTHROW;
void transpose() Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW;
+ Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
inline void scale(qreal w, qreal h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
inline void scale(const QSizeF &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
- QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
- QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
+ QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW;
+ Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
Q_DECL_RELAXED_CONSTEXPR inline qreal &rwidth() Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline qreal &rheight() Q_DECL_NOTHROW;
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 373d25c6ad..2585686156 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -2721,6 +2721,8 @@ bool QString::operator<(QLatin1String other) const
/*! \fn bool QString::operator<=(const QString &s1, const QString &s2)
+ \relates Qstring
+
Returns \c true if string \a s1 is lexically less than or equal to
string \a s2; otherwise returns \c false.
@@ -2766,9 +2768,10 @@ bool QString::operator<(QLatin1String other) const
*/
/*! \fn bool QString::operator>(const QString &s1, const QString &s2)
+ \relates QString
- Returns \c true if string \a s1 is lexically greater than string \a
- s2; otherwise returns \c false.
+ Returns \c true if string \a s1 is lexically greater than string \a s2;
+ otherwise returns \c false.
The comparison is based exclusively on the numeric Unicode values
of the characters and is very fast, but is not what a human would
@@ -8923,6 +8926,110 @@ bool operator<(const QStringRef &s1,const QStringRef &s2)
*/
/*!
+ \fn bool QStringRef::operator==(const char * s) const
+
+ \overload operator==()
+
+ The \a s byte array is converted to a QStringRef using the
+ fromUtf8() function. This function stops conversion at the
+ first NUL character found, or the end of the byte array.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is lexically equal to the parameter
+ string \a s. Otherwise returns \c false.
+
+*/
+
+/*!
+ \fn bool QStringRef::operator!=(const char * s) const
+
+ \overload operator!=()
+
+ The \a s const char pointer is converted to a QStringRef using
+ the fromUtf8() function.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is not lexically equal to the parameter
+ string \a s. Otherwise returns \c false.
+*/
+
+/*!
+ \fn bool QStringRef::operator<(const char * s) const
+
+ \overload operator<()
+
+ The \a s const char pointer is converted to a QStringRef using
+ the fromUtf8() function.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is lexically smaller than the parameter
+ string \a s. Otherwise returns \c false.
+*/
+
+/*!
+ \fn bool QStringRef::operator<=(const char * s) const
+
+ \overload operator<=()
+
+ The \a s const char pointer is converted to a QStringRef using
+ the fromUtf8() function.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is lexically smaller than or equal to the parameter
+ string \a s. Otherwise returns \c false.
+*/
+
+/*!
+ \fn bool QStringRef::operator>(const char * s) const
+
+
+ \overload operator>()
+
+ The \a s const char pointer is converted to a QStringRef using
+ the fromUtf8() function.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is lexically greater than the parameter
+ string \a s. Otherwise returns \c false.
+*/
+
+/*!
+ \fn bool QStringRef::operator>= (const char * s) const
+
+ \overload operator>=()
+
+ The \a s const char pointer is converted to a QStringRef using
+ the fromUtf8() function.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is lexically greater than or equal to the
+ parameter string \a s. Otherwise returns \c false.
+*/
+/*!
\typedef QString::Data
\internal
*/
@@ -10332,7 +10439,6 @@ QString QString::toHtmlEscaped() const
\endlist
*/
-
/*!
\internal
*/
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 532b294c28..670d94279d 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -498,7 +498,7 @@ public:
};
QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const Q_REQUIRED_RESULT;
- QString repeated(int times) const;
+ QString repeated(int times) const Q_REQUIRED_RESULT;
const ushort *utf16() const;
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index 4f46764697..b57954dc03 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -951,7 +951,7 @@
Returns a reference to the first item in the vector. This
function assumes that the vector isn't empty.
- \sa last(), isEmpty()
+ \sa last(), isEmpty(), constFirst()
*/
/*! \fn const T& QVector::first() const
@@ -959,12 +959,21 @@
\overload
*/
+/*! \fn const T& QVector::constFirst() const
+ \since 5.6
+
+ Returns a const reference to the first item in the vector. This
+ function assumes that the vector isn't empty.
+
+ \sa constLast(), isEmpty(), first()
+*/
+
/*! \fn T& QVector::last()
Returns a reference to the last item in the vector. This function
assumes that the vector isn't empty.
- \sa first(), isEmpty()
+ \sa first(), isEmpty(), constLast()
*/
/*! \fn const T& QVector::last() const
@@ -972,6 +981,15 @@
\overload
*/
+/*! \fn const T& QVector::constLast() const
+ \since 5.6
+
+ Returns a const reference to the last item in the vector. This function
+ assumes that the vector isn't empty.
+
+ \sa constFirst(), isEmpty(), last()
+*/
+
/*! \fn T QVector::value(int i) const
Returns the value at index position \a i in the vector.
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 2eb2dc4550..2adf2d4522 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -212,8 +212,10 @@ public:
inline int count() const { return d->size; }
inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
inline const T &first() const { Q_ASSERT(!isEmpty()); return *begin(); }
+ inline const T &constFirst() const { Q_ASSERT(!isEmpty()); return *begin(); }
inline T& last() { Q_ASSERT(!isEmpty()); return *(end()-1); }
inline const T &last() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
+ inline const T &constLast() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; }
inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; }
QVector<T> mid(int pos, int len = -1) const;
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 5e4a22e283..1dba6784b6 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -106,6 +106,7 @@ SOURCES += \
tools/qrect.cpp \
tools/qregexp.cpp \
tools/qrefcount.cpp \
+ tools/qringbuffer.cpp \
tools/qshareddata.cpp \
tools/qsharedpointer.cpp \
tools/qsimd.cpp \
diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h
index cec8ad62cb..32b76ee5bd 100644
--- a/src/dbus/qdbus_symbols_p.h
+++ b/src/dbus/qdbus_symbols_p.h
@@ -183,9 +183,6 @@ DEFINEFUNC(dbus_bool_t , dbus_connection_add_filter, (DBusConnection
void *user_data,
DBusFreeFunction free_data_function),
(connection, function, user_data, free_data_function), return)
-DEFINEFUNC(dbus_bool_t , dbus_connection_can_send_type, (DBusConnection *connection,
- int type),
- (connection, type), return)
DEFINEFUNC(void , dbus_connection_close, (DBusConnection *connection),
(connection), return)
DEFINEFUNC(DBusDispatchStatus , dbus_connection_dispatch, (DBusConnection *connection),
diff --git a/src/dbus/qdbusunixfiledescriptor.cpp b/src/dbus/qdbusunixfiledescriptor.cpp
index 96caa80549..77f48c03a4 100644
--- a/src/dbus/qdbusunixfiledescriptor.cpp
+++ b/src/dbus/qdbusunixfiledescriptor.cpp
@@ -174,6 +174,12 @@ QDBusUnixFileDescriptor &QDBusUnixFileDescriptor::operator=(const QDBusUnixFileD
}
/*!
+ \fn QDBusUnixFileDescriptor &operator=(QDBusUnixFileDescriptor &&other)
+
+ Move-assigns \a other to this QDBusUnixFileDescriptor.
+*/
+
+/*!
Destroys this QDBusUnixFileDescriptor object and disposes of the Unix file descriptor that it contained.
*/
QDBusUnixFileDescriptor::~QDBusUnixFileDescriptor()
diff --git a/src/dbus/qdbusvirtualobject.cpp b/src/dbus/qdbusvirtualobject.cpp
index aeeb2a1f2b..b65e71eef7 100644
--- a/src/dbus/qdbusvirtualobject.cpp
+++ b/src/dbus/qdbusvirtualobject.cpp
@@ -37,11 +37,17 @@
QT_BEGIN_NAMESPACE
+/*!
+ Constructs a QDBusVirtualObject with \a parent.
+*/
QDBusVirtualObject::QDBusVirtualObject(QObject *parent) :
QObject(parent)
{
}
+/*!
+ Destroys the object, deleting all of its child objects.
+*/
QDBusVirtualObject::~QDBusVirtualObject()
{
}
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index cc9d789c6a..c1b586f879 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -443,10 +443,11 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QAccessibleInterface::~QAccessibleInterface()
-
- Destroys the object.
+ Destroys the QAccessibleInterface.
*/
+QAccessibleInterface::~QAccessibleInterface()
+{
+}
/*!
\typedef QAccessible::Id
@@ -608,6 +609,11 @@ QAccessible::RootObjectHandler QAccessible::installRootObjectHandler(RootObjectH
\sa installActivationObserver()
*/
+QAccessible::ActivationObserver::~ActivationObserver()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
\internal
@@ -1254,10 +1260,6 @@ QColor QAccessibleInterface::backgroundColor() const
return QColor();
}
-QAccessibleInterface::~QAccessibleInterface()
-{
-}
-
/*!
\fn QAccessibleTextInterface *QAccessibleInterface::textInterface()
*/
@@ -1329,9 +1331,13 @@ QAccessibleInterface::~QAccessibleInterface()
the overload taking a \l QObject parameter as it might be cheaper.
*/
-/*! \fn QAccessibleEvent::~QAccessibleEvent()
+/*!
Destroys the event.
*/
+QAccessibleEvent::~QAccessibleEvent()
+{
+ // must be empty until ### Qt 6
+}
/*! \fn QAccessible::Event QAccessibleEvent::type() const
Returns the event type.
@@ -1392,6 +1398,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
Returns the new value of the accessible object of this event.
*/
+/*!
+ \internal
+*/
+QAccessibleValueChangeEvent::~QAccessibleValueChangeEvent()
+{
+ // must be empty until ### Qt 6
+}
/*!
\class QAccessibleStateChangeEvent
@@ -1410,6 +1423,12 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
The difference to the object's previous state is in \a state.
*/
/*!
+ \fn QAccessibleStateChangeEvent::QAccessibleStateChangeEvent(QAccessibleInterface *iface, QAccessible::State state)
+ Constructs a new QAccessibleStateChangeEvent.
+ \a iface is the interface associated with the event
+ \a state is the state of the accessible object.
+*/
+/*!
\fn QAccessible::State QAccessibleStateChangeEvent::changedStates() const
\brief Returns the states that have been changed.
@@ -1421,7 +1440,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
other hand tells about the change and has focused set to \c true since
the focus state is changed from \c true to \c false.
*/
-
+/*!
+ \internal
+*/
+QAccessibleStateChangeEvent::~QAccessibleStateChangeEvent()
+{
+ // must be empty until ### Qt 6
+}
/*!
\class QAccessibleTableModelChangeEvent
@@ -1478,6 +1503,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn void QAccessibleTableModelChangeEvent::setModelChangeType(ModelChangeType changeType)
Sets the type of change to \a changeType.
*/
+/*!
+ \internal
+*/
+QAccessibleTableModelChangeEvent::~QAccessibleTableModelChangeEvent()
+{
+ // must be empty until ### Qt 6
+}
/*!
@@ -1499,6 +1531,14 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn void QAccessibleTextCursorEvent::setCursorPosition(int position)
Sets the cursor \a position for this event.
*/
+/*!
+ \internal
+*/
+QAccessibleTextCursorEvent::~QAccessibleTextCursorEvent()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
\class QAccessibleTextInsertEvent
@@ -1522,6 +1562,14 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn QString QAccessibleTextInsertEvent::textInserted() const
Returns the text that has been inserted.
*/
+/*!
+ \internal
+*/
+QAccessibleTextInsertEvent::~QAccessibleTextInsertEvent()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
\class QAccessibleTextRemoveEvent
@@ -1546,6 +1594,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn QString QAccessibleTextRemoveEvent::textRemoved() const
Returns the text that has been removed.
*/
+/*!
+ \internal
+*/
+QAccessibleTextRemoveEvent::~QAccessibleTextRemoveEvent()
+{
+ // must be empty until ### Qt 6
+}
/*!
\class QAccessibleTextUpdateEvent
@@ -1572,6 +1627,14 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn QString QAccessibleTextUpdateEvent::textRemoved() const
Returns the removed text.
*/
+/*!
+ \internal
+*/
+QAccessibleTextUpdateEvent::~QAccessibleTextUpdateEvent()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
\class QAccessibleTextSelectionEvent
@@ -1595,6 +1658,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const
/*! \fn void QAccessibleTextSelectionEvent::setSelection(int start, int end)
Sets the selection for this event from position \a start to \a end.
*/
+/*!
+ \internal
+*/
+QAccessibleTextSelectionEvent::~QAccessibleTextSelectionEvent()
+{
+ // must be empty until ### Qt 6
+}
@@ -1833,9 +1903,12 @@ QDebug operator<<(QDebug d, const QAccessibleEvent &ev)
*/
/*!
- \fn QAccessibleTextInterface::~QAccessibleTextInterface()
Destroys the QAccessibleTextInterface.
*/
+QAccessibleTextInterface::~QAccessibleTextInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn void QAccessibleTextInterface::addSelection(int startOffset, int endOffset)
@@ -2215,9 +2288,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
- \fn QAccessibleEditableTextInterface::~QAccessibleEditableTextInterface()
Destroys the QAccessibleEditableTextInterface.
*/
+QAccessibleEditableTextInterface::~QAccessibleEditableTextInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn void QAccessibleEditableTextInterface::deleteText(int startOffset, int endOffset)
@@ -2256,9 +2332,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
- \fn QAccessibleValueInterface::~QAccessibleValueInterface()
- Destructor.
+ Destroys the QAccessibleValueInterface.
*/
+QAccessibleValueInterface::~QAccessibleValueInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn QVariant QAccessibleValueInterface::currentValue() const
@@ -2317,6 +2396,14 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
+ Destroys the QAccessibleImageInterface.
+*/
+QAccessibleImageInterface::~QAccessibleImageInterface()
+{
+ // must be empty until ### Qt 6
+}
+
+/*!
\class QAccessibleTableCellInterface
\inmodule QtGui
\ingroup accessibility
@@ -2328,9 +2415,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
- \fn virtual QAccessibleTableCellInterface::~QAccessibleTableCellInterface()
Destroys the QAccessibleTableCellInterface.
*/
+QAccessibleTableCellInterface::~QAccessibleTableCellInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn virtual int QAccessibleTableCellInterface::columnExtent() const
@@ -2384,9 +2474,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
- \fn virtual QAccessibleTableInterface::~QAccessibleTableInterface()
Destroys the QAccessibleTableInterface.
*/
+QAccessibleTableInterface::~QAccessibleTableInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn virtual QAccessibleInterface *QAccessibleTableInterface::cellAt(int row, int column) const
@@ -2537,9 +2630,12 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
*/
/*!
- \fn QAccessibleActionInterface::~QAccessibleActionInterface()
Destroys the QAccessibleActionInterface.
*/
+QAccessibleActionInterface::~QAccessibleActionInterface()
+{
+ // must be empty until ### Qt 6
+}
/*!
\fn QStringList QAccessibleActionInterface::actionNames() const
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
index faa8cd719d..a0281d1c11 100644
--- a/src/gui/accessible/qaccessible.h
+++ b/src/gui/accessible/qaccessible.h
@@ -396,10 +396,10 @@ public:
static UpdateHandler installUpdateHandler(UpdateHandler);
static RootObjectHandler installRootObjectHandler(RootObjectHandler);
- class ActivationObserver
+ class Q_GUI_EXPORT ActivationObserver
{
public:
- virtual ~ActivationObserver() {}
+ virtual ~ActivationObserver();
virtual void accessibilityActiveChanged(bool active) = 0;
};
static void installActivationObserver(ActivationObserver *);
@@ -514,7 +514,7 @@ protected:
class Q_GUI_EXPORT QAccessibleTextInterface
{
public:
- virtual ~QAccessibleTextInterface() {}
+ virtual ~QAccessibleTextInterface();
// selection
virtual void selection(int selectionIndex, int *startOffset, int *endOffset) const = 0;
virtual int selectionCount() const = 0;
@@ -547,7 +547,7 @@ public:
class Q_GUI_EXPORT QAccessibleEditableTextInterface
{
public:
- virtual ~QAccessibleEditableTextInterface() {}
+ virtual ~QAccessibleEditableTextInterface();
virtual void deleteText(int startOffset, int endOffset) = 0;
virtual void insertText(int offset, const QString &text) = 0;
@@ -557,8 +557,7 @@ public:
class Q_GUI_EXPORT QAccessibleValueInterface
{
public:
-
- virtual ~QAccessibleValueInterface() {}
+ virtual ~QAccessibleValueInterface();
virtual QVariant currentValue() const = 0;
virtual void setCurrentValue(const QVariant &value) = 0;
@@ -570,7 +569,7 @@ public:
class Q_GUI_EXPORT QAccessibleTableCellInterface
{
public:
- virtual ~QAccessibleTableCellInterface() {}
+ virtual ~QAccessibleTableCellInterface();
virtual bool isSelected() const = 0;
@@ -587,7 +586,7 @@ public:
class Q_GUI_EXPORT QAccessibleTableInterface
{
public:
- virtual ~QAccessibleTableInterface() {}
+ virtual ~QAccessibleTableInterface();
virtual QAccessibleInterface *caption() const = 0;
virtual QAccessibleInterface *summary() const = 0;
@@ -622,7 +621,7 @@ class Q_GUI_EXPORT QAccessibleActionInterface
{
Q_DECLARE_TR_FUNCTIONS(QAccessibleActionInterface)
public:
- virtual ~QAccessibleActionInterface() {}
+ virtual ~QAccessibleActionInterface();
virtual QStringList actionNames() const = 0;
virtual QString localizedActionName(const QString &name) const;
@@ -647,7 +646,7 @@ public:
class Q_GUI_EXPORT QAccessibleImageInterface
{
public:
- virtual ~QAccessibleImageInterface() {}
+ virtual ~QAccessibleImageInterface();
virtual QString imageDescription() const = 0;
virtual QSize imageSize() const = 0;
@@ -691,8 +690,7 @@ public:
m_uniqueId = QAccessible::uniqueId(iface);
}
- virtual ~QAccessibleEvent()
- {}
+ virtual ~QAccessibleEvent();
QAccessible::Event type() const { return m_type; }
QObject *object() const { return m_object; }
@@ -726,6 +724,7 @@ public:
{
m_type = QAccessible::StateChanged;
}
+ ~QAccessibleStateChangeEvent();
QAccessible::State changedStates() const {
return m_changedStates;
@@ -752,6 +751,8 @@ public:
m_type = QAccessible::TextCaretMoved;
}
+ ~QAccessibleTextCursorEvent();
+
void setCursorPosition(int position) { m_cursorPosition = position; }
int cursorPosition() const { return m_cursorPosition; }
@@ -776,6 +777,8 @@ public:
m_type = QAccessible::TextSelectionChanged;
}
+ ~QAccessibleTextSelectionEvent();
+
void setSelection(int start, int end) {
m_selectionStart = start;
m_selectionEnd = end;
@@ -805,6 +808,8 @@ public:
m_type = QAccessible::TextInserted;
}
+ ~QAccessibleTextInsertEvent();
+
QString textInserted() const {
return m_text;
}
@@ -833,6 +838,8 @@ public:
m_type = QAccessible::TextRemoved;
}
+ ~QAccessibleTextRemoveEvent();
+
QString textRemoved() const {
return m_text;
}
@@ -860,6 +867,9 @@ public:
{
m_type = QAccessible::TextUpdated;
}
+
+ ~QAccessibleTextUpdateEvent();
+
QString textRemoved() const {
return m_oldText;
}
@@ -892,6 +902,8 @@ public:
m_type = QAccessible::ValueChanged;
}
+ ~QAccessibleValueChangeEvent();
+
void setValue(const QVariant & val) { m_value= val; }
QVariant value() const { return m_value; }
@@ -926,6 +938,8 @@ public:
m_type = QAccessible::TableModelChanged;
}
+ ~QAccessibleTableModelChangeEvent();
+
void setModelChangeType(ModelChangeType changeType) { m_modelChangeType = changeType; }
ModelChangeType modelChangeType() const { return m_modelChangeType; }
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 6d7a40c2ef..40ba84bb14 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -606,7 +606,7 @@ QFactoryLoader *qt_iconEngineFactoryLoader()
/*!
Constructs a null icon.
*/
-QIcon::QIcon()
+QIcon::QIcon() Q_DECL_NOEXCEPT
: d(0)
{
}
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
index d87468b4f0..63e77eef99 100644
--- a/src/gui/image/qicon.h
+++ b/src/gui/image/qicon.h
@@ -51,22 +51,24 @@ public:
enum Mode { Normal, Disabled, Active, Selected };
enum State { On, Off };
- QIcon();
+ QIcon() Q_DECL_NOEXCEPT;
QIcon(const QPixmap &pixmap);
QIcon(const QIcon &other);
#ifdef Q_COMPILER_RVALUE_REFS
- QIcon(QIcon &&other)
- :d(0) { qSwap(d, other.d); }
+ QIcon(QIcon &&other) Q_DECL_NOEXCEPT
+ : d(0)
+ { qSwap(d, other.d); }
#endif
explicit QIcon(const QString &fileName); // file or resource name
explicit QIcon(QIconEngine *engine);
~QIcon();
QIcon &operator=(const QIcon &other);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QIcon &operator=(QIcon &&other)
+ inline QIcon &operator=(QIcon &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
- inline void swap(QIcon &other) { qSwap(d, other.d); }
+ inline void swap(QIcon &other) Q_DECL_NOEXCEPT
+ { qSwap(d, other.d); }
operator QVariant() const;
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 046c01ad54..7aeba45b3b 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -738,7 +738,7 @@ bool QImageData::checkForAlphaPixels() const
\sa isNull()
*/
-QImage::QImage()
+QImage::QImage() Q_DECL_NOEXCEPT
: QPaintDevice()
{
d = 0;
@@ -5151,4 +5151,18 @@ QImage::Format QImage::toImageFormat(QPixelFormat format) Q_DECL_NOTHROW
return Format_Invalid;
}
+Q_GUI_EXPORT void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient)
+{
+ if (orient == QImageIOHandler::TransformationNone)
+ return;
+ if (orient == QImageIOHandler::TransformationRotate270) {
+ src = rotated270(src);
+ } else {
+ src = qMove(src).mirrored(orient & QImageIOHandler::TransformationMirror,
+ orient & QImageIOHandler::TransformationFlip);
+ if (orient & QImageIOHandler::TransformationRotate90)
+ src = rotated90(src);
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 0ccbab819f..26707021ea 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -122,7 +122,7 @@ public:
#endif
};
- QImage();
+ QImage() Q_DECL_NOEXCEPT;
QImage(const QSize &size, Format format);
QImage(int width, int height, Format format);
QImage(uchar *data, int width, int height, Format format, QImageCleanupFunction cleanupFunction = 0, void *cleanupInfo = 0);
@@ -137,7 +137,7 @@ public:
QImage(const QImage &);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QImage(QImage &&other)
+ inline QImage(QImage &&other) Q_DECL_NOEXCEPT
: QPaintDevice(), d(0)
{ qSwap(d, other.d); }
#endif
@@ -145,10 +145,11 @@ public:
QImage &operator=(const QImage &);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QImage &operator=(QImage &&other)
+ inline QImage &operator=(QImage &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
- inline void swap(QImage &other) { qSwap(d, other.d); }
+ inline void swap(QImage &other) Q_DECL_NOEXCEPT
+ { qSwap(d, other.d); }
bool isNull() const;
diff --git a/src/gui/image/qimageiohandler.cpp b/src/gui/image/qimageiohandler.cpp
index cc9a6ae2a1..22b4bcf560 100644
--- a/src/gui/image/qimageiohandler.cpp
+++ b/src/gui/image/qimageiohandler.cpp
@@ -159,6 +159,43 @@
\value ProgressiveScanWrite. A handler which supports
this option is expected to write the image as a progressive scan image.
+
+ \value ImageTransformation. A handler which supports this option can read
+ the transformation metadata of an image. A handler that supports this option
+ should not apply the transformation itself.
+
+ \value TransformedByDefault. A handler that reports support for this feature
+ will have image transformation metadata applied by default on read.
+*/
+
+/*! \enum QImageIOHandler::Transformation
+ \since 5.5
+
+ This enum describes the different transformations or orientations
+ supported by some image formats, usually through EXIF.
+
+ \value TransformationNone No transformation should be applied.
+
+ \value TransformationMirror Mirror the image horizontally.
+
+ \value TransformationFlip Mirror the image vertically.
+
+ \value TransformationRotate180 Rotate the image 180 degrees.
+ This is the same as mirroring it both horizontally and vertically.
+
+ \value TransformationRotate90 Rotate the image 90 degrees.
+
+ \value TransformationMirrorAndRotate90 Mirror the image horizontally
+ and then rotate it 90 degrees.
+
+ \value TransformationFlipAndRotate90 Mirror the image vertically
+ and then rotate it 90 degrees.
+
+ \value TransformationRotate270 Rotate the image 270 degrees.
+ This is the same as mirroring it both horizontally, vertically and
+ then rotating it 90 degrees.
+
+ \sa QImageReader::transformation(), QImageReader::setAutoTransform(), QImageWriter::setTransformation()
*/
/*!
diff --git a/src/gui/image/qimageiohandler.h b/src/gui/image/qimageiohandler.h
index b48226f619..80cd87c4c3 100644
--- a/src/gui/image/qimageiohandler.h
+++ b/src/gui/image/qimageiohandler.h
@@ -86,8 +86,25 @@ public:
ImageFormat,
SupportedSubTypes,
OptimizedWrite,
- ProgressiveScanWrite
+ ProgressiveScanWrite,
+ ImageTransformation
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ , TransformedByDefault
+#endif
};
+
+ enum Transformation {
+ TransformationNone = 0,
+ TransformationMirror = 1,
+ TransformationFlip = 2,
+ TransformationRotate180 = TransformationMirror | TransformationFlip,
+ TransformationRotate90 = 4,
+ TransformationMirrorAndRotate90 = TransformationMirror | TransformationRotate90,
+ TransformationFlipAndRotate90 = TransformationFlip | TransformationRotate90,
+ TransformationRotate270 = TransformationRotate180 | TransformationRotate90
+ };
+ Q_DECLARE_FLAGS(Transformations, Transformation)
+
virtual QVariant option(ImageOption option) const;
virtual void setOption(ImageOption option, const QVariant &value);
virtual bool supportsOption(ImageOption option) const;
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index c2795cc38d..ba79bf40e5 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -533,6 +533,11 @@ public:
int quality;
QMap<QString, QString> text;
void getText();
+ enum {
+ UsePluginDefault,
+ ApplyTransform,
+ DoNotApplyTransform
+ } autoTransform;
// error
QImageReader::ImageReaderError imageReaderError;
@@ -552,6 +557,7 @@ QImageReaderPrivate::QImageReaderPrivate(QImageReader *qq)
handler = 0;
quality = -1;
imageReaderError = QImageReader::UnknownError;
+ autoTransform = UsePluginDefault;
q = qq;
}
@@ -1144,6 +1150,59 @@ QList<QByteArray> QImageReader::supportedSubTypes() const
}
/*!
+ \since 5.5
+
+ Returns the transformation metadata of the image, including image orientation. If the format
+ does not support transformation metadata \c QImageIOHandler::Transformation_None is returned.
+
+ \sa setAutoTransform(), autoTransform()
+*/
+QImageIOHandler::Transformations QImageReader::transformation() const
+{
+ int option = QImageIOHandler::TransformationNone;
+ if (d->initHandler() && d->handler->supportsOption(QImageIOHandler::ImageTransformation))
+ option = d->handler->option(QImageIOHandler::ImageTransformation).toInt();
+ return QImageIOHandler::Transformations(option);
+}
+
+/*!
+ \since 5.5
+
+ Sets if images returned by read() should have transformation metadata automatically applied.
+
+ \sa autoTransform(), transform(), read()
+*/
+void QImageReader::setAutoTransform(bool enabled)
+{
+ d->autoTransform = enabled ? QImageReaderPrivate::ApplyTransform
+ : QImageReaderPrivate::DoNotApplyTransform;
+}
+
+/*!
+ \since 5.5
+
+ Returns \c true if the image handler will apply transformation metadata on read().
+
+ \sa setAutoTransform(), transformation(), read()
+*/
+bool QImageReader::autoTransform() const
+{
+ switch (d->autoTransform) {
+ case QImageReaderPrivate::ApplyTransform:
+ return true;
+ case QImageReaderPrivate::DoNotApplyTransform:
+ return false;
+ case QImageReaderPrivate::UsePluginDefault:
+ if (d->initHandler())
+ return d->handler->supportsOption(QImageIOHandler::TransformedByDefault);
+ // no break
+ default:
+ break;
+ }
+ return false;
+}
+
+/*!
Returns \c true if an image can be read for the device (i.e., the
image format is supported, and the device seems to contain valid
data); otherwise returns \c false.
@@ -1185,6 +1244,8 @@ QImage QImageReader::read()
return read(&image) ? image : QImage();
}
+extern void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient);
+
/*!
\overload
@@ -1294,6 +1355,8 @@ bool QImageReader::read(QImage *image)
if (!disable2xImageLoading && QFileInfo(fileName()).baseName().endsWith(QLatin1String("@2x"))) {
image->setDevicePixelRatio(2.0);
}
+ if (autoTransform())
+ qt_imageTransform(*image, transformation());
return true;
}
diff --git a/src/gui/image/qimagereader.h b/src/gui/image/qimagereader.h
index 34191ed657..27a29bed49 100644
--- a/src/gui/image/qimagereader.h
+++ b/src/gui/image/qimagereader.h
@@ -105,6 +105,11 @@ public:
bool supportsAnimation() const;
+ QImageIOHandler::Transformations transformation() const;
+
+ void setAutoTransform(bool enabled);
+ bool autoTransform() const;
+
QByteArray subType() const;
QList<QByteArray> supportedSubTypes() const;
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index b418101163..e9de1db4b2 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -91,6 +91,7 @@
#include <qbytearray.h>
#include <qfile.h>
#include <qfileinfo.h>
+#include <qimage.h>
#include <qimageiohandler.h>
#include <qjsonarray.h>
#include <qset.h>
@@ -254,6 +255,7 @@ public:
QByteArray subType;
bool optimizedWrite;
bool progressiveScanWrite;
+ QImageIOHandler::Transformations transformation;
// error
QImageWriter::ImageWriterError imageWriterError;
@@ -277,6 +279,7 @@ QImageWriterPrivate::QImageWriterPrivate(QImageWriter *qq)
progressiveScanWrite = false;
imageWriterError = QImageWriter::UnknownError;
errorString = QImageWriter::tr("Unknown error");
+ transformation = QImageIOHandler::TransformationNone;
q = qq;
}
@@ -616,6 +619,33 @@ bool QImageWriter::progressiveScanWrite() const
}
/*!
+ \since 5.5
+
+ Sets the image transformations metadata including orientation.
+
+ If transformation metadata is not supported by the image format,
+ the transform is applied before writing.
+
+ \sa transformation(), write()
+*/
+void QImageWriter::setTransformation(QImageIOHandler::Transformations transform)
+{
+ d->transformation = transform;
+}
+
+/*!
+ \since 5.5
+
+ Returns the transformation and orientation the image has been set to written with.
+
+ \sa setTransformation()
+*/
+QImageIOHandler::Transformations QImageWriter::transformation() const
+{
+ return d->transformation;
+}
+
+/*!
\obsolete
Use setText() instead.
@@ -694,6 +724,8 @@ bool QImageWriter::canWrite() const
return d->canWriteHelper();
}
+extern void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient);
+
/*!
Writes the image \a image to the assigned device or file
name. Returns \c true on success; otherwise returns \c false. If the
@@ -708,6 +740,7 @@ bool QImageWriter::write(const QImage &image)
if (!canWrite())
return false;
+ QImage img = image;
if (d->handler->supportsOption(QImageIOHandler::Quality))
d->handler->setOption(QImageIOHandler::Quality, d->quality);
if (d->handler->supportsOption(QImageIOHandler::CompressionRatio))
@@ -722,8 +755,12 @@ bool QImageWriter::write(const QImage &image)
d->handler->setOption(QImageIOHandler::OptimizedWrite, d->optimizedWrite);
if (d->handler->supportsOption(QImageIOHandler::ProgressiveScanWrite))
d->handler->setOption(QImageIOHandler::ProgressiveScanWrite, d->progressiveScanWrite);
+ if (d->handler->supportsOption(QImageIOHandler::ImageTransformation))
+ d->handler->setOption(QImageIOHandler::ImageTransformation, int(d->transformation));
+ else
+ qt_imageTransform(img, d->transformation);
- if (!d->handler->write(image))
+ if (!d->handler->write(img))
return false;
if (QFile *file = qobject_cast<QFile *>(d->device))
file->flush();
diff --git a/src/gui/image/qimagewriter.h b/src/gui/image/qimagewriter.h
index 96d8f51b3a..7f92595c53 100644
--- a/src/gui/image/qimagewriter.h
+++ b/src/gui/image/qimagewriter.h
@@ -89,6 +89,9 @@ public:
void setProgressiveScanWrite(bool progressive);
bool progressiveScanWrite() const;
+ QImageIOHandler::Transformations transformation() const;
+ void setTransformation(QImageIOHandler::Transformations orientation);
+
// Obsolete as of 4.1
void setDescription(const QString &description);
QString description() const;
diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp
index 839f90f17c..4ff3917fe6 100644
--- a/src/gui/image/qjpeghandler.cpp
+++ b/src/gui/image/qjpeghandler.cpp
@@ -714,7 +714,7 @@ public:
};
QJpegHandlerPrivate(QJpegHandler *qq)
- : quality(75), exifOrientation(1), iod_src(0),
+ : quality(75), transformation(QImageIOHandler::TransformationNone), iod_src(0),
rgb888ToRgb32ConverterPtr(qt_convert_rgb888_to_rgb32), state(Ready), optimize(false), progressive(false), q(qq)
{}
@@ -730,10 +730,9 @@ public:
bool readJpegHeader(QIODevice*);
bool read(QImage *image);
- void applyExifOrientation(QImage *image);
int quality;
- int exifOrientation;
+ QImageIOHandler::Transformations transformation;
QVariant size;
QImage::Format format;
QSize scaledSize;
@@ -761,9 +760,8 @@ static bool readExifHeader(QDataStream &stream)
char prefix[6];
if (stream.readRawData(prefix, sizeof(prefix)) != sizeof(prefix))
return false;
- if (prefix[0] != 'E' || prefix[1] != 'x' || prefix[2] != 'i' || prefix[3] != 'f' || prefix[4] != 0 || prefix[5] != 0)
- return false;
- return true;
+ static const char exifMagic[6] = {'E', 'x', 'i', 'f', 0, 0};
+ return memcmp(prefix, exifMagic, 6) == 0;
}
/*
@@ -787,6 +785,7 @@ static int getExifOrientation(QByteArray &exifData)
quint16 val;
quint32 offset;
+ const qint64 headerStart = stream.device()->pos();
// read byte order marker
stream >> val;
@@ -803,20 +802,20 @@ static int getExifOrientation(QByteArray &exifData)
return -1;
stream >> offset;
- // we have already used 8 bytes of TIFF header
- offset -= 8;
// read IFD
while (!stream.atEnd()) {
quint16 numEntries;
// skip offset bytes to get the next IFD
- if (stream.skipRawData(offset) != (qint32)offset)
+ const qint64 bytesToSkip = offset - (stream.device()->pos() - headerStart);
+
+ if (stream.skipRawData(bytesToSkip) != bytesToSkip)
return -1;
stream >> numEntries;
- for (;numEntries > 0; --numEntries) {
+ for (; numEntries > 0; --numEntries) {
quint16 tag;
quint16 type;
quint32 components;
@@ -825,7 +824,7 @@ static int getExifOrientation(QByteArray &exifData)
stream >> tag >> type >> components >> value >> dummy;
if (tag == 0x0112) { // Tag Exif.Image.Orientation
- if (components !=1)
+ if (components != 1)
return -1;
if (type != 3) // we are expecting it to be an unsigned short
return -1;
@@ -847,6 +846,31 @@ static int getExifOrientation(QByteArray &exifData)
// No Exif orientation was found
return 0;
}
+
+static QImageIOHandler::Transformations exif2Qt(int exifOrientation)
+{
+ switch (exifOrientation) {
+ case 1: // normal
+ return QImageIOHandler::TransformationNone;
+ case 2: // mirror horizontal
+ return QImageIOHandler::TransformationMirror;
+ case 3: // rotate 180
+ return QImageIOHandler::TransformationRotate180;
+ case 4: // mirror vertical
+ return QImageIOHandler::TransformationFlip;
+ case 5: // mirror horizontal and rotate 270 CW
+ return QImageIOHandler::TransformationFlipAndRotate90;
+ case 6: // rotate 90 CW
+ return QImageIOHandler::TransformationRotate90;
+ case 7: // mirror horizontal and rotate 90 CW
+ return QImageIOHandler::TransformationMirrorAndRotate90;
+ case 8: // rotate 270 CW
+ return QImageIOHandler::TransformationRotate270;
+ }
+ qWarning("Invalid EXIF orientation");
+ return QImageIOHandler::TransformationNone;
+}
+
/*!
\internal
*/
@@ -866,7 +890,7 @@ bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device)
if (!setjmp(err.setjmp_buffer)) {
jpeg_save_markers(&info, JPEG_COM, 0xFFFF);
- jpeg_save_markers(&info, JPEG_APP0+1, 0xFFFF); // Exif uses APP1 marker
+ jpeg_save_markers(&info, JPEG_APP0 + 1, 0xFFFF); // Exif uses APP1 marker
(void) jpeg_read_header(&info, TRUE);
@@ -897,16 +921,18 @@ bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device)
description += key + QLatin1String(": ") + value.simplified();
readTexts.append(key);
readTexts.append(value);
- } else if (marker->marker == JPEG_APP0+1) {
+ } else if (marker->marker == JPEG_APP0 + 1) {
exifData.append((const char*)marker->data, marker->data_length);
}
}
- if (exifData.size()) {
+ if (!exifData.isEmpty()) {
// Exif data present
- int orientation = getExifOrientation(exifData);
- if (orientation > 0)
- exifOrientation = orientation;
+ int exifOrientation = getExifOrientation(exifData);
+ if (exifOrientation == -1)
+ return false;
+ if (exifOrientation > 0)
+ transformation = exif2Qt(exifOrientation);
}
state = ReadHeader;
@@ -922,48 +948,6 @@ bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device)
return true;
}
-void QJpegHandlerPrivate::applyExifOrientation(QImage *image)
-{
- // This is not an optimized implementation, but easiest to maintain
- QTransform transform;
-
- switch (exifOrientation) {
- case 1: // normal
- break;
- case 2: // mirror horizontal
- *image = image->mirrored(true, false);
- break;
- case 3: // rotate 180
- transform.rotate(180);
- *image = image->transformed(transform);
- break;
- case 4: // mirror vertical
- *image = image->mirrored(false, true);
- break;
- case 5: // mirror horizontal and rotate 270 CCW
- *image = image->mirrored(true, false);
- transform.rotate(270);
- *image = image->transformed(transform);
- break;
- case 6: // rotate 90 CW
- transform.rotate(90);
- *image = image->transformed(transform);
- break;
- case 7: // mirror horizontal and rotate 90 CW
- *image = image->mirrored(true, false);
- transform.rotate(90);
- *image = image->transformed(transform);
- break;
- case 8: // rotate 270 CW
- transform.rotate(-90);
- *image = image->transformed(transform);
- break;
- default:
- qWarning("This should never happen");
- }
- exifOrientation = 1;
-}
-
bool QJpegHandlerPrivate::read(QImage *image)
{
if(state == Ready)
@@ -975,7 +959,6 @@ bool QJpegHandlerPrivate::read(QImage *image)
if (success) {
for (int i = 0; i < readTexts.size()-1; i+=2)
image->setText(readTexts.at(i), readTexts.at(i+1));
- applyExifOrientation(image);
state = Ready;
return true;
@@ -1053,8 +1036,16 @@ bool QJpegHandler::read(QImage *image)
return d->read(image);
}
+extern void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient);
+
bool QJpegHandler::write(const QImage &image)
{
+ if (d->transformation != QImageIOHandler::TransformationNone) {
+ // We don't support writing EXIF headers so apply the transform to the data.
+ QImage img = image;
+ qt_imageTransform(img, d->transformation);
+ return write_jpeg_image(img, device(), d->quality, d->description, d->optimize, d->progressive);
+ }
return write_jpeg_image(image, device(), d->quality, d->description, d->optimize, d->progressive);
}
@@ -1068,7 +1059,8 @@ bool QJpegHandler::supportsOption(ImageOption option) const
|| option == Size
|| option == ImageFormat
|| option == OptimizedWrite
- || option == ProgressiveScanWrite;
+ || option == ProgressiveScanWrite
+ || option == ImageTransformation;
}
QVariant QJpegHandler::option(ImageOption option) const
@@ -1095,6 +1087,9 @@ QVariant QJpegHandler::option(ImageOption option) const
return d->optimize;
case ProgressiveScanWrite:
return d->progressive;
+ case ImageTransformation:
+ d->readJpegHeader(device());
+ return int(d->transformation);
default:
break;
}
@@ -1126,6 +1121,11 @@ void QJpegHandler::setOption(ImageOption option, const QVariant &value)
case ProgressiveScanWrite:
d->progressive = value.toBool();
break;
+ case ImageTransformation: {
+ int transformation = value.toInt();
+ if (transformation > 0 && transformation < 8)
+ d->transformation = QImageIOHandler::Transformations(transformation);
+ }
default:
break;
}
diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h
index 9bb193321b..c3897a1935 100644
--- a/src/gui/image/qpicture.h
+++ b/src/gui/image/qpicture.h
@@ -72,10 +72,11 @@ public:
QPicture& operator=(const QPicture &p);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QPicture &operator=(QPicture &&other)
+ inline QPicture &operator=(QPicture &&other) Q_DECL_NOEXCEPT
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
- inline void swap(QPicture &other) { d_ptr.swap(other.d_ptr); }
+ inline void swap(QPicture &other) Q_DECL_NOEXCEPT
+ { d_ptr.swap(other.d_ptr); }
void detach();
bool isDetached() const;
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index 810883ea6c..51b02acfcf 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -67,10 +67,11 @@ public:
QPixmap &operator=(const QPixmap &);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QPixmap &operator=(QPixmap &&other)
+ inline QPixmap &operator=(QPixmap &&other) Q_DECL_NOEXCEPT
{ qSwap(data, other.data); return *this; }
#endif
- inline void swap(QPixmap &other) { qSwap(data, other.data); }
+ inline void swap(QPixmap &other) Q_DECL_NOEXCEPT
+ { qSwap(data, other.data); }
operator QVariant() const;
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index 0de47f55af..12e19440dc 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -40,11 +40,6 @@
#include <QScopedArrayPointer>
#include <qt_windows.h>
-#ifdef Q_OS_WINCE
-#define UNDER_NT
-#include <wingdi.h>
-#endif
-
QT_BEGIN_NAMESPACE
#ifdef Q_OS_WINCE
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 3c88d2e9c1..7fbd24787e 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -676,16 +676,9 @@ QImage::Format QPngHandlerPrivate::readImageFormat()
&& num_palette <= 256)
{
// 1-bit and 8-bit color
- if (bit_depth != 1)
- png_set_packing(png_ptr);
- png_read_update_info(png_ptr, info_ptr);
- png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0);
format = bit_depth == 1 ? QImage::Format_Mono : QImage::Format_Indexed8;
} else {
// 32-bit
- if (bit_depth == 16)
- png_set_strip_16(png_ptr);
-
format = QImage::Format_ARGB32;
// Only add filler if no alpha, or we can get 5 channel data.
if (!(color_type & PNG_COLOR_MASK_ALPHA)
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 11f7f13552..1dc3e69470 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -263,6 +263,36 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &wind
{}
/*!
+ \since 5.6
+
+ Constructs a mouse event object.
+
+ The \a type parameter must be QEvent::MouseButtonPress,
+ QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
+ or QEvent::MouseMove.
+
+ The points \a localPos, \a windowPos and \a screenPos specify the
+ mouse cursor's position relative to the receiving widget or item,
+ window, and screen, respectively.
+
+ The \a button that caused the event is given as a value from the
+ \l Qt::MouseButton enum. If the event \a type is \l MouseMove,
+ the appropriate button for this event is Qt::NoButton. \a buttons
+ is the state of all buttons at the time of the event, \a modifiers
+ is the state of all keyboard modifiers.
+
+ The source of the event is specified by \a source.
+
+*/
+QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
+ : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0)
+{
+ QGuiApplicationPrivate::setMouseEventSource(this, source);
+}
+
+/*!
\internal
*/
QMouseEvent::~QMouseEvent()
@@ -1941,6 +1971,11 @@ QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
{
}
+QInputMethodEvent::~QInputMethodEvent()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
Sets the commit string to \a commitString.
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index e931e28a2e..dd7b35e2bb 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -106,6 +106,9 @@ public:
QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers);
+ QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source);
~QMouseEvent();
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
@@ -528,6 +531,8 @@ public:
};
QInputMethodEvent();
QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes);
+ ~QInputMethodEvent();
+
void setCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
inline const QList<Attribute> &attributes() const { return attrs; }
inline const QString &preeditString() const { return preedit; }
@@ -789,8 +794,10 @@ public:
explicit TouchPoint(int id = -1);
TouchPoint(const TouchPoint &other);
#ifdef Q_COMPILER_RVALUE_REFS
- TouchPoint(TouchPoint &&other) : d(other.d) { other.d = 0; }
- TouchPoint &operator=(TouchPoint &&other)
+ TouchPoint(TouchPoint &&other) Q_DECL_NOEXCEPT
+ : d(0)
+ { qSwap(d, other.d); }
+ TouchPoint &operator=(TouchPoint &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
~TouchPoint();
@@ -798,7 +805,8 @@ public:
TouchPoint &operator=(const TouchPoint &other)
{ if ( d != other.d ) { TouchPoint copy(other); swap(copy); } return *this; }
- void swap(TouchPoint &other) { qSwap(d, other.d); }
+ void swap(TouchPoint &other) Q_DECL_NOEXCEPT
+ { qSwap(d, other.d); }
int id() const;
diff --git a/src/gui/kernel/qgenericpluginfactory.cpp b/src/gui/kernel/qgenericpluginfactory.cpp
index 7e4727df8c..d7b9bfba06 100644
--- a/src/gui/kernel/qgenericpluginfactory.cpp
+++ b/src/gui/kernel/qgenericpluginfactory.cpp
@@ -69,13 +69,13 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
*/
QObject *QGenericPluginFactory::create(const QString& key, const QString &specification)
{
+#if (!defined(Q_OS_WIN32) || defined(QT_SHARED)) && !defined(QT_NO_LIBRARY)
const QString driver = key.toLower();
-
-#if !defined(Q_OS_WIN32) || defined(QT_SHARED)
-#ifndef QT_NO_LIBRARY
if (QObject *object = qLoadPlugin1<QObject, QGenericPlugin>(loader(), driver, specification))
return object;
-#endif
+#else // (!Q_OS_WIN32 || QT_SHARED) && !QT_NO_LIBRARY
+ Q_UNUSED(key)
+ Q_UNUSED(specification)
#endif
return 0;
}
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index fe0bbbc15a..7866f65b7e 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1334,6 +1334,9 @@ void QGuiApplicationPrivate::init()
#endif
#ifndef QT_NO_LIBRARY
+ if (qEnvironmentVariableIntValue("QT_LOAD_TESTABILITY") > 0)
+ loadTestability = true;
+
if (loadTestability) {
QLibrary testLib(QStringLiteral("qttestability"));
if (testLib.load()) {
@@ -1697,12 +1700,14 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
// A mouse event should not change both position and buttons at the same time. Instead we
// should first send a move event followed by a button changed event. Since this is not the case
// with the current event, we split it in two.
- QWindowSystemInterfacePrivate::MouseEvent *mouseButtonEvent = new QWindowSystemInterfacePrivate::MouseEvent(
+ QWindowSystemInterfacePrivate::MouseEvent mouseButtonEvent(
e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers);
if (e->flags & QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic)
- mouseButtonEvent->flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
- QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(mouseButtonEvent);
- stateChange = Qt::NoButton;
+ mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
+ e->buttons = buttons;
+ processMouseEvent(e);
+ processMouseEvent(&mouseButtonEvent);
+ return;
}
QWindow *window = e->window.data();
@@ -1771,9 +1776,8 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
if (!window)
return;
- QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, buttons, e->modifiers);
+ QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, buttons, e->modifiers, e->source);
ev.setTimestamp(e->timestamp);
- setMouseEventSource(&ev, e->source);
#ifndef QT_NO_CURSOR
if (!e->synthetic()) {
if (const QScreen *screen = window->screen())
@@ -1832,9 +1836,8 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
if (!e->window.isNull() || e->nullWindow()) { // QTBUG-36364, check if window closed in response to press
const QEvent::Type doubleClickType = frameStrut ? QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick;
QMouseEvent dblClickEvent(doubleClickType, localPoint, localPoint, globalPoint,
- button, buttons, e->modifiers);
+ button, buttons, e->modifiers, e->source);
dblClickEvent.setTimestamp(e->timestamp);
- setMouseEventSource(&dblClickEvent, e->source);
QGuiApplication::sendSpontaneousEvent(window, &dblClickEvent);
}
}
diff --git a/src/gui/kernel/qinputdevicemanager.cpp b/src/gui/kernel/qinputdevicemanager.cpp
index d0dd8a4e7c..dbdb03adbb 100644
--- a/src/gui/kernel/qinputdevicemanager.cpp
+++ b/src/gui/kernel/qinputdevicemanager.cpp
@@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE
QInputDeviceManager::QInputDeviceManager(QObject *parent)
: QObject(*new QInputDeviceManagerPrivate, parent)
{
+ qRegisterMetaType<DeviceType>();
}
int QInputDeviceManager::deviceCount(DeviceType type) const
diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h
index 15c84d1a82..d64793c23c 100644
--- a/src/gui/kernel/qinputdevicemanager_p.h
+++ b/src/gui/kernel/qinputdevicemanager_p.h
@@ -77,4 +77,6 @@ signals:
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QInputDeviceManager::DeviceType)
+
#endif // QINPUTDEVICEMANAGER_P_H
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 23d5f06aa2..ab846b63cb 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -39,6 +39,7 @@
#ifndef QT_NO_SHORTCUT
#include "qdebug.h"
+#include <QtCore/qhashfunctions.h>
#ifndef QT_NO_REGEXP
# include "qregexp.h"
#endif
@@ -1409,6 +1410,16 @@ bool QKeySequence::operator==(const QKeySequence &other) const
d->key[3] == other.d->key[3]);
}
+/*!
+ \since 5.6
+
+ Calculates the hash value of \a key, using
+ \a seed to seed the calculation.
+*/
+uint qHash(const QKeySequence &key, uint seed) Q_DECL_NOTHROW
+{
+ return qHashRange(key.d->key, key.d->key + QKeySequencePrivate::MaxKeyCount, seed);
+}
/*!
Provides an arbitrary comparison of this key sequence and
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
index cd7af5718f..e6616dae11 100644
--- a/src/gui/kernel/qkeysequence.h
+++ b/src/gui/kernel/qkeysequence.h
@@ -43,11 +43,12 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_SHORTCUT
+class QKeySequence;
+
/*****************************************************************************
QKeySequence stream functions
*****************************************************************************/
#ifndef QT_NO_DATASTREAM
-class QKeySequence;
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks);
#endif
@@ -59,6 +60,8 @@ void qt_set_sequence_auto_mnemonic(bool b);
class QVariant;
class QKeySequencePrivate;
+Q_GUI_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QKeySequence &key, uint seed = 0) Q_DECL_NOTHROW;
+
class Q_GUI_EXPORT QKeySequence
{
Q_GADGET
@@ -204,6 +207,7 @@ private:
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks);
+ friend Q_GUI_EXPORT uint qHash(const QKeySequence &key, uint seed) Q_DECL_NOTHROW;
friend class QShortcutMap;
friend class QShortcut;
diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp
index 2853f05ef3..3a1126d318 100644
--- a/src/gui/kernel/qopenglwindow.cpp
+++ b/src/gui/kernel/qopenglwindow.cpp
@@ -175,140 +175,156 @@ public:
this->shareContext = qt_gl_global_share_context();
}
- ~QOpenGLWindowPrivate()
- {
- Q_Q(QOpenGLWindow);
- if (q->isValid()) {
- q->makeCurrent(); // this works even when the platformwindow is destroyed
- paintDevice.reset(0);
- fbo.reset(0);
- blitter.destroy();
- q->doneCurrent();
- }
- }
+ ~QOpenGLWindowPrivate();
static QOpenGLWindowPrivate *get(QOpenGLWindow *w) { return w->d_func(); }
- void bindFBO()
- {
- if (updateBehavior > QOpenGLWindow::NoPartialUpdate)
- fbo->bind();
- else
- QOpenGLFramebufferObject::bindDefault();
+ void bindFBO();
+ void initialize();
+
+ void beginPaint(const QRegion &region) Q_DECL_OVERRIDE;
+ void endPaint() Q_DECL_OVERRIDE;
+ void flush(const QRegion &region) Q_DECL_OVERRIDE;
+
+ QOpenGLWindow::UpdateBehavior updateBehavior;
+ bool hasFboBlit;
+ QScopedPointer<QOpenGLContext> context;
+ QOpenGLContext *shareContext;
+ QScopedPointer<QOpenGLFramebufferObject> fbo;
+ QScopedPointer<QOpenGLWindowPaintDevice> paintDevice;
+ QOpenGLTextureBlitter blitter;
+ QColor backgroundColor;
+ QScopedPointer<QOffscreenSurface> offscreenSurface;
+};
+
+QOpenGLWindowPrivate::~QOpenGLWindowPrivate()
+{
+ Q_Q(QOpenGLWindow);
+ if (q->isValid()) {
+ q->makeCurrent(); // this works even when the platformwindow is destroyed
+ paintDevice.reset(0);
+ fbo.reset(0);
+ blitter.destroy();
+ q->doneCurrent();
}
+}
- void beginPaint(const QRegion &region) Q_DECL_OVERRIDE
- {
- Q_UNUSED(region);
- Q_Q(QOpenGLWindow);
-
- if (!context) {
- context.reset(new QOpenGLContext);
- context->setShareContext(shareContext);
- context->setFormat(q->requestedFormat());
- if (!context->create())
- qWarning("QOpenGLWindow::beginPaint: Failed to create context");
- if (!context->makeCurrent(q))
- qWarning("QOpenGLWindow::beginPaint: Failed to make context current");
-
- paintDevice.reset(new QOpenGLWindowPaintDevice(q));
- if (updateBehavior == QOpenGLWindow::PartialUpdateBlit)
- hasFboBlit = QOpenGLFramebufferObject::hasOpenGLFramebufferBlit();
-
- q->initializeGL();
- } else {
- context->makeCurrent(q);
- }
+void QOpenGLWindowPrivate::initialize()
+{
+ Q_Q(QOpenGLWindow);
- const int deviceWidth = q->width() * q->devicePixelRatio();
- const int deviceHeight = q->height() * q->devicePixelRatio();
- const QSize deviceSize(deviceWidth, deviceHeight);
- if (updateBehavior > QOpenGLWindow::NoPartialUpdate) {
- if (!fbo || fbo->size() != deviceSize) {
- QOpenGLFramebufferObjectFormat fboFormat;
- fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
- if (q->requestedFormat().samples() > 0) {
- if (updateBehavior != QOpenGLWindow::PartialUpdateBlend)
- fboFormat.setSamples(q->requestedFormat().samples());
- else
- qWarning("QOpenGLWindow: PartialUpdateBlend does not support multisampling");
- }
- fbo.reset(new QOpenGLFramebufferObject(deviceSize, fboFormat));
- markWindowAsDirty();
+ if (context)
+ return;
+
+ context.reset(new QOpenGLContext);
+ context->setShareContext(shareContext);
+ context->setFormat(q->requestedFormat());
+ if (!context->create())
+ qWarning("QOpenGLWindow::beginPaint: Failed to create context");
+ if (!context->makeCurrent(q))
+ qWarning("QOpenGLWindow::beginPaint: Failed to make context current");
+
+ paintDevice.reset(new QOpenGLWindowPaintDevice(q));
+ if (updateBehavior == QOpenGLWindow::PartialUpdateBlit)
+ hasFboBlit = QOpenGLFramebufferObject::hasOpenGLFramebufferBlit();
+
+ q->initializeGL();
+}
+
+void QOpenGLWindowPrivate::beginPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+ Q_Q(QOpenGLWindow);
+
+ initialize();
+ context->makeCurrent(q);
+
+ const int deviceWidth = q->width() * q->devicePixelRatio();
+ const int deviceHeight = q->height() * q->devicePixelRatio();
+ const QSize deviceSize(deviceWidth, deviceHeight);
+ if (updateBehavior > QOpenGLWindow::NoPartialUpdate) {
+ if (!fbo || fbo->size() != deviceSize) {
+ QOpenGLFramebufferObjectFormat fboFormat;
+ fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+ if (q->requestedFormat().samples() > 0) {
+ if (updateBehavior != QOpenGLWindow::PartialUpdateBlend)
+ fboFormat.setSamples(q->requestedFormat().samples());
+ else
+ qWarning("QOpenGLWindow: PartialUpdateBlend does not support multisampling");
}
- } else {
+ fbo.reset(new QOpenGLFramebufferObject(deviceSize, fboFormat));
markWindowAsDirty();
}
+ } else {
+ markWindowAsDirty();
+ }
- paintDevice->setSize(QSize(deviceWidth, deviceHeight));
- paintDevice->setDevicePixelRatio(q->devicePixelRatio());
- context->functions()->glViewport(0, 0, deviceWidth, deviceHeight);
+ paintDevice->setSize(QSize(deviceWidth, deviceHeight));
+ paintDevice->setDevicePixelRatio(q->devicePixelRatio());
+ context->functions()->glViewport(0, 0, deviceWidth, deviceHeight);
- context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject());
+ context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject());
- q->paintUnderGL();
+ q->paintUnderGL();
- if (updateBehavior > QOpenGLWindow::NoPartialUpdate)
- fbo->bind();
- }
+ if (updateBehavior > QOpenGLWindow::NoPartialUpdate)
+ fbo->bind();
+}
- void endPaint() Q_DECL_OVERRIDE
- {
- Q_Q(QOpenGLWindow);
-
- if (updateBehavior > QOpenGLWindow::NoPartialUpdate)
- fbo->release();
-
- context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject());
-
- if (updateBehavior == QOpenGLWindow::PartialUpdateBlit && hasFboBlit) {
- const int deviceWidth = q->width() * q->devicePixelRatio();
- const int deviceHeight = q->height() * q->devicePixelRatio();
- QOpenGLExtensions extensions(context.data());
- extensions.glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->handle());
- extensions.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, context->defaultFramebufferObject());
- extensions.glBlitFramebuffer(0, 0, deviceWidth, deviceHeight,
- 0, 0, deviceWidth, deviceHeight,
- GL_COLOR_BUFFER_BIT, GL_NEAREST);
- } else if (updateBehavior > QOpenGLWindow::NoPartialUpdate) {
- if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) {
- context->functions()->glEnable(GL_BLEND);
- context->functions()->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
- if (!blitter.isCreated())
- blitter.create();
+void QOpenGLWindowPrivate::endPaint()
+{
+ Q_Q(QOpenGLWindow);
+
+ if (updateBehavior > QOpenGLWindow::NoPartialUpdate)
+ fbo->release();
- QRect windowRect(QPoint(0, 0), fbo->size());
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(windowRect, windowRect);
- blitter.bind();
- blitter.blit(fbo->texture(), target, QOpenGLTextureBlitter::OriginBottomLeft);
- blitter.release();
+ context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject());
- if (updateBehavior == QOpenGLWindow::PartialUpdateBlend)
- context->functions()->glDisable(GL_BLEND);
+ if (updateBehavior == QOpenGLWindow::PartialUpdateBlit && hasFboBlit) {
+ const int deviceWidth = q->width() * q->devicePixelRatio();
+ const int deviceHeight = q->height() * q->devicePixelRatio();
+ QOpenGLExtensions extensions(context.data());
+ extensions.glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->handle());
+ extensions.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, context->defaultFramebufferObject());
+ extensions.glBlitFramebuffer(0, 0, deviceWidth, deviceHeight,
+ 0, 0, deviceWidth, deviceHeight,
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);
+ } else if (updateBehavior > QOpenGLWindow::NoPartialUpdate) {
+ if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) {
+ context->functions()->glEnable(GL_BLEND);
+ context->functions()->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
+ if (!blitter.isCreated())
+ blitter.create();
- q->paintOverGL();
- }
+ QRect windowRect(QPoint(0, 0), fbo->size());
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(windowRect, windowRect);
+ blitter.bind();
+ blitter.blit(fbo->texture(), target, QOpenGLTextureBlitter::OriginBottomLeft);
+ blitter.release();
- void flush(const QRegion &region) Q_DECL_OVERRIDE
- {
- Q_UNUSED(region);
- Q_Q(QOpenGLWindow);
- context->swapBuffers(q);
- emit q->frameSwapped();
+ if (updateBehavior == QOpenGLWindow::PartialUpdateBlend)
+ context->functions()->glDisable(GL_BLEND);
}
- QOpenGLWindow::UpdateBehavior updateBehavior;
- bool hasFboBlit;
- QScopedPointer<QOpenGLContext> context;
- QOpenGLContext *shareContext;
- QScopedPointer<QOpenGLFramebufferObject> fbo;
- QScopedPointer<QOpenGLWindowPaintDevice> paintDevice;
- QOpenGLTextureBlitter blitter;
- QColor backgroundColor;
- QScopedPointer<QOffscreenSurface> offscreenSurface;
-};
+ q->paintOverGL();
+}
+
+void QOpenGLWindowPrivate::bindFBO()
+{
+ if (updateBehavior > QOpenGLWindow::NoPartialUpdate)
+ fbo->bind();
+ else
+ QOpenGLFramebufferObject::bindDefault();
+}
+
+void QOpenGLWindowPrivate::flush(const QRegion &region)
+{
+ Q_UNUSED(region);
+ Q_Q(QOpenGLWindow);
+ context->swapBuffers(q);
+ emit q->frameSwapped();
+}
void QOpenGLWindowPaintDevice::ensureActiveTarget()
{
@@ -631,6 +647,8 @@ void QOpenGLWindow::paintEvent(QPaintEvent *event)
void QOpenGLWindow::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
+ Q_D(QOpenGLWindow);
+ d->initialize();
resizeGL(width(), height());
}
diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h
index e8b35aa82a..66b3f039f4 100644
--- a/src/gui/kernel/qpalette.h
+++ b/src/gui/kernel/qpalette.h
@@ -62,15 +62,17 @@ public:
QPalette &operator=(const QPalette &palette);
#ifdef Q_COMPILER_RVALUE_REFS
QPalette(QPalette &&other) Q_DECL_NOTHROW
- : d(other.d), data(other.data) { other.d = Q_NULLPTR; }
- inline QPalette &operator=(QPalette &&other)
+ : d(other.d), data(other.data)
+ { other.d = Q_NULLPTR; }
+ inline QPalette &operator=(QPalette &&other) Q_DECL_NOEXCEPT
{
for_faster_swapping_dont_use = other.for_faster_swapping_dont_use;
qSwap(d, other.d); return *this;
}
#endif
- void swap(QPalette &other) {
+ void swap(QPalette &other) Q_DECL_NOEXCEPT
+ {
qSwap(d, other.d);
qSwap(for_faster_swapping_dont_use, other.for_faster_swapping_dont_use);
}
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index 2d0458f705..3d35c4dcba 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -136,6 +136,12 @@ QVariant QPlatformDialogHelper::defaultStyleHint(QPlatformDialogHelper::StyleHi
return QVariant();
}
+void QPlatformDialogHelper::execModalForWindow(QWindow *parent)
+{
+ Q_UNUSED(parent);
+ exec();
+}
+
// Font dialog
class QFontDialogOptionsPrivate : public QSharedData
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index 8b2b9881b7..6d3a367e60 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -145,6 +145,7 @@ public:
virtual QVariant styleHint(StyleHint hint) const;
virtual void exec() = 0;
+ virtual void execModalForWindow(QWindow *parent);
virtual bool show(Qt::WindowFlags windowFlags,
Qt::WindowModality windowModality,
QWindow *parent) = 0;
diff --git a/src/gui/kernel/qplatforminputcontextplugin_p.h b/src/gui/kernel/qplatforminputcontextplugin_p.h
index 732eba3e06..d05672558d 100644
--- a/src/gui/kernel/qplatforminputcontextplugin_p.h
+++ b/src/gui/kernel/qplatforminputcontextplugin_p.h
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
class QPlatformInputContext;
-#define QPlatformInputContextFactoryInterface_iid "org.qt-project.Qt.QPlatformInputContextFactoryInterface"
+#define QPlatformInputContextFactoryInterface_iid "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1"
class Q_GUI_EXPORT QPlatformInputContextPlugin : public QObject
{
diff --git a/src/gui/kernel/qplatformintegrationplugin.h b/src/gui/kernel/qplatformintegrationplugin.h
index b5e0b1874c..89808cde5e 100644
--- a/src/gui/kernel/qplatformintegrationplugin.h
+++ b/src/gui/kernel/qplatformintegrationplugin.h
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
class QPlatformIntegration;
-#define QPlatformIntegrationFactoryInterface_iid "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2"
+#define QPlatformIntegrationFactoryInterface_iid "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3"
class Q_GUI_EXPORT QPlatformIntegrationPlugin : public QObject
{
diff --git a/src/gui/kernel/qplatformmenu.cpp b/src/gui/kernel/qplatformmenu.cpp
index cb311b8d13..da65381931 100644
--- a/src/gui/kernel/qplatformmenu.cpp
+++ b/src/gui/kernel/qplatformmenu.cpp
@@ -44,4 +44,9 @@ QPlatformMenuItem *QPlatformMenu::createMenuItem() const
return QGuiApplicationPrivate::platformTheme()->createPlatformMenuItem();
}
+QPlatformMenu *QPlatformMenu::createSubMenu() const
+{
+ return QGuiApplicationPrivate::platformTheme()->createPlatformMenu();
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h
index baa1e460d7..1022d0ed4a 100644
--- a/src/gui/kernel/qplatformmenu.h
+++ b/src/gui/kernel/qplatformmenu.h
@@ -123,6 +123,7 @@ public:
virtual QPlatformMenuItem *menuItemForTag(quintptr tag) const = 0;
virtual QPlatformMenuItem *createMenuItem() const;
+ virtual QPlatformMenu *createSubMenu() const;
Q_SIGNALS:
void aboutToShow();
void aboutToHide();
diff --git a/src/gui/kernel/qplatformopenglcontext.cpp b/src/gui/kernel/qplatformopenglcontext.cpp
index b9cf81b30e..f98f8a496c 100644
--- a/src/gui/kernel/qplatformopenglcontext.cpp
+++ b/src/gui/kernel/qplatformopenglcontext.cpp
@@ -131,6 +131,10 @@ bool QPlatformOpenGLContext::parseOpenGLVersion(const QByteArray &versionString,
if (versionParts.size() >= 2) {
major = versionParts.at(0).toInt(&majorOk);
minor = versionParts.at(1).toInt(&minorOk);
+ // Nexus 6 has "OpenGL ES 3.0V@95.0 (GIT@I86da836d38)"
+ if (!minorOk)
+ if (int idx = versionParts.at(1).indexOf('V'))
+ minor = versionParts.at(1).left(idx).toInt(&minorOk);
} else {
qWarning("Unrecognized OpenGL ES version");
}
diff --git a/src/gui/kernel/qshapedpixmapdndwindow.cpp b/src/gui/kernel/qshapedpixmapdndwindow.cpp
index 253a09e407..8f80789fb0 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow.cpp
+++ b/src/gui/kernel/qshapedpixmapdndwindow.cpp
@@ -47,7 +47,7 @@ QShapedPixmapWindow::QShapedPixmapWindow()
setFormat(format);
setSurfaceType(RasterSurface);
setFlags(Qt::ToolTip | Qt::FramelessWindowHint |
- Qt::X11BypassWindowManagerHint | Qt::WindowTransparentForInput);
+ Qt::X11BypassWindowManagerHint | Qt::WindowTransparentForInput | Qt::WindowDoesNotAcceptFocus);
create();
m_backingStore = new QBackingStore(this);
}
@@ -86,16 +86,14 @@ void QShapedPixmapWindow::setHotspot(const QPoint &hotspot)
m_hotSpot = hotspot;
}
-void QShapedPixmapWindow::updateGeometry()
+void QShapedPixmapWindow::updateGeometry(const QPoint &pos)
{
-#ifndef QT_NO_CURSOR
- QRect rect(QCursor::pos() - m_hotSpot, m_pixmap.size());
if (m_pixmap.isNull())
m_backingStore->resize(QSize(1,1));
else if (m_backingStore->size() != m_pixmap.size())
m_backingStore->resize(m_pixmap.size());
- setGeometry(rect);
-#endif
+
+ setGeometry(QRect(pos - m_hotSpot, m_backingStore->size()));
}
void QShapedPixmapWindow::exposeEvent(QExposeEvent *)
diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h
index ec56573195..fc311cff92 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow_p.h
+++ b/src/gui/kernel/qshapedpixmapdndwindow_p.h
@@ -63,7 +63,7 @@ public:
void setPixmap(const QPixmap &pixmap);
void setHotspot(const QPoint &hotspot);
- void updateGeometry();
+ void updateGeometry(const QPoint &pos);
protected:
void exposeEvent(QExposeEvent *) Q_DECL_OVERRIDE;
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index 517f3024aa..162dbfee20 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -210,7 +210,16 @@ void QBasicDrag::startDrag()
m_drag_icon_window->setPixmap(m_drag->pixmap());
m_drag_icon_window->setHotspot(m_drag->hotSpot());
- m_drag_icon_window->updateGeometry();
+
+#ifndef QT_NO_CURSOR
+ QPoint pos = QCursor::pos();
+ if (pos.x() == int(qInf())) {
+ // ### fixme: no mouse pos registered. Get pos from touch...
+ pos = QPoint();
+ }
+ m_drag_icon_window->updateGeometry(pos);
+#endif
+
m_drag_icon_window->setVisible(true);
enableEventFilter();
@@ -227,10 +236,10 @@ void QBasicDrag::cancel()
m_drag_icon_window->setVisible(false);
}
-void QBasicDrag::move(const QPoint &)
+void QBasicDrag::move(const QPoint &globalPos)
{
if (m_drag)
- m_drag_icon_window->updateGeometry();
+ m_drag_icon_window->updateGeometry(globalPos);
}
void QBasicDrag::drop(const QPoint &)
diff --git a/src/gui/kernel/qtouchdevice.cpp b/src/gui/kernel/qtouchdevice.cpp
index 8737825de0..1a6e9deba8 100644
--- a/src/gui/kernel/qtouchdevice.cpp
+++ b/src/gui/kernel/qtouchdevice.cpp
@@ -37,6 +37,8 @@
#include <QMutex>
#include <QCoreApplication>
+#include <private/qdebug_p.h>
+
QT_BEGIN_NAMESPACE
/*!
@@ -239,4 +241,25 @@ void QTouchDevicePrivate::registerDevice(QTouchDevice *dev)
deviceList()->append(dev);
}
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QTouchDevice *device)
+{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+ debug.noquote();
+ debug << "QTouchDevice(";
+ if (device) {
+ debug << '"' << device->name() << "\", type=";
+ QtDebugUtils::formatQEnum(debug, device->type());
+ debug << ", capabilities=";
+ QtDebugUtils::formatQFlags(debug, device->capabilities());
+ debug << ", maximumTouchPoints=" << device->maximumTouchPoints();
+ } else {
+ debug << '0';
+ }
+ debug << ')';
+ return debug;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qtouchdevice.h b/src/gui/kernel/qtouchdevice.h
index f2157ce2d6..1c1fcc63aa 100644
--- a/src/gui/kernel/qtouchdevice.h
+++ b/src/gui/kernel/qtouchdevice.h
@@ -38,16 +38,18 @@
QT_BEGIN_NAMESPACE
-
+class QDebug;
class QTouchDevicePrivate;
class Q_GUI_EXPORT QTouchDevice
{
+ Q_GADGET
public:
enum DeviceType {
TouchScreen,
TouchPad
};
+ Q_ENUM(DeviceType)
enum CapabilityFlag {
Position = 0x0001,
@@ -58,6 +60,7 @@ public:
NormalizedPosition = 0x0020,
MouseEmulation = 0x0040
};
+ Q_FLAG(CapabilityFlag)
Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)
QTouchDevice();
@@ -81,6 +84,10 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QTouchDevice::Capabilities)
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug, const QTouchDevice *);
+#endif
+
QT_END_NAMESPACE
#endif // QTOUCHDEVICE_H
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 13461e981e..6f01f9a466 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -49,6 +49,7 @@ QElapsedTimer QWindowSystemInterfacePrivate::eventTime;
bool QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = false;
QWaitCondition QWindowSystemInterfacePrivate::eventsFlushed;
QMutex QWindowSystemInterfacePrivate::flushEventMutex;
+QWindowSystemEventHandler *QWindowSystemInterfacePrivate::eventHandler;
//------------------------------------------------------------
//
@@ -630,14 +631,32 @@ bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFla
QWindowSystemInterfacePrivate::getWindowSystemEvent();
if (!event)
break;
- nevents++;
- QGuiApplicationPrivate::processWindowSystemEvent(event);
+
+ if (QWindowSystemInterfacePrivate::eventHandler) {
+ if (QWindowSystemInterfacePrivate::eventHandler->sendEvent(event))
+ nevents++;
+ } else {
+ nevents++;
+ QGuiApplicationPrivate::processWindowSystemEvent(event);
+ }
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;
@@ -819,14 +838,26 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPo
}
#endif
-Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier) {
-
- QWindowSystemInterface::handleMouseEvent(w, QHighDpi::toNativeLocalPosition(local, w), QHighDpi::toNativePixels(global, w), b, mods);
+Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods, int timestamp)
+{
+ QWindowSystemInterfacePrivate::MouseEvent e(w, timestamp, local, global, b, mods, Qt::MouseEventNotSynthesized);
+ QGuiApplicationPrivate::processWindowSystemEvent(&e);
}
Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
{
- QWindowSystemInterface::handleKeyEvent(w, t, k, mods, text, autorep, count);
+ unsigned long timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed();
+
+ // This is special handling needed for OS X which eventually will call sendEvent(), on other platforms
+ // this might not be safe, e.g., on Android. See: QGuiApplicationPrivate::processKeyEvent() for
+ // shortcut overriding on other platforms.
+#if defined(Q_OS_OSX)
+ if (t == QEvent::KeyPress && QWindowSystemInterface::tryHandleShortcutEvent(w, timestamp, k, mods, text))
+ return;
+#endif // Q_OS_OSX
+
+ QWindowSystemInterfacePrivate::KeyEvent e(w, timestamp, t, k, mods, text, autorep, count);
+ QGuiApplicationPrivate::processWindowSystemEvent(&e);
}
Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1)
@@ -834,11 +865,49 @@ Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int
return QWindowSystemInterface::tryHandleShortcutEventToObject(o, timestamp, k, mods, text, autorep, count);
}
-Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,
+Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,
const QList<QTouchEvent::TouchPoint> &points,
Qt::KeyboardModifiers mods = Qt::NoModifier)
{
- QWindowSystemInterface::handleTouchEvent(w, device, QWindowSystemInterfacePrivate::toNativeTouchPoints(points, w), mods);
+ unsigned long timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed();
+
+ if (!points.size()) // Touch events must have at least one point
+ return;
+
+ if (!QTouchDevicePrivate::isRegistered(device)) // Disallow passing bogus, non-registered devices.
+ return;
+
+ QEvent::Type type;
+ Qt::TouchPointStates states;
+
+ QList<QTouchEvent::TouchPoint>::const_iterator point = points.constBegin();
+ QList<QTouchEvent::TouchPoint>::const_iterator end = points.constEnd();
+ while (point != end) {
+ states |= point->state();
+ ++point;
+ }
+
+ // Determine the event type based on the combined point states.
+ type = QEvent::TouchUpdate;
+ if (states == Qt::TouchPointPressed)
+ type = QEvent::TouchBegin;
+ else if (states == Qt::TouchPointReleased)
+ type = QEvent::TouchEnd;
+
+ QWindowSystemInterfacePrivate::TouchEvent e(w, timestamp, type, device, points, mods);
+ QGuiApplicationPrivate::processWindowSystemEvent(&e);
}
+QWindowSystemEventHandler::~QWindowSystemEventHandler()
+{
+ QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(this);
+}
+
+bool QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
+{
+ QGuiApplicationPrivate::processWindowSystemEvent(e);
+ return true;
+}
+
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 8073669dfa..cbc3bad7cd 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -54,6 +54,8 @@
QT_BEGIN_NAMESPACE
+class QWindowSystemEventHandler;
+
class Q_GUI_EXPORT QWindowSystemInterfacePrivate {
public:
enum EventType {
@@ -492,6 +494,17 @@ public:
static QList<QWindowSystemInterface::TouchPoint>
toNativeTouchPoints(const QList<QTouchEvent::TouchPoint>& pointList,
const QWindow *window);
+
+ static void installWindowSystemEventHandler(QWindowSystemEventHandler *handler);
+ static void removeWindowSystemEventhandler(QWindowSystemEventHandler *handler);
+ static QWindowSystemEventHandler *eventHandler;
+};
+
+class Q_GUI_EXPORT QWindowSystemEventHandler
+{
+public:
+ virtual ~QWindowSystemEventHandler();
+ virtual bool sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *event);
};
QT_END_NAMESPACE
diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h
index c08faaaa8b..19809056fd 100644
--- a/src/gui/math3d/qgenericmatrix.h
+++ b/src/gui/math3d/qgenericmatrix.h
@@ -57,7 +57,7 @@ public:
void fill(T value);
- QGenericMatrix<M, N, T> transposed() const;
+ QGenericMatrix<M, N, T> transposed() const Q_REQUIRED_RESULT;
QGenericMatrix<N, M, T>& operator+=(const QGenericMatrix<N, M, T>& other);
QGenericMatrix<N, M, T>& operator-=(const QGenericMatrix<N, M, T>& other);
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index 4b35ee4e79..0e73f79ac0 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -301,13 +301,21 @@ void QQuaternion::normalize()
*/
/*!
- \fn QQuaternion QQuaternion::conjugate() const
+ \fn QQuaternion QQuaternion::conjugated() const
+ \since 5.5
Returns the conjugate of this quaternion, which is
(-x, -y, -z, scalar).
*/
/*!
+ \fn QQuaternion QQuaternion::conjugate() const
+ \obsolete
+
+ Use conjugated() instead.
+*/
+
+/*!
Rotates \a vector with this quaternion to produce a new vector
in 3D space. The following code:
@@ -318,12 +326,12 @@ void QQuaternion::normalize()
is equivalent to the following:
\code
- QVector3D result = (q * QQuaternion(0, vector) * q.conjugate()).vector();
+ QVector3D result = (q * QQuaternion(0, vector) * q.conjugated()).vector();
\endcode
*/
QVector3D QQuaternion::rotatedVector(const QVector3D& vector) const
{
- return (*this * QQuaternion(0, vector) * conjugate()).vector();
+ return (*this * QQuaternion(0, vector) * conjugated()).vector();
}
/*!
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index 52c717072d..5b0006ac56 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -83,12 +83,15 @@ public:
float length() const;
float lengthSquared() const;
- QQuaternion normalized() const;
+ QQuaternion normalized() const Q_REQUIRED_RESULT;
void normalize();
inline QQuaternion inverted() const;
- QQuaternion conjugate() const;
+ QQuaternion conjugated() const Q_REQUIRED_RESULT;
+#if QT_DEPRECATED_SINCE(5, 5)
+ QT_DEPRECATED QQuaternion conjugate() const Q_REQUIRED_RESULT;
+#endif
QVector3D rotatedVector(const QVector3D& vector) const;
@@ -161,12 +164,12 @@ inline QQuaternion::QQuaternion(float aScalar, float xpos, float ypos, float zpo
inline bool QQuaternion::isNull() const
{
- return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && qIsNull(wp);
+ return xp == 0.0f && yp == 0.0f && zp == 0.0f && wp == 0.0f;
}
inline bool QQuaternion::isIdentity() const
{
- return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && wp == 1.0f;
+ return xp == 0.0f && yp == 0.0f && zp == 0.0f && wp == 1.0f;
}
inline float QQuaternion::x() const { return xp; }
@@ -196,11 +199,18 @@ inline QQuaternion QQuaternion::inverted() const
return QQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
}
-inline QQuaternion QQuaternion::conjugate() const
+inline QQuaternion QQuaternion::conjugated() const
{
return QQuaternion(wp, -xp, -yp, -zp);
}
+#if QT_DEPRECATED_SINCE(5, 5)
+inline QQuaternion QQuaternion::conjugate() const
+{
+ return conjugated();
+}
+#endif
+
inline QQuaternion &QQuaternion::operator+=(const QQuaternion &quaternion)
{
xp += quaternion.xp;
@@ -230,9 +240,9 @@ inline QQuaternion &QQuaternion::operator*=(float factor)
inline const QQuaternion operator*(const QQuaternion &q1, const QQuaternion& q2)
{
- float ww = (q1.zp + q1.xp) * (q2.xp + q2.yp);
float yy = (q1.wp - q1.yp) * (q2.wp + q2.zp);
float zz = (q1.wp + q1.yp) * (q2.wp - q2.zp);
+ float ww = (q1.zp + q1.xp) * (q2.xp + q2.yp);
float xx = ww + yy + zz;
float qq = 0.5 * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp));
diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h
index 20264fa84f..137142f381 100644
--- a/src/gui/math3d/qvector2d.h
+++ b/src/gui/math3d/qvector2d.h
@@ -75,7 +75,7 @@ public:
float length() const;
float lengthSquared() const; //In Qt 6 convert to inline and constexpr
- QVector2D normalized() const;
+ QVector2D normalized() const Q_REQUIRED_RESULT;
void normalize();
float distanceToPoint(const QVector2D &point) const;
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h
index aa69104f55..72db8ac754 100644
--- a/src/gui/math3d/qvector4d.h
+++ b/src/gui/math3d/qvector4d.h
@@ -81,7 +81,7 @@ public:
float length() const;
float lengthSquared() const; //In Qt 6 convert to inline and constexpr
- QVector4D normalized() const;
+ QVector4D normalized() const Q_REQUIRED_RESULT;
void normalize();
QVector4D &operator+=(const QVector4D &vector);
diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp
index c8d33df4ba..1c008ccb42 100644
--- a/src/gui/opengl/qopengl.cpp
+++ b/src/gui/opengl/qopengl.cpp
@@ -47,6 +47,8 @@
#include <QtCore/QFile>
#include <QtCore/QDir>
+#include <set>
+
QT_BEGIN_NAMESPACE
#if defined(QT_OPENGL_3)
@@ -128,7 +130,7 @@ QDebug operator<<(QDebug d, const QOpenGLConfig::Gpu &g)
}
enum Operator { NotEqual, LessThan, LessEqualThan, Equals, GreaterThan, GreaterEqualThan };
-static const char *operators[] = {"!=", "<", "<=", "=", ">", ">="};
+static const char operators[][3] = {"!=", "<", "<=", "=", ">", ">="};
static inline QString valueKey() { return QStringLiteral("value"); }
static inline QString opKey() { return QStringLiteral("op"); }
@@ -474,4 +476,13 @@ QOpenGLConfig::Gpu QOpenGLConfig::Gpu::fromContext()
return gpu;
}
+Q_GUI_EXPORT std::set<QByteArray> *qgpu_features(const QString &filename)
+{
+ const QSet<QString> features = QOpenGLConfig::gpuFeatures(QOpenGLConfig::Gpu::fromContext(), filename);
+ std::set<QByteArray> *result = new std::set<QByteArray>;
+ foreach (const QString &feature, features)
+ result->insert(feature.toUtf8());
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/opengl/qopenglengineshadermanager.cpp b/src/gui/opengl/qopenglengineshadermanager.cpp
index 853ad8b711..7e53c01cba 100644
--- a/src/gui/opengl/qopenglengineshadermanager.cpp
+++ b/src/gui/opengl/qopenglengineshadermanager.cpp
@@ -511,7 +511,7 @@ GLuint QOpenGLEngineShaderManager::getUniformLocation(Uniform id)
if (uniformLocations.isEmpty())
uniformLocations.fill(GLuint(-1), NumUniforms);
- static const char *uniformNames[] = {
+ static const char *const uniformNames[] = {
"imageTexture",
"patternColor",
"globalOpacity",
diff --git a/src/gui/opengl/qopenglextensions_p.h b/src/gui/opengl/qopenglextensions_p.h
index ff5d79566c..7def687f49 100644
--- a/src/gui/opengl/qopenglextensions_p.h
+++ b/src/gui/opengl/qopenglextensions_p.h
@@ -76,6 +76,9 @@ public:
void (QOPENGLF_APIENTRYP TexStorage2D)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height);
private:
+ bool init();
+ QFunctionPointer resolve(const char *name);
+
QLibrary m_gl;
};
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index c60532b90b..b9d674fd3b 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -39,6 +39,10 @@
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
+#ifdef Q_OS_IOS
+#include <dlfcn.h>
+#endif
+
#ifndef GL_FRAMEBUFFER_SRGB_CAPABLE_EXT
#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
#endif
@@ -3202,35 +3206,53 @@ static void QOPENGLF_APIENTRY qopenglfResolveVertexAttribPointer(GLuint indx, GL
Q_GLOBAL_STATIC(QOpenGLES3Helper, qgles3Helper)
-QOpenGLES3Helper::QOpenGLES3Helper()
+bool QOpenGLES3Helper::init()
{
-#ifdef Q_OS_WIN
-#ifdef QT_DEBUG
+#ifndef Q_OS_IOS
+# ifdef Q_OS_WIN
+# ifndef QT_DEBUG
m_gl.setFileName(QStringLiteral("libGLESv2"));
-#else
+# else
m_gl.setFileName(QStringLiteral("libGLESv2d"));
-#endif
-#else
+# endif
+# else
m_gl.setFileName(QStringLiteral("GLESv2"));
+# endif // Q_OS_WIN
+ return m_gl.load();
+#else
+ return true;
+#endif // Q_OS_IOS
+}
+
+QFunctionPointer QOpenGLES3Helper::resolve(const char *name)
+{
+#ifdef Q_OS_IOS
+ return QFunctionPointer(dlsym(RTLD_DEFAULT, name));
+#else
+ return m_gl.resolve(name);
#endif
- if (m_gl.load()) {
- MapBufferRange = (GLvoid* (QOPENGLF_APIENTRYP)(GLenum, qopengl_GLintptr, qopengl_GLsizeiptr, GLbitfield)) m_gl.resolve("glMapBufferRange");
- UnmapBuffer = (GLboolean (QOPENGLF_APIENTRYP)(GLenum)) m_gl.resolve("glUnmapBuffer");
- BlitFramebuffer = (void (QOPENGLF_APIENTRYP)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum)) m_gl.resolve("glBlitFramebuffer");
- RenderbufferStorageMultisample = (void (QOPENGLF_APIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)) m_gl.resolve("glRenderbufferStorageMultisample");
+}
+
+QOpenGLES3Helper::QOpenGLES3Helper()
+{
+ if (init()) {
+ MapBufferRange = (GLvoid* (QOPENGLF_APIENTRYP)(GLenum, qopengl_GLintptr, qopengl_GLsizeiptr, GLbitfield)) resolve("glMapBufferRange");
+ UnmapBuffer = (GLboolean (QOPENGLF_APIENTRYP)(GLenum)) resolve("glUnmapBuffer");
+ BlitFramebuffer = (void (QOPENGLF_APIENTRYP)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum)) resolve("glBlitFramebuffer");
+ RenderbufferStorageMultisample = (void (QOPENGLF_APIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)) resolve("glRenderbufferStorageMultisample");
- GenVertexArrays = (void (QOPENGLF_APIENTRYP)(GLsizei, GLuint *)) m_gl.resolve("glGenVertexArrays");
- DeleteVertexArrays = (void (QOPENGLF_APIENTRYP)(GLsizei, const GLuint *)) m_gl.resolve("glDeleteVertexArrays");
- BindVertexArray = (void (QOPENGLF_APIENTRYP)(GLuint)) m_gl.resolve("glBindVertexArray");
- IsVertexArray = (GLboolean (QOPENGLF_APIENTRYP)(GLuint)) m_gl.resolve("glIsVertexArray");
+ GenVertexArrays = (void (QOPENGLF_APIENTRYP)(GLsizei, GLuint *)) resolve("glGenVertexArrays");
+ DeleteVertexArrays = (void (QOPENGLF_APIENTRYP)(GLsizei, const GLuint *)) resolve("glDeleteVertexArrays");
+ BindVertexArray = (void (QOPENGLF_APIENTRYP)(GLuint)) resolve("glBindVertexArray");
+ IsVertexArray = (GLboolean (QOPENGLF_APIENTRYP)(GLuint)) resolve("glIsVertexArray");
- TexImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *)) m_gl.resolve("glTexImage3D");
- TexSubImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)) m_gl.resolve("glTexSubImage3D");
- CompressedTexImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)) m_gl.resolve("glCompressedTexImage3D");
- CompressedTexSubImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)) m_gl.resolve("glCompressedTexSubImage3D");
+ TexImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *)) resolve("glTexImage3D");
+ TexSubImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)) resolve("glTexSubImage3D");
+ CompressedTexImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)) resolve("glCompressedTexImage3D");
+ CompressedTexSubImage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)) resolve("glCompressedTexSubImage3D");
- TexStorage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei)) m_gl.resolve("glTexStorage3D");
- TexStorage2D = (void (QOPENGLF_APIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)) m_gl.resolve("glTexStorage2D");
+ TexStorage3D = (void (QOPENGLF_APIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei)) resolve("glTexStorage3D");
+ TexStorage2D = (void (QOPENGLF_APIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)) resolve("glTexStorage2D");
if (!MapBufferRange || !GenVertexArrays || !TexImage3D || !TexStorage3D)
qFatal("OpenGL ES 3.0 entry points not found");
@@ -3568,7 +3590,7 @@ void QOpenGLExtensions::flushShared()
d->flushIsSufficientToSyncContexts = false; // default to false, not guaranteed by the spec
const char *vendor = (const char *) glGetString(GL_VENDOR);
if (vendor) {
- static const char *flushEnough[] = { "Apple", "ATI", "Intel", "NVIDIA" };
+ static const char *const flushEnough[] = { "Apple", "ATI", "Intel", "NVIDIA" };
for (size_t i = 0; i < sizeof(flushEnough) / sizeof(const char *); ++i) {
if (strstr(vendor, flushEnough[i])) {
d->flushIsSufficientToSyncContexts = true;
diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp
index 51086ffe65..62e016c475 100644
--- a/src/gui/opengl/qopenglpaintdevice.cpp
+++ b/src/gui/opengl/qopenglpaintdevice.cpp
@@ -169,6 +169,10 @@ QOpenGLPaintDevicePrivate::QOpenGLPaintDevicePrivate(const QSize &sz)
{
}
+QOpenGLPaintDevicePrivate::~QOpenGLPaintDevicePrivate()
+{
+}
+
class QOpenGLEngineThreadStorage
{
public:
diff --git a/src/gui/opengl/qopenglpaintdevice_p.h b/src/gui/opengl/qopenglpaintdevice_p.h
index 57d93ee80a..54ea09240d 100644
--- a/src/gui/opengl/qopenglpaintdevice_p.h
+++ b/src/gui/opengl/qopenglpaintdevice_p.h
@@ -56,7 +56,7 @@ class Q_GUI_EXPORT QOpenGLPaintDevicePrivate
{
public:
QOpenGLPaintDevicePrivate(const QSize &size);
- virtual ~QOpenGLPaintDevicePrivate() { }
+ virtual ~QOpenGLPaintDevicePrivate();
static QOpenGLPaintDevicePrivate *get(QOpenGLPaintDevice *dev) { return dev->d_func(); }
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 5bf8387400..670717c5f1 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -999,7 +999,7 @@ bool QBrush::operator==(const QBrush &b) const
*/
QDebug operator<<(QDebug dbg, const QBrush &b)
{
- static const char *BRUSH_STYLES[] = {
+ static const char *const BRUSH_STYLES[] = {
"NoBrush",
"SolidPattern",
"Dense1Pattern",
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index a3b88a50ef..ceb95f5676 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -73,10 +73,11 @@ public:
~QBrush();
QBrush &operator=(const QBrush &brush);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QBrush &operator=(QBrush &&other)
+ inline QBrush &operator=(QBrush &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
- inline void swap(QBrush &other) { qSwap(d, other.d); }
+ inline void swap(QBrush &other) Q_DECL_NOEXCEPT
+ { qSwap(d, other.d); }
operator QVariant() const;
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index b33d7a74fc..f1ceb464c8 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -729,8 +729,8 @@ void QColor::setHsv(int h, int s, int v, int a)
saturation, lightness, and alpha-channel (transparency) components of the
color's HSL value.
- These components can be retrieved individually using the hueHslF(),
- saturationHslF(), lightnessF() and alphaF() functions.
+ These components can be retrieved individually using the hslHueF(),
+ hslSaturationF(), lightnessF() and alphaF() functions.
\sa setHsl()
*/
@@ -759,8 +759,8 @@ void QColor::getHslF(qreal *h, qreal *s, qreal *l, qreal *a) const
saturation, lightness, and alpha-channel (transparency) components of the
color's HSL value.
- These components can be retrieved individually using the hueHsl(),
- saturationHsl(), lightness() and alpha() functions.
+ These components can be retrieved individually using the hslHue(),
+ hslSaturation(), lightness() and alpha() functions.
\sa setHsl()
*/
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index e46e997f1d..7b03cc00ff 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -944,7 +944,7 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP8, convertGrayscale8ToRGB32, convertGrayscale8FromARGB32PM, convertGrayscale8FromRGB32, convertGrayscale8ToRGB64 } // Format_Grayscale8
};
-FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = {
+const FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = {
0, // BPPNone
fetchPixels<QPixelLayout::BPP1MSB>, // BPP1MSB
fetchPixels<QPixelLayout::BPP1LSB>, // BPP1LSB
@@ -954,7 +954,7 @@ FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = {
fetchPixels<QPixelLayout::BPP32> // BPP32
};
-StorePixelsFunc qStorePixels[QPixelLayout::BPPCount] = {
+const StorePixelsFunc qStorePixels[QPixelLayout::BPPCount] = {
0, // BPPNone
storePixels<QPixelLayout::BPP1MSB>, // BPP1MSB
storePixels<QPixelLayout::BPP1LSB>, // BPP1LSB
@@ -966,7 +966,7 @@ StorePixelsFunc qStorePixels[QPixelLayout::BPPCount] = {
typedef uint (QT_FASTCALL *FetchPixelFunc)(const uchar *src, int index);
-FetchPixelFunc qFetchPixel[QPixelLayout::BPPCount] = {
+static const FetchPixelFunc qFetchPixel[QPixelLayout::BPPCount] = {
0, // BPPNone
fetchPixel<QPixelLayout::BPP1MSB>, // BPP1MSB
fetchPixel<QPixelLayout::BPP1LSB>, // BPP1LSB
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index f8865a6f7e..179900ddd2 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -1142,8 +1142,8 @@ typedef const uint *(QT_FASTCALL *FetchPixelsFunc)(uint *buffer, const uchar *sr
typedef void (QT_FASTCALL *StorePixelsFunc)(uchar *dest, const uint *src, int index, int count);
extern QPixelLayout qPixelLayouts[QImage::NImageFormats];
-extern FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount];
-extern StorePixelsFunc qStorePixels[QPixelLayout::BPPCount];
+extern const FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount];
+extern const StorePixelsFunc qStorePixels[QPixelLayout::BPPCount];
diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp
index 5f1b25e189..867c64c5e0 100644
--- a/src/gui/painting/qimagescale.cpp
+++ b/src/gui/painting/qimagescale.cpp
@@ -38,22 +38,6 @@
QT_BEGIN_NAMESPACE
-typedef void (*qt_qimageScaleFunc)(QImageScale::QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow);
-
-static void qt_qimageScaleAARGB(QImageScale::QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow);
-
-static void qt_qimageScaleAARGBA(QImageScale::QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow);
-
-qt_qimageScaleFunc qt_qimageScaleArgb = qt_qimageScaleAARGBA;
-qt_qimageScaleFunc qt_qimageScaleRgb = qt_qimageScaleAARGB;
-
-
/*
* Copyright (C) 2004, 2005 Daniel M. Duley
*
@@ -93,6 +77,8 @@ qt_qimageScaleFunc qt_qimageScaleRgb = qt_qimageScaleAARGB;
*
* Changes include formatting, namespaces and other C++'ings, removal of old
* #ifdef'ed code, and removal of unneeded border calculation code.
+ * Later the code has been refactored and an SSE4.1 optimizated path have been
+ * added instead of the removed MMX assembler.
*
* Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code
* is by Willem Monsuwe <willem@stack.nl>. All other modifications are
@@ -115,21 +101,14 @@ using namespace QImageScale;
// Code ported from Imlib...
//
-// FIXME: replace with qRed, etc... These work on pointers to pixels, not
-// pixel values
-#define A_VAL(p) (qAlpha(*p))
-#define R_VAL(p) (qRed(*p))
-#define G_VAL(p) (qGreen(*p))
-#define B_VAL(p) (qBlue(*p))
-
const unsigned int** QImageScale::qimageCalcYPoints(const unsigned int *src,
- int sw, int sh, int dh)
+ int sw, int sh, int dh)
{
const unsigned int **p;
int j = 0, rv = 0;
qint64 val, inc;
- if(dh < 0){
+ if (dh < 0) {
dh = -dh;
rv = 1;
}
@@ -157,7 +136,7 @@ int* QImageScale::qimageCalcXPoints(int sw, int dw)
int *p, j = 0, rv = 0;
qint64 val, inc;
- if(dw < 0){
+ if (dw < 0) {
dw = -dw;
rv = 1;
}
@@ -178,25 +157,23 @@ int* QImageScale::qimageCalcXPoints(int sw, int dw)
p[dw - i - 1] = tmp;
}
}
- return(p);
+ return p;
}
int* QImageScale::qimageCalcApoints(int s, int d, int up)
{
int *p, j = 0, rv = 0;
- if(d < 0){
+ if (d < 0) {
rv = 1;
d = -d;
}
p = new int[d];
- /* scaling up */
- if(up){
- qint64 val, inc;
-
- val = 0x8000 * s / d - 0x8000;
- inc = (((qint64)s) << 16) / d;
+ if (up) {
+ /* scaling up */
+ qint64 val = 0x8000 * s / d - 0x8000;
+ qint64 inc = (((qint64)s) << 16) / d;
for (int i = 0; i < d; i++) {
int pos = val >> 16;
if (pos < 0)
@@ -207,9 +184,8 @@ int* QImageScale::qimageCalcApoints(int s, int d, int up)
p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00);
val += inc;
}
- }
- /* scaling down */
- else {
+ } else {
+ /* scaling down */
qint64 val = 0;
qint64 inc = (((qint64)s) << 16) / d;
int Cp = (((d << 14) + s - 1) / s);
@@ -220,7 +196,7 @@ int* QImageScale::qimageCalcApoints(int s, int d, int up)
val += inc;
}
}
- if(rv){
+ if (rv) {
int tmp;
for (int i = d / 2; --i >= 0; ) {
tmp = p[i];
@@ -233,7 +209,7 @@ int* QImageScale::qimageCalcApoints(int s, int d, int up)
QImageScaleInfo* QImageScale::qimageFreeScaleInfo(QImageScaleInfo *isi)
{
- if(isi){
+ if (isi) {
delete[] isi->xpoints;
delete[] isi->ypoints;
delete[] isi->xapoints;
@@ -254,28 +230,28 @@ QImageScaleInfo* QImageScale::qimageCalcScaleInfo(const QImage &img,
sch = dh * qlonglong(img.height()) / sh;
isi = new QImageScaleInfo;
- if(!isi)
+ if (!isi)
return 0;
memset(isi, 0, sizeof(QImageScaleInfo));
isi->xup_yup = (qAbs(dw) >= sw) + ((qAbs(dh) >= sh) << 1);
isi->xpoints = qimageCalcXPoints(img.width(), scw);
- if(!isi->xpoints)
- return(qimageFreeScaleInfo(isi));
+ if (!isi->xpoints)
+ return qimageFreeScaleInfo(isi);
isi->ypoints = qimageCalcYPoints((const unsigned int *)img.scanLine(0),
img.bytesPerLine() / 4, img.height(), sch);
if (!isi->ypoints)
- return(qimageFreeScaleInfo(isi));
- if(aa) {
+ return qimageFreeScaleInfo(isi);
+ if (aa) {
isi->xapoints = qimageCalcApoints(img.width(), scw, isi->xup_yup & 1);
- if(!isi->xapoints)
- return(qimageFreeScaleInfo(isi));
+ if (!isi->xapoints)
+ return qimageFreeScaleInfo(isi);
isi->yapoints = qimageCalcApoints(img.height(), sch, isi->xup_yup & 2);
- if(!isi->yapoints)
- return(qimageFreeScaleInfo(isi));
+ if (!isi->yapoints)
+ return qimageFreeScaleInfo(isi);
}
- return(isi);
+ return isi;
}
@@ -349,7 +325,7 @@ static void qt_qimageScaleAARGBA(QImageScaleInfo *isi, unsigned int *dest,
int dh, int dow, int sow)
{
/* scaling up both ways */
- if (isi->xup_yup == 3){
+ if (isi->xup_yup == 3) {
qt_qimageScaleAARGBA_up_xy(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
}
/* if we're scaling down vertically */
@@ -381,46 +357,25 @@ static void qt_qimageScaleAARGBA(QImageScaleInfo *isi, unsigned int *dest,
}
}
-inline static void qt_qimageScaleAARGBA_helper_x(const unsigned int *pix, int xap, int Cx, int &r, int &g, int &b, int &a)
+inline static void qt_qimageScaleAARGBA_helper(const unsigned int *pix, int xyap, int Cxy, int step, int &r, int &g, int &b, int &a)
{
- r = R_VAL(pix) * xap;
- g = G_VAL(pix) * xap;
- b = B_VAL(pix) * xap;
- a = A_VAL(pix) * xap;
+ r = qRed(*pix) * xyap;
+ g = qGreen(*pix) * xyap;
+ b = qBlue(*pix) * xyap;
+ a = qAlpha(*pix) * xyap;
int j;
- for (j = (1 << 14) - xap; j > Cx; j -= Cx ){
- pix++;
- r += R_VAL(pix) * Cx;
- g += G_VAL(pix) * Cx;
- b += B_VAL(pix) * Cx;
- a += A_VAL(pix) * Cx;
- }
- pix++;
- r += R_VAL(pix) * j;
- g += G_VAL(pix) * j;
- b += B_VAL(pix) * j;
- a += A_VAL(pix) * j;
-}
-
-inline static void qt_qimageScaleAARGBA_helper_y(const unsigned int *pix, int yap, int Cy, int sow, int &r, int &g, int &b, int &a)
-{
- r = R_VAL(pix) * yap;
- g = G_VAL(pix) * yap;
- b = B_VAL(pix) * yap;
- a = A_VAL(pix) * yap;
- int j;
- for (j = (1 << 14) - yap; j > Cy; j -= Cy ){
- pix += sow;
- r += R_VAL(pix) * Cy;
- g += G_VAL(pix) * Cy;
- b += B_VAL(pix) * Cy;
- a += A_VAL(pix) * Cy;
- }
- pix += sow;
- r += R_VAL(pix) * j;
- g += G_VAL(pix) * j;
- b += B_VAL(pix) * j;
- a += A_VAL(pix) * j;
+ for (j = (1 << 14) - xyap; j > Cxy; j -= Cxy) {
+ pix += step;
+ r += qRed(*pix) * Cxy;
+ g += qGreen(*pix) * Cxy;
+ b += qBlue(*pix) * Cxy;
+ a += qAlpha(*pix) * Cxy;
+ }
+ pix += step;
+ r += qRed(*pix) * j;
+ g += qGreen(*pix) * j;
+ b += qBlue(*pix) * j;
+ a += qAlpha(*pix) * j;
}
static void qt_qimageScaleAARGBA_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest,
@@ -443,12 +398,12 @@ static void qt_qimageScaleAARGBA_up_x_down_y(QImageScaleInfo *isi, unsigned int
for (int x = dxx; x < end; x++) {
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int r, g, b, a;
- qt_qimageScaleAARGBA_helper_y(sptr, yap, Cy, sow, r, g, b, a);
+ qt_qimageScaleAARGBA_helper(sptr, yap, Cy, sow, r, g, b, a);
int xap = xapoints[x];
if (xap > 0) {
int rr, gg, bb, aa;
- qt_qimageScaleAARGBA_helper_y(sptr + 1, yap, Cy, sow, rr, gg, bb, aa);
+ qt_qimageScaleAARGBA_helper(sptr + 1, yap, Cy, sow, rr, gg, bb, aa);
r = r * (256 - xap);
g = g * (256 - xap);
@@ -484,12 +439,12 @@ static void qt_qimageScaleAARGBA_down_x_up_y(QImageScaleInfo *isi, unsigned int
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int r, g, b, a;
- qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, r, g, b, a);
+ qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, r, g, b, a);
int yap = yapoints[dyy + y];
if (yap > 0) {
int rr, gg, bb, aa;
- qt_qimageScaleAARGBA_helper_x(sptr + sow, xap, Cx, rr, gg, bb, aa);
+ qt_qimageScaleAARGBA_helper(sptr + sow, xap, Cx, 1, rr, gg, bb, aa);
r = r * (256 - yap);
g = g * (256 - yap);
@@ -528,7 +483,7 @@ static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *des
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int rx, gx, bx, ax;
- qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, rx, gx, bx, ax);
+ qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, rx, gx, bx, ax);
int r = ((rx>>4) * yap);
int g = ((gx>>4) * yap);
@@ -538,14 +493,14 @@ static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *des
int j;
for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
sptr += sow;
- qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, rx, gx, bx, ax);
+ qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, rx, gx, bx, ax);
r += ((rx>>4) * Cy);
g += ((gx>>4) * Cy);
b += ((bx>>4) * Cy);
a += ((ax>>4) * Cy);
}
sptr += sow;
- qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, rx, gx, bx, ax);
+ qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, rx, gx, bx, ax);
r += ((rx>>4) * j);
g += ((gx>>4) * j);
@@ -609,40 +564,22 @@ static void qt_qimageScaleAARGB(QImageScaleInfo *isi, unsigned int *dest,
}
-inline static void qt_qimageScaleAARGB_helper_x(const unsigned int *pix, int xap, int Cx, int &r, int &g, int &b)
+inline static void qt_qimageScaleAARGB_helper(const unsigned int *pix, int xyap, int Cxy, int step, int &r, int &g, int &b)
{
- r = R_VAL(pix) * xap;
- g = G_VAL(pix) * xap;
- b = B_VAL(pix) * xap;
+ r = qRed(*pix) * xyap;
+ g = qGreen(*pix) * xyap;
+ b = qBlue(*pix) * xyap;
int j;
- for (j = (1 << 14) - xap; j > Cx; j -= Cx ){
- pix++;
- r += R_VAL(pix) * Cx;
- g += G_VAL(pix) * Cx;
- b += B_VAL(pix) * Cx;
- }
- pix++;
- r += R_VAL(pix) * j;
- g += G_VAL(pix) * j;
- b += B_VAL(pix) * j;
-}
-
-inline static void qt_qimageScaleAARGB_helper_y(const unsigned int *pix, int yap, int Cy, int sow, int &r, int &g, int &b)
-{
- r = R_VAL(pix) * yap;
- g = G_VAL(pix) * yap;
- b = B_VAL(pix) * yap;
- int j;
- for (j = (1 << 14) - yap; j > Cy; j -= Cy ){
- pix += sow;
- r += R_VAL(pix) * Cy;
- g += G_VAL(pix) * Cy;
- b += B_VAL(pix) * Cy;
- }
- pix += sow;
- r += R_VAL(pix) * j;
- g += G_VAL(pix) * j;
- b += B_VAL(pix) * j;
+ for (j = (1 << 14) - xyap; j > Cxy; j -= Cxy) {
+ pix += step;
+ r += qRed(*pix) * Cxy;
+ g += qGreen(*pix) * Cxy;
+ b += qBlue(*pix) * Cxy;
+ }
+ pix += step;
+ r += qRed(*pix) * j;
+ g += qGreen(*pix) * j;
+ b += qBlue(*pix) * j;
}
static void qt_qimageScaleAARGB_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest,
@@ -665,12 +602,12 @@ static void qt_qimageScaleAARGB_up_x_down_y(QImageScaleInfo *isi, unsigned int *
for (int x = dxx; x < end; x++) {
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int r, g, b;
- qt_qimageScaleAARGB_helper_y(sptr, yap, Cy, sow, r, g, b);
+ qt_qimageScaleAARGB_helper(sptr, yap, Cy, sow, r, g, b);
int xap = xapoints[x];
if (xap > 0) {
int rr, bb, gg;
- qt_qimageScaleAARGB_helper_y(sptr + 1, yap, Cy, sow, rr, gg, bb);
+ qt_qimageScaleAARGB_helper(sptr + 1, yap, Cy, sow, rr, gg, bb);
r = r * (256 - xap);
g = g * (256 - xap);
@@ -704,12 +641,12 @@ static void qt_qimageScaleAARGB_down_x_up_y(QImageScaleInfo *isi, unsigned int *
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int r, g, b;
- qt_qimageScaleAARGB_helper_x(sptr, xap, Cx, r, g, b);
+ qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, r, g, b);
int yap = yapoints[dyy + y];
if (yap > 0) {
int rr, bb, gg;
- qt_qimageScaleAARGB_helper_x(sptr + sow, xap, Cx, rr, gg, bb);
+ qt_qimageScaleAARGB_helper(sptr + sow, xap, Cx, 1, rr, gg, bb);
r = r * (256 - yap);
g = g * (256 - yap);
@@ -745,7 +682,7 @@ static void qt_qimageScaleAARGB_down_xy(QImageScaleInfo *isi, unsigned int *dest
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int rx, gx, bx;
- qt_qimageScaleAARGB_helper_x(sptr, xap, Cx, rx, gx, bx);
+ qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, rx, gx, bx);
int r = (rx >> 4) * yap;
int g = (gx >> 4) * yap;
@@ -754,14 +691,14 @@ static void qt_qimageScaleAARGB_down_xy(QImageScaleInfo *isi, unsigned int *dest
int j;
for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
sptr += sow;
- qt_qimageScaleAARGB_helper_x(sptr, xap, Cx, rx, gx, bx);
+ qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, rx, gx, bx);
r += (rx >> 4) * Cy;
g += (gx >> 4) * Cy;
b += (bx >> 4) * Cy;
}
sptr += sow;
- qt_qimageScaleAARGB_helper_x(sptr, xap, Cx, rx, gx, bx);
+ qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, rx, gx, bx);
r += (rx >> 4) * j;
g += (gx >> 4) * j;
@@ -794,11 +731,11 @@ QImage qSmoothScaleImage(const QImage &src, int dw, int dh)
}
if (src.hasAlphaChannel())
- qt_qimageScaleArgb(scaleinfo, (unsigned int *)buffer.scanLine(0),
- 0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4);
+ qt_qimageScaleAARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0),
+ 0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4);
else
- qt_qimageScaleRgb(scaleinfo, (unsigned int *)buffer.scanLine(0),
- 0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4);
+ qt_qimageScaleAARGB(scaleinfo, (unsigned int *)buffer.scanLine(0),
+ 0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4);
qimageFreeScaleInfo(scaleinfo);
return buffer;
diff --git a/src/gui/painting/qimagescale_sse4.cpp b/src/gui/painting/qimagescale_sse4.cpp
index 565ea4daa1..303e0fd980 100644
--- a/src/gui/painting/qimagescale_sse4.cpp
+++ b/src/gui/painting/qimagescale_sse4.cpp
@@ -41,33 +41,17 @@ QT_BEGIN_NAMESPACE
using namespace QImageScale;
-inline static __m128i qt_qimageScaleAARGBA_helper_x(const unsigned int *pix, int xap, int Cx, const __m128i vxap, const __m128i vCx)
+inline static __m128i qt_qimageScaleAARGBA_helper(const unsigned int *pix, int xyap, int Cxy, int step, const __m128i vxyap, const __m128i vCxy)
{
__m128i vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
- __m128i vx = _mm_mullo_epi32(vpix, vxap);
+ __m128i vx = _mm_mullo_epi32(vpix, vxyap);
int i;
- for (i = (1 << 14) - xap; i > Cx; i -= Cx) {
- pix++;
+ for (i = (1 << 14) - xyap; i > Cxy; i -= Cxy) {
+ pix += step;
vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
- vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, vCx));
+ vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, vCxy));
}
- pix++;
- vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
- vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, _mm_set1_epi32(i)));
- return vx;
-}
-
-inline static __m128i qt_qimageScaleAARGBA_helper_y(const unsigned int *pix, int yap, int Cy, int sow, const __m128i vyap, const __m128i vCy)
-{
- __m128i vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
- __m128i vx = _mm_mullo_epi32(vpix, vyap);
- int i;
- for (i = (1 << 14) - yap; i > Cy; i -= Cy) {
- pix += sow;
- vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
- vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, vCy));
- }
- pix += sow;
+ pix += step;
vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, _mm_set1_epi32(i)));
return vx;
@@ -97,13 +81,13 @@ void qt_qimageScaleAARGBA_up_x_down_y_sse4(QImageScaleInfo *isi, unsigned int *d
unsigned int *dptr = dest + dx + ((y + dy) * dow);
for (int x = dxx; x < end; x++) {
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
- __m128i vx = qt_qimageScaleAARGBA_helper_y(sptr, yap, Cy, sow, vyap, vCy);
+ __m128i vx = qt_qimageScaleAARGBA_helper(sptr, yap, Cy, sow, vyap, vCy);
int xap = xapoints[x];
if (xap > 0) {
const __m128i vxap = _mm_set1_epi32(xap);
const __m128i vinvxap = _mm_sub_epi32(v256, vxap);
- __m128i vr = qt_qimageScaleAARGBA_helper_y(sptr + 1, yap, Cy, sow, vyap, vCy);
+ __m128i vr = qt_qimageScaleAARGBA_helper(sptr + 1, yap, Cy, sow, vyap, vCy);
vx = _mm_mullo_epi32(vx, vinvxap);
vr = _mm_mullo_epi32(vr, vxap);
@@ -145,13 +129,13 @@ void qt_qimageScaleAARGBA_down_x_up_y_sse4(QImageScaleInfo *isi, unsigned int *d
const __m128i vxap = _mm_set1_epi32(xap);
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
- __m128i vx = qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, vxap, vCx);
+ __m128i vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);
int yap = yapoints[dyy + y];
if (yap > 0) {
const __m128i vyap = _mm_set1_epi32(yap);
const __m128i vinvyap = _mm_sub_epi32(v256, vyap);
- __m128i vr = qt_qimageScaleAARGBA_helper_x(sptr + sow, xap, Cx, vxap, vCx);
+ __m128i vr = qt_qimageScaleAARGBA_helper(sptr + sow, xap, Cx, 1, vxap, vCx);
vx = _mm_mullo_epi32(vx, vinvyap);
vr = _mm_mullo_epi32(vr, vyap);
@@ -194,17 +178,17 @@ void qt_qimageScaleAARGBA_down_xy_sse4(QImageScaleInfo *isi, unsigned int *dest,
const __m128i vxap = _mm_set1_epi32(xap);
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
- __m128i vx = qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, vxap, vCx);
+ __m128i vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);
__m128i vr = _mm_mullo_epi32(_mm_srli_epi32(vx, 4), vyap);
int j;
for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
sptr += sow;
- vx = qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, vxap, vCx);
+ vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);
vr = _mm_add_epi32(vr, _mm_mullo_epi32(_mm_srli_epi32(vx, 4), vCy));
}
sptr += sow;
- vx = qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, vxap, vCx);
+ vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);
vr = _mm_add_epi32(vr, _mm_mullo_epi32(_mm_srli_epi32(vx, 4), _mm_set1_epi32(j)));
vr = _mm_srli_epi32(vr, 24);
diff --git a/src/gui/painting/qpagedpaintdevice.cpp b/src/gui/painting/qpagedpaintdevice.cpp
index 3adc5e9411..547cedf51f 100644
--- a/src/gui/painting/qpagedpaintdevice.cpp
+++ b/src/gui/painting/qpagedpaintdevice.cpp
@@ -36,6 +36,10 @@
QT_BEGIN_NAMESPACE
+QPagedPaintDevicePrivate::~QPagedPaintDevicePrivate()
+{
+}
+
/*!
\class QPagedPaintDevice
\inmodule QtGui
diff --git a/src/gui/painting/qpagedpaintdevice_p.h b/src/gui/painting/qpagedpaintdevice_p.h
index 62f69747db..30b1c0a1e6 100644
--- a/src/gui/painting/qpagedpaintdevice_p.h
+++ b/src/gui/painting/qpagedpaintdevice_p.h
@@ -61,9 +61,7 @@ public:
{
}
- virtual ~QPagedPaintDevicePrivate()
- {
- }
+ virtual ~QPagedPaintDevicePrivate();
// ### Qt6 Remove these and make public class methods virtual
virtual bool setPageLayout(const QPageLayout &newPageLayout)
diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp
index 4ee3d91ea3..27d4bbcfd7 100644
--- a/src/gui/painting/qpaintdevice.cpp
+++ b/src/gui/painting/qpaintdevice.cpp
@@ -35,7 +35,7 @@
QT_BEGIN_NAMESPACE
-QPaintDevice::QPaintDevice()
+QPaintDevice::QPaintDevice() Q_DECL_NOEXCEPT
{
reserved = 0;
painters = 0;
diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h
index c4ef9db766..b699956e99 100644
--- a/src/gui/painting/qpaintdevice.h
+++ b/src/gui/painting/qpaintdevice.h
@@ -85,7 +85,7 @@ public:
// ### and need to access this constant. Add it here as a static constant for now
static qreal devicePixelRatioFScale;
protected:
- QPaintDevice();
+ QPaintDevice() Q_DECL_NOEXCEPT;
virtual int metric(PaintDeviceMetric metric) const;
virtual void initPainter(QPainter *painter) const;
virtual QPaintDevice *redirected(QPoint *offset) const;
diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp
index 6271c8f9e6..bf1f31a85b 100644
--- a/src/gui/painting/qpaintengine.cpp
+++ b/src/gui/painting/qpaintengine.cpp
@@ -968,6 +968,10 @@ QRect QPaintEngine::systemRect() const
return d_func()->systemRect;
}
+QPaintEnginePrivate::~QPaintEnginePrivate()
+{
+}
+
void QPaintEnginePrivate::drawBoxTextItem(const QPointF &p, const QTextItemInt &ti)
{
if (!ti.glyphs.numGlyphs)
diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h
index c58662ede4..918c98997b 100644
--- a/src/gui/painting/qpaintengine_p.h
+++ b/src/gui/painting/qpaintengine_p.h
@@ -60,7 +60,8 @@ class Q_GUI_EXPORT QPaintEnginePrivate
public:
QPaintEnginePrivate() : pdev(0), q_ptr(0), currentClipDevice(0), hasSystemTransform(0),
hasSystemViewport(0) {}
- virtual ~QPaintEnginePrivate() { }
+ virtual ~QPaintEnginePrivate();
+
QPaintDevice *pdev;
QPaintEngine *q_ptr;
QRegion systemClip;
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 0f80cd18a0..f00bc8d9df 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -238,7 +238,7 @@ bool QPaintEngineExPrivate::hasClipOperations() const
*
*/
-static QPainterPath::ElementType qpaintengineex_ellipse_types[] = {
+static const QPainterPath::ElementType qpaintengineex_ellipse_types[] = {
QPainterPath::MoveToElement,
QPainterPath::CurveToElement,
QPainterPath::CurveToDataElement,
@@ -257,7 +257,7 @@ static QPainterPath::ElementType qpaintengineex_ellipse_types[] = {
QPainterPath::CurveToDataElement
};
-static QPainterPath::ElementType qpaintengineex_line_types_16[] = {
+static const QPainterPath::ElementType qpaintengineex_line_types_16[] = {
QPainterPath::MoveToElement, QPainterPath::LineToElement,
QPainterPath::MoveToElement, QPainterPath::LineToElement,
QPainterPath::MoveToElement, QPainterPath::LineToElement,
@@ -276,7 +276,7 @@ static QPainterPath::ElementType qpaintengineex_line_types_16[] = {
QPainterPath::MoveToElement, QPainterPath::LineToElement
};
-static QPainterPath::ElementType qpaintengineex_rect4_types_32[] = {
+static const QPainterPath::ElementType qpaintengineex_rect4_types_32[] = {
QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 1
QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 2
QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 3
@@ -312,7 +312,7 @@ static QPainterPath::ElementType qpaintengineex_rect4_types_32[] = {
};
-static QPainterPath::ElementType qpaintengineex_roundedrect_types[] = {
+static const QPainterPath::ElementType qpaintengineex_roundedrect_types[] = {
QPainterPath::MoveToElement,
QPainterPath::LineToElement,
QPainterPath::CurveToElement,
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index d3e8b542f0..99a9f823a1 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -7441,7 +7441,7 @@ start_lengthVariant:
}
}
- QList<QTextLayout::FormatRange> underlineFormats;
+ QVector<QTextLayout::FormatRange> underlineFormats;
int length = offset - old_offset;
if ((hidemnmemonic || showmnemonic) && maxUnderlines > 0) {
QChar *cout = text.data() + old_offset;
@@ -7515,7 +7515,7 @@ start_lengthVariant:
engine.forceJustification = true;
QTextLayout textLayout(&engine);
textLayout.setCacheEnabled(true);
- textLayout.setAdditionalFormats(underlineFormats);
+ textLayout.setFormats(underlineFormats);
if (finalText.isEmpty()) {
height = fm.height();
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index e3c6eabbc3..e2f267d7ee 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -521,7 +521,7 @@ void QPainterPath::setElementPositionAt(int i, qreal x, qreal y)
/*!
Constructs an empty QPainterPath object.
*/
-QPainterPath::QPainterPath()
+QPainterPath::QPainterPath() Q_DECL_NOEXCEPT
: d_ptr(0)
{
}
@@ -3057,20 +3057,19 @@ qreal QPainterPath::slopeAtPercent(qreal t) const
//tangent line
qreal slope = 0;
-#define SIGN(x) ((x < 0)?-1:1)
if (m1)
slope = m2/m1;
else {
- //windows doesn't define INFINITY :(
-#ifdef INFINITY
- slope = INFINITY*SIGN(m2);
-#else
- if (sizeof(qreal) == sizeof(double)) {
- return 1.79769313486231570e+308;
+ if (std::numeric_limits<qreal>::has_infinity) {
+ slope = (m2 < 0) ? -std::numeric_limits<qreal>::infinity()
+ : std::numeric_limits<qreal>::infinity();
} else {
- return ((qreal)3.40282346638528860e+38);
+ if (sizeof(qreal) == sizeof(double)) {
+ return 1.79769313486231570e+308;
+ } else {
+ return ((qreal)3.40282346638528860e+38);
+ }
}
-#endif
}
return slope;
diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h
index eb32782a96..4a7bd98234 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -81,16 +81,16 @@ public:
inline bool operator!=(const Element &e) const { return !operator==(e); }
};
- QPainterPath();
+ QPainterPath() Q_DECL_NOEXCEPT;
explicit QPainterPath(const QPointF &startPoint);
QPainterPath(const QPainterPath &other);
QPainterPath &operator=(const QPainterPath &other);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QPainterPath &operator=(QPainterPath &&other)
+ inline QPainterPath &operator=(QPainterPath &&other) Q_DECL_NOEXCEPT
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
~QPainterPath();
- inline void swap(QPainterPath &other) { d_ptr.swap(other.d_ptr); }
+ inline void swap(QPainterPath &other) Q_DECL_NOEXCEPT { d_ptr.swap(other.d_ptr); }
void closeSubpath();
@@ -147,8 +147,8 @@ public:
void translate(qreal dx, qreal dy);
inline void translate(const QPointF &offset);
- QPainterPath translated(qreal dx, qreal dy) const;
- inline QPainterPath translated(const QPointF &offset) const;
+ QPainterPath translated(qreal dx, qreal dy) const Q_REQUIRED_RESULT;
+ inline QPainterPath translated(const QPointF &offset) const Q_REQUIRED_RESULT;
QRectF boundingRect() const;
QRectF controlPointRect() const;
@@ -158,7 +158,7 @@ public:
bool isEmpty() const;
- QPainterPath toReversed() const;
+ QPainterPath toReversed() const Q_REQUIRED_RESULT;
QList<QPolygonF> toSubpathPolygons(const QMatrix &matrix = QMatrix()) const;
QList<QPolygonF> toFillPolygons(const QMatrix &matrix = QMatrix()) const;
QPolygonF toFillPolygon(const QMatrix &matrix = QMatrix()) const;
@@ -178,12 +178,12 @@ public:
bool intersects(const QPainterPath &p) const;
bool contains(const QPainterPath &p) const;
- QPainterPath united(const QPainterPath &r) const;
- QPainterPath intersected(const QPainterPath &r) const;
- QPainterPath subtracted(const QPainterPath &r) const;
- QPainterPath subtractedInverted(const QPainterPath &r) const;
+ QPainterPath united(const QPainterPath &r) const Q_REQUIRED_RESULT;
+ QPainterPath intersected(const QPainterPath &r) const Q_REQUIRED_RESULT;
+ QPainterPath subtracted(const QPainterPath &r) const Q_REQUIRED_RESULT;
+ QPainterPath subtractedInverted(const QPainterPath &r) const Q_REQUIRED_RESULT;
- QPainterPath simplified() const;
+ QPainterPath simplified() const Q_REQUIRED_RESULT;
bool operator==(const QPainterPath &other) const;
bool operator!=(const QPainterPath &other) const;
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 9b1f5e334a..011094b56b 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -384,7 +384,7 @@ QByteArray QPdf::generateDashes(const QPen &pen)
-static const char* pattern_for_brush[] = {
+static const char* const pattern_for_brush[] = {
0, // NoBrush
0, // SolidPattern
"0 J\n"
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index 24ea3f4cdd..62492980de 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -83,9 +83,10 @@ public:
struct QBackingstoreTextureInfo
{
- QWidget *widget; // may be null
+ void *source; // may be null
GLuint textureId;
QRect rect;
+ QRect clipRect;
QPlatformTextureList::Flags flags;
};
@@ -124,10 +125,10 @@ GLuint QPlatformTextureList::textureId(int index) const
return d->textures.at(index).textureId;
}
-QWidget *QPlatformTextureList::widget(int index)
+void *QPlatformTextureList::source(int index)
{
Q_D(const QPlatformTextureList);
- return d->textures.at(index).widget;
+ return d->textures.at(index).source;
}
QPlatformTextureList::Flags QPlatformTextureList::flags(int index) const
@@ -142,6 +143,12 @@ QRect QPlatformTextureList::geometry(int index) const
return d->textures.at(index).rect;
}
+QRect QPlatformTextureList::clipRect(int index) const
+{
+ Q_D(const QPlatformTextureList);
+ return d->textures.at(index).clipRect;
+}
+
void QPlatformTextureList::lock(bool on)
{
Q_D(QPlatformTextureList);
@@ -157,13 +164,15 @@ bool QPlatformTextureList::isLocked() const
return d->locked;
}
-void QPlatformTextureList::appendTexture(QWidget *widget, GLuint textureId, const QRect &geometry, Flags flags)
+void QPlatformTextureList::appendTexture(void *source, GLuint textureId, const QRect &geometry,
+ const QRect &clipRect, Flags flags)
{
Q_D(QPlatformTextureList);
QBackingstoreTextureInfo bi;
- bi.widget = widget;
+ bi.source = source;
bi.textureId = textureId;
bi.rect = geometry;
+ bi.clipRect = clipRect;
bi.flags = flags;
d->textures.append(bi);
}
@@ -198,7 +207,7 @@ void QPlatformTextureList::clear()
#ifndef QT_NO_OPENGL
-static QRect deviceRect(const QRect &rect, QWindow *window)
+static inline QRect deviceRect(const QRect &rect, QWindow *window)
{
QRect deviceRect(rect.topLeft() * window->devicePixelRatio(),
rect.size() * window->devicePixelRatio());
@@ -219,6 +228,32 @@ static QRegion deviceRegion(const QRegion &region, QWindow *window)
return deviceRegion;
}
+static inline QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
+{
+ return QRect(topLeftRect.x(), windowHeight - topLeftRect.bottomRight().y() - 1,
+ topLeftRect.width(), topLeftRect.height());
+}
+
+static void blit(const QPlatformTextureList *textures, int idx, QWindow *window, const QRect &deviceWindowRect,
+ QOpenGLTextureBlitter *blitter)
+{
+ const QRect rectInWindow = textures->geometry(idx);
+ QRect clipRect = textures->clipRect(idx);
+ if (clipRect.isEmpty())
+ clipRect = QRect(QPoint(0, 0), rectInWindow.size());
+ const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());
+ const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());
+
+ const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(deviceRect(clippedRectInWindow, window),
+ deviceWindowRect);
+
+ const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(deviceRect(srcRect, window),
+ deviceRect(rectInWindow, window).size(),
+ QOpenGLTextureBlitter::OriginBottomLeft);
+
+ blitter->blit(textures->textureId(idx), target, source);
+}
+
/*!
Flushes the given \a region from the specified \a window onto the
screen, and composes it with the specified \a textures.
@@ -254,15 +289,12 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
d_ptr->blitter->bind();
- QRect windowRect(QPoint(), window->size() * window->devicePixelRatio());
+ const QRect deviceWindowRect = deviceRect(QRect(QPoint(), window->size()), window);
// Textures for renderToTexture widgets.
for (int i = 0; i < textures->count(); ++i) {
- if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
- QRect targetRect = deviceRect(textures->geometry(i), window);
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, windowRect);
- d_ptr->blitter->blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft);
- }
+ if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop))
+ blit(textures, i, window, deviceWindowRect, d_ptr->blitter);
}
funcs->glEnable(GL_BLEND);
@@ -272,6 +304,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
// semi-transparency even when it is not wanted.
funcs->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
+ // Backingstore texture with the normal widgets.
GLuint textureId = 0;
QOpenGLTextureBlitter::Origin origin = QOpenGLTextureBlitter::OriginTopLeft;
if (QPlatformGraphicsBuffer *graphicsBuffer = this->graphicsBuffer()) {
@@ -307,12 +340,15 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
origin = QOpenGLTextureBlitter::OriginBottomLeft;
textureId = d_ptr->textureId;
} else {
- // Backingstore texture with the normal widgets.
- textureId = toTexture(deviceRegion(region, window), &d_ptr->textureSize, &d_ptr->needsSwizzle);
+ TextureFlags flags = 0;
+ textureId = toTexture(deviceRegion(region, window), &d_ptr->textureSize, &flags);
+ d_ptr->needsSwizzle = (flags & TextureSwizzle) != 0;
+ if (flags & TextureFlip)
+ origin = QOpenGLTextureBlitter::OriginBottomLeft;
}
if (textureId) {
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(), d_ptr->textureSize), windowRect);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(), d_ptr->textureSize), deviceWindowRect);
if (d_ptr->needsSwizzle)
d_ptr->blitter->setSwizzleRB(true);
d_ptr->blitter->blit(textureId, target, origin);
@@ -322,11 +358,8 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
// Textures for renderToTexture widgets that have WA_AlwaysStackOnTop set.
for (int i = 0; i < textures->count(); ++i) {
- if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
- QRect targetRect = deviceRect(textures->geometry(i), window);
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, windowRect);
- d_ptr->blitter->blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft);
- }
+ if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop))
+ blit(textures, i, window, deviceWindowRect, d_ptr->blitter);
}
funcs->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@@ -354,43 +387,55 @@ QImage QPlatformBackingStore::toImage() const
backingstore as an OpenGL texture. \a dirtyRegion is the part of the
backingstore which may have changed since the last call to this function. The
caller of this function must ensure that there is a current context.
+
The size of the texture is returned in \a textureSize.
The ownership of the texture is not transferred. The caller must not store
the return value between calls, but instead call this function before each use.
- The default implementation returns a cached texture if \a dirtyRegion is
- empty and the window has not been resized, otherwise it retrieves the
- content using toImage() and performs a texture upload.
+ The default implementation returns a cached texture if \a dirtyRegion is empty and
+ \a textureSize matches the backingstore size, otherwise it retrieves the content using
+ toImage() and performs a texture upload. This works only if the value of \a textureSize
+ is preserved between the calls to this function.
+
+ If the red and blue components have to swapped, \a flags will be set to include \c
+ TextureSwizzle. This allows creating textures from images in formats like
+ QImage::Format_RGB32 without any further image conversion. Instead, the swizzling will
+ be done in the shaders when performing composition. Other formats, that do not need
+ such swizzling due to being already byte ordered RGBA, for example
+ QImage::Format_RGBA8888, must result in having \a needsSwizzle set to false.
- If the red and blue components have to swapped, \a needsSwizzle will be set to \c true.
- This allows creating textures from images in formats like QImage::Format_RGB32 without
- any further image conversion. Instead, the swizzling will be done in the shaders when
- performing composition. Other formats, that do not need such swizzling due to being
- already byte ordered RGBA, for example QImage::Format_RGBA8888, must result in having \a
- needsSwizzle set to false.
+ If the image has to be flipped (e.g. because the texture is attached to an FBO), \a
+ flags will be set to include \c TextureFlip.
*/
-GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize, bool *needsSwizzle) const
+GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const
{
+ Q_ASSERT(textureSize);
+ Q_ASSERT(flags);
+
QImage image = toImage();
QSize imageSize = image.size();
- if (imageSize.isEmpty())
+
+ *flags = 0;
+ if (image.format() == QImage::Format_RGB32)
+ *flags |= TextureSwizzle;
+
+ if (imageSize.isEmpty()) {
+ *textureSize = imageSize;
return 0;
+ }
- bool resized = d_ptr->textureSize != imageSize;
+ // Must rely on the input only, not d_ptr.
+ // With the default composeAndFlush() textureSize is &d_ptr->textureSize.
+ bool resized = *textureSize != imageSize;
if (dirtyRegion.isEmpty() && !resized)
return d_ptr->textureId;
+ *textureSize = imageSize;
+
// Fast path for RGB32 and RGBA8888, convert everything else to RGBA8888.
- if (image.format() == QImage::Format_RGB32) {
- if (needsSwizzle)
- *needsSwizzle = true;
- } else {
- if (needsSwizzle)
- *needsSwizzle = false;
- if (image.format() != QImage::Format_RGBA8888)
- image = image.convertToFormat(QImage::Format_RGBA8888);
- }
+ if (image.format() != QImage::Format_RGB32 && image.format() != QImage::Format_RGBA8888)
+ image = image.convertToFormat(QImage::Format_RGBA8888);
QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
@@ -412,8 +457,6 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu
funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageSize.width(), imageSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE,
const_cast<uchar*>(image.constBits()));
- if (textureSize)
- *textureSize = imageSize;
} else {
funcs->glBindTexture(GL_TEXTURE_2D, d_ptr->textureId);
QRect imageRect = image.rect();
diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h
index df98ebf51b..eac97e9cf6 100644
--- a/src/gui/painting/qplatformbackingstore.h
+++ b/src/gui/painting/qplatformbackingstore.h
@@ -82,12 +82,14 @@ public:
bool isEmpty() const { return count() == 0; }
GLuint textureId(int index) const;
QRect geometry(int index) const;
- QWidget *widget(int index);
+ QRect clipRect(int index) const;
+ void *source(int index);
Flags flags(int index) const;
void lock(bool on);
bool isLocked() const;
- void appendTexture(QWidget *widget, GLuint textureId, const QRect &geometry, Flags flags = 0);
+ void appendTexture(void *source, GLuint textureId, const QRect &geometry,
+ const QRect &clipRect = QRect(), Flags flags = 0);
void clear();
Q_SIGNALS:
@@ -114,7 +116,12 @@ public:
QPlatformTextureList *textures, QOpenGLContext *context,
bool translucentBackground);
virtual QImage toImage() const;
- virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, bool *needsSwizzle) const;
+ enum TextureFlag {
+ TextureSwizzle = 0x01,
+ TextureFlip = 0x02
+ };
+ Q_DECLARE_FLAGS(TextureFlags, TextureFlag)
+ virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const;
#endif
virtual QPlatformGraphicsBuffer *graphicsBuffer() const;
@@ -130,6 +137,10 @@ private:
QPlatformBackingStorePrivate *d_ptr;
};
+#ifndef QT_NO_OPENGL
+Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformBackingStore::TextureFlags)
+#endif
+
QT_END_NAMESPACE
#endif // QPLATFORMBACKINGSTORE_H
diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h
index ee7d4d31ad..1549ebe2b5 100644
--- a/src/gui/painting/qpolygon.h
+++ b/src/gui/painting/qpolygon.h
@@ -138,7 +138,7 @@ public:
void translate(const QPointF &offset);
inline QPolygonF translated(qreal dx, qreal dy) const;
- QPolygonF translated(const QPointF &offset) const;
+ QPolygonF translated(const QPointF &offset) const Q_REQUIRED_RESULT;
QPolygon toPolygon() const;
@@ -148,9 +148,9 @@ public:
bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const;
- QPolygonF united(const QPolygonF &r) const;
- QPolygonF intersected(const QPolygonF &r) const;
- QPolygonF subtracted(const QPolygonF &r) const;
+ QPolygonF united(const QPolygonF &r) const Q_REQUIRED_RESULT;
+ QPolygonF intersected(const QPolygonF &r) const Q_REQUIRED_RESULT;
+ QPolygonF subtracted(const QPolygonF &r) const Q_REQUIRED_RESULT;
};
inline QPolygonF::QPolygonF(int asize) : QVector<QPointF>(asize) {}
diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h
index bab07b5a5d..ab2404e887 100644
--- a/src/gui/painting/qregion.h
+++ b/src/gui/painting/qregion.h
@@ -66,10 +66,10 @@ public:
~QRegion();
QRegion &operator=(const QRegion &);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QRegion &operator=(QRegion &&other)
+ inline QRegion &operator=(QRegion &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
- inline void swap(QRegion &other) { qSwap(d, other.d); }
+ inline void swap(QRegion &other) Q_DECL_NOEXCEPT { qSwap(d, other.d); }
bool isEmpty() const;
bool isNull() const;
diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h
index eda65b8e2f..f967c091df 100644
--- a/src/gui/painting/qstroker_p.h
+++ b/src/gui/painting/qstroker_p.h
@@ -201,7 +201,7 @@ public:
QStroker();
~QStroker();
- void setStrokeWidth(qfixed width) { m_strokeWidth = width; }
+ void setStrokeWidth(qfixed width) { m_strokeWidth = width; m_curveThreshold = width >= 1 ? 1.0/width : 0.5;}
qfixed strokeWidth() const { return m_strokeWidth; }
void setCapStyle(Qt::PenCapStyle capStyle) { m_capStyle = joinModeForCap(capStyle); }
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 4c879cf05d..056fd8b701 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -42,6 +42,11 @@ QT_BEGIN_NAMESPACE
// #define CACHE_DEBUG
+// out-of-line to avoid vtable duplication, breaking e.g. RTTI
+QTextureGlyphCache::~QTextureGlyphCache()
+{
+}
+
int QTextureGlyphCache::calculateSubPixelPositionCount(glyph_t glyph) const
{
// Test 12 different subpixel positions since it factors into 3*4 so it gives
@@ -262,6 +267,11 @@ QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g, QFixed subPixelPosition
* QImageTextureGlyphCache
*/
+// out-of-line to avoid vtable duplication, breaking e.g. RTTI
+QImageTextureGlyphCache::~QImageTextureGlyphCache()
+{
+}
+
void QImageTextureGlyphCache::resizeTextureData(int width, int height)
{
m_image = m_image.copy(0, 0, width, height);
diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h
index c9e7060b0d..7dd8277a45 100644
--- a/src/gui/painting/qtextureglyphcache_p.h
+++ b/src/gui/painting/qtextureglyphcache_p.h
@@ -72,7 +72,7 @@ public:
m_w(0), m_h(0), m_cx(0), m_cy(0), m_currentRowHeight(0)
{ }
- virtual ~QTextureGlyphCache() { }
+ ~QTextureGlyphCache();
struct GlyphAndSubPixelPosition
{
@@ -158,6 +158,8 @@ class Q_GUI_EXPORT QImageTextureGlyphCache : public QTextureGlyphCache
public:
QImageTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix)
: QTextureGlyphCache(format, matrix) { }
+ ~QImageTextureGlyphCache();
+
virtual void createTextureData(int width, int height) Q_DECL_OVERRIDE;
virtual void resizeTextureData(int width, int height) Q_DECL_OVERRIDE;
virtual void fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition) Q_DECL_OVERRIDE;
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 4b3f0b30dc..fca2b72249 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -1102,7 +1102,7 @@ QDataStream & operator>>(QDataStream &s, QTransform &t)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QTransform &m)
{
- static const char *typeStr[] =
+ static const char *const typeStr[] =
{
"TxNone",
"TxTranslate",
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp
index 70be92535d..7735fd6b46 100644
--- a/src/gui/text/qabstracttextdocumentlayout.cpp
+++ b/src/gui/text/qabstracttextdocumentlayout.cpp
@@ -40,6 +40,15 @@
QT_BEGIN_NAMESPACE
+QAbstractTextDocumentLayoutPrivate::~QAbstractTextDocumentLayoutPrivate()
+{
+}
+
+QTextObjectInterface::~QTextObjectInterface()
+{
+ // must be empty until ### Qt 6
+}
+
/*!
\class QAbstractTextDocumentLayout
\reentrant
diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h
index 27135b0476..68e7a0e4e9 100644
--- a/src/gui/text/qabstracttextdocumentlayout.h
+++ b/src/gui/text/qabstracttextdocumentlayout.h
@@ -126,7 +126,7 @@ private:
class Q_GUI_EXPORT QTextObjectInterface
{
public:
- virtual ~QTextObjectInterface() {}
+ virtual ~QTextObjectInterface();
virtual QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) = 0;
virtual void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) = 0;
};
diff --git a/src/gui/text/qabstracttextdocumentlayout_p.h b/src/gui/text/qabstracttextdocumentlayout_p.h
index 505135fa4b..a7f28ebf96 100644
--- a/src/gui/text/qabstracttextdocumentlayout_p.h
+++ b/src/gui/text/qabstracttextdocumentlayout_p.h
@@ -58,13 +58,14 @@ struct QTextObjectHandler
};
typedef QHash<int, QTextObjectHandler> HandlerHash;
-class QAbstractTextDocumentLayoutPrivate : public QObjectPrivate
+class Q_GUI_EXPORT QAbstractTextDocumentLayoutPrivate : public QObjectPrivate
{
public:
Q_DECLARE_PUBLIC(QAbstractTextDocumentLayout)
inline QAbstractTextDocumentLayoutPrivate()
: paintDevice(0) {}
+ ~QAbstractTextDocumentLayoutPrivate();
inline void setDocument(QTextDocument *doc) {
document = doc;
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index cc78ea7f45..72e4197fc5 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -237,7 +237,7 @@ public:
operator QVariant() const;
bool isCopyOf(const QFont &) const;
#ifdef Q_COMPILER_RVALUE_REFS
- inline QFont &operator=(QFont &&other)
+ inline QFont &operator=(QFont &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); qSwap(resolve_mask, other.resolve_mask); return *this; }
#endif
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 126f0bf3ec..dae4d560a8 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -121,6 +121,8 @@ static int getFontWeight(const QString &weightString)
return QFont::DemiBold;
return QFont::Bold;
}
+ if (s.contains(QLatin1String("thin")))
+ return QFont::Thin;
if (s.contains(QLatin1String("light")))
return QFont::Light;
if (s.contains(QLatin1String("black")))
@@ -346,7 +348,6 @@ struct QtFontFamily
populated(false),
fixedPitch(false),
name(n), count(0), foundries(0)
- , askedForFallback(false)
{
memset(writingSystems, 0, sizeof(writingSystems));
}
@@ -364,8 +365,6 @@ struct QtFontFamily
int count;
QtFontFoundry **foundries;
- QStringList fallbackFamilies;
- bool askedForFallback;
unsigned char writingSystems[QFontDatabase::WritingSystemsCount];
bool matchesFamilyName(const QString &familyName) const;
@@ -630,6 +629,7 @@ static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDe
} else {
fontDef->pixelSize = desc.size->pixelSize;
}
+ fontDef->pointSize = request.pointSize;
fontDef->styleHint = request.styleHint;
fontDef->styleStrategy = request.styleStrategy;
@@ -758,6 +758,7 @@ QString qt_resolveFontFamilyAlias(const QString &alias)
static QStringList fallbackFamilies(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script)
{
+ // make sure that the db has all fallback families
QStringList retList = QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(family,style,styleHint,script);
QFontDatabasePrivate *db = privateDb();
@@ -883,20 +884,13 @@ QFontEngine *loadEngine(int script, const QFontDef &request,
QFontEngine *engine = loadSingleEngine(script, request, family, foundry, style, size);
Q_ASSERT(!engine || engine->type() != QFontEngine::Multi);
if (engine && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) {
- // make sure that the db has all fallback families
- if (family && !family->askedForFallback) {
- QFont::Style fontStyle = QFont::Style(style->key.style);
- QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);
- if (styleHint == QFont::AnyStyle && request.fixedPitch)
- styleHint = QFont::TypeWriter;
- family->fallbackFamilies = fallbackFamilies(family->name, fontStyle, styleHint, QChar::Script(script));
+ QStringList fallbacks = request.fallBackFamilies;
- family->askedForFallback = true;
- }
+ QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);
+ if (styleHint == QFont::AnyStyle && request.fixedPitch)
+ styleHint = QFont::TypeWriter;
- QStringList fallbacks = request.fallBackFamilies;
- if (family)
- fallbacks += family->fallbackFamilies;
+ fallbacks += fallbackFamilies(family->name, QFont::Style(style->key.style), styleHint, QChar::Script(script));
QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
QFontEngineMulti *pfMultiEngine = pfdb->fontEngineMulti(engine, QChar::Script(script));
@@ -2505,9 +2499,7 @@ bool QFontDatabase::supportsThreadedFontRendering()
/*!
\internal
*/
-QFontEngine *
-QFontDatabase::findFont(int script, const QFontPrivate *fp,
- const QFontDef &request, bool multi)
+QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
{
QMutexLocker locker(fontDatabaseMutex());
@@ -2515,6 +2507,11 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
initializeDb();
QFontEngine *engine;
+
+ // Until we specifically asked not to, try looking for Multi font engine
+ // first, the last '1' indicates that we want Multi font engine instead
+ // of single ones
+ bool multi = !(request.styleStrategy & QFont::NoFontMerging);
QFontCache::Key key(request, script, multi ? 1 : 0);
engine = QFontCache::instance()->findEngine(key);
if (engine) {
@@ -2529,6 +2526,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
if (qt_enable_test_font && request.family == QLatin1String("__Qt__Box__Engine__")) {
engine =new QTestFontEngine(request.pixelSize);
engine->fontDef = request;
+ return engine;
}
QtFontDesc desc;
@@ -2536,24 +2534,14 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
int index = match(script, request, family_name, foundry_name, &desc, blackListed);
if (index >= 0) {
engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size);
- if (!engine)
+ if (engine)
+ initFontDef(desc, request, &engine->fontDef, multi);
+ else
blackListed.append(index);
} else {
FM_DEBUG(" NO MATCH FOUND\n");
}
- if (engine && engine->type() != QFontEngine::TestFontEngine) {
- initFontDef(desc, request, &engine->fontDef, engine->type() == QFontEngine::Multi);
-
- if (fp) {
- QFontDef def = request;
- if (def.family.isEmpty()) {
- def.family = fp->request.family;
- def.family = def.family.left(def.family.indexOf(QLatin1Char(',')));
- }
- }
- }
-
if (!engine) {
if (!request.family.isEmpty()) {
QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);
@@ -2583,7 +2571,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
loadDef.family = desc.family->name;
engine = loadEngine(script, loadDef, desc.family, desc.foundry, desc.style, desc.size);
if (engine)
- initFontDef(desc, loadDef, &engine->fontDef, engine->type() == QFontEngine::Multi);
+ initFontDef(desc, loadDef, &engine->fontDef, multi);
else
blackListed.append(index);
}
@@ -2598,12 +2586,6 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
FM_DEBUG("returning box engine");
}
- if (fp && fp->dpi > 0) {
- engine->fontDef.pointSize = qreal(double((engine->fontDef.pixelSize * 72) / fp->dpi));
- } else {
- engine->fontDef.pointSize = request.pointSize;
- }
-
return engine;
}
@@ -2671,12 +2653,16 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
for (; !fe && it != end; ++it) {
req.family = *it;
- fe = QFontDatabase::findFont(script, d, req, multi);
- if (fe && (fe->type()==QFontEngine::Box) && !req.family.isEmpty()) {
- if (fe->ref.load() == 0)
- delete fe;
-
- fe = 0;
+ fe = QFontDatabase::findFont(req, script);
+ if (fe) {
+ if (fe->type() == QFontEngine::Box && !req.family.isEmpty()) {
+ if (fe->ref.load() == 0)
+ delete fe;
+ fe = 0;
+ } else {
+ if (d->dpi > 0)
+ fe->fontDef.pointSize = qreal(double((fe->fontDef.pixelSize * 72) / d->dpi));
+ }
}
// No need to check requested fallback families again
diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h
index 6d738d96be..02bc8e8a08 100644
--- a/src/gui/text/qfontdatabase.h
+++ b/src/gui/text/qfontdatabase.h
@@ -153,7 +153,7 @@ private:
static void createDatabase();
static void parseFontName(const QString &name, QString &foundry, QString &family);
static QString resolveFontFamilyAlias(const QString &family);
- static QFontEngine *findFont(int script, const QFontPrivate *fp, const QFontDef &request, bool multi = false);
+ static QFontEngine *findFont(const QFontDef &request, int script);
static void load(const QFontPrivate *d, int script);
friend struct QFontDef;
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index b028d868b9..87e6c30afe 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1641,7 +1641,7 @@ QFontEngine *QFontEngineMulti::loadEngine(int at)
request.styleStrategy |= QFont::NoFontMerging;
request.family = fallbackFamilyAt(at - 1);
- if (QFontEngine *engine = QFontDatabase::findFont(m_script, /*fontprivate = */0, request, /*multi = */false)) {
+ if (QFontEngine *engine = QFontDatabase::findFont(request, m_script)) {
engine->fontDef = request;
return engine;
}
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 931c71dc63..37be0afccf 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -115,7 +115,7 @@ public:
QtFreetypeData::~QtFreetypeData()
{
- for (QHash<QFontEngine::FaceId, QFreetypeFace *>::ConstIterator iter = faces.begin(); iter != faces.end(); ++iter)
+ for (QHash<QFontEngine::FaceId, QFreetypeFace *>::ConstIterator iter = faces.cbegin(); iter != faces.cend(); ++iter)
iter.value()->cleanup();
faces.clear();
FT_Done_FreeType(library);
diff --git a/src/gui/text/qfontengine_qpf2.cpp b/src/gui/text/qfontengine_qpf2.cpp
index 7e16983b6c..a678b4c8ea 100644
--- a/src/gui/text/qfontengine_qpf2.cpp
+++ b/src/gui/text/qfontengine_qpf2.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
//#define DEBUG_HEADER
//#define DEBUG_FONTENGINE
-static QFontEngineQPF2::TagType tagTypes[QFontEngineQPF2::NumTags] = {
+static const QFontEngineQPF2::TagType tagTypes[QFontEngineQPF2::NumTags] = {
QFontEngineQPF2::StringType, // FontName
QFontEngineQPF2::StringType, // FileName
QFontEngineQPF2::UInt32Type, // FileIndex
diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h b/src/gui/text/qfontengineglyphcache.cpp
index 8b2a9f3788..f6fdfa3ce3 100644
--- a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h
+++ b/src/gui/text/qfontengineglyphcache.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@@ -31,23 +31,13 @@
**
****************************************************************************/
-#ifndef QCOCOAAUTORELEASEPOOL_H
-#define QCOCOAAUTORELEASEPOOL_H
-
-#undef slots
-#include <qglobal.h>
-#include <Cocoa/Cocoa.h>
+#include <private/qfontengineglyphcache_p.h>
QT_BEGIN_NAMESPACE
-class QCocoaAutoReleasePool
+
+// out-of-line to avoid vtable duplication, breaking e.g. RTTI
+QFontEngineGlyphCache::~QFontEngineGlyphCache()
{
-public:
- QCocoaAutoReleasePool();
- ~QCocoaAutoReleasePool();
+}
-private:
- NSAutoreleasePool *pool;
-};
QT_END_NAMESPACE
-
-#endif // QCOCOAAUTORELEASEPOOL_H
diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h
index 6cf4d2f1ba..def42c22a3 100644
--- a/src/gui/text/qfontengineglyphcache_p.h
+++ b/src/gui/text/qfontengineglyphcache_p.h
@@ -56,7 +56,7 @@
QT_BEGIN_NAMESPACE
-class QFontEngineGlyphCache: public QSharedData
+class Q_GUI_EXPORT QFontEngineGlyphCache: public QSharedData
{
public:
QFontEngineGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix) : m_format(format), m_transform(matrix)
@@ -64,7 +64,7 @@ public:
Q_ASSERT(m_format != QFontEngine::Format_None);
}
- virtual ~QFontEngineGlyphCache() { }
+ virtual ~QFontEngineGlyphCache();
QFontEngine::GlyphFormat glyphFormat() const { return m_format; }
const QTransform &transform() const { return m_transform; }
diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h
index 12aa2dadb4..65ec219a99 100644
--- a/src/gui/text/qfontmetrics.h
+++ b/src/gui/text/qfontmetrics.h
@@ -58,11 +58,12 @@ public:
QFontMetrics &operator=(const QFontMetrics &);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QFontMetrics &operator=(QFontMetrics &&other)
+ inline QFontMetrics &operator=(QFontMetrics &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
- void swap(QFontMetrics &other) { qSwap(d, other.d); }
+ void swap(QFontMetrics &other) Q_DECL_NOEXCEPT
+ { qSwap(d, other.d); }
int ascent() const;
int descent() const;
diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp
index e6d6863134..642313d340 100644
--- a/src/gui/text/qglyphrun.cpp
+++ b/src/gui/text/qglyphrun.cpp
@@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE
\ingroup text
\ingroup shared
- \mainclass
When Qt displays a string of text encoded in Unicode, it will first convert the Unicode points
into a list of glyph indexes and a list of positions based on one or more fonts. The Unicode
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 2631cf8d17..d5567e173d 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -55,7 +55,6 @@ QT_BEGIN_NAMESPACE
\ingroup text
\ingroup shared
- \mainclass
\note QRawFont is a low level class. For most purposes QFont is a more appropriate class.
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index 38d83c485c..f03895a16e 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -39,6 +39,10 @@
QT_BEGIN_NAMESPACE
+QStaticTextUserData::~QStaticTextUserData()
+{
+}
+
/*!
\class QStaticText
\brief The QStaticText class enables optimized drawing of text when the text and its layout
@@ -49,7 +53,6 @@ QT_BEGIN_NAMESPACE
\ingroup multimedia
\ingroup text
\ingroup shared
- \mainclass
QStaticText provides a way to cache layout data for a block of text so that it can be drawn
more efficiently than by using QPainter::drawText() in which the layout information is
diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h
index 088e49e2fc..49ca24d51c 100644
--- a/src/gui/text/qstatictext_p.h
+++ b/src/gui/text/qstatictext_p.h
@@ -52,7 +52,8 @@
QT_BEGIN_NAMESPACE
-class QStaticTextUserData
+// ### Qt 6: Unexport again, if QOpenGLStaticTextUserData (the one from QtOpenGL) is gone by then
+class Q_GUI_EXPORT QStaticTextUserData
{
public:
enum Type {
@@ -61,7 +62,7 @@ public:
};
QStaticTextUserData(Type t) : ref(0), type(t) {}
- virtual ~QStaticTextUserData() {}
+ virtual ~QStaticTextUserData();
QAtomicInt ref;
Type type;
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index 162c646a98..f180a839b7 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -90,13 +90,13 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
QTextLayout *layout = currentBlock.layout();
- QList<QTextLayout::FormatRange> ranges = layout->additionalFormats();
+ QVector<QTextLayout::FormatRange> ranges = layout->formats();
const int preeditAreaStart = layout->preeditAreaPosition();
const int preeditAreaLength = layout->preeditAreaText().length();
if (preeditAreaLength != 0) {
- QList<QTextLayout::FormatRange>::Iterator it = ranges.begin();
+ QVector<QTextLayout::FormatRange>::Iterator it = ranges.begin();
while (it != ranges.end()) {
if (it->start >= preeditAreaStart
&& it->start + it->length <= preeditAreaStart + preeditAreaLength) {
@@ -142,7 +142,7 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
}
if (formatsChanged) {
- layout->setAdditionalFormats(ranges);
+ layout->setFormats(ranges);
doc->markContentsDirty(currentBlock.position(), currentBlock.length());
}
}
@@ -329,7 +329,7 @@ void QSyntaxHighlighter::setDocument(QTextDocument *doc)
QTextCursor cursor(d->doc);
cursor.beginEditBlock();
for (QTextBlock blk = d->doc->begin(); blk.isValid(); blk = blk.next())
- blk.layout()->clearAdditionalFormats();
+ blk.layout()->clearFormats();
cursor.endEditBlock();
}
d->doc = doc;
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index d3b70aaf26..3d248f4afc 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1949,7 +1949,7 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock();
srcBlock.isValid() && dstBlock.isValid();
srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) {
- dstBlock.layout()->setAdditionalFormats(srcBlock.layout()->additionalFormats());
+ dstBlock.layout()->setFormats(srcBlock.layout()->formats());
}
QAbstractTextDocumentLayout *layout = doc->documentLayout();
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index db8a792be7..5864ca0b1a 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -504,8 +504,6 @@ public:
void layoutBlock(const QTextBlock &bl, int blockPosition, const QTextBlockFormat &blockFormat,
QTextLayoutStruct *layoutStruct, int layoutFrom, int layoutTo, const QTextBlockFormat *previousBlockFormat);
void layoutFlow(QTextFrame::Iterator it, QTextLayoutStruct *layoutStruct, int layoutFrom, int layoutTo, QFixed width = 0);
- void pageBreakInsideTable(QTextTable *table, QTextLayoutStruct *layoutStruct);
-
void floatMargins(const QFixed &y, const QTextLayoutStruct *layoutStruct, QFixed *left, QFixed *right) const;
QFixed findY(QFixed yFrom, const QTextLayoutStruct *layoutStruct, QFixed requiredWidth) const;
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 67a19804a3..187ffa5be7 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -2571,7 +2571,7 @@ void QTextEngine::setPreeditArea(int position, const QString &preeditText)
clearLineData();
}
-void QTextEngine::setFormats(const QList<QTextLayout::FormatRange> &formats)
+void QTextEngine::setFormats(const QVector<QTextLayout::FormatRange> &formats)
{
if (formats.isEmpty()) {
if (!specialData)
@@ -2946,17 +2946,17 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const
namespace {
class FormatRangeComparatorByStart {
- const QList<QTextLayout::FormatRange> &list;
+ const QVector<QTextLayout::FormatRange> &list;
public:
- FormatRangeComparatorByStart(const QList<QTextLayout::FormatRange> &list) : list(list) { }
+ FormatRangeComparatorByStart(const QVector<QTextLayout::FormatRange> &list) : list(list) { }
bool operator()(int a, int b) {
return list.at(a).start < list.at(b).start;
}
};
class FormatRangeComparatorByEnd {
- const QList<QTextLayout::FormatRange> &list;
+ const QVector<QTextLayout::FormatRange> &list;
public:
- FormatRangeComparatorByEnd(const QList<QTextLayout::FormatRange> &list) : list(list) { }
+ FormatRangeComparatorByEnd(const QVector<QTextLayout::FormatRange> &list) : list(list) { }
bool operator()(int a, int b) {
return list.at(a).start + list.at(a).length < list.at(b).start + list.at(b).length;
}
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 39b9e0cb5a..3590c6da07 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -570,9 +570,9 @@ public:
inline bool hasFormats() const
{ return block.docHandle() || (specialData && !specialData->formats.isEmpty()); }
- inline QList<QTextLayout::FormatRange> formats() const
- { return specialData ? specialData->formats : QList<QTextLayout::FormatRange>(); }
- void setFormats(const QList<QTextLayout::FormatRange> &formats);
+ inline QVector<QTextLayout::FormatRange> formats() const
+ { return specialData ? specialData->formats : QVector<QTextLayout::FormatRange>(); }
+ void setFormats(const QVector<QTextLayout::FormatRange> &formats);
private:
static void init(QTextEngine *e);
@@ -580,7 +580,7 @@ private:
struct SpecialData {
int preeditPosition;
QString preeditText;
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
QVector<QTextCharFormat> resolvedFormats;
// only used when no docHandle is available
QScopedPointer<QTextFormatCollection> formatCollection;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 7da3e84041..c42054c07c 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
for a specified area in the text layout's content.
\inmodule QtGui
- \sa QTextLayout::setAdditionalFormats(), QTextLayout::draw()
+ \sa QTextLayout::setFormats(), QTextLayout::draw()
*/
/*!
@@ -485,7 +485,6 @@ QString QTextLayout::preeditAreaText() const
return d->preeditAreaText();
}
-
/*!
Sets the additional formats supported by the text layout to \a formatList.
The formats are applied with preedit area text in place.
@@ -494,7 +493,20 @@ QString QTextLayout::preeditAreaText() const
*/
void QTextLayout::setAdditionalFormats(const QList<FormatRange> &formatList)
{
- d->setFormats(formatList);
+ setFormats(formatList.toVector());
+}
+
+/*!
+ \since 5.6
+
+ Sets the additional formats supported by the text layout to \a formats.
+ The formats are applied with preedit area text in place.
+
+ \sa formats(), clearFormats()
+*/
+void QTextLayout::setFormats(const QVector<FormatRange> &formats)
+{
+ d->setFormats(formats);
if (d->block.docHandle())
d->block.docHandle()->documentChange(d->block.position(), d->block.length());
@@ -507,6 +519,18 @@ void QTextLayout::setAdditionalFormats(const QList<FormatRange> &formatList)
*/
QList<QTextLayout::FormatRange> QTextLayout::additionalFormats() const
{
+ return formats().toList();
+}
+
+/*!
+ \since 5.6
+
+ Returns the list of additional formats supported by the text layout.
+
+ \sa setFormats(), clearFormats()
+*/
+QVector<QTextLayout::FormatRange> QTextLayout::formats() const
+{
return d->formats();
}
@@ -517,7 +541,19 @@ QList<QTextLayout::FormatRange> QTextLayout::additionalFormats() const
*/
void QTextLayout::clearAdditionalFormats()
{
- setAdditionalFormats(QList<FormatRange>());
+ clearFormats();
+}
+
+/*!
+ \since 5.6
+
+ Clears the list of additional formats supported by the text layout.
+
+ \sa formats(), setFormats()
+*/
+void QTextLayout::clearFormats()
+{
+ setFormats(QVector<FormatRange>());
}
/*!
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index 47dcd388e2..9709af4fd1 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -125,10 +125,18 @@ public:
int start;
int length;
QTextCharFormat format;
+
+ friend bool operator==(const FormatRange &lhs, const FormatRange &rhs)
+ { return lhs.start == rhs.start && lhs.length == rhs.length && lhs.format == rhs.format; }
+ friend bool operator!=(const FormatRange &lhs, const FormatRange &rhs)
+ { return !operator==(lhs, rhs); }
};
void setAdditionalFormats(const QList<FormatRange> &overrides);
QList<FormatRange> additionalFormats() const;
void clearAdditionalFormats();
+ void setFormats(const QVector<FormatRange> &overrides);
+ QVector<FormatRange> formats() const;
+ void clearFormats();
void setCacheEnabled(bool enable);
bool cacheEnabled() const;
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index e5acccb55b..a75a1aae54 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -1264,12 +1264,6 @@ int QTextTable::columns() const
return d->nCols;
}
-#if 0
-void QTextTable::mergeCells(const QTextCursor &selection)
-{
-}
-#endif
-
/*!
\fn QTextCursor QTextTable::rowStart(const QTextCursor &cursor) const
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index 9f561dcb02..edd3447357 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -670,7 +670,7 @@ void QZipReaderPrivate::scanFiles()
void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const QByteArray &contents/*, QFile::Permissions permissions, QZip::Method m*/)
{
#ifndef NDEBUG
- static const char *entryTypes[] = {
+ static const char *const entryTypes[] = {
"directory",
"file ",
"symlink " };
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index 61e239f678..be60ba72cc 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -21,6 +21,7 @@ HEADERS += \
text/qtextdocument_p.h \
text/qtexthtmlparser_p.h \
text/qabstracttextdocumentlayout.h \
+ text/qabstracttextdocumentlayout_p.h \
text/qtextdocumentlayout_p.h \
text/qtextcursor.h \
text/qtextcursor_p.h \
@@ -47,6 +48,7 @@ HEADERS += \
SOURCES += \
text/qfont.cpp \
text/qfontengine.cpp \
+ text/qfontengineglyphcache.cpp \
text/qfontsubset.cpp \
text/qfontmetrics.cpp \
text/qfontdatabase.cpp \
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp
index 0114b13209..74c95ecd5e 100644
--- a/src/network/access/qftp.cpp
+++ b/src/network/access/qftp.cpp
@@ -735,7 +735,10 @@ void QFtpDTP::socketConnectionClosed()
clearData();
}
- bytesFromSocket = socket->readAll();
+ if (socket->isOpen())
+ bytesFromSocket = socket->readAll();
+ else
+ bytesFromSocket.clear();
#if defined(QFTPDTP_DEBUG)
qDebug("QFtpDTP::connectState(CsClosed)");
#endif
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 647967839a..98247b7df0 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -106,15 +106,19 @@ void QHttpNetworkConnectionChannel::init()
socket->setProxy(QNetworkProxy::NoProxy);
#endif
+ // We want all signals (except the interactive ones) be connected as QueuedConnection
+ // because else we're falling into cases where we recurse back into the socket code
+ // and mess up the state. Always going to the event loop (and expecting that when reading/writing)
+ // is safer.
QObject::connect(socket, SIGNAL(bytesWritten(qint64)),
this, SLOT(_q_bytesWritten(qint64)),
- Qt::DirectConnection);
+ Qt::QueuedConnection);
QObject::connect(socket, SIGNAL(connected()),
this, SLOT(_q_connected()),
- Qt::DirectConnection);
+ Qt::QueuedConnection);
QObject::connect(socket, SIGNAL(readyRead()),
this, SLOT(_q_readyRead()),
- Qt::DirectConnection);
+ Qt::QueuedConnection);
// The disconnected() and error() signals may already come
// while calling connectToHost().
@@ -143,7 +147,7 @@ void QHttpNetworkConnectionChannel::init()
// won't be a sslSocket if encrypt is false
QObject::connect(sslSocket, SIGNAL(encrypted()),
this, SLOT(_q_encrypted()),
- Qt::DirectConnection);
+ Qt::QueuedConnection);
QObject::connect(sslSocket, SIGNAL(sslErrors(QList<QSslError>)),
this, SLOT(_q_sslErrors(QList<QSslError>)),
Qt::DirectConnection);
@@ -152,7 +156,7 @@ void QHttpNetworkConnectionChannel::init()
Qt::DirectConnection);
QObject::connect(sslSocket, SIGNAL(encryptedBytesWritten(qint64)),
this, SLOT(_q_encryptedBytesWritten(qint64)),
- Qt::DirectConnection);
+ Qt::QueuedConnection);
if (ignoreAllSslErrors)
sslSocket->ignoreSslErrors();
@@ -189,8 +193,11 @@ void QHttpNetworkConnectionChannel::close()
// pendingEncrypt must only be true in between connected and encrypted states
pendingEncrypt = false;
- if (socket)
+ if (socket) {
+ // socket can be 0 since the host lookup is done from qhttpnetworkconnection.cpp while
+ // there is no socket yet.
socket->close();
+ }
}
@@ -356,6 +363,14 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
}
return false;
}
+
+ // This code path for ConnectedState
+ if (pendingEncrypt) {
+ // Let's only be really connected when we have received the encrypted() signal. Else the state machine seems to mess up
+ // and corrupt the things sent to the server.
+ return false;
+ }
+
return true;
}
@@ -676,6 +691,12 @@ bool QHttpNetworkConnectionChannel::isSocketReading() const
void QHttpNetworkConnectionChannel::_q_bytesWritten(qint64 bytes)
{
Q_UNUSED(bytes);
+ if (ssl) {
+ // In the SSL case we want to send data from encryptedBytesWritten signal since that one
+ // is the one going down to the actual network, not only into some SSL buffer.
+ return;
+ }
+
// bytes have been written to the socket. write even more of them :)
if (isSocketWriting())
sendRequest();
@@ -751,7 +772,7 @@ void QHttpNetworkConnectionChannel::_q_connected()
// ### FIXME: if the server closes the connection unexpectedly, we shouldn't send the same broken request again!
//channels[i].reconnectAttempts = 2;
- if (pendingEncrypt) {
+ if (ssl || pendingEncrypt) { // FIXME: Didn't work properly with pendingEncrypt only, we should refactor this into an EncrypingState
#ifndef QT_NO_SSL
if (connection->sslContext().isNull()) {
// this socket is making the 1st handshake for this connection,
diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h
index 6872fcb691..16d6c3b40f 100644
--- a/src/network/access/qhttpnetworkconnectionchannel_p.h
+++ b/src/network/access/qhttpnetworkconnectionchannel_p.h
@@ -83,6 +83,8 @@ typedef QPair<QHttpNetworkRequest, QHttpNetworkReply*> HttpMessagePair;
class QHttpNetworkConnectionChannel : public QObject {
Q_OBJECT
public:
+ // TODO: Refactor this to add an EncryptingState (and remove pendingEncrypt).
+ // Also add an Unconnected state so IdleState does not have double meaning.
enum ChannelState {
IdleState = 0, // ready to send request
ConnectingState = 1, // connecting to host
diff --git a/src/network/access/qhttpprotocolhandler.cpp b/src/network/access/qhttpprotocolhandler.cpp
index eac261bc80..55187755bf 100644
--- a/src/network/access/qhttpprotocolhandler.cpp
+++ b/src/network/access/qhttpprotocolhandler.cpp
@@ -368,6 +368,13 @@ bool QHttpProtocolHandler::sendRequest()
// nothing to read currently, break the loop
break;
} else {
+ if (m_channel->written != uploadByteDevice->pos()) {
+ // Sanity check. This was useful in tracking down an upload corruption.
+ qWarning() << "QHttpProtocolHandler: Internal error in sendRequest. Expected to write at position" << m_channel->written << "but read device is at" << uploadByteDevice->pos();
+ Q_ASSERT(m_channel->written == uploadByteDevice->pos());
+ m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::ProtocolFailure);
+ return false;
+ }
qint64 currentWriteSize = m_socket->write(readPointer, currentReadSize);
if (currentWriteSize == -1 || currentWriteSize != currentReadSize) {
// socket broke down
diff --git a/src/network/access/qhttpthreaddelegate_p.h b/src/network/access/qhttpthreaddelegate_p.h
index 4889bcd1f1..784e9c14b8 100644
--- a/src/network/access/qhttpthreaddelegate_p.h
+++ b/src/network/access/qhttpthreaddelegate_p.h
@@ -191,6 +191,7 @@ protected:
QByteArray m_dataArray;
bool m_atEnd;
qint64 m_size;
+ qint64 m_pos; // to match calls of haveDataSlot with the expected position
public:
QNonContiguousByteDeviceThreadForwardImpl(bool aE, qint64 s)
: QNonContiguousByteDevice(),
@@ -198,7 +199,8 @@ public:
m_amount(0),
m_data(0),
m_atEnd(aE),
- m_size(s)
+ m_size(s),
+ m_pos(0)
{
}
@@ -206,6 +208,11 @@ public:
{
}
+ qint64 pos() Q_DECL_OVERRIDE
+ {
+ return m_pos;
+ }
+
const char* readPointer(qint64 maximumLength, qint64 &len) Q_DECL_OVERRIDE
{
if (m_amount > 0) {
@@ -233,11 +240,10 @@ public:
m_amount -= a;
m_data += a;
+ m_pos += a;
- // To main thread to inform about our state
- emit processedData(a);
-
- // FIXME possible optimization, already ask user thread for some data
+ // To main thread to inform about our state. The m_pos will be sent as a sanity check.
+ emit processedData(m_pos, a);
return true;
}
@@ -254,10 +260,21 @@ public:
{
m_amount = 0;
m_data = 0;
+ m_dataArray.clear();
+
+ if (wantDataPending) {
+ // had requested the user thread to send some data (only 1 in-flight at any moment)
+ wantDataPending = false;
+ }
// Communicate as BlockingQueuedConnection
bool b = false;
emit resetData(&b);
+ if (b) {
+ // the reset succeeded, we're at pos 0 again
+ m_pos = 0;
+ // the HTTP code will anyway abort the request if !b.
+ }
return b;
}
@@ -268,8 +285,13 @@ public:
public slots:
// From user thread:
- void haveDataSlot(QByteArray dataArray, bool dataAtEnd, qint64 dataSize)
+ void haveDataSlot(qint64 pos, QByteArray dataArray, bool dataAtEnd, qint64 dataSize)
{
+ if (pos != m_pos) {
+ // Sometimes when re-sending a request in the qhttpnetwork* layer there is a pending haveData from the
+ // user thread on the way to us. We need to ignore it since it is the data for the wrong(later) chunk.
+ return;
+ }
wantDataPending = false;
m_dataArray = dataArray;
@@ -289,7 +311,7 @@ signals:
// to main thread:
void wantData(qint64);
- void processedData(qint64);
+ void processedData(qint64 pos, qint64 amount);
void resetData(bool *b);
};
diff --git a/src/network/access/qnetworkaccessauthenticationmanager_p.h b/src/network/access/qnetworkaccessauthenticationmanager_p.h
index 8f06ecb6b7..462827d7fc 100644
--- a/src/network/access/qnetworkaccessauthenticationmanager_p.h
+++ b/src/network/access/qnetworkaccessauthenticationmanager_p.h
@@ -64,7 +64,7 @@ public:
QString domain;
QString user;
QString password;
- bool isNull() {
+ bool isNull() const {
return domain.isNull() && user.isNull() && password.isNull();
}
};
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index d4c7e121f0..e878feb2bf 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -985,6 +985,27 @@ QNetworkAccessManager::NetworkAccessibility QNetworkAccessManager::networkAccess
}
}
+/*!
+ \internal
+
+ Returns the network session currently in use.
+ This can be changed at any time, ownership remains with the QNetworkAccessManager
+*/
+const QWeakPointer<const QNetworkSession> QNetworkAccessManagerPrivate::getNetworkSession(const QNetworkAccessManager *q)
+{
+ return q->d_func()->networkSessionWeakRef;
+}
+
+QSharedPointer<QNetworkSession> QNetworkAccessManagerPrivate::getNetworkSession() const
+{
+ if (networkSessionStrongRef)
+ return networkSessionStrongRef;
+ return networkSessionWeakRef.toStrongRef();
+}
+
+#endif // QT_NO_BEARERMANAGEMENT
+
+
#ifndef QT_NO_SSL
/*!
\since 5.2
@@ -1046,26 +1067,6 @@ void QNetworkAccessManager::connectToHost(const QString &hostName, quint16 port)
}
/*!
- \internal
-
- Returns the network session currently in use.
- This can be changed at any time, ownership remains with the QNetworkAccessManager
-*/
-const QWeakPointer<const QNetworkSession> QNetworkAccessManagerPrivate::getNetworkSession(const QNetworkAccessManager *q)
-{
- return q->d_func()->networkSessionWeakRef;
-}
-
-QSharedPointer<QNetworkSession> QNetworkAccessManagerPrivate::getNetworkSession() const
-{
- if (networkSessionStrongRef)
- return networkSessionStrongRef;
- return networkSessionWeakRef.toStrongRef();
-}
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-/*!
\since 4.7
Sends a custom request to the server identified by the URL of \a request.
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index 2b11e5f993..8a24fc55fd 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -499,7 +499,7 @@ static const char zones[] =
"eet\0" // 2
"jst\0" // 9
"\0";
-static int zoneOffsets[] = {-8, -8, -7, -7, -6, -6, -5, -5, -4, -3, 0, 0, 0, 1, 2, 9 };
+static const int zoneOffsets[] = {-8, -8, -7, -7, -6, -6, -5, -5, -4, -3, 0, 0, 0, 1, 2, 9 };
static const char months[] =
"jan\0"
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 47621f41d8..c08648c47b 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -425,6 +425,7 @@ QNetworkReplyHttpImplPrivate::QNetworkReplyHttpImplPrivate()
, synchronous(false)
, state(Idle)
, statusCode(0)
+ , uploadByteDevicePosition(false)
, uploadDeviceChoking(false)
, outgoingData(0)
, bytesUploaded(-1)
@@ -874,9 +875,9 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
q, SLOT(uploadByteDeviceReadyReadSlot()),
Qt::QueuedConnection);
- // From main thread to user thread:
- QObject::connect(q, SIGNAL(haveUploadData(QByteArray,bool,qint64)),
- forwardUploadDevice, SLOT(haveDataSlot(QByteArray,bool,qint64)), Qt::QueuedConnection);
+ // From user thread to http thread:
+ QObject::connect(q, SIGNAL(haveUploadData(qint64,QByteArray,bool,qint64)),
+ forwardUploadDevice, SLOT(haveDataSlot(qint64,QByteArray,bool,qint64)), Qt::QueuedConnection);
QObject::connect(uploadByteDevice.data(), SIGNAL(readyRead()),
forwardUploadDevice, SIGNAL(readyRead()),
Qt::QueuedConnection);
@@ -884,8 +885,8 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
// From http thread to user thread:
QObject::connect(forwardUploadDevice, SIGNAL(wantData(qint64)),
q, SLOT(wantUploadDataSlot(qint64)));
- QObject::connect(forwardUploadDevice, SIGNAL(processedData(qint64)),
- q, SLOT(sentUploadDataSlot(qint64)));
+ QObject::connect(forwardUploadDevice,SIGNAL(processedData(qint64, qint64)),
+ q, SLOT(sentUploadDataSlot(qint64,qint64)));
QObject::connect(forwardUploadDevice, SIGNAL(resetData(bool*)),
q, SLOT(resetUploadDataSlot(bool*)),
Qt::BlockingQueuedConnection); // this is the only one with BlockingQueued!
@@ -1365,12 +1366,22 @@ void QNetworkReplyHttpImplPrivate::replyPreSharedKeyAuthenticationRequiredSlot(Q
void QNetworkReplyHttpImplPrivate::resetUploadDataSlot(bool *r)
{
*r = uploadByteDevice->reset();
+ if (*r) {
+ // reset our own position which is used for the inter-thread communication
+ uploadByteDevicePosition = 0;
+ }
}
// Coming from QNonContiguousByteDeviceThreadForwardImpl in HTTP thread
-void QNetworkReplyHttpImplPrivate::sentUploadDataSlot(qint64 amount)
+void QNetworkReplyHttpImplPrivate::sentUploadDataSlot(qint64 pos, qint64 amount)
{
+ if (uploadByteDevicePosition + amount != pos) {
+ // Sanity check, should not happen.
+ error(QNetworkReply::UnknownNetworkError, QString());
+ return;
+ }
uploadByteDevice->advanceReadPointer(amount);
+ uploadByteDevicePosition += amount;
}
// Coming from QNonContiguousByteDeviceThreadForwardImpl in HTTP thread
@@ -1395,7 +1406,7 @@ void QNetworkReplyHttpImplPrivate::wantUploadDataSlot(qint64 maxSize)
QByteArray dataArray(data, currentUploadDataLength);
// Communicate back to HTTP thread
- emit q->haveUploadData(dataArray, uploadByteDevice->atEnd(), uploadByteDevice->size());
+ emit q->haveUploadData(uploadByteDevicePosition, dataArray, uploadByteDevice->atEnd(), uploadByteDevice->size());
}
void QNetworkReplyHttpImplPrivate::uploadByteDeviceReadyReadSlot()
diff --git a/src/network/access/qnetworkreplyhttpimpl_p.h b/src/network/access/qnetworkreplyhttpimpl_p.h
index 08f3fcf342..fff88f8f2d 100644
--- a/src/network/access/qnetworkreplyhttpimpl_p.h
+++ b/src/network/access/qnetworkreplyhttpimpl_p.h
@@ -122,7 +122,7 @@ public:
Q_PRIVATE_SLOT(d_func(), void resetUploadDataSlot(bool *r))
Q_PRIVATE_SLOT(d_func(), void wantUploadDataSlot(qint64))
- Q_PRIVATE_SLOT(d_func(), void sentUploadDataSlot(qint64))
+ Q_PRIVATE_SLOT(d_func(), void sentUploadDataSlot(qint64,qint64))
Q_PRIVATE_SLOT(d_func(), void uploadByteDeviceReadyReadSlot())
Q_PRIVATE_SLOT(d_func(), void emitReplyUploadProgress(qint64, qint64))
Q_PRIVATE_SLOT(d_func(), void _q_cacheSaveDeviceAboutToClose())
@@ -146,7 +146,7 @@ signals:
void startHttpRequestSynchronously();
- void haveUploadData(QByteArray dataArray, bool dataAtEnd, qint64 dataSize);
+ void haveUploadData(const qint64 pos, QByteArray dataArray, bool dataAtEnd, qint64 dataSize);
};
class QNetworkReplyHttpImplPrivate: public QNetworkReplyPrivate
@@ -197,6 +197,7 @@ public:
// upload
QNonContiguousByteDevice* createUploadByteDevice();
QSharedPointer<QNonContiguousByteDevice> uploadByteDevice;
+ qint64 uploadByteDevicePosition;
bool uploadDeviceChoking; // if we couldn't readPointer() any data at the moment
QIODevice *outgoingData;
QSharedPointer<QRingBuffer> outgoingDataBuffer;
@@ -288,7 +289,7 @@ public:
// From QNonContiguousByteDeviceThreadForwardImpl in HTTP thread:
void resetUploadDataSlot(bool *r);
void wantUploadDataSlot(qint64);
- void sentUploadDataSlot(qint64);
+ void sentUploadDataSlot(qint64, qint64);
// From user's QNonContiguousByteDevice
void uploadByteDeviceReadyReadSlot();
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
index 33d42370b7..c1e837de7b 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp
@@ -75,6 +75,7 @@ QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate()
QMutexLocker locker(&mutex);
qDeleteAll(sessionEngines);
+ sessionEngines.clear();
if (bearerThread)
bearerThread->quit();
}
diff --git a/src/network/doc/src/ssl.qdoc b/src/network/doc/src/ssl.qdoc
index 5a994a114c..45dffc95a3 100644
--- a/src/network/doc/src/ssl.qdoc
+++ b/src/network/doc/src/ssl.qdoc
@@ -36,6 +36,8 @@
the Secure Sockets Layer (SSL) protocol, using the OpenSSL Toolkit (\l{http://www.openssl.org/})
to perform encryption and protocol handling.
+ \annotatedlist ssl
+
See the \l {openssl-v1later}{OpenSSL Compatibility} page for information about the
versions of OpenSSL that are known to work with Qt.
diff --git a/src/network/kernel/qhostinfo_winrt.cpp b/src/network/kernel/qhostinfo_winrt.cpp
index 0e606c2070..1a97fe0e40 100644
--- a/src/network/kernel/qhostinfo_winrt.cpp
+++ b/src/network/kernel/qhostinfo_winrt.cpp
@@ -35,7 +35,6 @@
#include <qurl.h>
-#include <ppltasks.h>
#include <wrl.h>
#include <windows.networking.h>
#include <windows.networking.sockets.h>
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 67dea74436..d6a3822422 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -559,7 +559,6 @@ QAbstractSocketPrivate::QAbstractSocketPrivate()
readBufferMaxSize(0),
writeBuffer(QABSTRACTSOCKET_BUFFERSIZE),
isBuffered(false),
- blockingTimeout(30000),
connectTimer(0),
disconnectTimer(0),
connectTimeElapsed(0),
diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h
index 1c04277f49..85e82aef47 100644
--- a/src/network/socket/qabstractsocket_p.h
+++ b/src/network/socket/qabstractsocket_p.h
@@ -140,7 +140,6 @@ public:
QRingBuffer writeBuffer;
bool isBuffered;
- int blockingTimeout;
QTimer *connectTimer;
QTimer *disconnectTimer;
diff --git a/src/network/socket/qnativesocketengine_winrt_p.h b/src/network/socket/qnativesocketengine_winrt_p.h
index 361fcf7ca2..42920c96f2 100644
--- a/src/network/socket/qnativesocketengine_winrt_p.h
+++ b/src/network/socket/qnativesocketengine_winrt_p.h
@@ -46,6 +46,7 @@
//
#include <QtCore/QEventLoop>
#include <QtCore/QBuffer>
+#include <QtCore/QMutex>
#include "QtNetwork/qhostaddress.h"
#include "private/qabstractsocketengine_p.h"
#include <wrl.h>
diff --git a/src/network/ssl/qasn1element.cpp b/src/network/ssl/qasn1element.cpp
index 95c360e7af..82807aec6e 100644
--- a/src/network/ssl/qasn1element.cpp
+++ b/src/network/ssl/qasn1element.cpp
@@ -46,32 +46,32 @@ static OidNameMap createOidMap()
{
OidNameMap oids;
// used by unit tests
- oids.insert(oids.end(), QByteArrayLiteral("0.9.2342.19200300.100.1.5"), QByteArrayLiteral("favouriteDrink"));
- oids.insert(oids.end(), QByteArrayLiteral("1.2.840.113549.1.9.1"), QByteArrayLiteral("emailAddress"));
- oids.insert(oids.end(), QByteArrayLiteral("1.3.6.1.5.5.7.1.1"), QByteArrayLiteral("authorityInfoAccess"));
- oids.insert(oids.end(), QByteArrayLiteral("1.3.6.1.5.5.7.48.1"), QByteArrayLiteral("OCSP"));
- oids.insert(oids.end(), QByteArrayLiteral("1.3.6.1.5.5.7.48.2"), QByteArrayLiteral("caIssuers"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.29.14"), QByteArrayLiteral("subjectKeyIdentifier"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.29.15"), QByteArrayLiteral("keyUsage"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.29.17"), QByteArrayLiteral("subjectAltName"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.29.19"), QByteArrayLiteral("basicConstraints"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.29.35"), QByteArrayLiteral("authorityKeyIdentifier"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.10"), QByteArrayLiteral("O"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.11"), QByteArrayLiteral("OU"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.12"), QByteArrayLiteral("title"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.13"), QByteArrayLiteral("description"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.17"), QByteArrayLiteral("postalCode"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.3"), QByteArrayLiteral("CN"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.4"), QByteArrayLiteral("SN"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.41"), QByteArrayLiteral("name"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.42"), QByteArrayLiteral("GN"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.43"), QByteArrayLiteral("initials"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.46"), QByteArrayLiteral("dnQualifier"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.5"), QByteArrayLiteral("serialNumber"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.6"), QByteArrayLiteral("C"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.7"), QByteArrayLiteral("L"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.8"), QByteArrayLiteral("ST"));
- oids.insert(oids.end(), QByteArrayLiteral("2.5.4.9"), QByteArrayLiteral("street"));
+ oids.insert(oids.cend(), QByteArrayLiteral("0.9.2342.19200300.100.1.5"), QByteArrayLiteral("favouriteDrink"));
+ oids.insert(oids.cend(), QByteArrayLiteral("1.2.840.113549.1.9.1"), QByteArrayLiteral("emailAddress"));
+ oids.insert(oids.cend(), QByteArrayLiteral("1.3.6.1.5.5.7.1.1"), QByteArrayLiteral("authorityInfoAccess"));
+ oids.insert(oids.cend(), QByteArrayLiteral("1.3.6.1.5.5.7.48.1"), QByteArrayLiteral("OCSP"));
+ oids.insert(oids.cend(), QByteArrayLiteral("1.3.6.1.5.5.7.48.2"), QByteArrayLiteral("caIssuers"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.14"), QByteArrayLiteral("subjectKeyIdentifier"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.15"), QByteArrayLiteral("keyUsage"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.17"), QByteArrayLiteral("subjectAltName"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.19"), QByteArrayLiteral("basicConstraints"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.35"), QByteArrayLiteral("authorityKeyIdentifier"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.10"), QByteArrayLiteral("O"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.11"), QByteArrayLiteral("OU"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.12"), QByteArrayLiteral("title"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.13"), QByteArrayLiteral("description"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.17"), QByteArrayLiteral("postalCode"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.3"), QByteArrayLiteral("CN"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.4"), QByteArrayLiteral("SN"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.41"), QByteArrayLiteral("name"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.42"), QByteArrayLiteral("GN"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.43"), QByteArrayLiteral("initials"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.46"), QByteArrayLiteral("dnQualifier"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.5"), QByteArrayLiteral("serialNumber"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.6"), QByteArrayLiteral("C"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.7"), QByteArrayLiteral("L"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.8"), QByteArrayLiteral("ST"));
+ oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.9"), QByteArrayLiteral("street"));
return oids;
}
Q_GLOBAL_STATIC_WITH_ARGS(OidNameMap, oidNameMap, (createOidMap()))
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp
index 1aac152ca3..6f91ccdb4d 100644
--- a/src/network/ssl/qsslcertificate.cpp
+++ b/src/network/ssl/qsslcertificate.cpp
@@ -594,7 +594,7 @@ bool QSslCertificate::importPkcs12(QIODevice *device,
// These certificates are known to be fraudulent and were created during the comodo
// compromise. See http://www.comodo.com/Comodo-Fraud-Incident-2011-03-23.html
-static const char *certificate_blacklist[] = {
+static const char *const certificate_blacklist[] = {
"04:7e:cb:e9:fc:a5:5f:7b:d0:9e:ae:36:e1:0c:ae:1e", "mail.google.com", // Comodo
"f5:c8:6a:f3:61:62:f1:3a:64:f5:4f:6d:c9:58:7c:06", "www.google.com", // Comodo
"d7:55:8f:da:f5:f1:10:5b:b2:13:28:2b:70:77:29:a3", "login.yahoo.com", // Comodo
diff --git a/src/network/ssl/qsslellipticcurve_dummy.cpp b/src/network/ssl/qsslellipticcurve_dummy.cpp
index d05c920a49..16b7a3cd00 100644
--- a/src/network/ssl/qsslellipticcurve_dummy.cpp
+++ b/src/network/ssl/qsslellipticcurve_dummy.cpp
@@ -57,7 +57,7 @@ QSslEllipticCurve QSslEllipticCurve::fromLongName(const QString &name)
return QSslEllipticCurve();
}
-bool QSslEllipticCurve::isTlsNamedCurve() const
+bool QSslEllipticCurve::isTlsNamedCurve() const Q_DECL_NOTHROW
{
return false;
}
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 00e13e449b..436588afc5 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -494,30 +494,8 @@ bool QSslSocketPrivate::ensureLibraryLoaded()
// Initialize OpenSSL's random seed.
if (!q_RAND_status()) {
- struct {
- int msec;
- int sec;
- void *stack;
- } randomish;
-
- int attempts = 500;
- do {
- if (attempts < 500) {
-#ifdef Q_OS_UNIX
- struct timespec ts = {0, 33333333};
- nanosleep(&ts, 0);
-#else
- Sleep(3);
-#endif
- randomish.msec = attempts;
- }
- randomish.stack = (void *)&randomish;
- randomish.msec = QTime::currentTime().msec();
- randomish.sec = QTime::currentTime().second();
- q_RAND_seed((const char *)&randomish, sizeof(randomish));
- } while (!q_RAND_status() && --attempts);
- if (!attempts)
- return false;
+ qWarning("Random number generator not seeded, disabling SSL support");
+ return false;
}
}
return true;
@@ -640,7 +618,10 @@ long QSslSocketPrivate::sslLibraryBuildVersionNumber()
QString QSslSocketPrivate::sslLibraryBuildVersionString()
{
- return QLatin1String(OPENSSL_VERSION_TEXT);
+ // Using QStringLiteral to store the version string as unicode and
+ // avoid false positives from Google searching the playstore for old
+ // SSL versions. See QTBUG-46265
+ return QStringLiteral(OPENSSL_VERSION_TEXT);
}
/*!
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
index 637bd1c560..8e5d93dce2 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
@@ -508,7 +508,7 @@ GLuint QGLEngineShaderManager::getUniformLocation(Uniform id)
if (uniformLocations.isEmpty())
uniformLocations.fill(GLuint(-1), NumUniforms);
- static const char *uniformNames[] = {
+ static const char *const uniformNames[] = {
"imageTexture",
"patternColor",
"globalOpacity",
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
index 637c375311..9a1ae6e008 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
@@ -304,19 +304,23 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed sub
for (int x = 0; x < maskWidth; ++x)
src[x] = -src[x]; // convert 0 and 1 into 0 and 255
}
- } else if (mask.format() == QImage::Format_RGB32) {
+ } else if (mask.depth() == 32) {
// Make the alpha component equal to the average of the RGB values.
// This is needed when drawing sub-pixel antialiased text on translucent targets.
for (int y = 0; y < maskHeight; ++y) {
quint32 *src = (quint32 *) mask.scanLine(y);
for (int x = 0; x < maskWidth; ++x) {
- uchar r = src[x] >> 16;
- uchar g = src[x] >> 8;
- uchar b = src[x];
- quint32 avg = (quint32(r) + quint32(g) + quint32(b) + 1) / 3; // "+1" for rounding.
+ int r = qRed(src[x]);
+ int g = qGreen(src[x]);
+ int b = qBlue(src[x]);
+ int avg;
+ if (mask.format() == QImage::Format_RGB32)
+ avg = (r + g + b + 1) / 3; // "+1" for rounding.
+ else // Format_ARGB_Premultiplied
+ avg = qAlpha(src[x]);
if (ctx->contextHandle()->isOpenGLES()) {
// swizzle the bits to accommodate for the GL_RGBA upload.
- src[x] = (avg << 24) | (quint32(r) << 0) | (quint32(g) << 8) | (quint32(b) << 16);
+ src[x] = (avg << 24) | (r << 0) | (g << 8) | (b << 16);
} else {
src[x] = (src[x] & 0x00ffffff) | (avg << 24);
}
@@ -325,7 +329,7 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed sub
}
funcs->glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture);
- if (mask.format() == QImage::Format_RGB32) {
+ if (mask.depth() == 32) {
GLenum format = GL_RGBA;
#if !defined(QT_OPENGL_ES_2)
if (!ctx->contextHandle()->isOpenGLES())
diff --git a/src/platformheaders/helper/helper.pri b/src/platformheaders/helper/helper.pri
new file mode 100644
index 0000000000..2f6e766214
--- /dev/null
+++ b/src/platformheaders/helper/helper.pri
@@ -0,0 +1,2 @@
+HEADERS += \
+ $$PWD/qplatformheaderhelper.h
diff --git a/src/platformheaders/xcbfunctions/qxcbfunctionshelper.h b/src/platformheaders/helper/qplatformheaderhelper.h
index a9d734a387..52302dbfba 100644
--- a/src/platformheaders/xcbfunctions/qxcbfunctionshelper.h
+++ b/src/platformheaders/helper/qplatformheaderhelper.h
@@ -31,16 +31,19 @@
**
****************************************************************************/
-#ifndef QXCBFUNCTIONHELPER_H
-#define QXCBFUNCTIONHELPER_H
+#ifndef QPLATFORMHEADERHELPER_H
+#define QPLATFORMHEADERHELPER_H
#include <QtCore/QByteArray>
#include <QtGui/QGuiApplication>
+#if 0
+#pragma qt_class(QPlatformHeaderHelper)
+#endif
+
QT_BEGIN_NAMESPACE
-namespace QXcbFunctionsHelper
-{
+namespace QPlatformHeaderHelper {
template<typename ReturnT, typename FunctionT>
ReturnT callPlatformFunction(const QByteArray &functionName)
@@ -81,4 +84,4 @@ ReturnT callPlatformFunction(const QByteArray &functionName, Arg1 a1, Arg2 a2, A
QT_END_NAMESPACE
-#endif /*QXCBFUNCTIONHELPER_H*/
+#endif /*QPLATFORMHEADERHELPER_H*/
diff --git a/src/platformheaders/platformheaders.pro b/src/platformheaders/platformheaders.pro
index 5e875f7d2d..6b6294d34c 100644
--- a/src/platformheaders/platformheaders.pro
+++ b/src/platformheaders/platformheaders.pro
@@ -7,6 +7,7 @@ include(nativecontexts/nativecontexts.pri)
include(xcbfunctions/xcbfunctions.pri)
include(eglfsfunctions/eglfsfunctions.pri)
include(windowsfunctions/windowsfunctions.pri)
+include(helper/helper.pri)
QMAKE_DOCS = $$PWD/doc/qtplatformheaders.qdocconf
diff --git a/src/platformheaders/xcbfunctions/qxcbintegrationfunctions.h b/src/platformheaders/xcbfunctions/qxcbintegrationfunctions.h
index 87e19e6a45..66bfb72307 100644
--- a/src/platformheaders/xcbfunctions/qxcbintegrationfunctions.h
+++ b/src/platformheaders/xcbfunctions/qxcbintegrationfunctions.h
@@ -34,7 +34,7 @@
#ifndef QXCBINTEGRATIONFUNCTIONS_H
#define QXCBINTEGRATIONFUNCTIONS_H
-#include "qxcbfunctionshelper.h"
+#include <QtPlatformHeaders/QPlatformHeaderHelper>
QT_BEGIN_NAMESPACE
@@ -45,7 +45,7 @@ public:
static const QByteArray xEmbedSystemTrayVisualHasAlphaChannelIdentifier() { return QByteArrayLiteral("XcbXEmbedSystemTrayVisualHasAlphaChannel"); }
static bool xEmbedSystemTrayVisualHasAlphaChannel()
{
- return QXcbFunctionsHelper::callPlatformFunction<bool, XEmbedSystemTrayVisualHasAlphaChannel>(xEmbedSystemTrayVisualHasAlphaChannelIdentifier());
+ return QPlatformHeaderHelper::callPlatformFunction<bool, XEmbedSystemTrayVisualHasAlphaChannel>(xEmbedSystemTrayVisualHasAlphaChannelIdentifier());
}
};
diff --git a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h
index d477a63ec7..0db2e2a09d 100644
--- a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h
+++ b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h
@@ -34,7 +34,7 @@
#ifndef QXCBWINDOWFUNCTIONS_H
#define QXCBWINDOWFUNCTIONS_H
-#include "qxcbfunctionshelper.h"
+#include <QtPlatformHeaders/QPlatformHeaderHelper>
QT_BEGIN_NAMESPACE
@@ -66,35 +66,35 @@ public:
static const QByteArray setWmWindowTypeIdentifier() { return QByteArrayLiteral("XcbSetWmWindowType"); }
static void setWmWindowType(QWindow *window, WmWindowType type)
{
- return QXcbFunctionsHelper::callPlatformFunction<void, SetWmWindowType, QWindow *, WmWindowType>(setWmWindowTypeIdentifier(), window, type);
+ return QPlatformHeaderHelper::callPlatformFunction<void, SetWmWindowType, QWindow *, WmWindowType>(setWmWindowTypeIdentifier(), window, type);
}
typedef void (*SetWmWindowIconText)(QWindow *window, const QString &text);
static const QByteArray setWmWindowIconTextIdentifier() { return QByteArrayLiteral("XcbSetWmWindowIconText"); }
static void setWmWindowIconText(QWindow *window, const QString &text)
{
- return QXcbFunctionsHelper::callPlatformFunction<void, SetWmWindowIconText, QWindow *, const QString &>(setWmWindowIconTextIdentifier(), window, text);
+ return QPlatformHeaderHelper::callPlatformFunction<void, SetWmWindowIconText, QWindow *, const QString &>(setWmWindowIconTextIdentifier(), window, text);
}
typedef void (*SetParentRelativeBackPixmap)(const QWindow *window);
static const QByteArray setParentRelativeBackPixmapIdentifier() { return QByteArrayLiteral("XcbSetParentRelativeBackPixmap"); }
static void setParentRelativeBackPixmap(const QWindow *window)
{
- return QXcbFunctionsHelper::callPlatformFunction<void, SetParentRelativeBackPixmap, const QWindow *>(setParentRelativeBackPixmapIdentifier(), window);
+ return QPlatformHeaderHelper::callPlatformFunction<void, SetParentRelativeBackPixmap, const QWindow *>(setParentRelativeBackPixmapIdentifier(), window);
}
typedef bool (*RequestSystemTrayWindowDock)(const QWindow *window);
static const QByteArray requestSystemTrayWindowDockIdentifier() { return QByteArrayLiteral("XcbRequestSystemTrayWindowDockIdentifier"); }
static bool requestSystemTrayWindowDock(const QWindow *window)
{
- return QXcbFunctionsHelper::callPlatformFunction<bool, RequestSystemTrayWindowDock, const QWindow *>(requestSystemTrayWindowDockIdentifier(), window);
+ return QPlatformHeaderHelper::callPlatformFunction<bool, RequestSystemTrayWindowDock, const QWindow *>(requestSystemTrayWindowDockIdentifier(), window);
}
typedef QRect (*SystemTrayWindowGlobalGeometry)(const QWindow *window);
static const QByteArray systemTrayWindowGlobalGeometryIdentifier() { return QByteArrayLiteral("XcbSystemTrayWindowGlobalGeometryIdentifier"); }
static QRect systemTrayWindowGlobalGeometry(const QWindow *window)
{
- return QXcbFunctionsHelper::callPlatformFunction<QRect, SystemTrayWindowGlobalGeometry, const QWindow *>(systemTrayWindowGlobalGeometryIdentifier(), window);
+ return QPlatformHeaderHelper::callPlatformFunction<QRect, SystemTrayWindowGlobalGeometry, const QWindow *>(systemTrayWindowGlobalGeometryIdentifier(), window);
}
typedef uint (*VisualId)(QWindow *window);
diff --git a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc
index 771b56e060..a02f93968d 100644
--- a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc
+++ b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc
@@ -32,7 +32,7 @@
\brief The QXcbWindowFunctions class is an inline class containing
miscellaneous functionality for xcb window specific functionality.
- A commen usage pattern is as follows:
+ A common usage pattern is as follows:
\snippet qxcbwindowfunctions/main.cpp 0
\note There is no binary compatibility guarantee for this class,
diff --git a/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp b/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp
index 93c822cefb..a64e107e71 100644
--- a/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp
+++ b/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp
@@ -75,6 +75,9 @@ void QDBusPlatformMenuItem::setIcon(const QIcon &icon)
m_icon = icon;
}
+/*!
+ Set a submenu under this menu item.
+*/
void QDBusPlatformMenuItem::setMenu(QPlatformMenu *menu)
{
m_subMenu = static_cast<QDBusPlatformMenu *>(menu);
@@ -242,8 +245,12 @@ const QList<QDBusPlatformMenuItem *> QDBusPlatformMenu::items() const
QPlatformMenuItem *QDBusPlatformMenu::createMenuItem() const
{
QDBusPlatformMenuItem *ret = new QDBusPlatformMenuItem();
- ret->setMenu(const_cast<QDBusPlatformMenu *>(this));
return ret;
}
+QPlatformMenu *QDBusPlatformMenu::createSubMenu() const
+{
+ return new QDBusPlatformMenu;
+}
+
QT_END_NAMESPACE
diff --git a/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h b/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h
index 2519533e32..16bb4f195c 100644
--- a/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h
+++ b/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h
@@ -124,7 +124,7 @@ public:
quintptr tag()const Q_DECL_OVERRIDE { return m_tag; }
void setTag(quintptr tag) Q_DECL_OVERRIDE;
- const QString text() { return m_text; }
+ const QString text() const { return m_text; }
void setText(const QString &text) Q_DECL_OVERRIDE;
void setIcon(const QIcon &icon) Q_DECL_OVERRIDE;
void setEnabled(bool enabled) Q_DECL_OVERRIDE;
@@ -150,6 +150,7 @@ public:
const QList<QDBusPlatformMenuItem *> items() const;
QPlatformMenuItem *createMenuItem() const Q_DECL_OVERRIDE;
+ QPlatformMenu *createSubMenu() const Q_DECL_OVERRIDE;
bool operator==(const QDBusPlatformMenu& other) { return m_tag == other.m_tag; }
@@ -175,6 +176,7 @@ private:
uint m_revision;
QHash<quintptr, QDBusPlatformMenuItem *> m_itemsByTag;
QList<QDBusPlatformMenuItem *> m_items;
+ QDBusPlatformMenuItem *m_containingMenuItem;
static QList<QDBusPlatformMenu *> m_topLevelMenus;
};
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index be70092010..75c4065d66 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -48,18 +48,6 @@
QT_BEGIN_NAMESPACE
-namespace {
-class AutoReleasePool
-{
-public:
- AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
- ~AutoReleasePool() { [pool release]; }
-
-private:
- NSAutoreleasePool *pool;
-};
-}
-
// this could become a list of all languages used for each writing
// system, instead of using the single most common language.
static const char *languageForWritingSystem[] = {
@@ -453,7 +441,7 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
Q_UNUSED(style);
Q_UNUSED(script);
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
static QHash<QString, QStringList> fallbackLists;
diff --git a/src/platformsupport/platformcompositor/qopenglcompositor.cpp b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
index 3fd6c999a2..2e386532e2 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositor.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
@@ -169,6 +169,29 @@ struct BlendStateBinder
bool m_blend;
};
+static inline QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
+{
+ return QRect(topLeftRect.x(), windowHeight - topLeftRect.bottomRight().y() - 1,
+ topLeftRect.width(), topLeftRect.height());
+}
+
+static void clippedBlit(const QPlatformTextureList *textures, int idx, const QRect &targetWindowRect, QOpenGLTextureBlitter *blitter)
+{
+ const QRect rectInWindow = textures->geometry(idx);
+ QRect clipRect = textures->clipRect(idx);
+ if (clipRect.isEmpty())
+ clipRect = QRect(QPoint(0, 0), rectInWindow.size());
+
+ const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());
+ const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());
+
+ const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(clippedRectInWindow, targetWindowRect);
+ const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(srcRect, rectInWindow.size(),
+ QOpenGLTextureBlitter::OriginBottomLeft);
+
+ blitter->blit(textures->textureId(idx), target, source);
+}
+
void QOpenGLCompositor::render(QOpenGLCompositorWindow *window)
{
const QPlatformTextureList *textures = window->textures();
@@ -181,7 +204,6 @@ void QOpenGLCompositor::render(QOpenGLCompositorWindow *window)
for (int i = 0; i < textures->count(); ++i) {
uint textureId = textures->textureId(i);
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
const float opacity = window->sourceWindow()->opacity();
if (opacity != currentOpacity) {
currentOpacity = opacity;
@@ -191,24 +213,25 @@ void QOpenGLCompositor::render(QOpenGLCompositorWindow *window)
if (textures->count() > 1 && i == textures->count() - 1) {
// Backingstore for a widget with QOpenGLWidget subwidgets
blend.set(true);
+ const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
} else if (textures->count() == 1) {
// A regular QWidget window
const bool translucent = window->sourceWindow()->requestedFormat().alphaBufferSize() > 0;
blend.set(translucent);
+ const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
} else if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
// Texture from an FBO belonging to a QOpenGLWidget
blend.set(false);
- m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginBottomLeft);
+ clippedBlit(textures, i, targetWindowRect, &m_blitter);
}
}
for (int i = 0; i < textures->count(); ++i) {
if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
blend.set(true);
- m_blitter.blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft);
+ clippedBlit(textures, i, targetWindowRect, &m_blitter);
}
}
diff --git a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
index 3caec468a6..8ce1ed2d2b 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
@@ -175,7 +175,8 @@ void QOpenGLCompositorBackingStore::composeAndFlush(QWindow *window, const QRegi
m_textures->clear();
for (int i = 0; i < textures->count(); ++i)
- m_textures->appendTexture(textures->widget(i), textures->textureId(i), textures->geometry(i), textures->flags(i));
+ m_textures->appendTexture(textures->source(i), textures->textureId(i), textures->geometry(i),
+ textures->clipRect(i), textures->flags(i));
updateTexture();
m_textures->appendTexture(Q_NULLPTR, m_bsTexture, window->geometry());
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
index 9530dd83d0..6d16b59d35 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -44,6 +44,7 @@
#include <QtCore/qdebug.h>
#include <QDir>
+#ifndef QT_NO_BEARERMANAGEMENT
extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
#import <CoreWLAN/CoreWLAN.h>
@@ -76,17 +77,19 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
- (id) init
{
[locker lock];
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
notificationCenter = [NSNotificationCenter defaultCenter];
currentInterface = [CWInterface interfaceWithName:nil];
[notificationCenter addObserver:self selector:@selector(notificationHandler:) name:CWPowerDidChangeNotification object:nil];
[locker unlock];
- [autoreleasepool release];
return self;
}
+static QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
+
-(void)dealloc
{
+ listener = nil;
[super dealloc];
}
@@ -117,7 +120,6 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
}
@end
-static QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
QT_BEGIN_NAMESPACE
@@ -151,7 +153,7 @@ void QScanThread::quit()
void QScanThread::run()
{
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
QStringList found;
mutex.lock();
CWInterface *currentInterface = [CWInterface interfaceWithName: QCFString::toNSString(interfaceName)];
@@ -233,7 +235,6 @@ void QScanThread::run()
}
}
emit networksChanged();
- [autoreleasepool release];
}
QStringList QScanThread::foundNetwork(const QString &id, const QString &name, const QNetworkConfiguration::StateFlags state, const QString &interfaceName, const QNetworkConfiguration::Purpose purpose)
@@ -273,7 +274,7 @@ void QScanThread::getUserConfigurations()
{
QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
userProfiles.clear();
NSSet *wifiInterfaces = [CWInterface interfaceNames];
@@ -354,7 +355,6 @@ void QScanThread::getUserConfigurations()
}
}
}
- [autoreleasepool release];
}
QString QScanThread::getSsidFromNetworkName(const QString &name)
@@ -433,7 +433,7 @@ QCoreWlanEngine::~QCoreWlanEngine()
void QCoreWlanEngine::initialize()
{
QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
if ([[CWInterface interfaceNames] count] > 0 && !listener) {
listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init];
@@ -445,7 +445,6 @@ void QCoreWlanEngine::initialize()
storeSession = NULL;
startNetworkChangeLoop();
- [autoreleasepool release];
}
@@ -466,7 +465,7 @@ bool QCoreWlanEngine::hasIdentifier(const QString &id)
void QCoreWlanEngine::connectToId(const QString &id)
{
QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
QString interfaceString = getInterfaceFromId(id);
CWInterface *wifiInterface =
@@ -538,7 +537,6 @@ void QCoreWlanEngine::connectToId(const QString &id)
locker.unlock();
emit connectionError(id, InterfaceLookupError);
- [autoreleasepool release];
}
void QCoreWlanEngine::disconnectFromId(const QString &id)
@@ -551,7 +549,7 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
emit connectionError(id, DisconnectionError);
return;
}
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
CWInterface *wifiInterface =
[CWInterface interfaceWithName: QCFString::toNSString(interfaceString)];
@@ -560,14 +558,13 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
[wifiInterface disassociate];
QTimer::singleShot(1000, this,SLOT(checkDisconnect()));
- [autoreleasepool release];
}
void QCoreWlanEngine::checkDisconnect()
{
QMutexLocker locker(&mutex);
if (!disconnectedInterfaceString.isEmpty()) {
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
CWInterface *wifiInterface =
[CWInterface interfaceWithName: QCFString::toNSString(disconnectedInterfaceString)];
@@ -579,7 +576,6 @@ void QCoreWlanEngine::checkDisconnect()
emit connectionError(id, DisconnectionError);
locker.relock();
}
- [autoreleasepool release];
disconnectedInterfaceString.clear();
}
}
@@ -594,7 +590,7 @@ void QCoreWlanEngine::doRequestUpdate()
{
QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
NSSet *wifiInterfaces = [CWInterface interfaceNames];
for (NSString *ifName in wifiInterfaces) {
@@ -604,7 +600,6 @@ void QCoreWlanEngine::doRequestUpdate()
locker.unlock();
if ([wifiInterfaces count] == 0)
networksChanged();
- [autoreleasepool release];
}
bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
@@ -612,12 +607,11 @@ bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
QMutexLocker locker(&mutex);
bool haswifi = false;
if(hasWifi) {
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
CWInterface *defaultInterface = [CWInterface interfaceWithName: QCFString::toNSString(wifiDeviceName)];
if (defaultInterface.powerOn) {
haswifi = true;
}
- [autoreleasepool release];
}
return haswifi;
}
@@ -811,7 +805,7 @@ quint64 QCoreWlanEngine::bytesReceived(const QString &id)
quint64 QCoreWlanEngine::startTime(const QString &identifier)
{
QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
quint64 timestamp = 0;
NSString *filePath = @"/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist";
@@ -858,7 +852,6 @@ quint64 QCoreWlanEngine::startTime(const QString &identifier)
}
}
}
- [autoreleasepool release];
return timestamp;
}
@@ -888,3 +881,5 @@ quint64 QCoreWlanEngine::getBytes(const QString &interfaceName, bool b)
}
QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/generic/evdevkeyboard/main.cpp b/src/plugins/generic/evdevkeyboard/main.cpp
index ceb8f4f792..444c9f1559 100644
--- a/src/plugins/generic/evdevkeyboard/main.cpp
+++ b/src/plugins/generic/evdevkeyboard/main.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QEvdevKeyboardPlugin : public QGenericPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevkeyboard.json")
+ Q_PLUGIN_METADATA(IID QGenericPluginFactoryInterface_iid FILE "evdevkeyboard.json")
public:
QEvdevKeyboardPlugin();
diff --git a/src/plugins/generic/evdevmouse/main.cpp b/src/plugins/generic/evdevmouse/main.cpp
index 7e9932ceb9..f39f92cfd2 100644
--- a/src/plugins/generic/evdevmouse/main.cpp
+++ b/src/plugins/generic/evdevmouse/main.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QEvdevMousePlugin : public QGenericPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevmouse.json")
+ Q_PLUGIN_METADATA(IID QGenericPluginFactoryInterface_iid FILE "evdevmouse.json")
public:
QEvdevMousePlugin();
diff --git a/src/plugins/generic/evdevtablet/main.cpp b/src/plugins/generic/evdevtablet/main.cpp
index 7d62e1a2bc..62524e8f33 100644
--- a/src/plugins/generic/evdevtablet/main.cpp
+++ b/src/plugins/generic/evdevtablet/main.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QEvdevTabletPlugin : public QGenericPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevtablet.json")
+ Q_PLUGIN_METADATA(IID QGenericPluginFactoryInterface_iid FILE "evdevtablet.json")
public:
QEvdevTabletPlugin();
diff --git a/src/plugins/generic/evdevtouch/main.cpp b/src/plugins/generic/evdevtouch/main.cpp
index ef6774b0a0..bb78dd6e84 100644
--- a/src/plugins/generic/evdevtouch/main.cpp
+++ b/src/plugins/generic/evdevtouch/main.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QEvdevTouchScreenPlugin : public QGenericPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "evdevtouch.json")
+ Q_PLUGIN_METADATA(IID QGenericPluginFactoryInterface_iid FILE "evdevtouch.json")
public:
QEvdevTouchScreenPlugin();
diff --git a/src/plugins/generic/libinput/main.cpp b/src/plugins/generic/libinput/main.cpp
index 2adc0c747b..9459ca3621 100644
--- a/src/plugins/generic/libinput/main.cpp
+++ b/src/plugins/generic/libinput/main.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QLibInputPlugin : public QGenericPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "libinput.json")
+ Q_PLUGIN_METADATA(IID QGenericPluginFactoryInterface_iid FILE "libinput.json")
public:
QObject *create(const QString &key, const QString &specification);
diff --git a/src/plugins/generic/tslib/main.cpp b/src/plugins/generic/tslib/main.cpp
index 36f1ac7c3c..9459e85544 100644
--- a/src/plugins/generic/tslib/main.cpp
+++ b/src/plugins/generic/tslib/main.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QTsLibPlugin : public QGenericPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "tslib.json")
+ Q_PLUGIN_METADATA(IID QGenericPluginFactoryInterface_iid FILE "tslib.json")
public:
QObject* create(const QString &key, const QString &specification);
diff --git a/src/plugins/generic/tuiotouch/main.cpp b/src/plugins/generic/tuiotouch/main.cpp
index e1d08f0e26..35e74e32bd 100644
--- a/src/plugins/generic/tuiotouch/main.cpp
+++ b/src/plugins/generic/tuiotouch/main.cpp
@@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE
class QTuioTouchPlugin : public QGenericPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "tuiotouch.json")
+ Q_PLUGIN_METADATA(IID QGenericPluginFactoryInterface_iid FILE "tuiotouch.json")
public:
QTuioTouchPlugin();
diff --git a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontextmain.cpp b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontextmain.cpp
index 5ab0dd8f04..96f6424ba2 100644
--- a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontextmain.cpp
+++ b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontextmain.cpp
@@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE
class QComposePlatformInputContextPlugin : public QPlatformInputContextPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface" FILE "compose.json")
+ Q_PLUGIN_METADATA(IID QPlatformInputContextFactoryInterface_iid FILE "compose.json")
public:
QComposeInputContext *create(const QString &, const QStringList &) Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforminputcontexts/ibus/main.cpp b/src/plugins/platforminputcontexts/ibus/main.cpp
index b621bec1ee..1b1a3be2c4 100644
--- a/src/plugins/platforminputcontexts/ibus/main.cpp
+++ b/src/plugins/platforminputcontexts/ibus/main.cpp
@@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE
class QIbusPlatformInputContextPlugin : public QPlatformInputContextPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface" FILE "ibus.json")
+ Q_PLUGIN_METADATA(IID QPlatformInputContextFactoryInterface_iid FILE "ibus.json")
public:
QIBusPlatformInputContext *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp
index 8ee3ff88d1..be5e969d2b 100644
--- a/src/plugins/platforms/android/androidjniinput.cpp
+++ b/src/plugins/platforms/android/androidjniinput.cpp
@@ -238,6 +238,52 @@ namespace QtAndroidInput
QWindowSystemInterface::handleTouchEvent(window, touchDevice, m_touchPoints);
}
+ static void tabletEvent(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint deviceId, jlong time, jint action,
+ jint pointerType, jint buttonState, jfloat x, jfloat y, jfloat pressure)
+ {
+ QPointF globalPosF(x, y);
+ QPoint globalPos((int)x, (int)y);
+ QWindow *tlw = topLevelWindowAt(globalPos);
+ QPointF localPos = tlw ? (globalPosF - tlw->position()) : globalPosF;
+
+ // Galaxy Note with plain Android:
+ // 0 1 0 stylus press
+ // 2 1 0 stylus drag
+ // 1 1 0 stylus release
+ // 0 1 2 stylus press with side-button held
+ // 2 1 2 stylus drag with side-button held
+ // 1 1 2 stylus release with side-button held
+ // Galaxy Note 4 with Samsung firmware:
+ // 0 1 0 stylus press
+ // 2 1 0 stylus drag
+ // 1 1 0 stylus release
+ // 211 1 2 stylus press with side-button held
+ // 213 1 2 stylus drag with side-button held
+ // 212 1 2 stylus release with side-button held
+ // when action == ACTION_UP (1) it's a release; otherwise we say which button is pressed
+ Qt::MouseButtons buttons = Qt::NoButton;
+ switch (action) {
+ case 1: // ACTION_UP
+ case 212: // stylus release while side-button held on Galaxy Note 4
+ buttons = Qt::NoButton;
+ break;
+ default: // action is press or drag
+ if (buttonState == 0)
+ buttons = Qt::LeftButton;
+ else // 2 means RightButton
+ buttons = Qt::MouseButtons(buttonState);
+ break;
+ }
+
+#ifdef QT_DEBUG_ANDROID_STYLUS
+ qDebug() << action << pointerType << buttonState << "@" << x << y << "pressure" << pressure << ": buttons" << buttons;
+#endif
+
+ QWindowSystemInterface::handleTabletEvent(tlw, ulong(time),
+ localPos, globalPosF, QTabletEvent::Stylus, pointerType,
+ buttons, pressure, 0, 0, 0., 0., 0, deviceId, Qt::NoModifier);
+ }
+
static int mapAndroidKey(int key)
{
// 0--9 0x00000007 -- 0x00000010
@@ -702,6 +748,7 @@ namespace QtAndroidInput
{"mouseUp", "(III)V", (void *)mouseUp},
{"mouseMove", "(III)V", (void *)mouseMove},
{"longPress", "(III)V", (void *)longPress},
+ {"tabletEvent", "(IIJIIIFFF)V", (void *)tabletEvent},
{"keyDown", "(IIIZ)V", (void *)keyDown},
{"keyUp", "(IIIZ)V", (void *)keyUp},
{"keyboardVisibilityChanged", "(Z)V", (void *)keyboardVisibilityChanged}
diff --git a/src/plugins/platforms/android/androidplatformplugin.cpp b/src/plugins/platforms/android/androidplatformplugin.cpp
index ea7a3c397a..245691e79f 100644
--- a/src/plugins/platforms/android/androidplatformplugin.cpp
+++ b/src/plugins/platforms/android/androidplatformplugin.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QAndroidPlatformIntegrationPlugin: public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "android.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "android.json")
public:
QPlatformIntegration *create(const QString &key, const QStringList &paramList);
};
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index 88bc4a653a..5c8406ca03 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -176,6 +176,8 @@ static jstring getSelectedText(JNIEnv *env, jobject /*thiz*/, jint flags)
#ifdef QT_DEBUG_ANDROID_IM_PROTOCOL
qDebug() << "@@@ GETSEL" << text;
#endif
+ if (text.isEmpty())
+ return 0;
return env->NewString(reinterpret_cast<const jchar *>(text.constData()), jsize(text.length()));
}
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index ad6cb3a1fc..ba0e6b001a 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -12,7 +12,6 @@ OBJECTIVE_SOURCES += main.mm \
qcocoawindow.mm \
qnsview.mm \
qnsviewaccessibility.mm \
- qcocoaautoreleasepool.mm \
qnswindowdelegate.mm \
qcocoanativeinterface.mm \
qcocoaeventdispatcher.mm \
@@ -48,7 +47,6 @@ HEADERS += qcocoaintegration.h \
qcocoabackingstore.h \
qcocoawindow.h \
qnsview.h \
- qcocoaautoreleasepool.h \
qnswindowdelegate.h \
qcocoanativeinterface.h \
qcocoaeventdispatcher.h \
diff --git a/src/plugins/platforms/cocoa/main.mm b/src/plugins/platforms/cocoa/main.mm
index eed2ad7dc5..e6c1ed79b2 100644
--- a/src/plugins/platforms/cocoa/main.mm
+++ b/src/plugins/platforms/cocoa/main.mm
@@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE
class QCocoaIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "cocoa.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "cocoa.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&);
};
@@ -52,7 +52,7 @@ QPlatformIntegration * QCocoaIntegrationPlugin::create(const QString& system, co
{
Q_UNUSED(paramList);
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (system.compare(QLatin1String("cocoa"), Qt::CaseInsensitive) == 0)
return new QCocoaIntegration;
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
index 06e957cd86..d1d6330249 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.mm
+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
@@ -34,7 +34,6 @@
#include "qcocoacursor.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include <QtGui/QBitmap>
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index 050fade284..1865624d57 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -66,7 +66,6 @@
****************************************************************************/
#include "qcocoaeventdispatcher.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
@@ -364,7 +363,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
if (d->interrupt)
break;
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSEvent* event = 0;
// First, send all previously excluded input events, if any:
@@ -622,7 +621,7 @@ NSModalSession QCocoaEventDispatcherPrivate::currentModalSession()
continue;
if (!info.session) {
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(info.window->handle());
NSWindow *nswindow = cocoaWindow->nativeWindow();
if (!nswindow)
@@ -670,7 +669,7 @@ void QCocoaEventDispatcherPrivate::updateChildrenWorksWhenModal()
// Make the dialog children of the window
// active. And make the dialog children of
// the previous modal dialog unactive again:
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
int size = cocoaModalSessionStack.size();
if (size > 0){
if (QWindow *prevModal = cocoaModalSessionStack[size-1].window)
@@ -691,7 +690,7 @@ void QCocoaEventDispatcherPrivate::cleanupModalSessions()
// point they were marked as stopped), is that ending a session
// when no other session runs below it on the stack will make cocoa
// drop some events on the floor.
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
int stackSize = cocoaModalSessionStack.size();
for (int i=stackSize-1; i>=0; --i) {
@@ -926,7 +925,7 @@ void QCocoaEventDispatcherPrivate::cancelWaitForMoreEvents()
{
// In case the event dispatcher is waiting for more
// events somewhere, we post a dummy event to wake it up:
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
[NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint
modifierFlags:0 timestamp:0. windowNumber:0 context:0
subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
index 48d7efe174..36943a563e 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
@@ -51,6 +51,7 @@ public:
virtual ~QCocoaFileDialogHelper();
void exec();
+ void execModalForWindow(QWindow *parent);
bool defaultNameFilterDisables() const;
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index 4ece1b5a22..fad3f28053 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -53,7 +53,6 @@
#include <qvarlengtharray.h>
#include <stdlib.h>
#include <qabstracteventdispatcher.h>
-#include "qcocoaautoreleasepool.h"
#include <QDir>
#include <qpa/qplatformnativeinterface.h>
@@ -254,17 +253,22 @@ static QString strippedText(QString s)
|| [self panel:nil shouldShowFilename:filepath];
[self updateProperties];
- QCocoaMenuBar::redirectKnownMenuItemsToFirstResponder();
[mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]];
[mSavePanel setNameFieldStringValue:selectable ? QCFString::toNSString(info.fileName()) : @""];
NSWindow *nsparent = static_cast<NSWindow *>(qGuiApp->platformNativeInterface()->nativeResourceForWindow("nswindow", parent));
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
+ QCocoaMenuBar::redirectKnownMenuItemsToFirstResponder();
+
[mSavePanel beginSheetModalForWindow:nsparent completionHandler:^(NSInteger result){
- mReturnCode = result;
- if (mHelper)
- mHelper->QNSOpenSavePanelDelegate_panelClosed(result == NSOKButton);
+ [[NSApplication sharedApplication] stopModalWithCode:result];
}];
+
+ mReturnCode = [[NSApplication sharedApplication] runModalForWindow:nsparent];
+ QAbstractEventDispatcher::instance()->interrupt();
+ if (mHelper)
+ mHelper->QNSOpenSavePanelDelegate_panelClosed(mReturnCode == NSOKButton);
}
- (BOOL)isHiddenFile:(NSString *)filename isDir:(BOOL)isDir
@@ -557,7 +561,7 @@ QCocoaFileDialogHelper::~QCocoaFileDialogHelper()
{
if (!mDelegate)
return;
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
[mDelegate release];
mDelegate = 0;
}
@@ -687,7 +691,7 @@ bool QCocoaFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit
void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
const SharedPointerFileDialogOptions &opts = options();
const QList<QUrl> selectedFiles = opts->initiallySelectedFiles();
@@ -706,14 +710,15 @@ void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate()
bool QCocoaFileDialogHelper::showCocoaFilePanel(Qt::WindowModality windowModality, QWindow *parent)
{
+ Q_UNUSED(parent)
+
createNSOpenSavePanelDelegate();
if (!mDelegate)
return false;
if (windowModality == Qt::NonModal)
[mDelegate showModelessPanel];
- else if (windowModality == Qt::WindowModal && parent)
- [mDelegate showWindowModalSheet:parent];
- // no need to show a Qt::ApplicationModal dialog here, since it will be done in _q_platformRunNativeAppModalPanel()
+ // no need to show a Qt::ApplicationModal dialog here, since it will be done in exec;
+ // Qt::WindowModal will be done in execModalForWindow.
return true;
}
@@ -737,7 +742,7 @@ void QCocoaFileDialogHelper::exec()
// QEventLoop has been interrupted, and the second-most event loop has not
// yet been reactivated (regardless if [NSApp run] is still on the stack)),
// showing a native modal dialog will fail.
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if ([mDelegate runApplicationModalPanel])
emit accept();
else
@@ -745,6 +750,14 @@ void QCocoaFileDialogHelper::exec()
}
+void QCocoaFileDialogHelper::execModalForWindow(QWindow *parent)
+{
+ if (!parent)
+ return exec();
+
+ [mDelegate showWindowModalSheet:parent];
+}
+
bool QCocoaFileDialogHelper::defaultNameFilterDisables() const
{
return true;
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index a3c72c58b9..1d8a1c5e70 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -33,7 +33,6 @@
#include "qcocoaglcontext.h"
#include "qcocoawindow.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoahelpers.h"
#include <qdebug.h>
#include <QtCore/private/qcore_mac_p.h>
@@ -145,7 +144,7 @@ QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLCo
if (m_format.renderableType() != QSurfaceFormat::OpenGL)
return;
- QCocoaAutoReleasePool pool; // For the SG Canvas render thread
+ QMacAutoReleasePool pool; // For the SG Canvas render thread
NSOpenGLPixelFormat *pixelFormat = static_cast <NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat(m_format));
m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nsOpenGLContext() : nil;
@@ -218,7 +217,7 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
{
Q_ASSERT(surface->surface()->supportsOpenGL());
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
setActiveWindow(window);
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index a84c0c0f2a..c2f0c730fe 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -33,7 +33,6 @@
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include <QtCore>
#include <QtGui>
@@ -630,7 +629,7 @@ QString qt_mac_applicationName()
int qt_mac_mainScreenHeight()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
// The first screen in the screens array is documented
// to have the (0,0) origin.
NSRect screenFrame = [[[NSScreen screens] firstObject] frame];
diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.mm b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
index c22fe8774b..f072991bdd 100644
--- a/src/plugins/platforms/cocoa/qcocoainputcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
@@ -34,7 +34,6 @@
#include "qnsview.h"
#include "qcocoainputcontext.h"
#include "qcocoanativeinterface.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoawindow.h"
#include <QtCore/QRect>
@@ -98,7 +97,7 @@ void QCocoaInputContext::reset()
if (!view)
return;
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (NSTextInputContext *ctxt = [NSTextInputContext currentInputContext]) {
[ctxt discardMarkedText];
[view unmarkText];
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index ee42a83446..cc235135f1 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -36,7 +36,6 @@
#include <Cocoa/Cocoa.h>
-#include "qcocoaautoreleasepool.h"
#include "qcocoacursor.h"
#include "qcocoawindow.h"
#include "qcocoanativeinterface.h"
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index c8f6dd05db..04d5769044 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -33,7 +33,6 @@
#include "qcocoaintegration.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoawindow.h"
#include "qcocoabackingstore.h"
#include "qcocoanativeinterface.h"
@@ -137,7 +136,7 @@ void QCocoaScreen::updateGeometry()
qreal QCocoaScreen::devicePixelRatio() const
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSScreen * screen = osScreen();
return qreal(screen ? [screen backingScaleFactor] : 1.0);
}
@@ -263,7 +262,7 @@ QCocoaIntegration::QCocoaIntegration()
mInstance = this;
initResources();
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
qApp->setAttribute(Qt::AA_DontUseNativeMenuBar, false);
@@ -314,7 +313,7 @@ QCocoaIntegration::~QCocoaIntegration()
qt_resetNSApplicationSendEvent();
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) {
// remove the apple event handlers installed by QCocoaApplicationDelegate
QCocoaApplicationDelegate *delegate = [QCocoaApplicationDelegate sharedDelegate];
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index 09a4c95469..eb231f064e 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -34,7 +34,6 @@
#include "qcocoamenu.h"
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include <QtCore/QtDebug>
#include <QtCore/qmetaobject.h>
@@ -81,7 +80,7 @@ QT_END_NAMESPACE
}
- (id) initWithMenu:(QCocoaMenu*) m;
-- (BOOL)hasShortcut:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteger)modifier;
+- (NSMenuItem *)findItem:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteger)modifier;
@end
@@ -152,11 +151,20 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate);
// Change the private unicode keys to the ones used in setting the "Key Equivalents"
NSString *characters = qt_mac_removePrivateUnicode([event characters]);
- if ([self hasShortcut:menu
- forKey:characters
- // Interested only in Shift, Cmd, Ctrl & Alt Keys, so ignoring masks like, Caps lock, Num Lock ...
- forModifiers:([event modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | NSCommandKeyMask | NSAlternateKeyMask))
- ]) {
+ // Interested only in Shift, Cmd, Ctrl & Alt Keys, so ignoring masks like, Caps lock, Num Lock ...
+ const NSUInteger mask = NSShiftKeyMask | NSControlKeyMask | NSCommandKeyMask | NSAlternateKeyMask;
+ if (NSMenuItem *menuItem = [self findItem:menu forKey:characters forModifiers:([event modifierFlags] & mask)]) {
+ if (!menuItem.target) {
+ // This item was modified by QCocoaMenuBar::redirectKnownMenuItemsToFirstResponder
+ // and it looks like we're running a modal session for NSOpenPanel/NSSavePanel.
+ // QCocoaFileDialogHelper is actually the only place we use this and we run NSOpenPanel modal
+ // (modal sheet, window modal, application modal).
+ // Whatever the current first responder is, let's give it a chance
+ // and do not touch the Qt's focusObject (which is different from some native view
+ // having a focus inside NSSave/OpenPanel.
+ return YES;
+ }
+
QObject *object = qApp->focusObject();
if (object) {
QChar ch;
@@ -194,22 +202,23 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate);
return NO;
}
-- (BOOL)hasShortcut:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteger)modifier
+- (NSMenuItem *)findItem:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteger)modifier
{
for (NSMenuItem *item in [menu itemArray]) {
if (![item isEnabled] || [item isHidden] || [item isSeparatorItem])
continue;
- if ([item hasSubmenu]
- && [self hasShortcut:[item submenu] forKey:key forModifiers:modifier])
- return YES;
+ if ([item hasSubmenu]) {
+ if (NSMenuItem *nested = [self findItem:[item submenu] forKey:key forModifiers:modifier])
+ return nested;
+ }
NSString *menuKey = [item keyEquivalent];
if (menuKey
&& NSOrderedSame == [menuKey compare:key]
&& modifier == [item keyEquivalentModifierMask])
- return YES;
+ return item;
}
- return NO;
+ return nil;
}
@end
@@ -223,7 +232,7 @@ QCocoaMenu::QCocoaMenu() :
m_menuBar(0),
m_containingMenuItem(0)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
m_delegate = [[QCocoaMenuDelegate alloc] initWithMenu:this];
m_nativeItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
@@ -243,7 +252,7 @@ QCocoaMenu::~QCocoaMenu()
if (m_containingMenuItem)
m_containingMenuItem->clearMenu(this);
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
[m_nativeItem setSubmenu:nil];
[m_nativeMenu release];
[m_delegate release];
@@ -252,7 +261,7 @@ QCocoaMenu::~QCocoaMenu()
void QCocoaMenu::setText(const QString &text)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QString stripped = qt_mac_removeAmpersandEscapes(text);
[m_nativeMenu setTitle:QCFString::toNSString(stripped)];
[m_nativeItem setTitle:QCFString::toNSString(stripped)];
@@ -274,7 +283,7 @@ void QCocoaMenu::setFont(const QFont &font)
void QCocoaMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
QCocoaMenuItem *beforeItem = static_cast<QCocoaMenuItem *>(before);
@@ -328,7 +337,7 @@ void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem)
void QCocoaMenu::removeMenuItem(QPlatformMenuItem *menuItem)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
if (!m_menuItems.contains(cocoaItem)) {
qWarning() << Q_FUNC_INFO << "Menu does not contain the item to be removed";
@@ -358,7 +367,7 @@ QCocoaMenuItem *QCocoaMenu::itemOrNull(int index) const
void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
if (!m_menuItems.contains(cocoaItem)) {
qWarning() << Q_FUNC_INFO << "Item does not belong to this menu";
@@ -387,7 +396,7 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
void QCocoaMenu::syncSeparatorsCollapsible(bool enable)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (enable) {
bool previousIsSeparator = true; // setting to true kills all the separators placed at the top.
NSMenuItem *previousItem = nil;
@@ -445,7 +454,7 @@ void QCocoaMenu::setVisible(bool visible)
void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QPoint pos = QPoint(targetRect.left(), targetRect.top() + targetRect.height());
QCocoaWindow *cocoaWindow = parentWindow ? static_cast<QCocoaWindow *>(parentWindow->handle()) : 0;
@@ -550,7 +559,7 @@ QList<QCocoaMenuItem *> QCocoaMenu::merged() const
void QCocoaMenu::syncModalState(bool modal)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (!m_enabled)
modal = true;
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index 7c902a0e53..7775cdbde6 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -37,7 +37,6 @@
#include "qcocoawindow.h"
#include "qcocoamenuloader.h"
#include "qcocoaapplication.h" // for custom application category
-#include "qcocoaautoreleasepool.h"
#include "qcocoaapplicationdelegate.h"
#include <QtGui/QGuiApplication>
@@ -84,7 +83,7 @@ QCocoaMenuBar::~QCocoaMenuBar()
void QCocoaMenuBar::insertNativeMenu(QCocoaMenu *menu, QCocoaMenu *beforeMenu)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (beforeMenu) {
NSUInteger nativeIndex = [m_nativeMenu indexOfItem:beforeMenu->nsMenuItem()];
@@ -127,7 +126,7 @@ void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *befor
void QCocoaMenuBar::removeNativeMenu(QCocoaMenu *menu)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (menu->menuBar() == this)
menu->setMenuBar(0);
@@ -148,7 +147,7 @@ void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu)
void QCocoaMenuBar::syncMenu(QPlatformMenu *menu)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenu *cocoaMenu = static_cast<QCocoaMenu *>(menu);
Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items())
@@ -261,7 +260,7 @@ void QCocoaMenuBar::resetKnownMenuItemsToQt()
void QCocoaMenuBar::updateMenuBarImmediately()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenuBar *mb = findGlobalMenubar();
QCocoaWindow *cw = findWindowForMenubar();
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
index f288ab85c0..942fc8db21 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -37,7 +37,6 @@
#include "qcocoamenubar.h"
#include "messages.h"
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include "qt_mac_p.h"
#include "qcocoaapplication.h" // for custom application category
#include "qcocoamenuloader.h"
@@ -104,7 +103,7 @@ QCocoaMenuItem::QCocoaMenuItem() :
QCocoaMenuItem::~QCocoaMenuItem()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (m_menu && COCOA_MENU_ANCESTOR(m_menu) == this)
SET_COCOA_MENU_ANCESTOR(m_menu, 0);
@@ -139,7 +138,7 @@ void QCocoaMenuItem::setMenu(QPlatformMenu *menu)
m_menu->setContainingMenuItem(0);
}
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
m_menu = static_cast<QCocoaMenu *>(menu);
if (m_menu) {
SET_COCOA_MENU_ANCESTOR(m_menu, this);
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index 205a49d25a..c8b54c9224 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -234,7 +234,7 @@ void QCocoaNativeInterface::registerDraggedTypes(const QStringList &types)
void QCocoaNativeInterface::setDockMenu(QPlatformMenu *platformMenu)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaMenu *cocoaPlatformMenu = static_cast<QCocoaMenu *>(platformMenu);
NSMenu *menu = cocoaPlatformMenu->nsMenu();
[NSApp QT_MANGLE_NAMESPACE(qt_setDockMenu): menu];
diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.h b/src/plugins/platforms/cocoa/qcocoaprintdevice.h
index 2133900048..3ac112781f 100644
--- a/src/plugins/platforms/cocoa/qcocoaprintdevice.h
+++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.h
@@ -60,13 +60,8 @@ class QCocoaPrintDevice : public QPlatformPrintDevice
public:
QCocoaPrintDevice();
explicit QCocoaPrintDevice(const QString &id);
- QCocoaPrintDevice(const QCocoaPrintDevice &other);
virtual ~QCocoaPrintDevice();
- QCocoaPrintDevice *clone();
-
- bool operator==(const QCocoaPrintDevice &other) const;
-
bool isValid() const Q_DECL_OVERRIDE;
bool isDefault() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
index b92ec31a11..4d319e149b 100644
--- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
+++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
@@ -96,24 +96,6 @@ QCocoaPrintDevice::QCocoaPrintDevice(const QString &id)
}
}
-QCocoaPrintDevice::QCocoaPrintDevice(const QCocoaPrintDevice &other)
- : QPlatformPrintDevice(other),
- m_printer(0),
- m_session(0),
- m_ppd(0)
-{
- m_printer = other.m_printer;
- PMRetain(m_printer);
- m_session = other.m_session;
- PMRetain(m_session);
- m_macPapers = other.m_macPapers;
- foreach (PMPaper paper, m_macPapers.values())
- PMRetain(paper);
- openPpdFile();
- m_customMargins = other.m_customMargins;
- m_printableMargins = other.m_printableMargins;
-}
-
QCocoaPrintDevice::~QCocoaPrintDevice()
{
if (m_ppd)
@@ -127,16 +109,6 @@ QCocoaPrintDevice::~QCocoaPrintDevice()
PMRelease(m_printer);
}
-QCocoaPrintDevice *QCocoaPrintDevice::clone()
-{
- return new QCocoaPrintDevice(*this);
-}
-
-bool QCocoaPrintDevice::operator==(const QCocoaPrintDevice &other) const
-{
- return (m_id == other.m_id);
-}
-
bool QCocoaPrintDevice::isValid() const
{
return m_printer ? true : false;
diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
index 65cc9bc38b..93f8b2ba6f 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
@@ -33,7 +33,6 @@
#include "qcocoasystemsettings.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoahelpers.h"
#include <QtCore/private/qcore_mac_p.h>
@@ -45,7 +44,7 @@ QT_BEGIN_NAMESPACE
QColor qt_mac_colorForTheme(ThemeBrush brush)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCFType<CGColorRef> cgClr = 0;
HIThemeBrushCreateCGColor(brush, &cgClr);
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
index b5f038094f..b5f038094f 100755..100644
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
index f50f552623..f50f552623 100755..100644
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index 11749e14de..4b73d0af08 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -47,7 +47,6 @@
#include "qcocoamenu.h"
#include "qcocoamenubar.h"
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include <QtCore/qfileinfo.h>
#include <QtGui/private/qguiapplication_p.h>
@@ -253,7 +252,7 @@ QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &siz
QPlatformTheme::IconOptions iconOptions) const
{
Q_UNUSED(iconOptions);
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:QCFString::toNSString(fileInfo.canonicalFilePath())];
if (!iconImage)
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index fba97c2629..e2ab71a890 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -245,6 +245,8 @@ public: // for QNSView
friend class QCocoaBackingStore;
friend class QCocoaNativeInterface;
+ void removeMonitor();
+
NSView *m_contentView;
QNSView *m_qtView;
QCocoaNSWindow *m_nsWindow;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 0c1da59748..c61d6580fa 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -33,7 +33,6 @@
#include "qcocoawindow.h"
#include "qcocoaintegration.h"
#include "qnswindowdelegate.h"
-#include "qcocoaautoreleasepool.h"
#include "qcocoaeventdispatcher.h"
#ifndef QT_NO_OPENGL
#include "qcocoaglcontext.h"
@@ -374,7 +373,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
qDebug() << "QCocoaWindow::QCocoaWindow" << this;
#endif
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (tlw->type() == Qt::ForeignWindow) {
NSView *foreignView = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>());
@@ -410,16 +409,18 @@ QCocoaWindow::~QCocoaWindow()
qDebug() << "QCocoaWindow::~QCocoaWindow" << this;
#endif
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
[m_nsWindow setContentView:nil];
[m_nsWindow.helper detachFromPlatformWindow];
if (m_isNSWindowChild) {
if (m_parentCocoaWindow)
m_parentCocoaWindow->removeChildWindow(this);
- } else if (parent()) {
+ } else if ([m_contentView superview]) {
[m_contentView removeFromSuperview];
}
+ removeMonitor();
+
// Make sure to disconnect observer in all case if view is valid
// to avoid notifications received when deleting when using Qt::AA_NativeWindows attribute
if (m_qtView) {
@@ -436,7 +437,9 @@ QCocoaWindow::~QCocoaWindow()
// While it is unlikely that this window will be in the popup stack
// during deletetion we clear any pointers here to make sure.
- QCocoaIntegration::instance()->popupWindowStack()->removeAll(this);
+ if (QCocoaIntegration::instance()) {
+ QCocoaIntegration::instance()->popupWindowStack()->removeAll(this);
+ }
foreach (QCocoaWindow *child, m_childWindows) {
[m_nsWindow removeChildWindow:child->m_nsWindow];
@@ -450,7 +453,13 @@ QCocoaWindow::~QCocoaWindow()
QSurfaceFormat QCocoaWindow::format() const
{
- return window()->requestedFormat();
+ QSurfaceFormat format = window()->requestedFormat();
+
+ // Upgrade the default surface format to include an alpha channel. The default RGB format
+ // causes Cocoa to spend an unreasonable amount of time converting it to RGBA internally.
+ if (format == QSurfaceFormat())
+ format.setAlphaBufferSize(8);
+ return format;
}
void QCocoaWindow::setGeometry(const QRect &rectIn)
@@ -492,7 +501,7 @@ QRect QCocoaWindow::geometry() const
void QCocoaWindow::setCocoaGeometry(const QRect &rect)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (m_contentViewIsEmbedded) {
QPlatformWindow::setGeometry(rect);
@@ -616,7 +625,7 @@ void QCocoaWindow::setVisible(bool visible)
m_inSetVisible = true;
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QCocoaWindow *parentCocoaWindow = 0;
if (window()->transientParent())
parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
@@ -689,8 +698,11 @@ void QCocoaWindow::setVisible(bool visible)
&& [m_nsWindow isKindOfClass:[NSPanel class]]) {
[(NSPanel *)m_nsWindow setWorksWhenModal:YES];
if (!(parentCocoaWindow && window()->transientParent()->isActive()) && window()->type() == Qt::Popup) {
- monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask|NSRightMouseDownMask|NSOtherMouseDown handler:^(NSEvent *) {
- QWindowSystemInterface::handleMouseEvent(window(), QPointF(-1, -1), QPointF(window()->framePosition() - QPointF(1, 1)), Qt::LeftButton);
+ removeMonitor();
+ monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask|NSRightMouseDownMask|NSOtherMouseDownMask|NSMouseMovedMask handler:^(NSEvent *e) {
+ QPointF localPoint = qt_mac_flipPoint([NSEvent mouseLocation]);
+ QWindowSystemInterface::handleMouseEvent(window(), window()->mapFromGlobal(localPoint.toPoint()), localPoint,
+ cocoaButton2QtButton([e buttonNumber]));
}];
}
}
@@ -735,10 +747,7 @@ void QCocoaWindow::setVisible(bool visible)
} else {
[m_contentView setHidden:YES];
}
- if (monitor && window()->type() == Qt::Popup) {
- [NSEvent removeMonitor:monitor];
- monitor = nil;
- }
+ removeMonitor();
if (window()->type() == Qt::Popup)
QCocoaIntegration::instance()->popupWindowStack()->removeAll(this);
@@ -790,9 +799,22 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags)
if (flags & Qt::FramelessWindowHint)
return styleMask;
if ((type & Qt::Popup) == Qt::Popup) {
- if (!windowIsPopupType(type))
- styleMask = (NSUtilityWindowMask | NSResizableWindowMask | NSClosableWindowMask |
- NSMiniaturizableWindowMask | NSTitledWindowMask);
+ if (!windowIsPopupType(type)) {
+ styleMask = NSUtilityWindowMask;
+ if (!(flags & Qt::CustomizeWindowHint)) {
+ styleMask |= NSResizableWindowMask | NSClosableWindowMask |
+ NSMiniaturizableWindowMask | NSTitledWindowMask;
+ } else {
+ if (flags & Qt::WindowMaximizeButtonHint)
+ styleMask |= NSResizableWindowMask;
+ if (flags & Qt::WindowTitleHint)
+ styleMask |= NSTitledWindowMask;
+ if (flags & Qt::WindowCloseButtonHint)
+ styleMask |= NSClosableWindowMask;
+ if (flags & Qt::WindowMinimizeButtonHint)
+ styleMask |= NSMiniaturizableWindowMask;
+ }
+ }
} else {
if (type == Qt::Window && !(flags & Qt::CustomizeWindowHint)) {
styleMask = (NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTitledWindowMask);
@@ -887,7 +909,7 @@ void QCocoaWindow::setWindowState(Qt::WindowState state)
void QCocoaWindow::setWindowTitle(const QString &title)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (!m_nsWindow)
return;
@@ -898,7 +920,7 @@ void QCocoaWindow::setWindowTitle(const QString &title)
void QCocoaWindow::setWindowFilePath(const QString &filePath)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (!m_nsWindow)
return;
@@ -908,7 +930,7 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath)
void QCocoaWindow::setWindowIcon(const QIcon &icon)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSButton *iconButton = [m_nsWindow standardWindowButton:NSWindowDocumentIconButton];
if (iconButton == nil) {
@@ -1026,7 +1048,7 @@ bool QCocoaWindow::isOpaque() const
void QCocoaWindow::propagateSizeHints()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
if (!m_nsWindow)
return;
@@ -1237,7 +1259,9 @@ QCocoaGLContext *QCocoaWindow::currentContext() const
void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
{
bool wasNSWindowChild = m_isNSWindowChild;
- m_isNSWindowChild = parentWindow && (window()->property("_q_platform_MacUseNSWindow").toBool());
+ BOOL requestNSWindowChild = qt_mac_resolveOption(NO, window(), "_q_platform_MacUseNSWindow",
+ "QT_MAC_USE_NSWINDOW");
+ m_isNSWindowChild = parentWindow && requestNSWindowChild;
bool needsNSWindow = m_isNSWindowChild || !parentWindow;
QCocoaWindow *oldParentCocoaWindow = m_parentCocoaWindow;
@@ -1368,7 +1392,7 @@ bool QCocoaWindow::shouldUseNSPanel()
QCocoaNSWindow * QCocoaWindow::createNSWindow()
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QRect rect = initialGeometry(window(), windowGeometry(), defaultWindowWidth, defaultWindowHeight);
NSRect frame = qt_mac_flipRect(rect);
@@ -1457,6 +1481,14 @@ void QCocoaWindow::removeChildWindow(QCocoaWindow *child)
[m_nsWindow removeChildWindow:child->m_nsWindow];
}
+void QCocoaWindow::removeMonitor()
+{
+ if (!monitor)
+ return;
+ [NSEvent removeMonitor:monitor];
+ monitor = nil;
+}
+
// Returns the current global screen geometry for the nswindow associated with this window.
QRect QCocoaWindow::windowGeometry() const
{
diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm
index 3d88a8d5df..f4fd32ffd1 100644
--- a/src/plugins/platforms/cocoa/qmacclipboard.mm
+++ b/src/plugins/platforms/cocoa/qmacclipboard.mm
@@ -43,7 +43,6 @@
#include <stdlib.h>
#include <string.h>
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
QT_BEGIN_NAMESPACE
@@ -555,7 +554,7 @@ QMacPasteboard::sync() const
QString qt_mac_get_pasteboardString(PasteboardRef paste)
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSPasteboard *pb = nil;
CFStringRef pbname;
if (PasteboardCopyName(paste, &pbname) == noErr) {
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 3c12228ef6..c71c9f0680 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -39,7 +39,6 @@
#include "qnsview.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
-#include "qcocoaautoreleasepool.h"
#include "qmultitouch_mac_p.h"
#include "qcocoadrag.h"
#include <qpa/qplatformintegration.h>
@@ -849,7 +848,7 @@ QT_WARNING_POP
{
[super updateTrackingAreas];
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
// NSTrackingInVisibleRect keeps care of updating once the tracking is set up, so bail out early
if (m_trackingArea && [[self trackingAreas] containsObject:m_trackingArea])
@@ -1786,7 +1785,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
-(void)registerDragTypes
{
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
QStringList customTypes = qt_mac_enabledDraggedTypes();
if (currentCustomDragTypes == 0 || *currentCustomDragTypes != customTypes) {
if (currentCustomDragTypes == 0)
@@ -1850,41 +1849,9 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
return NO;
}
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
+- (void)updateCursorFromDragResponse:(QPlatformDragQtResponse)response drag:(QCocoaDrag *)drag
{
- return [self handleDrag : sender];
-}
-
-- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
-{
- return [self handleDrag : sender];
-}
-
-// Sends drag update to Qt, return the action
-- (NSDragOperation)handleDrag:(id <NSDraggingInfo>)sender
-{
- NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil];
- QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
- Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]);
-
- QWindow *target = findEventTargetWindow(m_window);
- if (!target)
- return NSDragOperationNone;
-
- // update these so selecting move/copy/link works
- QGuiApplicationPrivate::modifier_buttons = [QNSView convertKeyModifiers: [[NSApp currentEvent] modifierFlags]];
-
- QPlatformDragQtResponse response(false, Qt::IgnoreAction, QRect());
- if ([sender draggingSource] != nil) {
- QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
- response = QWindowSystemInterface::handleDrag(target, nativeDrag->platformDropData(), mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed);
- } else {
- QCocoaDropData mimeData([sender draggingPasteboard]);
- response = QWindowSystemInterface::handleDrag(target, &mimeData, mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed);
- }
-
- QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
- const QPixmap pixmapCursor = nativeDrag->currentDrag()->dragCursor(response.acceptedAction());
+ const QPixmap pixmapCursor = drag->currentDrag()->dragCursor(response.acceptedAction());
NSCursor *nativeCursor = nil;
if (pixmapCursor.isNull()) {
@@ -1924,6 +1891,41 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
));
CGEventPost(kCGHIDEventTap, moveEvent);
CFRelease(moveEvent);
+}
+
+- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
+{
+ return [self handleDrag : sender];
+}
+
+- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
+{
+ return [self handleDrag : sender];
+}
+
+// Sends drag update to Qt, return the action
+- (NSDragOperation)handleDrag:(id <NSDraggingInfo>)sender
+{
+ NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil];
+ QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
+ Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]);
+
+ QWindow *target = findEventTargetWindow(m_window);
+ if (!target)
+ return NSDragOperationNone;
+
+ // update these so selecting move/copy/link works
+ QGuiApplicationPrivate::modifier_buttons = [QNSView convertKeyModifiers: [[NSApp currentEvent] modifierFlags]];
+
+ QPlatformDragQtResponse response(false, Qt::IgnoreAction, QRect());
+ if ([sender draggingSource] != nil) {
+ QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
+ response = QWindowSystemInterface::handleDrag(target, nativeDrag->platformDropData(), mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed);
+ [self updateCursorFromDragResponse:response drag:nativeDrag];
+ } else {
+ QCocoaDropData mimeData([sender draggingPasteboard]);
+ response = QWindowSystemInterface::handleDrag(target, &mimeData, mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed);
+ }
return qt_mac_mapDropAction(response.acceptedAction());
}
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index 56fc720a83..d4552eade4 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -38,7 +38,6 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
-#include "qcocoaautoreleasepool.h"
#ifndef QT_NO_PRINTER
@@ -50,7 +49,7 @@ QMacPrintEngine::QMacPrintEngine(QPrinter::PrinterMode mode) : QPaintEngine(*(ne
{
Q_D(QMacPrintEngine);
d->mode = mode;
- d->m_printDevice = new QCocoaPrintDevice(QCocoaPrinterSupport().defaultPrintDeviceId());
+ d->m_printDevice.reset(new QCocoaPrintDevice(QCocoaPrinterSupport().defaultPrintDeviceId()));
d->m_pageLayout.setPageSize(d->m_printDevice->defaultPageSize());
d->initialize();
}
@@ -233,7 +232,7 @@ void QMacPrintEnginePrivate::initialize()
q->gccaps = paintEngine->gccaps;
- QCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
printInfo = [[NSPrintInfo alloc] initWithDictionary:[NSDictionary dictionary]];
QList<int> resolutions = m_printDevice->supportedResolutions();
@@ -561,7 +560,7 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
id = QCocoaPrinterSupport().defaultPrintDeviceId();
else if (!QCocoaPrinterSupport().availablePrintDeviceIds().contains(id))
break;
- d->m_printDevice = new QCocoaPrintDevice(id);
+ d->m_printDevice.reset(new QCocoaPrintDevice(id));
PMPrinter printer = d->m_printDevice->macPrinter();
PMRetain(printer);
PMSessionSetCurrentPMPrinter(d->session(), printer);
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac_p.h b/src/plugins/platforms/cocoa/qprintengine_mac_p.h
index 6a795a55d8..494fb5b9d1 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac_p.h
+++ b/src/plugins/platforms/cocoa/qprintengine_mac_p.h
@@ -116,7 +116,7 @@ class QMacPrintEnginePrivate : public QPaintEnginePrivate
public:
QPrinter::PrinterMode mode;
QPrinter::PrinterState state;
- QSharedDataPointer<QCocoaPrintDevice> m_printDevice;
+ QSharedPointer<QCocoaPrintDevice> m_printDevice;
QPageLayout m_pageLayout;
NSPrintInfo *printInfo;
PMResolution resolution;
diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h
index e210f0221f..576e0f9729 100644
--- a/src/plugins/platforms/cocoa/qt_mac_p.h
+++ b/src/plugins/platforms/cocoa/qt_mac_p.h
@@ -103,17 +103,6 @@ public:
}
};
-class Q_WIDGETS_EXPORT QMacCocoaAutoReleasePool
-{
-private:
- void *pool;
-public:
- QMacCocoaAutoReleasePool();
- ~QMacCocoaAutoReleasePool();
-
- inline void *handle() const { return pool; }
-};
-
QString qt_mac_removeMnemonics(const QString &original); //implemented in qmacstyle_mac.cpp
class Q_WIDGETS_EXPORT QMacWindowChangeEvent
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
index d439196dc1..16c05329de 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp
@@ -358,10 +358,10 @@ public:
} else if (path.isRect() && (q->state()->matrix.type() <= QTransform::TxScale)) {
const qreal * const points = path.points();
D2D_RECT_F rect = {
- points[0], // left
- points[1], // top
- points[2], // right,
- points[5] // bottom
+ FLOAT(points[0]), // left
+ FLOAT(points[1]), // top
+ FLOAT(points[2]), // right,
+ FLOAT(points[5]) // bottom
};
dc()->PushAxisAlignedClip(rect, antialiasMode());
@@ -918,13 +918,13 @@ public:
DWRITE_GLYPH_RUN glyphRun = {
fontFace, // IDWriteFontFace *fontFace;
- fontDef.pixelSize, // FLOAT fontEmSize;
- numGlyphs, // UINT32 glyphCount;
+ FLOAT(fontDef.pixelSize), // FLOAT fontEmSize;
+ UINT32(numGlyphs), // UINT32 glyphCount;
glyphIndices, // const UINT16 *glyphIndices;
glyphAdvances, // const FLOAT *glyphAdvances;
glyphOffsets, // const DWRITE_GLYPH_OFFSET *glyphOffsets;
FALSE, // BOOL isSideways;
- rtl ? 1 : 0 // UINT32 bidiLevel;
+ rtl ? 1u : 0u // UINT32 bidiLevel;
};
const bool antiAlias = bool((q->state()->renderHints & QPainter::TextAntialiasing)
@@ -1393,8 +1393,8 @@ void QWindowsDirect2DPaintEngine::drawEllipse(const QRectF &r)
D2D1_ELLIPSE ellipse = {
to_d2d_point_2f(p),
- r.width() / 2.0,
- r.height() / 2.0
+ FLOAT(r.width() / 2.0),
+ FLOAT(r.height() / 2.0)
};
if (d->brush.brush)
@@ -1421,8 +1421,8 @@ void QWindowsDirect2DPaintEngine::drawEllipse(const QRect &r)
D2D1_ELLIPSE ellipse = {
to_d2d_point_2f(p),
- r.width() / 2.0,
- r.height() / 2.0
+ FLOAT(r.width() / 2.0),
+ FLOAT(r.height() / 2.0)
};
if (d->brush.brush)
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dplatformplugin.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dplatformplugin.cpp
index ab4be67bbe..e4cc163b9e 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dplatformplugin.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dplatformplugin.cpp
@@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE
class QWindowsDirect2DIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "direct2d.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "direct2d.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&);
};
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
index e762eab711..ba23526447 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
@@ -163,7 +163,7 @@ void QWindowsDirect2DWindow::present(const QRegion &region)
const SIZE size = { bounds.width(), bounds.height() };
const POINT ptDst = { bounds.x(), bounds.y() };
const POINT ptSrc = { 0, 0 };
- const BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255.0 * opacity(), AC_SRC_ALPHA };
+ const BLENDFUNCTION blend = { AC_SRC_OVER, 0, BYTE(255.0 * opacity()), AC_SRC_ALPHA };
const QRect r = region.boundingRect();
const RECT dirty = { r.left(), r.top(), r.left() + r.width(), r.top() + r.height() };
UPDATELAYEREDWINDOWINFO info = { sizeof(UPDATELAYEREDWINDOWINFO), NULL,
diff --git a/src/plugins/platforms/directfb/main.cpp b/src/plugins/platforms/directfb/main.cpp
index 3faa7c9a8b..4308a164ae 100644
--- a/src/plugins/platforms/directfb/main.cpp
+++ b/src/plugins/platforms/directfb/main.cpp
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
class QDirectFbIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "directfb.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "directfb.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&);
};
diff --git a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp
index e635d4fd22..e1d97d9628 100644
--- a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp
@@ -217,7 +217,7 @@ Qt::KeyboardModifiers QDirectFbConvenience::keyboardModifiers(DFBInputDeviceModi
modifiers |= Qt::ControlModifier;
}
if (mask & DIMM_META) {
- modifiers | Qt::MetaModifier;
+ modifiers |= Qt::MetaModifier;
}
return modifiers;
}
diff --git a/src/plugins/platforms/eglfs/cursor-atlas.png b/src/plugins/platforms/eglfs/cursor-atlas.png
index 40c5b6ef4f..40c5b6ef4f 100755..100644
--- a/src/plugins/platforms/eglfs/cursor-atlas.png
+++ b/src/plugins/platforms/eglfs/cursor-atlas.png
Binary files differ
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp
index cd92c49ff1..fe47c947b4 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -87,8 +88,11 @@ QEglFSKmsCursor::QEglFSKmsCursor(QEglFSKmsScreen *screen)
QEglFSKmsCursor::~QEglFSKmsCursor()
{
- drmModeSetCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0, 0);
- drmModeMoveCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0);
+ Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) {
+ QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen);
+ drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0);
+ drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0);
+ }
gbm_bo_destroy(m_bo);
m_bo = Q_NULLPTR;
@@ -143,10 +147,15 @@ void QEglFSKmsCursor::changeCursor(QCursor *windowCursor, QWindow *window)
gbm_bo_write(m_bo, cursorImage.constBits(), cursorImage.byteCount());
uint32_t handle = gbm_bo_get_handle(m_bo).u32;
- int status = drmModeSetCursor(m_screen->device()->fd(), m_screen->output().crtc_id, handle,
- m_cursorSize.width(), m_cursorSize.height());
- if (status != 0)
- qWarning("Could not set cursor: %d", status);
+
+ Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) {
+ QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen);
+
+ int status = drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, handle,
+ m_cursorSize.width(), m_cursorSize.height());
+ if (status != 0)
+ qWarning("Could not set cursor on screen %s: %d", kmsScreen->name().toLatin1().constData(), status);
+ }
}
#endif // QT_NO_CURSOR
@@ -157,12 +166,17 @@ QPoint QEglFSKmsCursor::pos() const
void QEglFSKmsCursor::setPos(const QPoint &pos)
{
- QPoint adjustedPos = pos - m_cursorImage.hotspot();
- int ret = drmModeMoveCursor(m_screen->device()->fd(), m_screen->output().crtc_id, adjustedPos.x(), adjustedPos.y());
- if (ret == 0) {
- m_pos = pos;
- } else {
- qWarning("Failed to move cursor: %d", ret);
+ Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) {
+ QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen);
+ QPoint origin = kmsScreen->geometry().topLeft();
+ QPoint localPos = pos - origin;
+ QPoint adjustedPos = localPos - m_cursorImage.hotspot();
+
+ int ret = drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, adjustedPos.x(), adjustedPos.y());
+ if (ret == 0)
+ m_pos = pos;
+ else
+ qWarning("Failed to move cursor on screen %s: %d", kmsScreen->name().toLatin1().constData(), ret);
}
}
@@ -176,8 +190,11 @@ void QEglFSKmsCursor::initCursorAtlas()
QFile file(QString::fromUtf8(json));
if (!file.open(QFile::ReadOnly)) {
- drmModeSetCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0, 0);
- drmModeMoveCursor(m_screen->device()->fd(), m_screen->output().crtc_id, 0, 0);
+ Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) {
+ QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen);
+ drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0);
+ drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0);
+ }
m_visible = false;
return;
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp
index bafe1e3324..18a66e34f5 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -308,6 +309,7 @@ QEglFSKmsDevice::QEglFSKmsDevice(QEglFSKmsIntegration *integration, const QStrin
, m_gbm_device(Q_NULLPTR)
, m_crtc_allocator(0)
, m_connector_allocator(0)
+ , m_globalCursor(Q_NULLPTR)
{
}
@@ -347,6 +349,10 @@ void QEglFSKmsDevice::close()
qt_safe_close(m_dri_fd);
m_dri_fd = -1;
}
+
+ if (m_globalCursor)
+ m_globalCursor->deleteLater();
+ m_globalCursor = Q_NULLPTR;
}
void QEglFSKmsDevice::createScreens()
@@ -357,6 +363,8 @@ void QEglFSKmsDevice::createScreens()
return;
}
+ QEglFSKmsScreen *primaryScreen = Q_NULLPTR;
+ QList<QPlatformScreen *> siblings;
QPoint pos(0, 0);
QEglFSIntegration *integration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration());
@@ -369,12 +377,24 @@ void QEglFSKmsDevice::createScreens()
if (screen) {
integration->addScreen(screen);
pos.rx() += screen->geometry().width();
+ siblings << screen;
+
+ if (!primaryScreen)
+ primaryScreen = screen;
}
drmModeFreeConnector(connector);
}
drmModeFreeResources(resources);
+
+ if (!m_integration->separateScreens()) {
+ Q_FOREACH (QPlatformScreen *screen, siblings)
+ static_cast<QEglFSKmsScreen *>(screen)->setVirtualSiblings(siblings);
+
+ if (primaryScreen)
+ m_globalCursor = new QEglFSKmsCursor(primaryScreen);
+ }
}
gbm_device *QEglFSKmsDevice::device() const
@@ -387,6 +407,11 @@ int QEglFSKmsDevice::fd() const
return m_dri_fd;
}
+QPlatformCursor *QEglFSKmsDevice::globalCursor() const
+{
+ return m_globalCursor;
+}
+
void QEglFSKmsDevice::handleDrmEvent()
{
drmEventContext drmEvent = {
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.h
index 29a1332c9a..23fca934e5 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsdevice.h
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -34,6 +35,7 @@
#ifndef QEGLFSKMSDEVICE_H
#define QEGLFSKMSDEVICE_H
+#include "qeglfskmscursor.h"
#include "qeglfskmsintegration.h"
#include <xf86drm.h>
@@ -57,6 +59,8 @@ public:
gbm_device *device() const;
int fd() const;
+ QPlatformCursor *globalCursor() const;
+
void handleDrmEvent();
private:
@@ -70,6 +74,8 @@ private:
quint32 m_crtc_allocator;
quint32 m_connector_allocator;
+ QEglFSKmsCursor *m_globalCursor;
+
int crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector);
QEglFSKmsScreen *screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos);
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp
index 7bb932cf00..45224ccb87 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -60,6 +61,7 @@ QEglFSKmsIntegration::QEglFSKmsIntegration()
: m_device(Q_NULLPTR)
, m_hwCursor(true)
, m_pbuffers(false)
+ , m_separateScreens(false)
{}
void QEglFSKmsIntegration::platformInit()
@@ -203,6 +205,11 @@ bool QEglFSKmsIntegration::hwCursor() const
return m_hwCursor;
}
+bool QEglFSKmsIntegration::separateScreens() const
+{
+ return m_separateScreens;
+}
+
QMap<QString, QVariantMap> QEglFSKmsIntegration::outputSettings() const
{
return m_outputSettings;
@@ -235,6 +242,7 @@ void QEglFSKmsIntegration::loadConfig()
m_hwCursor = object.value(QStringLiteral("hwcursor")).toBool(m_hwCursor);
m_pbuffers = object.value(QStringLiteral("pbuffers")).toBool(m_pbuffers);
m_devicePath = object.value(QStringLiteral("device")).toString();
+ m_separateScreens = object.value(QStringLiteral("separateScreens")).toBool(m_separateScreens);
const QJsonArray outputs = object.value(QStringLiteral("outputs")).toArray();
for (int i = 0; i < outputs.size(); i++) {
@@ -254,6 +262,7 @@ void QEglFSKmsIntegration::loadConfig()
qCDebug(qLcEglfsKmsDebug) << "Configuration:\n"
<< "\thwcursor:" << m_hwCursor << "\n"
<< "\tpbuffers:" << m_pbuffers << "\n"
+ << "\tseparateScreens:" << m_separateScreens << "\n"
<< "\toutputs:" << m_outputSettings;
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h
index 9a160d2570..edb6906a4b 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsintegration.h
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -65,6 +66,7 @@ public:
bool supportsPBuffers() const Q_DECL_OVERRIDE;
bool hwCursor() const;
+ bool separateScreens() const;
QMap<QString, QVariantMap> outputSettings() const;
private:
@@ -73,6 +75,7 @@ private:
QEglFSKmsDevice *m_device;
bool m_hwCursor;
bool m_pbuffers;
+ bool m_separateScreens;
QString m_devicePath;
QMap<QString, QVariantMap> m_outputSettings;
};
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp
index a27819d1dd..5e49c224a0 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -120,6 +121,7 @@ QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsIntegration *integration,
, m_cursor(Q_NULLPTR)
, m_interruptHandler(new QEglFSKmsInterruptHandler(this))
{
+ m_siblings << this;
}
QEglFSKmsScreen::~QEglFSKmsScreen()
@@ -185,6 +187,9 @@ QString QEglFSKmsScreen::name() const
QPlatformCursor *QEglFSKmsScreen::cursor() const
{
if (m_integration->hwCursor()) {
+ if (!m_integration->separateScreens())
+ return m_device->globalCursor();
+
if (m_cursor.isNull()) {
QEglFSKmsScreen *that = const_cast<QEglFSKmsScreen *>(this);
that->m_cursor.reset(new QEglFSKmsCursor(that));
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h
index 16521c7fe0..4c1b0d02ad 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -85,6 +86,10 @@ public:
qreal refreshRate() const Q_DECL_OVERRIDE;
+ 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; }
gbm_surface *surface() const { return m_gbm_surface; }
@@ -110,6 +115,8 @@ private:
QPoint m_pos;
QScopedPointer<QEglFSKmsCursor> m_cursor;
+ QList<QPlatformScreen *> m_siblings;
+
struct FrameBuffer {
FrameBuffer() : fb(0) {}
uint32_t fb;
diff --git a/src/plugins/platforms/eglfs/qeglfsmain.cpp b/src/plugins/platforms/eglfs/qeglfsmain.cpp
index 4aae7118ac..89b2f20569 100644
--- a/src/plugins/platforms/eglfs/qeglfsmain.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsmain.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QEglFSIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "eglfs.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "eglfs.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp
index 30fdce9fd3..c0d51c94a5 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp
@@ -35,6 +35,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
+#include <QtGui/private/qopenglcontext_p.h>
#include <QtGui/QOpenGLContext>
#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
@@ -106,6 +107,7 @@ void QEglFSWindow::create()
if (isRaster()) {
QOpenGLContext *context = new QOpenGLContext(QGuiApplication::instance());
+ context->setShareContext(qt_gl_global_share_context());
context->setFormat(m_format);
context->setScreen(window()->screen());
if (!context->create())
diff --git a/src/plugins/platforms/haiku/main.h b/src/plugins/platforms/haiku/main.h
index fbf0bee527..9889109c7e 100644
--- a/src/plugins/platforms/haiku/main.h
+++ b/src/plugins/platforms/haiku/main.h
@@ -38,7 +38,7 @@ QT_BEGIN_NAMESPACE
class QHaikuIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "haiku.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "haiku.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/haiku/qhaikuwindow.cpp b/src/plugins/platforms/haiku/qhaikuwindow.cpp
index 140b79af12..9622d12111 100644
--- a/src/plugins/platforms/haiku/qhaikuwindow.cpp
+++ b/src/plugins/platforms/haiku/qhaikuwindow.cpp
@@ -130,6 +130,7 @@ QHaikuWindow::QHaikuWindow(QWindow *window)
if (!m_window)
qFatal("QHaikuWindow: failed to create window");
+ setGeometry(rect);
setWindowFlags(window->flags());
}
@@ -164,13 +165,13 @@ void QHaikuWindow::setVisible(bool visible)
{
if (visible) {
m_window->Show();
+
+ window()->requestActivate();
+
+ QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), window()->geometry().size()));
} else {
m_window->Hide();
}
-
- window()->requestActivate();
-
- QWindowSystemInterface::handleExposeEvent(window(), window()->geometry());
}
bool QHaikuWindow::isExposed() const
@@ -307,7 +308,7 @@ void QHaikuWindow::haikuWindowMoved(const QPoint &pos)
QPlatformWindow::setGeometry(newGeometry);
QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
- QWindowSystemInterface::handleExposeEvent(window(), newGeometry);
+ QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), newGeometry.size()));
}
void QHaikuWindow::haikuWindowResized(const QSize &size, bool zoomInProgress)
@@ -316,7 +317,7 @@ void QHaikuWindow::haikuWindowResized(const QSize &size, bool zoomInProgress)
QPlatformWindow::setGeometry(newGeometry);
QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
- QWindowSystemInterface::handleExposeEvent(window(), newGeometry);
+ QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), newGeometry.size()));
if ((m_windowState == Qt::WindowMaximized) && !zoomInProgress) {
// the user has resized the window while maximized -> reset maximized flag
diff --git a/src/plugins/platforms/ios/plugin.mm b/src/plugins/platforms/ios/plugin.mm
index 41fe712f60..e68e1dfd6f 100644
--- a/src/plugins/platforms/ios/plugin.mm
+++ b/src/plugins/platforms/ios/plugin.mm
@@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE
class QIOSIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "ios.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "ios.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&);
};
diff --git a/src/plugins/platforms/ios/qiosapplicationstate.mm b/src/plugins/platforms/ios/qiosapplicationstate.mm
index 92799f80c1..7a37e213bd 100644
--- a/src/plugins/platforms/ios/qiosapplicationstate.mm
+++ b/src/plugins/platforms/ios/qiosapplicationstate.mm
@@ -43,7 +43,7 @@
@implementation QIOSApplicationStateListener
-- (id) init
+- (id)init
{
self = [super init];
if (self) {
@@ -75,7 +75,7 @@
return self;
}
-- (void) dealloc
+- (void)dealloc
{
[[NSNotificationCenter defaultCenter]
removeObserver:self
@@ -92,12 +92,12 @@
[super dealloc];
}
-- (void) applicationDidBecomeActive
+- (void)applicationDidBecomeActive
{
[self handleApplicationStateChanged:UIApplicationStateActive];
}
-- (void) applicationWillResignActive
+- (void)applicationWillResignActive
{
// Note that UIApplication is still UIApplicationStateActive at this
// point, but since there is no separate notification for the inactive
@@ -105,12 +105,12 @@
[self handleApplicationStateChanged:UIApplicationStateInactive];
}
-- (void) applicationDidEnterBackground
+- (void)applicationDidEnterBackground
{
[self handleApplicationStateChanged:UIApplicationStateBackground];
}
-- (void) handleApplicationStateChanged:(UIApplicationState) uiApplicationState
+- (void)handleApplicationStateChanged:(UIApplicationState)uiApplicationState
{
// We may receive application state changes after QCoreApplication has
// gone down, as the block we schedule on the main queue keeps the
diff --git a/src/plugins/platforms/ios/qiosbackingstore.h b/src/plugins/platforms/ios/qiosbackingstore.h
index 68c77d9900..5d2ae429f1 100644
--- a/src/plugins/platforms/ios/qiosbackingstore.h
+++ b/src/plugins/platforms/ios/qiosbackingstore.h
@@ -39,6 +39,8 @@
QT_BEGIN_NAMESPACE
class QOpenGLPaintDevice;
+class QOpenGLFramebufferObject;
+class QOffscreenSurface;
class QIOSBackingStore : public QPlatformBackingStore
{
@@ -49,13 +51,19 @@ public:
QPaintDevice *paintDevice();
void beginPaint(const QRegion &);
+ void endPaint();
void flush(QWindow *window, const QRegion &region, const QPoint &offset);
void resize(const QSize &size, const QRegion &staticContents);
+ GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const;
+
+ void makeCurrent();
private:
QOpenGLContext *m_context;
QOpenGLPaintDevice *m_device;
+ QOpenGLFramebufferObject *m_fbo;
+ QOffscreenSurface *m_surface;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosbackingstore.mm b/src/plugins/platforms/ios/qiosbackingstore.mm
index acec95b0d3..875d06dc80 100644
--- a/src/plugins/platforms/ios/qiosbackingstore.mm
+++ b/src/plugins/platforms/ios/qiosbackingstore.mm
@@ -36,41 +36,117 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLPaintDevice>
+#include <QtGui/QOpenGLFramebufferObject>
+#include <QtGui/QOffscreenSurface>
+#include <QtGui/private/qwindow_p.h>
#include <QtDebug>
+class QIOSPaintDevice : public QOpenGLPaintDevice
+{
+public:
+ QIOSPaintDevice(QIOSBackingStore *backingStore) : m_backingStore(backingStore) { }
+ void ensureActiveTarget() Q_DECL_OVERRIDE;
+
+private:
+ QIOSBackingStore *m_backingStore;
+};
+
+void QIOSPaintDevice::ensureActiveTarget()
+{
+ m_backingStore->makeCurrent();
+}
+
QIOSBackingStore::QIOSBackingStore(QWindow *window)
: QPlatformBackingStore(window)
, m_context(new QOpenGLContext)
, m_device(0)
+ , m_fbo(0)
+ , m_surface(0)
{
QSurfaceFormat fmt = window->requestedFormat();
- fmt.setDepthBufferSize(16);
- fmt.setStencilBufferSize(8);
+ // Due to sharing QIOSContext redirects our makeCurrent on window() attempts to
+ // the global share context. Hence it is essential to have a compatible format.
+ fmt.setDepthBufferSize(QSurfaceFormat::defaultFormat().depthBufferSize());
+ fmt.setStencilBufferSize(QSurfaceFormat::defaultFormat().stencilBufferSize());
+
+ if (fmt.depthBufferSize() == 0)
+ qWarning("No depth in default format, expect rendering errors");
- // Needed to prevent QOpenGLContext::makeCurrent() from failing
- window->setSurfaceType(QSurface::OpenGLSurface);
+ if (window->surfaceType() == QSurface::RasterSurface)
+ window->setSurfaceType(QSurface::OpenGLSurface);
m_context->setFormat(fmt);
m_context->setScreen(window->screen());
+ Q_ASSERT(QOpenGLContext::globalShareContext());
+ m_context->setShareContext(QOpenGLContext::globalShareContext());
m_context->create();
}
QIOSBackingStore::~QIOSBackingStore()
{
+ delete m_fbo;
+ delete m_surface;
delete m_context;
delete m_device;
}
+void QIOSBackingStore::makeCurrent()
+{
+ QSurface *surface = m_surface ? m_surface : static_cast<QSurface *>(window());
+ if (!m_context->makeCurrent(surface))
+ qWarning("QIOSBackingStore: makeCurrent() failed");
+ if (m_fbo)
+ m_fbo->bind();
+}
+
void QIOSBackingStore::beginPaint(const QRegion &)
{
- m_context->makeCurrent(window());
+ if (qt_window_private(window())->compositing) {
+ if (!m_fbo) {
+ delete m_device;
+ m_device = 0;
+ }
+ if (!m_surface) {
+ m_surface = new QOffscreenSurface;
+ m_surface->setFormat(m_context->format());
+ m_surface->create();
+ }
+ if (!m_context->makeCurrent(m_surface))
+ qWarning("QIOSBackingStore: Failed to make offscreen surface current");
+ const QSize size = window()->size() * window()->devicePixelRatio();
+ if (m_fbo && m_fbo->size() != size) {
+ delete m_fbo;
+ m_fbo = 0;
+ }
+ if (!m_fbo)
+ m_fbo = new QOpenGLFramebufferObject(size, QOpenGLFramebufferObject::CombinedDepthStencil);
+ } else if (m_fbo) {
+ delete m_fbo;
+ m_fbo = 0;
+ delete m_surface;
+ m_surface = 0;
+ delete m_device;
+ m_device = 0;
+ }
+
+ makeCurrent();
+
+ if (!m_device)
+ m_device = new QIOSPaintDevice(this);
+}
+
+void QIOSBackingStore::endPaint()
+{
+ if (m_fbo) {
+ m_fbo->release();
+ glFlush();
+ }
}
QPaintDevice *QIOSBackingStore::paintDevice()
{
- if (!m_device)
- m_device = new QOpenGLPaintDevice;
+ Q_ASSERT(m_device);
// Keep paint device size and device pixel ratio in sync with window
qreal devicePixelRatio = window()->devicePixelRatio();
@@ -82,6 +158,8 @@ QPaintDevice *QIOSBackingStore::paintDevice()
void QIOSBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
+ Q_ASSERT(!qt_window_private(window)->compositing);
+
Q_UNUSED(region);
Q_UNUSED(offset);
@@ -111,4 +189,21 @@ void QIOSBackingStore::resize(const QSize &size, const QRegion &staticContents)
qWarning() << "QIOSBackingStore needs to have the same size as its window";
}
+GLuint QIOSBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const
+{
+ Q_ASSERT(qt_window_private(window())->compositing);
+ Q_UNUSED(dirtyRegion);
+
+ if (flags)
+ *flags = TextureFlip;
+
+ if (!m_fbo)
+ return 0;
+
+ if (textureSize)
+ *textureSize = m_fbo->size();
+
+ return m_fbo->texture();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosclipboard.mm b/src/plugins/platforms/ios/qiosclipboard.mm
index 192ee67689..e0c6ec5d72 100644
--- a/src/plugins/platforms/ios/qiosclipboard.mm
+++ b/src/plugins/platforms/ios/qiosclipboard.mm
@@ -62,7 +62,7 @@
@implementation QUIClipboard
--(id)initWithQIOSClipboard:(QIOSClipboard *)qiosClipboard
+- (id)initWithQIOSClipboard:(QIOSClipboard *)qiosClipboard
{
self = [super init];
if (self) {
@@ -87,7 +87,7 @@
return self;
}
--(void)dealloc
+- (void)dealloc
{
[[NSNotificationCenter defaultCenter]
removeObserver:self
diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm
index c7541fc51b..fe0ca33c13 100644
--- a/src/plugins/platforms/ios/qioscontext.mm
+++ b/src/plugins/platforms/ios/qioscontext.mm
@@ -116,7 +116,8 @@ static QString fboStatusString(GLenum status)
bool QIOSContext::makeCurrent(QPlatformSurface *surface)
{
- Q_ASSERT(surface && surface->surface()->surfaceType() == QSurface::OpenGLSurface);
+ Q_ASSERT(surface && (surface->surface()->surfaceType() == QSurface::OpenGLSurface
+ || surface->surface()->surfaceType() == QSurface::RasterGLSurface));
[EAGLContext setCurrentContext:m_eaglContext];
@@ -141,7 +142,8 @@ void QIOSContext::doneCurrent()
void QIOSContext::swapBuffers(QPlatformSurface *surface)
{
- Q_ASSERT(surface && surface->surface()->surfaceType() == QSurface::OpenGLSurface);
+ Q_ASSERT(surface && (surface->surface()->surfaceType() == QSurface::OpenGLSurface
+ || surface->surface()->surfaceType() == QSurface::RasterGLSurface));
if (surface->surface()->surfaceClass() == QSurface::Offscreen)
return; // Nothing to do
diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm
index fc12e83a81..8e4b4c5875 100644
--- a/src/plugins/platforms/ios/qioseventdispatcher.mm
+++ b/src/plugins/platforms/ios/qioseventdispatcher.mm
@@ -293,7 +293,7 @@ static bool rootLevelRunLoopIntegration()
@implementation QIOSApplicationStateTracker
-+ (void) load
++ (void)load
{
[[NSNotificationCenter defaultCenter]
addObserver:self
@@ -323,7 +323,7 @@ static bool rootLevelRunLoopIntegration()
# error "Unknown processor family"
#endif
-+ (void) applicationDidFinishLaunching
++ (void)applicationDidFinishLaunching
{
if (!isQtApplication())
return;
@@ -377,7 +377,7 @@ static bool rootLevelRunLoopIntegration()
// four bits of the exit code (exit(3) will only pass on the lower 8 bits).
static const char kApplicationWillTerminateExitCode = SIGTERM | 0x80;
-+ (void) applicationWillTerminate
++ (void)applicationWillTerminate
{
if (!isQtApplication())
return;
diff --git a/src/plugins/platforms/ios/qiosfileengineassetslibrary.h b/src/plugins/platforms/ios/qiosfileengineassetslibrary.h
index 043e101a21..37bbc7bf23 100644
--- a/src/plugins/platforms/ios/qiosfileengineassetslibrary.h
+++ b/src/plugins/platforms/ios/qiosfileengineassetslibrary.h
@@ -55,10 +55,17 @@ public:
QString fileName(FileName file) const Q_DECL_OVERRIDE;
void setFileName(const QString &file) Q_DECL_OVERRIDE;
QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const Q_DECL_OVERRIDE;
+
+#ifndef QT_NO_FILESYSTEMITERATOR
+ Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) Q_DECL_OVERRIDE;
+ Iterator *endEntryList() Q_DECL_OVERRIDE;
+#endif
+
void setError(QFile::FileError error, const QString &str) { QAbstractFileEngine::setError(error, str); }
private:
QString m_fileName;
+ QString m_assetUrl;
qint64 m_offset;
mutable QIOSAssetData *m_data;
diff --git a/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm b/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm
index 73bfc2a87f..44a7901160 100644
--- a/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm
+++ b/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm
@@ -38,6 +38,145 @@
#include <QtCore/QTimer>
#include <QtCore/private/qcoreapplication_p.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qset.h>
+#include <QtCore/qthreadstorage.h>
+
+static QThreadStorage<QString> g_iteratorCurrentUrl;
+static QThreadStorage<QPointer<QIOSAssetData> > g_assetDataCache;
+
+static const int kBufferSize = 10;
+static ALAsset *kNoAsset = 0;
+
+static void ensureAuthorizationDialogNotBlocked()
+{
+ if ([ALAssetsLibrary authorizationStatus] != ALAuthorizationStatusNotDetermined)
+ return;
+ if (static_cast<QCoreApplicationPrivate *>(QObjectPrivate::get(qApp))->in_exec)
+ return;
+
+ // Since authorization status has not been determined, the user will be asked
+ // to authorize the app. But since main has not finished, the dialog will be held
+ // back until the launch completes. To avoid a dead-lock below, we start an event
+ // loop to complete the launch.
+ QEventLoop loop;
+ QTimer::singleShot(1, &loop, &QEventLoop::quit);
+ loop.exec();
+}
+
+// -------------------------------------------------------------------------
+
+class QIOSAssetEnumerator
+{
+public:
+ QIOSAssetEnumerator(ALAssetsLibrary *assetsLibrary, ALAssetsGroupType type)
+ : m_semWriteAsset(dispatch_semaphore_create(kBufferSize))
+ , m_semReadAsset(dispatch_semaphore_create(0))
+ , m_stop(false)
+ , m_assetsLibrary([assetsLibrary retain])
+ , m_type(type)
+ , m_buffer(QVector<ALAsset *>(kBufferSize))
+ , m_readIndex(0)
+ , m_writeIndex(0)
+ , m_nextAssetReady(false)
+ {
+ ensureAuthorizationDialogNotBlocked();
+ startEnumerate();
+ }
+
+ ~QIOSAssetEnumerator()
+ {
+ m_stop = true;
+
+ // Flush and autorelease remaining assets in the buffer
+ while (hasNext())
+ next();
+
+ // Documentation states that we need to balance out calls to 'wait'
+ // and 'signal'. Since the enumeration function always will be one 'wait'
+ // ahead, we need to signal m_semProceedToNextAsset one last time.
+ dispatch_semaphore_signal(m_semWriteAsset);
+ dispatch_release(m_semReadAsset);
+ dispatch_release(m_semWriteAsset);
+
+ [m_assetsLibrary autorelease];
+ }
+
+ bool hasNext()
+ {
+ if (!m_nextAssetReady) {
+ dispatch_semaphore_wait(m_semReadAsset, DISPATCH_TIME_FOREVER);
+ m_nextAssetReady = true;
+ }
+ return m_buffer[m_readIndex] != kNoAsset;
+ }
+
+ ALAsset *next()
+ {
+ Q_ASSERT(m_nextAssetReady);
+ Q_ASSERT(m_buffer[m_readIndex]);
+
+ ALAsset *asset = [m_buffer[m_readIndex] autorelease];
+ dispatch_semaphore_signal(m_semWriteAsset);
+
+ m_readIndex = (m_readIndex + 1) % kBufferSize;
+ m_nextAssetReady = false;
+ return asset;
+ }
+
+private:
+ dispatch_semaphore_t m_semWriteAsset;
+ dispatch_semaphore_t m_semReadAsset;
+ std::atomic_bool m_stop;
+
+ ALAssetsLibrary *m_assetsLibrary;
+ ALAssetsGroupType m_type;
+ QVector<ALAsset *> m_buffer;
+ int m_readIndex;
+ int m_writeIndex;
+ bool m_nextAssetReady;
+
+ void writeAsset(ALAsset *asset)
+ {
+ dispatch_semaphore_wait(m_semWriteAsset, DISPATCH_TIME_FOREVER);
+ m_buffer[m_writeIndex] = [asset retain];
+ dispatch_semaphore_signal(m_semReadAsset);
+ m_writeIndex = (m_writeIndex + 1) % kBufferSize;
+ }
+
+ void startEnumerate()
+ {
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ [m_assetsLibrary enumerateGroupsWithTypes:m_type usingBlock:^(ALAssetsGroup *group, BOOL *stopEnumerate) {
+
+ if (!group) {
+ writeAsset(kNoAsset);
+ return;
+ }
+
+ if (m_stop) {
+ *stopEnumerate = true;
+ return;
+ }
+
+ [group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stopEnumerate) {
+ Q_UNUSED(index);
+ if (!asset || ![[asset valueForProperty:ALAssetPropertyType] isEqual:ALAssetTypePhoto])
+ return;
+
+ writeAsset(asset);
+ *stopEnumerate = m_stop;
+ }];
+ } failureBlock:^(NSError *error) {
+ NSLog(@"QIOSFileEngine: %@", error);
+ writeAsset(kNoAsset);
+ }];
+ });
+ }
+
+};
+
+// -------------------------------------------------------------------------
class QIOSAssetData : public QObject
{
@@ -47,35 +186,17 @@ public:
, m_assetUrl(assetUrl)
, m_assetLibrary(0)
{
- switch ([ALAssetsLibrary authorizationStatus]) {
- case ALAuthorizationStatusRestricted:
- case ALAuthorizationStatusDenied:
- engine->setError(QFile::PermissionsError, QLatin1String("Unauthorized access"));
- return;
- case ALAuthorizationStatusNotDetermined:
- if (!static_cast<QCoreApplicationPrivate *>(QObjectPrivate::get(qApp))->in_exec) {
- // Since authorization status has not been determined, the user will be asked
- // to authorize the app. But since main has not finished, the dialog will be held
- // back until the launch completes. To avoid a dead-lock below, we start an event
- // loop to complete the launch.
- QEventLoop loop;
- QTimer::singleShot(1, &loop, &QEventLoop::quit);
- loop.exec();
- }
- break;
- default:
- if (g_currentAssetData) {
- // It's a common pattern that QFiles pointing to the same path are created and destroyed
- // several times during a single event loop cycle. To avoid loading the same asset
- // over and over, we check if the last loaded asset has not been destroyed yet, and try to
- // reuse its data. Since QFile is (mostly) reentrant, we need to protect m_currentAssetData
- // from being modified by several threads at the same time.
- QMutexLocker lock(&g_mutex);
- if (g_currentAssetData && g_currentAssetData->m_assetUrl == assetUrl) {
- m_assetLibrary = [g_currentAssetData->m_assetLibrary retain];
- m_asset = [g_currentAssetData->m_asset retain];
- return;
- }
+ ensureAuthorizationDialogNotBlocked();
+
+ if (QIOSAssetData *assetData = g_assetDataCache.localData()) {
+ // It's a common pattern that QFiles pointing to the same path are created and destroyed
+ // several times during a single event loop cycle. To avoid loading the same asset
+ // over and over, we check if the last loaded asset has not been destroyed yet, and try to
+ // reuse its data.
+ if (assetData->m_assetUrl == assetUrl) {
+ m_assetLibrary = [assetData->m_assetLibrary retain];
+ m_asset = [assetData->m_asset retain];
+ return;
}
}
@@ -90,6 +211,26 @@ public:
NSURL *url = [NSURL URLWithString:assetUrl.toNSString()];
m_assetLibrary = [[ALAssetsLibrary alloc] init];
[m_assetLibrary assetForURL:url resultBlock:^(ALAsset *asset) {
+
+ if (!asset) {
+ // When an asset couldn't be loaded, chances are that it belongs to ALAssetsGroupPhotoStream.
+ // Such assets can be stored in the cloud and might need to be downloaded first. Unfortunately,
+ // forcing that to happen is hidden behind private APIs ([ALAsset requestDefaultRepresentation]).
+ // As a work-around, we search for it instead, since that will give us a pointer to the asset.
+ QIOSAssetEnumerator e(m_assetLibrary, ALAssetsGroupPhotoStream);
+ while (e.hasNext()) {
+ ALAsset *a = e.next();
+ QString url = QUrl::fromNSURL([a valueForProperty:ALAssetPropertyAssetURL]).toString();
+ if (url == assetUrl) {
+ asset = a;
+ break;
+ }
+ }
+ }
+
+ if (!asset)
+ engine->setError(QFile::OpenError, QLatin1String("could not open image"));
+
m_asset = [asset retain];
dispatch_semaphore_signal(semaphore);
} failureBlock:^(NSError *error) {
@@ -101,17 +242,15 @@ public:
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_release(semaphore);
- QMutexLocker lock(&g_mutex);
- g_currentAssetData = this;
+ g_assetDataCache.setLocalData(this);
}
~QIOSAssetData()
{
- QMutexLocker lock(&g_mutex);
[m_assetLibrary release];
[m_asset release];
- if (this == g_currentAssetData)
- g_currentAssetData = 0;
+ if (g_assetDataCache.localData() == this)
+ g_assetDataCache.setLocalData(0);
}
ALAsset *m_asset;
@@ -119,21 +258,67 @@ public:
private:
QString m_assetUrl;
ALAssetsLibrary *m_assetLibrary;
+};
+
+// -------------------------------------------------------------------------
- static QBasicMutex g_mutex;
- static QPointer<QIOSAssetData> g_currentAssetData;
+#ifndef QT_NO_FILESYSTEMITERATOR
+
+class QIOSFileEngineIteratorAssetsLibrary : public QAbstractFileEngineIterator
+{
+public:
+ QIOSAssetEnumerator *m_enumerator;
+
+ QIOSFileEngineIteratorAssetsLibrary(
+ QDir::Filters filters, const QStringList &nameFilters)
+ : QAbstractFileEngineIterator(filters, nameFilters)
+ , m_enumerator(new QIOSAssetEnumerator([[[ALAssetsLibrary alloc] init] autorelease], ALAssetsGroupAll))
+ {
+ }
+
+ ~QIOSFileEngineIteratorAssetsLibrary()
+ {
+ delete m_enumerator;
+ g_iteratorCurrentUrl.setLocalData(QString());
+ }
+
+ QString next() Q_DECL_OVERRIDE
+ {
+ // Cache the URL that we are about to return, since QDir will immediately create a
+ // new file engine on the file and ask if it exists. Unless we do this, we end up
+ // creating a new ALAsset just to verify its existence, which will be especially
+ // costly for assets belonging to ALAssetsGroupPhotoStream.
+ ALAsset *asset = m_enumerator->next();
+ QString url = QUrl::fromNSURL([asset valueForProperty:ALAssetPropertyAssetURL]).toString();
+ g_iteratorCurrentUrl.setLocalData(url);
+ return url;
+ }
+
+ bool hasNext() const Q_DECL_OVERRIDE
+ {
+ return m_enumerator->hasNext();
+ }
+
+ QString currentFileName() const Q_DECL_OVERRIDE
+ {
+ return g_iteratorCurrentUrl.localData();
+ }
+
+ QFileInfo currentFileInfo() const
+ {
+ return QFileInfo(currentFileName());
+ }
};
-QBasicMutex QIOSAssetData::g_mutex;
-QPointer<QIOSAssetData> QIOSAssetData::g_currentAssetData = 0;
+#endif
// -------------------------------------------------------------------------
QIOSFileEngineAssetsLibrary::QIOSFileEngineAssetsLibrary(const QString &fileName)
- : m_fileName(fileName)
- , m_offset(0)
+ : m_offset(0)
, m_data(0)
{
+ setFileName(fileName);
}
QIOSFileEngineAssetsLibrary::~QIOSFileEngineAssetsLibrary()
@@ -143,18 +328,8 @@ QIOSFileEngineAssetsLibrary::~QIOSFileEngineAssetsLibrary()
ALAsset *QIOSFileEngineAssetsLibrary::loadAsset() const
{
- if (!m_data) {
- // QUrl::fromLocalFile() will remove double slashes. Since the asset url is passed around as a file
- // name in the app (and converted to/from a file url, e.g in QFileDialog), we need to check if we still
- // have two leading slashes after the scheme, and restore the second slash if not.
- QString assetUrl = m_fileName;
- const int index = 16; // "assets-library://"
- if (assetUrl[index] != QLatin1Char('/'))
- assetUrl.insert(index, '/');
-
- m_data = new QIOSAssetData(assetUrl, const_cast<QIOSFileEngineAssetsLibrary *>(this));
- }
-
+ if (!m_data)
+ m_data = new QIOSAssetData(m_assetUrl, const_cast<QIOSFileEngineAssetsLibrary *>(this));
return m_data->m_asset;
}
@@ -179,15 +354,21 @@ bool QIOSFileEngineAssetsLibrary::close()
QAbstractFileEngine::FileFlags QIOSFileEngineAssetsLibrary::fileFlags(QAbstractFileEngine::FileFlags type) const
{
QAbstractFileEngine::FileFlags flags = 0;
- if (!loadAsset())
+ const bool isDir = (m_assetUrl == QLatin1String("assets-library://"));
+ const bool exists = isDir || m_assetUrl == g_iteratorCurrentUrl.localData() || loadAsset();
+
+ if (!exists)
return flags;
if (type & FlagsMask)
flags |= ExistsFlag;
- if (type & PermsMask)
- flags |= ReadOwnerPerm | ReadUserPerm | ReadGroupPerm | ReadOtherPerm;
+ if (type & PermsMask) {
+ ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
+ if (status != ALAuthorizationStatusRestricted && status != ALAuthorizationStatusDenied)
+ flags |= ReadOwnerPerm | ReadUserPerm | ReadGroupPerm | ReadOtherPerm;
+ }
if (type & TypesMask)
- flags |= FileType;
+ flags |= isDir ? DirectoryType : FileType;
return flags;
}
@@ -245,11 +426,32 @@ void QIOSFileEngineAssetsLibrary::setFileName(const QString &file)
if (m_data)
close();
m_fileName = file;
+ // QUrl::fromLocalFile() will remove double slashes. Since the asset url is
+ // passed around as a file name in the app (and converted to/from a file url, e.g
+ // in QFileDialog), we need to ensure that m_assetUrl ends up being valid.
+ int index = file.indexOf(QLatin1String("asset.JPG?"));
+ if (index == -1)
+ m_assetUrl = QLatin1String("assets-library://");
+ else
+ m_assetUrl = QLatin1String("assets-library://asset/") + file.mid(index);
}
QStringList QIOSFileEngineAssetsLibrary::entryList(QDir::Filters filters, const QStringList &filterNames) const
{
- Q_UNUSED(filters);
- Q_UNUSED(filterNames);
- return QStringList();
+ return QAbstractFileEngine::entryList(filters, filterNames);
+}
+
+#ifndef QT_NO_FILESYSTEMITERATOR
+
+QAbstractFileEngine::Iterator *QIOSFileEngineAssetsLibrary::beginEntryList(
+ QDir::Filters filters, const QStringList &filterNames)
+{
+ return new QIOSFileEngineIteratorAssetsLibrary(filters, filterNames);
}
+
+QAbstractFileEngine::Iterator *QIOSFileEngineAssetsLibrary::endEntryList()
+{
+ return 0;
+}
+
+#endif
diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h
index 86b784618f..544f9e0a42 100644
--- a/src/plugins/platforms/ios/qiosglobal.h
+++ b/src/plugins/platforms/ios/qiosglobal.h
@@ -68,7 +68,7 @@ int infoPlistValue(NSString* key, int defaultValue);
QT_END_NAMESPACE
@interface UIResponder (QtFirstResponder)
-+(id)currentFirstResponder;
++ (id)currentFirstResponder;
@end
class FirstResponderCandidate : public QScopedValueRollback<UIResponder *>
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index ef24abbfd9..f5b971391d 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -133,7 +133,7 @@ int infoPlistValue(NSString* key, int defaultValue)
@end
@implementation QtFirstResponderEvent
-- (void) dealloc
+- (void)dealloc
{
self.firstResponder = 0;
[super dealloc];
@@ -158,7 +158,7 @@ int infoPlistValue(NSString* key, int defaultValue)
@implementation UIResponder (QtFirstResponder)
-+(id)currentFirstResponder
++ (id)currentFirstResponder
{
QtFirstResponderEvent *event = [[[QtFirstResponderEvent alloc] init] autorelease];
[[UIApplication sharedApplication] sendAction:@selector(qt_findFirstResponder:event:) to:nil from:nil forEvent:event];
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index 037b28e91d..d03c589b2a 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -579,7 +579,7 @@ void QIOSInputContext::focusWindowChanged(QWindow *focusWindow)
void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties)
{
// Mask for properties that we are interested in and see if any of them changed
- updatedProperties &= (Qt::ImEnabled | Qt::ImHints | Qt::ImQueryInput | Qt::ImReturnKeyType | Qt::ImPlatformData);
+ updatedProperties &= (Qt::ImEnabled | Qt::ImHints | Qt::ImQueryInput | Qt::ImEnterKeyType | Qt::ImPlatformData);
qImDebug() << "fw =" << qApp->focusWindow() << "fo =" << qApp->focusObject();
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 7cd4280f5e..b4050b8f62 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -77,6 +77,15 @@ QIOSIntegration::QIOSIntegration()
"'applicationDidFinishLaunching' inside your UIApplication delegate.\n");
}
+ // The backingstore needs a global share context in order to support composition in
+ // QPlatformBackingStore.
+ qApp->setAttribute(Qt::AA_ShareOpenGLContexts, true);
+ // And that context must match the format used for the backingstore's context.
+ QSurfaceFormat fmt;
+ fmt.setDepthBufferSize(16);
+ fmt.setStencilBufferSize(8);
+ QSurfaceFormat::setDefaultFormat(fmt);
+
// Set current directory to app bundle folder
QDir::setCurrent(QString::fromUtf8([[[NSBundle mainBundle] bundlePath] UTF8String]));
@@ -137,6 +146,8 @@ bool QIOSIntegration::hasCapability(Capability cap) const
return false;
case ApplicationState:
return true;
+ case RasterGLSurface:
+ return true;
default:
return QPlatformIntegration::hasCapability(cap);
}
@@ -208,6 +219,10 @@ QPlatformServices *QIOSIntegration::services() const
QVariant QIOSIntegration::styleHint(StyleHint hint) const
{
switch (hint) {
+ case PasswordMaskDelay:
+ // this number is based on timing the native delay
+ // since there is no API to get it
+ return 2000;
case ShowIsMaximized:
return true;
case SetFocusOnTouchRelease:
diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm
index 08fc8a5e9c..045d39e328 100644
--- a/src/plugins/platforms/ios/qiosmenu.mm
+++ b/src/plugins/platforms/ios/qiosmenu.mm
@@ -165,7 +165,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
[self reloadAllComponents];
}
--(void)listenForKeyboardWillHideNotification:(BOOL)listen
+- (void)listenForKeyboardWillHideNotification:(BOOL)listen
{
if (listen) {
[[NSNotificationCenter defaultCenter]
@@ -179,7 +179,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
}
}
--(void)dealloc
+- (void)dealloc
{
[self listenForKeyboardWillHideNotification:NO];
self.toolbar = 0;
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 324133074b..3e16efcd22 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -104,12 +104,12 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
@public
QIOSScreen *m_screen;
}
-- (id) initWithQIOSScreen:(QIOSScreen *)screen;
+- (id)initWithQIOSScreen:(QIOSScreen *)screen;
@end
@implementation QIOSOrientationListener
-- (id) initWithQIOSScreen:(QIOSScreen *)screen
+- (id)initWithQIOSScreen:(QIOSScreen *)screen
{
self = [super init];
if (self) {
@@ -123,7 +123,7 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
return self;
}
-- (void) dealloc
+- (void)dealloc
{
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
@@ -132,7 +132,7 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
[super dealloc];
}
-- (void) orientationChanged:(NSNotification *)notification
+- (void)orientationChanged:(NSNotification *)notification
{
Q_UNUSED(notification);
m_screen->updateProperties();
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index 3d0bac82c8..d86f545154 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -92,12 +92,12 @@
return [QUITextPosition positionWithIndex:(self.range.location + self.range.length)];
}
-- (NSRange) range
+- (NSRange)range
{
return _range;
}
--(BOOL)isEmpty
+- (BOOL)isEmpty
{
return (self.range.length == 0);
}
@@ -111,7 +111,7 @@
@implementation WrapperView
--(id)initWithView:(UIView *)view
+- (id)initWithView:(UIView *)view
{
if (self = [self init]) {
[self addSubview:view];
@@ -143,7 +143,7 @@
// retained, we ensure that all messages sent to the view during
// its lifetime in a window hierarcy will be able to traverse the
// responder chain.
--(void)willMoveToWindow:(UIWindow *)window
+- (void)willMoveToWindow:(UIWindow *)window
{
if (window)
[[self nextResponder] retain];
@@ -170,25 +170,25 @@
QVariantMap platformData = m_configuredImeState->value(Qt::ImPlatformData).toMap();
Qt::InputMethodHints hints = Qt::InputMethodHints(m_configuredImeState->value(Qt::ImHints).toUInt());
- Qt::ReturnKeyType returnKeyType = Qt::ReturnKeyType(m_configuredImeState->value(Qt::ImReturnKeyType).toUInt());
+ Qt::EnterKeyType enterKeyType = Qt::EnterKeyType(m_configuredImeState->value(Qt::ImEnterKeyType).toUInt());
- switch (returnKeyType) {
- case Qt::ReturnKeyEnter:
+ switch (enterKeyType) {
+ case Qt::EnterKeyReturn:
self.returnKeyType = UIReturnKeyDefault;
break;
- case Qt::ReturnKeyDone:
+ case Qt::EnterKeyDone:
self.returnKeyType = UIReturnKeyDone;
break;
- case Qt::ReturnKeyGo:
+ case Qt::EnterKeyGo:
self.returnKeyType = UIReturnKeyGo;
break;
- case Qt::ReturnKeySend:
+ case Qt::EnterKeySend:
self.returnKeyType = UIReturnKeySend;
break;
- case Qt::ReturnKeySearch:
+ case Qt::EnterKeySearch:
self.returnKeyType = UIReturnKeySearch;
break;
- case Qt::ReturnKeyNext:
+ case Qt::EnterKeyNext:
self.returnKeyType = UIReturnKeyNext;
break;
default:
@@ -255,7 +255,7 @@
}
// Based on what we set up in initWithInputContext above
- updatedProperties &= (Qt::ImHints | Qt::ImReturnKeyType | Qt::ImPlatformData);
+ updatedProperties &= (Qt::ImHints | Qt::ImEnterKeyType | Qt::ImPlatformData);
if (!updatedProperties)
return NO;
@@ -383,17 +383,17 @@
return m_inputContext->imeState().currentState.value(query);
}
--(id<UITextInputTokenizer>)tokenizer
+- (id<UITextInputTokenizer>)tokenizer
{
return [[[UITextInputStringTokenizer alloc] initWithTextInput:id<UITextInput>(self)] autorelease];
}
--(UITextPosition *)beginningOfDocument
+- (UITextPosition *)beginningOfDocument
{
return [QUITextPosition positionWithIndex:0];
}
--(UITextPosition *)endOfDocument
+- (UITextPosition *)endOfDocument
{
int endPosition = [self currentImeState:Qt::ImSurroundingText].toString().length();
return [QUITextPosition positionWithIndex:endPosition];
@@ -659,7 +659,7 @@
return [NSDictionary dictionaryWithObject:uifont forKey:UITextInputTextFontKey];
}
--(NSDictionary *)markedTextStyle
+- (NSDictionary *)markedTextStyle
{
return [NSDictionary dictionary];
}
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm
index 6667ec3dd8..4ea5fc7de1 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.mm
+++ b/src/plugins/platforms/ios/qiosviewcontroller.mm
@@ -288,13 +288,13 @@
// -------------------------------------------------------------------------
--(BOOL)shouldAutorotate
+- (BOOL)shouldAutorotate
{
return m_screen && m_screen->uiScreen() == [UIScreen mainScreen] && !self.lockedOrientation;
}
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_6_0)
--(NSUInteger)supportedInterfaceOrientations
+- (NSUInteger)supportedInterfaceOrientations
{
// As documented by Apple in the iOS 6.0 release notes, setStatusBarOrientation:animated:
// only works if the supportedInterfaceOrientations of the view controller is 0, making
@@ -307,7 +307,7 @@
#endif
#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0)
--(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
Q_UNUSED(interfaceOrientation);
return [self shouldAutorotate];
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index 777a3c12c5..80fba00ffb 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -119,7 +119,8 @@ void QIOSWindow::setVisible(bool visible)
}
if (visible && shouldAutoActivateWindow()) {
- requestActivateWindow();
+ if (!window()->property("_q_showWithoutActivating").toBool())
+ requestActivateWindow();
} else if (!visible && [m_view isActiveWindow]) {
// Our window was active/focus window but now hidden, so relinquish
// focus to the next possible window in the stack.
@@ -145,6 +146,9 @@ void QIOSWindow::setVisible(bool visible)
bool QIOSWindow::shouldAutoActivateWindow() const
{
+ if (![m_view canBecomeFirstResponder])
+ return false;
+
// We don't want to do automatic window activation for popup windows
// that are unlikely to contain editable controls (to avoid hiding
// the keyboard while the popup is showing)
diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.h b/src/plugins/platforms/ios/quiaccessibilityelement.h
index a690e12c7d..c76e3a6a1e 100644
--- a/src/plugins/platforms/ios/quiaccessibilityelement.h
+++ b/src/plugins/platforms/ios/quiaccessibilityelement.h
@@ -42,8 +42,8 @@
@property (readonly) QAccessible::Id axid;
-- (id) initWithId: (QAccessible::Id) anId withAccessibilityContainer: (id) view;
-+ (QMacAccessibilityElement *) elementWithId: (QAccessible::Id) anId withAccessibilityContainer: (id) view;
+- (id)initWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view;
++ (QMacAccessibilityElement *)elementWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view;
@end
diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.mm b/src/plugins/platforms/ios/quiaccessibilityelement.mm
index 2cecfc1126..3bac1ca88d 100644
--- a/src/plugins/platforms/ios/quiaccessibilityelement.mm
+++ b/src/plugins/platforms/ios/quiaccessibilityelement.mm
@@ -37,7 +37,7 @@
@implementation QMacAccessibilityElement
-- (id) initWithId: (QAccessible::Id) anId withAccessibilityContainer: (id) view
+- (id)initWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view
{
Q_ASSERT((int)anId < 0);
self = [super initWithAccessibilityContainer: view];
@@ -47,7 +47,7 @@
return self;
}
-+ (id) elementWithId: (QAccessible::Id) anId withAccessibilityContainer: (id) view
++ (id)elementWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view
{
Q_ASSERT(anId);
if (!anId)
@@ -64,17 +64,17 @@
return element;
}
-- (void) invalidate
+- (void)invalidate
{
[self release];
}
-- (BOOL) isAccessibilityElement
+- (BOOL)isAccessibilityElement
{
return YES;
}
-- (NSString*) accessibilityLabel
+- (NSString*)accessibilityLabel
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (!iface) {
@@ -85,7 +85,7 @@
return iface->text(QAccessible::Name).toNSString();
}
-- (NSString*) accessibilityHint
+- (NSString*)accessibilityHint
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (!iface) {
@@ -95,7 +95,7 @@
return iface->text(QAccessible::Description).toNSString();
}
-- (NSString*) accessibilityValue
+- (NSString*)accessibilityValue
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (!iface) {
@@ -119,7 +119,7 @@
return [super accessibilityHint];
}
-- (CGRect) accessibilityFrame
+- (CGRect)accessibilityFrame
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (!iface) {
@@ -131,7 +131,7 @@
return CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
}
-- (UIAccessibilityTraits) accessibilityTraits
+- (UIAccessibilityTraits)accessibilityTraits
{
UIAccessibilityTraits traits = UIAccessibilityTraitNone;
@@ -156,7 +156,7 @@
return traits;
}
-- (BOOL) accessibilityActivate
+- (BOOL)accessibilityActivate
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (QAccessibleActionInterface *action = iface->actionInterface()) {
@@ -171,21 +171,21 @@
return NO; // fall back to sending mouse clicks
}
-- (void) accessibilityIncrement
+- (void)accessibilityIncrement
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (QAccessibleActionInterface *action = iface->actionInterface())
action->doAction(QAccessibleActionInterface::increaseAction());
}
-- (void) accessibilityDecrement
+- (void)accessibilityDecrement
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
if (QAccessibleActionInterface *action = iface->actionInterface())
action->doAction(QAccessibleActionInterface::decreaseAction());
}
-- (BOOL) accessibilityScroll : (UIAccessibilityScrollDirection) direction
+- (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction
{
QAccessibleInterface *iface = QAccessible::accessibleInterface(self.axid);
QAccessibleActionInterface *action = iface->actionInterface();
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index 8be3515cb5..c6ef843b9f 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -50,7 +50,7 @@
return [CAEAGLLayer class];
}
--(id)initWithQIOSWindow:(QIOSWindow *)window
+- (id)initWithQIOSWindow:(QIOSWindow *)window
{
if (self = [self initWithFrame:toCGRect(window->geometry())])
m_qioswindow = window;
@@ -77,7 +77,7 @@
if (QIOSIntegration::instance()->debugWindowManagement()) {
static CGFloat hue = 0.0;
CGFloat lastHue = hue;
- for (CGFloat diff = 0; diff < 0.1 || diff > 0.9; diff = fabsf(hue - lastHue))
+ for (CGFloat diff = 0; diff < 0.1 || diff > 0.9; diff = fabs(hue - lastHue))
hue = drand48();
#define colorWithBrightness(br) \
@@ -194,7 +194,7 @@
- (BOOL)canBecomeFirstResponder
{
- return YES;
+ return !(m_qioswindow->window()->flags() & Qt::WindowDoesNotAcceptFocus);
}
- (BOOL)becomeFirstResponder
@@ -280,6 +280,12 @@
// -------------------------------------------------------------------------
+-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
+{
+ if (m_qioswindow->window()->flags() & Qt::WindowTransparentForInput)
+ return NO;
+ return [super pointInside:point withEvent:event];
+}
- (void)updateTouchList:(NSSet *)touches withState:(Qt::TouchPointState)state
{
@@ -310,7 +316,7 @@
}
}
-- (void) sendTouchEventWithTimestamp:(ulong)timeStamp
+- (void)sendTouchEventWithTimestamp:(ulong)timeStamp
{
// Send touch event synchronously
QIOSIntegration *iosIntegration = QIOSIntegration::instance();
diff --git a/src/plugins/platforms/kms/main.cpp b/src/plugins/platforms/kms/main.cpp
index 8683a9c8d1..565ac7a7d4 100644
--- a/src/plugins/platforms/kms/main.cpp
+++ b/src/plugins/platforms/kms/main.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QKmsIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "kms.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "kms.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
diff --git a/src/plugins/platforms/linuxfb/main.cpp b/src/plugins/platforms/linuxfb/main.cpp
index 046ee913d8..ba70984073 100644
--- a/src/plugins/platforms/linuxfb/main.cpp
+++ b/src/plugins/platforms/linuxfb/main.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QLinuxFbIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "linuxfb.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "linuxfb.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
diff --git a/src/plugins/platforms/minimal/main.cpp b/src/plugins/platforms/minimal/main.cpp
index 4c746a85f2..98babf6876 100644
--- a/src/plugins/platforms/minimal/main.cpp
+++ b/src/plugins/platforms/minimal/main.cpp
@@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE
class QMinimalIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "minimal.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "minimal.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
diff --git a/src/plugins/platforms/minimalegl/main.cpp b/src/plugins/platforms/minimalegl/main.cpp
index 7ee14ae5ff..52ab3ad689 100644
--- a/src/plugins/platforms/minimalegl/main.cpp
+++ b/src/plugins/platforms/minimalegl/main.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QMinimalEglIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "minimalegl.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "minimalegl.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
diff --git a/src/plugins/platforms/offscreen/main.cpp b/src/plugins/platforms/offscreen/main.cpp
index 64a0586036..363f2afcc3 100644
--- a/src/plugins/platforms/offscreen/main.cpp
+++ b/src/plugins/platforms/offscreen/main.cpp
@@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE
class QOffscreenIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "offscreen.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "offscreen.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
};
diff --git a/src/plugins/platforms/openwfd/main.cpp b/src/plugins/platforms/openwfd/main.cpp
index d28ab945fa..b0403bc533 100644
--- a/src/plugins/platforms/openwfd/main.cpp
+++ b/src/plugins/platforms/openwfd/main.cpp
@@ -38,7 +38,7 @@ QT_BEGIN_NAMESPACE
class QOpenWFDIntegrationPlugin : public QPlatformIntegrationPlugin
{
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid)
public:
QPlatformIntegration *create(const QString&, const QStringList&);
};
diff --git a/src/plugins/platforms/qnx/main.h b/src/plugins/platforms/qnx/main.h
index 5e69ee3889..955bef471c 100644
--- a/src/plugins/platforms/qnx/main.h
+++ b/src/plugins/platforms/qnx/main.h
@@ -38,7 +38,7 @@ QT_BEGIN_NAMESPACE
class QQnxIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "qnx.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "qnx.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&);
};
diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp
index 99c44c69ef..5ed8d30e67 100644
--- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp
+++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp
@@ -102,7 +102,7 @@ HRESULT STDMETHODCALLTYPE AccessibleApplication::get_toolkitName(/* [retval][out
HRESULT STDMETHODCALLTYPE AccessibleApplication::get_toolkitVersion(/* [retval][out] */ BSTR *version)
{
- *version = ::SysAllocString(QT_UNICODE_LITERAL(QT_VERSION_STR));
+ *version = ::SysAllocString(TEXT(QT_VERSION_STR));
return S_OK;
}
diff --git a/src/plugins/platforms/windows/main.cpp b/src/plugins/platforms/windows/main.cpp
index 5bdcbef01e..29bb9562e3 100644
--- a/src/plugins/platforms/windows/main.cpp
+++ b/src/plugins/platforms/windows/main.cpp
@@ -97,7 +97,7 @@ QT_BEGIN_NAMESPACE
class QWindowsIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "windows.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "windows.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&, int &, char **);
};
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index 0184877fdd..06c9985cac 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -39,7 +39,6 @@
#include <QtGui/QOpenGLContext>
#if defined(QT_OPENGL_ES_2_ANGLE) || defined(QT_OPENGL_DYNAMIC)
-# define EGL_EGLEXT_PROTOTYPES
# include <QtANGLE/EGL/eglext.h>
#endif
@@ -137,7 +136,6 @@ bool QWindowsLibEGL::init()
eglGetError = RESOLVE((EGLint (EGLAPIENTRY *)(void)), eglGetError);
eglGetDisplay = RESOLVE((EGLDisplay (EGLAPIENTRY *)(EGLNativeDisplayType)), eglGetDisplay);
- eglGetPlatformDisplayEXT = RESOLVE((EGLDisplay (EGLAPIENTRY *)(EGLenum platform, void *native_display, const EGLint *attrib_list)), eglGetPlatformDisplayEXT);
eglInitialize = RESOLVE((EGLBoolean (EGLAPIENTRY *)(EGLDisplay, EGLint *, EGLint *)), eglInitialize);
eglTerminate = RESOLVE((EGLBoolean (EGLAPIENTRY *)(EGLDisplay)), eglTerminate);
eglChooseConfig = RESOLVE((EGLBoolean (EGLAPIENTRY *)(EGLDisplay, const EGLint *, EGLConfig *, EGLint, EGLint *)), eglChooseConfig);
@@ -156,7 +154,15 @@ bool QWindowsLibEGL::init()
eglSwapBuffers = RESOLVE((EGLBoolean (EGLAPIENTRY *)(EGLDisplay , EGLSurface)), eglSwapBuffers);
eglGetProcAddress = RESOLVE((__eglMustCastToProperFunctionPointerType (EGLAPIENTRY * )(const char *)), eglGetProcAddress);
- return eglGetError && eglGetDisplay && eglInitialize;
+ if (!eglGetError || !eglGetDisplay || !eglInitialize || !eglGetProcAddress)
+ return false;
+
+ eglGetPlatformDisplayEXT = 0;
+#ifdef EGL_ANGLE_platform_angle
+ eglGetPlatformDisplayEXT = reinterpret_cast<EGLDisplay (EGLAPIENTRY *)(EGLenum, void *, const EGLint *)>(eglGetProcAddress("eglGetPlatformDisplayEXT"));
+#endif
+
+ return true;
}
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
@@ -360,7 +366,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester:
EGLDisplay display = EGL_NO_DISPLAY;
EGLint major = 0;
EGLint minor = 0;
-#ifdef EGL_ANGLE_platform_angle_opengl
+#ifdef EGL_ANGLE_platform_angle
if (libEGL.eglGetPlatformDisplayEXT
&& (preferredType & QWindowsOpenGLTester::AngleBackendMask)) {
const EGLint anglePlatformAttributes[][5] = {
@@ -384,7 +390,7 @@ QWindowsEGLStaticContext *QWindowsEGLStaticContext::create(QWindowsOpenGLTester:
}
}
}
-#else // EGL_ANGLE_platform_angle_opengl
+#else // EGL_ANGLE_platform_angle
Q_UNUSED(preferredType)
#endif
if (display == EGL_NO_DISPLAY)
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.h b/src/plugins/platforms/windows/qwindowseglcontext.h
index 2b249348c3..d8302c97a7 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.h
+++ b/src/plugins/platforms/windows/qwindowseglcontext.h
@@ -46,7 +46,6 @@ struct QWindowsLibEGL
EGLint (EGLAPIENTRY * eglGetError)(void);
EGLDisplay (EGLAPIENTRY * eglGetDisplay)(EGLNativeDisplayType display_id);
- EGLDisplay (EGLAPIENTRY * eglGetPlatformDisplayEXT)(EGLenum platform, void *native_display, const EGLint *attrib_list);
EGLBoolean (EGLAPIENTRY * eglInitialize)(EGLDisplay dpy, EGLint *major, EGLint *minor);
EGLBoolean (EGLAPIENTRY * eglTerminate)(EGLDisplay dpy);
EGLBoolean (EGLAPIENTRY * eglChooseConfig)(EGLDisplay dpy, const EGLint *attrib_list,
@@ -74,6 +73,8 @@ struct QWindowsLibEGL
EGLBoolean (EGLAPIENTRY * eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
__eglMustCastToProperFunctionPointerType (EGLAPIENTRY * eglGetProcAddress)(const char *procname);
+ EGLDisplay (EGLAPIENTRY * eglGetPlatformDisplayEXT)(EGLenum platform, void *native_display, const EGLint *attrib_list);
+
private:
#if !defined(QT_STATIC) || defined(QT_OPENGL_DYNAMIC)
void *resolve(const char *name);
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index 9691156403..6e58c55bbe 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -34,6 +34,7 @@
#include "qwindowsnativeinterface.h"
#include "qwindowswindow.h"
#include "qwindowscontext.h"
+#include "qwindowsfontdatabase.h"
#include "qwindowsopenglcontext.h"
#include "qwindowsopengltester.h"
#include "qwindowsintegration.h"
@@ -222,6 +223,11 @@ int QWindowsNativeInterface::registerMimeType(const QString &mimeType)
return QWindowsMime::registerMimeType(mimeType);
}
+QFont QWindowsNativeInterface::logFontToQFont(const void *logFont, int verticalDpi)
+{
+ return QWindowsFontDatabase::LOGFONT_to_QFont(*reinterpret_cast<const LOGFONT *>(logFont), verticalDpi);
+}
+
QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &function) const
{
if (function == QWindowsWindowFunctions::setTouchWindowTouchTypeIdentifier())
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h
index be8418b769..97839ae1ae 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.h
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h
@@ -34,6 +34,7 @@
#ifndef QWINDOWSNATIVEINTERFACE_H
#define QWINDOWSNATIVEINTERFACE_H
+#include <QtGui/qfont.h>
#include <QtGui/qpa/qplatformnativeinterface.h>
QT_BEGIN_NAMESPACE
@@ -77,6 +78,7 @@ public:
Q_INVOKABLE void registerWindowsMime(void *mimeIn);
Q_INVOKABLE void unregisterWindowsMime(void *mime);
Q_INVOKABLE int registerMimeType(const QString &mimeType);
+ Q_INVOKABLE QFont logFontToQFont(const void *logFont, int verticalDpi);
bool asyncExpose() const;
void setAsyncExpose(bool value);
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 30b58f78e9..d6677bb228 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -438,6 +438,8 @@ QDebug operator<<(QDebug debug, const WindowCreationData &d)
// Fix top level window flags in case only the type flags are passed.
static inline void fixTopLevelWindowFlags(Qt::WindowFlags &flags)
{
+ // Not supported on Windows, also do correction when it is set.
+ flags &= ~Qt::WindowFullscreenButtonHint;
switch (flags) {
case Qt::Window:
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint
diff --git a/src/plugins/platforms/winrt/main.cpp b/src/plugins/platforms/winrt/main.cpp
index 1398c52e96..d1cf08887f 100644
--- a/src/plugins/platforms/winrt/main.cpp
+++ b/src/plugins/platforms/winrt/main.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -40,7 +43,7 @@ QT_BEGIN_NAMESPACE
class QWinRTIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "winrt.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "winrt.json")
public:
QStringList keys() const;
diff --git a/src/plugins/platforms/winrt/qwinrtbackingstore.cpp b/src/plugins/platforms/winrt/qwinrtbackingstore.cpp
index b55551e820..dcf8239538 100644
--- a/src/plugins/platforms/winrt/qwinrtbackingstore.cpp
+++ b/src/plugins/platforms/winrt/qwinrtbackingstore.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtbackingstore.h b/src/plugins/platforms/winrt/qwinrtbackingstore.h
index 69bd3c397c..20b27a3865 100644
--- a/src/plugins/platforms/winrt/qwinrtbackingstore.h
+++ b/src/plugins/platforms/winrt/qwinrtbackingstore.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtcursor.cpp b/src/plugins/platforms/winrt/qwinrtcursor.cpp
index 1adb2bb89f..94ce23bd2c 100644
--- a/src/plugins/platforms/winrt/qwinrtcursor.cpp
+++ b/src/plugins/platforms/winrt/qwinrtcursor.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -46,7 +49,7 @@ using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::UI::Core;
using namespace ABI::Windows::Foundation;
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class QWinRTCursorPrivate
{
@@ -155,3 +158,6 @@ QPoint QWinRTCursor::pos() const
coreWindow->get_PointerPosition(&point);
return QPoint(point.X, point.Y);
}
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/platforms/winrt/qwinrtcursor.h b/src/plugins/platforms/winrt/qwinrtcursor.h
index 4245faab6f..9c9b9e93ef 100644
--- a/src/plugins/platforms/winrt/qwinrtcursor.h
+++ b/src/plugins/platforms/winrt/qwinrtcursor.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -36,7 +39,7 @@
#include <qpa/qplatformcursor.h>
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class QWinRTCursorPrivate;
class QWinRTCursor : public QPlatformCursor
@@ -54,4 +57,6 @@ private:
Q_DECLARE_PRIVATE(QWinRTCursor)
};
+QT_END_NAMESPACE
+
#endif // QWINRTCURSOR_H
diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
index fd90582119..42ffe8f716 100644
--- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp
+++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -33,6 +36,9 @@
#include "qwinrteglcontext.h"
+#define EGL_EGLEXT_PROTOTYPES
+#include "EGL/eglext.h"
+
QT_BEGIN_NAMESPACE
QWinRTEGLContext::QWinRTEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLSurface surface, EGLConfig config)
@@ -40,6 +46,17 @@ QWinRTEGLContext::QWinRTEGLContext(const QSurfaceFormat &format, QPlatformOpenGL
{
}
+void QWinRTEGLContext::swapBuffers(QPlatformSurface *surface)
+{
+#ifdef Q_OS_WINPHONE
+ const QSize size = surface->surface()->size();
+ eglPostSubBufferNV(eglDisplay(), eglSurfaceForPlatformSurface(surface),
+ 0, 0, size.width(), size.height());
+#else
+ eglSwapBuffers(eglDisplay(), eglSurfaceForPlatformSurface(surface));
+#endif
+}
+
EGLSurface QWinRTEGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
{
if (surface->surface()->surfaceClass() == QSurface::Window) {
diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.h b/src/plugins/platforms/winrt/qwinrteglcontext.h
index bec9c19089..958d623c4c 100644
--- a/src/plugins/platforms/winrt/qwinrteglcontext.h
+++ b/src/plugins/platforms/winrt/qwinrteglcontext.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -43,6 +46,7 @@ class QWinRTEGLContext : public QEGLPlatformContext
public:
explicit QWinRTEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLSurface surface, EGLConfig config);
+ void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE;
protected:
diff --git a/src/plugins/platforms/winrt/qwinrteventdispatcher.cpp b/src/plugins/platforms/winrt/qwinrteventdispatcher.cpp
index 7f77b79660..716681c905 100644
--- a/src/plugins/platforms/winrt/qwinrteventdispatcher.cpp
+++ b/src/plugins/platforms/winrt/qwinrteventdispatcher.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrteventdispatcher.h b/src/plugins/platforms/winrt/qwinrteventdispatcher.h
index 35e637eba5..ecbdde34bd 100644
--- a/src/plugins/platforms/winrt/qwinrteventdispatcher.h
+++ b/src/plugins/platforms/winrt/qwinrteventdispatcher.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp
index 417befeb63..e1b2a07d5f 100644
--- a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp
+++ b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.h b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.h
index 13abf6e2b8..51b79c84ef 100644
--- a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.h
+++ b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtfileengine.cpp b/src/plugins/platforms/winrt/qwinrtfileengine.cpp
index 719bb18dd6..858cb841b9 100644
--- a/src/plugins/platforms/winrt/qwinrtfileengine.cpp
+++ b/src/plugins/platforms/winrt/qwinrtfileengine.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtfileengine.h b/src/plugins/platforms/winrt/qwinrtfileengine.h
index 983338f2e2..86721d8578 100644
--- a/src/plugins/platforms/winrt/qwinrtfileengine.h
+++ b/src/plugins/platforms/winrt/qwinrtfileengine.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -36,8 +39,6 @@
#include <private/qabstractfileengine_p.h>
-QT_BEGIN_NAMESPACE
-
namespace ABI {
namespace Windows {
namespace Storage {
@@ -46,6 +47,8 @@ namespace ABI {
}
}
+QT_BEGIN_NAMESPACE
+
class QWinRTFileEngineHandlerPrivate;
class QWinRTFileEngineHandler : public QAbstractFileEngineHandler
{
diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp b/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
index 15767c2805..09edea52e7 100644
--- a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
+++ b/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -46,6 +49,71 @@ using namespace Microsoft::WRL;
QT_BEGIN_NAMESPACE
+// Based on unicode range tables at http://www.microsoft.com/typography/otspec/os2.htm#ur
+static QFontDatabase::WritingSystem writingSystemFromUnicodeRange(const DWRITE_UNICODE_RANGE &range)
+{
+ if (range.first >= 0x0000 && range.last <= 0x007F)
+ return QFontDatabase::Latin;
+ if (range.first >= 0x0370 && range.last <= 0x03FF)
+ return QFontDatabase::Greek;
+ if (range.first >= 0x0400 && range.last <= 0x04FF)
+ return QFontDatabase::Cyrillic;
+ if (range.first >= 0x0530 && range.last <= 0x058F)
+ return QFontDatabase::Armenian;
+ if (range.first >= 0x0590 && range.last <= 0x05FF)
+ return QFontDatabase::Hebrew;
+ if (range.first >= 0x0600 && range.last <= 0x06FF)
+ return QFontDatabase::Arabic;
+ if (range.first >= 0x0700 && range.last <= 0x074F)
+ return QFontDatabase::Syriac;
+ if (range.first >= 0x0780 && range.last <= 0x07BF)
+ return QFontDatabase::Thaana;
+ if (range.first >= 0x0900 && range.last <= 0x097F)
+ return QFontDatabase::Devanagari;
+ if (range.first >= 0x0980 && range.last <= 0x09FF)
+ return QFontDatabase::Bengali;
+ if (range.first >= 0x0A00 && range.last <= 0x0A7F)
+ return QFontDatabase::Gurmukhi;
+ if (range.first >= 0x0A80 && range.last <= 0x0AFF)
+ return QFontDatabase::Gujarati;
+ if (range.first >= 0x0B00 && range.last <= 0x0B7F)
+ return QFontDatabase::Oriya;
+ if (range.first >= 0x0B80 && range.last <= 0x0BFF)
+ return QFontDatabase::Tamil;
+ if (range.first >= 0x0C00 && range.last <= 0x0C7F)
+ return QFontDatabase::Telugu;
+ if (range.first >= 0x0C80 && range.last <= 0x0CFF)
+ return QFontDatabase::Kannada;
+ if (range.first >= 0x0D00 && range.last <= 0x0D7F)
+ return QFontDatabase::Malayalam;
+ if (range.first >= 0x0D80 && range.last <= 0x0DFF)
+ return QFontDatabase::Sinhala;
+ if (range.first >= 0x0E00 && range.last <= 0x0E7F)
+ return QFontDatabase::Thai;
+ if (range.first >= 0x0E80 && range.last <= 0x0EFF)
+ return QFontDatabase::Lao;
+ if (range.first >= 0x0F00 && range.last <= 0x0FFF)
+ return QFontDatabase::Tibetan;
+ if (range.first >= 0x1000 && range.last <= 0x109F)
+ return QFontDatabase::Myanmar;
+ if (range.first >= 0x10A0 && range.last <= 0x10FF)
+ return QFontDatabase::Georgian;
+ if (range.first >= 0x1780 && range.last <= 0x17FF)
+ return QFontDatabase::Khmer;
+ if (range.first >= 0x4E00 && range.last <= 0x9FFF)
+ return QFontDatabase::SimplifiedChinese;
+ if (range.first >= 0xAC00 && range.last <= 0xD7AF)
+ return QFontDatabase::Korean;
+ if (range.first >= 0x1680 && range.last <= 0x169F)
+ return QFontDatabase::Ogham;
+ if (range.first >= 0x16A0 && range.last <= 0x16FF)
+ return QFontDatabase::Runic;
+ if (range.first >= 0x07C0 && range.last <= 0x07FF)
+ return QFontDatabase::Nko;
+
+ return QFontDatabase::Other;
+}
+
QString QWinRTFontDatabase::fontDir() const
{
QString fontDirectory = QBasicFontDatabase::fontDir();
@@ -260,17 +328,27 @@ void QWinRTFontDatabase::populateFamily(const QString &familyName)
const bool fixedPitch = fontFace->IsMonospacedFont();
- quint32 unicodeRange[4];
+ // Get writing systems from unicode ranges
quint32 actualRangeCount;
- hr = fontFace->GetUnicodeRanges(
- 2, reinterpret_cast<DWRITE_UNICODE_RANGE *>(unicodeRange), &actualRangeCount);
- if (FAILED(hr) && hr != E_NOT_SUFFICIENT_BUFFER) { // Ignore insufficient buffer; we only need 4 indices
+ hr = fontFace->GetUnicodeRanges(0, nullptr, &actualRangeCount);
+ Q_ASSERT(hr == E_NOT_SUFFICIENT_BUFFER);
+ QVector<DWRITE_UNICODE_RANGE> unicodeRanges(actualRangeCount);
+ hr = fontFace->GetUnicodeRanges(actualRangeCount, unicodeRanges.data(), &actualRangeCount);
+ if (FAILED(hr)) {
qWarning("Unable to get font unicode range: %s", qPrintable(qt_error_string(hr)));
continue;
}
- quint32 codePageRange[2] = { 0, 0 };
- QSupportedWritingSystems writingSystems =
- QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
+ QSupportedWritingSystems writingSystems;
+ for (quint32 i = 0; i < actualRangeCount; ++i) {
+ const QFontDatabase::WritingSystem writingSystem = writingSystemFromUnicodeRange(unicodeRanges.at(i));
+ writingSystems.setSupported(writingSystem);
+ }
+ if (writingSystems.supported(QFontDatabase::SimplifiedChinese)) {
+ writingSystems.setSupported(QFontDatabase::TraditionalChinese);
+ writingSystems.setSupported(QFontDatabase::Japanese);
+ }
+ if (writingSystems.supported(QFontDatabase::Latin))
+ writingSystems.setSupported(QFontDatabase::Vietnamese);
IDWriteFontFile *fontFile;
hr = fontFace->GetFiles(&fileCount, &fontFile);
diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.h b/src/plugins/platforms/winrt/qwinrtfontdatabase.h
index cde81baa44..7b3f402c13 100644
--- a/src/plugins/platforms/winrt/qwinrtfontdatabase.h
+++ b/src/plugins/platforms/winrt/qwinrtfontdatabase.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -36,12 +39,14 @@
#include <QtPlatformSupport/private/qbasicfontdatabase_p.h>
-QT_BEGIN_NAMESPACE
-
#ifdef QT_WINRT_USE_DWRITE
struct IDWriteFontFile;
struct IDWriteFontFamily;
+#endif
+QT_BEGIN_NAMESPACE
+
+#ifdef QT_WINRT_USE_DWRITE
struct FontDescription
{
quint32 index;
diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
index f0de578db6..c94b53ef1c 100644
--- a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
+++ b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.h b/src/plugins/platforms/winrt/qwinrtinputcontext.h
index 761908a9cb..ce7fbabf49 100644
--- a/src/plugins/platforms/winrt/qwinrtinputcontext.h
+++ b/src/plugins/platforms/winrt/qwinrtinputcontext.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp
index 015ebaadb5..70ee6dbe6a 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.cpp
+++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.h b/src/plugins/platforms/winrt/qwinrtintegration.h
index 1ec44cd46a..bbd6c1e41b 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.h
+++ b/src/plugins/platforms/winrt/qwinrtintegration.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp
index c5d3634523..4fc1fea626 100644
--- a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp
+++ b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.h b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.h
index fc510fe34e..2f473a05f7 100644
--- a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.h
+++ b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp
index c4512b4d2d..1d36bb31f6 100644
--- a/src/plugins/platforms/winrt/qwinrtscreen.cpp
+++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h
index cbef9543a9..d34ce75748 100644
--- a/src/plugins/platforms/winrt/qwinrtscreen.h
+++ b/src/plugins/platforms/winrt/qwinrtscreen.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtservices.cpp b/src/plugins/platforms/winrt/qwinrtservices.cpp
index 1faa3945a7..cb04f670d2 100644
--- a/src/plugins/platforms/winrt/qwinrtservices.cpp
+++ b/src/plugins/platforms/winrt/qwinrtservices.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtservices.h b/src/plugins/platforms/winrt/qwinrtservices.h
index 0262a2ab83..585eb2f010 100644
--- a/src/plugins/platforms/winrt/qwinrtservices.h
+++ b/src/plugins/platforms/winrt/qwinrtservices.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -37,7 +40,7 @@
#include <qpa/qplatformservices.h>
#include <QtCore/QScopedPointer>
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class QWinRTServicesPrivate;
class QWinRTServices : public QPlatformServices
@@ -54,4 +57,6 @@ private:
Q_DECLARE_PRIVATE(QWinRTServices)
};
+QT_END_NAMESPACE
+
#endif // QWINRTSERVICES_H
diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp
index c42368cc87..a0fa2798a8 100644
--- a/src/plugins/platforms/winrt/qwinrttheme.cpp
+++ b/src/plugins/platforms/winrt/qwinrttheme.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrttheme.h b/src/plugins/platforms/winrt/qwinrttheme.h
index 73dcd6cdf4..2e159cbd55 100644
--- a/src/plugins/platforms/winrt/qwinrttheme.h
+++ b/src/plugins/platforms/winrt/qwinrttheme.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp
index b96f4255c2..adc5dfb776 100644
--- a/src/plugins/platforms/winrt/qwinrtwindow.cpp
+++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/winrt/qwinrtwindow.h b/src/plugins/platforms/winrt/qwinrtwindow.h
index eee95d6bd3..3cfe346ab2 100644
--- a/src/plugins/platforms/winrt/qwinrtwindow.h
+++ b/src/plugins/platforms/winrt/qwinrtwindow.h
@@ -5,7 +5,7 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,16 +16,19 @@
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro
index 29b6d1d2f7..9de0476810 100644
--- a/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro
+++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro
@@ -1,6 +1,6 @@
TEMPLATE = subdirs
-contains(QT_CONFIG, egl):contains(QT_CONFIG, egl_x11) {
+contains(QT_CONFIG, egl): contains(QT_CONFIG, egl_x11): contains(QT_CONFIG, opengl) {
SUBDIRS += xcb_egl
}
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h
index c71c668f31..74c117582a 100644
--- a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h
@@ -57,7 +57,9 @@ public:
virtual bool handleXcbEvent(xcb_generic_event_t *event, uint responseType);
virtual QXcbWindow *createWindow(QWindow *window) const = 0;
+#ifndef QT_NO_OPENGL
virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const = 0;
+#endif
virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const = 0;
virtual QXcbNativeInterfaceHandler *nativeInterfaceHandler() const { return Q_NULLPTR; }
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 5d32eb7614..78282d1415 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -70,7 +70,6 @@
#endif
#if defined(XCB_USE_XINPUT2)
-#include <X11/extensions/XInput2.h>
#include <X11/extensions/XI2proto.h>
#endif
@@ -457,6 +456,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
, m_focusWindow(0)
, m_systemTrayTracker(0)
, m_glIntegration(Q_NULLPTR)
+ , m_xiGrab(false)
{
#ifdef XCB_USE_XLIB
Display *dpy = XOpenDisplay(m_displayName.constData());
@@ -909,7 +909,7 @@ static Qt::MouseButtons translateMouseButtons(int s)
return ret;
}
-static Qt::MouseButton translateMouseButton(xcb_button_t s)
+Qt::MouseButton QXcbConnection::translateMouseButton(xcb_button_t s)
{
switch (s) {
case 1: return Qt::LeftButton;
@@ -944,39 +944,6 @@ static Qt::MouseButton translateMouseButton(xcb_button_t s)
}
}
-void QXcbConnection::handleButtonPress(xcb_generic_event_t *ev)
-{
- xcb_button_press_event_t *event = (xcb_button_press_event_t *)ev;
-
- // the event explicitly contains the state of the three first buttons,
- // the rest we need to manage ourselves
- m_buttons = (m_buttons & ~0x7) | translateMouseButtons(event->state);
- m_buttons |= translateMouseButton(event->detail);
- qCDebug(lcQpaXInput, "xcb: pressed mouse button %d, button state %X", event->detail, static_cast<unsigned int>(m_buttons));
-}
-
-void QXcbConnection::handleButtonRelease(xcb_generic_event_t *ev)
-{
- xcb_button_release_event_t *event = (xcb_button_release_event_t *)ev;
-
- // the event explicitly contains the state of the three first buttons,
- // the rest we need to manage ourselves
- m_buttons = (m_buttons & ~0x7) | translateMouseButtons(event->state);
- m_buttons &= ~translateMouseButton(event->detail);
- qCDebug(lcQpaXInput, "xcb: released mouse button %d, button state %X", event->detail, static_cast<unsigned int>(m_buttons));
-}
-
-void QXcbConnection::handleMotionNotify(xcb_generic_event_t *ev)
-{
- xcb_motion_notify_event_t *event = (xcb_motion_notify_event_t *)ev;
-
- m_buttons = (m_buttons & ~0x7) | translateMouseButtons(event->state);
-#ifdef Q_XCB_DEBUG
- qCDebug(lcQpaXInput, "xcb: moved mouse to %4d, %4d; button state %X",
- event->event_x, event->event_y, static_cast<unsigned int>(m_buttons));
-#endif
-}
-
#ifndef QT_NO_XKB
namespace {
typedef union {
@@ -1018,18 +985,35 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
switch (response_type) {
case XCB_EXPOSE:
HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent);
- case XCB_BUTTON_PRESS:
- m_keyboard->updateXKBStateFromCore(((xcb_button_press_event_t *)event)->state);
- handleButtonPress(event);
+
+ // press/release/motion is only delivered here when XI 2.2+ is _not_ in use
+ case XCB_BUTTON_PRESS: {
+ xcb_button_press_event_t *ev = (xcb_button_press_event_t *)event;
+ m_keyboard->updateXKBStateFromCore(ev->state);
+ // the event explicitly contains the state of the three first buttons,
+ // the rest we need to manage ourselves
+ m_buttons = (m_buttons & ~0x7) | translateMouseButtons(ev->state);
+ m_buttons |= translateMouseButton(ev->detail);
+ qCDebug(lcQpaXInput, "legacy mouse press, button %d state %X", ev->detail, static_cast<unsigned int>(m_buttons));
HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent);
- case XCB_BUTTON_RELEASE:
- m_keyboard->updateXKBStateFromCore(((xcb_button_release_event_t *)event)->state);
- handleButtonRelease(event);
+ }
+ case XCB_BUTTON_RELEASE: {
+ xcb_button_release_event_t *ev = (xcb_button_release_event_t *)event;
+ m_keyboard->updateXKBStateFromCore(ev->state);
+ m_buttons = (m_buttons & ~0x7) | translateMouseButtons(ev->state);
+ m_buttons &= ~translateMouseButton(ev->detail);
+ qCDebug(lcQpaXInput, "legacy mouse release, button %d state %X", ev->detail, static_cast<unsigned int>(m_buttons));
HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent);
- case XCB_MOTION_NOTIFY:
- m_keyboard->updateXKBStateFromCore(((xcb_motion_notify_event_t *)event)->state);
- handleMotionNotify(event);
+ }
+ case XCB_MOTION_NOTIFY: {
+ xcb_motion_notify_event_t *ev = (xcb_motion_notify_event_t *)event;
+ m_keyboard->updateXKBStateFromCore(ev->state);
+ m_buttons = (m_buttons & ~0x7) | translateMouseButtons(ev->state);
+ qCDebug(lcQpaXInput, "legacy mouse move %d,%d button %d state %X", ev->event_x, ev->event_y,
+ ev->detail, static_cast<unsigned int>(m_buttons));
HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent);
+ }
+
case XCB_CONFIGURE_NOTIFY:
HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent);
case XCB_MAP_NOTIFY:
@@ -1090,6 +1074,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
break;
#if defined(XCB_USE_XINPUT2)
case XCB_GE_GENERIC:
+ // Here the windowEventListener is invoked from xi2HandleEvent()
if (m_xi2Enabled)
xi2HandleEvent(reinterpret_cast<xcb_ge_event_t *>(event));
break;
@@ -1931,6 +1916,12 @@ void QXcbConnection::initializeXKB()
#endif
}
+bool QXcbConnection::xi2MouseEvents() const
+{
+ static bool mouseViaXI2 = !qEnvironmentVariableIsSet("QT_XCB_NO_XI2_MOUSE");
+ return mouseViaXI2;
+}
+
#if defined(XCB_USE_XINPUT2)
static int xi2ValuatorOffset(unsigned char *maskPtr, int maskLen, int number)
{
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 466492ce42..0191b0e1ef 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -69,7 +69,8 @@
#endif
#endif
struct XInput2TouchDeviceData;
-#endif
+#endif // XCB_USE_XINPUT2
+
struct xcb_randr_get_output_info_reply_t;
//#define Q_XCB_DEBUG
@@ -347,6 +348,7 @@ public:
virtual void handleFocusInEvent(const xcb_focus_in_event_t *) {}
virtual void handleFocusOutEvent(const xcb_focus_out_event_t *) {}
virtual void handlePropertyNotifyEvent(const xcb_property_notify_event_t *) {}
+ virtual void handleXIMouseEvent(xcb_ge_event_t *) {}
virtual QXcbWindow *toWindow() { return 0; }
};
@@ -413,14 +415,14 @@ public:
void xi2Select(xcb_window_t window);
#endif
#ifdef XCB_USE_XINPUT21
- bool isUsingXInput21() const { return m_xi2Enabled && m_xi2Minor >= 1; }
+ bool isAtLeastXI21() const { return m_xi2Enabled && m_xi2Minor >= 1; }
#else
- bool isUsingXInput21() const { return false; }
+ bool isAtLeastXI21() const { return false; }
#endif
#ifdef XCB_USE_XINPUT22
- bool isUsingXInput22() const { return m_xi2Enabled && m_xi2Minor >= 2; }
+ bool isAtLeastXI22() const { return m_xi2Enabled && m_xi2Minor >= 2; }
#else
- bool isUsingXInput22() const { return false; }
+ bool isAtLeastXI22() const { return false; }
#endif
void sync();
@@ -457,7 +459,9 @@ public:
xcb_timestamp_t getTimestamp();
+ void setButton(Qt::MouseButton button, bool down) { if (down) m_buttons |= button; else m_buttons &= ~button; }
Qt::MouseButtons buttons() const { return m_buttons; }
+ Qt::MouseButton translateMouseButton(xcb_button_t s);
QXcbWindow *focusWindow() const { return m_focusWindow; }
void setFocusWindow(QXcbWindow *);
@@ -479,12 +483,19 @@ public:
void handleEnterEvent(const xcb_enter_notify_event_t *);
#endif
+#ifdef XCB_USE_XINPUT22
+ bool xi2SetMouseGrabEnabled(xcb_window_t w, bool grab);
+#endif
+ Qt::MouseButton xiToQtMouseButton(uint32_t b);
+
QXcbEventReader *eventReader() const { return m_reader; }
bool canGrab() const { return m_canGrabServer; }
QXcbGlIntegration *glIntegration() const { return m_glIntegration; }
+ bool xi2MouseEvents() const;
+
protected:
bool event(QEvent *e) Q_DECL_OVERRIDE;
@@ -512,9 +523,6 @@ private:
bool checkOutputIsPrimary(xcb_window_t rootWindow, xcb_randr_output_t output);
void initializeScreens();
void updateScreens(const xcb_randr_notify_event_t *event);
- void handleButtonPress(xcb_generic_event_t *event);
- void handleButtonRelease(xcb_generic_event_t *event);
- void handleMotionNotify(xcb_generic_event_t *event);
bool m_xi2Enabled;
int m_xi2Minor;
@@ -527,6 +535,9 @@ private:
void xi2HandleHierachyEvent(void *event);
void xi2HandleDeviceChangedEvent(void *event);
int m_xiOpCode, m_xiEventBase, m_xiErrorBase;
+#ifdef XCB_USE_XINPUT22
+ void xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindow);
+#endif // XCB_USE_XINPUT22
#ifndef QT_NO_TABLETEVENT
struct TabletData {
TabletData() : deviceId(0), pointerType(QTabletEvent::UnknownPointer),
@@ -546,10 +557,10 @@ private:
};
QHash<int, ValuatorClassInfo> valuatorInfo;
};
- bool xi2HandleTabletEvent(void *event, TabletData *tabletData);
+ bool xi2HandleTabletEvent(void *event, TabletData *tabletData, QXcbWindowEventListener *eventListener);
void xi2ReportTabletEvent(TabletData &tabletData, void *event);
QVector<TabletData> m_tabletData;
-#endif
+#endif // !QT_NO_TABLETEVENT
struct ScrollingDevice {
ScrollingDevice() : deviceId(0), verticalIndex(0), horizontalIndex(0), orientations(0), legacyOrientations(0) { }
int deviceId;
@@ -562,9 +573,7 @@ private:
void updateScrollingDevice(ScrollingDevice& scrollingDevice, int num_classes, void *classes);
void xi2HandleScrollEvent(void *event, ScrollingDevice &scrollingDevice);
QHash<int, ScrollingDevice> m_scrollingDevices;
-#endif // XCB_USE_XINPUT2
-#if defined(XCB_USE_XINPUT2)
static bool xi2GetValuatorValueIfSet(void *event, int valuatorNum, double *value);
static bool xi2PrepareXIGenericDeviceEvent(xcb_ge_event_t *event, int opCode);
#endif
@@ -636,6 +645,7 @@ private:
QByteArray m_startupId;
QXcbSystemTrayTracker *m_systemTrayTracker;
QXcbGlIntegration *m_glIntegration;
+ bool m_xiGrab;
friend class QXcbEventReader;
};
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index 9e48067a51..e165c753ab 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -43,7 +43,6 @@
#include <X11/extensions/XInput2.h>
#include <X11/extensions/XI2proto.h>
-#define FINGER_MAX_WIDTH_MM 10
struct XInput2TouchDeviceData {
XInput2TouchDeviceData()
@@ -175,9 +174,11 @@ void QXcbConnection::xi2SetupDevices()
case XIKeyClass:
qCDebug(lcQpaXInputDevices) << " it's a keyboard";
break;
+#ifdef XCB_USE_XINPUT22
case XITouchClass:
// will be handled in deviceForId()
break;
+#endif
default:
qCDebug(lcQpaXInputDevices) << " has class" << devices[i].classes[c]->type;
break;
@@ -274,34 +275,37 @@ void QXcbConnection::xi2Select(xcb_window_t window)
unsigned char *xiBitMask = reinterpret_cast<unsigned char *>(&bitMask);
#ifdef XCB_USE_XINPUT22
- if (isUsingXInput22()) {
+ if (isAtLeastXI22()) {
bitMask |= XI_TouchBeginMask;
bitMask |= XI_TouchUpdateMask;
bitMask |= XI_TouchEndMask;
+ bitMask |= XI_PropertyEventMask; // for tablets
+ if (xi2MouseEvents()) {
+ // We want both mouse and touch through XI2 if touch is supported (>= 2.2).
+ // The plain xcb press and motion events will not be delivered after this.
+ bitMask |= XI_ButtonPressMask;
+ bitMask |= XI_ButtonReleaseMask;
+ bitMask |= XI_MotionMask;
+ qCDebug(lcQpaXInput, "XInput 2.2: Selecting press/release/motion events in addition to touch");
+ }
XIEventMask mask;
mask.mask_len = sizeof(bitMask);
mask.mask = xiBitMask;
- if (!m_touchDevices.isEmpty()) {
- // If we select for touch events on the master pointer, XInput2
- // will not synthesize mouse events. This means Qt must do it,
- // which is also preferable, since Qt can control better when
- // to do so.
- mask.deviceid = XIAllMasterDevices;
- Status result = XISelectEvents(xDisplay, window, &mask, 1);
- if (result != Success)
- qCDebug(lcQpaXInput, "XInput 2.2: failed to select touch events, window %x, result %d", window, result);
- }
+ // When xi2MouseEvents() is true (the default), pointer emulation for touch and tablet
+ // events will get disabled. This is preferable for touch, as Qt Quick handles touch events
+ // directly while for others QtGui synthesizes mouse events, not so much for tablets. For
+ // the latter we will synthesize the events ourselves.
+ mask.deviceid = XIAllMasterDevices;
+ Status result = XISelectEvents(xDisplay, window, &mask, 1);
+ if (result != Success)
+ qCDebug(lcQpaXInput, "XInput 2.2: failed to select pointer/touch events, window %x, result %d", window, result);
}
#endif // XCB_USE_XINPUT22
+ const bool pointerSelected = isAtLeastXI22() && xi2MouseEvents();
QSet<int> tabletDevices;
#ifndef QT_NO_TABLETEVENT
- // For each tablet, select some additional event types.
- // Press, motion, etc. events must never be selected for _all_ devices
- // as that would render the standard XCB_MOTION_NOTIFY and
- // similar handlers useless and we have no intention to infect
- // all the pure xcb code with Xlib-based XI2.
- if (!m_tabletData.isEmpty()) {
+ if (!m_tabletData.isEmpty() && !pointerSelected) {
unsigned int tabletBitMask;
unsigned char *xiTabletBitMask = reinterpret_cast<unsigned char *>(&tabletBitMask);
QVector<XIEventMask> xiEventMask(m_tabletData.count());
@@ -322,7 +326,8 @@ void QXcbConnection::xi2Select(xcb_window_t window)
#ifdef XCB_USE_XINPUT21
// Enable each scroll device
- if (!m_scrollingDevices.isEmpty()) {
+ if (!m_scrollingDevices.isEmpty() && !pointerSelected) {
+ // Only when XI2 mouse events are not enabled, otherwise motion and release are selected already.
QVector<XIEventMask> xiEventMask(m_scrollingDevices.size());
unsigned int scrollBitMask;
unsigned char *xiScrollBitMask = reinterpret_cast<unsigned char *>(&scrollBitMask);
@@ -359,8 +364,8 @@ void QXcbConnection::xi2Select(xcb_window_t window)
XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
{
XInput2TouchDeviceData *dev = Q_NULLPTR;
- QHash<int, XInput2TouchDeviceData*>::const_iterator devIt = m_touchDevices.find(id);
- if ( devIt != m_touchDevices.end() ) {
+ QHash<int, XInput2TouchDeviceData*>::const_iterator devIt = m_touchDevices.constFind(id);
+ if (devIt != m_touchDevices.cend()) {
dev = devIt.value();
} else {
int nrDevices = 0;
@@ -424,7 +429,7 @@ XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
dev->size.width() > 10000 || dev->size.height() > 10000)
dev->size = QSizeF(130, 110);
}
- if (!isUsingXInput22() || type == QTouchDevice::TouchPad)
+ if (!isAtLeastXI22() || type == QTouchDevice::TouchPad)
caps |= QTouchDevice::MouseEmulation;
if (type >= QTouchDevice::TouchScreen && type <= QTouchDevice::TouchPad) {
@@ -446,9 +451,9 @@ XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
}
#if defined(XCB_USE_XINPUT21) || !defined(QT_NO_TABLETEVENT)
-static qreal fixed1616ToReal(FP1616 val)
+static inline qreal fixed1616ToReal(FP1616 val)
{
- return (qreal(val >> 16)) + (val & 0xFFFF) / (qreal)0xFFFF;
+ return qreal(val) / 0x10000;
}
#endif // defined(XCB_USE_XINPUT21) || !defined(QT_NO_TABLETEVENT)
@@ -467,163 +472,280 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event)
{
if (xi2PrepareXIGenericDeviceEvent(event, m_xiOpCode)) {
xXIGenericDeviceEvent *xiEvent = reinterpret_cast<xXIGenericDeviceEvent *>(event);
+ int sourceDeviceId = xiEvent->deviceid; // may be the master id
+ xXIDeviceEvent *xiDeviceEvent = 0;
+ QXcbWindowEventListener *eventListener = 0;
- if (xiEvent->evtype == XI_HierarchyChanged) {
+ switch (xiEvent->evtype) {
+ case XI_ButtonPress:
+ case XI_ButtonRelease:
+ case XI_Motion:
+ case XI_TouchBegin:
+ case XI_TouchUpdate:
+ case XI_TouchEnd:
+ {
+ xiDeviceEvent = reinterpret_cast<xXIDeviceEvent *>(event);
+ eventListener = windowEventListenerFromId(xiDeviceEvent->event);
+ if (eventListener) {
+ long result = 0;
+ if (eventListener->handleGenericEvent(reinterpret_cast<xcb_generic_event_t *>(event), &result))
+ return;
+ }
+ sourceDeviceId = xiDeviceEvent->sourceid; // use the actual device id instead of the master
+ break;
+ }
+ case XI_HierarchyChanged:
xi2HandleHierachyEvent(xiEvent);
return;
- }
- if (xiEvent->evtype == XI_DeviceChanged) {
+ case XI_DeviceChanged:
xi2HandleDeviceChangedEvent(xiEvent);
return;
+ default:
+ break;
}
#ifndef QT_NO_TABLETEVENT
for (int i = 0; i < m_tabletData.count(); ++i) {
- if (m_tabletData.at(i).deviceId == xiEvent->deviceid) {
- if (xi2HandleTabletEvent(xiEvent, &m_tabletData[i]))
+ if (m_tabletData.at(i).deviceId == sourceDeviceId) {
+ if (xi2HandleTabletEvent(xiEvent, &m_tabletData[i], eventListener))
return;
}
}
#endif // QT_NO_TABLETEVENT
#ifdef XCB_USE_XINPUT21
- QHash<int, ScrollingDevice>::iterator device = m_scrollingDevices.find(xiEvent->deviceid);
+ QHash<int, ScrollingDevice>::iterator device = m_scrollingDevices.find(sourceDeviceId);
if (device != m_scrollingDevices.end())
xi2HandleScrollEvent(xiEvent, device.value());
#endif // XCB_USE_XINPUT21
#ifdef XCB_USE_XINPUT22
- if (xiEvent->evtype == XI_TouchBegin || xiEvent->evtype == XI_TouchUpdate || xiEvent->evtype == XI_TouchEnd) {
- xXIDeviceEvent* xiDeviceEvent = reinterpret_cast<xXIDeviceEvent *>(event);
- if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
- qCDebug(lcQpaXInput, "XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f",
- event->event_type, xiEvent->sequenceNumber, xiDeviceEvent->detail,
- fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y),
- fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y) );
-
- if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)) {
- XInput2TouchDeviceData *dev = touchDeviceForId(xiDeviceEvent->sourceid);
- Q_ASSERT(dev);
- const bool firstTouch = m_touchPoints.isEmpty();
- if (xiEvent->evtype == XI_TouchBegin) {
- QWindowSystemInterface::TouchPoint tp;
- tp.id = xiDeviceEvent->detail % INT_MAX;
- tp.state = Qt::TouchPointPressed;
- tp.pressure = -1.0;
- m_touchPoints[tp.id] = tp;
- }
- QWindowSystemInterface::TouchPoint &touchPoint = m_touchPoints[xiDeviceEvent->detail];
- qreal x = fixed1616ToReal(xiDeviceEvent->root_x);
- qreal y = fixed1616ToReal(xiDeviceEvent->root_y);
- qreal nx = -1.0, ny = -1.0, w = 0.0, h = 0.0;
- QXcbScreen* screen = m_screens.at(0);
- for (int i = 0; i < dev->xiDeviceInfo->num_classes; ++i) {
- XIAnyClassInfo *classinfo = dev->xiDeviceInfo->classes[i];
- if (classinfo->type == XIValuatorClass) {
- XIValuatorClassInfo *vci = reinterpret_cast<XIValuatorClassInfo *>(classinfo);
- int n = vci->number;
- double value;
- if (!xi2GetValuatorValueIfSet(xiDeviceEvent, n, &value))
- continue;
- if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
- qCDebug(lcQpaXInput, " valuator %20s value %lf from range %lf -> %lf",
- atomName(vci->label).constData(), value, vci->min, vci->max );
- if (vci->label == atom(QXcbAtom::RelX)) {
- nx = valuatorNormalized(value, vci);
- } else if (vci->label == atom(QXcbAtom::RelY)) {
- ny = valuatorNormalized(value, vci);
- } else if (vci->label == atom(QXcbAtom::AbsX)) {
- nx = valuatorNormalized(value, vci);
- } else if (vci->label == atom(QXcbAtom::AbsY)) {
- ny = valuatorNormalized(value, vci);
- } else if (vci->label == atom(QXcbAtom::AbsMTPositionX)) {
- nx = valuatorNormalized(value, vci);
- } else if (vci->label == atom(QXcbAtom::AbsMTPositionY)) {
- ny = valuatorNormalized(value, vci);
- } else if (vci->label == atom(QXcbAtom::AbsMTTouchMajor)) {
- // Convert the value within its range as a fraction of a finger's max (contact patch)
- // width in mm, and from there to pixels depending on screen resolution
- w = valuatorNormalized(value, vci) * FINGER_MAX_WIDTH_MM *
- screen->geometry().width() / screen->physicalSize().width();
- } else if (vci->label == atom(QXcbAtom::AbsMTTouchMinor)) {
- h = valuatorNormalized(value, vci) * FINGER_MAX_WIDTH_MM *
- screen->geometry().height() / screen->physicalSize().height();
- } else if (vci->label == atom(QXcbAtom::AbsMTPressure) ||
- vci->label == atom(QXcbAtom::AbsPressure)) {
- touchPoint.pressure = valuatorNormalized(value, vci);
- }
- }
- }
- // If any value was not updated, use the last-known value.
- if (nx == -1.0) {
- x = touchPoint.area.center().x();
- nx = x / screen->geometry().width();
- }
- if (ny == -1.0) {
- y = touchPoint.area.center().y();
- ny = y / screen->geometry().height();
- }
- if (xiEvent->evtype != XI_TouchEnd) {
- if (w == 0.0)
- w = touchPoint.area.width();
- if (h == 0.0)
- h = touchPoint.area.height();
- }
-
- switch (xiEvent->evtype) {
- case XI_TouchBegin:
- if (firstTouch) {
- dev->firstPressedPosition = QPointF(x, y);
- dev->firstPressedNormalPosition = QPointF(nx, ny);
- }
- dev->pointPressedPosition.insert(touchPoint.id, QPointF(x, y));
- break;
- case XI_TouchUpdate:
- if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad && dev->pointPressedPosition.value(touchPoint.id) == QPointF(x, y)) {
- qreal dx = (nx - dev->firstPressedNormalPosition.x()) *
- dev->size.width() * screen->geometry().width() / screen->physicalSize().width();
- qreal dy = (ny - dev->firstPressedNormalPosition.y()) *
- dev->size.height() * screen->geometry().height() / screen->physicalSize().height();
- x = dev->firstPressedPosition.x() + dx;
- y = dev->firstPressedPosition.y() + dy;
- touchPoint.state = Qt::TouchPointMoved;
- } else if (touchPoint.area.center() != QPoint(x, y)) {
- touchPoint.state = Qt::TouchPointMoved;
- dev->pointPressedPosition[touchPoint.id] = QPointF(x, y);
- }
- break;
- case XI_TouchEnd:
- touchPoint.state = Qt::TouchPointReleased;
- if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad && dev->pointPressedPosition.value(touchPoint.id) == QPointF(x, y)) {
- qreal dx = (nx - dev->firstPressedNormalPosition.x()) *
- dev->size.width() * screen->geometry().width() / screen->physicalSize().width();
- qreal dy = (ny - dev->firstPressedNormalPosition.y()) *
- dev->size.width() * screen->geometry().width() / screen->physicalSize().width();
- x = dev->firstPressedPosition.x() + dx;
- y = dev->firstPressedPosition.y() + dy;
- }
- dev->pointPressedPosition.remove(touchPoint.id);
- }
- touchPoint.area = QRectF(x - w/2, y - h/2, w, h);
- touchPoint.normalPosition = QPointF(nx, ny);
+ if (xiDeviceEvent) {
+ switch (xiDeviceEvent->evtype) {
+ case XI_ButtonPress:
+ case XI_ButtonRelease:
+ case XI_Motion:
+ if (xi2MouseEvents() && eventListener)
+ eventListener->handleXIMouseEvent(event);
+ break;
+ case XI_TouchBegin:
+ case XI_TouchUpdate:
+ case XI_TouchEnd:
if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
- qCDebug(lcQpaXInput) << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition <<
- " area " << touchPoint.area << " pressure " << touchPoint.pressure;
- QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiEvent->time, dev->qtTouchDevice, m_touchPoints.values());
- if (touchPoint.state == Qt::TouchPointReleased)
- // If a touchpoint was released, we can forget it, because the ID won't be reused.
- m_touchPoints.remove(touchPoint.id);
- else
- // Make sure that we don't send TouchPointPressed/Moved in more than one QTouchEvent
- // with this touch point if the next XI2 event is about a different touch point.
- touchPoint.state = Qt::TouchPointStationary;
+ qCDebug(lcQpaXInput, "XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x",
+ event->event_type, xiDeviceEvent->sequenceNumber, xiDeviceEvent->detail,
+ fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y),
+ fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event);
+ if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event))
+ xi2ProcessTouch(xiDeviceEvent, platformWindow);
+ break;
}
}
#endif // XCB_USE_XINPUT22
}
}
+#ifdef XCB_USE_XINPUT22
+void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindow)
+{
+ xXIDeviceEvent *xiDeviceEvent = static_cast<xXIDeviceEvent *>(xiDevEvent);
+ XInput2TouchDeviceData *dev = touchDeviceForId(xiDeviceEvent->sourceid);
+ Q_ASSERT(dev);
+ const bool firstTouch = m_touchPoints.isEmpty();
+ if (xiDeviceEvent->evtype == XI_TouchBegin) {
+ QWindowSystemInterface::TouchPoint tp;
+ tp.id = xiDeviceEvent->detail % INT_MAX;
+ tp.state = Qt::TouchPointPressed;
+ tp.pressure = -1.0;
+ m_touchPoints[tp.id] = tp;
+ }
+ QWindowSystemInterface::TouchPoint &touchPoint = m_touchPoints[xiDeviceEvent->detail];
+ qreal x = fixed1616ToReal(xiDeviceEvent->root_x);
+ qreal y = fixed1616ToReal(xiDeviceEvent->root_y);
+ qreal nx = -1.0, ny = -1.0, d = 0.0;
+ QXcbScreen* screen = m_screens.at(0);
+ for (int i = 0; i < dev->xiDeviceInfo->num_classes; ++i) {
+ XIAnyClassInfo *classinfo = dev->xiDeviceInfo->classes[i];
+ if (classinfo->type == XIValuatorClass) {
+ XIValuatorClassInfo *vci = reinterpret_cast<XIValuatorClassInfo *>(classinfo);
+ int n = vci->number;
+ double value;
+ if (!xi2GetValuatorValueIfSet(xiDeviceEvent, n, &value))
+ continue;
+ if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
+ qCDebug(lcQpaXInput, " valuator %20s value %lf from range %lf -> %lf",
+ atomName(vci->label).constData(), value, vci->min, vci->max );
+ if (vci->label == atom(QXcbAtom::RelX)) {
+ nx = valuatorNormalized(value, vci);
+ } else if (vci->label == atom(QXcbAtom::RelY)) {
+ ny = valuatorNormalized(value, vci);
+ } else if (vci->label == atom(QXcbAtom::AbsX)) {
+ nx = valuatorNormalized(value, vci);
+ } else if (vci->label == atom(QXcbAtom::AbsY)) {
+ ny = valuatorNormalized(value, vci);
+ } else if (vci->label == atom(QXcbAtom::AbsMTPositionX)) {
+ nx = valuatorNormalized(value, vci);
+ } else if (vci->label == atom(QXcbAtom::AbsMTPositionY)) {
+ ny = valuatorNormalized(value, vci);
+ } else if (vci->label == atom(QXcbAtom::AbsMTTouchMajor)) {
+ d = valuatorNormalized(value, vci) * screen->geometry().width();
+ } else if (vci->label == atom(QXcbAtom::AbsMTPressure) ||
+ vci->label == atom(QXcbAtom::AbsPressure)) {
+ touchPoint.pressure = valuatorNormalized(value, vci);
+ }
+ }
+ }
+ // If any value was not updated, use the last-known value.
+ if (nx == -1.0) {
+ x = touchPoint.area.center().x();
+ nx = x / screen->geometry().width();
+ }
+ if (ny == -1.0) {
+ y = touchPoint.area.center().y();
+ ny = y / screen->geometry().height();
+ }
+ if (xiDeviceEvent->evtype != XI_TouchEnd) {
+ if (d == 0.0)
+ d = touchPoint.area.width();
+ }
+
+ switch (xiDeviceEvent->evtype) {
+ case XI_TouchBegin:
+ if (firstTouch) {
+ dev->firstPressedPosition = QPointF(x, y);
+ dev->firstPressedNormalPosition = QPointF(nx, ny);
+ }
+ dev->pointPressedPosition.insert(touchPoint.id, QPointF(x, y));
+
+ // Touches must be accepted when we are grabbing touch events. Otherwise the entire sequence
+ // will get replayed when the grab ends.
+ if (m_xiGrab) {
+ // XIAllowTouchEvents deadlocks with libXi < 1.7.4 (this has nothing to do with the XI2 versions like 2.2)
+ // http://lists.x.org/archives/xorg-devel/2014-July/043059.html
+#ifndef LIBXI_MAJOR
+ static bool allowTouchWarningShown = false;
+ if (!allowTouchWarningShown) {
+ allowTouchWarningShown = true;
+ qWarning("Skipping XIAllowTouchEvents() because it was not possible to detect libXi version at build time."
+ " Minimum libXi version required is 1.7.4."
+ " Expect issues with touch behavior.");
+ }
+#elif LIBXI_MAJOR == 1 && (LIBXI_MINOR < 7 || (LIBXI_MINOR == 7 && LIBXI_PATCH < 4))
+ static bool allowTouchWarningShown = false;
+ if (!allowTouchWarningShown) {
+ allowTouchWarningShown = true;
+ qWarning("Skipping XIAllowTouchEvents() due to not having libXi >= 1.7.4."
+ " libXi version at build time was %d.%d.%d."
+ " Expect issues with touch behavior.", LIBXI_MAJOR, LIBXI_MINOR, LIBXI_PATCH);
+ }
+#else
+ XIAllowTouchEvents(static_cast<Display *>(m_xlib_display), xiDeviceEvent->deviceid,
+ xiDeviceEvent->detail, xiDeviceEvent->event, XIAcceptTouch);
+#endif
+ }
+ break;
+ case XI_TouchUpdate:
+ if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad && dev->pointPressedPosition.value(touchPoint.id) == QPointF(x, y)) {
+ qreal dx = (nx - dev->firstPressedNormalPosition.x()) *
+ dev->size.width() * screen->geometry().width() / screen->physicalSize().width();
+ qreal dy = (ny - dev->firstPressedNormalPosition.y()) *
+ dev->size.height() * screen->geometry().height() / screen->physicalSize().height();
+ x = dev->firstPressedPosition.x() + dx;
+ y = dev->firstPressedPosition.y() + dy;
+ touchPoint.state = Qt::TouchPointMoved;
+ } else if (touchPoint.area.center() != QPoint(x, y)) {
+ touchPoint.state = Qt::TouchPointMoved;
+ dev->pointPressedPosition[touchPoint.id] = QPointF(x, y);
+ }
+ break;
+ case XI_TouchEnd:
+ touchPoint.state = Qt::TouchPointReleased;
+ if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad && dev->pointPressedPosition.value(touchPoint.id) == QPointF(x, y)) {
+ qreal dx = (nx - dev->firstPressedNormalPosition.x()) *
+ dev->size.width() * screen->geometry().width() / screen->physicalSize().width();
+ qreal dy = (ny - dev->firstPressedNormalPosition.y()) *
+ dev->size.width() * screen->geometry().width() / screen->physicalSize().width();
+ x = dev->firstPressedPosition.x() + dx;
+ y = dev->firstPressedPosition.y() + dy;
+ }
+ dev->pointPressedPosition.remove(touchPoint.id);
+ }
+ touchPoint.area = QRectF(x - d/2, y - d/2, d, d);
+ touchPoint.normalPosition = QPointF(nx, ny);
+
+ if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
+ qCDebug(lcQpaXInput) << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition <<
+ " area " << touchPoint.area << " pressure " << touchPoint.pressure;
+ QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiDeviceEvent->time, dev->qtTouchDevice, m_touchPoints.values());
+ if (touchPoint.state == Qt::TouchPointReleased)
+ // If a touchpoint was released, we can forget it, because the ID won't be reused.
+ m_touchPoints.remove(touchPoint.id);
+ else
+ // Make sure that we don't send TouchPointPressed/Moved in more than one QTouchEvent
+ // with this touch point if the next XI2 event is about a different touch point.
+ touchPoint.state = Qt::TouchPointStationary;
+}
+
+bool QXcbConnection::xi2SetMouseGrabEnabled(xcb_window_t w, bool grab)
+{
+ if (grab && !canGrab())
+ return false;
+
+ int num_devices = 0;
+ Display *xDisplay = static_cast<Display *>(xlib_display());
+ XIDeviceInfo *info = XIQueryDevice(xDisplay, XIAllMasterDevices, &num_devices);
+ if (!info)
+ return false;
+
+ XIEventMask evmask;
+ unsigned char mask[XIMaskLen(XI_LASTEVENT)];
+ evmask.mask = mask;
+ evmask.mask_len = sizeof(mask);
+ memset(mask, 0, sizeof(mask));
+ evmask.deviceid = XIAllMasterDevices;
+
+ XISetMask(mask, XI_ButtonPress);
+ XISetMask(mask, XI_ButtonRelease);
+ XISetMask(mask, XI_Motion);
+ XISetMask(mask, XI_TouchBegin);
+ XISetMask(mask, XI_TouchUpdate);
+ XISetMask(mask, XI_TouchEnd);
+
+ bool grabbed = true;
+ for (int i = 0; i < num_devices; i++) {
+ int id = info[i].deviceid, n = 0;
+ XIDeviceInfo *deviceInfo = XIQueryDevice(xDisplay, id, &n);
+ if (deviceInfo) {
+ const bool grabbable = deviceInfo->use != XIMasterKeyboard;
+ XIFreeDeviceInfo(deviceInfo);
+ if (!grabbable)
+ continue;
+ }
+ if (!grab) {
+ Status result = XIUngrabDevice(xDisplay, id, CurrentTime);
+ if (result != Success) {
+ grabbed = false;
+ qCDebug(lcQpaXInput, "XInput 2.2: failed to ungrab events for device %d (result %d)", id, result);
+ }
+ } else {
+ Status result = XIGrabDevice(xDisplay, id, w, CurrentTime, None, XIGrabModeAsync,
+ XIGrabModeAsync, False, &evmask);
+ if (result != Success) {
+ grabbed = false;
+ qCDebug(lcQpaXInput, "XInput 2.2: failed to grab events for device %d on window %x (result %d)", id, w, result);
+ }
+ }
+ }
+
+ XIFreeDeviceInfo(info);
+
+ m_xiGrab = grabbed;
+
+ return grabbed;
+}
+#endif // XCB_USE_XINPUT22
+
void QXcbConnection::xi2HandleHierachyEvent(void *event)
{
xXIHierarchyEvent *xiEvent = reinterpret_cast<xXIHierarchyEvent *>(event);
@@ -790,7 +912,8 @@ void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollin
#endif // XCB_USE_XINPUT21
}
-static Qt::MouseButton xiToQtMouseButton(uint32_t b) {
+Qt::MouseButton QXcbConnection::xiToQtMouseButton(uint32_t b)
+{
switch (b) {
case 1: return Qt::LeftButton;
case 2: return Qt::MiddleButton;
@@ -837,20 +960,29 @@ static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) {
}
#ifndef QT_NO_TABLETEVENT
-bool QXcbConnection::xi2HandleTabletEvent(void *event, TabletData *tabletData)
+bool QXcbConnection::xi2HandleTabletEvent(void *event, TabletData *tabletData, QXcbWindowEventListener *eventListener)
{
bool handled = true;
Display *xDisplay = static_cast<Display *>(m_xlib_display);
xXIGenericDeviceEvent *xiEvent = static_cast<xXIGenericDeviceEvent *>(event);
+ xXIDeviceEvent *xiDeviceEvent = reinterpret_cast<xXIDeviceEvent *>(xiEvent);
+
+#ifdef XCB_USE_XINPUT22
+ // Synthesize mouse events since otherwise there are no mouse events from
+ // the pen on the XI 2.2+ path.
+ if (xi2MouseEvents() && eventListener)
+ eventListener->handleXIMouseEvent(reinterpret_cast<xcb_ge_event_t *>(event));
+#endif
+
switch (xiEvent->evtype) {
case XI_ButtonPress: {
- Qt::MouseButton b = xiToQtMouseButton(reinterpret_cast<xXIDeviceEvent *>(event)->detail);
+ Qt::MouseButton b = xiToQtMouseButton(xiDeviceEvent->detail);
tabletData->buttons |= b;
xi2ReportTabletEvent(*tabletData, xiEvent);
break;
}
case XI_ButtonRelease: {
- Qt::MouseButton b = xiToQtMouseButton(reinterpret_cast<xXIDeviceEvent *>(event)->detail);
+ Qt::MouseButton b = xiToQtMouseButton(xiDeviceEvent->detail);
tabletData->buttons ^= b;
xi2ReportTabletEvent(*tabletData, xiEvent);
break;
@@ -913,7 +1045,7 @@ bool QXcbConnection::xi2HandleTabletEvent(void *event, TabletData *tabletData)
// TODO maybe have a hash of tabletData->deviceId to device data so we can
// look up the tablet name here, and distinguish multiple tablets
qCDebug(lcQpaXInput, "XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d",
- ev->deviceid, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID],
+ tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID],
ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool);
}
XFree(data);
@@ -977,7 +1109,7 @@ void QXcbConnection::xi2ReportTabletEvent(TabletData &tabletData, void *event)
if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
qCDebug(lcQpaXInput, "XI2 event on tablet %d with tool %d type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf",
- ev->deviceid, tabletData.tool, ev->evtype, ev->sequenceNumber, ev->detail,
+ tabletData.deviceId, tabletData.tool, ev->evtype, ev->sequenceNumber, ev->detail,
fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y),
fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y),
(int)tabletData.buttons, pressure, xTilt, yTilt, rotation);
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index 5a7c2cef83..f3bffd2998 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -47,6 +47,12 @@
#include <stdio.h>
#include <X11/keysym.h>
+#ifdef XCB_USE_XINPUT22
+#include <X11/extensions/XI2proto.h>
+#undef KeyPress
+#undef KeyRelease
+#endif
+
#ifndef XK_ISO_Left_Tab
#define XK_ISO_Left_Tab 0xFE20
#endif
@@ -791,6 +797,31 @@ void QXcbKeyboard::updateXKBStateFromCore(quint16 state)
}
}
+void QXcbKeyboard::updateXKBStateFromXI(void *modInfo, void *groupInfo)
+{
+#ifdef XCB_USE_XINPUT22
+ if (m_config && !connection()->hasXKB()) {
+ xXIModifierInfo *mods = static_cast<xXIModifierInfo *>(modInfo);
+ xXIGroupInfo *group = static_cast<xXIGroupInfo *>(groupInfo);
+ const xkb_state_component newState = xkb_state_update_mask(xkb_state,
+ mods->base_mods,
+ mods->latched_mods,
+ mods->locked_mods,
+ group->base_group,
+ group->latched_group,
+ group->locked_group);
+
+ if ((newState & XKB_STATE_LAYOUT_EFFECTIVE) == XKB_STATE_LAYOUT_EFFECTIVE) {
+ //qWarning("TODO: Support KeyboardLayoutChange on QPA (QTBUG-27681)");
+ }
+ }
+#else
+ Q_UNUSED(modInfo);
+ Q_UNUSED(groupInfo);
+ Q_ASSERT(false); // this can't be
+#endif
+}
+
quint32 QXcbKeyboard::xkbModMask(quint16 state)
{
quint32 xkb_mask = 0;
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
index 2281674e2f..d2e37d624c 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -68,6 +68,7 @@ public:
void updateXKBMods();
quint32 xkbModMask(quint16 state);
void updateXKBStateFromCore(quint16 state);
+ void updateXKBStateFromXI(void *modInfo, void *groupInfo);
#ifndef QT_NO_XKB
// when XKEYBOARD is present on the X server
int coreDeviceId() const { return core_device_id; }
diff --git a/src/plugins/platforms/xcb/qxcbmain.cpp b/src/plugins/platforms/xcb/qxcbmain.cpp
index 0c3e8b5cd3..4a07b66491 100644
--- a/src/plugins/platforms/xcb/qxcbmain.cpp
+++ b/src/plugins/platforms/xcb/qxcbmain.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QXcbIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "xcb.json")
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "xcb.json")
public:
QPlatformIntegration *create(const QString&, const QStringList&, int &, char **) Q_DECL_OVERRIDE;
};
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index ad7e5a0320..3bc0df6f57 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -98,6 +98,7 @@
#if defined(XCB_USE_XINPUT2)
#include <X11/extensions/XInput2.h>
+#include <X11/extensions/XI2proto.h>
#endif
#define XCOORD_MAX 16383
@@ -2069,16 +2070,17 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
}
}
-void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
+void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, int root_y,
+ int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp)
{
- const bool isWheel = event->detail >= 4 && event->detail <= 7;
+ const bool isWheel = detail >= 4 && detail <= 7;
if (!isWheel && window() != QGuiApplication::focusWindow()) {
QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver();
if (!(w->flags() & Qt::WindowDoesNotAcceptFocus))
w->requestActivate();
}
- updateNetWmUserTime(event->time);
+ updateNetWmUserTime(timestamp);
if (m_embedded) {
if (window() != QGuiApplication::focusWindow()) {
@@ -2088,51 +2090,121 @@ void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
sendXEmbedMessage(container->xcb_window(), XEMBED_REQUEST_FOCUS);
}
}
- QPoint local(event->event_x, event->event_y);
- QPoint global = QPoint(event->root_x, event->root_y);
-
- Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state);
+ QPoint local(event_x, event_y);
+ QPoint global(root_x, root_y);
if (isWheel) {
- if (!connection()->isUsingXInput21()) {
+ if (!connection()->isAtLeastXI21()) {
// Logic borrowed from qapplication_x11.cpp
- int delta = 120 * ((event->detail == 4 || event->detail == 6) ? 1 : -1);
- bool hor = (((event->detail == 4 || event->detail == 5)
+ int delta = 120 * ((detail == 4 || detail == 6) ? 1 : -1);
+ bool hor = (((detail == 4 || detail == 5)
&& (modifiers & Qt::AltModifier))
- || (event->detail == 6 || event->detail == 7));
+ || (detail == 6 || detail == 7));
- QWindowSystemInterface::handleWheelEvent(window(), event->time,
+ QWindowSystemInterface::handleWheelEvent(window(), timestamp,
local, global, delta, hor ? Qt::Horizontal : Qt::Vertical, modifiers);
}
return;
}
- handleMouseEvent(event->time, local, global, modifiers);
+ handleMouseEvent(timestamp, local, global, modifiers);
}
-void QXcbWindow::handleButtonReleaseEvent(const xcb_button_release_event_t *event)
+void QXcbWindow::handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y,
+ int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp)
{
- QPoint local(event->event_x, event->event_y);
- QPoint global = QPoint(event->root_x, event->root_y);
- Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state);
+ QPoint local(event_x, event_y);
+ QPoint global(root_x, root_y);
- if (event->detail >= 4 && event->detail <= 7) {
+ if (detail >= 4 && detail <= 7) {
// mouse wheel, handled in handleButtonPressEvent()
return;
}
- handleMouseEvent(event->time, local, global, modifiers);
+ handleMouseEvent(timestamp, local, global, modifiers);
+}
+
+void QXcbWindow::handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y,
+ Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp)
+{
+ QPoint local(event_x, event_y);
+ QPoint global(root_x, root_y);
+ handleMouseEvent(timestamp, local, global, modifiers);
+}
+
+// Handlers for plain xcb events. Used only when XI 2.2 or newer is not available.
+void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
+{
+ Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state);
+ handleButtonPressEvent(event->event_x, event->event_y, event->root_x, event->root_y, event->detail,
+ modifiers, event->time);
+}
+
+void QXcbWindow::handleButtonReleaseEvent(const xcb_button_release_event_t *event)
+{
+ Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state);
+ handleButtonReleaseEvent(event->event_x, event->event_y, event->root_x, event->root_y, event->detail,
+ modifiers, event->time);
}
void QXcbWindow::handleMotionNotifyEvent(const xcb_motion_notify_event_t *event)
{
- QPoint local(event->event_x, event->event_y);
- if (!xcbScreen())
- return;
- QPoint global = QPoint(event->root_x, event->root_y);
Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state);
+ handleMotionNotifyEvent(event->event_x, event->event_y, event->root_x, event->root_y, modifiers, event->time);
+}
- handleMouseEvent(event->time, local, global, modifiers);
+#ifdef XCB_USE_XINPUT22
+static inline int fixed1616ToInt(FP1616 val)
+{
+ return int((qreal(val >> 16)) + (val & 0xFFFF) / (qreal)0xFFFF);
+}
+#endif
+
+// With XI 2.2+ press/release/motion comes here instead of the above handlers.
+void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event)
+{
+#ifdef XCB_USE_XINPUT22
+ QXcbConnection *conn = connection();
+ xXIDeviceEvent *ev = reinterpret_cast<xXIDeviceEvent *>(event);
+ const Qt::KeyboardModifiers modifiers = conn->keyboard()->translateModifiers(ev->mods.effective_mods);
+ const int event_x = fixed1616ToInt(ev->event_x);
+ const int event_y = fixed1616ToInt(ev->event_y);
+ const int root_x = fixed1616ToInt(ev->root_x);
+ const int root_y = fixed1616ToInt(ev->root_y);
+
+ conn->keyboard()->updateXKBStateFromXI(&ev->mods, &ev->group);
+
+ const Qt::MouseButton button = conn->xiToQtMouseButton(ev->detail);
+
+ if (ev->buttons_len > 0) {
+ unsigned char *buttonMask = (unsigned char *) &ev[1];
+ for (int i = 1; i <= 15; ++i)
+ conn->setButton(conn->translateMouseButton(i), XIMaskIsSet(buttonMask, i));
+ }
+
+ switch (ev->evtype) {
+ case XI_ButtonPress:
+ qCDebug(lcQpaXInput, "XI2 mouse press, button %d", button);
+ conn->setButton(button, true);
+ handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time);
+ break;
+ case XI_ButtonRelease:
+ qCDebug(lcQpaXInput, "XI2 mouse release, button %d", button);
+ conn->setButton(button, false);
+ handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time);
+ break;
+ case XI_Motion:
+ qCDebug(lcQpaXInput, "XI2 mouse motion %d,%d", event_x, event_y);
+ handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time);
+ break;
+ default:
+ qWarning() << "Unrecognized XI2 mouse event" << ev->evtype;
+ break;
+ }
+#else
+ Q_UNUSED(event);
+ Q_ASSERT(false); // this can't be
+#endif
}
QXcbWindow *QXcbWindow::toWindow() { return this; }
@@ -2314,6 +2386,10 @@ bool QXcbWindow::setKeyboardGrabEnabled(bool grab)
bool QXcbWindow::setMouseGrabEnabled(bool grab)
{
+#ifdef XCB_USE_XINPUT22
+ if (connection()->xi2MouseEvents())
+ return connection()->xi2SetMouseGrabEnabled(m_window, grab);
+#endif
if (grab && !connection()->canGrab())
return false;
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index 14280f292c..1010600e44 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -132,6 +132,7 @@ public:
void handleFocusInEvent(const xcb_focus_in_event_t *event) Q_DECL_OVERRIDE;
void handleFocusOutEvent(const xcb_focus_out_event_t *event) Q_DECL_OVERRIDE;
void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) Q_DECL_OVERRIDE;
+ void handleXIMouseEvent(xcb_ge_event_t *) Q_DECL_OVERRIDE;
QXcbWindow *toWindow() Q_DECL_OVERRIDE;
@@ -204,6 +205,15 @@ protected:
void doFocusIn();
void doFocusOut();
+ void handleButtonPressEvent(int event_x, int event_y, int root_x, int root_y,
+ int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp);
+
+ void handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y,
+ int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp);
+
+ void handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y,
+ Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp);
+
xcb_window_t m_window;
QXcbScreen *m_xcbScreen;
diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
index fd704dd904..12987567ff 100644
--- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro
+++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
@@ -59,6 +59,11 @@ contains(QT_CONFIG, xcb-xlib) {
DEFINES += XCB_USE_XINPUT2
SOURCES += qxcbconnection_xi2.cpp
LIBS += -lXi
+ !isEmpty(QMAKE_LIBXI_VERSION_MAJOR) {
+ DEFINES += LIBXI_MAJOR=$$QMAKE_LIBXI_VERSION_MAJOR \
+ LIBXI_MINOR=$$QMAKE_LIBXI_VERSION_MINOR \
+ LIBXI_PATCH=$$QMAKE_LIBXI_VERSION_PATCH
+ }
}
}
diff --git a/src/plugins/platformthemes/gtk2/main.cpp b/src/plugins/platformthemes/gtk2/main.cpp
index 2431443dfa..34ac3ffc07 100644
--- a/src/plugins/platformthemes/gtk2/main.cpp
+++ b/src/plugins/platformthemes/gtk2/main.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
class QGtk2ThemePlugin : public QPlatformThemePlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1" FILE "gtk2.json")
+ Q_PLUGIN_METADATA(IID QPlatformThemeFactoryInterface_iid FILE "gtk2.json")
public:
QPlatformTheme *create(const QString &key, const QStringList &params) Q_DECL_OVERRIDE;
diff --git a/src/plugins/printsupport/cocoa/main.cpp b/src/plugins/printsupport/cocoa/main.cpp
index d0925bbc34..2037724719 100644
--- a/src/plugins/printsupport/cocoa/main.cpp
+++ b/src/plugins/printsupport/cocoa/main.cpp
@@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE
class QCocoaPrinterSupportPlugin : public QPlatformPrinterSupportPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.QPlatformPrinterSupportFactoryInterface" FILE "cocoa.json")
+ Q_PLUGIN_METADATA(IID QPlatformPrinterSupportFactoryInterface_iid FILE "cocoa.json")
public:
QPlatformPrinterSupport *create(const QString &);
diff --git a/src/plugins/printsupport/cups/main.cpp b/src/plugins/printsupport/cups/main.cpp
index 9651a074cc..82485114ab 100644
--- a/src/plugins/printsupport/cups/main.cpp
+++ b/src/plugins/printsupport/cups/main.cpp
@@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE
class QCupsPrinterSupportPlugin : public QPlatformPrinterSupportPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.QPlatformPrinterSupportFactoryInterface" FILE "cups.json")
+ Q_PLUGIN_METADATA(IID QPlatformPrinterSupportFactoryInterface_iid FILE "cups.json")
public:
QStringList keys() const;
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index c2bd2872a9..808424b1ed 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -89,16 +89,6 @@ QPpdPrintDevice::QPpdPrintDevice(const QString &id)
}
}
-QPpdPrintDevice::QPpdPrintDevice(const QPpdPrintDevice &other)
- : QPlatformPrintDevice(other),
- m_cupsDest(0),
- m_ppd(0)
-{
- m_cupsName = other.m_cupsName;
- m_cupsInstance = other.m_cupsInstance;
- loadPrinter();
-}
-
QPpdPrintDevice::~QPpdPrintDevice()
{
if (m_ppd)
@@ -109,20 +99,6 @@ QPpdPrintDevice::~QPpdPrintDevice()
m_ppd = 0;
}
-QPpdPrintDevice &QPpdPrintDevice::operator=(const QPpdPrintDevice &other)
-{
- m_cupsName = other.m_cupsName;
- m_cupsInstance = other.m_cupsInstance;
- if (other.m_cupsDest && other.m_ppd)
- loadPrinter();
- return *this;
-}
-
-bool QPpdPrintDevice::operator==(const QPpdPrintDevice &other) const
-{
- return (m_id == other.m_id);
-}
-
bool QPpdPrintDevice::isValid() const
{
return m_cupsDest && m_ppd;
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.h b/src/plugins/printsupport/cups/qppdprintdevice.h
index 2437234d28..64eb872bd1 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.h
+++ b/src/plugins/printsupport/cups/qppdprintdevice.h
@@ -63,15 +63,8 @@ class QPpdPrintDevice : public QPlatformPrintDevice
public:
QPpdPrintDevice();
explicit QPpdPrintDevice(const QString &id);
- QPpdPrintDevice(const QPpdPrintDevice &other);
virtual ~QPpdPrintDevice();
- QPpdPrintDevice &operator=(const QPpdPrintDevice &other);
-
- QPpdPrintDevice *clone();
-
- bool operator==(const QPpdPrintDevice &other) const;
-
bool isValid() const Q_DECL_OVERRIDE;
bool isDefault() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/printsupport/windows/main.cpp b/src/plugins/printsupport/windows/main.cpp
index f1ee620b8b..28e99f1916 100644
--- a/src/plugins/printsupport/windows/main.cpp
+++ b/src/plugins/printsupport/windows/main.cpp
@@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE
class QWindowsPrinterSupportPlugin : public QPlatformPrinterSupportPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.QPlatformPrinterSupportFactoryInterface" FILE "windows.json")
+ Q_PLUGIN_METADATA(IID QPlatformPrinterSupportFactoryInterface_iid FILE "windows.json")
public:
QPlatformPrinterSupport *create(const QString &);
diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
index af8e07edd2..505f3138ca 100644
--- a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
+++ b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
@@ -113,28 +113,11 @@ QWindowsPrintDevice::QWindowsPrintDevice(const QString &id)
}
}
-QWindowsPrintDevice::QWindowsPrintDevice(const QWindowsPrintDevice &other)
- : QPlatformPrintDevice(other)
-{
- OpenPrinter((LPWSTR)other.m_id.utf16(), &m_hPrinter, NULL);
-}
-
QWindowsPrintDevice::~QWindowsPrintDevice()
{
ClosePrinter(m_hPrinter);
}
-QWindowsPrintDevice &QWindowsPrintDevice::operator=(const QWindowsPrintDevice &other)
-{
- OpenPrinter((LPWSTR)other.m_id.utf16(), &m_hPrinter, NULL);
- return *this;
-}
-
-bool QWindowsPrintDevice::operator==(const QWindowsPrintDevice &other) const
-{
- return (m_id == other.m_id);
-}
-
bool QWindowsPrintDevice::isValid() const
{
return m_hPrinter;
diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.h b/src/plugins/printsupport/windows/qwindowsprintdevice.h
index 2e0f6e4658..8ab487a59c 100644
--- a/src/plugins/printsupport/windows/qwindowsprintdevice.h
+++ b/src/plugins/printsupport/windows/qwindowsprintdevice.h
@@ -58,15 +58,8 @@ class QWindowsPrintDevice : public QPlatformPrintDevice
public:
QWindowsPrintDevice();
explicit QWindowsPrintDevice(const QString &id);
- QWindowsPrintDevice(const QWindowsPrintDevice &other);
virtual ~QWindowsPrintDevice();
- QWindowsPrintDevice &operator=(const QWindowsPrintDevice &other);
-
- QWindowsPrintDevice *clone();
-
- bool operator==(const QWindowsPrintDevice &other) const;
-
bool isValid() const Q_DECL_OVERRIDE;
bool isDefault() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/styles/bb10style/bright/button/core_button_inactive.png b/src/plugins/styles/bb10style/bright/button/core_button_inactive.png
index 7769f15e44..7769f15e44 100755..100644
--- a/src/plugins/styles/bb10style/bright/button/core_button_inactive.png
+++ b/src/plugins/styles/bb10style/bright/button/core_button_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/button/core_button_pressed.png b/src/plugins/styles/bb10style/bright/button/core_button_pressed.png
index 59b5bfa7c2..59b5bfa7c2 100755..100644
--- a/src/plugins/styles/bb10style/bright/button/core_button_pressed.png
+++ b/src/plugins/styles/bb10style/bright/button/core_button_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png
index f1c2ee3bed..f1c2ee3bed 100755..100644
--- a/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png
+++ b/src/plugins/styles/bb10style/bright/checkbox/core_checkbox_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png
index 07b8ea21bf..07b8ea21bf 100755..100644
--- a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png
+++ b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png
index 55f8aee066..55f8aee066 100755..100644
--- a/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png
+++ b/src/plugins/styles/bb10style/bright/lineedit/core_textinput_bg_highlight.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png b/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png
index 34daccc27e..34daccc27e 100755..100644
--- a/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png
+++ b/src/plugins/styles/bb10style/bright/listitem/core_listitem_active.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png b/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png
index 7a1e22321d..7a1e22321d 100755..100644
--- a/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png
+++ b/src/plugins/styles/bb10style/bright/listitem/core_listitem_divider.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png
index 3ff930dea7..3ff930dea7 100755..100644
--- a/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png
+++ b/src/plugins/styles/bb10style/bright/progressbar/core_progressindicator_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png
index cb4c6a8136..cb4c6a8136 100755..100644
--- a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png
+++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png
index 88fd1344d2..88fd1344d2 100755..100644
--- a/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png
+++ b/src/plugins/styles/bb10style/bright/radiobutton/core_radiobutton_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png
index 79154e0568..79154e0568 100755..100644
--- a/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png
+++ b/src/plugins/styles/bb10style/bright/scrollbar/core_scrollbar.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png
index 8cb79118b9..8cb79118b9 100755..100644
--- a/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png
+++ b/src/plugins/styles/bb10style/bright/slider/core_slider_handle_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/button/core_button_inactive.png b/src/plugins/styles/bb10style/dark/button/core_button_inactive.png
index 97842e1ac4..97842e1ac4 100755..100644
--- a/src/plugins/styles/bb10style/dark/button/core_button_inactive.png
+++ b/src/plugins/styles/bb10style/dark/button/core_button_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/button/core_button_pressed.png b/src/plugins/styles/bb10style/dark/button/core_button_pressed.png
index c149b64a26..c149b64a26 100755..100644
--- a/src/plugins/styles/bb10style/dark/button/core_button_pressed.png
+++ b/src/plugins/styles/bb10style/dark/button/core_button_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png
index 507a77b3ea..507a77b3ea 100755..100644
--- a/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png
+++ b/src/plugins/styles/bb10style/dark/checkbox/core_checkbox_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png
index 07b8ea21bf..07b8ea21bf 100755..100644
--- a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png
+++ b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png
index 9b115897e8..9b115897e8 100755..100644
--- a/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png
+++ b/src/plugins/styles/bb10style/dark/lineedit/core_textinput_bg_highlight.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png b/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png
index 52aa4e4aa2..52aa4e4aa2 100755..100644
--- a/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png
+++ b/src/plugins/styles/bb10style/dark/listitem/core_listitem_active.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png b/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png
index 39e3a8a4f5..39e3a8a4f5 100755..100644
--- a/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png
+++ b/src/plugins/styles/bb10style/dark/listitem/core_listitem_divider.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png
index 95fcafb437..95fcafb437 100755..100644
--- a/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png
+++ b/src/plugins/styles/bb10style/dark/progressbar/core_progressindicator_bg.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png
index fd61937d65..fd61937d65 100755..100644
--- a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png
+++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_inactive.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png
index 58a1a57b4c..58a1a57b4c 100755..100644
--- a/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png
+++ b/src/plugins/styles/bb10style/dark/radiobutton/core_radiobutton_pressed.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png
index 384f60758a..384f60758a 100755..100644
--- a/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png
+++ b/src/plugins/styles/bb10style/dark/scrollbar/core_scrollbar.png
Binary files differ
diff --git a/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png
index 803c374015..803c374015 100755..100644
--- a/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png
+++ b/src/plugins/styles/bb10style/dark/slider/core_slider_handle_pressed.png
Binary files differ
diff --git a/src/printsupport/dialogs/qpagesetupdialog_mac.mm b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
index 886cbc0152..b86de31883 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_mac.mm
+++ b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
@@ -201,10 +201,9 @@ int QPageSetupDialog::exec()
QDialog::setVisible(true);
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
static_cast <QMacPageSetupDialogPrivate*>(d)->openCocoaPageLayout(Qt::ApplicationModal);
static_cast <QMacPageSetupDialogPrivate*>(d)->closeCocoaPageLayout();
- [pool release];
QDialog::setVisible(false);
diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm
index 1655131de4..030526954d 100644
--- a/src/printsupport/dialogs/qprintdialog_mac.mm
+++ b/src/printsupport/dialogs/qprintdialog_mac.mm
@@ -301,10 +301,9 @@ int QPrintDialog::exec()
QDialog::setVisible(true);
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
d->openCocoaPrintPanel(Qt::ApplicationModal);
d->closeCocoaPrintPanel();
- [pool release];
QDialog::setVisible(false);
diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp
index bd6d81774c..6385f58aa1 100644
--- a/src/printsupport/kernel/qplatformprintdevice.cpp
+++ b/src/printsupport/kernel/qplatformprintdevice.cpp
@@ -75,11 +75,6 @@ QPlatformPrintDevice::~QPlatformPrintDevice()
{
}
-bool QPlatformPrintDevice::operator==(const QPlatformPrintDevice &other) const
-{
- return m_id == other.m_id;
-}
-
QString QPlatformPrintDevice::id() const
{
return m_id;
diff --git a/src/printsupport/kernel/qplatformprintdevice.h b/src/printsupport/kernel/qplatformprintdevice.h
index 1e21e608ad..8bb87a70f9 100644
--- a/src/printsupport/kernel/qplatformprintdevice.h
+++ b/src/printsupport/kernel/qplatformprintdevice.h
@@ -55,17 +55,14 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_PRINTER
-class Q_PRINTSUPPORT_EXPORT QPlatformPrintDevice : public QSharedData
+class Q_PRINTSUPPORT_EXPORT QPlatformPrintDevice
{
+ Q_DISABLE_COPY(QPlatformPrintDevice)
public:
QPlatformPrintDevice();
explicit QPlatformPrintDevice(const QString &id);
virtual ~QPlatformPrintDevice();
- QPlatformPrintDevice *clone();
-
- bool operator==(const QPlatformPrintDevice &other) const;
-
virtual QString id() const;
virtual QString name() const;
virtual QString location() const;
diff --git a/src/printsupport/kernel/qplatformprintplugin.h b/src/printsupport/kernel/qplatformprintplugin.h
index 279de9b952..ad39bf5a0c 100644
--- a/src/printsupport/kernel/qplatformprintplugin.h
+++ b/src/printsupport/kernel/qplatformprintplugin.h
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
class QPlatformPrinterSupport;
-#define QPlatformPrinterSupportFactoryInterface_iid "org.qt-project.QPlatformPrinterSupportFactoryInterface"
+#define QPlatformPrinterSupportFactoryInterface_iid "org.qt-project.QPlatformPrinterSupportFactoryInterface.5.1"
class Q_PRINTSUPPORT_EXPORT QPlatformPrinterSupportPlugin : public QObject
{
diff --git a/src/printsupport/kernel/qprintdevice.cpp b/src/printsupport/kernel/qprintdevice.cpp
index 7c18b53e09..a640c14483 100644
--- a/src/printsupport/kernel/qprintdevice.cpp
+++ b/src/printsupport/kernel/qprintdevice.cpp
@@ -73,7 +73,7 @@ QPrintDevice &QPrintDevice::operator=(const QPrintDevice &other)
bool QPrintDevice::operator==(const QPrintDevice &other) const
{
if (d && other.d)
- return *d == *other.d;
+ return d->id() == other.d->id();
return d == other.d;
}
diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h
index ad55cded0e..ddf5595734 100644
--- a/src/printsupport/kernel/qprintdevice_p.h
+++ b/src/printsupport/kernel/qprintdevice_p.h
@@ -136,7 +136,7 @@ private:
friend class QPlatformPrinterSupport;
friend class QPlatformPrintDevice;
QPrintDevice(QPlatformPrintDevice *dd);
- QSharedDataPointer<QPlatformPrintDevice> d;
+ QSharedPointer<QPlatformPrintDevice> d;
};
Q_DECLARE_SHARED(QPrintDevice)
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index 246dae0ddf..a106a58502 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -1764,7 +1764,7 @@ QRectF QPrinter::paperRect(Unit unit) const
}
/*!
- \obsolete Use pageLayout().paintRect() instead.
+ \obsolete Use pageLayout().paintRectPixels(resolution()) instead.
Returns the page's rectangle; this is usually smaller than the
paperRect() since the page normally has margins between its
@@ -1781,7 +1781,7 @@ QRect QPrinter::pageRect() const
}
/*!
- \obsolete Use pageLayout().fullPageRect() instead.
+ \obsolete Use pageLayout().fullRectPixels(resolution()) instead.
Returns the paper's rectangle; this is usually larger than the
pageRect().
diff --git a/src/printsupport/widgets/qprintpreviewwidget.cpp b/src/printsupport/widgets/qprintpreviewwidget.cpp
index 6033381b58..686dab07bf 100644
--- a/src/printsupport/widgets/qprintpreviewwidget.cpp
+++ b/src/printsupport/widgets/qprintpreviewwidget.cpp
@@ -335,8 +335,8 @@ void QPrintPreviewWidgetPrivate::populateScene()
pages.clear();
int numPages = pictures.count();
- QSize paperSize = printer->paperRect().size();
- QRect pageRect = printer->pageRect();
+ QSize paperSize = printer->pageLayout().fullRectPixels(printer->resolution()).size();
+ QRect pageRect = printer->pageLayout().paintRectPixels(printer->resolution());
for (int i = 0; i < numPages; i++) {
PageItem* item = new PageItem(i+1, pictures.at(i), paperSize, pageRect);
diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp
index 6262c25e0d..c35fca7217 100644
--- a/src/sql/kernel/qsqlresult.cpp
+++ b/src/sql/kernel/qsqlresult.cpp
@@ -837,6 +837,9 @@ QString QSqlResult::executedQuery() const
return d->executedQuery;
}
+/*!
+ Resets the number of bind parameters.
+*/
void QSqlResult::resetBindCount()
{
Q_D(QSqlResult);
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index b687ae568d..b0d3e6df9d 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -1302,6 +1302,14 @@ Qt::ItemFlags QSqlTableModel::flags(const QModelIndex &index) const
return QSqlQueryModel::flags(index) | Qt::ItemIsEditable;
}
+/*!
+ This is an overloaded function.
+
+ It returns an empty record, having only the field names. This function can be used to
+ retrieve the field names of a record.
+
+ \sa QSqlRecord::isEmpty()
+*/
QSqlRecord QSqlTableModel::record() const
{
return QSqlQueryModel::record();
diff --git a/src/testlib/doc/qttestlib.qdocconf b/src/testlib/doc/qttestlib.qdocconf
index 35b4fbcb7b..0fafc733b1 100644
--- a/src/testlib/doc/qttestlib.qdocconf
+++ b/src/testlib/doc/qttestlib.qdocconf
@@ -40,5 +40,8 @@ excludedirs += ../../../examples/widgets/doc
imagedirs += images
+# Add a thumbnail for examples that do not have images
+manifestmeta.thumbnail.names = "QtTestLib/Chapter *"
+
navigation.landingpage = "Qt Test"
navigation.cppclassespage = "Qt Test C++ Classes"
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 81cc07c410..994179958b 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -274,14 +274,33 @@ inline bool qCompare(quint32 const &t1, quint64 const &t2, const char *actual,
}
QT_END_NAMESPACE
+#ifdef QT_TESTCASE_BUILDDIR
+# define QTEST_SET_MAIN_SOURCE_PATH QTest::setMainSourcePath(__FILE__, QT_TESTCASE_BUILDDIR);
+#else
+# define QTEST_SET_MAIN_SOURCE_PATH QTest::setMainSourcePath(__FILE__);
+#endif
+
#define QTEST_APPLESS_MAIN(TestObject) \
int main(int argc, char *argv[]) \
{ \
TestObject tc; \
+ QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
}
#include <QtTest/qtestsystem.h>
+#include <set>
+
+#ifndef QT_NO_OPENGL
+# define QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
+ extern Q_TESTLIB_EXPORT std::set<QByteArray> *(*qgpu_features_ptr)(const QString &); \
+ extern Q_GUI_EXPORT std::set<QByteArray> *qgpu_features(const QString &);
+# define QTEST_ADD_GPU_BLACKLIST_SUPPORT \
+ qgpu_features_ptr = qgpu_features;
+#else
+# define QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS
+# define QTEST_ADD_GPU_BLACKLIST_SUPPORT
+#endif
#if defined(QT_WIDGETS_LIB)
@@ -294,12 +313,17 @@ int main(int argc, char *argv[]) \
#endif
#define QTEST_MAIN(TestObject) \
+QT_BEGIN_NAMESPACE \
+QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
+QT_END_NAMESPACE \
int main(int argc, char *argv[]) \
{ \
QApplication app(argc, argv); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
QTEST_DISABLE_KEYPAD_NAVIGATION \
+ QTEST_ADD_GPU_BLACKLIST_SUPPORT \
TestObject tc; \
+ QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
}
@@ -308,11 +332,16 @@ int main(int argc, char *argv[]) \
#include <QtTest/qtest_gui.h>
#define QTEST_MAIN(TestObject) \
+QT_BEGIN_NAMESPACE \
+QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
+QT_END_NAMESPACE \
int main(int argc, char *argv[]) \
{ \
QGuiApplication app(argc, argv); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
+ QTEST_ADD_GPU_BLACKLIST_SUPPORT \
TestObject tc; \
+ QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
}
@@ -324,6 +353,7 @@ int main(int argc, char *argv[]) \
QCoreApplication app(argc, argv); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
TestObject tc; \
+ QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
}
@@ -335,6 +365,7 @@ int main(int argc, char *argv[]) \
QCoreApplication app(argc, argv); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
TestObject tc; \
+ QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
}
diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp
index bfeca08617..f9ce908a00 100644
--- a/src/testlib/qtestblacklist.cpp
+++ b/src/testlib/qtestblacklist.cpp
@@ -34,6 +34,7 @@
#include "qtestresult_p.h"
#include <QtTest/qtestcase.h>
+#include <QtTest/qtest.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qfile.h>
#include <QtCore/qset.h>
@@ -161,6 +162,9 @@ static bool checkCondition(const QByteArray &condition)
static bool ignoreAll = false;
static std::set<QByteArray> *ignoredTests = 0;
+static std::set<QByteArray> *gpuFeatures = 0;
+
+Q_TESTLIB_EXPORT std::set<QByteArray> *(*qgpu_features_ptr)(const QString &) = 0;
namespace QTestPrivate {
@@ -196,7 +200,18 @@ void parseBlackList()
}
}
-void checkBlackList(const char *slot, const char *data)
+void parseGpuBlackList()
+{
+ if (!qgpu_features_ptr)
+ return;
+ QString filename = QTest::qFindTestData(QStringLiteral("GPU_BLACKLIST"));
+ if (filename.isEmpty())
+ return;
+ if (!gpuFeatures)
+ gpuFeatures = qgpu_features_ptr(filename);
+}
+
+void checkBlackLists(const char *slot, const char *data)
{
bool ignore = ignoreAll;
@@ -211,6 +226,16 @@ void checkBlackList(const char *slot, const char *data)
}
QTestResult::setBlacklistCurrentTest(ignore);
+
+ // Tests blacklisted in GPU_BLACKLIST are to be skipped. Just ignoring the result is
+ // not sufficient since these are expected to crash or behave in undefined ways.
+ if (!ignore && gpuFeatures) {
+ const QByteArray disableKey = QByteArrayLiteral("disable_") + QByteArray(slot);
+ if (gpuFeatures->find(disableKey) != gpuFeatures->end()) {
+ const QByteArray msg = QByteArrayLiteral("Skipped due to GPU blacklist: ") + disableKey;
+ QTest::qSkip(msg.constData(), __FILE__, __LINE__);
+ }
+ }
}
}
diff --git a/src/testlib/qtestblacklist_p.h b/src/testlib/qtestblacklist_p.h
index 158d99593e..87f4dfdb5e 100644
--- a/src/testlib/qtestblacklist_p.h
+++ b/src/testlib/qtestblacklist_p.h
@@ -50,8 +50,10 @@
QT_BEGIN_NAMESPACE
namespace QTestPrivate {
- void parseBlackList();
- void checkBlackList(const char *slot, const char *data);
+ // Export functions so they can also be used by QQuickTest
+ Q_TESTLIB_EXPORT void parseBlackList();
+ Q_TESTLIB_EXPORT void parseGpuBlackList();
+ Q_TESTLIB_EXPORT void checkBlackLists(const char *slot, const char *data);
}
QT_END_NAMESPACE
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index e1e6805a0f..858475f396 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1374,6 +1374,7 @@ static bool installCoverageTool(const char * appname, const char * testname)
namespace QTest
{
static QObject *currentTestObject = 0;
+ static QString mainSourcePath;
class TestFunction {
public:
@@ -2167,7 +2168,7 @@ static bool qInvokeTestMethod(const char *slotName, const char *data, WatchDog *
if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) {
foundFunction = true;
- QTestPrivate::checkBlackList(slot, dataCount ? table.testData(curDataIndex)->dataTag() : 0);
+ QTestPrivate::checkBlackLists(slot, dataCount ? table.testData(curDataIndex)->dataTag() : 0);
QTestDataSetter s(curDataIndex >= dataCount ? static_cast<QTestData *>(0)
: table.testData(curDataIndex));
@@ -2682,6 +2683,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
#endif
QTestPrivate::parseBlackList();
+ QTestPrivate::parseGpuBlackList();
QTestResult::reset();
@@ -3032,6 +3034,13 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
found = candidate;
}
+ // 6. Try main source directory
+ if (found.isEmpty()) {
+ QString candidate = QTest::mainSourcePath % QLatin1Char('/') % base;
+ if (QFileInfo(candidate).exists())
+ found = candidate;
+ }
+
if (found.isEmpty()) {
QTest::qWarn(qPrintable(
QString::fromLatin1("testdata %1 could not be located!").arg(base)),
@@ -3219,6 +3228,19 @@ QObject *QTest::testObject()
}
/*! \internal
+ */
+void QTest::setMainSourcePath(const char *file, const char *builddir)
+{
+ QString mainSourceFile = QFile::decodeName(file);
+ QFileInfo fi;
+ if (builddir)
+ fi.setFile(QDir(QFile::decodeName(builddir)), mainSourceFile);
+ else
+ fi.setFile(mainSourceFile);
+ QTest::mainSourcePath = fi.absolutePath();
+}
+
+/*! \internal
This function is called by various specializations of QTest::qCompare
to decide whether to report a failure and to produce verbose test output.
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index 45290de6de..2c6a94faa1 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -236,6 +236,8 @@ namespace QTest
Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc = 0, char **argv = 0);
Q_TESTLIB_EXPORT int qExec(QObject *testObject, const QStringList &arguments);
+ Q_TESTLIB_EXPORT void setMainSourcePath(const char *file, const char *builddir = 0);
+
Q_TESTLIB_EXPORT bool qVerify(bool statement, const char *statementStr, const char *description,
const char *file, int line);
Q_TESTLIB_EXPORT void qFail(const char *statementStr, const char *file, int line);
diff --git a/src/testlib/qtestmouse.cpp b/src/testlib/qtestmouse.cpp
new file mode 100644
index 0000000000..99a75744fa
--- /dev/null
+++ b/src/testlib/qtestmouse.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtTest module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QtGlobal>
+#include <QtCore/qnamespace.h>
+#include <QtTest/qtest_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QTest {
+
+Q_TESTLIB_EXPORT Qt::MouseButton lastMouseButton = Qt::NoButton;
+Q_TESTLIB_EXPORT int lastMouseTimestamp = 0;
+
+} // namespace QTest
+
+QT_END_NAMESPACE
diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h
index 2cf84a7ea0..cd3901ae6f 100644
--- a/src/testlib/qtestmouse.h
+++ b/src/testlib/qtestmouse.h
@@ -45,6 +45,7 @@
#include <QtTest/qtestspontaneevent.h>
#include <QtCore/qpoint.h>
#include <QtCore/qstring.h>
+#include <QtCore/qpointer.h>
#include <QtGui/qevent.h>
#include <QtGui/qwindow.h>
@@ -57,12 +58,15 @@
QT_BEGIN_NAMESPACE
-Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier);
+Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods, int timestamp);
namespace QTest
{
enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDClick, MouseMove };
+ extern Q_TESTLIB_EXPORT Qt::MouseButton lastMouseButton;
+ extern Q_TESTLIB_EXPORT int lastMouseTimestamp;
+
static void waitForEvents()
{
#ifdef Q_OS_MAC
@@ -83,52 +87,48 @@ namespace QTest
QTest::qWarn("Mouse event occurs outside of target window.");
}
- static Qt::MouseButton lastButton = Qt::NoButton;
-
if (delay == -1 || delay < defaultMouseDelay())
delay = defaultMouseDelay();
- if (delay > 0)
+ if (delay > 0) {
QTest::qWait(delay);
+ lastMouseTimestamp += delay;
+ }
if (pos.isNull())
pos = window->geometry().center();
- if (action == MouseClick) {
- mouseEvent(MousePress, window, button, stateKey, pos);
- mouseEvent(MouseRelease, window, button, stateKey, pos);
- return;
- }
QTEST_ASSERT(uint(stateKey) == 0 || stateKey & Qt::KeyboardModifierMask);
stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);
+ QPointF global = window->mapToGlobal(pos);
+ QPointer<QWindow> w(window);
switch (action)
{
- case MousePress:
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),button,stateKey);
- lastButton = button;
- break;
- case MouseRelease:
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton,stateKey);
- lastButton = Qt::NoButton;
- break;
- case MouseDClick:
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),button,stateKey);
- qWait(10);
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton,stateKey);
- qWait(20);
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),button,stateKey);
- qWait(10);
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton,stateKey);
- break;
- case MouseMove:
- qt_handleMouseEvent(window,pos,window->mapToGlobal(pos),lastButton,stateKey);
- // No QCursor::setPos() call here. That could potentially result in mouse events sent by the windowing system
- // which is highly undesired here. Tests must avoid relying on QCursor.
+ case MouseDClick:
+ qt_handleMouseEvent(w, pos, global, button, stateKey, ++lastMouseTimestamp);
+ qt_handleMouseEvent(w, pos, global, Qt::NoButton, stateKey, ++lastMouseTimestamp);
+ // fall through
+ case MousePress:
+ case MouseClick:
+ qt_handleMouseEvent(w, pos, global, button, stateKey, ++lastMouseTimestamp);
+ lastMouseButton = button;
+ if (action == MousePress)
break;
- default:
- QTEST_ASSERT(false);
+ // fall through
+ case MouseRelease:
+ qt_handleMouseEvent(w, pos, global, Qt::NoButton, stateKey, ++lastMouseTimestamp);
+ lastMouseTimestamp += 500; // avoid double clicks being generated
+ lastMouseButton = Qt::NoButton;
+ break;
+ case MouseMove:
+ qt_handleMouseEvent(w, pos, global, lastMouseButton, stateKey, ++lastMouseTimestamp);
+ // No QCursor::setPos() call here. That could potentially result in mouse events sent by the windowing system
+ // which is highly undesired here. Tests must avoid relying on QCursor.
+ break;
+ default:
+ QTEST_ASSERT(false);
}
waitForEvents();
}
@@ -153,6 +153,15 @@ namespace QTest
Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
{
QTEST_ASSERT(widget);
+
+ if (pos.isNull())
+ pos = widget->rect().center();
+
+#ifdef QTEST_QPA_MOUSE_HANDLING
+ QWindow *w = widget->window()->windowHandle();
+ QTEST_ASSERT(w);
+ mouseEvent(action, w, button, stateKey, w->mapFromGlobal(widget->mapToGlobal(pos)), delay);
+#else
extern int Q_TESTLIB_EXPORT defaultMouseDelay();
if (delay == -1 || delay < defaultMouseDelay())
@@ -160,9 +169,6 @@ namespace QTest
if (delay > 0)
QTest::qWait(delay);
- if (pos.isNull())
- pos = widget->rect().center();
-
if (action == MouseClick) {
mouseEvent(MousePress, widget, button, stateKey, pos);
mouseEvent(MouseRelease, widget, button, stateKey, pos);
@@ -198,12 +204,12 @@ namespace QTest
}
QSpontaneKeyEvent::setSpontaneous(&me);
if (!qApp->notify(widget, &me)) {
- static const char *mouseActionNames[] =
+ static const char *const mouseActionNames[] =
{ "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" };
QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget");
QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toLatin1().data());
}
-
+#endif
}
inline void mousePress(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro
index 52bcdd097b..2d9bae5f31 100644
--- a/src/testlib/testlib.pro
+++ b/src/testlib/testlib.pro
@@ -56,6 +56,7 @@ SOURCES = qtestcase.cpp \
qcsvbenchmarklogger.cpp \
qtestelement.cpp \
qtestelementattribute.cpp \
+ qtestmouse.cpp \
qtestxunitstreamer.cpp \
qxunittestlogger.cpp \
qtestblacklist.cpp
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index a92e5b8f3d..be6bcadacb 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -97,6 +97,7 @@ SOURCES += \
../../corelib/tools/qlocale_tools.cpp \
../../corelib/tools/qmap.cpp \
../../corelib/tools/qregexp.cpp \
+ ../../corelib/tools/qringbuffer.cpp \
../../corelib/tools/qpoint.cpp \
../../corelib/tools/qrect.cpp \
../../corelib/tools/qsize.cpp \
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 8b6a0519c5..5be58d3c4b 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -448,7 +448,8 @@ void Generator::generateCode()
// Generate internal qt_static_metacall() function
//
const bool hasStaticMetaCall = !isQt &&
- (cdef->hasQObject || !cdef->methodList.isEmpty() || !cdef->propertyList.isEmpty());
+ (cdef->hasQObject || !cdef->methodList.isEmpty()
+ || !cdef->propertyList.isEmpty() || !cdef->constructorList.isEmpty());
if (hasStaticMetaCall)
generateStaticMetacall();
@@ -1125,7 +1126,8 @@ void Generator::generateStaticMetacall()
fprintf(out, "%s", QByteArray("QPrivateSignal()").constData());
}
fprintf(out, ");\n");
- fprintf(out, " if (_a[0]) *reinterpret_cast<QObject**>(_a[0]) = _r; } break;\n");
+ fprintf(out, " if (_a[0]) *reinterpret_cast<%s**>(_a[0]) = _r; } break;\n",
+ cdef->hasQGadget ? "void" : "QObject");
}
fprintf(out, " default: break;\n");
fprintf(out, " }\n");
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index 51873033c7..f253c49995 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -661,8 +661,10 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym
expansion += s;
}
} else if (mode == Hash) {
- if (index < 0)
+ if (index < 0 || index >= arguments.size()) {
that->error("'#' is not followed by a macro parameter");
+ continue;
+ }
const Symbols &arg = arguments.at(index);
QByteArray stringified;
@@ -681,7 +683,7 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym
expansion.pop_back();
Symbol next = s;
- if (index >= 0) {
+ if (index >= 0 && index < arguments.size()) {
const Symbols &arg = arguments.at(index);
if (arg.size() == 0) {
mode = Normal;
@@ -703,7 +705,7 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym
expansion += next;
}
- if (index >= 0) {
+ if (index >= 0 && index < arguments.size()) {
const Symbols &arg = arguments.at(index);
for (int i = 1; i < arg.size(); ++i)
expansion += arg.at(i);
diff --git a/src/tools/qdoc/atom.cpp b/src/tools/qdoc/atom.cpp
index ebbe685985..f50f401c5b 100644
--- a/src/tools/qdoc/atom.cpp
+++ b/src/tools/qdoc/atom.cpp
@@ -66,8 +66,6 @@ QT_BEGIN_NAMESPACE
/*! \enum Atom::AtomType
- \value AbstractLeft
- \value AbstractRight
\value AnnotatedList
\value AutoLink
\value BaseName
@@ -149,8 +147,6 @@ static const struct {
const char *english;
int no;
} atms[] = {
- { "AbstractLeft", Atom::AbstractLeft },
- { "AbstractRight", Atom::AbstractRight },
{ "AnnotatedList", Atom::AnnotatedList },
{ "AutoLink", Atom::AutoLink },
{ "BaseName", Atom::BaseName },
diff --git a/src/tools/qdoc/atom.h b/src/tools/qdoc/atom.h
index dae106a742..86b8ba7b3c 100644
--- a/src/tools/qdoc/atom.h
+++ b/src/tools/qdoc/atom.h
@@ -47,8 +47,6 @@ class Atom
{
public:
enum AtomType {
- AbstractLeft,
- AbstractRight,
AnnotatedList,
AutoLink,
BaseName,
diff --git a/src/tools/qdoc/codeparser.cpp b/src/tools/qdoc/codeparser.cpp
index 90823080ce..4f80ec80d9 100644
--- a/src/tools/qdoc/codeparser.cpp
+++ b/src/tools/qdoc/codeparser.cpp
@@ -423,33 +423,6 @@ void CodeParser::checkModuleInclusion(Node* n)
.arg(n->name()).arg(Generator::defaultModuleName()));
}
break;
-#if 0
- case Node::Document:
- if (n->access() != Node::Private && !n->doc().isEmpty()) {
- if (n->docSubtype() == Node::HeaderFile) {
-#if 0
- n->doc().location().warning(tr("Header file with title \"%1\" has no \\inmodule command; "
- "using project name by default: %2")
- .arg(n->title()).arg(Generator::defaultModuleName()));
-#endif
- }
- else if (n->docSubtype() == Node::Page) {
-#if 0
- n->doc().location().warning(tr("Page with title \"%1\" has no \\inmodule command; "
- "using project name by default: %2")
- .arg(n->title()).arg(Generator::defaultModuleName()));
-#endif
- }
- else if (n->docSubtype() == Node::Example) {
-#if 0
- n->doc().location().warning(tr("Example with title \"%1\" has no \\inmodule command; "
- "using project name by default: %2")
- .arg(n->title()).arg(Generator::defaultModuleName()));
-#endif
- }
- }
- break;
-#endif
default:
break;
}
diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp
index 552fb6a4ba..0468f3691e 100644
--- a/src/tools/qdoc/cppcodeparser.cpp
+++ b/src/tools/qdoc/cppcodeparser.cpp
@@ -520,16 +520,6 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc,
else if (t == "ditamap")
ptype = Node::DitaMapPage;
}
-
-#if 0
- const Node* n = qdb_->checkForCollision(args[0]);
- if (n) {
- QString other = n->doc().location().fileName();
- doc.location().warning(tr("Name/title collision detected: '%1' in '\\%2'")
- .arg(args[0]).arg(command),
- tr("Also used here: %1").arg(other));
- }
-#endif
DocumentNode* dn = 0;
if (ptype == Node::DitaMapPage)
dn = new DitaMapNode(qdb_->primaryTreeRoot(), args[0]);
@@ -870,7 +860,8 @@ const QSet<QString>& CppCodeParser::otherMetaCommands()
<< COMMAND_QMLINSTANTIATES
<< COMMAND_QMLDEFAULT
<< COMMAND_QMLREADONLY
- << COMMAND_QMLABSTRACT;
+ << COMMAND_QMLABSTRACT
+ << COMMAND_ABSTRACT;
}
return otherMetaCommands_;
}
@@ -891,8 +882,7 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc,
((Aggregate *) node)->addInclude(arg);
}
else {
- doc.location().warning(tr("Ignored '\\%1'")
- .arg(COMMAND_INHEADERFILE));
+ doc.location().warning(tr("Ignored '\\%1'").arg(COMMAND_INHEADERFILE));
}
}
else if (command == COMMAND_OVERLOAD) {
@@ -931,9 +921,7 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc,
func->setReimplemented(true);
}
else {
- doc.location().warning(tr("Ignored '\\%1' in %2")
- .arg(COMMAND_REIMP)
- .arg(node->name()));
+ doc.location().warning(tr("Ignored '\\%1' in %2").arg(COMMAND_REIMP).arg(node->name()));
}
}
}
@@ -1014,7 +1002,7 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc,
}
}
}
- else if (command == COMMAND_QMLABSTRACT) {
+ else if ((command == COMMAND_QMLABSTRACT) || (command == COMMAND_ABSTRACT)) {
if (node->isQmlType() || node->isJsType())
node->setAbstract(true);
}
@@ -2077,29 +2065,25 @@ bool CppCodeParser::matchDeclList(Aggregate *parent)
case Tok_Q_DECLARE_SEQUENTIAL_ITERATOR:
readToken();
if (match(Tok_LeftParen) && match(Tok_Ident))
- sequentialIteratorClasses.insert(previousLexeme(),
- location().fileName());
+ sequentialIteratorClasses.insert(previousLexeme(), location().fileName());
match(Tok_RightParen);
break;
case Tok_Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR:
readToken();
if (match(Tok_LeftParen) && match(Tok_Ident))
- mutableSequentialIteratorClasses.insert(previousLexeme(),
- location().fileName());
+ mutableSequentialIteratorClasses.insert(previousLexeme(), location().fileName());
match(Tok_RightParen);
break;
case Tok_Q_DECLARE_ASSOCIATIVE_ITERATOR:
readToken();
if (match(Tok_LeftParen) && match(Tok_Ident))
- associativeIteratorClasses.insert(previousLexeme(),
- location().fileName());
+ associativeIteratorClasses.insert(previousLexeme(), location().fileName());
match(Tok_RightParen);
break;
case Tok_Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR:
readToken();
if (match(Tok_LeftParen) && match(Tok_Ident))
- mutableAssociativeIteratorClasses.insert(previousLexeme(),
- location().fileName());
+ mutableAssociativeIteratorClasses.insert(previousLexeme(), location().fileName());
match(Tok_RightParen);
break;
case Tok_Q_DECLARE_FLAGS:
diff --git a/src/tools/qdoc/cppcodeparser.h b/src/tools/qdoc/cppcodeparser.h
index 4acd370541..31964699a2 100644
--- a/src/tools/qdoc/cppcodeparser.h
+++ b/src/tools/qdoc/cppcodeparser.h
@@ -177,6 +177,7 @@ protected:
QString exampleImageFilter;
};
+#define COMMAND_ABSTRACT Doc::alias("abstract")
#define COMMAND_CLASS Doc::alias("class")
#define COMMAND_CONTENTSPAGE Doc::alias("contentspage")
#define COMMAND_DITAMAP Doc::alias("ditamap")
diff --git a/src/tools/qdoc/doc.cpp b/src/tools/qdoc/doc.cpp
index bfe9cbe935..f322bd9360 100644
--- a/src/tools/qdoc/doc.cpp
+++ b/src/tools/qdoc/doc.cpp
@@ -69,7 +69,6 @@ struct Macro
enum {
CMD_A,
- CMD_ABSTRACT,
CMD_ANNOTATEDLIST,
CMD_B,
CMD_BADCODE,
@@ -85,7 +84,6 @@ enum {
CMD_DOTS,
CMD_E,
CMD_ELSE,
- CMD_ENDABSTRACT,
CMD_ENDCHAPTER,
CMD_ENDCODE,
CMD_ENDDIV,
@@ -187,7 +185,6 @@ static struct {
QString *alias;
} cmds[] = {
{ "a", CMD_A, 0 },
- { "abstract", CMD_ABSTRACT, 0 },
{ "annotatedlist", CMD_ANNOTATEDLIST, 0 },
{ "b", CMD_B, 0 },
{ "badcode", CMD_BADCODE, 0 },
@@ -203,7 +200,6 @@ static struct {
{ "dots", CMD_DOTS, 0 },
{ "e", CMD_E, 0 },
{ "else", CMD_ELSE, 0 },
- { "endabstract", CMD_ENDABSTRACT, 0 },
{ "endchapter", CMD_ENDCHAPTER, 0 },
{ "endcode", CMD_ENDCODE, 0 },
{ "enddiv", CMD_ENDDIV, 0 },
@@ -631,12 +627,6 @@ void DocParser::parse(const QString& source,
append(Atom::FormattingRight,ATOM_FORMATTING_PARAMETER);
priv->params.insert(p1);
break;
- case CMD_ABSTRACT:
- if (openCommand(cmd)) {
- leavePara();
- append(Atom::AbstractLeft);
- }
- break;
case CMD_BADCODE:
leavePara();
append(Atom::CodeBad,getCode(CMD_BADCODE, marker));
@@ -748,12 +738,6 @@ void DocParser::parse(const QString& source,
location().warning(tr("Unexpected '\\%1'").arg(cmdName(CMD_ELSE)));
}
break;
- case CMD_ENDABSTRACT:
- if (closeCommand(cmd)) {
- leavePara();
- append(Atom::AbstractRight);
- }
- break;
case CMD_ENDCHAPTER:
endSection(Doc::Chapter, cmd);
break;
@@ -1830,11 +1814,6 @@ bool DocParser::openCommand(int cmd)
if (outer == CMD_LIST) {
ok = (cmd == CMD_FOOTNOTE || cmd == CMD_LIST);
}
- else if (outer == CMD_ABSTRACT) {
- ok = (cmd == CMD_LIST ||
- cmd == CMD_QUOTATION ||
- cmd == CMD_TABLE);
- }
else if (outer == CMD_SIDEBAR) {
ok = (cmd == CMD_LIST ||
cmd == CMD_QUOTATION ||
@@ -2674,8 +2653,6 @@ void DocParser::skipToNextPreprocessorCommand()
int DocParser::endCmdFor(int cmd)
{
switch (cmd) {
- case CMD_ABSTRACT:
- return CMD_ENDABSTRACT;
case CMD_BADCODE:
return CMD_ENDCODE;
case CMD_CHAPTER:
diff --git a/src/tools/qdoc/doc/qdoc-manual-cmdindex.qdoc b/src/tools/qdoc/doc/qdoc-manual-cmdindex.qdoc
index 87416fcd14..63fcee6469 100644
--- a/src/tools/qdoc/doc/qdoc-manual-cmdindex.qdoc
+++ b/src/tools/qdoc/doc/qdoc-manual-cmdindex.qdoc
@@ -106,6 +106,7 @@
\li \l {printto-command} {\\printto}
\li \l {printuntil-command} {\\printuntil}
\li \l {property-command} {\\property}
+ \li \l {qmlabstract-command} {\\qmlabstract}
\li \l {qmlattachedproperty-command} {\\qmlattachedproperty}
\li \l {qmlattachedsignal-command} {\\qmlattachedsignal}
\li \l {qmlbasictype-command} {\\qmlbasictype}
diff --git a/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc b/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc
index 700b1a09c7..3bf63214ad 100644
--- a/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc
+++ b/src/tools/qdoc/doc/qdoc-manual-contextcmds.qdoc
@@ -46,6 +46,7 @@
below the \l {Topic Commands} {topic} command.
\list
+ \li \l {abstract-command} {\\abstract}
\li \l {compat-command}{\\compat},
\li \l {contentspage-command}{\\contentspage},
\li \l {indexpage-command}{\\indexpage},
@@ -59,6 +60,7 @@
\li \l {overload-command}{\\overload},
\li \l {preliminary-command}{\\preliminary},
\li \l {previouspage-command}{\\previouspage},
+ \li \l {qmlabstract-command} {\\qmlabstract}
\li \l {reentrant-command}{\\reentrant},
\li \l {reimp-command}{\\reimp},
\li \l {relates-command}{\\relates},
@@ -199,21 +201,41 @@
index page of the collection.
*/
-
/*!
\page 16-qdoc-commands-status.html
\previouspage Document Navigation
\contentspage QDoc Manual
\nextpage Thread Support
- \title Reporting Status
-
- These commands are for indicating that a documented element is
- still under development, is becoming obsolete, is provided for
- compatibility reasons, or is simply not to be included in the
- public interface. The \l {since-command}{\\since} command is for
- including information about the version when a function or class
- first appeared.
+ \title Status
+
+ These commands are for indicating that a documented element has
+ some special status. The element could be marked as about to be
+ made obsolete, or that it is provided for compatibility with an
+ earlier version, or is simply not to be included in the public
+ interface. The \l {since-command}{\\since} command is for
+ specifying the version number in which a function or class first
+ appeared. The \l {qmlabstract-command} {\\qmlabstract} command is
+ for marking a QML type as an abstract base class.
+
+ \target abstract-command
+ \target qmlabstract-command
+ \section1 \\abstract and \\qmlabstract
+
+ \\abstract is a synonym for the \\qmlabstract command. Add this
+ command to the \l {qmltype-command} {\\qmltype} comment for a QML
+ type when that type is meant to be used \e {only} as an abstract
+ base type. When a QML type is abstract, it means that the QML type
+ that can't be instantiated. Instead, the properties in its public
+ API are included in the public properties list on the reference
+ page for each QML type that inherits the abstract QML type. The
+ properties are documented as if they are properties of the
+ inheriting QML type.
+
+ Normally, when a QML type is marked with \e{\\qmlabstract}, it is
+ also marked with \e{\\internal} so that its reference page is not
+ generated. It the abstract QML type is not marked internal, it
+ will have a reference page in the documentation.
\target compat-command
\section1 \\compat
diff --git a/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc b/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc
index d9b5a6f659..9458d96045 100644
--- a/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc
+++ b/src/tools/qdoc/doc/qdoc-manual-markupcmds.qdoc
@@ -38,7 +38,6 @@
\list
\li \l {a-command} {\\a}
- \li \l {abstract-command} {\\abstract}
\li \l {annotatedlist-command} {\\annotatedlist}
\li \l {b-command} {\\b} \span {class="newStuff"}
\li \l {b-command} {\\bold} {(deprecated, use \\b)}
@@ -2886,19 +2885,6 @@
parts with a special rendering, conceptual meaning or
function.
- \target abstract-command
- \section1 \\abstract
-
- The \\abstract and \\endabstract commands delimit a
- document's abstract section.
-
- The abstract section is rendered as an indented italicized
- paragraph.
-
- \warning The \b{\\abstract} and \b{\\endabstract} commands
- have not been implemented. The abstract section is rendered as a
- regular HTML paragraph.
-
\target quotation-command
\section1 \\quotation
diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp
index 3fb6acf72b..d7a17fce26 100644
--- a/src/tools/qdoc/htmlgenerator.cpp
+++ b/src/tools/qdoc/htmlgenerator.cpp
@@ -474,14 +474,6 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
static bool in_para = false;
switch (atom->type()) {
- case Atom::AbstractLeft:
- if (relative)
- relative->doc().location().warning(tr("\abstract is not implemented."));
- else
- Location::information(tr("\abstract is not implemented."));
- break;
- case Atom::AbstractRight:
- break;
case Atom::AutoLink:
case Atom::NavAutoLink:
if (!inLink_ && !inContents_ && !inSectionHeading_) {
@@ -2199,7 +2191,7 @@ void HtmlGenerator::generateRequisites(Aggregate *inner, CodeMarker *marker)
out() << "<div class=\"table\"><table class=\"alignedsummary\">\n";
QStringList::ConstIterator i;
- for (i = requisiteorder.begin(); i != requisiteorder.constEnd(); ++i) {
+ for (i = requisiteorder.constBegin(); i != requisiteorder.constEnd(); ++i) {
if (requisites.contains(*i)) {
out() << "<tr>"
@@ -2319,7 +2311,7 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker)
out() << "<div class=\"table\"><table class=\"alignedsummary\">\n";
QStringList::ConstIterator i;
- for (i = requisiteorder.begin(); i != requisiteorder.constEnd(); ++i) {
+ for (i = requisiteorder.constBegin(); i != requisiteorder.constEnd(); ++i) {
if (requisites.contains(*i)) {
out() << "<tr>"
@@ -3559,7 +3551,8 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode,
bool handled = false;
for (int k = 0; k != 18; ++k) {
const QString & tag = spanTags[2 * k];
- if (tag == QStringRef(&src, i, tag.length())) {
+ if (i + tag.length() <= src.length() &&
+ tag == QStringRef(&src, i, tag.length())) {
html += spanTags[2 * k + 1];
i += tag.length();
handled = true;
@@ -4544,33 +4537,49 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString
writer.writeCDATA(QString("No description available"));
writer.writeEndElement(); // description
- // Add words from module name as tags (QtQuickControls -> qt,quick,controls)
- QRegExp re("([A-Z]+[a-z0-9]*)");
+ // Add words from module name as tags
+ // QtQuickControls -> qt,quick,controls
+ // QtOpenGL -> qt,opengl
+ QRegExp re("([A-Z]+[a-z0-9]*(3D|GL)?)");
int pos = 0;
while ((pos = re.indexIn(project, pos)) != -1) {
tags << re.cap(1).toLower();
pos += re.matchedLength();
}
tags += QSet<QString>::fromList(en->title().toLower().split(QLatin1Char(' ')));
+
+ // Clean up tags, exclude invalid and common words
+ QSet<QString>::iterator tag_it = tags.begin();
+ QSet<QString> modified;
+ while (tag_it != tags.end()) {
+ QString s = *tag_it;
+ if (s.at(0) == '(')
+ s.remove(0, 1).chop(1);
+ if (s.endsWith(QLatin1Char(':')))
+ s.chop(1);
+
+ if (s.length() < 2
+ || s.at(0).isDigit()
+ || s.at(0) == '-'
+ || s == QStringLiteral("qt")
+ || s == QStringLiteral("the")
+ || s == QStringLiteral("and")
+ || s.startsWith(QStringLiteral("example"))
+ || s.startsWith(QStringLiteral("chapter")))
+ tag_it = tags.erase(tag_it);
+ else if (s != *tag_it) {
+ modified << s;
+ tag_it = tags.erase(tag_it);
+ }
+ else
+ ++tag_it;
+ }
+ tags += modified;
+
if (!tags.isEmpty()) {
writer.writeStartElement("tags");
bool wrote_one = false;
- // Exclude invalid and common words
foreach (QString tag, tags) {
- if (tag.length() < 2)
- continue;
- if (tag.at(0).isDigit())
- continue;
- if (tag.at(0) == '-')
- continue;
- if (tag == QLatin1String("qt"))
- continue;
- if (tag.startsWith("example"))
- continue;
- if (tag.startsWith("chapter"))
- continue;
- if (tag.endsWith(QLatin1Char(':')))
- tag.chop(1);
if (wrote_one)
writer.writeCharacters(",");
writer.writeCharacters(tag);
diff --git a/src/tools/qdoc/location.cpp b/src/tools/qdoc/location.cpp
index 12dc9e1b4c..5eba2a69ef 100644
--- a/src/tools/qdoc/location.cpp
+++ b/src/tools/qdoc/location.cpp
@@ -256,7 +256,7 @@ QString Location::canonicalRelativePath(const QString &path)
*/
void Location::warning(const QString& message, const QString& details) const
{
- if (!Generator::preparing())
+ if (!Generator::preparing() || Generator::singleExec())
emitMessage(Warning, message, details);
}
@@ -267,7 +267,7 @@ void Location::warning(const QString& message, const QString& details) const
*/
void Location::error(const QString& message, const QString& details) const
{
- if (!Generator::preparing())
+ if (!Generator::preparing() || Generator::singleExec())
emitMessage(Error, message, details);
}
diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp
index ec721aee64..dbe397357c 100644
--- a/src/tools/qdoc/node.cpp
+++ b/src/tools/qdoc/node.cpp
@@ -2760,8 +2760,8 @@ bool CollectionNode::hasNamespaces() const
bool CollectionNode::hasClasses() const
{
if (!members_.isEmpty()) {
- NodeList::const_iterator i = members_.begin();
- while (i != members_.end()) {
+ NodeList::const_iterator i = members_.cbegin();
+ while (i != members_.cend()) {
if ((*i)->isClass())
return true;
++i;
@@ -2777,8 +2777,8 @@ bool CollectionNode::hasClasses() const
void CollectionNode::getMemberNamespaces(NodeMap& out)
{
out.clear();
- NodeList::const_iterator i = members_.begin();
- while (i != members_.end()) {
+ NodeList::const_iterator i = members_.cbegin();
+ while (i != members_.cend()) {
if ((*i)->isNamespace())
out.insert((*i)->name(),(*i));
++i;
@@ -2792,8 +2792,8 @@ void CollectionNode::getMemberNamespaces(NodeMap& out)
void CollectionNode::getMemberClasses(NodeMap& out)
{
out.clear();
- NodeList::const_iterator i = members_.begin();
- while (i != members_.end()) {
+ NodeList::const_iterator i = members_.cbegin();
+ while (i != members_.cend()) {
if ((*i)->isClass())
out.insert((*i)->name(),(*i));
++i;
diff --git a/src/tools/qdoc/puredocparser.cpp b/src/tools/qdoc/puredocparser.cpp
index 6b644cac31..bfd3925353 100644
--- a/src/tools/qdoc/puredocparser.cpp
+++ b/src/tools/qdoc/puredocparser.cpp
@@ -188,8 +188,8 @@ bool PureDocParser::processQdocComments()
topics.insert(i+1,"and");
doc.location().warning(tr("Multiple topic commands found in comment: %1").arg(topics));
}
- ArgList::ConstIterator a = args.begin();
- while (a != args.end()) {
+ ArgList::ConstIterator a = args.cbegin();
+ while (a != args.cend()) {
Doc nodeDoc = doc;
Node* node = processTopicCommand(nodeDoc,topic,*a);
if (node != 0) {
diff --git a/src/tools/qdoc/qdocdatabase.cpp b/src/tools/qdoc/qdocdatabase.cpp
index fca34b0a6a..f10072a943 100644
--- a/src/tools/qdoc/qdocdatabase.cpp
+++ b/src/tools/qdoc/qdocdatabase.cpp
@@ -1549,8 +1549,8 @@ void QDocDatabase::mergeCollections(Node::Genus genus, CNMap& cnm, const Node* r
foreach (Tree* t, searchOrder()) {
CNMap* m = t->getCollectionMap(genus);
if (m && !m->isEmpty()) {
- CNMap::const_iterator i = m->begin();
- while (i != m->end()) {
+ CNMap::const_iterator i = m->cbegin();
+ while (i != m->cend()) {
if (!i.value()->isInternal())
cnmm.insert(i.key(), i.value());
++i;
diff --git a/src/tools/qdoc/qmlcodeparser.cpp b/src/tools/qdoc/qmlcodeparser.cpp
index 4f5720a94d..f485255b8e 100644
--- a/src/tools/qdoc/qmlcodeparser.cpp
+++ b/src/tools/qdoc/qmlcodeparser.cpp
@@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE
#define COMMAND_SINCE Doc::alias("since")
#define COMMAND_WRAPPER Doc::alias("wrapper")
+#define COMMAND_ABSTRACT Doc::alias("abstract")
#define COMMAND_QMLABSTRACT Doc::alias("qmlabstract")
#define COMMAND_QMLCLASS Doc::alias("qmlclass")
#define COMMAND_QMLTYPE Doc::alias("qmltype")
@@ -251,6 +252,7 @@ const QSet<QString>& QmlCodeParser::otherMetaCommands()
<< COMMAND_OBSOLETE
<< COMMAND_PRELIMINARY
<< COMMAND_SINCE
+ << COMMAND_ABSTRACT
<< COMMAND_QMLABSTRACT
<< COMMAND_INQMLMODULE
<< COMMAND_INJSMODULE
diff --git a/src/tools/qdoc/qmlvisitor.cpp b/src/tools/qdoc/qmlvisitor.cpp
index 4803a1d63a..360af5adf6 100644
--- a/src/tools/qdoc/qmlvisitor.cpp
+++ b/src/tools/qdoc/qmlvisitor.cpp
@@ -55,6 +55,7 @@ QT_BEGIN_NAMESPACE
#define COMMAND_SINCE Doc::alias(QLatin1String("since"))
#define COMMAND_WRAPPER Doc::alias(QLatin1String("wrapper"))
+#define COMMAND_ABSTRACT Doc::alias(QLatin1String("abstract"))
#define COMMAND_QMLABSTRACT Doc::alias(QLatin1String("qmlabstract"))
#define COMMAND_QMLCLASS Doc::alias(QLatin1String("qmlclass"))
#define COMMAND_QMLTYPE Doc::alias(QLatin1String("qmltype"))
@@ -497,7 +498,7 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::AST::SourceLocation,
while (i != metacommands.end()) {
QString command = *i;
ArgList args = doc.metaCommandArgs(command);
- if (command == COMMAND_QMLABSTRACT) {
+ if ((command == COMMAND_QMLABSTRACT) || (command == COMMAND_ABSTRACT)) {
if (node->isQmlType() || node->isJsType()) {
node->setAbstract(true);
}
diff --git a/src/tools/qdoc/tree.cpp b/src/tools/qdoc/tree.cpp
index 0da963fe0b..629514e7d1 100644
--- a/src/tools/qdoc/tree.cpp
+++ b/src/tools/qdoc/tree.cpp
@@ -1222,8 +1222,8 @@ CollectionNode* Tree::getCollection(const QString& name, Node::Genus genus)
{
CNMap* m = getCollectionMap(genus);
if (m) {
- CNMap::const_iterator i = m->find(name);
- if (i != m->end())
+ CNMap::const_iterator i = m->constFind(name);
+ if (i != m->cend())
return i.value();
}
return 0;
@@ -1249,8 +1249,8 @@ CollectionNode* Tree::findCollection(const QString& name, Node::Genus genus)
CNMap* m = getCollectionMap(genus);
if (!m) // error
return 0;
- CNMap::const_iterator i = m->find(name);
- if (i != m->end())
+ CNMap::const_iterator i = m->constFind(name);
+ if (i != m->cend())
return i.value();
Node::NodeType t = Node::NoType;
switch (genus) {
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp
index 4f6cb56060..c7625c2827 100644
--- a/src/widgets/accessible/itemviews.cpp
+++ b/src/widgets/accessible/itemviews.cpp
@@ -1010,6 +1010,9 @@ QAccessible::Role QAccessibleTableCell::role() const
QAccessible::State QAccessibleTableCell::state() const
{
QAccessible::State st;
+ if (!view)
+ return st;
+
QRect globalRect = view->rect();
globalRect.translate(view->mapToGlobal(QPoint(0,0)));
if (!globalRect.intersects(rect()))
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index 65def6d4b8..6676a3ccba 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -534,7 +534,10 @@ int QDialog::exec()
QPointer<QDialog> guard = this;
if (d->nativeDialogInUse) {
- d->platformHelper()->exec();
+ if (windowModality() == Qt::WindowModal)
+ d->platformHelper()->execModalForWindow(d->parentWindow());
+ else
+ d->platformHelper()->exec();
} else {
QEventLoop eventLoop;
d->eventLoop = &eventLoop;
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 1be2f93478..41522bfa19 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -893,6 +893,12 @@ void QFileDialogPrivate::_q_goToUrl(const QUrl &url)
/*!
Sets the file dialog's current \a directory.
+
+ \note On iOS, if you set \a directory to \l{QStandardPaths::standardLocations()}
+ {QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()},
+ a native image picker dialog will be used for accessing the user's photo album.
+ The filename returned can be loaded using QFile and related APIs.
+ This feature was added in Qt 5.5.
*/
void QFileDialog::setDirectory(const QString &directory)
{
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index df07de7975..7329019a87 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -185,6 +185,8 @@ void QFileInfoGatherer::removePath(const QString &path)
#ifndef QT_NO_FILESYSTEMWATCHER
QMutexLocker locker(&mutex);
watcher->removePath(path);
+#else
+ Q_UNUSED(path);
#endif
}
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 04238f242a..4859231d95 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -544,7 +544,7 @@ QModelIndex QFileSystemModel::parent(const QModelIndex &index) const
QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(index);
Q_ASSERT(indexNode != 0);
- QFileSystemModelPrivate::QFileSystemNode *parentNode = (indexNode ? indexNode->parent : 0);
+ QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent;
if (parentNode == 0 || parentNode == &d->root)
return QModelIndex();
@@ -653,10 +653,12 @@ int QFileSystemModel::columnCount(const QModelIndex &parent) const
*/
QVariant QFileSystemModel::myComputer(int role) const
{
+#ifndef QT_NO_FILESYSTEMWATCHER
Q_D(const QFileSystemModel);
+#endif
switch (role) {
case Qt::DisplayRole:
- return d->myComputer();
+ return QFileSystemModelPrivate::myComputer();
#ifndef QT_NO_FILESYSTEMWATCHER
case Qt::DecorationRole:
return d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer);
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index 701fea1c03..a4b37f360b 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -361,6 +361,36 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type)
Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
+static LOGFONT getCaptionLogFont(HANDLE hTheme)
+{
+ LOGFONT result = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } };
+
+ if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &result))) {
+ NONCLIENTMETRICS ncm;
+ ncm.cbSize = sizeof(NONCLIENTMETRICS);
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false);
+ result = ncm.lfMessageFont;
+ }
+ return result;
+}
+
+static bool getCaptionQFont(int dpi, QFont *result)
+{
+ if (!pOpenThemeData)
+ return false;
+ const HANDLE hTheme =
+ pOpenThemeData(QApplicationPrivate::getHWNDForWidget(QApplication::desktop()), L"WINDOW");
+ if (!hTheme)
+ return false;
+ // Call into QWindowsNativeInterface to convert the LOGFONT into a QFont.
+ const LOGFONT logFont = getCaptionLogFont(hTheme);
+ QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface();
+ return ni && QMetaObject::invokeMethod(ni, "logFontToQFont", Qt::DirectConnection,
+ Q_RETURN_ARG(QFont, *result),
+ Q_ARG(const void *, &logFont),
+ Q_ARG(int, dpi));
+}
+
void QVistaHelper::drawTitleBar(QPainter *painter)
{
Q_ASSERT(backButton_);
@@ -378,7 +408,9 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
const int verticalCenter = (btnTop + btnHeight / 2) - 1;
const QString text = wizard->window()->windowTitle();
- const QFont font = QApplication::font("QMdiSubWindowTitleBar");
+ QFont font;
+ if (!isWindow || !getCaptionQFont(wizard->logicalDpiY() * wizard->devicePixelRatio(), &font))
+ font = QApplication::font("QMdiSubWindowTitleBar");
const QFontMetrics fontMetrics(font);
const QRect brect = fontMetrics.boundingRect(text);
int textHeight = brect.height();
@@ -649,19 +681,6 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event)
return false;
}
-HFONT QVistaHelper::getCaptionFont(HANDLE hTheme)
-{
- LOGFONT lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } };
-
- if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &lf))) {
- NONCLIENTMETRICS ncm;
- ncm.cbSize = sizeof(NONCLIENTMETRICS);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false);
- lf = ncm.lfMessageFont;
- }
- return CreateFontIndirect(&lf);
-}
-
// Return a HDC for the wizard along with the transformation if the
// wizard is a child window.
HDC QVistaHelper::backingStoreDC(const QWidget *wizard, QPoint *offset)
@@ -713,7 +732,8 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q
bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
// Set up the DC
- HFONT hCaptionFont = getCaptionFont(hTheme);
+ const LOGFONT captionLogFont = getCaptionLogFont(hTheme);
+ const HFONT hCaptionFont = CreateFontIndirect(&captionLogFont);
HBITMAP hOldBmp = (HBITMAP)SelectObject(dcMem, (HGDIOBJ) bmp);
HFONT hOldFont = (HFONT)SelectObject(dcMem, (HGDIOBJ) hCaptionFont);
diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h
index 8c36472bee..84b795d506 100644
--- a/src/widgets/dialogs/qwizard_win_p.h
+++ b/src/widgets/dialogs/qwizard_win_p.h
@@ -105,7 +105,6 @@ public:
static HDC backingStoreDC(const QWidget *wizard, QPoint *offset);
private:
- static HFONT getCaptionFont(HANDLE hTheme);
HWND wizardHWND() const;
bool drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc);
static bool drawBlackRect(const QRect &rect, HDC hdc);
diff --git a/src/widgets/doc/images/listview.png b/src/widgets/doc/images/listview.png
index fa49c52c62..fa49c52c62 100755..100644
--- a/src/widgets/doc/images/listview.png
+++ b/src/widgets/doc/images/listview.png
Binary files differ
diff --git a/src/widgets/doc/images/modelview-combobox.png b/src/widgets/doc/images/modelview-combobox.png
index d172b413eb..d172b413eb 100755..100644
--- a/src/widgets/doc/images/modelview-combobox.png
+++ b/src/widgets/doc/images/modelview-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/tableview.png b/src/widgets/doc/images/tableview.png
index 8be1b6ce62..8be1b6ce62 100755..100644
--- a/src/widgets/doc/images/tableview.png
+++ b/src/widgets/doc/images/tableview.png
Binary files differ
diff --git a/src/widgets/doc/snippets/macmainwindow.mm b/src/widgets/doc/snippets/macmainwindow.mm
index e1df77089c..e1df77089c 100755..100644
--- a/src/widgets/doc/snippets/macmainwindow.mm
+++ b/src/widgets/doc/snippets/macmainwindow.mm
diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp
index f53804e494..5a97be3d96 100644
--- a/src/widgets/effects/qgraphicseffect.cpp
+++ b/src/widgets/effects/qgraphicseffect.cpp
@@ -111,6 +111,10 @@
#ifndef QT_NO_GRAPHICSEFFECT
QT_BEGIN_NAMESPACE
+QGraphicsEffectPrivate::~QGraphicsEffectPrivate()
+{
+}
+
/*!
\internal
\class QGraphicsEffectSource
diff --git a/src/widgets/effects/qgraphicseffect_p.h b/src/widgets/effects/qgraphicseffect_p.h
index 6e990cc52e..35264c0d30 100644
--- a/src/widgets/effects/qgraphicseffect_p.h
+++ b/src/widgets/effects/qgraphicseffect_p.h
@@ -142,6 +142,7 @@ class Q_WIDGETS_EXPORT QGraphicsEffectPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QGraphicsEffect)
public:
QGraphicsEffectPrivate() : source(0), isEnabled(1) {}
+ ~QGraphicsEffectPrivate();
inline void setGraphicsEffectSource(QGraphicsEffectSource *newSource)
{
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index cd30410097..1fdbe0fc18 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -10829,9 +10829,7 @@ void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic
range.start = 0;
range.length = layout.text().length();
range.format.setTextOutline(d->pen);
- QList<QTextLayout::FormatRange> formats;
- formats.append(range);
- layout.setAdditionalFormats(formats);
+ layout.setFormats(QVector<QTextLayout::FormatRange>(1, range));
}
setupTextLayout(&layout);
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index db4d18299b..08ea1ea0e3 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -269,8 +269,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
// Send mouse event.
QMouseEvent mouseEvent(type, pos, receiver->mapTo(receiver->topLevelWidget(), pos.toPoint()),
receiver->mapToGlobal(pos.toPoint()),
- event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&mouseEvent, event->source());
+ event->button(), event->buttons(), event->modifiers(), event->source());
QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
QApplicationPrivate::sendMouseEvent(receiver, &mouseEvent, alienWidget, widget,
diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h
index b025730bb1..68382bf498 100644
--- a/src/widgets/graphicsview/qgraphicsscene.h
+++ b/src/widgets/graphicsview/qgraphicsscene.h
@@ -282,6 +282,10 @@ protected:
QWidget *widget = 0);
protected Q_SLOTS:
+ // ### Qt 6: make unconditional
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ virtual
+#endif
bool focusNextPrevChild(bool next);
Q_SIGNALS:
diff --git a/src/widgets/graphicsview/qgraphicstransform.cpp b/src/widgets/graphicsview/qgraphicstransform.cpp
index 67564b5a8b..fe963fbf3c 100644
--- a/src/widgets/graphicsview/qgraphicstransform.cpp
+++ b/src/widgets/graphicsview/qgraphicstransform.cpp
@@ -89,6 +89,11 @@
#ifndef QT_NO_GRAPHICSVIEW
QT_BEGIN_NAMESPACE
+
+QGraphicsTransformPrivate::~QGraphicsTransformPrivate()
+{
+}
+
void QGraphicsTransformPrivate::setItem(QGraphicsItem *i)
{
if (item == i)
diff --git a/src/widgets/graphicsview/qgraphicstransform_p.h b/src/widgets/graphicsview/qgraphicstransform_p.h
index dde085935f..c81a95fd3d 100644
--- a/src/widgets/graphicsview/qgraphicstransform_p.h
+++ b/src/widgets/graphicsview/qgraphicstransform_p.h
@@ -51,12 +51,14 @@ QT_BEGIN_NAMESPACE
class QGraphicsItem;
-class QGraphicsTransformPrivate : public QObjectPrivate {
+// ### Qt 6: unexport again, if QtQuick1's QDeclarativeTranslatePrivate is gone by then
+class Q_WIDGETS_EXPORT QGraphicsTransformPrivate : public QObjectPrivate {
public:
Q_DECLARE_PUBLIC(QGraphicsTransform)
QGraphicsTransformPrivate()
: QObjectPrivate(), item(0) {}
+ ~QGraphicsTransformPrivate();
QGraphicsItem *item;
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index c270c4be88..decb455988 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -362,6 +362,10 @@ QGraphicsViewPrivate::QGraphicsViewPrivate()
styleOptions.reserve(QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS);
}
+QGraphicsViewPrivate::~QGraphicsViewPrivate()
+{
+}
+
/*!
\internal
*/
diff --git a/src/widgets/graphicsview/qgraphicsview_p.h b/src/widgets/graphicsview/qgraphicsview_p.h
index fec8336695..dcbffb1c39 100644
--- a/src/widgets/graphicsview/qgraphicsview_p.h
+++ b/src/widgets/graphicsview/qgraphicsview_p.h
@@ -63,6 +63,7 @@ class Q_WIDGETS_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
Q_DECLARE_PUBLIC(QGraphicsView)
public:
QGraphicsViewPrivate();
+ ~QGraphicsViewPrivate();
void recalculateContentSize();
void centerView(QGraphicsView::ViewportAnchor anchor);
diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp
index 402d54d2d8..e9ab6dffec 100644
--- a/src/widgets/graphicsview/qgraphicswidget_p.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp
@@ -64,9 +64,7 @@ void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFl
adjustWindowFlags(&wFlags);
windowFlags = wFlags;
- if (parentItem)
- setParentItemHelper(parentItem, 0, 0);
-
+ q->setParentItem(parentItem);
q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::DefaultType));
q->setGraphicsItem(q);
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 2caf5d1eb3..5b955a6e14 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -1882,8 +1882,7 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event)
|| (d->pressedIndex != index)) {
QMouseEvent me(QEvent::MouseButtonPress,
event->localPos(), event->windowPos(), event->screenPos(),
- event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&me, event->source());
+ event->button(), event->buttons(), event->modifiers(), event->source());
mousePressEvent(&me);
return;
}
diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h
index b792228312..016c50436b 100644
--- a/src/widgets/itemviews/qabstractitemview_p.h
+++ b/src/widgets/itemviews/qabstractitemview_p.h
@@ -168,8 +168,20 @@ public:
QModelIndex index;
int col = -1;
int row = -1;
+ const QMimeData *mime = event->mimeData();
+
+ // Drag enter event shall always be accepted, if mime type and action match.
+ // Whether the data can actually be dropped will be checked in drag move.
+ if (event->type() == QEvent::DragEnter) {
+ const QStringList modelTypes = model->mimeTypes();
+ for (int i = 0; i < modelTypes.count(); ++i)
+ if (mime->hasFormat(modelTypes.at(i))
+ && (event->dropAction() & model->supportedDropActions()))
+ return true;
+ }
+
if (dropOn(event, &row, &col, &index)) {
- return model->canDropMimeData(event->mimeData(),
+ return model->canDropMimeData(mime,
dragDropMode == QAbstractItemView::InternalMove ? Qt::MoveAction : event->dropAction(),
row, col, index);
}
diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp
index 5c317bbb0c..0ee03035a4 100644
--- a/src/widgets/itemviews/qcolumnview.cpp
+++ b/src/widgets/itemviews/qcolumnview.cpp
@@ -878,7 +878,9 @@ QList<int> QColumnView::columnWidths() const
{
Q_D(const QColumnView);
QList<int> list;
- for (int i = 0; i < d->columns.count(); ++i)
+ const int columnCount = d->columns.count();
+ list.reserve(columnCount);
+ for (int i = 0; i < columnCount; ++i)
list.append(d->columnSizes.at(i));
return list;
}
diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h
index ed30b5f085..0c0bdb5d1f 100644
--- a/src/widgets/itemviews/qcolumnview_p.h
+++ b/src/widgets/itemviews/qcolumnview_p.h
@@ -89,6 +89,16 @@ public:
QAbstractScrollArea::resizeEvent(event);
}
+ void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE
+ {
+ if (!previewWidget)
+ return;
+ scrollDirtyRegion(dx, dy);
+ viewport()->scroll(dx, dy);
+
+ QAbstractItemView::scrollContentsBy(dx, dy);
+ }
+
QRect visualRect(const QModelIndex &) const Q_DECL_OVERRIDE
{
return QRect();
diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp
index 1cc3a2a905..cab32619c5 100644
--- a/src/widgets/itemviews/qfileiconprovider.cpp
+++ b/src/widgets/itemviews/qfileiconprovider.cpp
@@ -117,6 +117,7 @@ public:
if (themeSizes.isEmpty())
return sizes;
+ sizes.reserve(themeSizes.count());
foreach (int size, themeSizes)
sizes << QSize(size, size);
}
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 66ff472724..bca315f80b 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -1879,13 +1879,13 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent,
// insert sections into hiddenSectionSize
QHash<int, int> newHiddenSectionSize; // from logical index to section size
- for (int i = 0; i < logicalFirst; ++i)
- if (isSectionHidden(i))
- newHiddenSectionSize[i] = d->hiddenSectionSize[i];
- for (int j = logicalLast + 1; j < d->sectionCount(); ++j)
- if (isSectionHidden(j))
- newHiddenSectionSize[j] = d->hiddenSectionSize[j - insertCount];
- d->hiddenSectionSize = newHiddenSectionSize;
+ for (QHash<int, int>::const_iterator it = d->hiddenSectionSize.cbegin(),
+ end = d->hiddenSectionSize.cend(); it != end; ++it) {
+ const int oldIndex = it.key();
+ const int newIndex = (oldIndex < logicalFirst) ? oldIndex : oldIndex + insertCount;
+ newHiddenSectionSize[newIndex] = it.value();
+ }
+ d->hiddenSectionSize.swap(newHiddenSectionSize);
d->doDelayedResizeSections();
emit sectionCountChanged(oldCount, count());
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index b7a4ec3925..9b07564db9 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -53,6 +53,8 @@
QT_BEGIN_NAMESPACE
+extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
+
/*!
\class QListView
@@ -796,6 +798,35 @@ void QListView::mouseReleaseEvent(QMouseEvent *e)
}
}
+#ifndef QT_NO_WHEELEVENT
+/*!
+ \reimp
+*/
+void QListView::wheelEvent(QWheelEvent *e)
+{
+ Q_D(QListView);
+ if (e->orientation() == Qt::Vertical) {
+ if (e->angleDelta().x() == 0
+ && ((d->flow == TopToBottom && d->wrap) || (d->flow == LeftToRight && !d->wrap))
+ && d->vbar->minimum() == 0 && d->vbar->maximum() == 0) {
+ QPoint pixelDelta(e->pixelDelta().y(), e->pixelDelta().x());
+ QPoint angleDelta(e->angleDelta().y(), e->angleDelta().x());
+ QWheelEvent hwe(e->pos(), e->globalPos(), pixelDelta, angleDelta, e->delta(),
+ Qt::Horizontal, e->buttons(), e->modifiers(), e->phase());
+ if (e->spontaneous())
+ qt_sendSpontaneousEvent(d->hbar, &hwe);
+ else
+ QApplication::sendEvent(d->hbar, &hwe);
+ e->setAccepted(hwe.isAccepted());
+ } else {
+ QApplication::sendEvent(d->vbar, e);
+ }
+ } else {
+ QApplication::sendEvent(d->hbar, e);
+ }
+}
+#endif // QT_NO_WHEELEVENT
+
/*!
\reimp
*/
@@ -1846,8 +1877,17 @@ void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step)
const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded &&
qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded;
- if (bothScrollBarsAuto && contentsSize.width() - qq->verticalScrollBar()->width() <= viewport()->width()
- && contentsSize.height() - qq->horizontalScrollBar()->height() <= viewport()->height()) {
+ const QSize viewportSize(viewport()->width() + (qq->verticalScrollBar()->maximum() > 0 ? qq->verticalScrollBar()->width() : 0),
+ viewport()->height() + (qq->horizontalScrollBar()->maximum() > 0 ? qq->horizontalScrollBar()->height() : 0));
+
+ bool verticalWantsToShow = contentsSize.height() > viewportSize.height();
+ bool horizontalWantsToShow;
+ if (verticalWantsToShow)
+ horizontalWantsToShow = contentsSize.width() > viewportSize.width() - qq->verticalScrollBar()->width();
+ else
+ horizontalWantsToShow = contentsSize.width() > viewportSize.width();
+
+ if (bothScrollBarsAuto && !horizontalWantsToShow) {
// break the infinite loop described above by setting the range to 0, 0.
// QAbstractScrollArea will then hide the scroll bar for us
horizontalScrollBar()->setRange(0, 0);
@@ -1868,8 +1908,17 @@ void QCommonListViewBase::updateVerticalScrollBar(const QSize &step)
const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded &&
qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded;
- if (bothScrollBarsAuto && contentsSize.width() - qq->verticalScrollBar()->width() <= viewport()->width()
- && contentsSize.height() - qq->horizontalScrollBar()->height() <= viewport()->height()) {
+ const QSize viewportSize(viewport()->width() + (qq->verticalScrollBar()->maximum() > 0 ? qq->verticalScrollBar()->width() : 0),
+ viewport()->height() + (qq->horizontalScrollBar()->maximum() > 0 ? qq->horizontalScrollBar()->height() : 0));
+
+ bool horizontalWantsToShow = contentsSize.width() > viewportSize.width();
+ bool verticalWantsToShow;
+ if (horizontalWantsToShow)
+ verticalWantsToShow = contentsSize.height() > viewportSize.height() - qq->horizontalScrollBar()->height();
+ else
+ verticalWantsToShow = contentsSize.height() > viewportSize.height();
+
+ if (bothScrollBarsAuto && !verticalWantsToShow) {
// break the infinite loop described above by setting the range to 0, 0.
// QAbstractScrollArea will then hide the scroll bar for us
verticalScrollBar()->setRange(0, 0);
diff --git a/src/widgets/itemviews/qlistview.h b/src/widgets/itemviews/qlistview.h
index f62c96067f..ac65a47d9f 100644
--- a/src/widgets/itemviews/qlistview.h
+++ b/src/widgets/itemviews/qlistview.h
@@ -146,6 +146,9 @@ protected:
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
+#endif
void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index 66f965aa54..668bfda59d 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -299,7 +299,10 @@ void QListModel::sort(int column, Qt::SortOrder order)
std::sort(sorting.begin(), sorting.end(), compare);
QModelIndexList fromIndexes;
QModelIndexList toIndexes;
- for (int r = 0; r < sorting.count(); ++r) {
+ const int sortingCount = sorting.count();
+ fromIndexes.reserve(sortingCount);
+ toIndexes.reserve(sortingCount);
+ for (int r = 0; r < sortingCount; ++r) {
QListWidgetItem *item = sorting.at(r).first;
toIndexes.append(createIndex(r, 0, item));
fromIndexes.append(createIndex(sorting.at(r).second, 0, sorting.at(r).first));
@@ -423,7 +426,9 @@ QMimeData *QListModel::internalMimeData() const
QMimeData *QListModel::mimeData(const QModelIndexList &indexes) const
{
QList<QListWidgetItem*> itemlist;
- for (int i = 0; i < indexes.count(); ++i)
+ const int indexesCount = indexes.count();
+ itemlist.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; ++i)
itemlist << at(indexes.at(i).row());
const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent());
@@ -1710,7 +1715,9 @@ QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFla
QModelIndexList indexes = d->listModel()->match(model()->index(0, 0, QModelIndex()),
Qt::DisplayRole, text, -1, flags);
QList<QListWidgetItem*> items;
- for (int i = 0; i < indexes.size(); ++i)
+ const int indexesSize = indexes.size();
+ items.reserve(indexesSize);
+ for (int i = 0; i < indexesSize; ++i)
items.append(d->listModel()->at(indexes.at(i).row()));
return items;
}
@@ -1795,6 +1802,7 @@ QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*> items) const
// if non empty, it's called from the model's own mimeData
if (cachedIndexes.isEmpty()) {
+ cachedIndexes.reserve(items.count());
foreach (QListWidgetItem *item, items)
cachedIndexes << indexFromItem(item);
@@ -1845,7 +1853,9 @@ void QListWidget::dropEvent(QDropEvent *event) {
if (d->dropOn(event, &row, &col, &topIndex)) {
QList<QModelIndex> selIndexes = selectedIndexes();
QList<QPersistentModelIndex> persIndexes;
- for (int i = 0; i < selIndexes.count(); i++)
+ const int selIndexesCount = selIndexes.count();
+ persIndexes.reserve(selIndexesCount);
+ for (int i = 0; i < selIndexesCount; i++)
persIndexes.append(selIndexes.at(i));
if (persIndexes.contains(topIndex))
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 9ebcbc35a7..b2d4abe5ac 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -812,7 +812,9 @@ QMimeData *QTableModel::internalMimeData() const
QMimeData *QTableModel::mimeData(const QModelIndexList &indexes) const
{
QList<QTableWidgetItem*> items;
- for (int i = 0; i < indexes.count(); ++i)
+ const int indexesCount = indexes.count();
+ items.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; ++i)
items << item(indexes.at(i));
const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent());
@@ -2326,7 +2328,9 @@ QList<QTableWidgetSelectionRange> QTableWidget::selectedRanges() const
{
const QList<QItemSelectionRange> ranges = selectionModel()->selection();
QList<QTableWidgetSelectionRange> result;
- for (int i = 0; i < ranges.count(); ++i)
+ const int rangesCount = ranges.count();
+ result.reserve(rangesCount);
+ for (int i = 0; i < rangesCount; ++i)
result.append(QTableWidgetSelectionRange(ranges.at(i).top(),
ranges.at(i).left(),
ranges.at(i).bottom(),
@@ -2372,7 +2376,9 @@ QList<QTableWidgetItem*> QTableWidget::findItems(const QString &text, Qt::MatchF
indexes += d->model->match(model()->index(0, column, QModelIndex()),
Qt::DisplayRole, text, -1, flags);
QList<QTableWidgetItem*> items;
- for (int i = 0; i < indexes.size(); ++i)
+ const int indexCount = indexes.size();
+ items.reserve(indexCount);
+ for (int i = 0; i < indexCount; ++i)
items.append(d->tableModel()->item(indexes.at(i)));
return items;
}
@@ -2565,6 +2571,7 @@ QMimeData *QTableWidget::mimeData(const QList<QTableWidgetItem*> items) const
// if non empty, it's called from the model's own mimeData
if (cachedIndexes.isEmpty()) {
+ cachedIndexes.reserve(items.count());
foreach (QTableWidgetItem *item, items)
cachedIndexes << indexFromItem(item);
@@ -2676,7 +2683,9 @@ void QTableWidget::dropEvent(QDropEvent *event) {
}
QList<QTableWidgetItem *> taken;
- for (int i = 0; i < indexes.count(); ++i)
+ const int indexesCount = indexes.count();
+ taken.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; ++i)
taken.append(takeItem(indexes.at(i).row(), indexes.at(i).column()));
for (int i = 0; i < indexes.count(); ++i) {
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 43db43fcd4..9b3e270fdd 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -3658,6 +3658,7 @@ void QTreeViewPrivate::updateScrollBars()
if (!viewportSize.isValid())
viewportSize = QSize(0, 0);
+ executePostedLayout();
if (viewItems.isEmpty()) {
q->doItemsLayout();
}
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index 1366a00318..5970e94292 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -3042,7 +3042,9 @@ QList<QTreeWidgetItem*> QTreeWidget::findItems(const QString &text, Qt::MatchFla
QModelIndexList indexes = d->model->match(model()->index(0, column, QModelIndex()),
Qt::DisplayRole, text, -1, flags);
QList<QTreeWidgetItem*> items;
- for (int i = 0; i < indexes.size(); ++i)
+ const int indexesSize = indexes.size();
+ items.reserve(indexesSize);
+ for (int i = 0; i < indexesSize; ++i)
items.append(d->item(indexes.at(i)));
return items;
}
@@ -3371,7 +3373,9 @@ void QTreeWidget::dropEvent(QDropEvent *event) {
if (d->dropOn(event, &row, &col, &topIndex)) {
QList<QModelIndex> idxs = selectedIndexes();
QList<QPersistentModelIndex> indexes;
- for (int i = 0; i < idxs.count(); i++)
+ const int indexesCount = idxs.count();
+ indexes.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; i++)
indexes.append(idxs.at(i));
if (indexes.contains(topIndex))
diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri
index 88c1e2595b..21a982f349 100644
--- a/src/widgets/kernel/kernel.pri
+++ b/src/widgets/kernel/kernel.pri
@@ -49,6 +49,7 @@ SOURCES += \
kernel/qlayoutengine.cpp \
kernel/qlayoutitem.cpp \
kernel/qshortcut.cpp \
+ kernel/qsizepolicy.cpp \
kernel/qstackedlayout.cpp \
kernel/qtooltip.cpp \
kernel/qwhatsthis.cpp \
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index dd7474b930..f457993168 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3250,12 +3250,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
QPointer<QWidget> pw = w;
while (w) {
- QMouseEvent me(mouse->type(), relpos, mouse->windowPos(), mouse->globalPos(), mouse->button(), mouse->buttons(),
- mouse->modifiers());
+ QMouseEvent me(mouse->type(), relpos, mouse->windowPos(), mouse->globalPos(),
+ mouse->button(), mouse->buttons(), mouse->modifiers(), mouse->source());
me.spont = mouse->spontaneous();
me.setTimestamp(mouse->timestamp());
QGuiApplicationPrivate::setMouseEventFlags(&me, mouse->flags());
- QGuiApplicationPrivate::setMouseEventSource(&me, mouse->source());
// throw away any mouse-tracking-only mouse events
if (!w->hasMouseTracking()
&& mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) {
@@ -4273,15 +4272,16 @@ void QApplicationPrivate::cleanupMultitouch_sys()
{
}
-QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos)
+QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QTouchEvent::TouchPoint &touchPoint)
{
+ const QPointF screenPos = touchPoint.screenPos();
int closestTouchPointId = -1;
QObject *closestTarget = 0;
qreal closestDistance = qreal(0.);
QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it = activeTouchPoints.constBegin(),
ite = activeTouchPoints.constEnd();
while (it != ite) {
- if (it.key().device == device) {
+ if (it.key().device == device && it.key().touchPointId != touchPoint.id()) {
const QTouchEvent::TouchPoint &touchPoint = it->touchPoint;
qreal dx = screenPos.x() - touchPoint.screenPos().x();
qreal dy = screenPos.y() - touchPoint.screenPos().y();
@@ -4337,7 +4337,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
}
if (device->type() == QTouchDevice::TouchScreen) {
- QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint.screenPos());
+ QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint);
QWidget *widget = static_cast<QWidget *>(target.data());
if (closestWidget
&& (widget->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget))) {
@@ -4357,8 +4357,10 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
#ifdef Q_OS_OSX
// Single-touch events are normally not sent unless WA_TouchPadAcceptSingleTouchEvents is set.
- // In Qt 4 this check was in OS X-only coode. That behavior is preserved here by the #ifdef.
- if (touchPoints.count() == 1 && !targetWidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents))
+ // In Qt 4 this check was in OS X-only code. That behavior is preserved here by the #ifdef.
+ if (touchPoints.count() == 1
+ && device->type() == QTouchDevice::TouchPad
+ && !targetWidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents))
continue;
#endif
@@ -4374,7 +4376,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin();
const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd();
for (; it != end; ++it) {
- QWidget *widget = it.key();
+ const QPointer<QWidget> widget = it.key();
if (!QApplicationPrivate::tryModalHelper(widget, 0))
continue;
@@ -4414,7 +4416,8 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
// has been implicitly accepted and continue to send touch events
if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted()) {
accepted = true;
- widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
+ if (!widget.isNull())
+ widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
}
break;
}
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 46359d7940..ba8d7ff63c 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -280,7 +280,7 @@ public:
void initializeMultitouch_sys();
void cleanupMultitouch();
void cleanupMultitouch_sys();
- QWidget *findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos);
+ QWidget *findClosestTouchPointTarget(QTouchDevice *device, const QTouchEvent::TouchPoint &touchPoint);
void appendTouchPoint(const QTouchEvent::TouchPoint &touchPoint);
void removeTouchPoint(int touchPointId);
static bool translateRawTouchEvent(QWidget *widget,
diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp
index 713a019cc3..7b7d465070 100644
--- a/src/widgets/kernel/qgesture.cpp
+++ b/src/widgets/kernel/qgesture.cpp
@@ -36,7 +36,7 @@
#include "private/qstandardgestures_p.h"
#include "qgraphicsview.h"
-#include <QtCore/QDebug>
+#include <private/qdebug_p.h>
#ifndef QT_NO_GESTURES
QT_BEGIN_NAMESPACE
@@ -1091,9 +1091,12 @@ QPointF QGestureEvent::mapToGraphicsScene(const QPointF &gesturePoint) const
static void formatGestureHeader(QDebug d, const char *className, const QGesture *gesture)
{
- d << className << "(state=" << gesture->state();
- if (gesture->hasHotSpot())
- d << ",hotSpot=" << gesture->hotSpot();
+ d << className << "(state=";
+ QtDebugUtils::formatQEnum(d, gesture->state());
+ if (gesture->hasHotSpot()) {
+ d << ",hotSpot=";
+ QtDebugUtils::formatQPoint(d, gesture->hotSpot());
+ }
}
Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture)
@@ -1103,31 +1106,42 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture)
switch (gesture->gestureType()) {
case Qt::TapGesture:
formatGestureHeader(d, "QTapGesture", gesture);
- d << ",position=" << static_cast<const QTapGesture*>(gesture)->position() << ')';
+ d << ",position=";
+ QtDebugUtils::formatQPoint(d, static_cast<const QTapGesture*>(gesture)->position());
+ d << ')';
break;
case Qt::TapAndHoldGesture: {
const QTapAndHoldGesture *tap = static_cast<const QTapAndHoldGesture*>(gesture);
formatGestureHeader(d, "QTapAndHoldGesture", tap);
- d << ",position=" << tap->position() << ",timeout=" << tap->timeout() << ')';
+ d << ",position=";
+ QtDebugUtils::formatQPoint(d, tap->position());
+ d << ",timeout=" << tap->timeout() << ')';
}
break;
case Qt::PanGesture: {
const QPanGesture *pan = static_cast<const QPanGesture*>(gesture);
formatGestureHeader(d, "QPanGesture", pan);
- d << ",lastOffset=" << pan->lastOffset() << ",offset=" << pan->offset()
- << ",acceleration=" << pan->acceleration()
- << ",delta=" << pan->delta() << ')';
+ d << ",lastOffset=";
+ QtDebugUtils::formatQPoint(d, pan->lastOffset());
+ d << pan->lastOffset();
+ d << ",offset=";
+ QtDebugUtils::formatQPoint(d, pan->offset());
+ d << ",acceleration=" << pan->acceleration() << ",delta=";
+ QtDebugUtils::formatQPoint(d, pan->delta());
+ d << ')';
}
break;
case Qt::PinchGesture: {
const QPinchGesture *pinch = static_cast<const QPinchGesture*>(gesture);
formatGestureHeader(d, "QPinchGesture", pinch);
d << ",totalChangeFlags=" << pinch->totalChangeFlags()
- << ",changeFlags=" << pinch->changeFlags()
- << ",startCenterPoint=" << pinch->startCenterPoint()
- << ",lastCenterPoint=" << pinch->lastCenterPoint()
- << ",centerPoint=" << pinch->centerPoint()
- << ",totalScaleFactor=" << pinch->totalScaleFactor()
+ << ",changeFlags=" << pinch->changeFlags() << ",startCenterPoint=";
+ QtDebugUtils::formatQPoint(d, pinch->startCenterPoint());
+ d << ",lastCenterPoint=";
+ QtDebugUtils::formatQPoint(d, pinch->lastCenterPoint());
+ d << ",centerPoint=";
+ QtDebugUtils::formatQPoint(d, pinch->centerPoint());
+ d << ",totalScaleFactor=" << pinch->totalScaleFactor()
<< ",lastScaleFactor=" << pinch->lastScaleFactor()
<< ",scaleFactor=" << pinch->scaleFactor()
<< ",totalRotationAngle=" << pinch->totalRotationAngle()
@@ -1138,9 +1152,11 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture)
case Qt::SwipeGesture: {
const QSwipeGesture *swipe = static_cast<const QSwipeGesture*>(gesture);
formatGestureHeader(d, "QSwipeGesture", swipe);
- d << ",horizontalDirection=" << swipe->horizontalDirection()
- << ",verticalDirection=" << swipe->verticalDirection()
- << ",swipeAngle=" << swipe->swipeAngle() << ')';
+ d << ",horizontalDirection=";
+ QtDebugUtils::formatQEnum(d, swipe->horizontalDirection());
+ d << ",verticalDirection=";
+ QtDebugUtils::formatQEnum(d, swipe->verticalDirection());
+ d << ",swipeAngle=" << swipe->swipeAngle() << ')';
}
break;
default:
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index dcacea4777..e74f17b6f7 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -1470,85 +1470,4 @@ QSize QLayout::closestAcceptableSize(const QWidget *widget, const QSize &size)
return result;
}
-void QSizePolicy::setControlType(ControlType type)
-{
- /*
- The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10,
- etc. In memory, we pack it onto the available bits (CTSize) in
- setControlType(), and unpack it here.
-
- Example:
-
- 0x00000001 maps to 0
- 0x00000002 maps to 1
- 0x00000004 maps to 2
- 0x00000008 maps to 3
- etc.
- */
-
- int i = 0;
- while (true) {
- if (type & (0x1 << i)) {
- bits.ctype = i;
- return;
- }
- ++i;
- }
-}
-
-QSizePolicy::ControlType QSizePolicy::controlType() const
-{
- return QSizePolicy::ControlType(1 << bits.ctype);
-}
-
-#ifndef QT_NO_DATASTREAM
-
-/*!
- \relates QSizePolicy
- \since 4.2
-
- Writes the size \a policy to the data stream \a stream.
-
- \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
-*/
-QDataStream &operator<<(QDataStream &stream, const QSizePolicy &policy)
-{
- // The order here is for historical reasons. (compatibility with Qt4)
- quint32 data = (policy.bits.horPolicy | // [0, 3]
- policy.bits.verPolicy << 4 | // [4, 7]
- policy.bits.hfw << 8 | // [8]
- policy.bits.ctype << 9 | // [9, 13]
- policy.bits.wfh << 14 | // [14]
- policy.bits.retainSizeWhenHidden << 15 | // [15]
- policy.bits.verStretch << 16 | // [16, 23]
- policy.bits.horStretch << 24); // [24, 31]
- return stream << data;
-}
-
-#define VALUE_OF_BITS(data, bitstart, bitcount) ((data >> bitstart) & ((1 << bitcount) -1))
-
-/*!
- \relates QSizePolicy
- \since 4.2
-
- Reads the size \a policy from the data stream \a stream.
-
- \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
-*/
-QDataStream &operator>>(QDataStream &stream, QSizePolicy &policy)
-{
- quint32 data;
- stream >> data;
- policy.bits.horPolicy = VALUE_OF_BITS(data, 0, 4);
- policy.bits.verPolicy = VALUE_OF_BITS(data, 4, 4);
- policy.bits.hfw = VALUE_OF_BITS(data, 8, 1);
- policy.bits.ctype = VALUE_OF_BITS(data, 9, 5);
- policy.bits.wfh = VALUE_OF_BITS(data, 14, 1);
- policy.bits.retainSizeWhenHidden = VALUE_OF_BITS(data, 15, 1);
- policy.bits.verStretch = VALUE_OF_BITS(data, 16, 8);
- policy.bits.horStretch = VALUE_OF_BITS(data, 24, 8);
- return stream;
-}
-#endif // QT_NO_DATASTREAM
-
QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index b21925e1d4..21f4c9a221 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -34,7 +34,6 @@
#include "qlayout.h"
#include "qapplication.h"
-#include "qdebug.h"
#include "qlayoutengine_p.h"
#include "qmenubar.h"
#include "qtoolbar.h"
@@ -68,14 +67,6 @@ inline static QSize toLayoutItemSize(QWidgetPrivate *priv, const QSize &size)
}
/*!
- Returns a QVariant storing this QSizePolicy.
-*/
-QSizePolicy::operator QVariant() const
-{
- return QVariant(QVariant::SizePolicy, this);
-}
-
-/*!
\class QLayoutItem
\brief The QLayoutItem class provides an abstract item that a
QLayout manipulates.
@@ -847,14 +838,4 @@ int QWidgetItemV2::heightForWidth(int width) const
return height;
}
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QSizePolicy &p)
-{
- QDebugStateSaver saver(dbg);
- dbg.nospace() << "QSizePolicy(horizontalPolicy = " << p.horizontalPolicy()
- << ", verticalPolicy = " << p.verticalPolicy() << ')';
- return dbg;
-}
-#endif
-
QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp
index 7e4efc0e77..14e0abf7c7 100644
--- a/src/widgets/kernel/qopenglwidget.cpp
+++ b/src/widgets/kernel/qopenglwidget.cpp
@@ -104,6 +104,12 @@ QT_BEGIN_NAMESPACE
non-sharable. To overcome this issue, prefer using
QSurfaceFormat::setDefaultFormat() instead of setFormat().
+ \note Calling QSurfaceFormat::setDefaultFormat() before constructing
+ the QApplication instance is mandatory on some platforms (for example,
+ OS X) when an OpenGL core profile context is requested. This is to
+ ensure that resource sharing between contexts stays functional as all
+ internal contexts are created using the correct version and profile.
+
\section1 Painting Techniques
As described above, subclass QOpenGLWidget to render pure 3D content in the
@@ -739,6 +745,7 @@ void QOpenGLWidgetPrivate::initialize()
QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext);
ctx->setShareContext(shareContext);
ctx->setFormat(requestedFormat);
+ ctx->setScreen(shareContext->screen());
if (!ctx->create()) {
qWarning("QOpenGLWidget: Failed to create context");
return;
@@ -762,6 +769,7 @@ void QOpenGLWidgetPrivate::initialize()
// in QQuickWidget, use a dedicated QOffscreenSurface.
surface = new QOffscreenSurface;
surface->setFormat(ctx->format());
+ surface->setScreen(ctx->screen());
surface->create();
if (!ctx->makeCurrent(surface)) {
diff --git a/src/widgets/kernel/qsizepolicy.qdoc b/src/widgets/kernel/qsizepolicy.cpp
index e84412bc46..1476b4c5d7 100644
--- a/src/widgets/kernel/qsizepolicy.qdoc
+++ b/src/widgets/kernel/qsizepolicy.cpp
@@ -3,9 +3,9 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the documentation of the Qt Toolkit.
+** This file is part of the QtWidgets module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:FDL$
+** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -14,17 +14,31 @@
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: http://www.gnu.org/copyleft/fdl.html.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
** $QT_END_LICENSE$
**
****************************************************************************/
+#include "qsizepolicy.h"
+
+#include <qdatastream.h>
+#include <qdebug.h>
+#include <qvariant.h>
+
+QT_BEGIN_NAMESPACE
+
/*!
\class QSizePolicy
\brief The QSizePolicy class is a layout attribute describing horizontal
@@ -207,15 +221,18 @@
*/
/*!
- \fn ControlType QSizePolicy::controlType() const
\since 4.3
Returns the control type associated with the widget for which
this size policy applies.
*/
+QSizePolicy::ControlType QSizePolicy::controlType() const
+{
+ return QSizePolicy::ControlType(1 << bits.ctype);
+}
+
/*!
- \fn void QSizePolicy::setControlType(ControlType type)
\since 4.3
Sets the control type associated with the widget for which this
@@ -230,6 +247,31 @@
\sa QStyle::layoutSpacing()
*/
+void QSizePolicy::setControlType(ControlType type)
+{
+ /*
+ The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10,
+ etc. In memory, we pack it onto the available bits (CTSize) in
+ setControlType(), and unpack it here.
+
+ Example:
+
+ 0x00000001 maps to 0
+ 0x00000002 maps to 1
+ 0x00000004 maps to 2
+ 0x00000008 maps to 3
+ etc.
+ */
+
+ int i = 0;
+ while (true) {
+ if (type & (0x1 << i)) {
+ bits.ctype = i;
+ return;
+ }
+ ++i;
+ }
+}
/*!
\fn void QSizePolicy::setHeightForWidth(bool dependent)
@@ -344,7 +386,8 @@
\fn void QSizePolicy::retainSizeWhenHidden() const
\since 5.2
- Returns if the layout should retain the widgets size when it is hidden. This is by default false.
+ Returns whether the layout should retain the widget's size when it is hidden.
+ This is \c false by default.
\sa setRetainSizeWhenHidden()
*/
@@ -353,8 +396,8 @@
\fn void QSizePolicy::setRetainSizeWhenHidden(bool retainSize)
\since 5.2
- Set if a layout should retain the widgets size when it is hidden.
- If \a retainSize is true the layout will not be changed by hiding the widget.
+ Sets whether a layout should retain the widget's size when it is hidden.
+ If \a retainSize is \c true, the layout will not be changed by hiding the widget.
\sa retainSizeWhenHidden()
*/
@@ -385,3 +428,72 @@
\sa setControlType(), controlType()
*/
+/*!
+ Returns a QVariant storing this QSizePolicy.
+*/
+QSizePolicy::operator QVariant() const
+{
+ return QVariant(QVariant::SizePolicy, this);
+}
+
+#ifndef QT_NO_DATASTREAM
+
+/*!
+ \relates QSizePolicy
+ \since 4.2
+
+ Writes the size \a policy to the data stream \a stream.
+
+ \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
+*/
+QDataStream &operator<<(QDataStream &stream, const QSizePolicy &policy)
+{
+ // The order here is for historical reasons. (compatibility with Qt4)
+ quint32 data = (policy.bits.horPolicy | // [0, 3]
+ policy.bits.verPolicy << 4 | // [4, 7]
+ policy.bits.hfw << 8 | // [8]
+ policy.bits.ctype << 9 | // [9, 13]
+ policy.bits.wfh << 14 | // [14]
+ policy.bits.retainSizeWhenHidden << 15 | // [15]
+ policy.bits.verStretch << 16 | // [16, 23]
+ policy.bits.horStretch << 24); // [24, 31]
+ return stream << data;
+}
+
+#define VALUE_OF_BITS(data, bitstart, bitcount) ((data >> bitstart) & ((1 << bitcount) -1))
+
+/*!
+ \relates QSizePolicy
+ \since 4.2
+
+ Reads the size \a policy from the data stream \a stream.
+
+ \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
+*/
+QDataStream &operator>>(QDataStream &stream, QSizePolicy &policy)
+{
+ quint32 data;
+ stream >> data;
+ policy.bits.horPolicy = VALUE_OF_BITS(data, 0, 4);
+ policy.bits.verPolicy = VALUE_OF_BITS(data, 4, 4);
+ policy.bits.hfw = VALUE_OF_BITS(data, 8, 1);
+ policy.bits.ctype = VALUE_OF_BITS(data, 9, 5);
+ policy.bits.wfh = VALUE_OF_BITS(data, 14, 1);
+ policy.bits.retainSizeWhenHidden = VALUE_OF_BITS(data, 15, 1);
+ policy.bits.verStretch = VALUE_OF_BITS(data, 16, 8);
+ policy.bits.horStretch = VALUE_OF_BITS(data, 24, 8);
+ return stream;
+}
+#endif // QT_NO_DATASTREAM
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QSizePolicy &p)
+{
+ QDebugStateSaver saver(dbg);
+ dbg.nospace() << "QSizePolicy(horizontalPolicy = " << p.horizontalPolicy()
+ << ", verticalPolicy = " << p.verticalPolicy() << ')';
+ return dbg;
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h
index 2376a2c644..6cd511f513 100644
--- a/src/widgets/kernel/qsizepolicy.h
+++ b/src/widgets/kernel/qsizepolicy.h
@@ -112,7 +112,7 @@ public:
bool operator==(const QSizePolicy& s) const { return data == s.data; }
bool operator!=(const QSizePolicy& s) const { return data != s.data; }
- operator QVariant() const; // implemented in qlayoutitem.cpp
+ operator QVariant() const;
int horizontalStretch() const { return static_cast<int>(bits.horStretch); }
int verticalStretch() const { return static_cast<int>(bits.verStretch); }
@@ -155,7 +155,6 @@ Q_DECLARE_TYPEINFO(QSizePolicy, Q_PRIMITIVE_TYPE);
Q_DECLARE_OPERATORS_FOR_FLAGS(QSizePolicy::ControlTypes)
#ifndef QT_NO_DATASTREAM
-// implemented in qlayout.cpp
Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &, const QSizePolicy &);
Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &);
#endif
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index f05094dd01..6e7479d29a 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -4860,7 +4860,7 @@ void QWidget::unsetLayoutDirection()
\fn QFontMetrics QWidget::fontMetrics() const
Returns the font metrics for the widget's current font.
- Equivalent to QFontMetrics(widget->font()).
+ Equivalent to \c QFontMetrics(widget->font()).
\sa font(), fontInfo(), setFont()
*/
@@ -4869,7 +4869,7 @@ void QWidget::unsetLayoutDirection()
\fn QFontInfo QWidget::fontInfo() const
Returns the font info for the widget's current font.
- Equivalent to QFontInto(widget->font()).
+ Equivalent to \c QFontInfo(widget->font()).
\sa font(), fontMetrics(), setFont()
*/
@@ -7335,6 +7335,8 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
stream >> restoredScreenWidth;
const QDesktopWidget * const desktop = QApplication::desktop();
+ if (restoredScreenNumber >= desktop->numScreens())
+ restoredScreenNumber = desktop->primaryScreen();
const qreal screenWidthF = qreal(desktop->screenGeometry(restoredScreenNumber).width());
// Sanity check bailing out when large variations of screen sizes occur due to
// high DPI scaling or different levels of DPI awareness.
@@ -7362,9 +7364,6 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
.expandedTo(d_func()->adjustedSize()));
}
- if (restoredScreenNumber >= desktop->numScreens())
- restoredScreenNumber = desktop->primaryScreen();
-
const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber);
// Modify the restored geometry if we are about to restore to coordinates
@@ -12092,6 +12091,7 @@ QOpenGLContext *QWidgetPrivate::shareContext() const
QOpenGLContext *ctx = new QOpenGLContext;
ctx->setShareContext(qt_gl_global_share_context());
ctx->setFormat(extra->topextra->window->format());
+ ctx->setScreen(extra->topextra->window->screen());
ctx->create();
that->extra->topextra->shareContext = ctx;
}
diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp
index 485cf82078..d1070839fa 100644
--- a/src/widgets/kernel/qwidgetbackingstore.cpp
+++ b/src/widgets/kernel/qwidgetbackingstore.cpp
@@ -962,7 +962,8 @@ static void findTextureWidgetsRecursively(QWidget *tlw, QWidget *widget, QPlatfo
QPlatformTextureList::Flags flags = 0;
if (widget->testAttribute(Qt::WA_AlwaysStackOnTop))
flags |= QPlatformTextureList::StacksOnTop;
- widgetTextures->appendTexture(widget, wd->textureId(), QRect(widget->mapTo(tlw, QPoint()), widget->size()), flags);
+ const QRect rect(widget->mapTo(tlw, QPoint()), widget->size());
+ widgetTextures->appendTexture(widget, wd->textureId(), rect, wd->clipRect(), flags);
}
for (int i = 0; i < wd->children.size(); ++i) {
@@ -1156,7 +1157,7 @@ void QWidgetBackingStore::doSync()
#ifndef QT_NO_OPENGL
if (widgetTextures && widgetTextures->count()) {
for (int i = 0; i < widgetTextures->count(); ++i) {
- QWidget *w = widgetTextures->widget(i);
+ QWidget *w = static_cast<QWidget *>(widgetTextures->source(i));
if (dirtyRenderToTextureWidgets.contains(w)) {
const QRect rect = widgetTextures->geometry(i); // mapped to the tlw already
dirty += rect;
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index d8f89d279b..633e710853 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE
Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();
QWidget *qt_button_down = 0; // widget got last button-down
-static QPointer<QWidget> qt_tablet_target = 0;
// popup control
QWidget *qt_popup_down = 0; // popup that contains the pressed widget
@@ -447,8 +446,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (receiver != popup)
widgetPos = receiver->mapFromGlobal(event->globalPos());
QWidget *alien = m_widget->childAt(m_widget->mapFromGlobal(event->globalPos()));
- QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&e, QGuiApplicationPrivate::mouseEventSource(event));
+ QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(),
+ event->button(), event->buttons(), event->modifiers(), event->source());
e.setTimestamp(event->timestamp());
QApplicationPrivate::sendMouseEvent(receiver, &e, alien, m_widget, &qt_button_down, qt_last_mouse_receiver);
qt_last_mouse_receiver = receiver;
@@ -490,9 +489,9 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (globalGeometry.contains(event->globalPos())) {
// Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()
const QPoint localPos = win->mapFromGlobal(event->globalPos());
- QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
+ QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(),
+ event->button(), event->buttons(), event->modifiers(), event->source());
QCoreApplicationPrivate::setEventSpontaneous(e, true);
- QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event));
e->setTimestamp(event->timestamp());
QCoreApplication::postEvent(win, e);
}
@@ -549,8 +548,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
// The preceding statement excludes MouseButtonPress events which caused
// creation of a MouseButtonDblClick event. QTBUG-25831
QMouseEvent translated(event->type(), mapped, event->windowPos(), event->screenPos(),
- event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&translated, QGuiApplicationPrivate::mouseEventSource(event));
+ event->button(), event->buttons(), event->modifiers(), event->source());
translated.setTimestamp(event->timestamp());
QApplicationPrivate::sendMouseEvent(receiver, &translated, widget, m_widget,
&qt_button_down, qt_last_mouse_receiver);
@@ -875,6 +873,7 @@ bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long
#ifndef QT_NO_TABLETEVENT
void QWidgetWindow::handleTabletEvent(QTabletEvent *event)
{
+ static QPointer<QWidget> qt_tablet_target = 0;
if (event->type() == QEvent::TabletPress) {
QWidget *widget = m_widget->childAt(event->pos());
if (!widget)
diff --git a/src/widgets/styles/qcommonstylepixmaps_p.h b/src/widgets/styles/qcommonstylepixmaps_p.h
index 471903e927..8075256158 100644
--- a/src/widgets/styles/qcommonstylepixmaps_p.h
+++ b/src/widgets/styles/qcommonstylepixmaps_p.h
@@ -348,7 +348,7 @@ static const char * const qt_unshade_xpm[] = {
"..........",
".........."};
-static const char * dock_widget_close_xpm[] = {
+static const char * const dock_widget_close_xpm[] = {
"8 8 2 1",
"# c #000000",
". c None",
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 95a41b4830..518f985b13 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -93,18 +93,6 @@
QT_USE_NAMESPACE
-namespace {
-class AutoReleasePool
-{
-public:
- AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
- ~AutoReleasePool() { [pool release]; }
-
-private:
- NSAutoreleasePool *pool;
-};
-}
-
@interface QT_MANGLE_NAMESPACE(NotificationReceiver) : NSObject {
QMacStylePrivate *mPrivate;
}
@@ -1753,7 +1741,7 @@ QMacStylePrivate::QMacStylePrivate()
QMacStylePrivate::~QMacStylePrivate()
{
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
Q_FOREACH (NSView *b, cocoaControls)
[b release];
}
@@ -2135,7 +2123,7 @@ QMacStyle::QMacStyle()
: QCommonStyle(*new QMacStylePrivate)
{
Q_D(QMacStyle);
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
d->receiver = [[NotificationReceiver alloc] initWithPrivate:d];
NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
@@ -2152,7 +2140,7 @@ QMacStyle::QMacStyle()
QMacStyle::~QMacStyle()
{
Q_D(QMacStyle);
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
[reinterpret_cast<NSScroller*>(d->nsscroller) release];
@@ -2169,7 +2157,7 @@ QMacStyle::~QMacStyle()
*/
QPixmap QMacStylePrivate::generateBackgroundPattern() const
{
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
QPixmap px(4, 4);
QMacCGContext cg(&px);
HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal);
@@ -2767,7 +2755,7 @@ QPalette QMacStyle::standardPalette() const
int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,
QStyleHintReturn *hret) const
{
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
SInt32 ret = 0;
switch (sh) {
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index 862a4302f3..1849331b79 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -2368,8 +2368,8 @@ QDebug operator<<(QDebug debug, QStyle::State state)
return operator<< <QStyle::StateFlag>(debug, state);
# else
Q_UNUSED(state);
-# endif
return debug;
+# endif
}
# endif // !QT_NO_DEBUG_STREAM
#endif // QT_VERSION < QT_VERSION_CHECK(6,0,0)
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 86b5632d2e..40b8aaae9a 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -586,7 +586,7 @@ public:
};
///////////////////////////////////////////////////////////////////////////////////////////
-static const char *knownStyleHints[] = {
+static const char *const knownStyleHints[] = {
"activate-on-singleclick",
"alignment",
"arrow-keys-navigate-into-children",
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 40597a41f3..db8a649931 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -299,8 +299,8 @@ void QWindowsStyle::polish(QPalette &pal)
int QWindowsStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *, const QWidget *widget)
{
- switch (pm) {
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+ switch (pm) {
case QStyle::PM_DockWidgetFrameWidth:
# ifndef Q_OS_WINCE
return GetSystemMetrics(SM_CXFRAME);
@@ -337,13 +337,14 @@ int QWindowsStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, const
# else
return GetSystemMetrics(SM_CYDLGFRAME);
# endif
-#else
- Q_UNUSED(widget)
-#endif // Q_OS_WIN
default:
break;
}
+#else // Q_OS_WIN && !Q_OS_WINRT
+ Q_UNUSED(pm);
+ Q_UNUSED(widget);
+#endif
return QWindowsStylePrivate::InvalidMetric;
}
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index f715d93298..daa8ab12a9 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -250,8 +250,6 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
int state = option->state;
if (!QWindowsVistaStylePrivate::useVista()) {
- foreach (const QObject *target, d->animationTargets())
- d->stopAnimation(target);
QWindowsStyle::drawPrimitive(element, option, painter, widget);
return;
}
@@ -810,8 +808,6 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
if (!QWindowsVistaStylePrivate::useVista()) {
- foreach (const QObject *target, d->animationTargets())
- d->stopAnimation(target);
QWindowsStyle::drawControl(element, option, painter, widget);
return;
}
@@ -1494,8 +1490,6 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
{
QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
if (!QWindowsVistaStylePrivate::useVista()) {
- foreach (const QObject *target, d->animationTargets())
- d->stopAnimation(target);
QWindowsStyle::drawComplexControl(control, option, painter, widget);
return;
}
diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp
index 0e598717c8..8eadc42625 100644
--- a/src/widgets/util/qflickgesture.cpp
+++ b/src/widgets/util/qflickgesture.cpp
@@ -66,8 +66,8 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
case QEvent::MouseButtonRelease:
case QEvent::MouseMove: {
QMouseEvent *me = static_cast<QMouseEvent *>(e);
- QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(cme, me->source());
+ QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(),
+ me->button(), me->buttons(), me->modifiers(), me->source());
return cme;
}
#ifndef QT_NO_GRAPHICSVIEW
@@ -78,8 +78,8 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
#if 1
QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress :
(me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove);
- QMouseEvent *cme = new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(cme, me->source());
+ QMouseEvent *cme = new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(),
+ me->button(), me->buttons(), me->modifiers(), me->source());
return cme;
#else
QGraphicsSceneMouseEvent *copy = new QGraphicsSceneMouseEvent(me->type());
@@ -240,8 +240,7 @@ public:
qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway,
mouseButton, QApplication::mouseButtons() & ~mouseButton,
- QApplication::keyboardModifiers());
- QGuiApplicationPrivate::setMouseEventSource(&re, mouseEventSource);
+ QApplication::keyboardModifiers(), mouseEventSource);
sendMouseEvent(&re, RegrabMouseAfterwards);
// don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release!
}
@@ -291,8 +290,7 @@ protected:
if (me) {
QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()),
mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPos()), me->screenPos(),
- me->button(), me->buttons(), me->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&copy, me->source());
+ me->button(), me->buttons(), me->modifiers(), me->source());
qt_sendSpontaneousEvent(mouseTarget, &copy);
}
diff --git a/src/widgets/util/qscroller_mac.mm b/src/widgets/util/qscroller_mac.mm
index 9120c43075..07de07de52 100644
--- a/src/widgets/util/qscroller_mac.mm
+++ b/src/widgets/util/qscroller_mac.mm
@@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE
QPointF QScrollerPrivate::realDpi(int screen)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
NSArray *nsscreens = [NSScreen screens];
if (screen < 0 || screen >= int([nsscreens count]))
@@ -59,7 +59,6 @@ QPointF QScrollerPrivate::realDpi(int screen)
} else {
return QPointF();
}
- [pool release];
}
QT_END_NAMESPACE
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 2e1caedde7..5e45c66f3b 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -168,6 +168,10 @@ QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate()
{
}
+QAbstractScrollAreaPrivate::~QAbstractScrollAreaPrivate()
+{
+}
+
QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(Qt::Orientation orientation, QWidget *parent)
:QWidget(parent), scrollBar(new QScrollBar(orientation, this)),
layout(new QBoxLayout(orientation == Qt::Horizontal ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom)),
diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h
index f770bb69f8..33222573f4 100644
--- a/src/widgets/widgets/qabstractscrollarea_p.h
+++ b/src/widgets/widgets/qabstractscrollarea_p.h
@@ -54,12 +54,15 @@ QT_BEGIN_NAMESPACE
class QScrollBar;
class QAbstractScrollAreaScrollBarContainer;
+
+// ### Qt 6: is the export still needed? If not, unexport QFramePrivate, too.
class Q_WIDGETS_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate
{
Q_DECLARE_PUBLIC(QAbstractScrollArea)
public:
QAbstractScrollAreaPrivate();
+ ~QAbstractScrollAreaPrivate();
void replaceScrollBar(QScrollBar *scrollBar, Qt::Orientation orientation);
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 76f923904d..ef80e359df 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -3034,7 +3034,7 @@ void QComboBoxPrivate::showPopupFromMouseEvent(QMouseEvent *e)
QStyle::SubControl sc = q->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, e->pos(), q);
if (e->button() == Qt::LeftButton
- && sc != QStyle::SC_None
+ && !(sc == QStyle::SC_None && e->type() == QEvent::MouseButtonRelease)
&& (sc == QStyle::SC_ComboBoxArrow || !q->isEditable())
&& !viewContainer()->isVisible()) {
if (sc == QStyle::SC_ComboBoxArrow)
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index b1749fa5d3..a8da78a025 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -2316,9 +2316,9 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event)
QString QDateTimeEditPrivate::getAmPmText(AmPm ap, Case cs) const
{
if (ap == AmText) {
- return (cs == UpperCase ? QDateTimeEdit::tr("AM") : QDateTimeEdit::tr("am"));
+ return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
} else {
- return (cs == UpperCase ? QDateTimeEdit::tr("PM") : QDateTimeEdit::tr("pm"));
+ return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
}
}
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 237eb775b9..3e8c08f923 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -852,9 +852,19 @@ void QDialogButtonBoxPrivate::_q_handleButtonClicked()
{
Q_Q(QDialogButtonBox);
if (QAbstractButton *button = qobject_cast<QAbstractButton *>(q->sender())) {
+ // Can't fetch this *after* emitting clicked, as clicked may destroy the button
+ // or change its role. Now changing the role is not possible yet, but arguably
+ // both clicked and accepted/rejected/etc. should be emitted "atomically"
+ // depending on whatever role the button had at the time of the click.
+ const QDialogButtonBox::ButtonRole buttonRole = q->buttonRole(button);
+ QPointer<QDialogButtonBox> guard(q);
+
emit q->clicked(button);
- switch (q->buttonRole(button)) {
+ if (!guard)
+ return;
+
+ switch (buttonRole) {
case QPlatformDialogHelper::AcceptRole:
case QPlatformDialogHelper::YesRole:
emit q->accepted();
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index af0f2515fe..bc2259ce90 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -1854,20 +1855,6 @@ static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)
return Qt::NoDockWidgetArea;
}
-static QRect constrainedRect(QRect rect, const QRect &desktop)
-{
- if (desktop.isValid()) {
- rect.setWidth(qMin(rect.width(), desktop.width()));
- rect.setHeight(qMin(rect.height(), desktop.height()));
- rect.moveLeft(qMax(rect.left(), desktop.left()));
- rect.moveTop(qMax(rect.top(), desktop.top()));
- rect.moveRight(qMin(rect.right(), desktop.right()));
- rect.moveBottom(qMin(rect.bottom(), desktop.bottom()));
- }
-
- return rect;
-}
-
bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> &widgets, bool testing)
{
uchar marker;
@@ -1958,11 +1945,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
#endif
if (!testing) {
QRect r(x, y, w, h);
- QDesktopWidget *desktop = QApplication::desktop();
- if (desktop->isVirtualDesktop())
- r = constrainedRect(r, desktop->screenGeometry(desktop->screenNumber(r.topLeft())));
- else
- r = constrainedRect(r, desktop->screenGeometry(widget));
+ r = QDockAreaLayout::constrainedRect(r, widget);
widget->move(r.topLeft());
widget->resize(r.size());
}
@@ -2075,6 +2058,36 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const
#endif //QT_NO_TABBAR
#ifndef QT_NO_TABBAR
+/*! \internal
+ reparent all the widgets contained in this layout portion to the
+ specified parent. This is used to reparent dock widgets and tabbars
+ to the floating window or the main window
+ */
+void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent)
+{
+ if (tabBar)
+ tabBar->setParent(parent);
+
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.flags & QDockAreaLayoutItem::GapItem)
+ continue;
+ if (item.skip())
+ continue;
+ if (item.subinfo)
+ item.subinfo->reparentWidgets(parent);
+ if (item.widgetItem) {
+ QWidget *w = item.widgetItem->widget();
+ if (w->parent() != parent) {
+ bool hidden = w->isHidden();
+ w->setParent(parent);
+ if (!hidden)
+ w->show();
+ }
+ }
+ }
+}
+
//returns whether the tabbar is visible or not
bool QDockAreaLayoutInfo::updateTabBar() const
{
@@ -2981,6 +2994,33 @@ QSize QDockAreaLayout::minimumSize() const
return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3));
}
+/*! \internal
+ Try to fit the given rectangle \a rect on the screen which contains
+ the window \a widget.
+ Used to compute the geometry of a dragged a dock widget that should
+ be shown with \a rect, but needs to be visible on the screen
+ */
+QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget)
+{
+ QRect desktop;
+ QDesktopWidget *desktopW = QApplication::desktop();
+ if (desktopW->isVirtualDesktop())
+ desktop = desktopW->screenGeometry(rect.topLeft());
+ else
+ desktop = desktopW->screenGeometry(widget);
+
+ if (desktop.isValid()) {
+ rect.setWidth(qMin(rect.width(), desktop.width()));
+ rect.setHeight(qMin(rect.height(), desktop.height()));
+ rect.moveLeft(qMax(rect.left(), desktop.left()));
+ rect.moveTop(qMax(rect.top(), desktop.top()));
+ rect.moveRight(qMin(rect.right(), desktop.right()));
+ rect.moveBottom(qMin(rect.bottom(), desktop.bottom()));
+ }
+
+ return rect;
+}
+
bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
{
QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
@@ -2994,9 +3034,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
item.widgetItem = new QDockWidgetItem(dockWidget);
if (placeHolder->window) {
- const QRect screenGeometry =
- QApplication::desktop()->screenGeometry(placeHolder->topLevelRect.center());
- const QRect r = constrainedRect(placeHolder->topLevelRect, screenGeometry);
+ const QRect r = constrainedRect(placeHolder->topLevelRect, dockWidget);
dockWidget->d_func()->setWindowState(true, true, r);
}
dockWidget->setVisible(!placeHolder->hidden);
diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h
index 64fae7ebf6..93b005f64f 100644
--- a/src/widgets/widgets/qdockarealayout_p.h
+++ b/src/widgets/widgets/qdockarealayout_p.h
@@ -202,6 +202,7 @@ public:
QTabBar *tabBar;
int tabBarShape;
+ void reparentWidgets(QWidget *p);
bool updateTabBar() const;
void setTabBarShape(int shape);
QSize tabBarMinimumSize() const;
@@ -232,7 +233,8 @@ public:
bool isValid() const;
- enum { DockWidgetStateMarker = 0xfd };
+ enum { DockWidgetStateMarker = 0xfd, FloatingDockWidgetTabMarker = 0xf9 };
+ static QRect constrainedRect(QRect rect, QWidget *widget);
void saveState(QDataStream &stream) const;
bool restoreState(QDataStream &stream, const QList<QDockWidget*> &widgets, bool testing = false);
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 21b0904cc0..1b7473fbd7 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -65,6 +65,18 @@ extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); /
// qmainwindow.cpp
extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
+static inline QMainWindowLayout *qt_mainwindow_layout_from_dock(const QDockWidget *dock)
+{
+ const QWidget *p = dock->parentWidget();
+ while (p) {
+ const QMainWindow *window = qobject_cast<const QMainWindow*>(p);
+ if (window)
+ return qt_mainwindow_layout(window);
+ p = p->parentWidget();
+ }
+ return Q_NULLPTR;
+}
+
static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
{ return (priv->features & feature) == feature; }
@@ -194,25 +206,40 @@ QDockWidgetLayout::~QDockWidgetLayout()
qDeleteAll(item_list);
}
+/*! \internal
+ Returns true if the dock widget managed by this layout should have a native
+ window decoration or if Qt needs to draw it.
+ */
bool QDockWidgetLayout::nativeWindowDeco() const
{
- return nativeWindowDeco(parentWidget()->isWindow());
+ bool floating = parentWidget()->isWindow();
+ if (!floating && qobject_cast<QDockWidgetGroupWindow*>(parentWidget()->parentWidget()))
+ return wmSupportsNativeWindowDeco();
+ return nativeWindowDeco(floating);
}
-static bool isXcb()
+/*! \internal
+ Returns true if the window manager can draw natively the windows decoration
+ of a dock widget
+ */
+bool QDockWidgetLayout::wmSupportsNativeWindowDeco()
{
+#if defined(Q_OS_WINCE) || defined(Q_OS_ANDROID)
+ return false;
+#else
static const bool xcb = !QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive);
- return xcb;
+ return !xcb;
+#endif
}
+/*! \internal
+ Returns true if the dock widget managed by this layout should have a native
+ window decoration or if Qt needs to draw it. The \a floating parameter
+ overrides the floating current state of the dock widget.
+ */
bool QDockWidgetLayout::nativeWindowDeco(bool floating) const
{
-#if defined(Q_OS_WINCE) || defined(Q_OS_ANDROID)
- Q_UNUSED(floating)
- return false;
-#else
- return !isXcb() && (floating && item_list[QDockWidgetLayout::TitleBar] == 0);
-#endif
+ return wmSupportsNativeWindowDeco() && floating && item_list.at(QDockWidgetLayout::TitleBar) == 0;
}
@@ -611,7 +638,10 @@ void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const
return;
QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(layout());
- option->initFrom(this);
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent());
+ // If we are in a floating tab, init from the parent because the attributes and the geometry
+ // of the title bar should be taken from the floating window.
+ option->initFrom(floatingTab && !isFloating() ? parentWidget() : this);
option->rect = dwlayout->titleArea();
option->title = d->fixedWindowTitle;
option->closable = hasFeature(this, QDockWidget::DockWidgetClosable);
@@ -681,14 +711,20 @@ void QDockWidgetPrivate::_q_toggleTopLevel()
q->setFloating(!q->isFloating());
}
+/*! \internal
+ Initialize the drag state structure and remember the position of the click.
+ This is called when the mouse is pressed, but the dock is not yet dragged out.
+
+ \a nca specify that the event comes from NonClientAreaMouseButtonPress
+ */
void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
{
+ Q_Q(QDockWidget);
+
if (state != 0)
return;
- QMainWindow *win = qobject_cast<QMainWindow*>(parent);
- Q_ASSERT(win != 0);
- QMainWindowLayout *layout = qt_mainwindow_layout(win);
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(layout != 0);
if (layout->pluggingWidget != 0) // the main window is animating a docking operation
return;
@@ -702,17 +738,23 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
state->ctrlDrag = false;
}
-void QDockWidgetPrivate::startDrag()
+/*! \internal
+ Actually start the drag and detach the dockwidget.
+ The \a group parameter is true when we should potentially drag a group of
+ tabbed widgets, and false if the dock widget should always be dragged
+ alone.
+ */
+void QDockWidgetPrivate::startDrag(bool group)
{
Q_Q(QDockWidget);
if (state == 0 || state->dragging)
return;
- QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(layout != 0);
- state->widgetItem = layout->unplug(q);
+ state->widgetItem = layout->unplug(q, group);
if (state->widgetItem == 0) {
/* I have a QMainWindow parent, but I was never inserted with
QMainWindow::addDockWidget, so the QMainWindowLayout has no
@@ -728,6 +770,11 @@ void QDockWidgetPrivate::startDrag()
state->dragging = true;
}
+/*! \internal
+ Ends the drag end drop operation of the QDockWidget.
+ The \a abort parameter specifies that it ends because of programmatic state
+ reset rather than mouse release event.
+ */
void QDockWidgetPrivate::endDrag(bool abort)
{
Q_Q(QDockWidget);
@@ -736,29 +783,31 @@ void QDockWidgetPrivate::endDrag(bool abort)
q->releaseMouse();
if (state->dragging) {
- QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *mwLayout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(mwLayout != 0);
if (abort || !mwLayout->plug(state->widgetItem)) {
if (hasFeature(this, QDockWidget::DockWidgetFloatable)) {
+ // This QDockWidget will now stay in the floating state.
if (state->ownWidgetItem)
delete state->widgetItem;
mwLayout->restore();
- if (isXcb()) {
+ QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
+ if (!dwLayout->nativeWindowDeco()) {
// get rid of the X11BypassWindowManager window flag and activate the resizer
Qt::WindowFlags flags = q->windowFlags();
flags &= ~Qt::X11BypassWindowManagerHint;
q->setWindowFlags(flags);
- setResizerActive(true);
+ setResizerActive(q->isFloating());
q->show();
} else {
- QDockWidgetLayout *myLayout
- = qobject_cast<QDockWidgetLayout*>(layout);
- setResizerActive(myLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0);
+ setResizerActive(false);
}
undockedGeometry = q->geometry();
q->activateWindow();
} else {
+ // The tab was not plugged back in the QMainWindow but the QDockWidget cannot
+ // stay floating, revert to the previous state.
mwLayout->revert(state->widgetItem);
}
}
@@ -782,11 +831,7 @@ bool QDockWidgetPrivate::isAnimating() const
{
Q_Q(const QDockWidget);
- QMainWindow *mainWin = qobject_cast<QMainWindow*>(parent);
- if (mainWin == 0)
- return false;
-
- QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin);
+ QMainWindowLayout *mainWinLayout = qt_mainwindow_layout_from_dock(q);
if (mainWinLayout == 0)
return false;
@@ -804,12 +849,14 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
if (!dwLayout->nativeWindowDeco()) {
QRect titleArea = dwLayout->titleArea();
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent);
+
if (event->button() != Qt::LeftButton ||
!titleArea.contains(event->pos()) ||
// check if the tool window is movable... do nothing if it
// is not (but allow moving if the window is floating)
(!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
- qobject_cast<QMainWindow*>(parent) == 0 ||
+ (qobject_cast<QMainWindow*>(parent) == 0 && !floatingTab) ||
isAnimating() || state != 0) {
return false;
}
@@ -853,7 +900,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
QDockWidgetLayout *dwlayout
= qobject_cast<QDockWidgetLayout *>(layout);
- QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
if (!dwlayout->nativeWindowDeco()) {
if (!state->dragging
&& mwlayout->pluggingWidget == 0
@@ -871,7 +918,12 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
if (state->dragging && !state->nca) {
QPoint pos = event->globalPos() - state->pressPos;
- q->move(pos);
+
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent);
+ if (floatingTab && !q->isFloating())
+ floatingTab->move(pos);
+ else
+ q->move(pos);
if (state && !state->ctrlDrag)
mwlayout->hover(state->widgetItem, event->globalPos());
@@ -902,8 +954,9 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
- QRect geo = q->geometry();
- QRect titleRect = q->frameGeometry();
+ QWidget *tl = q->topLevelWidget();
+ QRect geo = tl->geometry();
+ QRect titleRect = tl->frameGeometry();
#ifdef Q_DEAD_CODE_FROM_QT4_MAC
if ((features & QDockWidget::DockWidgetVerticalTitleBar)) {
titleRect.setTop(geo.top());
@@ -924,7 +977,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
break;
if (state != 0)
break;
- if (qobject_cast<QMainWindow*>(parent) == 0)
+ if (qobject_cast<QMainWindow*>(parent) == 0 && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
break;
if (isAnimating())
break;
@@ -958,11 +1011,17 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
}
}
+/*! \internal
+ Called when the QDockWidget or the QDockWidgetGroupWindow is moved
+ */
void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
{
Q_Q(QDockWidget);
- if (state == 0 || !state->dragging || !state->nca || !q->isWindow())
+ if (state == 0 || !state->dragging || !state->nca)
+ return;
+
+ if (!q->isWindow() && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
return;
// When the native window frame is being dragged, all we get is these mouse
@@ -971,7 +1030,7 @@ void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
if (state->ctrlDrag)
return;
- QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(layout != 0);
QPoint globalMousePos = event->pos() + state->pressPos;
@@ -999,8 +1058,9 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
Q_Q(QDockWidget);
if (!floating && parent) {
- QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
- if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
+ QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
+ if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea
+ && !qobject_cast<QDockWidgetGroupWindow *>(parent))
return; // this dockwidget can't be redocked
}
@@ -1048,7 +1108,7 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
if (floating != wasFloating) {
emit q->topLevelChanged(floating);
if (!floating && parent) {
- QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
if (mwlayout)
emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
}
@@ -1230,8 +1290,11 @@ void QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features)
emit featuresChanged(d->features);
update();
if (closableChanged && layout->nativeWindowDeco()) {
- //this ensures the native decoration is drawn
- d->setWindowState(true /*floating*/, true /*unplug*/);
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow *>(parent());
+ if (floatingTab && !isFloating())
+ floatingTab->adjustFlags();
+ else
+ d->setWindowState(true /*floating*/, true /*unplug*/); //this ensures the native decoration is drawn
}
}
@@ -1323,11 +1386,12 @@ void QDockWidget::changeEvent(QEvent *event)
#endif
#ifndef QT_NO_TABBAR
{
- QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
- if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) {
+ if (QMainWindowLayout *winLayout = qt_mainwindow_layout_from_dock(this)) {
if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this))
info->updateTabBar();
}
+ if (QDockWidgetGroupWindow *p = qobject_cast<QDockWidgetGroupWindow *>(parent()))
+ p->adjustFlags();
}
#endif // QT_NO_TABBAR
break;
@@ -1380,7 +1444,7 @@ bool QDockWidget::event(QEvent *event)
Q_D(QDockWidget);
QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
- QMainWindowLayout *layout = qt_mainwindow_layout(win);
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(this);
switch (event->type()) {
#ifndef QT_NO_ACTION
@@ -1417,6 +1481,9 @@ bool QDockWidget::event(QEvent *event)
}
if (!isFloating() && layout != 0 && onTop)
layout->raise(this);
+ if (QDockWidgetGroupWindow *p = qobject_cast<QDockWidgetGroupWindow *>(parent()))
+ p->adjustFlags();
+
break;
}
case QEvent::WindowActivate:
diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h
index 752d6519e5..9c68bc5fb1 100644
--- a/src/widgets/widgets/qdockwidget_p.h
+++ b/src/widgets/widgets/qdockwidget_p.h
@@ -108,7 +108,7 @@ public:
void setWindowState(bool floating, bool unplug = false, const QRect &rect = QRect());
void nonClientAreaMouseEvent(QMouseEvent *event);
void initDrag(const QPoint &pos, bool nca);
- void startDrag();
+ void startDrag(bool group = true);
void endDrag(bool abort = false);
void moveEvent(QMoveEvent *event);
@@ -151,6 +151,7 @@ public:
int minimumTitleWidth() const;
int titleHeight() const;
void updateMaxSize();
+ static bool wmSupportsNativeWindowDeco();
bool nativeWindowDeco() const;
bool nativeWindowDeco(bool floating) const;
diff --git a/src/widgets/widgets/qframe.cpp b/src/widgets/widgets/qframe.cpp
index 0861ea70b5..755b03a4ca 100644
--- a/src/widgets/widgets/qframe.cpp
+++ b/src/widgets/widgets/qframe.cpp
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
QFramePrivate::QFramePrivate()
- : frect(QRect(0, 0, 0, 0)),
+ : frect(0, 0, 0, 0),
frameStyle(QFrame::NoFrame | QFrame::Plain),
lineWidth(1),
midLineWidth(0),
@@ -55,6 +55,10 @@ QFramePrivate::QFramePrivate()
{
}
+QFramePrivate::~QFramePrivate()
+{
+}
+
inline void QFramePrivate::init()
{
setLayoutItemMargins(QStyle::SE_FrameLayoutItem);
diff --git a/src/widgets/widgets/qframe_p.h b/src/widgets/widgets/qframe_p.h
index 2b80e9abbe..eb04bbed4a 100644
--- a/src/widgets/widgets/qframe_p.h
+++ b/src/widgets/widgets/qframe_p.h
@@ -50,11 +50,13 @@
QT_BEGIN_NAMESPACE
-class QFramePrivate : public QWidgetPrivate
+// ### unexport this class when and if QAbstractScrollAreaPrivate is unexported
+class Q_WIDGETS_EXPORT QFramePrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QFrame)
public:
QFramePrivate();
+ ~QFramePrivate();
void updateFrameWidth();
void updateStyledFrameWidths();
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index fa1a5acb5f..c70bc4baef 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -53,6 +53,10 @@
QT_BEGIN_NAMESPACE
+QLabelPrivate::~QLabelPrivate()
+{
+}
+
/*!
\class QLabel
\brief The QLabel widget provides a text or image display.
diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h
index 3778cb9d47..2eb4ff9fc6 100644
--- a/src/widgets/widgets/qlabel_p.h
+++ b/src/widgets/widgets/qlabel_p.h
@@ -65,6 +65,7 @@ class QLabelPrivate : public QFramePrivate
Q_DECLARE_PUBLIC(QLabel)
public:
QLabelPrivate() {}
+ ~QLabelPrivate();
void init();
void clearContents();
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index 6a41c3791f..ad3a92d35a 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -440,6 +440,10 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE
Q_Q(QLineEdit);
if (!newAction)
return 0;
+ if (!hasSideWidgets()) { // initial setup.
+ QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString)));
+ lastTextSize = q->text().size();
+ }
QWidget *w = 0;
// Store flags about QWidgetAction here since removeAction() may be called from ~QAction,
// in which a qobject_cast<> no longer works.
@@ -456,10 +460,6 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE
toolButton->setDefaultAction(newAction);
w = toolButton;
}
- if (!hasSideWidgets()) { // initial setup.
- QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString)));
- lastTextSize = q->text().size();
- }
// If there is a 'before' action, it takes preference
PositionIndexPair positionIndex = before ? findSideWidget(before) : PositionIndexPair(position, -1);
SideWidgetEntryList &list = positionIndex.first == QLineEdit::TrailingPosition ? trailingSideWidgets : leadingSideWidgets;
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index 1ede07e4cb..4654262ea7 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
// QLineEditIconButton: This is a simple helper class that represents clickable icons that fade in with text
-class QLineEditIconButton : public QToolButton
+class Q_AUTOTEST_EXPORT QLineEditIconButton : public QToolButton
{
Q_OBJECT
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
diff --git a/src/widgets/widgets/qmacnativewidget_mac.h b/src/widgets/widgets/qmacnativewidget_mac.h
index b27d877e8f..761e55656b 100644
--- a/src/widgets/widgets/qmacnativewidget_mac.h
+++ b/src/widgets/widgets/qmacnativewidget_mac.h
@@ -52,7 +52,6 @@ public:
NSView *nativeView() const;
protected:
- void init(NSView *parentView);
bool event(QEvent *ev);
private:
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 2a1e8428ab..f365ff7d17 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -420,6 +420,13 @@ QMainWindow::~QMainWindow()
at the bottom. Implies AllowTabbedDocks. See also
\l setTabPosition().
+ \value GroupedDragging When dragging the titlebar of a dock, all the tabs
+ that are tabbed with it are going to be dragged.
+ Implies AllowTabbedDocks. Does not work well if
+ some QDockWidgets have restrictions in which area
+ they are allowed. (This enum value was added in Qt
+ 5.6.)
+
These options only control how dock widgets may be dropped in a QMainWindow.
They do not re-arrange the dock widgets to conform with the specified
options. For this reason they should be set before any dock widgets
@@ -1080,7 +1087,7 @@ void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget
addDockWidget(area, dockwidget, orientation);
#ifdef Q_DEAD_CODE_FROM_QT4_MAC //drawer support
- QMacCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
if (qt_mac_is_macdrawer(dockwidget)) {
extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp
diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h
index cbbea74b9b..0bd70c87a6 100644
--- a/src/widgets/widgets/qmainwindow.h
+++ b/src/widgets/widgets/qmainwindow.h
@@ -77,7 +77,8 @@ public:
AllowNestedDocks = 0x02,
AllowTabbedDocks = 0x04,
ForceTabbedDocks = 0x08, // implies AllowTabbedDocks, !AllowNestedDocks
- VerticalTabs = 0x10 // implies AllowTabbedDocks
+ VerticalTabs = 0x10, // implies AllowTabbedDocks
+ GroupedDragging = 0x20 // implies AllowTabbedDocks
};
Q_ENUM(DockOption)
Q_DECLARE_FLAGS(DockOptions, DockOption)
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 3620aa04fc..ee76720a27 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -49,6 +50,7 @@
#include <qstatusbar.h>
#include <qstring.h>
#include <qstyle.h>
+#include <qstylepainter.h>
#include <qvarlengtharray.h>
#include <qstack.h>
#include <qmap.h>
@@ -61,6 +63,7 @@
#include <private/qapplication_p.h>
#include <private/qlayoutengine_p.h>
+#include <private/qwidgetresizehandler_p.h>
#ifdef Q_DEAD_CODE_FROM_QT4_MAC
# include <private/qcore_mac_p.h>
# include <private/qt_cocoa_helpers_mac_p.h>
@@ -68,9 +71,7 @@
QT_BEGIN_NAMESPACE
-#ifdef QT_NO_DOCKWIDGET
extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
-#endif
/******************************************************************************
** debug
@@ -165,6 +166,242 @@ QDebug operator<<(QDebug debug, const QMainWindowLayout *layout)
#endif // !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_DEBUG)
/******************************************************************************
+ ** QDockWidgetGroupWindow
+ */
+// QDockWidgetGroupWindow is the floating window containing the tabbed dockwidgets in case several
+// dockwidgets are dragged together (QMainWindow::GroupedDragging feature).
+// QDockWidgetGroupLayout is the layout of that window and use a QDockAreaLayoutInfo to layout
+// the tabs inside it.
+#ifndef QT_NO_DOCKWIDGET
+class QDockWidgetGroupLayout : public QLayout {
+ QDockAreaLayoutInfo info;
+ QWidgetResizeHandler *resizer;
+public:
+ QDockWidgetGroupLayout(QWidget* parent) : QLayout(parent) {
+ setSizeConstraint(QLayout::SetMinAndMaxSize);
+ resizer = new QWidgetResizeHandler(parent);
+ resizer->setMovingEnabled(false);
+ }
+ ~QDockWidgetGroupLayout() {
+ info.deleteAllLayoutItems();
+ }
+
+ void addItem(QLayoutItem*) Q_DECL_OVERRIDE { Q_UNREACHABLE(); }
+ int count() const Q_DECL_OVERRIDE { return 0; }
+ QLayoutItem* itemAt(int index) const Q_DECL_OVERRIDE
+ {
+ int x = 0;
+ return info.itemAt(&x, index);
+ }
+ QLayoutItem* takeAt(int index) Q_DECL_OVERRIDE
+ {
+ int x = 0;
+ return info.takeAt(&x, index);
+ }
+ QSize sizeHint() const Q_DECL_OVERRIDE
+ {
+ int fw = frameWidth();
+ return info.sizeHint() + QSize(fw, fw);
+ }
+ QSize minimumSize() const Q_DECL_OVERRIDE
+ {
+ int fw = frameWidth();
+ return info.minimumSize() + QSize(fw, fw);
+ }
+ QSize maximumSize() const Q_DECL_OVERRIDE
+ {
+ int fw = frameWidth();
+ return info.maximumSize() + QSize(fw, fw);
+ }
+ void setGeometry(const QRect&r) Q_DECL_OVERRIDE
+ {
+ QDockAreaLayoutInfo *li = layoutInfo();
+ if (li->isEmpty()) {
+ static_cast<QDockWidgetGroupWindow *>(parent())->destroyIfEmpty();
+ return;
+ }
+ int fw = frameWidth();
+ li->reparentWidgets(parentWidget());
+ li->rect = r.adjusted(fw, fw, -fw, -fw);
+ li->fitItems();
+ li->apply(false);
+ resizer->setActive(QWidgetResizeHandler::Resize, !nativeWindowDeco());
+ }
+
+ QDockAreaLayoutInfo *layoutInfo() {
+ return &info;
+ }
+
+ bool nativeWindowDeco() const
+ {
+ return QDockWidgetLayout::wmSupportsNativeWindowDeco();
+ }
+
+ int frameWidth() const
+ {
+ return nativeWindowDeco() ? 0 :
+ parentWidget()->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, parentWidget());
+ }
+};
+
+// This item will be used in the layout for the gap item. We cannot use QWidgetItem directly
+// because QWidgetItem functions return an empty size for widgets are are floating.
+class QDockWidgetGroupWindowItem : public QWidgetItem
+{
+public:
+ QDockWidgetGroupWindowItem(QDockWidgetGroupWindow *parent) : QWidgetItem(parent) {}
+ QSize minimumSize() const Q_DECL_OVERRIDE { return lay()->minimumSize(); }
+ QSize maximumSize() const Q_DECL_OVERRIDE { return lay()->maximumSize(); }
+ QSize sizeHint() const Q_DECL_OVERRIDE { return lay()->sizeHint(); }
+
+private:
+ QLayout *lay() const { return const_cast<QDockWidgetGroupWindowItem *>(this)->widget()->layout(); }
+};
+
+bool QDockWidgetGroupWindow::event(QEvent *e)
+{
+ switch (e->type()) {
+ case QEvent::Close:
+ // Forward the close to the QDockWidget just as if its close button was pressed
+ if (QDockWidget *dw = topDockWidget()) {
+ e->ignore();
+ dw->close();
+ adjustFlags();
+ }
+ return true;
+ case QEvent::Move:
+ // Let QDockWidgetPrivate::moseEvent handle the dragging
+ if (QDockWidget *dw = topDockWidget())
+ static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->moveEvent(static_cast<QMoveEvent*>(e));
+ return true;
+ case QEvent::NonClientAreaMouseMove:
+ case QEvent::NonClientAreaMouseButtonPress:
+ case QEvent::NonClientAreaMouseButtonRelease:
+ case QEvent::NonClientAreaMouseButtonDblClick:
+ // Let the QDockWidgetPrivate of the currently visible dock widget handle the drag and drop
+ if (QDockWidget *dw = topDockWidget())
+ static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(e));
+ return true;
+ case QEvent::ChildAdded:
+ if (qobject_cast<QDockWidget *>(static_cast<QChildEvent*>(e)->child()))
+ adjustFlags();
+ break;
+ default:
+ break;
+ }
+ return QWidget::event(e);
+}
+
+void QDockWidgetGroupWindow::paintEvent(QPaintEvent *)
+{
+ QDockWidgetGroupLayout *lay = static_cast<QDockWidgetGroupLayout *>(layout());
+ bool nativeDeco = lay->nativeWindowDeco();
+
+ if (!nativeDeco) {
+ QStyleOptionFrame framOpt;
+ framOpt.init(this);
+ QStylePainter p(this);
+ p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);
+ }
+}
+
+QDockAreaLayoutInfo *QDockWidgetGroupWindow::layoutInfo() const
+{
+ return static_cast<QDockWidgetGroupLayout*>(layout())->layoutInfo();
+}
+
+/*! \internal
+ Returns the currently active QDockWidget.
+ */
+QDockWidget *QDockWidgetGroupWindow::topDockWidget() const
+{
+ QDockAreaLayoutInfo *info = layoutInfo();
+ QDockWidget *dw = 0;
+ if (info->tabBar && info->tabBar->currentIndex() >= 0) {
+ int i = info->tabIndexToListIndex(info->tabBar->currentIndex());
+ if (i >= 0) {
+ const QDockAreaLayoutItem &item = info->item_list.at(i);
+ if (item.widgetItem)
+ dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());
+ }
+ }
+ if (!dw) {
+ for (int i = 0; !dw && i < info->item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = info->item_list.at(i);
+ if (item.skip())
+ continue;
+ if (!item.widgetItem)
+ continue;
+ dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());
+ }
+ }
+ return dw;
+}
+
+/*! \internal
+ Destroy this window if there is no more QDockWidget in it.
+ */
+void QDockWidgetGroupWindow::destroyIfEmpty()
+{
+ if (layoutInfo()->isEmpty()) {
+ // Make sure to reparent the possibly floating or hidden QDockWidgets to the parent
+ foreach (QDockWidget *dw,
+ findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly)) {
+ bool wasFloating = dw->isFloating();
+ bool wasHidden = dw->isHidden();
+ dw->setParent(parentWidget());
+ if (wasFloating) {
+ dw->setFloating(true);
+ } else {
+ // maybe it was hidden, we still have to put it back in the main layout.
+ QMainWindowLayout *ml = qt_mainwindow_layout(static_cast<QMainWindow*>(parentWidget()));
+ Qt::DockWidgetArea area = ml->dockWidgetArea(this);
+ if (area == Qt::NoDockWidgetArea)
+ area = Qt::LeftDockWidgetArea;
+ static_cast<QMainWindow*>(parentWidget())->addDockWidget(area, dw);
+ }
+ if (!wasHidden)
+ dw->show();
+ }
+ foreach (QTabBar *tb, findChildren<QTabBar *>(QString(), Qt::FindDirectChildrenOnly))
+ tb->setParent(parentWidget());
+ deleteLater();
+ }
+}
+
+/*! \internal
+ Sets the flags of this window in accordence to the capabilities of the dock widgets
+ */
+void QDockWidgetGroupWindow::adjustFlags()
+{
+ QDockWidget *top = topDockWidget();
+ if (!top)
+ return;
+ const bool nativeDeco = static_cast<QDockWidgetGroupLayout *>(layout())->nativeWindowDeco();
+
+ Qt::WindowFlags oldFlags = windowFlags();
+ Qt::WindowFlags flags = oldFlags;
+ if (nativeDeco) {
+ flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
+ if (top->features() & QDockWidget::DockWidgetClosable)
+ flags |= Qt::WindowCloseButtonHint;
+ else
+ flags &= ~Qt::WindowCloseButtonHint;
+ flags &= ~Qt::FramelessWindowHint;
+ } else {
+ flags |= Qt::FramelessWindowHint;
+ }
+ if (oldFlags != flags) {
+ setWindowFlags(flags);
+ show(); // setWindowFlags hides the window
+ }
+
+ setWindowTitle(top->windowTitle());
+ setWindowIcon(top->windowIcon());
+}
+#endif
+
+/******************************************************************************
** QMainWindowLayoutState
*/
@@ -335,8 +572,8 @@ QList<int> QMainWindowLayoutState::indexOf(QWidget *widget) const
#ifndef QT_NO_DOCKWIDGET
// is it a dock widget?
- if (QDockWidget *dockWidget = qobject_cast<QDockWidget *>(widget)) {
- result = dockAreaLayout.indexOf(dockWidget);
+ if (qobject_cast<QDockWidget *>(widget) || qobject_cast<QDockWidgetGroupWindow *>(widget)) {
+ result = dockAreaLayout.indexOf(widget);
if (!result.isEmpty())
result.prepend(1);
return result;
@@ -413,7 +650,8 @@ QList<int> QMainWindowLayoutState::gapIndex(QWidget *widget,
#ifndef QT_NO_DOCKWIDGET
// is it a dock widget?
- if (qobject_cast<QDockWidget *>(widget) != 0) {
+ if (qobject_cast<QDockWidget *>(widget) != 0
+ || qobject_cast<QDockWidgetGroupWindow *>(widget)) {
result = dockAreaLayout.gapIndex(pos);
if (!result.isEmpty())
result.prepend(1);
@@ -440,7 +678,7 @@ bool QMainWindowLayoutState::insertGap(const QList<int> &path, QLayoutItem *item
#ifndef QT_NO_DOCKWIDGET
if (i == 1) {
- Q_ASSERT(qobject_cast<QDockWidget*>(item->widget()) != 0);
+ Q_ASSERT(qobject_cast<QDockWidget*>(item->widget()) || qobject_cast<QDockWidgetGroupWindow*>(item->widget()));
return dockAreaLayout.insertGap(path.mid(1), item);
}
#endif //QT_NO_DOCKWIDGET
@@ -593,6 +831,17 @@ void QMainWindowLayoutState::saveState(QDataStream &stream) const
{
#ifndef QT_NO_DOCKWIDGET
dockAreaLayout.saveState(stream);
+#ifndef QT_NO_TABBAR
+ QList<QDockWidgetGroupWindow *> floatingTabs =
+ mainWindow->findChildren<QDockWidgetGroupWindow *>(QString(), Qt::FindDirectChildrenOnly);
+
+ foreach (QDockWidgetGroupWindow *floating, floatingTabs) {
+ if (floating->layoutInfo()->isEmpty())
+ continue;
+ stream << uchar(QDockAreaLayout::FloatingDockWidgetTabMarker) << floating->geometry();
+ floating->layoutInfo()->saveState(stream);
+ }
+#endif
#endif
#ifndef QT_NO_TOOLBAR
toolBarAreaLayout.saveState(stream);
@@ -638,12 +887,28 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream)
case QDockAreaLayout::DockWidgetStateMarker:
{
QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
if (!dockAreaLayout.restoreState(stream, dockWidgets, true /*testing*/)) {
return false;
}
}
break;
-#endif
+#ifndef QT_NO_TABBAR
+ case QDockAreaLayout::FloatingDockWidgetTabMarker:
+ {
+ QRect geom;
+ stream >> geom;
+ QDockAreaLayoutInfo info;
+ QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
+ if (!info.restoreState(stream, dockWidgets, true /* testing*/))
+ return false;
+ }
+ break;
+#endif // QT_NO_TABBAR
+#endif // QT_NO_DOCKWIDGET
default:
//there was an error during the parsing
return false;
@@ -682,6 +947,8 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
case QDockAreaLayout::DockWidgetStateMarker:
{
QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
if (!dockAreaLayout.restoreState(stream, dockWidgets))
return false;
@@ -702,6 +969,26 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
}
}
break;
+#ifndef QT_NO_TABBAR
+ case QDockAreaLayout::FloatingDockWidgetTabMarker:
+ {
+ QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
+ QDockWidgetGroupWindow* floatingTab = qt_mainwindow_layout(mainWindow)->createTabbedDockWindow();
+ *floatingTab->layoutInfo() = QDockAreaLayoutInfo(&dockAreaLayout.sep, QInternal::LeftDock,
+ Qt::Horizontal, QTabBar::RoundedSouth, mainWindow);
+ QRect geometry;
+ stream >> geometry;
+ if (!floatingTab->layoutInfo()->restoreState(stream, dockWidgets, false))
+ return false;
+ geometry = QDockAreaLayout::constrainedRect(geometry, floatingTab);
+ floatingTab->move(geometry.topLeft());
+ floatingTab->resize(geometry.size());
+ floatingTab->show();
+ }
+ break;
+#endif // QT_NO_TABBAR
#endif // QT_NO_DOCKWIDGET
#ifndef QT_NO_TOOLBAR
@@ -1223,7 +1510,7 @@ void QMainWindowLayout::splitDockWidget(QDockWidget *after,
invalidate();
}
-Qt::DockWidgetArea QMainWindowLayout::dockWidgetArea(QDockWidget *widget) const
+Qt::DockWidgetArea QMainWindowLayout::dockWidgetArea(QWidget *widget) const
{
QList<int> pathToWidget = layoutState.dockAreaLayout.indexOf(widget);
if (pathToWidget.isEmpty())
@@ -1238,20 +1525,88 @@ void QMainWindowLayout::keepSize(QDockWidget *w)
#ifndef QT_NO_TABBAR
+// Handle custom tooltip, and allow to drag tabs away.
class QMainWindowTabBar : public QTabBar
{
+ QMainWindow *mainWindow;
+ QDockWidget *draggingDock; // Currently dragging (detached) dock widget
public:
- QMainWindowTabBar(QWidget *parent);
+ QMainWindowTabBar(QMainWindow *parent);
protected:
bool event(QEvent *e) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE;
+
};
-QMainWindowTabBar::QMainWindowTabBar(QWidget *parent)
- : QTabBar(parent)
+QMainWindowTabBar::QMainWindowTabBar(QMainWindow *parent)
+ : QTabBar(parent), mainWindow(parent), draggingDock(0)
{
setExpanding(false);
}
+void QMainWindowTabBar::mouseMoveEvent(QMouseEvent *e)
+{
+ // The QTabBar handles the moving (reordering) of tabs.
+ // When QTabBarPrivate::dragInProgress is true, and that the mouse is outside of a region
+ // around the QTabBar, we will consider the user wants to drag that QDockWidget away from this
+ // tab area.
+
+ QTabBarPrivate *d = static_cast<QTabBarPrivate*>(d_ptr.data());
+ if (!draggingDock && (mainWindow->dockOptions() & QMainWindow::GroupedDragging)) {
+ int offset = QApplication::startDragDistance() + 1;
+ offset *= 3;
+ QRect r = rect().adjusted(-offset, -offset, offset, offset);
+ if (d->dragInProgress && !r.contains(e->pos()) && d->validIndex(d->pressedIndex)) {
+ QMainWindowLayout* mlayout = qt_mainwindow_layout(mainWindow);
+ QDockAreaLayoutInfo *info = mlayout->dockInfo(this);
+ Q_ASSERT(info);
+ int idx = info->tabIndexToListIndex(d->pressedIndex);
+ const QDockAreaLayoutItem &item = info->item_list.at(idx);
+ if (item.widgetItem
+ && (draggingDock = qobject_cast<QDockWidget *>(item.widgetItem->widget()))) {
+ // We should drag this QDockWidget away by unpluging it.
+ // First cancel the QTabBar's internal move
+ d->moveTabFinished(d->pressedIndex);
+ d->pressedIndex = -1;
+ if (d->movingTab)
+ d->movingTab->setVisible(false);
+ d->dragStartPosition = QPoint();
+
+ // Then starts the drag using QDockWidgetPrivate's API
+ QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));
+ QDockWidgetLayout *dwlayout = static_cast<QDockWidgetLayout *>(draggingDock->layout());
+ dockPriv->initDrag(dwlayout->titleArea().center(), true);
+ dockPriv->startDrag(false);
+ if (dockPriv->state)
+ dockPriv->state->ctrlDrag = e->modifiers() & Qt::ControlModifier;
+ }
+ }
+ }
+
+ if (draggingDock) {
+ QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));
+ if (dockPriv->state && dockPriv->state->dragging) {
+ QPoint pos = e->globalPos() - dockPriv->state->pressPos;
+ draggingDock->move(pos);
+ // move will call QMainWindowLayout::hover
+ }
+ }
+ QTabBar::mouseMoveEvent(e);
+}
+
+void QMainWindowTabBar::mouseReleaseEvent(QMouseEvent *e)
+{
+ if (draggingDock && e->button() == Qt::LeftButton) {
+ QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));
+ if (dockPriv->state && dockPriv->state->dragging) {
+ dockPriv->endDrag();
+ }
+ draggingDock = 0;
+ }
+ QTabBar::mouseReleaseEvent(e);
+}
+
bool QMainWindowTabBar::event(QEvent *e)
{
// show the tooltip if tab is too small to fit label
@@ -1276,7 +1631,7 @@ QTabBar *QMainWindowLayout::getTabBar()
if (!unusedTabBars.isEmpty()) {
result = unusedTabBars.takeLast();
} else {
- result = new QMainWindowTabBar(parentWidget());
+ result = new QMainWindowTabBar(static_cast<QMainWindow *>(parentWidget()));
result->setDrawBase(true);
result->setElideMode(Qt::ElideRight);
result->setDocumentMode(_documentMode);
@@ -1305,12 +1660,30 @@ QWidget *QMainWindowLayout::getSeparatorWidget()
return result;
}
+/*! \internal
+ Returns a pointer QDockAreaLayoutInfo which contains this \a widget directly
+ (in its internal list)
+ */
+QDockAreaLayoutInfo *QMainWindowLayout::dockInfo(QWidget *widget)
+{
+ QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget);
+ if (info)
+ return info;
+ foreach (QDockWidgetGroupWindow *dwgw,
+ parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {
+ info = dwgw->layoutInfo()->info(widget);
+ if (info)
+ return info;
+ }
+ return 0;
+}
+
void QMainWindowLayout::tabChanged()
{
QTabBar *tb = qobject_cast<QTabBar*>(sender());
if (tb == 0)
return;
- QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(tb);
+ QDockAreaLayoutInfo *info = dockInfo(tb);
if (info == 0)
return;
info->apply(false);
@@ -1323,7 +1696,7 @@ void QMainWindowLayout::tabMoved(int from, int to)
{
QTabBar *tb = qobject_cast<QTabBar*>(sender());
Q_ASSERT(tb);
- QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(tb);
+ QDockAreaLayoutInfo *info = dockInfo(tb);
Q_ASSERT(info);
info->moveTab(from, to);
@@ -1365,7 +1738,7 @@ bool QMainWindowLayout::endSeparatorMove(const QPoint&)
void QMainWindowLayout::raise(QDockWidget *widget)
{
- QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget);
+ QDockAreaLayoutInfo *info = dockInfo(widget);
if (info == 0)
return;
#ifndef QT_NO_TABBAR
@@ -1549,6 +1922,8 @@ void QMainWindowLayout::revert(QLayoutItem *widgetItem)
QWidget *widget = widgetItem->widget();
layoutState = savedState;
currentGapPos = layoutState.indexOf(widget);
+ if (currentGapPos.isEmpty())
+ return;
fixToolBarOrientation(widgetItem, currentGapPos.at(1));
layoutState.unplug(currentGapPos);
layoutState.fitLayout();
@@ -1613,6 +1988,42 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
if (widget == pluggingWidget) {
#ifndef QT_NO_DOCKWIDGET
+ if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(widget)) {
+ // When the animated widget was a QDockWidgetGroupWindow, it means each of the
+ // embedded QDockWidget needs to be plugged back into the QMainWindow layout.
+ savedState.clear();
+ QDockAreaLayoutInfo* info = dwgw->layoutInfo();
+ QList<int> path = layoutState.dockAreaLayout.indexOf(widget);
+ Q_ASSERT(path.size() >= 2);
+
+ QDockAreaLayoutInfo* parentInfo = layoutState.dockAreaLayout.info(path);
+ Q_ASSERT(parentInfo);
+ if (parentInfo->tabbed) {
+ // merge the two tab widgets
+ int idx = path.last();
+ Q_ASSERT(parentInfo->item_list[idx].widgetItem->widget() == dwgw);
+ delete parentInfo->item_list[idx].widgetItem;
+ parentInfo->item_list.removeAt(idx);
+ std::copy(info->item_list.cbegin(), info->item_list.cend(),
+ std::inserter(parentInfo->item_list, parentInfo->item_list.begin() + idx));
+ quintptr currentId = info->currentTabId();
+ *info = QDockAreaLayoutInfo();
+ parentInfo->reparentWidgets(parentWidget());
+ parentInfo->updateTabBar();
+ parentInfo->setCurrentTabId(currentId);
+ } else {
+ QDockAreaLayoutItem &item = layoutState.dockAreaLayout.item(path);
+ Q_ASSERT(item.widgetItem->widget() == dwgw);
+ delete item.widgetItem;
+ item.widgetItem = 0;
+ item.subinfo = new QDockAreaLayoutInfo(qMove(*info));
+ *info = QDockAreaLayoutInfo();
+ item.subinfo->reparentWidgets(parentWidget());
+ item.subinfo->setTabBarShape(parentInfo->tabBarShape);
+ }
+ dwgw->destroyIfEmpty();
+ }
+
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget))
dw->d_func()->plug(currentGapRect);
#endif
@@ -1633,7 +2044,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
if (qobject_cast<QDockWidget*>(widget) != 0) {
// info() might return null if the widget is destroyed while
// animating but before the animationFinished signal is received.
- if (QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget))
+ if (QDockAreaLayoutInfo *info = dockInfo(widget))
info->setCurrentTab(widget);
}
#endif
@@ -1777,8 +2188,33 @@ void QMainWindowLayout::setCentralWidget(QWidget *widget)
invalidate();
}
-QLayoutItem *QMainWindowLayout::unplug(QWidget *widget)
-{
+/*! \internal
+ Unplug \a widget (QDockWidget or QToolBar) from it's parent container.
+
+ If \a group is true we might actually unplug the group of tabs this
+ widget is part if QMainWindow::GroupedDragging is set. When \a group
+ is false, the widget itself is always unplugged alone
+
+ Returns the QLayoutItem of the dragged element.
+ The layout item is kept in the layout but set as a gap item.
+ */
+QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
+{
+#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_TABBAR)
+ QDockWidgetGroupWindow *floatingParent = qobject_cast<QDockWidgetGroupWindow *>(widget->parentWidget());
+ if (group && floatingParent && !widget->isWindow()) {
+ // We are just dragging a floating window as it, not need to do anything, we just have to
+ // look up the corresponding QWidgetItem* if it exists
+ QList<int> tabbedWindowPath = layoutState.indexOf(widget->parentWidget());
+ return tabbedWindowPath.isEmpty() ? 0 : layoutState.item(tabbedWindowPath);
+ } else if (floatingParent) {
+ // We are unplugging a dock widget from a floating window.
+ if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
+ dw->d_func()->unplug(widget->geometry());
+ return 0;
+ }
+ }
+#endif
QList<int> path = layoutState.indexOf(widget);
if (path.isEmpty())
return 0;
@@ -1792,9 +2228,35 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget)
#ifndef QT_NO_DOCKWIDGET
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
- dw->d_func()->unplug(r);
+ Q_ASSERT(path.first() == 1);
+ bool actualGroup = false;
+#ifndef QT_NO_TABBAR
+ if (group && (dockOptions & QMainWindow::GroupedDragging) && path.size() > 3) {
+ QDockAreaLayoutItem &parentItem = layoutState.dockAreaLayout.item(path.mid(1, path.size() - 2));
+ if (parentItem.subinfo && parentItem.subinfo->tabbed) {
+ // The QDockWidget is part of a group of tab and we need to unplug them all.
+ actualGroup = true;
+ path.removeLast();
+
+ QDockWidgetGroupWindow* floatingTabs = createTabbedDockWindow();
+ QDockAreaLayoutInfo* info = floatingTabs->layoutInfo();
+ *info = qMove(*parentItem.subinfo);
+ delete parentItem.subinfo;
+ parentItem.subinfo = 0;
+ floatingTabs->setGeometry(info->rect.translated(parentWidget()->pos()));
+ floatingTabs->show();
+ floatingTabs->raise();
+ item = new QDockWidgetGroupWindowItem(floatingTabs);
+ parentItem.widgetItem = item;
+ savedState = layoutState;
+ }
+ }
+#endif // QT_NO_TABBAR
+ if (!actualGroup) {
+ dw->d_func()->unplug(r);
+ }
}
-#endif
+#endif // QT_NO_DOCKWIDGET
#ifndef QT_NO_TOOLBAR
if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) {
tb->d_func()->unplug(r);
@@ -1841,6 +2303,9 @@ QList<int> QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mouse
#ifndef QT_NO_DOCKWIDGET
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget))
allowed = dw->isAreaAllowed(toDockWidgetArea(path.at(1)));
+
+ if (qobject_cast<QDockWidgetGroupWindow *>(widget))
+ allowed = true;
#endif
#ifndef QT_NO_TOOLBAR
if (QToolBar *tb = qobject_cast<QToolBar*>(widget))
@@ -1893,11 +2358,23 @@ QList<int> QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mouse
return path;
}
+QDockWidgetGroupWindow *QMainWindowLayout::createTabbedDockWindow()
+{
+ QDockWidgetGroupWindow* f = new QDockWidgetGroupWindow(parentWidget(), Qt::Tool);
+ new QDockWidgetGroupLayout(f);
+ return f;
+}
+
void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animate)
{
#ifndef QT_NO_DOCKWIDGET
#ifndef QT_NO_TABBAR
QSet<QTabBar*> used = newState.dockAreaLayout.usedTabBars();
+ foreach (QDockWidgetGroupWindow *dwgw,
+ parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {
+ used += dwgw->layoutInfo()->usedTabBars();
+ }
+
QSet<QTabBar*> retired = usedTabBars - used;
usedTabBars = used;
foreach (QTabBar *tab_bar, retired) {
@@ -1916,6 +2393,8 @@ void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animat
}
}
+ for (int i = 0; i < QInternal::DockCount; ++i)
+ newState.dockAreaLayout.docks[i].reparentWidgets(parentWidget());
#endif // QT_NO_TABBAR
#endif // QT_NO_DOCKWIDGET
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index 8ccb4d303f..9155c5fb23 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -77,6 +77,23 @@ QT_BEGIN_NAMESPACE
class QToolBar;
class QRubberBand;
+#ifndef QT_NO_DOCKWIDGET
+class QDockWidgetGroupWindow : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit QDockWidgetGroupWindow(QWidget* parent = 0, Qt::WindowFlags f = 0)
+ : QWidget(parent, f) {}
+ QDockAreaLayoutInfo *layoutInfo() const;
+ QDockWidget *topDockWidget() const;
+ void destroyIfEmpty();
+ void adjustFlags();
+protected:
+ bool event(QEvent *) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
+};
+#endif
+
/* This data structure represents the state of all the tool-bars and dock-widgets. It's value based
so it can be easilly copied into a temporary variable. All operations are performed without moving
any widgets. Only when we are sure we have the desired state, we call apply(), which moves the
@@ -196,10 +213,11 @@ public:
QDockWidget *dockwidget,
Qt::Orientation orientation);
void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
- Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
+ Qt::DockWidgetArea dockWidgetArea(QWidget* widget) const;
void raise(QDockWidget *widget);
void setVerticalTabsEnabled(bool enabled);
bool restoreDockWidget(QDockWidget *dockwidget);
+ QDockAreaLayoutInfo *dockInfo(QWidget *w);
#ifndef QT_NO_TABBAR
bool _documentMode;
@@ -224,6 +242,8 @@ public:
void setTabShape(QTabWidget::TabShape tabShape);
QTabWidget::TabPosition tabPosition(Qt::DockWidgetArea area) const;
void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition);
+
+ QDockWidgetGroupWindow *createTabbedDockWindow();
#endif // QT_NO_TABWIDGET
#endif // QT_NO_TABBAR
@@ -273,7 +293,7 @@ public:
QList<int> hover(QLayoutItem *widgetItem, const QPoint &mousePos);
bool plug(QLayoutItem *widgetItem);
- QLayoutItem *unplug(QWidget *widget);
+ QLayoutItem *unplug(QWidget *widget, bool group = false);
void revert(QLayoutItem *widgetItem);
void updateGapIndicator();
void paintDropIndicator(QPainter *p, QWidget *widget, const QRegion &clip);
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 1749f9d8c7..4403deda8e 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -183,7 +183,7 @@ void QMenuPrivate::setPlatformMenu(QPlatformMenu *menu)
}
// forward declare function
-static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* item);
+static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu);
void QMenuPrivate::syncPlatformMenu()
{
@@ -200,7 +200,7 @@ void QMenuPrivate::syncPlatformMenu()
menuItem->setTag(reinterpret_cast<quintptr>(action));
QObject::connect(menuItem, SIGNAL(activated()), action, SLOT(trigger()), Qt::QueuedConnection);
QObject::connect(menuItem, SIGNAL(hovered()), action, SIGNAL(hovered()), Qt::QueuedConnection);
- copyActionToPlatformItem(action, menuItem);
+ copyActionToPlatformItem(action, menuItem, platformMenu.data());
platformMenu->insertMenuItem(menuItem, beforeItem);
beforeItem = menuItem;
}
@@ -1110,8 +1110,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
handleEnterLeaveEvents(&previousMouseMenu,qobject_cast<QMenu *>(caused));
if(e->type() != QEvent::MouseButtonRelease || mouseDown == caused) {
QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(),
- e->button(), e->buttons(), e->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&new_e, e->source());
+ e->button(), e->buttons(), e->modifiers(), e->source());
QApplication::sendEvent(caused, &new_e);
return true;
}
@@ -3105,7 +3104,7 @@ QMenu::timerEvent(QTimerEvent *e)
}
}
-static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* item)
+static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu)
{
item->setText(action->text());
item->setIsSeparator(action->isSeparator());
@@ -3131,6 +3130,8 @@ static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* i
item->setEnabled(action->isEnabled());
if (action->menu()) {
+ if (!action->menu()->platformMenu())
+ action->menu()->setPlatformMenu(itemsMenu->createSubMenu());
item->setMenu(action->menu()->platformMenu());
} else {
item->setMenu(0);
@@ -3185,7 +3186,7 @@ void QMenu::actionEvent(QActionEvent *e)
menuItem->setTag(reinterpret_cast<quintptr>(e->action()));
QObject::connect(menuItem, SIGNAL(activated()), e->action(), SLOT(trigger()));
QObject::connect(menuItem, SIGNAL(hovered()), e->action(), SIGNAL(hovered()));
- copyActionToPlatformItem(e->action(), menuItem);
+ copyActionToPlatformItem(e->action(), menuItem, d->platformMenu);
QPlatformMenuItem* beforeItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->before()));
d->platformMenu->insertMenuItem(menuItem, beforeItem);
} else if (e->type() == QEvent::ActionRemoved) {
@@ -3195,7 +3196,7 @@ void QMenu::actionEvent(QActionEvent *e)
} else if (e->type() == QEvent::ActionChanged) {
QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action()));
if (menuItem) {
- copyActionToPlatformItem(e->action(), menuItem);
+ copyActionToPlatformItem(e->action(), menuItem, d->platformMenu);
d->platformMenu->syncMenuItem(menuItem);
}
}
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 4659d9cf6c..1ad99bed9c 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -1632,7 +1632,7 @@ QSize QMenuBar::sizeHint() const
if(d->leftWidget) {
QSize sz = d->leftWidget->sizeHint();
sz.rheight() += margin;
- ret.expandedTo(sz);
+ ret = ret.expandedTo(sz);
}
if(d->rightWidget) {
QSize sz = d->rightWidget->sizeHint();
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index de6e45234c..38773a4fbf 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -58,6 +58,10 @@ QT_BEGIN_NAMESPACE
//#define QSPLITTER_DEBUG
+QSplitterPrivate::~QSplitterPrivate()
+{
+}
+
/*!
\class QSplitterHandle
\brief The QSplitterHandle class provides handle functionality for the splitter.
diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h
index a45f776da1..890bd535ec 100644
--- a/src/widgets/widgets/qsplitter_p.h
+++ b/src/widgets/widgets/qsplitter_p.h
@@ -76,6 +76,7 @@ class QSplitterPrivate : public QFramePrivate
public:
QSplitterPrivate() : rubberBand(0), opaque(true), firstShow(true),
childrenCollapsible(true), compatMode(false), handleWidth(-1), blockChildAdd(false), opaqueResizeSet(false) {}
+ ~QSplitterPrivate();
QPointer<QRubberBand> rubberBand;
mutable QList<QSplitterLayoutStruct *> list;
diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp
index 2cec8a0b9c..19a2edf0f2 100644
--- a/src/widgets/widgets/qstackedwidget.cpp
+++ b/src/widgets/widgets/qstackedwidget.cpp
@@ -182,7 +182,9 @@ int QStackedWidget::insertWidget(int index, QWidget *widget)
not deleted but simply removed from the stacked layout, causing it
to be hidden.
- \b{Note:} Ownership of \a widget reverts to the application.
+ \note Parent object and parent widget of \a widget will remain the
+ QStackedWidget. If the application wants to reuse the removed
+ \a widget, then it is recommended to re-parent it.
\sa addWidget(), insertWidget(), currentWidget()
*/
diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index 5a56c592a6..8473b261fc 100644
--- a/src/widgets/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
@@ -897,7 +897,7 @@ void QToolButton::setDefaultAction(QAction *action)
return;
if (!actions().contains(action))
addAction(action);
- setText(action->iconText());
+ setText(action->text());
setIcon(action->icon());
#ifndef QT_NO_TOOLTIP
setToolTip(action->toolTip());
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 759e41a5fa..436937be72 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -189,7 +189,7 @@ void QWidgetLineControl::commitPreedit()
m_preeditCursor = 0;
setPreeditArea(-1, QString());
- m_textLayout.clearAdditionalFormats();
+ m_textLayout.clearFormats();
updateDisplayText(/*force*/ true);
#endif
}
@@ -557,7 +557,8 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
const int oldPreeditCursor = m_preeditCursor;
m_preeditCursor = event->preeditString().length();
m_hideCursor = false;
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
+ formats.reserve(event->attributes().size());
for (int i = 0; i < event->attributes().size(); ++i) {
const QInputMethodEvent::Attribute &a = event->attributes().at(i);
if (a.type == QInputMethodEvent::Cursor) {
@@ -574,7 +575,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
}
}
}
- m_textLayout.setAdditionalFormats(formats);
+ m_textLayout.setFormats(formats);
updateDisplayText(/*force*/ true);
if (cursorPositionChanged)
emitCursorPositionChanged();
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index faa63cb400..22d199fc74 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -883,7 +883,8 @@ void QWidgetTextControl::setTextCursor(const QTextCursor &cursor)
const bool posChanged = cursor.position() != d->cursor.position();
const QTextCursor oldSelection = d->cursor;
d->cursor = cursor;
- d->cursorOn = d->hasFocus && (d->interactionFlags & Qt::TextEditable);
+ d->cursorOn = d->hasFocus
+ && (d->interactionFlags & (Qt::TextSelectableByKeyboard | Qt::TextEditable));
d->_q_updateCurrentCharFormatAndSelection();
ensureCursorVisible();
d->repaintOldAndNewSelection(oldSelection);
@@ -2028,7 +2029,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
QTextLayout *layout = block.layout();
if (isGettingInput)
layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
- QList<QTextLayout::FormatRange> overrides;
+ QVector<QTextLayout::FormatRange> overrides;
+ overrides.reserve(e->attributes().size());
const int oldPreeditCursor = preeditCursor;
preeditCursor = e->preeditString().length();
hideCursor = false;
@@ -2048,7 +2050,7 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
}
}
}
- layout->setAdditionalFormats(overrides);
+ layout->setFormats(overrides);
cursor.endEditBlock();
@@ -2138,7 +2140,7 @@ void QWidgetTextControlPrivate::focusEvent(QFocusEvent *e)
#ifdef QT_KEYPAD_NAVIGATION
if (!QApplication::keypadNavigationEnabled() || (hasEditFocus && (e->reason() == Qt::PopupFocusReason))) {
#endif
- cursorOn = (interactionFlags & Qt::TextSelectableByKeyboard);
+ cursorOn = (interactionFlags & (Qt::TextSelectableByKeyboard | Qt::TextEditable));
if (interactionFlags & Qt::TextEditable) {
setBlinkingCursorEnabled(true);
}
@@ -2877,7 +2879,7 @@ void QWidgetTextControlPrivate::commitPreedit()
QTextBlock block = cursor.block();
QTextLayout *layout = block.layout();
layout->setPreeditArea(-1, QString());
- layout->clearAdditionalFormats();
+ layout->clearFormats();
cursor.endEditBlock();
}
diff --git a/src/winmain/qtmain_win.cpp b/src/winmain/qtmain_win.cpp
index e88cecf0b3..2944e07e00 100644
--- a/src/winmain/qtmain_win.cpp
+++ b/src/winmain/qtmain_win.cpp
@@ -111,7 +111,7 @@ extern "C" int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR /*cmdParamarg*/, int
argv[argc] = Q_NULLPTR;
LocalFree(argvW);
const int exitCode = main(argc, argv);
- for (int i = 0; i < argc; ++i)
+ for (int i = 0; i < argc && argv[i]; ++i)
delete [] argv[i];
delete [] argv;
return exitCode;
diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp
index 5a44df622a..e68da520e7 100644
--- a/src/winmain/qtmain_winrt.cpp
+++ b/src/winmain/qtmain_winrt.cpp
@@ -222,11 +222,49 @@ private:
// Main entry point for Appx containers
int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
+#if _MSC_VER < 1900
int argc = 0;
char **argv, **env;
_startupinfo info = { _query_new_mode() };
if (int init = __getmainargs(&argc, &argv, &env, false, &info))
return init;
+#else
+ QByteArray commandLine = QString::fromWCharArray(GetCommandLine()).toUtf8();
+ QVarLengthArray<char *> args;
+ args.append(commandLine.data());
+ bool quote = false;
+ bool escape = false;
+ for (int i = 0; i < commandLine.size(); ++i) {
+ switch (commandLine.at(i)) {
+ case '\\':
+ escape = true;
+ break;
+ case '"':
+ if (escape) {
+ escape = false;
+ break;
+ }
+ quote = !quote;
+ commandLine[i] = '\0';
+ break;
+ case ' ':
+ if (quote)
+ break;
+ commandLine[i] = '\0';
+ if (args.last()[0] != '\0')
+ args.append(commandLine.data() + i + 1);
+ // fall through
+ default:
+ if (args.last()[0] == '\0')
+ args.last() = commandLine.data() + i;
+ escape = false; // only quotes are escaped
+ break;
+ }
+ }
+ int argc = args.size();
+ char **argv = args.data();
+ char **env = Q_NULLPTR;
+#endif // _MSC_VER >= 1900
for (int i = 0; env && env[i]; ++i) {
QByteArray var(env[i]);
diff --git a/src/xml/doc/qtxml.qdocconf b/src/xml/doc/qtxml.qdocconf
index 8ca421ff4e..419859ac8b 100644
--- a/src/xml/doc/qtxml.qdocconf
+++ b/src/xml/doc/qtxml.qdocconf
@@ -40,3 +40,6 @@ imagedirs += images \
navigation.landingpage = "Qt XML"
navigation.cppclassespage = "Qt XML C++ Classes"
+
+# Add a thumbnail for examples that do not have images
+manifestmeta.thumbnail.names = "QtXml/XML Stream Lint Example"