summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/.prev_CMakeLists.txt232
-rw-r--r--src/corelib/.prev_configure.cmake6
-rw-r--r--src/corelib/CMakeLists.txt385
-rw-r--r--src/corelib/Qt5AndroidSupport.cmake205
-rw-r--r--src/corelib/Qt5CoreMacros.cmake507
-rw-r--r--src/corelib/Qt6AndroidMacros.cmake77
-rw-r--r--src/corelib/Qt6CTestMacros.cmake14
-rw-r--r--src/corelib/Qt6Config.cmake.in51
-rw-r--r--src/corelib/Qt6CoreConfigExtras.cmake.in2
-rw-r--r--src/corelib/Qt6CoreConfigExtrasMkspecDir.cmake.in6
-rw-r--r--src/corelib/Qt6CoreConfigExtrasMkspecDirForInstall.cmake.in6
-rw-r--r--src/corelib/Qt6CoreConfigureFileTemplate.in1
-rw-r--r--src/corelib/Qt6CoreMacros.cmake228
-rw-r--r--src/corelib/Qt6ModuleLocation.cmake.in15
-rw-r--r--src/corelib/Qt6ModuleLocationForInstall.cmake.in6
-rw-r--r--src/corelib/animation/qabstractanimation.cpp30
-rw-r--r--src/corelib/animation/qabstractanimation.h3
-rw-r--r--src/corelib/animation/qabstractanimation_p.h2
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp2
-rw-r--r--src/corelib/configure.cmake4
-rw-r--r--src/corelib/configure.json4
-rw-r--r--src/corelib/corelib.pro2
-rw-r--r--src/corelib/doc/qtcore.qdocconf7
-rw-r--r--src/corelib/doc/snippets/cmake-macros/examples.cmake6
-rw-r--r--src/corelib/doc/snippets/code/doc_src_containers.cpp2
-rw-r--r--src/corelib/doc/snippets/code/doc_src_properties.cpp7
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp303
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qiterator.cpp9
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp16
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_text_qcollator.cpp58
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_text_qregularexpression.cpp9
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp6
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qexception.cpp16
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp14
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp23
-rw-r--r--src/corelib/doc/snippets/eventfilters/filterobject.h2
-rw-r--r--src/corelib/doc/snippets/overview/using-qt-core.cmake4
-rw-r--r--src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp4
-rw-r--r--src/corelib/doc/snippets/qstring/main.cpp26
-rw-r--r--src/corelib/doc/snippets/qstring/stringbuilder.cpp2
-rw-r--r--src/corelib/doc/snippets/qstringlist/main.cpp2
-rw-r--r--src/corelib/doc/snippets/qstringlistmodel/main.cpp2
-rw-r--r--src/corelib/doc/src/animation.qdoc9
-rw-r--r--src/corelib/doc/src/cmake-macros.qdoc334
-rw-r--r--src/corelib/doc/src/containers.qdoc330
-rw-r--r--src/corelib/doc/src/foreach-keyword.qdoc100
-rw-r--r--src/corelib/doc/src/includes/qobject.qdocinc (renamed from src/corelib/doc/src/includes/qt_add_binary_resources.qdocinc)19
-rw-r--r--src/corelib/doc/src/includes/qt_add_big_resources.qdocinc44
-rw-r--r--src/corelib/doc/src/includes/qt_add_resources.qdocinc40
-rw-r--r--src/corelib/doc/src/includes/qt_generate_moc.qdocinc42
-rw-r--r--src/corelib/doc/src/includes/qt_import_plugins.qdocinc58
-rw-r--r--src/corelib/doc/src/includes/qt_wrap_cpp.qdocinc49
-rw-r--r--src/corelib/doc/src/java-style-iterators.qdoc198
-rw-r--r--src/corelib/doc/src/objectmodel/metaobjects.qdoc2
-rw-r--r--src/corelib/doc/src/objectmodel/properties.qdoc6
-rw-r--r--src/corelib/doc/src/qt6-changes.qdoc753
-rw-r--r--src/corelib/doc/src/qtcore-index.qdoc15
-rw-r--r--src/corelib/doc/src/qtcore.qdoc2
-rw-r--r--src/corelib/global/global.pri3
-rw-r--r--src/corelib/global/qcompare.h143
-rw-r--r--src/corelib/global/qcompare.qdoc137
-rw-r--r--src/corelib/global/qcompilerdetection.h19
-rw-r--r--src/corelib/global/qcontainerinfo.h151
-rw-r--r--src/corelib/global/qendian.cpp13
-rw-r--r--src/corelib/global/qendian_p.h49
-rw-r--r--src/corelib/global/qflags.h11
-rw-r--r--src/corelib/global/qfloat16.cpp48
-rw-r--r--src/corelib/global/qfloat16.h193
-rw-r--r--src/corelib/global/qglobal.cpp77
-rw-r--r--src/corelib/global/qglobal.h213
-rw-r--r--src/corelib/global/qglobalstatic.h24
-rw-r--r--src/corelib/global/qisenum.h51
-rw-r--r--src/corelib/global/qlibraryinfo.cpp47
-rw-r--r--src/corelib/global/qlibraryinfo.h5
-rw-r--r--src/corelib/global/qlogging.cpp44
-rw-r--r--src/corelib/global/qlogging.h9
-rw-r--r--src/corelib/global/qmalloc.cpp5
-rw-r--r--src/corelib/global/qmemory_p.h71
-rw-r--r--src/corelib/global/qnamespace.h20
-rw-r--r--src/corelib/global/qnamespace.qdoc104
-rw-r--r--src/corelib/global/qnumeric.cpp7
-rw-r--r--src/corelib/global/qnumeric_p.h92
-rw-r--r--src/corelib/global/qrandom.cpp147
-rw-r--r--src/corelib/global/qrandom.h76
-rw-r--r--src/corelib/global/qrandom_p.h5
-rw-r--r--src/corelib/global/qsimd.cpp45
-rw-r--r--src/corelib/global/qsysinfo.h3
-rw-r--r--src/corelib/global/qt_windows.h2
-rw-r--r--src/corelib/global/qtypeinfo.h50
-rw-r--r--src/corelib/io/PSL-LICENSE.txt373
-rw-r--r--src/corelib/io/qbuffer.h9
-rw-r--r--src/corelib/io/qdebug.cpp45
-rw-r--r--src/corelib/io/qdebug.h18
-rw-r--r--src/corelib/io/qdir.cpp9
-rw-r--r--src/corelib/io/qdir.h12
-rw-r--r--src/corelib/io/qdiriterator.cpp10
-rw-r--r--src/corelib/io/qdiriterator.h4
-rw-r--r--src/corelib/io/qfile.cpp20
-rw-r--r--src/corelib/io/qfiledevice.cpp11
-rw-r--r--src/corelib/io/qfileinfo.cpp62
-rw-r--r--src/corelib/io/qfileinfo.h25
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp32
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp32
-rw-r--r--src/corelib/io/qfilesystemiterator_unix.cpp2
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp4
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp4
-rw-r--r--src/corelib/io/qfilesystemwatcher_win_p.h2
-rw-r--r--src/corelib/io/qfsfileengine_p.h3
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp2
-rw-r--r--src/corelib/io/qiodevice.cpp5
-rw-r--r--src/corelib/io/qiodevice.h2
-rw-r--r--src/corelib/io/qiodevice_p.h3
-rw-r--r--src/corelib/io/qlockfile.cpp8
-rw-r--r--src/corelib/io/qlockfile.h2
-rw-r--r--src/corelib/io/qlockfile_win.cpp31
-rw-r--r--src/corelib/io/qloggingregistry_p.h6
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice.cpp16
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice_p.h41
-rw-r--r--src/corelib/io/qprocess.cpp59
-rw-r--r--src/corelib/io/qprocess.h22
-rw-r--r--src/corelib/io/qprocess_p.h44
-rw-r--r--src/corelib/io/qprocess_unix.cpp38
-rw-r--r--src/corelib/io/qprocess_win.cpp10
-rw-r--r--src/corelib/io/qresource.cpp311
-rw-r--r--src/corelib/io/qresource.h2
-rw-r--r--src/corelib/io/qsettings.cpp20
-rw-r--r--src/corelib/io/qsettings_mac.cpp32
-rw-r--r--src/corelib/io/qsettings_p.h7
-rw-r--r--src/corelib/io/qsettings_win.cpp16
-rw-r--r--src/corelib/io/qstandardpaths.cpp27
-rw-r--r--src/corelib/io/qstandardpaths.h6
-rw-r--r--src/corelib/io/qstandardpaths_android.cpp2
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp59
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp4
-rw-r--r--src/corelib/io/qstorageinfo.cpp12
-rw-r--r--src/corelib/io/qstorageinfo.h27
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp2
-rw-r--r--src/corelib/io/qstorageinfo_win.cpp2
-rw-r--r--src/corelib/io/qt_attribution.json29
-rw-r--r--src/corelib/io/qtemporaryfile.cpp8
-rw-r--r--src/corelib/io/qurl.cpp19
-rw-r--r--src/corelib/io/qurl.h10
-rw-r--r--src/corelib/io/qurlquery.cpp14
-rw-r--r--src/corelib/io/qurlquery.h3
-rw-r--r--src/corelib/io/qurlrecode.cpp2
-rw-r--r--src/corelib/io/qwindowspipereader_p.h2
-rw-r--r--src/corelib/io/qwindowspipewriter_p.h2
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp6
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h13
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel_p.h2
-rw-r--r--src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp4
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp41
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.h7
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp24
-rw-r--r--src/corelib/kernel/kernel.pri13
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp34
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.h9
-rw-r--r--src/corelib/kernel/qassociativeiterable.cpp104
-rw-r--r--src/corelib/kernel/qassociativeiterable.h32
-rw-r--r--src/corelib/kernel/qbasictimer.h8
-rw-r--r--src/corelib/kernel/qcore_foundation.mm246
-rw-r--r--src/corelib/kernel/qcore_mac_p.h75
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp136
-rw-r--r--src/corelib/kernel/qcoreapplication.h7
-rw-r--r--src/corelib/kernel/qcoreapplication_mac.cpp5
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h6
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp2
-rw-r--r--src/corelib/kernel/qcoreevent.cpp68
-rw-r--r--src/corelib/kernel/qcoreevent.h77
-rw-r--r--src/corelib/kernel/qcoreglobaldata_p.h5
-rw-r--r--src/corelib/kernel/qdeadlinetimer.cpp27
-rw-r--r--src/corelib/kernel/qelapsedtimer.cpp20
-rw-r--r--src/corelib/kernel/qelapsedtimer.h10
-rw-r--r--src/corelib/kernel/qelapsedtimer_generic.cpp13
-rw-r--r--src/corelib/kernel/qelapsedtimer_mac.cpp2
-rw-r--r--src/corelib/kernel/qeventdispatcher_cf_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp22
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp2
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp166
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h19
-rw-r--r--src/corelib/kernel/qeventloop.cpp8
-rw-r--r--src/corelib/kernel/qeventloop.h2
-rw-r--r--src/corelib/kernel/qiterable.cpp200
-rw-r--r--src/corelib/kernel/qiterable_p.cpp63
-rw-r--r--src/corelib/kernel/qiterable_p.h2
-rw-r--r--src/corelib/kernel/qjni.cpp2
-rw-r--r--src/corelib/kernel/qjni_p.h8
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp8
-rw-r--r--src/corelib/kernel/qjnionload.cpp7
-rw-r--r--src/corelib/kernel/qmath.h10
-rw-r--r--src/corelib/kernel/qmetacontainer.cpp4
-rw-r--r--src/corelib/kernel/qmetacontainer.h336
-rw-r--r--src/corelib/kernel/qmetaobject.cpp125
-rw-r--r--src/corelib/kernel/qmetaobject.h45
-rw-r--r--src/corelib/kernel/qmetaobject_p.h29
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder.cpp242
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder_p.h15
-rw-r--r--src/corelib/kernel/qmetatype.cpp165
-rw-r--r--src/corelib/kernel/qmetatype.h534
-rw-r--r--src/corelib/kernel/qmetatype_p.h10
-rw-r--r--src/corelib/kernel/qmimedata.cpp6
-rw-r--r--src/corelib/kernel/qmimedata.h3
-rw-r--r--src/corelib/kernel/qobject.cpp258
-rw-r--r--src/corelib/kernel/qobject.h29
-rw-r--r--src/corelib/kernel/qobject_p.h36
-rw-r--r--src/corelib/kernel/qobjectcleanuphandler.cpp6
-rw-r--r--src/corelib/kernel/qobjectcleanuphandler.h3
-rw-r--r--src/corelib/kernel/qobjectdefs.h13
-rw-r--r--src/corelib/kernel/qpointer.cpp58
-rw-r--r--src/corelib/kernel/qpointer.h64
-rw-r--r--src/corelib/kernel/qpoll.cpp2
-rw-r--r--src/corelib/kernel/qppsattribute.cpp308
-rw-r--r--src/corelib/kernel/qppsattribute_p.h138
-rw-r--r--src/corelib/kernel/qppsattributeprivate_p.h89
-rw-r--r--src/corelib/kernel/qppsobject.cpp966
-rw-r--r--src/corelib/kernel/qppsobject_p.h127
-rw-r--r--src/corelib/kernel/qppsobjectprivate_p.h128
-rw-r--r--src/corelib/kernel/qproperty.cpp512
-rw-r--r--src/corelib/kernel/qproperty.h175
-rw-r--r--src/corelib/kernel/qproperty_p.h136
-rw-r--r--src/corelib/kernel/qpropertyprivate.h193
-rw-r--r--src/corelib/kernel/qsequentialiterable.cpp19
-rw-r--r--src/corelib/kernel/qsequentialiterable.h16
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp2
-rw-r--r--src/corelib/kernel/qsharedmemory_systemv.cpp2
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp2
-rw-r--r--src/corelib/kernel/qsignalmapper.cpp7
-rw-r--r--src/corelib/kernel/qsocketnotifier.h6
-rw-r--r--src/corelib/kernel/qsystemerror.cpp10
-rw-r--r--src/corelib/kernel/qsystemerror_p.h2
-rw-r--r--src/corelib/kernel/qtestsupport_core.h9
-rw-r--r--src/corelib/kernel/qtranslator.cpp44
-rw-r--r--src/corelib/kernel/qtranslator.h22
-rw-r--r--src/corelib/kernel/qvariant.cpp440
-rw-r--r--src/corelib/kernel/qvariant.h149
-rw-r--r--src/corelib/kernel/qwineventnotifier.cpp71
-rw-r--r--src/corelib/kernel/qwineventnotifier_p.h6
-rw-r--r--src/corelib/kernel/qwinregistry_p.h6
-rw-r--r--src/corelib/mimetypes/mimetypes_resources.cmake2
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp4
-rw-r--r--src/corelib/mimetypes/qmimetype.h2
-rw-r--r--src/corelib/mimetypes/qmimetypeparser.cpp5
-rw-r--r--src/corelib/plugin/qelfparser_p.cpp4
-rw-r--r--src/corelib/plugin/qelfparser_p.h4
-rw-r--r--src/corelib/plugin/qfactoryinterface.h1
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp2
-rw-r--r--src/corelib/plugin/qlibrary.cpp20
-rw-r--r--src/corelib/plugin/qlibrary.h7
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp12
-rw-r--r--src/corelib/plugin/qlibrary_win.cpp2
-rw-r--r--src/corelib/plugin/qmachparser.cpp2
-rw-r--r--src/corelib/plugin/qplugin.h9
-rw-r--r--src/corelib/plugin/qpluginloader.cpp58
-rw-r--r--src/corelib/plugin/qpluginloader.h2
-rw-r--r--src/corelib/plugin/qsystemlibrary.cpp1
-rw-r--r--src/corelib/plugin/qsystemlibrary_p.h4
-rw-r--r--src/corelib/plugin/quuid.cpp8
-rw-r--r--src/corelib/plugin/quuid.h5
-rw-r--r--src/corelib/serialization/qcborcommon.cpp2
-rw-r--r--src/corelib/serialization/qcborcommon.h5
-rw-r--r--src/corelib/serialization/qcbormap.h4
-rw-r--r--src/corelib/serialization/qcborstreamreader.cpp6
-rw-r--r--src/corelib/serialization/qcborstreamreader.h4
-rw-r--r--src/corelib/serialization/qcborstreamwriter.cpp4
-rw-r--r--src/corelib/serialization/qcborstreamwriter.h4
-rw-r--r--src/corelib/serialization/qcborvalue.cpp2
-rw-r--r--src/corelib/serialization/qcborvalue.h15
-rw-r--r--src/corelib/serialization/qcborvalue_p.h4
-rw-r--r--src/corelib/serialization/qjsoncbor.cpp4
-rw-r--r--src/corelib/serialization/qjsondocument.cpp18
-rw-r--r--src/corelib/serialization/qjsonobject.h4
-rw-r--r--src/corelib/serialization/qjsonparser.cpp40
-rw-r--r--src/corelib/serialization/qjsonvalue.cpp2
-rw-r--r--src/corelib/serialization/qjsonvalue.h2
-rw-r--r--src/corelib/serialization/qtextstream.cpp14
-rw-r--r--src/corelib/serialization/qxmlstream.cpp32
-rw-r--r--src/corelib/serialization/qxmlstream.g15
-rw-r--r--src/corelib/serialization/qxmlstream.h8
-rw-r--r--src/corelib/serialization/qxmlstream_p.h15
-rw-r--r--src/corelib/serialization/qxmlstreamparser_p.h15
-rw-r--r--src/corelib/serialization/qxmlutils.cpp6
-rw-r--r--src/corelib/text/UNICODE_LICENSE.txt2
-rw-r--r--src/corelib/text/qanystringview.h45
-rw-r--r--src/corelib/text/qanystringview.qdoc60
-rw-r--r--src/corelib/text/qbytearray.cpp329
-rw-r--r--src/corelib/text/qbytearray.h257
-rw-r--r--src/corelib/text/qbytearraylist.cpp6
-rw-r--r--src/corelib/text/qbytearraylist.h17
-rw-r--r--src/corelib/text/qbytearrayview.h5
-rw-r--r--src/corelib/text/qbytearrayview.qdoc8
-rw-r--r--src/corelib/text/qbytedata_p.h2
-rw-r--r--src/corelib/text/qchar.cpp77
-rw-r--r--src/corelib/text/qchar.h126
-rw-r--r--src/corelib/text/qcollator.cpp149
-rw-r--r--src/corelib/text/qcollator.h15
-rw-r--r--src/corelib/text/qlocale.cpp965
-rw-r--r--src/corelib/text/qlocale.h1654
-rw-r--r--src/corelib/text/qlocale.qdoc157
-rw-r--r--src/corelib/text/qlocale_data_p.h10731
-rw-r--r--src/corelib/text/qlocale_mac.mm45
-rw-r--r--src/corelib/text/qlocale_p.h86
-rw-r--r--src/corelib/text/qlocale_tools.cpp54
-rw-r--r--src/corelib/text/qlocale_unix.cpp27
-rw-r--r--src/corelib/text/qlocale_win.cpp42
-rw-r--r--src/corelib/text/qregularexpression.cpp52
-rw-r--r--src/corelib/text/qregularexpression.h108
-rw-r--r--src/corelib/text/qstring.cpp1324
-rw-r--r--src/corelib/text/qstring.h764
-rw-r--r--src/corelib/text/qstringalgorithms.h116
-rw-r--r--src/corelib/text/qstringbuilder.cpp9
-rw-r--r--src/corelib/text/qstringbuilder.h74
-rw-r--r--src/corelib/text/qstringconverter.cpp254
-rw-r--r--src/corelib/text/qstringconverter.h70
-rw-r--r--src/corelib/text/qstringconverter_p.h42
-rw-r--r--src/corelib/text/qstringlist.cpp49
-rw-r--r--src/corelib/text/qstringlist.h34
-rw-r--r--src/corelib/text/qstringtokenizer.cpp88
-rw-r--r--src/corelib/text/qstringtokenizer.h24
-rw-r--r--src/corelib/text/qstringview.cpp33
-rw-r--r--src/corelib/text/qstringview.h212
-rw-r--r--src/corelib/text/qt_attribution.json2
-rw-r--r--src/corelib/text/qtextboundaryfinder.cpp2
-rw-r--r--src/corelib/text/qutf8stringview.h44
-rw-r--r--src/corelib/text/qutf8stringview.qdoc90
-rw-r--r--src/corelib/thread/qatomic_cxx11.h40
-rw-r--r--src/corelib/thread/qbasicatomic.h13
-rw-r--r--src/corelib/thread/qexception.cpp82
-rw-r--r--src/corelib/thread/qexception.h20
-rw-r--r--src/corelib/thread/qfutex_p.h2
-rw-r--r--src/corelib/thread/qfuture.h25
-rw-r--r--src/corelib/thread/qfuture.qdoc195
-rw-r--r--src/corelib/thread/qfuture_impl.h205
-rw-r--r--src/corelib/thread/qfutureinterface.cpp38
-rw-r--r--src/corelib/thread/qfutureinterface.h85
-rw-r--r--src/corelib/thread/qfutureinterface_p.h5
-rw-r--r--src/corelib/thread/qfuturesynchronizer.h2
-rw-r--r--src/corelib/thread/qfuturewatcher.h10
-rw-r--r--src/corelib/thread/qmutex.cpp373
-rw-r--r--src/corelib/thread/qmutex.h247
-rw-r--r--src/corelib/thread/qmutex_linux.cpp11
-rw-r--r--src/corelib/thread/qmutex_p.h16
-rw-r--r--src/corelib/thread/qmutex_win.cpp2
-rw-r--r--src/corelib/thread/qorderedmutexlocker_p.h2
-rw-r--r--src/corelib/thread/qpromise.h18
-rw-r--r--src/corelib/thread/qpromise.qdoc58
-rw-r--r--src/corelib/thread/qresultstore.cpp80
-rw-r--r--src/corelib/thread/qresultstore.h50
-rw-r--r--src/corelib/thread/qrunnable.h11
-rw-r--r--src/corelib/thread/qsemaphore.h3
-rw-r--r--src/corelib/thread/qthread.cpp8
-rw-r--r--src/corelib/thread/qthread.h4
-rw-r--r--src/corelib/thread/qthread_p.h14
-rw-r--r--src/corelib/thread/qthread_unix.cpp2
-rw-r--r--src/corelib/thread/qthreadpool.cpp58
-rw-r--r--src/corelib/thread/qthreadpool.h3
-rw-r--r--src/corelib/thread/qthreadpool_p.h36
-rw-r--r--src/corelib/thread/qthreadstorage.cpp2
-rw-r--r--src/corelib/thread/qthreadstorage.h2
-rw-r--r--src/corelib/thread/qwaitcondition.h2
-rw-r--r--src/corelib/thread/qwaitcondition_p.h4
-rw-r--r--src/corelib/thread/qwaitcondition_unix.cpp11
-rw-r--r--src/corelib/thread/qwaitcondition_win.cpp11
-rw-r--r--src/corelib/time/qcalendar.cpp88
-rw-r--r--src/corelib/time/qdatetime.cpp804
-rw-r--r--src/corelib/time/qdatetime.h118
-rw-r--r--src/corelib/time/qdatetime_p.h6
-rw-r--r--src/corelib/time/qdatetimeparser.cpp249
-rw-r--r--src/corelib/time/qdatetimeparser_p.h18
-rw-r--r--src/corelib/time/qhijricalendar_data_p.h2246
-rw-r--r--src/corelib/time/qjalalicalendar_data_p.h1624
-rw-r--r--src/corelib/time/qromancalendar_data_p.h5156
-rw-r--r--src/corelib/time/qtimezone.cpp21
-rw-r--r--src/corelib/time/qtimezone.h6
-rw-r--r--src/corelib/time/qtimezoneprivate_data_p.h1331
-rw-r--r--src/corelib/time/qtimezoneprivate_p.h6
-rw-r--r--src/corelib/time/qtimezoneprivate_tz.cpp57
-rw-r--r--src/corelib/time/qtimezoneprivate_win.cpp8
-rw-r--r--src/corelib/tools/qalgorithms.qdoc23
-rw-r--r--src/corelib/tools/qarraydata.cpp31
-rw-r--r--src/corelib/tools/qarraydata.h130
-rw-r--r--src/corelib/tools/qarraydataops.h1654
-rw-r--r--src/corelib/tools/qarraydatapointer.h169
-rw-r--r--src/corelib/tools/qbitarray.cpp151
-rw-r--r--src/corelib/tools/qbitarray.h93
-rw-r--r--src/corelib/tools/qcache.h62
-rw-r--r--src/corelib/tools/qcache.qdoc14
-rw-r--r--src/corelib/tools/qcommandlineoption.h2
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp4
-rw-r--r--src/corelib/tools/qcontainerfwd.h34
-rw-r--r--src/corelib/tools/qcontainertools_impl.h136
-rw-r--r--src/corelib/tools/qcontiguouscache.cpp26
-rw-r--r--src/corelib/tools/qcontiguouscache.h9
-rw-r--r--src/corelib/tools/qcryptographichash.cpp63
-rw-r--r--src/corelib/tools/qcryptographichash.h2
-rw-r--r--src/corelib/tools/qduplicatetracker_p.h23
-rw-r--r--src/corelib/tools/qeasingcurve.cpp47
-rw-r--r--src/corelib/tools/qeasingcurve.h11
-rw-r--r--src/corelib/tools/qflatmap_p.h2
-rw-r--r--src/corelib/tools/qfreelist.cpp6
-rw-r--r--src/corelib/tools/qfreelist_p.h5
-rw-r--r--src/corelib/tools/qhash.cpp181
-rw-r--r--src/corelib/tools/qhash.h323
-rw-r--r--src/corelib/tools/qhashfunctions.h18
-rw-r--r--src/corelib/tools/qiterator.h76
-rw-r--r--src/corelib/tools/qiterator.qdoc284
-rw-r--r--src/corelib/tools/qline.cpp39
-rw-r--r--src/corelib/tools/qline.h41
-rw-r--r--src/corelib/tools/qlist.h637
-rw-r--r--src/corelib/tools/qlist.qdoc333
-rw-r--r--src/corelib/tools/qmakearray_p.h8
-rw-r--r--src/corelib/tools/qmap.h240
-rw-r--r--src/corelib/tools/qmap.qdoc80
-rw-r--r--src/corelib/tools/qmargins.cpp34
-rw-r--r--src/corelib/tools/qmargins.h123
-rw-r--r--src/corelib/tools/qmessageauthenticationcode.cpp41
-rw-r--r--src/corelib/tools/qmessageauthenticationcode.h2
-rw-r--r--src/corelib/tools/qmultimap.qdoc119
-rw-r--r--src/corelib/tools/qoffsetstringarray_p.h9
-rw-r--r--src/corelib/tools/qpair.qdoc16
-rw-r--r--src/corelib/tools/qpoint.cpp82
-rw-r--r--src/corelib/tools/qpoint.h312
-rw-r--r--src/corelib/tools/qrect.cpp28
-rw-r--r--src/corelib/tools/qrect.h117
-rw-r--r--src/corelib/tools/qringbuffer_p.h8
-rw-r--r--src/corelib/tools/qscopedpointer.cpp28
-rw-r--r--src/corelib/tools/qscopedpointer.h99
-rw-r--r--src/corelib/tools/qscopedpointer_p.h148
-rw-r--r--src/corelib/tools/qscopedvaluerollback.h18
-rw-r--r--src/corelib/tools/qscopeguard.h13
-rw-r--r--src/corelib/tools/qset.h19
-rw-r--r--src/corelib/tools/qset.qdoc296
-rw-r--r--src/corelib/tools/qshareddata.cpp97
-rw-r--r--src/corelib/tools/qshareddata.h316
-rw-r--r--src/corelib/tools/qshareddata_impl.h11
-rw-r--r--src/corelib/tools/qsharedpointer.h2
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h182
-rw-r--r--src/corelib/tools/qsize.cpp57
-rw-r--r--src/corelib/tools/qsize.h188
-rw-r--r--src/corelib/tools/qtaggedpointer.h11
-rw-r--r--src/corelib/tools/qtaggedpointer.qdoc24
-rw-r--r--src/corelib/tools/qtimeline.cpp4
-rw-r--r--src/corelib/tools/qtools_p.h3
-rw-r--r--src/corelib/tools/qvarlengtharray.h285
-rw-r--r--src/corelib/tools/qvarlengtharray.qdoc62
-rw-r--r--src/corelib/tools/qversionnumber.cpp24
-rw-r--r--src/corelib/tools/qversionnumber.h185
-rw-r--r--src/corelib/tools/tools.pri1
450 files changed, 26300 insertions, 28584 deletions
diff --git a/src/corelib/.prev_CMakeLists.txt b/src/corelib/.prev_CMakeLists.txt
index e024f49c93..653609e73b 100644
--- a/src/corelib/.prev_CMakeLists.txt
+++ b/src/corelib/.prev_CMakeLists.txt
@@ -4,7 +4,7 @@
## Core Module:
#####################################################################
-qt_add_module(Core
+qt_internal_add_module(Core
GENERATE_METATYPES
QMAKE_MODULE_CONFIG moc resources
EXCEPTIONS
@@ -18,11 +18,9 @@ qt_add_module(Core
global/qglobal.cpp global/qglobal.h
global/qglobalstatic.h
global/qhooks.cpp global/qhooks_p.h
- global/qisenum.h
global/qlibraryinfo.cpp global/qlibraryinfo.h
global/qlogging.cpp global/qlogging.h
global/qmalloc.cpp
- global/qmemory_p.h
global/qnamespace.h
global/qnumeric.cpp global/qnumeric.h global/qnumeric_p.h
global/qoperatingsystemversion.cpp global/qoperatingsystemversion.h global/qoperatingsystemversion_p.h
@@ -81,7 +79,7 @@ qt_add_module(Core
kernel/qelapsedtimer.cpp kernel/qelapsedtimer.h
kernel/qeventloop.cpp kernel/qeventloop.h
kernel/qfunctions_p.h
- kernel/qiterable.cpp kernel/qiterable.h kernel/qiterable_p.cpp kernel/qiterable_p.h
+ kernel/qiterable.cpp kernel/qiterable.h kernel/qiterable_p.h
kernel/qmath.cpp kernel/qmath.h
kernel/qmetacontainer.cpp kernel/qmetacontainer.h
kernel/qmetaobject.cpp kernel/qmetaobject.h kernel/qmetaobject_p.h
@@ -204,7 +202,7 @@ qt_add_module(Core
tools/qrect.cpp tools/qrect.h
tools/qrefcount.cpp tools/qrefcount.h
tools/qringbuffer.cpp tools/qringbuffer_p.h
- tools/qscopedpointer.h tools/qscopedpointer_p.h
+ tools/qscopedpointer.h
tools/qscopedvaluerollback.h
tools/qscopeguard.h
tools/qset.h
@@ -233,7 +231,7 @@ qt_add_module(Core
)
-qt_add_simd_part(Core SIMD mips_dsp
+qt_internal_add_simd_part(Core SIMD mips_dsp
SOURCES
../gui/painting/qt_mips_asm_dsp_p.h
text/qstring_mips_dsp_asm.S
@@ -297,12 +295,12 @@ endif()
#### Keys ignored in scope 2:.:.:corelib.pro:QT_FEATURE_gc_binaries:
# MODULE_CONFIG = "gc_binaries"
-qt_extend_target(Core CONDITION NOT QT_NAMESPACE_ISEMPTY
+qt_internal_extend_target(Core CONDITION NOT QT_NAMESPACE_ISEMPTY
PUBLIC_DEFINES
QT_NAMESPACE=
)
-qt_extend_target(Core CONDITION ANDROID
+qt_internal_extend_target(Core CONDITION ANDROID
SOURCES
kernel/qsharedmemory_android.cpp
kernel/qsystemsemaphore_android.cpp
@@ -310,7 +308,7 @@ qt_extend_target(Core CONDITION ANDROID
LIBS_SUFFIX="_${CMAKE_SYSTEM_PROCESSOR}.so"
)
-qt_extend_target(Core CONDITION MSVC AND (TEST_architecture_arch STREQUAL "i386")
+qt_internal_extend_target(Core CONDITION MSVC AND (TEST_architecture_arch STREQUAL "i386")
LINK_OPTIONS
"/BASE:0x67000000"
)
@@ -318,7 +316,7 @@ qt_extend_target(Core CONDITION MSVC AND (TEST_architecture_arch STREQUAL "i386"
#### Keys ignored in scope 6:.:.:corelib.pro:FREEBSD OR OPENBSD:
# QMAKE_LFLAGS_NOUNDEF = <EMPTY>
-qt_extend_target(Core CONDITION QT_FEATURE_animation
+qt_internal_extend_target(Core CONDITION QT_FEATURE_animation
SOURCES
animation/qabstractanimation.cpp animation/qabstractanimation.h animation/qabstractanimation_p.h
animation/qanimationgroup.cpp animation/qanimationgroup.h animation/qanimationgroup_p.h
@@ -329,7 +327,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_animation
animation/qvariantanimation.cpp animation/qvariantanimation.h animation/qvariantanimation_p.h
)
-qt_extend_target(Core CONDITION WIN32
+qt_internal_extend_target(Core CONDITION WIN32
SOURCES
global/qoperatingsystemversion_win.cpp global/qoperatingsystemversion_win_p.h
io/qfilesystemengine_win.cpp
@@ -368,7 +366,7 @@ qt_extend_target(Core CONDITION WIN32
userenv
)
-qt_extend_target(Core CONDITION APPLE
+qt_internal_extend_target(Core CONDITION APPLE
SOURCES
global/qoperatingsystemversion_darwin.mm
io/qfilesystemengine_mac.mm
@@ -385,7 +383,7 @@ qt_extend_target(Core CONDITION APPLE
${FWFoundation}
)
-qt_extend_target(Core CONDITION MACOS
+qt_internal_extend_target(Core CONDITION MACOS
LIBRARIES
${FWAppKit}
${FWApplicationServices}
@@ -396,7 +394,7 @@ qt_extend_target(Core CONDITION MACOS
${FWIOKit}
)
-qt_extend_target(Core CONDITION INTEGRITY
+qt_internal_extend_target(Core CONDITION INTEGRITY
LIBRARIES
ivfs
net
@@ -430,26 +428,26 @@ qt_extend_target(Core CONDITION INTEGRITY
#### Keys ignored in scope 27:.:global:global/global.pri:else:
# f16c_cxx = "false"
-qt_extend_target(Core CONDITION _ss_f16c_cxx
+qt_internal_extend_target(Core CONDITION _ss_f16c_cxx
DEFINES
QFLOAT16_INCLUDE_FAST
)
if(NOT _ss_f16c_cxx)
- qt_add_simd_part(Core SIMD f16c
+ qt_internal_add_simd_part(Core SIMD f16c
SOURCES
global/qfloat16_f16c.c
)
endif()
-qt_extend_target(Core CONDITION NOT CMAKE_CROSSCOMPILING AND NOT _x_-armcc_x_ AND NOT static AND (hurd_x_ OR linux_x_)
+qt_internal_extend_target(Core CONDITION NOT CMAKE_CROSSCOMPILING AND NOT _x_-armcc_x_ AND NOT static AND (hurd_x_ OR linux_x_)
DEFINES
ELF_INTERPRETER=\\\"=Creadelf-l/bin/ls|perl-n-e\'['quote', ['if', ['/program', 'interpreter:', ['.*'], ']/'], '{', 'print', '$1;', '}']]\'\\\"
LINK_OPTIONS
"-Wl,-e,qt_core_boilerplate"
)
-qt_extend_target(Core CONDITION LINUX AND NOT static
+qt_internal_extend_target(Core CONDITION LINUX AND NOT static
SOURCES
global/minimum-linux_p.h
)
@@ -466,17 +464,17 @@ qt_extend_target(Core CONDITION LINUX AND NOT static
#### Keys ignored in scope 35:.:global:global/global.pri:silent:
# no_pch_assembler.commands = "@echo" "compiling[no_pch]" "${QMAKE_FILE_IN}" "&&"
-qt_extend_target(Core CONDITION LINUX AND NOT precompile_header AND NOT static
+qt_internal_extend_target(Core CONDITION LINUX AND NOT precompile_header AND NOT static
SOURCES
global/minimum-linux.S
)
-qt_extend_target(Core CONDITION QT_FEATURE_slog2
+qt_internal_extend_target(Core CONDITION QT_FEATURE_slog2
LIBRARIES
Slog2::Slog2
)
-qt_extend_target(Core CONDITION QT_FEATURE_journald
+qt_internal_extend_target(Core CONDITION QT_FEATURE_journald
LIBRARIES
PkgConfig::Libsystemd
)
@@ -493,12 +491,12 @@ qt_extend_target(Core CONDITION QT_FEATURE_journald
#### Keys ignored in scope 40:.:global:global/global.pri:silent:
# versiontagging_compiler.commands = "@echo" "compiling[versiontagging]" "${QMAKE_FILE_IN}" "&&"
-qt_extend_target(Core CONDITION NOT GCC OR NOT ltcg
+qt_internal_extend_target(Core CONDITION NOT GCC OR NOT ltcg
SOURCES
global/qversiontagging.cpp
)
-qt_extend_target(Core CONDITION UNIX
+qt_internal_extend_target(Core CONDITION UNIX
SOURCES
io/qfilesystemengine_unix.cpp
io/qfilesystemiterator_unix.cpp
@@ -511,7 +509,7 @@ qt_extend_target(Core CONDITION UNIX
thread/qthread_unix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_thread
+qt_internal_extend_target(Core CONDITION QT_FEATURE_thread
SOURCES
thread/qatomic.cpp thread/qatomic.h
thread/qatomic_bootstrap.h
@@ -529,33 +527,33 @@ qt_extend_target(Core CONDITION QT_FEATURE_thread
thread/qthreadstorage.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_thread AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_thread AND WIN32
SOURCES
thread/qmutex_win.cpp
thread/qwaitcondition_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_thread AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_thread AND UNIX
SOURCES
thread/qwaitcondition_unix.cpp
)
-qt_extend_target(Core CONDITION APPLE AND QT_FEATURE_thread
+qt_internal_extend_target(Core CONDITION APPLE AND QT_FEATURE_thread
SOURCES
thread/qmutex_mac.cpp
)
-qt_extend_target(Core CONDITION LINUX AND QT_FEATURE_thread
+qt_internal_extend_target(Core CONDITION LINUX AND QT_FEATURE_thread
SOURCES
thread/qmutex_linux.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_thread AND UNIX AND NOT APPLE AND NOT LINUX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_thread AND UNIX AND NOT APPLE AND NOT LINUX
SOURCES
thread/qmutex_unix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_future
+qt_internal_extend_target(Core CONDITION QT_FEATURE_future
SOURCES
thread/qexception.cpp thread/qexception.h
thread/qfuture.h
@@ -567,23 +565,23 @@ qt_extend_target(Core CONDITION QT_FEATURE_future
thread/qresultstore.cpp thread/qresultstore.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_std_atomic64
+qt_internal_extend_target(Core CONDITION QT_FEATURE_std_atomic64
PUBLIC_LIBRARIES
WrapAtomic::WrapAtomic
)
-qt_extend_target(Core CONDITION ICC
+qt_internal_extend_target(Core CONDITION ICC
COMPILE_OPTIONS
-fp-model
strict
)
-qt_extend_target(Core CONDITION QT_FEATURE_system_zlib
+qt_internal_extend_target(Core CONDITION QT_FEATURE_system_zlib
LIBRARIES
ZLIB::ZLIB
)
-qt_extend_target(Core CONDITION NOT QT_FEATURE_system_zlib
+qt_internal_extend_target(Core CONDITION NOT QT_FEATURE_system_zlib
SOURCES
../3rdparty/zlib/src/adler32.c
../3rdparty/zlib/src/compress.c
@@ -604,18 +602,18 @@ qt_extend_target(Core CONDITION NOT QT_FEATURE_system_zlib
../3rdparty/zlib/src
)
-qt_extend_target(Core CONDITION QT_FEATURE_commandlineparser
+qt_internal_extend_target(Core CONDITION QT_FEATURE_commandlineparser
SOURCES
tools/qcommandlineoption.cpp tools/qcommandlineoption.h
tools/qcommandlineparser.cpp tools/qcommandlineparser.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_system_doubleconversion
+qt_internal_extend_target(Core CONDITION QT_FEATURE_system_doubleconversion
LIBRARIES
WrapDoubleConversion::WrapDoubleConversion
)
-qt_extend_target(Core CONDITION QT_FEATURE_doubleconversion AND NOT QT_FEATURE_system_doubleconversion
+qt_internal_extend_target(Core CONDITION QT_FEATURE_doubleconversion AND NOT QT_FEATURE_system_doubleconversion
SOURCES
../3rdparty/double-conversion/bignum.cc ../3rdparty/double-conversion/bignum.h
../3rdparty/double-conversion/bignum-dtoa.cc ../3rdparty/double-conversion/bignum-dtoa.h
@@ -633,38 +631,38 @@ qt_extend_target(Core CONDITION QT_FEATURE_doubleconversion AND NOT QT_FEATURE_s
../3rdparty/double-conversion/include
)
-qt_extend_target(Core CONDITION QT_FEATURE_system_libb2
+qt_internal_extend_target(Core CONDITION QT_FEATURE_system_libb2
LIBRARIES
PkgConfig::Libb2
)
-qt_extend_target(Core CONDITION QT_FEATURE_easingcurve
+qt_internal_extend_target(Core CONDITION QT_FEATURE_easingcurve
SOURCES
tools/qeasingcurve.cpp tools/qeasingcurve.h
tools/qtimeline.cpp tools/qtimeline.h
)
-qt_extend_target(Core CONDITION UNIX AND NOT HAIKU AND NOT INTEGRITY AND NOT VXWORKS AND NOT WASM AND (NOT ICC OR NOT MACOS)
+qt_internal_extend_target(Core CONDITION UNIX AND NOT HAIKU AND NOT INTEGRITY AND NOT VXWORKS AND NOT WASM AND (NOT ICC OR NOT MACOS)
LIBRARIES
m
)
-qt_extend_target(Core CONDITION APPLE AND NOT NACL
+qt_internal_extend_target(Core CONDITION APPLE AND NOT NACL
SOURCES
text/qlocale_mac.mm
)
-qt_extend_target(Core CONDITION UNIX AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION UNIX AND (NACL OR NOT APPLE)
SOURCES
text/qlocale_unix.cpp
)
-qt_extend_target(Core CONDITION WIN32 AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION WIN32 AND (NACL OR NOT APPLE)
SOURCES
text/qlocale_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_icu
+qt_internal_extend_target(Core CONDITION QT_FEATURE_icu
SOURCES
text/qcollator_icu.cpp
text/qlocale_icu.cpp
@@ -672,159 +670,159 @@ qt_extend_target(Core CONDITION QT_FEATURE_icu
ICU::i18n ICU::uc ICU::data
)
-qt_extend_target(Core CONDITION WIN32 AND NOT QT_FEATURE_icu
+qt_internal_extend_target(Core CONDITION WIN32 AND NOT QT_FEATURE_icu
SOURCES
text/qcollator_win.cpp
)
-qt_extend_target(Core CONDITION MACOS AND NOT QT_FEATURE_icu
+qt_internal_extend_target(Core CONDITION MACOS AND NOT QT_FEATURE_icu
SOURCES
text/qcollator_macx.cpp
)
-qt_extend_target(Core CONDITION UNIX AND NOT MACOS AND NOT QT_FEATURE_icu
+qt_internal_extend_target(Core CONDITION UNIX AND NOT MACOS AND NOT QT_FEATURE_icu
SOURCES
text/qcollator_posix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_regularexpression
+qt_internal_extend_target(Core CONDITION QT_FEATURE_regularexpression
SOURCES
text/qregularexpression.cpp text/qregularexpression.h
LIBRARIES
WrapPCRE2::WrapPCRE2
)
-qt_extend_target(Core CONDITION QT_FEATURE_hijricalendar
+qt_internal_extend_target(Core CONDITION QT_FEATURE_hijricalendar
SOURCES
time/qhijricalendar.cpp time/qhijricalendar_p.h
time/qhijricalendar_data_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_islamiccivilcalendar
+qt_internal_extend_target(Core CONDITION QT_FEATURE_islamiccivilcalendar
SOURCES
time/qislamiccivilcalendar.cpp time/qislamiccivilcalendar_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_jalalicalendar
+qt_internal_extend_target(Core CONDITION QT_FEATURE_jalalicalendar
SOURCES
time/qjalalicalendar.cpp time/qjalalicalendar_p.h
time/qjalalicalendar_data_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_timezone
+qt_internal_extend_target(Core CONDITION QT_FEATURE_timezone
SOURCES
time/qtimezone.cpp time/qtimezone.h
time/qtimezoneprivate.cpp time/qtimezoneprivate_p.h
time/qtimezoneprivate_data_p.h
)
-qt_extend_target(Core CONDITION APPLE AND QT_FEATURE_timezone AND NOT NACL
+qt_internal_extend_target(Core CONDITION APPLE AND QT_FEATURE_timezone AND NOT NACL
SOURCES
time/qtimezoneprivate_mac.mm
)
-qt_extend_target(Core CONDITION ANDROID AND QT_FEATURE_timezone AND NOT ANDROID_EMBEDDED AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION ANDROID AND QT_FEATURE_timezone AND NOT ANDROID_EMBEDDED AND (NACL OR NOT APPLE)
SOURCES
time/qtimezoneprivate_android.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_timezone AND UNIX AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION QT_FEATURE_timezone AND UNIX AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
SOURCES
time/qtimezoneprivate_tz.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_icu AND QT_FEATURE_timezone AND UNIX AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION QT_FEATURE_icu AND QT_FEATURE_timezone AND UNIX AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
SOURCES
time/qtimezoneprivate_icu.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_icu AND QT_FEATURE_timezone AND WIN32 AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION QT_FEATURE_icu AND QT_FEATURE_timezone AND WIN32 AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
SOURCES
time/qtimezoneprivate_icu.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_timezone AND WIN32 AND NOT QT_FEATURE_icu AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION QT_FEATURE_timezone AND WIN32 AND NOT QT_FEATURE_icu AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
SOURCES
time/qtimezoneprivate_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_datetimeparser
+qt_internal_extend_target(Core CONDITION QT_FEATURE_datetimeparser
SOURCES
time/qdatetimeparser.cpp time/qdatetimeparser_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_zstd
+qt_internal_extend_target(Core CONDITION QT_FEATURE_zstd
LIBRARIES
ZSTD::ZSTD
)
-qt_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher
+qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher
SOURCES
io/qfilesystemwatcher.cpp io/qfilesystemwatcher.h io/qfilesystemwatcher_p.h
io/qfilesystemwatcher_polling.cpp io/qfilesystemwatcher_polling_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND WIN32
SOURCES
io/qfilesystemwatcher_win.cpp io/qfilesystemwatcher_win_p.h
)
-qt_extend_target(Core CONDITION MACOS AND QT_FEATURE_filesystemwatcher
+qt_internal_extend_target(Core CONDITION MACOS AND QT_FEATURE_filesystemwatcher
SOURCES
io/qfilesystemwatcher_fsevents.mm io/qfilesystemwatcher_fsevents_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND QT_FEATURE_inotify AND UNIX AND NOT MACOS
+qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND QT_FEATURE_inotify AND UNIX AND NOT MACOS
SOURCES
io/qfilesystemwatcher_inotify.cpp io/qfilesystemwatcher_inotify_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND UNIX AND NOT MACOS AND NOT QT_FEATURE_inotify AND (APPLE OR FREEBSD OR NETBSD OR OPENBSD)
+qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND UNIX AND NOT MACOS AND NOT QT_FEATURE_inotify AND (APPLE OR FREEBSD OR NETBSD OR OPENBSD)
SOURCES
io/qfilesystemwatcher_kqueue.cpp io/qfilesystemwatcher_kqueue_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_processenvironment
+qt_internal_extend_target(Core CONDITION QT_FEATURE_processenvironment
SOURCES
io/qprocess.cpp io/qprocess.h io/qprocess_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_processenvironment AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_processenvironment AND WIN32
SOURCES
io/qprocess_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_processenvironment AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_processenvironment AND UNIX
SOURCES
io/qprocess_unix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_settings
+qt_internal_extend_target(Core CONDITION QT_FEATURE_settings
SOURCES
io/qsettings.cpp io/qsettings.h io/qsettings_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_settings AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_settings AND WIN32
SOURCES
io/qsettings_win.cpp
)
-qt_extend_target(Core CONDITION APPLE AND QT_FEATURE_settings AND NOT NACL
+qt_internal_extend_target(Core CONDITION APPLE AND QT_FEATURE_settings AND NOT NACL
SOURCES
io/qsettings_mac.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_settings AND WASM
+qt_internal_extend_target(Core CONDITION QT_FEATURE_settings AND WASM
SOURCES
io/qsettings_wasm.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_filesystemiterator AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemiterator AND WIN32
SOURCES
io/qfilesystemiterator_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_process AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_process AND UNIX
SOURCES
../3rdparty/forkfd/forkfd.h
io/forkfd_qt.cpp
@@ -832,22 +830,22 @@ qt_extend_target(Core CONDITION QT_FEATURE_process AND UNIX
../3rdparty/forkfd
)
-qt_extend_target(Core CONDITION APPLE AND QT_FEATURE_processenvironment
+qt_internal_extend_target(Core CONDITION APPLE AND QT_FEATURE_processenvironment
SOURCES
io/qprocess_darwin.mm
)
-qt_extend_target(Core CONDITION APPLE AND NOT MACOS
+qt_internal_extend_target(Core CONDITION APPLE AND NOT MACOS
PUBLIC_LIBRARIES
${FWMobileCoreServices}
)
-qt_extend_target(Core CONDITION UNIX AND NOT APPLE
+qt_internal_extend_target(Core CONDITION UNIX AND NOT APPLE
SOURCES
kernel/qelapsedtimer_unix.cpp
)
-qt_extend_target(Core CONDITION ANDROID AND NOT ANDROID_EMBEDDED
+qt_internal_extend_target(Core CONDITION ANDROID AND NOT ANDROID_EMBEDDED
SOURCES
io/qstandardpaths_android.cpp
io/qstorageinfo_unix.cpp
@@ -856,7 +854,7 @@ qt_extend_target(Core CONDITION ANDROID AND NOT ANDROID_EMBEDDED
kernel/qjnionload.cpp
)
-qt_extend_target(Core CONDITION HAIKU AND (ANDROID_EMBEDDED OR NOT ANDROID)
+qt_internal_extend_target(Core CONDITION HAIKU AND (ANDROID_EMBEDDED OR NOT ANDROID)
SOURCES
io/qstandardpaths_haiku.cpp
io/qstorageinfo_unix.cpp
@@ -864,92 +862,92 @@ qt_extend_target(Core CONDITION HAIKU AND (ANDROID_EMBEDDED OR NOT ANDROID)
be
)
-qt_extend_target(Core CONDITION UNIX AND NOT APPLE AND NOT HAIKU AND (ANDROID_EMBEDDED OR NOT ANDROID)
+qt_internal_extend_target(Core CONDITION UNIX AND NOT APPLE AND NOT HAIKU AND (ANDROID_EMBEDDED OR NOT ANDROID)
SOURCES
io/qstandardpaths_unix.cpp
io/qstorageinfo_unix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_proxymodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_proxymodel
SOURCES
itemmodels/qabstractproxymodel.cpp itemmodels/qabstractproxymodel.h itemmodels/qabstractproxymodel_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_concatenatetablesproxymodel AND QT_FEATURE_proxymodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_concatenatetablesproxymodel AND QT_FEATURE_proxymodel
SOURCES
itemmodels/qconcatenatetablesproxymodel.cpp itemmodels/qconcatenatetablesproxymodel.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_identityproxymodel AND QT_FEATURE_proxymodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_identityproxymodel AND QT_FEATURE_proxymodel
SOURCES
itemmodels/qidentityproxymodel.cpp itemmodels/qidentityproxymodel.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_proxymodel AND QT_FEATURE_sortfilterproxymodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_proxymodel AND QT_FEATURE_sortfilterproxymodel
SOURCES
itemmodels/qsortfilterproxymodel.cpp itemmodels/qsortfilterproxymodel.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_proxymodel AND QT_FEATURE_transposeproxymodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_proxymodel AND QT_FEATURE_transposeproxymodel
SOURCES
itemmodels/qtransposeproxymodel.cpp itemmodels/qtransposeproxymodel.h itemmodels/qtransposeproxymodel_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_stringlistmodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_stringlistmodel
SOURCES
itemmodels/qstringlistmodel.cpp itemmodels/qstringlistmodel.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_library
+qt_internal_extend_target(Core CONDITION QT_FEATURE_library
SOURCES
plugin/qelfparser_p.cpp plugin/qelfparser_p.h
plugin/qlibrary.cpp plugin/qlibrary.h plugin/qlibrary_p.h
plugin/qmachparser.cpp plugin/qmachparser_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_library AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_library AND UNIX
SOURCES
plugin/qlibrary_unix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_library AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_library AND WIN32
SOURCES
plugin/qlibrary_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_dlopen AND QT_FEATURE_library
+qt_internal_extend_target(Core CONDITION QT_FEATURE_dlopen AND QT_FEATURE_library
LIBRARIES
${CMAKE_DL_LIBS}
)
-qt_extend_target(Core CONDITION APPLE AND (IOS OR TVOS)
+qt_internal_extend_target(Core CONDITION APPLE AND (IOS OR TVOS)
LIBRARIES
${FWUIKit}
)
-qt_extend_target(Core CONDITION WATCHOS
+qt_internal_extend_target(Core CONDITION WATCHOS
LIBRARIES
${FWWatchKit}
)
-qt_extend_target(Core CONDITION QT_FEATURE_poll_select AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_poll_select AND UNIX
SOURCES
kernel/qpoll.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_glib AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_glib AND UNIX
SOURCES
kernel/qeventdispatcher_glib.cpp kernel/qeventdispatcher_glib_p.h
LIBRARIES
GLIB2::GLIB2
)
-qt_extend_target(Core CONDITION QT_FEATURE_clock_gettime AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_clock_gettime AND UNIX
LIBRARIES
WrapRt::WrapRt
)
-qt_extend_target(Core CONDITION UNIX AND NOT ANDROID
+qt_internal_extend_target(Core CONDITION UNIX AND NOT ANDROID
SOURCES
kernel/qsharedmemory_posix.cpp
kernel/qsharedmemory_systemv.cpp
@@ -959,32 +957,22 @@ qt_extend_target(Core CONDITION UNIX AND NOT ANDROID
kernel/qsystemsemaphore_unix.cpp
)
-qt_extend_target(Core CONDITION VXWORKS
+qt_internal_extend_target(Core CONDITION VXWORKS
SOURCES
kernel/qfunctions_vxworks.cpp kernel/qfunctions_vxworks.h
)
-qt_extend_target(Core CONDITION QNX AND QT_FEATURE_qqnx_pps
- SOURCES
- kernel/qppsattribute.cpp kernel/qppsattribute_p.h
- kernel/qppsattributeprivate_p.h
- kernel/qppsobject.cpp kernel/qppsobject_p.h
- kernel/qppsobjectprivate_p.h
- LIBRARIES
- PPS::PPS
-)
-
-qt_extend_target(Core CONDITION QT_FEATURE_cborstreamreader
+qt_internal_extend_target(Core CONDITION QT_FEATURE_cborstreamreader
SOURCES
serialization/qcborstreamreader.cpp serialization/qcborstreamreader.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_cborstreamwriter
+qt_internal_extend_target(Core CONDITION QT_FEATURE_cborstreamwriter
SOURCES
serialization/qcborstreamwriter.cpp serialization/qcborstreamwriter.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_mimetype
+qt_internal_extend_target(Core CONDITION QT_FEATURE_mimetype
SOURCES
mimetypes/qmimedatabase.cpp mimetypes/qmimedatabase.h mimetypes/qmimedatabase_p.h
mimetypes/qmimeglobpattern.cpp mimetypes/qmimeglobpattern_p.h
@@ -995,16 +983,16 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype
mimetypes/qmimetypeparser.cpp mimetypes/qmimetypeparser_p.h
)
-#### Keys ignored in scope 172:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype:
+#### Keys ignored in scope 171:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype:
# MIME_DATABASE = "mimetypes/mime/packages/freedesktop.org.xml"
# OTHER_FILES = "$$MIME_DATABASE"
-qt_extend_target(Core CONDITION QT_FEATURE_mimetype AND QT_FEATURE_mimetype_database
+qt_internal_extend_target(Core CONDITION QT_FEATURE_mimetype AND QT_FEATURE_mimetype_database
INCLUDE_DIRECTORIES
.rcc
)
-#### Keys ignored in scope 173:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database:
+#### Keys ignored in scope 172:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database:
# QMAKE_EXTRA_COMPILERS = "mimedb"
# mimedb.commands = "${QMAKE_FILE_IN}" ">" "${QMAKE_FILE_OUT}"
# mimedb.depends = "$$PWD/mime/generate.pl"
@@ -1012,33 +1000,33 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype AND QT_FEATURE_mimetype_data
# mimedb.output = "$$outpath/qmimeprovider_database.cpp"
# mimedb.variable_out = "INCLUDED_SOURCES"
-#### Keys ignored in scope 174:.:mimetypes:mimetypes/mimetypes.pri:ANDROID:
+#### Keys ignored in scope 173:.:mimetypes:mimetypes/mimetypes.pri:ANDROID:
# outpath = "$$outpath/$${QT_ARCH}"
-#### Keys ignored in scope 176:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug):
+#### Keys ignored in scope 175:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug):
# outpath = "$$outpath/debug"
-#### Keys ignored in scope 177:.:mimetypes:mimetypes/mimetypes.pri:else:
+#### Keys ignored in scope 176:.:mimetypes:mimetypes/mimetypes.pri:else:
# outpath = "$$outpath/release"
-#### Keys ignored in scope 178:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY:
+#### Keys ignored in scope 177:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY:
# mimedb.commands = "cmd" "/c" "$$shell_path($$PWD/mime/generate.bat)"
# mimedb.depends = "$$PWD/mime/generate.bat" "$$PWD/mime/hexdump.ps1"
-#### Keys ignored in scope 179:.:mimetypes:mimetypes/mimetypes.pri:else:
+#### Keys ignored in scope 178:.:mimetypes:mimetypes/mimetypes.pri:else:
# mimedb.commands = "perl" "$${mimedb.depends}"
-#### Keys ignored in scope 180:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd:
+#### Keys ignored in scope 179:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd:
# mimedb.commands = "--zstd"
-qt_extend_target(Core CONDITION WASM
+qt_internal_extend_target(Core CONDITION WASM
SOURCES
platform/wasm/qstdweb.cpp platform/wasm/qstdweb_p.h
)
-qt_create_tracepoints(Core qtcore.tracepoints)
-qt_add_docs(Core
+qt_internal_create_tracepoints(Core qtcore.tracepoints)
+qt_internal_add_docs(Core
doc/qtcore.qdocconf
)
diff --git a/src/corelib/.prev_configure.cmake b/src/corelib/.prev_configure.cmake
index b410879c45..1218f552cb 100644
--- a/src/corelib/.prev_configure.cmake
+++ b/src/corelib/.prev_configure.cmake
@@ -637,8 +637,8 @@ qt_feature("mimetype-database" PRIVATE
)
qt_feature("pcre2"
LABEL "PCRE2"
- ENABLE INPUT_pcre STREQUAL 'qt'
- DISABLE INPUT_pcre STREQUAL 'no' OR INPUT_pcre STREQUAL 'system'
+ ENABLE INPUT_pcre STREQUAL 'qt' OR QT_FEATURE_system_pcre2
+ DISABLE INPUT_pcre STREQUAL 'no'
)
qt_feature_config("pcre2" QMAKE_PRIVATE_CONFIG)
qt_feature("system-pcre2" PRIVATE
@@ -930,7 +930,7 @@ qt_feature("etw" PRIVATE
DISABLE INPUT_trace STREQUAL 'lttng' OR INPUT_trace STREQUAL 'no'
)
qt_feature("forkfd_pidfd" PRIVATE
- LABEL "pidfd support in forkfd"
+ LABEL "CLONE_PIDFD support in forkfd"
CONDITION LINUX
)
qt_feature("win32_system_libs"
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 7a9256daf8..c14bcf91bb 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -26,12 +26,13 @@ endif()
## Core Module:
#####################################################################
-qt_add_module(Core
+qt_internal_add_module(Core
GENERATE_METATYPES
QMAKE_MODULE_CONFIG moc resources
EXCEPTIONS
SOURCES
global/archdetect.cpp
+ global/qcompare.h
global/qcompilerdetection.h
global/qcontainerinfo.h
global/qendian.cpp global/qendian.h global/qendian_p.h
@@ -40,11 +41,9 @@ qt_add_module(Core
global/qglobal.cpp global/qglobal.h
global/qglobalstatic.h
global/qhooks.cpp global/qhooks_p.h
- global/qisenum.h
global/qlibraryinfo.cpp global/qlibraryinfo.h
global/qlogging.cpp global/qlogging.h
global/qmalloc.cpp
- global/qmemory_p.h
# global/qnamespace.h # special case
global/qnumeric.cpp global/qnumeric.h global/qnumeric_p.h
global/qoperatingsystemversion.cpp global/qoperatingsystemversion.h global/qoperatingsystemversion_p.h
@@ -103,7 +102,7 @@ qt_add_module(Core
kernel/qelapsedtimer.cpp kernel/qelapsedtimer.h
kernel/qeventloop.cpp kernel/qeventloop.h
kernel/qfunctions_p.h
- kernel/qiterable.cpp kernel/qiterable.h kernel/qiterable_p.cpp kernel/qiterable_p.h
+ kernel/qiterable.cpp kernel/qiterable.h kernel/qiterable_p.h
kernel/qmath.cpp kernel/qmath.h
kernel/qmetacontainer.cpp kernel/qmetacontainer.h
kernel/qmetaobject.cpp kernel/qmetaobject.h kernel/qmetaobject_p.h
@@ -226,7 +225,7 @@ qt_add_module(Core
tools/qrect.cpp tools/qrect.h
tools/qrefcount.cpp tools/qrefcount.h
tools/qringbuffer.cpp tools/qringbuffer_p.h
- tools/qscopedpointer.h tools/qscopedpointer_p.h
+ tools/qscopedpointer.h
tools/qscopedvaluerollback.h
tools/qscopeguard.h
tools/qset.h
@@ -260,6 +259,7 @@ qt_add_module(Core
# Generated in QtBaseGlobalTargets
EXTRA_CMAKE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/Qt6CTestMacros.cmake"
+ "${CMAKE_CURRENT_SOURCE_DIR}/Qt6CoreConfigureFileTemplate.in"
${corelib_extra_cmake_files}
# special case end
)
@@ -287,7 +287,7 @@ endif()
# Handle QObject: Automoc does not work for this as it would
# require to spill internals into users:
-qt_add_module(Core_qobject STATIC
+qt_internal_add_module(Core_qobject STATIC
NO_SYNC_QT
NO_CONFIG_HEADER_FILE
NO_MODULE_HEADERS
@@ -307,7 +307,7 @@ set_target_properties(Core_qobject PROPERTIES
)
target_include_directories(Core_qobject PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/kernel") # for moc_qobject.cpp
target_link_libraries(Core_qobject PRIVATE Qt::Platform Qt::GlobalConfig)
-extend_target(Core LIBRARIES Qt::Core_qobject)
+qt_internal_extend_target(Core LIBRARIES Qt::Core_qobject)
add_dependencies(Core_qobject ${QT_CMAKE_EXPORT_NAMESPACE}::moc)
set(core_qobject_metatypes_json_args)
@@ -315,7 +315,7 @@ if (NOT QT_WILL_INSTALL)
set(core_qobject_metatypes_json_args INSTALL_DIR "${QT_BUILD_DIR}/${INSTALL_LIBDIR}/metatypes")
endif()
-qt6_generate_meta_types_json_file(Core_qobject
+qt6_extract_metatypes(Core_qobject
MANUAL_MOC_JSON_FILES ${core_qobject_metatypes_json_list}
${core_qobject_metatypes_json_args}
)
@@ -355,7 +355,7 @@ if (LINUX AND NOT CMAKE_CROSSCOMPILING AND BUILD_SHARED_LIBS)
endif()
# special case end
-qt_add_simd_part(Core SIMD mips_dsp
+qt_internal_add_simd_part(Core SIMD mips_dsp
SOURCES
../gui/painting/qt_mips_asm_dsp_p.h
text/qstring_mips_dsp_asm.S
@@ -368,7 +368,7 @@ endif()
if(ANDROID)
set_property(TARGET Core APPEND PROPERTY QT_ANDROID_BUNDLED_JAR_DEPENDENCIES
- jar/QtAndroid.jar
+ jar/Qt${QtBase_VERSION_MAJOR}Android.jar # special case
)
set_property(TARGET Core APPEND PROPERTY QT_ANDROID_LIB_DEPENDENCIES
plugins/platforms/libplugins_platforms_qtforandroid.so
@@ -421,13 +421,13 @@ endif()
# special case begin
# remove because it's handled manually
-#qt_extend_target(Core CONDITION NOT QT_NAMESPACE_ISEMPTY
+#qt_internal_extend_target(Core CONDITION NOT QT_NAMESPACE_ISEMPTY
# PUBLIC_DEFINES
# QT_NAMESPACE=
#)
# special case end
-qt_extend_target(Core CONDITION ANDROID
+qt_internal_extend_target(Core CONDITION ANDROID
SOURCES
kernel/qsharedmemory_android.cpp
kernel/qsystemsemaphore_android.cpp
@@ -435,7 +435,7 @@ qt_extend_target(Core CONDITION ANDROID
LIBS_SUFFIX="_${ANDROID_ABI}.so" # special case
)
-qt_extend_target(Core CONDITION MSVC AND (TEST_architecture_arch STREQUAL "i386")
+qt_internal_extend_target(Core CONDITION MSVC AND (TEST_architecture_arch STREQUAL "i386")
LINK_OPTIONS
"/BASE:0x67000000"
)
@@ -443,7 +443,7 @@ qt_extend_target(Core CONDITION MSVC AND (TEST_architecture_arch STREQUAL "i386"
#### Keys ignored in scope 6:.:.:corelib.pro:FREEBSD OR OPENBSD:
# QMAKE_LFLAGS_NOUNDEF = <EMPTY>
-qt_extend_target(Core CONDITION QT_FEATURE_animation
+qt_internal_extend_target(Core CONDITION QT_FEATURE_animation
SOURCES
animation/qabstractanimation.cpp animation/qabstractanimation.h animation/qabstractanimation_p.h
animation/qanimationgroup.cpp animation/qanimationgroup.h animation/qanimationgroup_p.h
@@ -454,7 +454,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_animation
animation/qvariantanimation.cpp animation/qvariantanimation.h animation/qvariantanimation_p.h
)
-qt_extend_target(Core CONDITION WIN32
+qt_internal_extend_target(Core CONDITION WIN32
SOURCES
global/qoperatingsystemversion_win.cpp global/qoperatingsystemversion_win_p.h
io/qfilesystemengine_win.cpp
@@ -492,7 +492,7 @@ qt_extend_target(Core CONDITION WIN32
userenv
)
-qt_extend_target(Core CONDITION APPLE
+qt_internal_extend_target(Core CONDITION APPLE
SOURCES
global/qoperatingsystemversion_darwin.mm
io/qfilesystemengine_mac.mm
@@ -509,7 +509,7 @@ qt_extend_target(Core CONDITION APPLE
${FWFoundation}
)
-qt_extend_target(Core CONDITION MACOS
+qt_internal_extend_target(Core CONDITION MACOS
LIBRARIES
${FWAppKit}
${FWApplicationServices}
@@ -520,7 +520,7 @@ qt_extend_target(Core CONDITION MACOS
${FWIOKit}
)
-qt_extend_target(Core CONDITION INTEGRITY
+qt_internal_extend_target(Core CONDITION INTEGRITY
LIBRARIES
ivfs
net
@@ -554,11 +554,11 @@ qt_extend_target(Core CONDITION INTEGRITY
#### Keys ignored in scope 27:.:global:global/global.pri:else:
# f16c_cxx = "false"
-# extend_target(Core CONDITION _ss_f16c_cxx ... # special case remove: Handled manually
+# qt_internal_extend_target(Core CONDITION _ss_f16c_cxx ... # special case remove: Handled manually
# special case begin
# Remove this because it's handled manually
-#extend_target(Core CONDITION NOT _x_-armcc_x_ AND NOT cross_compile AND NOT static AND (hurd_x_ OR linux_x_)
+#qt_internal_extend_target(Core CONDITION NOT _x_-armcc_x_ AND NOT cross_compile AND NOT static AND (hurd_x_ OR linux_x_)
# DEFINES
# ELF_INTERPRETER=\\\"=Creadelf-l/bin/ls|perl-n-e\'['quote', ['if', ['/program', 'interpreter:', ['.*'], ']/'], '{', 'print', '$1;', '}']]\'\\\"
# LINK_OPTIONS
@@ -566,7 +566,7 @@ qt_extend_target(Core CONDITION INTEGRITY
#)
# special case end
-qt_extend_target(Core CONDITION LINUX AND NOT static
+qt_internal_extend_target(Core CONDITION LINUX AND NOT static
SOURCES
global/minimum-linux_p.h
)
@@ -583,17 +583,17 @@ qt_extend_target(Core CONDITION LINUX AND NOT static
#### Keys ignored in scope 35:.:global:global/global.pri:silent:
# no_pch_assembler.commands = "@echo" "compiling[no_pch]" "${QMAKE_FILE_IN}" "&&"
-qt_extend_target(Core CONDITION LINUX AND NOT precompile_header AND NOT static
+qt_internal_extend_target(Core CONDITION LINUX AND NOT precompile_header AND NOT static
SOURCES
global/minimum-linux.S
)
-qt_extend_target(Core CONDITION QT_FEATURE_slog2
+qt_internal_extend_target(Core CONDITION QT_FEATURE_slog2
LIBRARIES
Slog2::Slog2
)
-qt_extend_target(Core CONDITION QT_FEATURE_journald
+qt_internal_extend_target(Core CONDITION QT_FEATURE_journald
LIBRARIES
PkgConfig::Libsystemd
)
@@ -610,12 +610,12 @@ qt_extend_target(Core CONDITION QT_FEATURE_journald
#### Keys ignored in scope 40:.:global:global/global.pri:silent:
# versiontagging_compiler.commands = "@echo" "compiling[versiontagging]" "${QMAKE_FILE_IN}" "&&"
-qt_extend_target(Core CONDITION NOT GCC OR NOT ltcg
+qt_internal_extend_target(Core CONDITION NOT GCC OR NOT ltcg
SOURCES
global/qversiontagging.cpp
)
-qt_extend_target(Core CONDITION UNIX
+qt_internal_extend_target(Core CONDITION UNIX
SOURCES
io/qfilesystemengine_unix.cpp
io/qfilesystemiterator_unix.cpp
@@ -628,7 +628,7 @@ qt_extend_target(Core CONDITION UNIX
thread/qthread_unix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_thread
+qt_internal_extend_target(Core CONDITION QT_FEATURE_thread
SOURCES
thread/qatomic.cpp thread/qatomic.h
thread/qatomic_bootstrap.h
@@ -646,33 +646,33 @@ qt_extend_target(Core CONDITION QT_FEATURE_thread
thread/qthreadstorage.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_thread AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_thread AND WIN32
SOURCES
thread/qmutex_win.cpp
thread/qwaitcondition_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_thread AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_thread AND UNIX
SOURCES
thread/qwaitcondition_unix.cpp
)
-qt_extend_target(Core CONDITION APPLE AND QT_FEATURE_thread
+qt_internal_extend_target(Core CONDITION APPLE AND QT_FEATURE_thread
SOURCES
thread/qmutex_mac.cpp
)
-qt_extend_target(Core CONDITION LINUX AND QT_FEATURE_thread
+qt_internal_extend_target(Core CONDITION LINUX AND QT_FEATURE_thread
SOURCES
thread/qmutex_linux.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_thread AND UNIX AND NOT APPLE AND NOT LINUX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_thread AND UNIX AND NOT APPLE AND NOT LINUX
SOURCES
thread/qmutex_unix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_future
+qt_internal_extend_target(Core CONDITION QT_FEATURE_future
SOURCES
thread/qexception.cpp thread/qexception.h
thread/qfuture.h
@@ -684,23 +684,23 @@ qt_extend_target(Core CONDITION QT_FEATURE_future
thread/qresultstore.cpp thread/qresultstore.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_std_atomic64
+qt_internal_extend_target(Core CONDITION QT_FEATURE_std_atomic64
PUBLIC_LIBRARIES
WrapAtomic::WrapAtomic
)
-qt_extend_target(Core CONDITION ICC
+qt_internal_extend_target(Core CONDITION ICC
COMPILE_OPTIONS
-fp-model
strict
)
-qt_extend_target(Core CONDITION QT_FEATURE_system_zlib
+qt_internal_extend_target(Core CONDITION QT_FEATURE_system_zlib
LIBRARIES
ZLIB::ZLIB
)
-qt_extend_target(Core CONDITION NOT QT_FEATURE_system_zlib
+qt_internal_extend_target(Core CONDITION NOT QT_FEATURE_system_zlib
SOURCES
../3rdparty/zlib/src/adler32.c
../3rdparty/zlib/src/compress.c
@@ -721,18 +721,18 @@ qt_extend_target(Core CONDITION NOT QT_FEATURE_system_zlib
../3rdparty/zlib/src
)
-qt_extend_target(Core CONDITION QT_FEATURE_commandlineparser
+qt_internal_extend_target(Core CONDITION QT_FEATURE_commandlineparser
SOURCES
tools/qcommandlineoption.cpp tools/qcommandlineoption.h
tools/qcommandlineparser.cpp tools/qcommandlineparser.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_system_doubleconversion
+qt_internal_extend_target(Core CONDITION QT_FEATURE_system_doubleconversion
LIBRARIES
WrapDoubleConversion::WrapDoubleConversion
)
-qt_extend_target(Core CONDITION QT_FEATURE_doubleconversion AND NOT QT_FEATURE_system_doubleconversion
+qt_internal_extend_target(Core CONDITION QT_FEATURE_doubleconversion AND NOT QT_FEATURE_system_doubleconversion
SOURCES
../3rdparty/double-conversion/bignum.cc ../3rdparty/double-conversion/bignum.h
../3rdparty/double-conversion/bignum-dtoa.cc ../3rdparty/double-conversion/bignum-dtoa.h
@@ -750,38 +750,38 @@ qt_extend_target(Core CONDITION QT_FEATURE_doubleconversion AND NOT QT_FEATURE_s
../3rdparty/double-conversion/include
)
-qt_extend_target(Core CONDITION QT_FEATURE_system_libb2
+qt_internal_extend_target(Core CONDITION QT_FEATURE_system_libb2
LIBRARIES
PkgConfig::Libb2
)
-qt_extend_target(Core CONDITION QT_FEATURE_easingcurve
+qt_internal_extend_target(Core CONDITION QT_FEATURE_easingcurve
SOURCES
tools/qeasingcurve.cpp tools/qeasingcurve.h
tools/qtimeline.cpp tools/qtimeline.h
)
-qt_extend_target(Core CONDITION UNIX AND NOT HAIKU AND NOT INTEGRITY AND NOT VXWORKS AND NOT WASM AND (NOT ICC OR NOT MACOS)
+qt_internal_extend_target(Core CONDITION UNIX AND NOT HAIKU AND NOT INTEGRITY AND NOT VXWORKS AND NOT WASM AND (NOT ICC OR NOT MACOS)
LIBRARIES
m
)
-qt_extend_target(Core CONDITION APPLE AND NOT NACL
+qt_internal_extend_target(Core CONDITION APPLE AND NOT NACL
SOURCES
text/qlocale_mac.mm
)
-qt_extend_target(Core CONDITION UNIX AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION UNIX AND (NACL OR NOT APPLE)
SOURCES
text/qlocale_unix.cpp
)
-qt_extend_target(Core CONDITION WIN32 AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION WIN32 AND (NACL OR NOT APPLE)
SOURCES
text/qlocale_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_icu
+qt_internal_extend_target(Core CONDITION QT_FEATURE_icu
SOURCES
text/qcollator_icu.cpp
text/qlocale_icu.cpp
@@ -789,159 +789,159 @@ qt_extend_target(Core CONDITION QT_FEATURE_icu
ICU::i18n ICU::uc ICU::data
)
-qt_extend_target(Core CONDITION WIN32 AND NOT QT_FEATURE_icu
+qt_internal_extend_target(Core CONDITION WIN32 AND NOT QT_FEATURE_icu
SOURCES
text/qcollator_win.cpp
)
-qt_extend_target(Core CONDITION MACOS AND NOT QT_FEATURE_icu
+qt_internal_extend_target(Core CONDITION MACOS AND NOT QT_FEATURE_icu
SOURCES
text/qcollator_macx.cpp
)
-qt_extend_target(Core CONDITION UNIX AND NOT MACOS AND NOT QT_FEATURE_icu
+qt_internal_extend_target(Core CONDITION UNIX AND NOT MACOS AND NOT QT_FEATURE_icu
SOURCES
text/qcollator_posix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_regularexpression
+qt_internal_extend_target(Core CONDITION QT_FEATURE_regularexpression
SOURCES
text/qregularexpression.cpp text/qregularexpression.h
LIBRARIES
WrapPCRE2::WrapPCRE2
)
-qt_extend_target(Core CONDITION QT_FEATURE_hijricalendar
+qt_internal_extend_target(Core CONDITION QT_FEATURE_hijricalendar
SOURCES
time/qhijricalendar.cpp time/qhijricalendar_p.h
time/qhijricalendar_data_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_islamiccivilcalendar
+qt_internal_extend_target(Core CONDITION QT_FEATURE_islamiccivilcalendar
SOURCES
time/qislamiccivilcalendar.cpp time/qislamiccivilcalendar_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_jalalicalendar
+qt_internal_extend_target(Core CONDITION QT_FEATURE_jalalicalendar
SOURCES
time/qjalalicalendar.cpp time/qjalalicalendar_p.h
time/qjalalicalendar_data_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_timezone
+qt_internal_extend_target(Core CONDITION QT_FEATURE_timezone
SOURCES
time/qtimezone.cpp time/qtimezone.h
time/qtimezoneprivate.cpp time/qtimezoneprivate_p.h
time/qtimezoneprivate_data_p.h
)
-qt_extend_target(Core CONDITION APPLE AND QT_FEATURE_timezone AND NOT NACL
+qt_internal_extend_target(Core CONDITION APPLE AND QT_FEATURE_timezone AND NOT NACL
SOURCES
time/qtimezoneprivate_mac.mm
)
-qt_extend_target(Core CONDITION ANDROID AND QT_FEATURE_timezone AND NOT ANDROID_EMBEDDED AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION ANDROID AND QT_FEATURE_timezone AND NOT ANDROID_EMBEDDED AND (NACL OR NOT APPLE)
SOURCES
time/qtimezoneprivate_android.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_timezone AND UNIX AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION QT_FEATURE_timezone AND UNIX AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
SOURCES
time/qtimezoneprivate_tz.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_icu AND QT_FEATURE_timezone AND UNIX AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION QT_FEATURE_icu AND QT_FEATURE_timezone AND UNIX AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
SOURCES
time/qtimezoneprivate_icu.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_icu AND QT_FEATURE_timezone AND WIN32 AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION QT_FEATURE_icu AND QT_FEATURE_timezone AND WIN32 AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
SOURCES
time/qtimezoneprivate_icu.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_timezone AND WIN32 AND NOT QT_FEATURE_icu AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
+qt_internal_extend_target(Core CONDITION QT_FEATURE_timezone AND WIN32 AND NOT QT_FEATURE_icu AND (ANDROID_EMBEDDED OR NOT ANDROID) AND (NACL OR NOT APPLE)
SOURCES
time/qtimezoneprivate_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_datetimeparser
+qt_internal_extend_target(Core CONDITION QT_FEATURE_datetimeparser
SOURCES
time/qdatetimeparser.cpp time/qdatetimeparser_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_zstd
+qt_internal_extend_target(Core CONDITION QT_FEATURE_zstd
LIBRARIES
ZSTD::ZSTD
)
-qt_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher
+qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher
SOURCES
io/qfilesystemwatcher.cpp io/qfilesystemwatcher.h io/qfilesystemwatcher_p.h
io/qfilesystemwatcher_polling.cpp io/qfilesystemwatcher_polling_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND WIN32
SOURCES
io/qfilesystemwatcher_win.cpp io/qfilesystemwatcher_win_p.h
)
-qt_extend_target(Core CONDITION MACOS AND QT_FEATURE_filesystemwatcher
+qt_internal_extend_target(Core CONDITION MACOS AND QT_FEATURE_filesystemwatcher
SOURCES
io/qfilesystemwatcher_fsevents.mm io/qfilesystemwatcher_fsevents_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND QT_FEATURE_inotify AND UNIX AND NOT MACOS
+qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND QT_FEATURE_inotify AND UNIX AND NOT MACOS
SOURCES
io/qfilesystemwatcher_inotify.cpp io/qfilesystemwatcher_inotify_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND UNIX AND NOT MACOS AND NOT QT_FEATURE_inotify AND (APPLE OR FREEBSD OR NETBSD OR OPENBSD)
+qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher AND UNIX AND NOT MACOS AND NOT QT_FEATURE_inotify AND (APPLE OR FREEBSD OR NETBSD OR OPENBSD)
SOURCES
io/qfilesystemwatcher_kqueue.cpp io/qfilesystemwatcher_kqueue_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_processenvironment
+qt_internal_extend_target(Core CONDITION QT_FEATURE_processenvironment
SOURCES
io/qprocess.cpp io/qprocess.h io/qprocess_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_processenvironment AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_processenvironment AND WIN32
SOURCES
io/qprocess_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_processenvironment AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_processenvironment AND UNIX
SOURCES
io/qprocess_unix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_settings
+qt_internal_extend_target(Core CONDITION QT_FEATURE_settings
SOURCES
io/qsettings.cpp io/qsettings.h io/qsettings_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_settings AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_settings AND WIN32
SOURCES
io/qsettings_win.cpp
)
-qt_extend_target(Core CONDITION APPLE AND QT_FEATURE_settings AND NOT NACL
+qt_internal_extend_target(Core CONDITION APPLE AND QT_FEATURE_settings AND NOT NACL
SOURCES
io/qsettings_mac.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_settings AND WASM
+qt_internal_extend_target(Core CONDITION QT_FEATURE_settings AND WASM
SOURCES
io/qsettings_wasm.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_filesystemiterator AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemiterator AND WIN32
SOURCES
io/qfilesystemiterator_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_process AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_process AND UNIX
SOURCES
../3rdparty/forkfd/forkfd.h
io/forkfd_qt.cpp
@@ -949,22 +949,22 @@ qt_extend_target(Core CONDITION QT_FEATURE_process AND UNIX
../3rdparty/forkfd
)
-qt_extend_target(Core CONDITION APPLE AND QT_FEATURE_processenvironment
+qt_internal_extend_target(Core CONDITION APPLE AND QT_FEATURE_processenvironment
SOURCES
io/qprocess_darwin.mm
)
-qt_extend_target(Core CONDITION APPLE AND NOT MACOS
+qt_internal_extend_target(Core CONDITION APPLE AND NOT MACOS
PUBLIC_LIBRARIES
${FWMobileCoreServices}
)
-qt_extend_target(Core CONDITION UNIX AND NOT APPLE
+qt_internal_extend_target(Core CONDITION UNIX AND NOT APPLE
SOURCES
kernel/qelapsedtimer_unix.cpp
)
-qt_extend_target(Core CONDITION ANDROID AND NOT ANDROID_EMBEDDED
+qt_internal_extend_target(Core CONDITION ANDROID AND NOT ANDROID_EMBEDDED
SOURCES
io/qstandardpaths_android.cpp
io/qstorageinfo_unix.cpp
@@ -973,7 +973,7 @@ qt_extend_target(Core CONDITION ANDROID AND NOT ANDROID_EMBEDDED
kernel/qjnionload.cpp
)
-qt_extend_target(Core CONDITION HAIKU AND (ANDROID_EMBEDDED OR NOT ANDROID)
+qt_internal_extend_target(Core CONDITION HAIKU AND (ANDROID_EMBEDDED OR NOT ANDROID)
SOURCES
io/qstandardpaths_haiku.cpp
io/qstorageinfo_unix.cpp
@@ -981,92 +981,92 @@ qt_extend_target(Core CONDITION HAIKU AND (ANDROID_EMBEDDED OR NOT ANDROID)
be
)
-qt_extend_target(Core CONDITION UNIX AND NOT APPLE AND NOT HAIKU AND (ANDROID_EMBEDDED OR NOT ANDROID)
+qt_internal_extend_target(Core CONDITION UNIX AND NOT APPLE AND NOT HAIKU AND (ANDROID_EMBEDDED OR NOT ANDROID)
SOURCES
io/qstandardpaths_unix.cpp
io/qstorageinfo_unix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_proxymodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_proxymodel
SOURCES
itemmodels/qabstractproxymodel.cpp itemmodels/qabstractproxymodel.h itemmodels/qabstractproxymodel_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_concatenatetablesproxymodel AND QT_FEATURE_proxymodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_concatenatetablesproxymodel AND QT_FEATURE_proxymodel
SOURCES
itemmodels/qconcatenatetablesproxymodel.cpp itemmodels/qconcatenatetablesproxymodel.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_identityproxymodel AND QT_FEATURE_proxymodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_identityproxymodel AND QT_FEATURE_proxymodel
SOURCES
itemmodels/qidentityproxymodel.cpp itemmodels/qidentityproxymodel.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_proxymodel AND QT_FEATURE_sortfilterproxymodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_proxymodel AND QT_FEATURE_sortfilterproxymodel
SOURCES
itemmodels/qsortfilterproxymodel.cpp itemmodels/qsortfilterproxymodel.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_proxymodel AND QT_FEATURE_transposeproxymodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_proxymodel AND QT_FEATURE_transposeproxymodel
SOURCES
itemmodels/qtransposeproxymodel.cpp itemmodels/qtransposeproxymodel.h itemmodels/qtransposeproxymodel_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_stringlistmodel
+qt_internal_extend_target(Core CONDITION QT_FEATURE_stringlistmodel
SOURCES
itemmodels/qstringlistmodel.cpp itemmodels/qstringlistmodel.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_library
+qt_internal_extend_target(Core CONDITION QT_FEATURE_library
SOURCES
plugin/qelfparser_p.cpp plugin/qelfparser_p.h
plugin/qlibrary.cpp plugin/qlibrary.h plugin/qlibrary_p.h
plugin/qmachparser.cpp plugin/qmachparser_p.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_library AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_library AND UNIX
SOURCES
plugin/qlibrary_unix.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_library AND WIN32
+qt_internal_extend_target(Core CONDITION QT_FEATURE_library AND WIN32
SOURCES
plugin/qlibrary_win.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_dlopen AND QT_FEATURE_library
+qt_internal_extend_target(Core CONDITION QT_FEATURE_dlopen AND QT_FEATURE_library
LIBRARIES
${CMAKE_DL_LIBS}
)
-qt_extend_target(Core CONDITION APPLE AND (IOS OR TVOS)
+qt_internal_extend_target(Core CONDITION APPLE AND (IOS OR TVOS)
LIBRARIES
${FWUIKit}
)
-qt_extend_target(Core CONDITION WATCHOS
+qt_internal_extend_target(Core CONDITION WATCHOS
LIBRARIES
${FWWatchKit}
)
-qt_extend_target(Core CONDITION QT_FEATURE_poll_select AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_poll_select AND UNIX
SOURCES
kernel/qpoll.cpp
)
-qt_extend_target(Core CONDITION QT_FEATURE_glib AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_glib AND UNIX
SOURCES
kernel/qeventdispatcher_glib.cpp kernel/qeventdispatcher_glib_p.h
LIBRARIES
GLIB2::GLIB2
)
-qt_extend_target(Core CONDITION QT_FEATURE_clock_gettime AND UNIX
+qt_internal_extend_target(Core CONDITION QT_FEATURE_clock_gettime AND UNIX
LIBRARIES
WrapRt::WrapRt
)
-qt_extend_target(Core CONDITION UNIX AND NOT ANDROID
+qt_internal_extend_target(Core CONDITION UNIX AND NOT ANDROID
SOURCES
kernel/qsharedmemory_posix.cpp
kernel/qsharedmemory_systemv.cpp
@@ -1076,32 +1076,22 @@ qt_extend_target(Core CONDITION UNIX AND NOT ANDROID
kernel/qsystemsemaphore_unix.cpp
)
-qt_extend_target(Core CONDITION VXWORKS
+qt_internal_extend_target(Core CONDITION VXWORKS
SOURCES
kernel/qfunctions_vxworks.cpp kernel/qfunctions_vxworks.h
)
-qt_extend_target(Core CONDITION QNX AND QT_FEATURE_qqnx_pps
- SOURCES
- kernel/qppsattribute.cpp kernel/qppsattribute_p.h
- kernel/qppsattributeprivate_p.h
- kernel/qppsobject.cpp kernel/qppsobject_p.h
- kernel/qppsobjectprivate_p.h
- LIBRARIES
- PPS::PPS
-)
-
-qt_extend_target(Core CONDITION QT_FEATURE_cborstreamreader
+qt_internal_extend_target(Core CONDITION QT_FEATURE_cborstreamreader
SOURCES
serialization/qcborstreamreader.cpp serialization/qcborstreamreader.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_cborstreamwriter
+qt_internal_extend_target(Core CONDITION QT_FEATURE_cborstreamwriter
SOURCES
serialization/qcborstreamwriter.cpp serialization/qcborstreamwriter.h
)
-qt_extend_target(Core CONDITION QT_FEATURE_mimetype
+qt_internal_extend_target(Core CONDITION QT_FEATURE_mimetype
SOURCES
mimetypes/qmimedatabase.cpp mimetypes/qmimedatabase.h mimetypes/qmimedatabase_p.h
mimetypes/qmimeglobpattern.cpp mimetypes/qmimeglobpattern_p.h
@@ -1112,18 +1102,18 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype
mimetypes/qmimetypeparser.cpp mimetypes/qmimetypeparser_p.h
)
-#### Keys ignored in scope 172:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype:
+#### Keys ignored in scope 171:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype:
# MIME_DATABASE = "mimetypes/mime/packages/freedesktop.org.xml"
# OTHER_FILES = "$$MIME_DATABASE"
# special case begin
-# qt_extend_target(Core CONDITION QT_FEATURE_mimetype AND QT_FEATURE_mimetype_database
+# qt_internal_extend_target(Core CONDITION QT_FEATURE_mimetype AND QT_FEATURE_mimetype_database
# INCLUDE_DIRECTORIES
# .rcc
#)
# special case end
-#### Keys ignored in scope 173:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database:
+#### Keys ignored in scope 172:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database:
# QMAKE_EXTRA_COMPILERS = "mimedb"
# mimedb.commands = "${QMAKE_FILE_IN}" ">" "${QMAKE_FILE_OUT}"
# mimedb.depends = "$$PWD/mime/generate.pl"
@@ -1131,23 +1121,23 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype
# mimedb.output = "$$outpath/qmimeprovider_database.cpp"
# mimedb.variable_out = "INCLUDED_SOURCES"
-#### Keys ignored in scope 174:.:mimetypes:mimetypes/mimetypes.pri:ANDROID:
+#### Keys ignored in scope 173:.:mimetypes:mimetypes/mimetypes.pri:ANDROID:
# outpath = "$$outpath/$${QT_ARCH}"
-#### Keys ignored in scope 176:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug):
+#### Keys ignored in scope 175:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug):
# outpath = "$$outpath/debug"
-#### Keys ignored in scope 177:.:mimetypes:mimetypes/mimetypes.pri:else:
+#### Keys ignored in scope 176:.:mimetypes:mimetypes/mimetypes.pri:else:
# outpath = "$$outpath/release"
-#### Keys ignored in scope 178:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY:
+#### Keys ignored in scope 177:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY:
# mimedb.commands = "cmd" "/c" "$$shell_path($$PWD/mime/generate.bat)"
# mimedb.depends = "$$PWD/mime/generate.bat" "$$PWD/mime/hexdump.ps1"
-#### Keys ignored in scope 179:.:mimetypes:mimetypes/mimetypes.pri:else:
+#### Keys ignored in scope 178:.:mimetypes:mimetypes/mimetypes.pri:else:
# mimedb.commands = "perl" "$${mimedb.depends}"
-#### Keys ignored in scope 180:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd:
+#### Keys ignored in scope 179:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd:
# mimedb.commands = "--zstd"
# Resources:
# special case begin
@@ -1160,27 +1150,104 @@ if(QT_FEATURE_mimetype AND QT_FEATURE_mimetype_database)
# Generate qmimeprovider_database.cpp
set(qmimeprovider_db_output "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmimeprovider_database.cpp")
- set(command_args "")
- set(mime_dir "${CMAKE_CURRENT_SOURCE_DIR}/mimetypes/mime")
- set(command_depends "${mime_dir}/generate.pl" "${corelib_mimetypes_resource_file}")
- if (MSVC)
- list(APPEND command_args "${mime_dir}/generate.bat")
- list(APPEND command_depends "${mime_dir}/generate.bat" "${mime_dir}/hexdump.ps1" )
+ if(CMAKE_VERSION VERSION_LESS 3.18 OR QT_AVOID_CMAKE_ARCHIVING_API)
+ set(command_args "")
+ set(mime_dir "${CMAKE_CURRENT_SOURCE_DIR}/mimetypes/mime")
+ set(command_depends "${mime_dir}/generate.pl" "${corelib_mimetypes_resource_file}")
+ if (MSVC)
+ list(APPEND command_args "${mime_dir}/generate.bat")
+ list(APPEND command_depends "${mime_dir}/generate.bat" "${mime_dir}/hexdump.ps1" )
+ else()
+ list(APPEND command_args perl "${mime_dir}/generate.pl" )
+ endif()
+
+ if (QT_FEATURE_zstd)
+ list(APPEND command_args "--zstd")
+ endif()
+
+ list(APPEND command_args "${corelib_mimetypes_resource_file}" ">" "${qmimeprovider_db_output}")
+
+ add_custom_command(OUTPUT "${qmimeprovider_db_output}"
+ DEPENDS ${command_depends}
+ COMMAND ${command_args}
+ COMMENT "Generating ${qmimeprovider_db_output}"
+ )
else()
- list(APPEND command_args perl "${mime_dir}/generate.pl" )
- endif()
+ if(QT_FEATURE_zstd)
+ set(qmime_db_compression Zstd)
+ string(APPEND qmime_db_content "#define MIME_DATABASE_IS_ZSTD\n")
+ else()
+ set(qmime_db_compression GZip)
+ string(APPEND qmime_db_content "#define MIME_DATABASE_IS_GZIP\n")
+ endif()
- if (QT_FEATURE_zstd)
- list(APPEND command_args "--zstd")
- endif()
+ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.rcc")
+ get_filename_component(mime_types_resource_file "${corelib_mimetypes_resource_file}" NAME)
- list(APPEND command_args "${corelib_mimetypes_resource_file}" ">" "${qmimeprovider_db_output}")
+ set(mimetypes_resource_file_minified "${CMAKE_CURRENT_BINARY_DIR}/.rcc/${mime_types_resource_file}")
- add_custom_command(OUTPUT "${qmimeprovider_db_output}"
- DEPENDS ${command_depends}
- COMMAND ${command_args}
- COMMENT "Generating ${qmimeprovider_db_output}"
- )
+ set(mimetypes_resfile_timestamp_file "${CMAKE_CURRENT_BINARY_DIR}/.rcc/${mime_types_resource_file}.timestamp")
+ file(TIMESTAMP "${corelib_mimetypes_resource_file}" mimetypes_resfile_timestamp)
+
+ set(compute_db_archive ON)
+ if (EXISTS "${mimetypes_resfile_timestamp_file}")
+ file(READ "${mimetypes_resfile_timestamp_file}" old_mimetypes_resfile_timestamp)
+ if ("${mimetypes_resfile_timestamp}" STREQUAL "${old_mimetypes_resfile_timestamp}")
+ set(compute_db_archive OFF)
+ endif()
+ endif()
+
+ if (compute_db_archive)
+ find_program(xmlstarlet NAMES xmlstarlet xml)
+ if (xmlstarlet)
+ execute_process(
+ COMMAND "${xmlstarlet}" sel -D -B -t -c / "${corelib_mimetypes_resource_file}"
+ OUTPUT_FILE "${mimetypes_resource_file_minified}"
+ RESULT_VARIABLE failed_to_minify
+ )
+ if (NOT failed_to_minify)
+ set(corelib_mimetypes_resource_file "${mimetypes_resource_file_minified}")
+ endif()
+ else()
+ message(WARNING "xmlstarlet was not found. ${mime_types_resource_file} will not be minified!")
+ endif()
+
+ if (CMAKE_VERSION GREATER_EQUAL 3.19)
+ set(additional_file_archive_create_parameters COMPRESSION_LEVEL 9)
+ endif()
+
+ file(ARCHIVE_CREATE OUTPUT "${qmimeprovider_db_output}.archive"
+ PATHS "${corelib_mimetypes_resource_file}"
+ FORMAT raw
+ COMPRESSION ${qmime_db_compression}
+ ${additional_file_archive_create_parameters}
+ )
+ file(READ "${qmimeprovider_db_output}.archive" qmime_db_archive HEX)
+ file(SIZE "${qmimeprovider_db_output}.archive" qmime_db_archive_size)
+ file(SIZE "${corelib_mimetypes_resource_file}" qmime_db_resource_size)
+ file(REMOVE ${qmimeprovider_db_output}.archive)
+
+ string(APPEND qmime_db_content "static const unsigned char mimetype_database[] = { ")
+
+ string(REGEX MATCHALL "([a-f0-9][a-f0-9])" qmime_db_hex "${qmime_db_archive}")
+
+ list(TRANSFORM qmime_db_hex PREPEND "0x")
+ math(EXPR qmime_db_archive_size "${qmime_db_archive_size} - 1")
+ foreach(index RANGE 0 ${qmime_db_archive_size} 12)
+ list(APPEND index_list ${index})
+ endforeach()
+ list(TRANSFORM qmime_db_hex PREPEND "\n " AT ${index_list})
+ list(JOIN qmime_db_hex ", " qmime_db_hex_joined)
+
+ string(APPEND qmime_db_content "${qmime_db_hex_joined}")
+ string(APPEND qmime_db_content "\n};\n")
+ string(APPEND qmime_db_content "static constexpr size_t MimeTypeDatabaseOriginalSize = ${qmime_db_resource_size};\n")
+
+ file(WRITE "${qmimeprovider_db_output}" "${qmime_db_content}")
+
+ file(WRITE "${mimetypes_resfile_timestamp_file}" "${mimetypes_resfile_timestamp}")
+ endif()
+ endif()
target_sources(Core PRIVATE ${qmimeprovider_db_output})
set_source_files_properties(${qmimeprovider_db_output} PROPERTIES HEADER_FILE_ONLY TRUE)
@@ -1189,7 +1256,7 @@ endif()
# special case end
-qt_extend_target(Core CONDITION WASM
+qt_internal_extend_target(Core CONDITION WASM
SOURCES
platform/wasm/qstdweb.cpp platform/wasm/qstdweb_p.h
)
@@ -1198,12 +1265,12 @@ qt_extend_target(Core CONDITION WASM
# needs refinement for the other compiler specific cases.
if(TEST_arch_${TEST_architecture_arch}_subarch_f16c)
# Equivalent to contains(QT_CPU_FEATURES.$$QT_ARCH, f16c)
- extend_target(Core
+ qt_internal_extend_target(Core
DEFINES
QFLOAT16_INCLUDE_FAST
)
else()
- qt_add_simd_part(Core SIMD f16c
+ qt_internal_add_simd_part(Core SIMD f16c
SOURCES
global/qfloat16_f16c.c
)
@@ -1226,14 +1293,25 @@ endif()
qt_internal_apply_gc_binaries_conditional(Core PUBLIC)
-if(WIN32)
- set(isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>)
- set(isWin32 $<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>)
- set(isNotExcluded $<NOT:$<BOOL:$<TARGET_PROPERTY:Qt5_NO_LINK_QTMAIN>>>)
- set(isPolicyNEW $<TARGET_POLICY:CMP0020>)
+# Add entry-point on platforms that need it. A project can opt-out of using the
+# entrypoint by setting the qt_no_entrypoint property to TRUE on a target.
+if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
+ # find_package(Qt6Core) should call find_package(Qt6EntryPoint) so that we can
+ # link against EntryPoint. Normally this is handled automatically for deps, but
+ # for some reason it doesn't work for the EntryPoint, so we need to add it manually.
+ qt_record_extra_qt_package_dependency(Core EntryPoint "${PROJECT_VERSION}")
- target_link_libraries(Core INTERFACE $<$<AND:${isExe},${isWin32},${isNotExcluded},${isPolicyNEW}>:Qt::WinMain>)
- qt_record_extra_qt_package_dependency(Core WinMain "${PROJECT_VERSION}")
+ set(entrypoint_conditions "$<NOT:$<BOOL:$<TARGET_PROPERTY:qt_no_entrypoint>>>")
+ list(APPEND entrypoint_conditions "$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>")
+
+ if(WIN32)
+ list(APPEND entrypoint_conditions "$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>")
+ endif()
+
+ list(JOIN entrypoint_conditions "," entrypoint_conditions)
+ set(entrypoint_conditions "$<AND:${entrypoint_conditions}>")
+
+ target_link_libraries(Core INTERFACE "$<${entrypoint_conditions}:${QT_CMAKE_EXPORT_NAMESPACE}::EntryPoint>")
endif()
# Record darwin minimum deployment target.
@@ -1245,13 +1323,13 @@ if(APPLE AND CMAKE_OSX_DEPLOYMENT_TARGET)
endif()
# special case end
-qt_create_tracepoints(Core qtcore.tracepoints)
+qt_internal_create_tracepoints(Core qtcore.tracepoints)
# special case begin
if(TARGET Core_tracepoints_header)
add_dependencies(Core_qobject Core_tracepoints_header)
endif()
# special case end
-qt_add_docs(Core
+qt_internal_add_docs(Core
doc/qtcore.qdocconf
)
@@ -1259,10 +1337,13 @@ qt_add_docs(Core
# Handle qtzlib.pro to create headers for the
# QtZlibPrivate target, equivalent to Qt += zlib-private
if(NOT QT_FEATURE_system_zlib)
- qt_add_module(Zlib
+ qt_internal_add_module(Zlib
INTERNAL_MODULE
HEADER_MODULE
NO_CONFIG_HEADER_FILE
)
endif()
+
+qt_internal_add_optimize_full_flags(IN_CURRENT_SCOPE)
+
# special case end
diff --git a/src/corelib/Qt5AndroidSupport.cmake b/src/corelib/Qt5AndroidSupport.cmake
deleted file mode 100644
index e1e99f1c62..0000000000
--- a/src/corelib/Qt5AndroidSupport.cmake
+++ /dev/null
@@ -1,205 +0,0 @@
-if (NOT ${PROJECT_NAME}-MultiAbiBuild)
-
- set(ANDROID_ABIS armeabi-v7a arm64-v8a x86 x86_64)
-
- # Match Android's sysroots
- set(ANDROID_SYSROOT_armeabi-v7a arm-linux-androideabi)
- set(ANDROID_SYSROOT_arm64-v8a aarch64-linux-android)
- set(ANDROID_SYSROOT_x86 i686-linux-android)
- set(ANDROID_SYSROOT_x86_64 x86_64-linux-android)
-
- foreach(abi IN LISTS ANDROID_ABIS)
- set(abi_initial_value OFF)
- if (abi STREQUAL ${ANDROID_ABI})
- set(abi_initial_value ON)
- endif()
- find_library(Qt5Core_${abi}_Probe Qt5Core_${abi})
- if (Qt5Core_${abi}_Probe)
- option(ANDROID_BUILD_ABI_${abi} "Enable the build for Android ${abi}" ${abi_initial_value})
- endif()
- endforeach()
- option(ANDROID_MIN_SDK_VERSION "Android minimum SDK version" "23")
- option(ANDROID_TARGET_SDK_VERSION "Android target SDK version" "28")
-
- # Make sure to delete the "android-build" directory, which contains all the
- # build artefacts, and also the androiddeployqt/gradle artefacts
- set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${CMAKE_BINARY_DIR}/android-build)
-
- if (CMAKE_VERSION VERSION_LESS 3.15)
- message(STATUS "-----------------------------------------------------------------------------------------------------------")
- message(STATUS "CMake version 3.15 is required to clean the <build_dir>/android-build when issuing the \"clean\" target.\n\n"
- "For this CMake version please use the \"clean-android-build\" support target additionally to the \"clean\" target.")
- message(STATUS "-----------------------------------------------------------------------------------------------------------")
-
- add_custom_target(clean-android-build
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/android-build
- VERBATIM)
- endif()
-
- # Write the android_<project_name>_deployment_settings.json file
- file(WRITE ${CMAKE_BINARY_DIR}/android_deployment_settings.json.in
-[=[{
- "_description": "This file is created by CMake to be read by androiddeployqt and should not be modified by hand.",
- "application-binary": "@QT_ANDROID_APPLICATION_BINARY@",
- "application-arguments": "@QT_ANDROID_APPLICATION_ARGUMENTS@",
- "architectures": {
-@QT_ANDROID_ARCHITECTURES@
- },
- @QT_ANDROID_DEPLOYMENT_DEPENDENCIES@
- @QT_ANDROID_EXTRA_PLUGINS@
- @QT_ANDROID_PACKAGE_SOURCE_DIR@
- @QT_ANDROID_VERSION_CODE@
- @QT_ANDROID_VERSION_NAME@
- @QT_ANDROID_EXTRA_LIBS@
- @QT_QML_IMPORT_PATH@
- "ndk": "@ANDROID_NDK@",
- "ndk-host": "@ANDROID_HOST_TAG@",
- "qml-root-path": "@CMAKE_CURRENT_SOURCE_DIR@",
- "qt": "@QT_DIR@",
- "sdk": "@ANDROID_SDK@",
- "stdcpp-path": "@ANDROID_TOOLCHAIN_ROOT@/sysroot/usr/lib/",
- "tool-prefix": "llvm",
- "toolchain-prefix": "llvm",
- "useLLVM": true
-}]=])
-
- if (NOT QT_ANDROID_APPLICATION_BINARY)
- set(QT_ANDROID_APPLICATION_BINARY ${PROJECT_NAME})
- endif()
-
- if(NOT ANDROID_SDK)
- get_filename_component(ANDROID_SDK ${ANDROID_NDK}/../ ABSOLUTE)
- endif()
-
- find_program(ANDROID_DEPLOY_QT androiddeployqt)
- get_filename_component(QT_DIR ${ANDROID_DEPLOY_QT}/../../ ABSOLUTE)
-
- unset(QT_ANDROID_ARCHITECTURES)
- foreach(abi IN LISTS ANDROID_ABIS)
- if (ANDROID_BUILD_ABI_${abi})
- list(APPEND QT_ANDROID_ARCHITECTURES " \"${abi}\" : \"${ANDROID_SYSROOT_${abi}}\"")
- endif()
- endforeach()
- string(REPLACE ";" ",\n" QT_ANDROID_ARCHITECTURES "${QT_ANDROID_ARCHITECTURES}")
-
- macro(generate_json_variable_list var_list json_key)
- if (${var_list})
- set(QT_${var_list} "\"${json_key}\": \"")
- string(REPLACE ";" "," joined_var_list "${${var_list}}")
- string(APPEND QT_${var_list} "${joined_var_list}\",")
- endif()
- endmacro()
-
- macro(generate_json_variable var json_key)
- if (${var})
- set(QT_${var} "\"${json_key}\": \"${${var}}\",")
- endif()
- endmacro()
-
- generate_json_variable_list(ANDROID_DEPLOYMENT_DEPENDENCIES "deployment-dependencies")
- generate_json_variable_list(ANDROID_EXTRA_PLUGINS "android-extra-plugins")
- generate_json_variable(ANDROID_PACKAGE_SOURCE_DIR "android-package-source-directory")
- generate_json_variable(ANDROID_APPLICATION_ARGUMENTS "android-application-arguments")
- generate_json_variable(ANDROID_VERSION_CODE "android-version-code")
- generate_json_variable(ANDROID_VERSION_NAME "android-version-name")
- generate_json_variable_list(ANDROID_EXTRA_LIBS "android-extra-libs")
- generate_json_variable_list(QML_IMPORT_PATH "qml-import-paths")
- generate_json_variable_list(ANDROID_MIN_SDK_VERSION "android-min-sdk-version")
- generate_json_variable_list(ANDROID_TARGET_SDK_VERSION "android-target-sdk-version")
-
-
- configure_file(
- "${CMAKE_BINARY_DIR}/android_deployment_settings.json.in"
- "${CMAKE_BINARY_DIR}/android_deployment_settings.json" @ONLY)
-
- # Create "apk" and "aab" targets
- if (DEFINED ENV{JAVA_HOME})
- set(JAVA_HOME $ENV{JAVA_HOME} CACHE INTERNAL "Saved JAVA_HOME variable")
- endif()
- if (JAVA_HOME)
- set(android_deploy_qt_jdk "--jdk ${JAVA_HOME}")
- endif()
-
- if (ANDROID_SDK_PLATFORM)
- set(android_deploy_qt_platform "--android-platform ${ANDROID_SDK_PLATFORM}")
- endif()
-
- add_custom_target(apk
- COMMAND ${CMAKE_COMMAND} -E env JAVA_HOME=${JAVA_HOME} ${ANDROID_DEPLOY_QT}
- --input "${CMAKE_BINARY_DIR}/android_deployment_settings.json"
- --output "${CMAKE_BINARY_DIR}/android-build"
- --apk "${CMAKE_BINARY_DIR}/android-build/${PROJECT_NAME}.apk"
- ${android_deploy_qt_platform}
- ${android_deploy_qt_jdk}
- VERBATIM)
-
- add_custom_target(aab
- COMMAND ${CMAKE_COMMAND} -E env JAVA_HOME=${JAVA_HOME} ${ANDROID_DEPLOY_QT}
- --input "${CMAKE_BINARY_DIR}/android_deployment_settings.json"
- --output "${CMAKE_BINARY_DIR}/android-build"
- --apk "${CMAKE_BINARY_DIR}/android-build/${PROJECT_NAME}.apk"
- --aab
- ${android_deploy_qt_platform}
- ${android_deploy_qt_jdk}
- VERBATIM)
-
- include(ExternalProject)
- macro (setup_library library_name android_abi)
- # Use Qt Creator's 4.12 settings file if present
- unset(QTC_SETTINGS_PARAMETER)
- if (EXISTS ${CMAKE_BINARY_DIR}/qtcsettings.cmake)
- set(QTC_SETTINGS_PARAMETER -C ${CMAKE_BINARY_DIR}/qtcsettings.cmake)
- endif()
-
- # Build all the given ABI as an external project
- ExternalProject_Add(${library_name}-builder
- SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
- PREFIX MultiAbi
- BUILD_ALWAYS YES
- DOWNLOAD_COMMAND ""
- INSTALL_COMMAND ""
- UPDATE_COMMAND ""
- PATCH_COMMAND ""
- CMAKE_ARGS
- ${QTC_SETTINGS_PARAMETER}
- -D ANDROID_ABI=${android_abi}
- -D CMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
- -D CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
- -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
- -D ANDROID_PLATFORM=${ANDROID_PLATFORM}
- -D ANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}
- -D CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
- -D CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=${CMAKE_FIND_ROOT_PATH_MODE_PROGRAM}
- -D CMAKE_FIND_ROOT_PATH_MODE_LIBRARY=${CMAKE_FIND_ROOT_PATH_MODE_LIBRARY}
- -D CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=${CMAKE_FIND_ROOT_PATH_MODE_INCLUDE}
- -D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=${CMAKE_FIND_ROOT_PATH_MODE_PACKAGE}
- -D CMAKE_SHARED_LIBRARY_SUFFIX_CXX=_${android_abi}.so
- -D CMAKE_SHARED_MODULE_SUFFIX_CXX=_${android_abi}.so
- -D CMAKE_SHARED_LIBRARY_SUFFIX_C=_${android_abi}.so
- -D CMAKE_SHARED_MODULE_SUFFIX_C=_${android_abi}.so
- -D CMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/android-build/libs/${android_abi}
- -D ${PROJECT_NAME}-MultiAbiBuild=ON
- )
- endmacro()
-
- foreach(abi IN LISTS ANDROID_ABIS)
- if (NOT abi STREQUAL ${ANDROID_ABI})
- if (ANDROID_BUILD_ABI_${abi})
- setup_library(${PROJECT_NAME}-${abi} ${abi} ${CMAKE_PREFIX_PATH})
- endif()
- else()
- # For the default abi just use the regular cmake run, to have
- # nice IDE integration and so on
- set(CMAKE_SHARED_MODULE_SUFFIX_CXX "_${ANDROID_ABI}.so")
- set(CMAKE_SHARED_LIBRARY_SUFFIX_CXX "_${ANDROID_ABI}.so")
- set(CMAKE_SHARED_MODULE_SUFFIX_C "_${ANDROID_ABI}.so")
- set(CMAKE_SHARED_LIBRARY_SUFFIX_C "_${ANDROID_ABI}.so")
- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/android-build/libs/${ANDROID_ABI})
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/android-build/libs/${ANDROID_ABI})
- endif()
- endforeach()
-else()
- # unset the variable, just not to issue an unused variable warning
- unset(${PROJECT_NAME}-MultiAbiBuild)
-endif()
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
deleted file mode 100644
index f5766f8775..0000000000
--- a/src/corelib/Qt5CoreMacros.cmake
+++ /dev/null
@@ -1,507 +0,0 @@
-#=============================================================================
-# Copyright 2005-2011 Kitware, Inc.
-# Copyright (C) 2020 The Qt Company Ltd.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# * Neither the name of Kitware, Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#=============================================================================
-
-######################################
-#
-# Macros for building Qt files
-#
-######################################
-
-include(CMakeParseArguments)
-
-function(_qt5_warn_deprecated command_name)
- if(NOT DEFINED _QT5_INTERNAL_SCOPE)
- message(AUTHOR_WARNING
- "${command_name} is not part of the official API, and might be removed in Qt 6.")
- endif()
-endfunction()
-
-# macro used to create the names of output files preserving relative dirs
-macro(qt5_make_output_file infile prefix ext outfile )
- _qt5_warn_deprecated("qt5_make_output_file")
-
- string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
- string(LENGTH ${infile} _infileLength)
- set(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
- if(_infileLength GREATER _binlength)
- string(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
- if(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
- file(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
- else()
- file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
- endif()
- else()
- file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
- endif()
- if(CMAKE_HOST_WIN32 AND rel MATCHES "^([a-zA-Z]):(.*)$") # absolute path
- set(rel "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
- endif()
- set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
- string(REPLACE ".." "__" _outfile ${_outfile})
- get_filename_component(outpath ${_outfile} PATH)
- if(CMAKE_VERSION VERSION_LESS "3.14")
- get_filename_component(_outfile_ext ${_outfile} EXT)
- get_filename_component(_outfile_ext ${_outfile_ext} NAME_WE)
- get_filename_component(_outfile ${_outfile} NAME_WE)
- string(APPEND _outfile ${_outfile_ext})
- else()
- get_filename_component(_outfile ${_outfile} NAME_WLE)
- endif()
- file(MAKE_DIRECTORY ${outpath})
- set(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
-endmacro()
-
-
-macro(qt5_get_moc_flags _moc_flags)
- _qt5_warn_deprecated("qt5_get_moc_flags")
-
- set(${_moc_flags})
- get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
-
- if(CMAKE_INCLUDE_CURRENT_DIR)
- list(APPEND _inc_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
- endif()
-
- foreach(_current ${_inc_DIRS})
- if("${_current}" MATCHES "\\.framework/?$")
- string(REGEX REPLACE "/[^/]+\\.framework" "" framework_path "${_current}")
- set(${_moc_flags} ${${_moc_flags}} "-F${framework_path}")
- else()
- set(${_moc_flags} ${${_moc_flags}} "-I${_current}")
- endif()
- endforeach()
-
- get_directory_property(_defines COMPILE_DEFINITIONS)
- foreach(_current ${_defines})
- set(${_moc_flags} ${${_moc_flags}} "-D${_current}")
- endforeach()
-
- if(WIN32)
- set(${_moc_flags} ${${_moc_flags}} -DWIN32)
- endif()
- if (MSVC)
- set(${_moc_flags} ${${_moc_flags}} --compiler-flavor=msvc)
- endif()
-endmacro()
-
-
-# helper macro to set up a moc rule
-function(qt5_create_moc_command infile outfile moc_flags moc_options moc_target moc_depends)
- _qt5_warn_deprecated("qt5_create_moc_command")
-
- # Pass the parameters in a file. Set the working directory to
- # be that containing the parameters file and reference it by
- # just the file name. This is necessary because the moc tool on
- # MinGW builds does not seem to handle spaces in the path to the
- # file given with the @ syntax.
- get_filename_component(_moc_outfile_name "${outfile}" NAME)
- get_filename_component(_moc_outfile_dir "${outfile}" PATH)
- if(_moc_outfile_dir)
- set(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
- endif()
- set (_moc_parameters_file ${outfile}_parameters)
- set (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
- string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
-
- if(moc_target)
- set(_moc_parameters_file ${_moc_parameters_file}$<$<BOOL:$<CONFIGURATION>>:_$<CONFIGURATION>>)
- set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>")
- set(targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>")
-
- set(targetincludes "$<$<BOOL:${targetincludes}>:-I$<JOIN:${targetincludes},\n-I>\n>")
- set(targetdefines "$<$<BOOL:${targetdefines}>:-D$<JOIN:${targetdefines},\n-D>\n>")
-
- file (GENERATE
- OUTPUT ${_moc_parameters_file}
- CONTENT "${targetdefines}${targetincludes}${_moc_parameters}\n"
- )
-
- set(targetincludes)
- set(targetdefines)
- else()
- file(WRITE ${_moc_parameters_file} "${_moc_parameters}\n")
- endif()
-
- set(_moc_extra_parameters_file @${_moc_parameters_file})
- add_custom_command(OUTPUT ${outfile}
- COMMAND ${Qt5Core_MOC_EXECUTABLE} ${_moc_extra_parameters_file}
- DEPENDS ${infile} ${moc_depends}
- ${_moc_working_dir}
- VERBATIM)
- set_source_files_properties(${infile} PROPERTIES SKIP_AUTOMOC ON)
- set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON)
- set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON)
-endfunction()
-
-
-function(qt5_generate_moc infile outfile )
- set(_QT5_INTERNAL_SCOPE ON)
-
- # get include dirs and flags
- qt5_get_moc_flags(moc_flags)
- get_filename_component(abs_infile ${infile} ABSOLUTE)
- set(_outfile "${outfile}")
- if(NOT IS_ABSOLUTE "${outfile}")
- set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
- endif()
- if ("x${ARGV2}" STREQUAL "xTARGET")
- set(moc_target ${ARGV3})
- endif()
- qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "")
-endfunction()
-
-if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
- function(qt_generate_moc)
- if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
- qt5_generate_moc(${ARGV})
- elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
- qt6_generate_moc(${ARGV})
- endif()
- endfunction()
-endif()
-
-
-# qt5_wrap_cpp(outfiles inputfile ... )
-
-function(qt5_wrap_cpp outfiles)
- set(_QT5_INTERNAL_SCOPE ON)
-
- # get include dirs
- qt5_get_moc_flags(moc_flags)
-
- set(options)
- set(oneValueArgs TARGET)
- set(multiValueArgs OPTIONS DEPENDS)
-
- cmake_parse_arguments(_WRAP_CPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- set(moc_files ${_WRAP_CPP_UNPARSED_ARGUMENTS})
- set(moc_options ${_WRAP_CPP_OPTIONS})
- set(moc_target ${_WRAP_CPP_TARGET})
- set(moc_depends ${_WRAP_CPP_DEPENDS})
-
- foreach(it ${moc_files})
- get_filename_component(it ${it} ABSOLUTE)
- qt5_make_output_file(${it} moc_ cpp outfile)
- qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
- list(APPEND ${outfiles} ${outfile})
- endforeach()
- set(${outfiles} ${${outfiles}} PARENT_SCOPE)
-endfunction()
-
-# This will override the CMake upstream command, because that one is for Qt 3.
-if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
- function(qt_wrap_cpp outfiles)
- if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
- qt5_wrap_cpp("${outfiles}" ${ARGN})
- elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
- qt6_wrap_cpp("${outfiles}" ${ARGN})
- endif()
- set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
- endfunction()
-endif()
-
-
-# _qt5_parse_qrc_file(infile _out_depends _rc_depends)
-# internal
-
-function(_qt5_parse_qrc_file infile _out_depends _rc_depends)
- get_filename_component(rc_path ${infile} PATH)
-
- if(EXISTS "${infile}")
- # parse file for dependencies
- # all files are absolute paths or relative to the location of the qrc file
- file(READ "${infile}" RC_FILE_CONTENTS)
- string(REGEX MATCHALL "<file[^<]+" RC_FILES "${RC_FILE_CONTENTS}")
- foreach(RC_FILE ${RC_FILES})
- string(REGEX REPLACE "^<file[^>]*>" "" RC_FILE "${RC_FILE}")
- if(NOT IS_ABSOLUTE "${RC_FILE}")
- set(RC_FILE "${rc_path}/${RC_FILE}")
- endif()
- set(RC_DEPENDS ${RC_DEPENDS} "${RC_FILE}")
- endforeach()
- # Since this cmake macro is doing the dependency scanning for these files,
- # let's make a configured file and add it as a dependency so cmake is run
- # again when dependencies need to be recomputed.
- qt5_make_output_file("${infile}" "" "qrc.depends" out_depends)
- configure_file("${infile}" "${out_depends}" COPYONLY)
- else()
- # The .qrc file does not exist (yet). Let's add a dependency and hope
- # that it will be generated later
- set(out_depends)
- endif()
-
- set(${_out_depends} ${out_depends} PARENT_SCOPE)
- set(${_rc_depends} ${RC_DEPENDS} PARENT_SCOPE)
-endfunction()
-
-
-# qt5_add_binary_resources(target inputfiles ... )
-
-function(qt5_add_binary_resources target)
- set(_QT5_INTERNAL_SCOPE ON)
-
- set(options)
- set(oneValueArgs DESTINATION)
- set(multiValueArgs OPTIONS)
-
- cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- set(rcc_files ${_RCC_UNPARSED_ARGUMENTS})
- set(rcc_options ${_RCC_OPTIONS})
- set(rcc_destination ${_RCC_DESTINATION})
-
- if(NOT rcc_destination)
- set(rcc_destination ${CMAKE_CURRENT_BINARY_DIR}/${target}.rcc)
- endif()
-
- foreach(it ${rcc_files})
- get_filename_component(infile ${it} ABSOLUTE)
-
- _qt5_parse_qrc_file(${infile} _out_depends _rc_depends)
- set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
- set(infiles ${infiles} ${infile})
- set(out_depends ${out_depends} ${_out_depends})
- set(rc_depends ${rc_depends} ${_rc_depends})
- endforeach()
-
- add_custom_command(OUTPUT ${rcc_destination}
- COMMAND ${Qt5Core_RCC_EXECUTABLE}
- ARGS ${rcc_options} --binary --name ${target} --output ${rcc_destination} ${infiles}
- DEPENDS ${rc_depends} ${out_depends} ${infiles} VERBATIM)
- add_custom_target(${target} ALL DEPENDS ${rcc_destination})
-endfunction()
-
-if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
- function(qt_add_binary_resources)
- if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
- qt5_add_binary_resources(${ARGV})
- elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
- qt6_add_binary_resources(${ARGV})
- endif()
- endfunction()
-endif()
-
-
-# qt5_add_resources(outfiles inputfile ... )
-
-function(qt5_add_resources outfiles)
- set(_QT5_INTERNAL_SCOPE ON)
-
- set(options)
- set(oneValueArgs)
- set(multiValueArgs OPTIONS)
-
- cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- set(rcc_files ${_RCC_UNPARSED_ARGUMENTS})
- set(rcc_options ${_RCC_OPTIONS})
-
- if("${rcc_options}" MATCHES "-binary")
- message(WARNING "Use qt5_add_binary_resources for binary option")
- endif()
-
- foreach(it ${rcc_files})
- get_filename_component(outfilename ${it} NAME_WE)
- get_filename_component(infile ${it} ABSOLUTE)
- set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cpp)
-
- _qt5_parse_qrc_file(${infile} _out_depends _rc_depends)
- set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
-
- add_custom_command(OUTPUT ${outfile}
- COMMAND ${Qt5Core_RCC_EXECUTABLE}
- ARGS ${rcc_options} --name ${outfilename} --output ${outfile} ${infile}
- MAIN_DEPENDENCY ${infile}
- DEPENDS ${_rc_depends} "${_out_depends}" VERBATIM)
- set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON)
- set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON)
- list(APPEND ${outfiles} ${outfile})
- endforeach()
- set(${outfiles} ${${outfiles}} PARENT_SCOPE)
-endfunction()
-
-if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
- function(qt_add_resources outfiles)
- if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
- qt5_add_resources("${outfiles}" ${ARGN})
- elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
- qt6_add_resources("${outfiles}" ${ARGN})
- endif()
- set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
- endfunction()
-endif()
-
-
-# qt5_add_big_resources(outfiles inputfile ... )
-
-function(qt5_add_big_resources outfiles)
- set(_QT5_INTERNAL_SCOPE ON)
-
- if (CMAKE_VERSION VERSION_LESS 3.9)
- message(FATAL_ERROR, "qt5_add_big_resources requires CMake 3.9 or newer")
- endif()
-
- set(options)
- set(oneValueArgs)
- set(multiValueArgs OPTIONS)
-
- cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- set(rcc_files ${_RCC_UNPARSED_ARGUMENTS})
- set(rcc_options ${_RCC_OPTIONS})
-
- if("${rcc_options}" MATCHES "-binary")
- message(WARNING "Use qt5_add_binary_resources for binary option")
- endif()
-
- foreach(it ${rcc_files})
- get_filename_component(outfilename ${it} NAME_WE)
- get_filename_component(infile ${it} ABSOLUTE)
- set(tmpoutfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}tmp.cpp)
- set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.o)
-
- _qt5_parse_qrc_file(${infile} _out_depends _rc_depends)
- set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
- add_custom_command(OUTPUT ${tmpoutfile}
- COMMAND ${Qt5Core_RCC_EXECUTABLE} ${rcc_options} --name ${outfilename} --pass 1 --output ${tmpoutfile} ${infile}
- DEPENDS ${infile} ${_rc_depends} "${out_depends}" VERBATIM)
- add_custom_target(big_resources_${outfilename} ALL DEPENDS ${tmpoutfile})
- add_library(rcc_object_${outfilename} OBJECT ${tmpoutfile})
- set_target_properties(rcc_object_${outfilename} PROPERTIES AUTOMOC OFF)
- set_target_properties(rcc_object_${outfilename} PROPERTIES AUTOUIC OFF)
- add_dependencies(rcc_object_${outfilename} big_resources_${outfilename})
- # The modification of TARGET_OBJECTS needs the following change in cmake
- # https://gitlab.kitware.com/cmake/cmake/commit/93c89bc75ceee599ba7c08b8fe1ac5104942054f
- add_custom_command(OUTPUT ${outfile}
- COMMAND ${Qt5Core_RCC_EXECUTABLE}
- ARGS ${rcc_options} --name ${outfilename} --pass 2 --temp $<TARGET_OBJECTS:rcc_object_${outfilename}> --output ${outfile} ${infile}
- DEPENDS rcc_object_${outfilename} $<TARGET_OBJECTS:rcc_object_${outfilename}>
- VERBATIM)
- list(APPEND ${outfiles} ${outfile})
- endforeach()
- set(${outfiles} ${${outfiles}} PARENT_SCOPE)
-endfunction()
-
-if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
- function(qt_add_big_resources outfiles)
- if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
- qt5_add_big_resources(${outfiles} ${ARGN})
- elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
- qt6_add_big_resources(${outfiles} ${ARGN})
- endif()
- set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
- endfunction()
-endif()
-
-
-set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
-
-macro(qt5_use_modules _target _link_type)
- _qt5_warn_deprecated("qt5_use_modules")
-
- if (NOT TARGET ${_target})
- message(FATAL_ERROR "The first argument to qt5_use_modules must be an existing target.")
- endif()
- if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE" )
- set(_qt5_modules ${ARGN})
- set(_qt5_link_type ${_link_type})
- else()
- set(_qt5_modules ${_link_type} ${ARGN})
- endif()
-
- if ("${_qt5_modules}" STREQUAL "")
- message(FATAL_ERROR "qt5_use_modules requires at least one Qt module to use.")
- endif()
-
- foreach(_module ${_qt5_modules})
- if (NOT Qt5${_module}_FOUND)
- find_package(Qt5${_module} PATHS "${_Qt5_COMPONENT_PATH}" NO_DEFAULT_PATH)
- if (NOT Qt5${_module}_FOUND)
- message(FATAL_ERROR "Cannot use \"${_module}\" module which has not yet been found.")
- endif()
- endif()
- target_link_libraries(${_target} ${_qt5_link_type} ${Qt5${_module}_LIBRARIES})
- set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_module}_INCLUDE_DIRS})
- set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_module}_COMPILE_DEFINITIONS})
- 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
- 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()
-endmacro()
-
-function(qt5_import_plugins TARGET_NAME)
- set(_doing "")
- foreach(_arg ${ARGN})
- if(_arg STREQUAL "INCLUDE")
- set(_doing "INCLUDE")
- elseif(_arg STREQUAL "EXCLUDE")
- set(_doing "EXCLUDE")
- elseif(_arg STREQUAL "INCLUDE_BY_TYPE")
- set(_doing "INCLUDE_BY_TYPE")
- elseif(_arg STREQUAL "EXCLUDE_BY_TYPE")
- set(_doing "EXCLUDE_BY_TYPE")
- else()
- if(_doing STREQUAL "INCLUDE")
- set_property(TARGET ${TARGET_NAME} APPEND PROPERTY QT_PLUGINS "${_arg}")
- elseif(_doing STREQUAL "EXCLUDE")
- set_property(TARGET ${TARGET_NAME} APPEND PROPERTY QT_NO_PLUGINS "${_arg}")
- elseif(_doing STREQUAL "INCLUDE_BY_TYPE")
- string(REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}")
- set(_doing "INCLUDE_BY_TYPE_PLUGINS")
- elseif(_doing STREQUAL "INCLUDE_BY_TYPE_PLUGINS")
- set_property(TARGET ${TARGET_NAME} APPEND PROPERTY "QT_PLUGINS_${_plugin_type}" "${_arg}")
- elseif(_doing STREQUAL "EXCLUDE_BY_TYPE")
- string(REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}")
- set_property(TARGET ${TARGET_NAME} PROPERTY "QT_PLUGINS_${_plugin_type}" -)
- else()
- message(FATAL_ERROR "Unexpected extra argument: \"${_arg}\"")
- endif()
- endif()
- endforeach()
-endfunction()
-
-if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
- function(qt_import_plugins)
- if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
- qt5_import_plugins(${ARGV})
- elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
- qt6_import_plugins(${ARGV})
- endif()
- endfunction()
-endif()
diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake
index 7b566a7633..e1f17a73b0 100644
--- a/src/corelib/Qt6AndroidMacros.cmake
+++ b/src/corelib/Qt6AndroidMacros.cmake
@@ -1,4 +1,23 @@
# Generate deployment tool json
+
+# Locate newest Android sdk build tools revision
+function(_qt_internal_android_get_sdk_build_tools_revision out_var)
+ if (NOT QT_ANDROID_SDK_BUILD_TOOLS_REVISION)
+ file(GLOB android_build_tools
+ LIST_DIRECTORIES true
+ RELATIVE "${ANDROID_SDK_ROOT}/build-tools"
+ "${ANDROID_SDK_ROOT}/build-tools/*")
+ if (NOT android_build_tools)
+ message(FATAL_ERROR "Could not locate Android SDK build tools under \"${ANDROID_SDK_ROOT}/build-tools\"")
+ endif()
+ list(SORT android_build_tools)
+ list(REVERSE android_build_tools)
+ list(GET android_build_tools 0 android_build_tools_latest)
+ endif()
+ set(${out_var} "${android_build_tools_latest}" PARENT_SCOPE)
+endfunction()
+
+# Generate the deployment settings json file for a cmake target.
function(qt6_android_generate_deployment_settings target)
# Information extracted from mkspecs/features/android/android_deployment_settings.prf
if (NOT TARGET ${target})
@@ -19,7 +38,7 @@ function(qt6_android_generate_deployment_settings target)
if (NOT target_output_name)
set(target_output_name ${target})
endif()
- set(deploy_file "${target_binary_dir}/android-lib${target_output_name}.so-deployment-settings.json")
+ set(deploy_file "${target_binary_dir}/android-${target_output_name}-deployment-settings.json")
set(file_contents "{\n")
# content begin
@@ -34,10 +53,10 @@ function(qt6_android_generate_deployment_settings target)
file(GLOB plugin_dir_files LIST_DIRECTORIES FALSE "${glob_expression}")
if (NOT plugin_dir_files)
message(SEND_ERROR
- "Detected Qt installation does not contain qtforandroid_${CMAKE_ANDROID_ARCH_ABI}.so in the following dir:
-${android_plugin_dir_path}
-This is most likely due to the installation not being a Qt for Android build.
-Please recheck your build configuration.")
+ "Detected Qt installation does not contain qtforandroid_${CMAKE_ANDROID_ARCH_ABI}.so in the following dir:"
+ "${android_plugin_dir_path}"
+ "This is most likely due to the installation not being a Qt for Android build."
+ "Please recheck your build configuration.")
return()
else()
list(GET plugin_dir_files 0 android_platform_plugin_path)
@@ -49,21 +68,22 @@ Please recheck your build configuration.")
set(qt_android_install_dir "${CMAKE_INSTALL_PREFIX}")
endif()
- file(TO_NATIVE_PATH "${qt_android_install_dir}" qt_android_install_dir_native)
+ file(TO_CMAKE_PATH "${qt_android_install_dir}" qt_android_install_dir_native)
string(APPEND file_contents
" \"qt\": \"${qt_android_install_dir_native}\",\n")
# Android SDK path
- file(TO_NATIVE_PATH "${ANDROID_SDK_ROOT}" android_sdk_root_native)
+ file(TO_CMAKE_PATH "${ANDROID_SDK_ROOT}" android_sdk_root_native)
string(APPEND file_contents
" \"sdk\": \"${android_sdk_root_native}\",\n")
# Android SDK Build Tools Revision
+ _qt_internal_android_get_sdk_build_tools_revision(QT_ANDROID_SDK_BUILD_TOOLS_REVISION)
string(APPEND file_contents
- " \"sdkBuildToolsRevision\": \"${QT_ANDROID_SDK_BUILD_TOOLS_VERSION}\",\n")
+ " \"sdkBuildToolsRevision\": \"${QT_ANDROID_SDK_BUILD_TOOLS_REVISION}\",\n")
# Android NDK
- file(TO_NATIVE_PATH "${ANDROID_NDK}" android_ndk_root_native)
+ file(TO_CMAKE_PATH "${ANDROID_NDK}" android_ndk_root_native)
string(APPEND file_contents
" \"ndk\": \"${android_ndk_root_native}\",\n")
@@ -107,8 +127,7 @@ Please recheck your build configuration.")
endif()
# Extra plugins
- get_target_property(android_extra_plugins
- ${target} QT_ANDROID_EXTRA_PLUGINS)
+ get_target_property(android_extra_plugins ${target} QT_ANDROID_EXTRA_PLUGINS)
if (android_extra_plugins)
list(JOIN android_extra_plugins "," android_extra_plugins)
string(APPEND file_contents
@@ -116,8 +135,7 @@ Please recheck your build configuration.")
endif()
# Extra libs
- get_target_property(android_extra_libs
- ${target} QT_ANDROID_EXTRA_LIBS)
+ get_target_property(android_extra_libs ${target} QT_ANDROID_EXTRA_LIBS)
if (android_extra_libs)
list(JOIN android_extra_libs "," android_extra_libs)
string(APPEND file_contents
@@ -125,13 +143,12 @@ Please recheck your build configuration.")
endif()
# package source dir
- get_target_property(android_package_source_dir
- ${target} QT_ANDROID_PACKAGE_SOURCE_DIR)
+ get_target_property(android_package_source_dir ${target} QT_ANDROID_PACKAGE_SOURCE_DIR)
if (android_package_source_dir)
- file(TO_NATIVE_PATH "${android_package_source_dir}" android_package_source_dir_native)
+ file(TO_CMAKE_PATH "${android_package_source_dir}" android_package_source_dir_native)
string(APPEND file_contents
" \"android-package-source-directory\": \"${android_package_source_dir_native}\",\n")
-endif()
+ endif()
#TODO: ANDROID_VERSION_NAME, doesn't seem to be used?
@@ -139,7 +156,7 @@ endif()
get_target_property(qml_import_path ${target} QT_QML_IMPORT_PATH)
if (qml_import_path)
- file(TO_NATIVE_PATH "${qml_import_path}" qml_import_path_native)
+ file(TO_CMAKE_PATH "${qml_import_path}" qml_import_path_native)
string(APPEND file_contents
" \"qml-import-path\": \"${qml_import_path_native}\",\n")
endif()
@@ -148,7 +165,7 @@ endif()
if(NOT qml_root_path)
set(qml_root_path "${target_source_dir}")
endif()
- file(TO_NATIVE_PATH "${qml_root_path}" qml_root_path_native)
+ file(TO_CMAKE_PATH "${qml_root_path}" qml_root_path_native)
string(APPEND file_contents
" \"qml-root-path\": \"${qml_root_path_native}\",\n")
@@ -156,12 +173,18 @@ endif()
string(APPEND file_contents
" \"application-binary\": \"${target_output_name}\",\n")
+ # App command-line arguments
+ if (QT_ANDROID_APPLICATION_ARGUMENTS)
+ string(APPEND file_contents
+ " \"android-application-arguments\": \"${QT_ANDROID_APPLICATION_ARGUMENTS}\",\n")
+ endif()
+
# Override qmlimportscanner binary path
set(qml_importscanner_binary_path "${QT_HOST_PATH}/bin/qmlimportscanner")
if (WIN32)
string(APPEND qml_importscanner_binary_path ".exe")
endif()
- file(TO_NATIVE_PATH "${qml_importscanner_binary_path}" qml_importscanner_binary_path_native)
+ file(TO_CMAKE_PATH "${qml_importscanner_binary_path}" qml_importscanner_binary_path_native)
string(APPEND file_contents
" \"qml-importscanner-binary\" : \"${qml_importscanner_binary_path_native}\",\n")
@@ -170,10 +193,21 @@ endif()
if (WIN32)
string(APPEND rcc_binary_path ".exe")
endif()
- file(TO_NATIVE_PATH "${rcc_binary_path}" rcc_binary_path_native)
+ file(TO_CMAKE_PATH "${rcc_binary_path}" rcc_binary_path_native)
string(APPEND file_contents
" \"rcc-binary\" : \"${rcc_binary_path_native}\",\n")
+ # Extra prefix paths
+ foreach(prefix IN LISTS CMAKE_FIND_ROOT_PATH)
+ if (NOT "${prefix}" STREQUAL "${qt_android_install_dir_native}"
+ AND NOT "${prefix}" STREQUAL "${android_ndk_root_native}")
+ list(APPEND extra_prefix_list \"${prefix}\")
+ endif()
+ endforeach()
+ string (REPLACE ";" "," extra_prefix_list "${extra_prefix_list}")
+ string(APPEND file_contents
+ " \"extraPrefixDirs\" : [ ${extra_prefix_list} ],\n")
+
# Last item in json file
# base location of stdlibc++, will be suffixed by androiddeploy qt
@@ -250,6 +284,7 @@ function(qt6_android_add_apk_target target)
COMMAND ${deployment_tool}
--input ${deployment_file}
--output ${apk_dir}
+ --apk ${apk_dir}/${target}.apk
COMMENT "Creating APK for ${target}"
)
diff --git a/src/corelib/Qt6CTestMacros.cmake b/src/corelib/Qt6CTestMacros.cmake
index d1ea0a350d..50cc40939a 100644
--- a/src/corelib/Qt6CTestMacros.cmake
+++ b/src/corelib/Qt6CTestMacros.cmake
@@ -32,7 +32,8 @@ if (CMAKE_BUILD_TYPE)
endif()
if (CMAKE_TOOLCHAIN_FILE)
- list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
+ file(TO_CMAKE_PATH "${CMAKE_TOOLCHAIN_FILE}" _CMAKE_TOOLCHAIN_FILE)
+ list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_TOOLCHAIN_FILE=${_CMAKE_TOOLCHAIN_FILE}")
endif()
if (CMAKE_VERBOSE_MAKEFILE)
@@ -112,7 +113,7 @@ function(_qt_internal_set_up_test_run_environment testname)
endfunction()
-macro(expect_pass _dir)
+macro(_qt_internal_test_expect_pass _dir)
cmake_parse_arguments(_ARGS "" "BINARY" "" ${ARGN})
string(REPLACE "(" "_" testname "${_dir}")
string(REPLACE ")" "_" testname "${testname}")
@@ -136,13 +137,16 @@ macro(expect_pass _dir)
endif()
endmacro()
-macro(expect_fail _dir)
+macro(_qt_internal_test_expect_fail _dir)
string(REPLACE "(" "_" testname "${_dir}")
string(REPLACE ")" "_" testname "${testname}")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}")
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/${_dir}/FindPackageHints.cmake" "set(Qt6Tests_PREFIX_PATH \"${CMAKE_PREFIX_PATH}\")")
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/${_dir}/FindPackageHints.cmake"
+ "set(Qt6Tests_PREFIX_PATH \"${CMAKE_PREFIX_PATH}\")
+list(APPEND CMAKE_PREFIX_PATH \"${CMAKE_PREFIX_PATH}\")
+")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/CMakeLists.txt"
"
@@ -172,7 +176,7 @@ macro(expect_fail _dir)
)
endmacro()
-function(test_module_includes)
+function(_qt_internal_test_module_includes)
set(all_args ${ARGN})
set(packages_string "")
diff --git a/src/corelib/Qt6Config.cmake.in b/src/corelib/Qt6Config.cmake.in
deleted file mode 100644
index 6b6544f932..0000000000
--- a/src/corelib/Qt6Config.cmake.in
+++ /dev/null
@@ -1,51 +0,0 @@
-
-if (CMAKE_VERSION VERSION_LESS 3.1.0)
- message(FATAL_ERROR \"Qt5 requires at least CMake version 3.1.0\")
-endif()
-
-if (NOT Qt5_FIND_COMPONENTS)
- set(Qt5_NOT_FOUND_MESSAGE \"The Qt5 package requires at least one component\")
- set(Qt5_FOUND False)
- return()
-endif()
-
-set(_Qt5_FIND_PARTS_REQUIRED)
-if (Qt5_FIND_REQUIRED)
- set(_Qt5_FIND_PARTS_REQUIRED REQUIRED)
-endif()
-set(_Qt5_FIND_PARTS_QUIET)
-if (Qt5_FIND_QUIETLY)
- set(_Qt5_FIND_PARTS_QUIET QUIET)
-endif()
-
-get_filename_component(_qt5_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/..\" ABSOLUTE)
-
-set(_Qt5_NOTFOUND_MESSAGE)
-
-include(${CMAKE_CURRENT_LIST_DIR}/Qt5ModuleLocation.cmake)
-
-foreach(module ${Qt5_FIND_COMPONENTS})
- find_package(Qt5${module}
- ${_Qt5_FIND_PARTS_QUIET}
- ${_Qt5_FIND_PARTS_REQUIRED}
- PATHS ${_qt5_module_paths} NO_DEFAULT_PATH
- )
- if (NOT Qt5${module}_FOUND)
- string(CONFIGURE ${_qt5_module_location_template} _expected_module_location @ONLY)
-
- if (Qt5_FIND_REQUIRED_${module})
- set(_Qt5_NOTFOUND_MESSAGE \"${_Qt5_NOTFOUND_MESSAGE}Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_expected_module_location}\\\"\\n\")
- elseif(NOT Qt5_FIND_QUIETLY)
- message(WARNING \"Failed to find Qt5 component \\\"${module}\\\" config file at \\\"${_expected_module_location}\\\"\")
- endif()
-
- unset(_expected_module_location)
- endif()
-endforeach()
-
-if (_Qt5_NOTFOUND_MESSAGE)
- set(Qt5_NOT_FOUND_MESSAGE \"${_Qt5_NOTFOUND_MESSAGE}\")
- set(Qt5_FOUND False)
-endif()
-
-_qt5_Core_check_file_exists(\"${CMAKE_CURRENT_LIST_DIR}/Qt5ConfigVersion.cmake\")
diff --git a/src/corelib/Qt6CoreConfigExtras.cmake.in b/src/corelib/Qt6CoreConfigExtras.cmake.in
index c43e4f772e..5c4468fa10 100644
--- a/src/corelib/Qt6CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt6CoreConfigExtras.cmake.in
@@ -47,6 +47,8 @@ set(QT@PROJECT_VERSION_MAJOR@_IS_SHARED_LIBS_BUILD "@BUILD_SHARED_LIBS@")
get_filename_component(_Qt6CoreConfigDir ${CMAKE_CURRENT_LIST_FILE} PATH)
set(_Qt6CTestMacros "${_Qt6CoreConfigDir}/Qt6CTestMacros.cmake")
+@qtcore_extra_cmake_code@
+
if(ANDROID_PLATFORM)
include("${CMAKE_CURRENT_LIST_DIR}/@QT_CMAKE_EXPORT_NAMESPACE@AndroidMacros.cmake")
endif()
diff --git a/src/corelib/Qt6CoreConfigExtrasMkspecDir.cmake.in b/src/corelib/Qt6CoreConfigExtrasMkspecDir.cmake.in
deleted file mode 100644
index c357237d0e..0000000000
--- a/src/corelib/Qt6CoreConfigExtrasMkspecDir.cmake.in
+++ /dev/null
@@ -1,6 +0,0 @@
-
-!!IF isEmpty(CMAKE_HOST_DATA_DIR_IS_ABSOLUTE)
-set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
-!!ELSE
-set(_qt5_corelib_extra_includes \"$${CMAKE_HOST_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
-!!ENDIF
diff --git a/src/corelib/Qt6CoreConfigExtrasMkspecDirForInstall.cmake.in b/src/corelib/Qt6CoreConfigExtrasMkspecDirForInstall.cmake.in
deleted file mode 100644
index 706304cf34..0000000000
--- a/src/corelib/Qt6CoreConfigExtrasMkspecDirForInstall.cmake.in
+++ /dev/null
@@ -1,6 +0,0 @@
-
-!!IF isEmpty(CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE)
-set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
-!!ELSE
-set(_qt5_corelib_extra_includes \"$${CMAKE_INSTALL_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
-!!ENDIF
diff --git a/src/corelib/Qt6CoreConfigureFileTemplate.in b/src/corelib/Qt6CoreConfigureFileTemplate.in
new file mode 100644
index 0000000000..5ed5cae0a7
--- /dev/null
+++ b/src/corelib/Qt6CoreConfigureFileTemplate.in
@@ -0,0 +1 @@
+@qt_core_configure_file_contents@
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 34e5efb5e9..bb1deffd04 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -38,8 +38,10 @@
include(CMakeParseArguments)
+set(__qt_core_macros_module_base_dir "${CMAKE_CURRENT_LIST_DIR}")
+
# macro used to create the names of output files preserving relative dirs
-macro(qt6_make_output_file infile prefix ext outfile )
+macro(_qt_internal_make_output_file infile prefix ext outfile )
string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
string(LENGTH ${infile} _infileLength)
set(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
@@ -71,8 +73,7 @@ macro(qt6_make_output_file infile prefix ext outfile )
set(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
endmacro()
-
-macro(qt6_get_moc_flags _moc_flags)
+macro(_qt_internal_get_moc_flags _moc_flags)
set(${_moc_flags})
get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
@@ -102,9 +103,8 @@ macro(qt6_get_moc_flags _moc_flags)
endif()
endmacro()
-
# helper macro to set up a moc rule
-function(qt6_create_moc_command infile outfile moc_flags moc_options moc_target moc_depends)
+function(_qt_internal_create_moc_command infile outfile moc_flags moc_options moc_target moc_depends)
# Pass the parameters in a file. Set the working directory to
# be that containing the parameters file and reference it by
# just the file name. This is necessary because the moc tool on
@@ -149,10 +149,9 @@ function(qt6_create_moc_command infile outfile moc_flags moc_options moc_target
set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON)
endfunction()
-
function(qt6_generate_moc infile outfile )
# get include dirs and flags
- qt6_get_moc_flags(moc_flags)
+ _qt_internal_get_moc_flags(moc_flags)
get_filename_component(abs_infile ${infile} ABSOLUTE)
set(_outfile "${outfile}")
if(NOT IS_ABSOLUTE "${outfile}")
@@ -161,7 +160,7 @@ function(qt6_generate_moc infile outfile )
if ("x${ARGV2}" STREQUAL "xTARGET")
set(moc_target ${ARGV3})
endif()
- qt6_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "")
+ _qt_internal_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "")
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
@@ -179,7 +178,7 @@ endif()
function(qt6_wrap_cpp outfiles )
# get include dirs
- qt6_get_moc_flags(moc_flags)
+ _qt_internal_get_moc_flags(moc_flags)
set(options)
set(oneValueArgs TARGET)
@@ -194,8 +193,9 @@ function(qt6_wrap_cpp outfiles )
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
- qt6_make_output_file(${it} moc_ cpp outfile)
- qt6_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
+ _qt_internal_make_output_file(${it} moc_ cpp outfile)
+ _qt_internal_create_moc_command(
+ ${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
list(APPEND ${outfiles} ${outfile})
endforeach()
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
@@ -235,7 +235,7 @@ function(_qt6_parse_qrc_file infile _out_depends _rc_depends)
# Since this cmake macro is doing the dependency scanning for these files,
# let's make a configured file and add it as a dependency so cmake is run
# again when dependencies need to be recomputed.
- qt6_make_output_file("${infile}" "" "qrc.depends" out_depends)
+ _qt_internal_make_output_file("${infile}" "" "qrc.depends" out_depends)
configure_file("${infile}" "${out_depends}" COPYONLY)
else()
# The .qrc file does not exist (yet). Let's add a dependency and hope
@@ -308,7 +308,7 @@ endif()
function(qt6_add_resources outfiles )
if (TARGET ${outfiles})
cmake_parse_arguments(arg "" "OUTPUT_TARGETS" "" ${ARGN})
- qt6_process_resource(${ARGV})
+ _qt_internal_process_resource(${ARGV})
if (arg_OUTPUT_TARGETS)
set(${arg_OUTPUT_TARGETS} ${${arg_OUTPUT_TARGETS}} PARENT_SCOPE)
endif()
@@ -424,8 +424,13 @@ endif()
set(_Qt6_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
-function(add_qt_gui_executable target)
+# This function is currently in Technical Preview.
+# It's signature and behavior might change.
+#
+# Wrapper function that adds an executable with some Qt specific behavior.
+function(qt6_add_executable target)
if(ANDROID)
+ list(REMOVE_ITEM ARGN "WIN32" "MACOSX_BUNDLE")
add_library("${target}" MODULE ${ARGN})
# On our qmake builds we do don't compile the executables with
# visibility=hidden. Not having this flag set will cause the
@@ -435,18 +440,11 @@ function(add_qt_gui_executable target)
set_property(TARGET "${target}" PROPERTY CXX_VISIBILITY_PRESET default)
set_property(TARGET "${target}" PROPERTY OBJC_VISIBILITY_PRESET default)
set_property(TARGET "${target}" PROPERTY OBJCXX_VISIBILITY_PRESET default)
- qt_android_apply_arch_suffix("${target}")
+ qt6_android_apply_arch_suffix("${target}")
else()
- add_executable("${target}" WIN32 MACOSX_BUNDLE ${ARGN})
+ add_executable("${target}" ${ARGN})
endif()
target_link_libraries("${target}" PRIVATE Qt::Core)
- if(TARGET Qt::Gui)
- target_link_libraries("${target}" PRIVATE Qt::Gui)
- endif()
-
- if (WIN32)
- qt6_generate_win32_rc_file(${target})
- endif()
if(ANDROID)
qt_android_generate_deployment_settings("${target}")
@@ -454,6 +452,18 @@ function(add_qt_gui_executable target)
endif()
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_executable)
+ qt6_add_executable(${ARGV})
+ endfunction()
+endif()
+
+# Temporarily keep compatibility, until all repositories are migrated.
+function(add_qt_gui_executable)
+ message(AUTHOR_WARNING "Please replace add_qt_gui_executable with qt_add_executable instead. The former will be removed shortly.")
+ qt6_add_executable(${ARGV})
+endfunction()
+
function(_qt_get_plugin_name_with_version target out_var)
string(REGEX REPLACE "^Qt::(.+)" "Qt${QT_DEFAULT_MAJOR_VERSION}::\\1"
qt_plugin_with_version "${target}")
@@ -563,18 +573,19 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
endif()
-# Generate Qt metatypes.json for a target. By default we check whether AUTOMOC
-# has been enabled and we extract the information from that target. Should you
-# not wish to use automoc you need to pass in all the generated json files via the
+# Extracts metatypes from a Qt target and generates a metatypes.json for it.
+# By default we check whether AUTOMOC has been enabled and we extract the information from the
+# target's AUTOMOC supporting files.
+# Should you not wish to use automoc you need to pass in all the generated json files via the
# MANUAL_MOC_JSON_FILES parameter. The latter can be obtained by running moc with
# the --output-json parameter.
# Params:
# INSTALL_DIR: Location where to install the metatypes file. For public consumption,
-# defaults to a ${CMAKE_INSTALL_PREFIX}/lib/metatypes directory.
+# defaults to a ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}/metatypes directory.
# Executable metatypes files are never installed.
# COPY_OVER_INSTALL: (Qt Internal) When present will install the file via a post build step
# copy rather than using install.
-function(qt6_generate_meta_types_json_file target)
+function(qt6_extract_metatypes target)
get_target_property(existing_meta_types_file ${target} INTERFACE_QT_META_TYPES_BUILD_FILE)
if (existing_meta_types_file)
@@ -604,7 +615,12 @@ function(qt6_generate_meta_types_json_file target)
# Automatically fill default install args when not specified.
if (NOT arg_INSTALL_DIR)
- set(arg_INSTALL_DIR "lib/metatypes")
+ # INSTALL_LIBDIR is not set when QtBuildInternals is not loaded (when not doing a Qt build).
+ if(INSTALL_LIBDIR)
+ set(arg_INSTALL_DIR "${INSTALL_LIBDIR}/metatypes")
+ else()
+ set(arg_INSTALL_DIR "lib/metatypes")
+ endif()
endif()
get_target_property(target_binary_dir ${target} BINARY_DIR)
@@ -743,7 +759,7 @@ function(qt6_generate_meta_types_json_file target)
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${metatypes_file_gen}
${metatypes_file}
- COMMENT "Runing automoc with --collect-json"
+ COMMENT "Running automoc with --collect-json"
)
# We still need to add this file as a source of Core, otherwise the file
@@ -820,8 +836,8 @@ function(qt6_generate_meta_types_json_file target)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
- function(qt_generate_meta_types_json_file)
- qt6_generate_meta_types_json_file(${ARGV})
+ function(qt_extract_metatypes)
+ qt6_extract_metatypes(${ARGV})
endfunction()
endif()
@@ -842,7 +858,7 @@ endif()
# If you do not wish to auto-generate rc files, it's possible to provide your
# own RC file by setting the property QT_TARGET_WINDOWS_RC_FILE with a path to
# an existing rc file.
-function(qt6_generate_win32_rc_file target)
+function(_qt_internal_generate_win32_rc_file target)
set(prohibited_target_types INTERFACE_LIBRARY STATIC_LIBRARY OBJECT_LIBRARY)
get_target_property(target_type ${target} TYPE)
if(target_type IN_LIST prohibited_target_types)
@@ -1013,6 +1029,13 @@ END
set(cfgs "${CMAKE_BUILD_TYPE}")
set(outputs "${rc_file_output}")
endif()
+
+ # We would like to do the following:
+ # target_sources(${target} PRIVATE "$<$<CONFIG:${cfg}>:${output}>")
+ # However, https://gitlab.kitware.com/cmake/cmake/-/issues/20682 doesn't let us.
+ # Work-around by compiling the resources in an object lib and linking that.
+ add_library(${target}_rc OBJECT "${output}")
+ target_link_libraries(${target} PRIVATE $<TARGET_OBJECTS:${target}_rc>)
while(outputs)
list(POP_FRONT cfgs cfg)
list(POP_FRONT outputs output)
@@ -1021,12 +1044,7 @@ END
DEPENDS "${input}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${input}" "${output}"
)
-
- # We would like to do the following:
- # target_sources(${target} PRIVATE "$<$<CONFIG:${cfg}>:${output}>")
- # However, https://gitlab.kitware.com/cmake/cmake/-/issues/20682 doesn't let us.
- add_library(${target}_${cfg}_rc OBJECT "${output}")
- target_link_libraries(${target} PRIVATE "$<$<CONFIG:${cfg}>:${target}_${cfg}_rc>")
+ target_sources(${target}_rc PRIVATE "$<$<CONFIG:${cfg}>:${output}>")
endwhile()
endif()
endfunction()
@@ -1042,9 +1060,20 @@ endfunction()
function(__qt_propagate_generated_resource target resource_name generated_source_code output_generated_target)
get_target_property(type ${target} TYPE)
if(type STREQUAL STATIC_LIBRARY)
- set(resource_target "${target}_resources_${resourceName}")
+ set(resource_target "${target}_resources_${resource_name}")
add_library("${resource_target}" OBJECT "${generated_source_code}")
- set_property(TARGET ${resource_target} APPEND PROPERTY QT_RESOURCE_NAME ${resourceName})
+ set_property(TARGET ${resource_target} APPEND PROPERTY _qt_resource_name ${resource_name})
+
+ # Save the path to the generated source file, relative to the the current build dir.
+ # The path will be used in static library prl file generation to ensure qmake links
+ # against the installed resource object files.
+ # Example saved path:
+ # .rcc/qrc_qprintdialog.cpp
+ file(RELATIVE_PATH generated_cpp_file_relative_path
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ "${generated_source_code}")
+ set_property(TARGET ${resource_target} APPEND PROPERTY
+ _qt_resource_generated_cpp_relative_path "${generated_cpp_file_relative_path}")
# Use TARGET_NAME genex to map to the correct prefixed target name when it is exported
# via qt_install(EXPORT), so that the consumers of the target can find the object library
@@ -1058,6 +1087,22 @@ function(__qt_propagate_generated_resource target resource_name generated_source
endif()
endfunction()
+# Creates fake targets and adds resource files to IDE's tree
+function(_qt_internal_expose_source_file_to_ide target file)
+ set(ide_target_extension "other_files")
+ set(qml_extensions ".qml" ".js")
+ get_filename_component(resource_extension "${file}" LAST_EXT)
+ if(resource_extension IN_LIST qml_extensions)
+ set(ide_target_extension "qml_files")
+ endif()
+
+ set(ide_target ${target}_${ide_target_extension})
+ if(NOT TARGET ${ide_target})
+ add_custom_target(${ide_target} SOURCES "${file}")
+ else()
+ set_property(TARGET ${ide_target} APPEND PROPERTY SOURCES "${file}")
+ endif()
+endfunction()
#
# Process resources via file path instead of QRC files. Behind the
@@ -1073,9 +1118,13 @@ endfunction()
# will be generated. Should you wish to perform additional processing on these
# targets pass a value to the OUTPUT_TARGETS parameter.
#
-function(QT6_PROCESS_RESOURCE target resourceName)
+function(_qt_internal_process_resource target resourceName)
- cmake_parse_arguments(rcc "" "PREFIX;LANG;BASE;OUTPUT_TARGETS" "FILES;OPTIONS" ${ARGN})
+ cmake_parse_arguments(rcc "" "PREFIX;LANG;BASE;OUTPUT_TARGETS;DESTINATION" "FILES;OPTIONS" ${ARGN})
+
+ if("${rcc_OPTIONS}" MATCHES "-binary")
+ set(isBinary TRUE)
+ endif()
string(REPLACE "/" "_" resourceName ${resourceName})
string(REPLACE "." "_" resourceName ${resourceName})
@@ -1103,14 +1152,14 @@ function(QT6_PROCESS_RESOURCE target resourceName)
if(NOT rcc_PREFIX)
get_target_property(rcc_PREFIX ${target} QT_RESOURCE_PREFIX)
if (NOT rcc_PREFIX)
- message(FATAL_ERROR "QT6_PROCESS_RESOURCE() was called without a PREFIX and the target does not provide QT_RESOURCE_PREFIX. Please either add a PREFIX or make the target ${target} provide a default.")
+ message(FATAL_ERROR "_qt_internal_process_resource() was called without a PREFIX and the target does not provide QT_RESOURCE_PREFIX. Please either add a PREFIX or make the target ${target} provide a default.")
endif()
endif()
# Apply quick compiler pass. This is only enabled when Qt6QmlMacros is
# parsed.
if (QT6_ADD_RESOURCE_DECLARATIVE_EXTENSIONS)
- qt6_quick_compiler_process_resources(${target} ${resourceName}
+ _qt_internal_quick_compiler_process_resources(${target} ${resourceName}
FILES ${resource_files}
PREFIX ${rcc_PREFIX}
OUTPUT_REMAINING_RESOURCES resources
@@ -1129,8 +1178,8 @@ function(QT6_PROCESS_RESOURCE target resourceName)
return()
endif()
list(APPEND output_targets ${output_target_quick})
- set(generatedResourceFile "${CMAKE_CURRENT_BINARY_DIR}/.rcc/generated_${newResourceName}.qrc")
- set(generatedSourceCode "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qrc_${newResourceName}.cpp")
+ set(generatedBaseName "${newResourceName}")
+ set(generatedResourceFile "${CMAKE_CURRENT_BINARY_DIR}/.rcc/${generatedBaseName}.qrc")
# Generate .qrc file:
@@ -1167,15 +1216,18 @@ function(QT6_PROCESS_RESOURCE target resourceName)
endif()
list(APPEND resource_dependencies ${target_dependency})
endif()
+ _qt_internal_expose_source_file_to_ide(${target} "${file}")
endforeach()
# </qresource></RCC>
string(APPEND qrcContents " </qresource>\n</RCC>\n")
- file(GENERATE OUTPUT "${generatedResourceFile}" CONTENT "${qrcContents}")
+ set(template_file "${__qt_core_macros_module_base_dir}/Qt6CoreConfigureFileTemplate.in")
+ set(qt_core_configure_file_contents "${qrcContents}")
+ configure_file("${template_file}" "${generatedResourceFile}")
+
+ set(rccArgs --name "${newResourceName}" "${generatedResourceFile}")
- set(rccArgs --name "${newResourceName}"
- --output "${generatedSourceCode}" "${generatedResourceFile}")
if(rcc_OPTIONS)
list(APPEND rccArgs ${rcc_OPTIONS})
endif()
@@ -1190,10 +1242,29 @@ function(QT6_PROCESS_RESOURCE target resourceName)
list(APPEND rccArgs "--no-zstd")
endif()
+ set_property(SOURCE "${generatedResourceFile}" PROPERTY SKIP_AUTOGEN ON)
+
+ # Set output file name for rcc command
+ if(isBinary)
+ set(generatedOutfile "${CMAKE_CURRENT_BINARY_DIR}/${generatedBaseName}.rcc")
+ if(rcc_DESTINATION)
+ # Add .rcc suffix if it's not specified by user
+ get_filename_component(destinationRccExt "${rcc_DESTINATION}" LAST_EXT)
+ if("${destinationRccExt}" STREQUAL ".rcc")
+ set(generatedOutfile "${rcc_DESTINATION}")
+ else()
+ set(generatedOutfile "${rcc_DESTINATION}.rcc")
+ endif()
+ endif()
+ else()
+ set(generatedOutfile "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qrc_${newResourceName}.cpp")
+ endif()
+
+ list(PREPEND rccArgs --output "${generatedOutfile}")
+
# Process .qrc file:
- add_custom_command(OUTPUT "${generatedSourceCode}"
- COMMAND "${QT_CMAKE_EXPORT_NAMESPACE}::rcc"
- ARGS ${rccArgs}
+ add_custom_command(OUTPUT "${generatedOutfile}"
+ COMMAND "${QT_CMAKE_EXPORT_NAMESPACE}::rcc" ${rccArgs}
DEPENDS
${resource_dependencies}
${generatedResourceFile}
@@ -1201,26 +1272,34 @@ function(QT6_PROCESS_RESOURCE target resourceName)
COMMENT "RCC ${newResourceName}"
VERBATIM)
- get_target_property(type "${target}" TYPE)
- # Only do this if newResourceName is the same as resourceName, since
- # the resource will be chainloaded by the qt quickcompiler
- # qml cache loader
- if(newResourceName STREQUAL resourceName)
- __qt_propagate_generated_resource(${target} ${resourceName} "${generatedSourceCode}" output_target)
- list(APPEND output_targets ${output_target})
+ if(isBinary)
+ # Add generated .rcc target to 'all' set
+ add_custom_target(binary_resource_${generatedBaseName} ALL DEPENDS "${generatedOutfile}")
else()
- target_sources(${target} PRIVATE "${generatedSourceCode}")
- endif()
- if (rcc_OUTPUT_TARGETS)
- set(${rcc_OUTPUT_TARGETS} "${output_targets}" PARENT_SCOPE)
+ set_property(SOURCE "${generatedOutfile}" PROPERTY SKIP_AUTOGEN ON)
+ set_property(TARGET ${target} APPEND PROPERTY _qt_generated_qrc_files "${generatedResourceFile}")
+
+ # Only do this if newResourceName is the same as resourceName, since
+ # the resource will be chainloaded by the qt quickcompiler
+ # qml cache loader
+ if(newResourceName STREQUAL resourceName)
+ __qt_propagate_generated_resource(${target} ${resourceName} "${generatedOutfile}" output_target)
+ list(APPEND output_targets ${output_target})
+ else()
+ target_sources(${target} PRIVATE "${generatedOutfile}")
+ endif()
+ if (rcc_OUTPUT_TARGETS)
+ set(${rcc_OUTPUT_TARGETS} "${output_targets}" PARENT_SCOPE)
+ endif()
endif()
endfunction()
+# This function is currently in Technical Preview.
+# It's signature and behavior might change.
function(qt6_add_plugin target)
cmake_parse_arguments(arg
"STATIC"
- "OUTPUT_NAME"
- "CLASS_NAME"
+ "OUTPUT_NAME;CLASS_NAME;TYPE"
""
${ARGN}
)
@@ -1246,7 +1325,7 @@ function(qt6_add_plugin target)
set_property(TARGET "${target}" PROPERTY OUTPUT_NAME "${output_name}")
if (ANDROID)
- qt_android_apply_arch_suffix("${target}")
+ qt6_android_apply_arch_suffix("${target}")
set_target_properties(${target}
PROPERTIES
LIBRARY_OUTPUT_NAME "plugins_${arg_TYPE}_${output_name}"
@@ -1275,22 +1354,23 @@ endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_add_plugin)
- if (NOT DEFINED QT_DISABLE_QT_ADD_PLUGIN_COMPATIBILITY
- OR NOT QT_DISABLE_QT_ADD_PLUGIN_COMPATIBILITY)
- qt_internal_add_plugin(${ARGV})
- else()
- qt6_add_plugin(${ARGV})
- endif()
+ qt6_add_plugin(${ARGV})
endfunction()
endif()
# By default Qt6 forces usage of utf8 sources for consumers of Qt.
# Users can opt out of utf8 sources by calling this function with the target name of their
# application or library.
-function(qt_disable_utf8_sources target)
+function(qt6_allow_non_utf8_sources target)
set_target_properties("${target}" PROPERTIES QT_NO_UTF8_SOURCE TRUE)
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_allow_non_utf8_sources)
+ qt6_allow_non_utf8_sources(${ARGV})
+ endfunction()
+endif()
+
function(_qt_internal_apply_strict_cpp target)
# Disable C, Obj-C and C++ GNU extensions aka no "-std=gnu++11".
# Similar to mkspecs/features/default_post.prf's CONFIG += strict_cpp.
diff --git a/src/corelib/Qt6ModuleLocation.cmake.in b/src/corelib/Qt6ModuleLocation.cmake.in
deleted file mode 100644
index cf70f6bc0e..0000000000
--- a/src/corelib/Qt6ModuleLocation.cmake.in
+++ /dev/null
@@ -1,15 +0,0 @@
-!!IF !isEmpty(_QMAKE_SUPER_CACHE_)
-get_filename_component(_qt5_root_dir \"${CMAKE_CURRENT_LIST_DIR}/../../../..\" ABSOLUTE)
-
-file(GLOB qtmodules ${_qt5_root_dir} "${_qt5_root_dir}/*")
-foreach(qtmodule ${qtmodules})
- if(IS_DIRECTORY ${qtmodule})
- list(APPEND _qt5_module_paths "${qtmodule}" "${qtmodule}/lib/cmake")
- endif()
-endforeach()
-!!ELSE
-set(_qt5_root_dir ${_qt5_install_prefix})
-set(_qt5_module_paths ${_qt5_install_prefix})
-!!ENDIF
-
-set(_qt5_module_location_template ${_qt5_root_dir})
diff --git a/src/corelib/Qt6ModuleLocationForInstall.cmake.in b/src/corelib/Qt6ModuleLocationForInstall.cmake.in
deleted file mode 100644
index 8751e4acbc..0000000000
--- a/src/corelib/Qt6ModuleLocationForInstall.cmake.in
+++ /dev/null
@@ -1,6 +0,0 @@
-set(_qt5_root_dir ${_qt5_install_prefix})
-set(_qt5_module_paths ${_qt5_install_prefix})
-
-set(_qt5_at "@")
-set(_qt5_module_location_template ${_qt5_install_prefix}/Qt5${_qt5_at}module${_qt5_at}/Qt5${_qt5_at}module${_qt5_at}Config.cmake)
-unset(_qt5_at)
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index c0a119f8b3..133bc5689d 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -248,7 +248,7 @@ QUnifiedTimer *QUnifiedTimer::instance()
void QUnifiedTimer::maybeUpdateAnimationsToCurrentTime()
{
if (elapsed() - lastTick > 50)
- updateAnimationTimers(-1);
+ updateAnimationTimers();
}
qint64 QUnifiedTimer::elapsed() const
@@ -290,13 +290,13 @@ void QUnifiedTimer::stopAnimationDriver()
driver->stop();
}
-void QUnifiedTimer::updateAnimationTimers(qint64 currentTick)
+void QUnifiedTimer::updateAnimationTimers()
{
//setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations
- if(insideTick)
+ if (insideTick)
return;
- qint64 totalElapsed = currentTick > 0 ? currentTick : elapsed();
+ const qint64 totalElapsed = elapsed();
// ignore consistentTiming in case the pause timer is active
qint64 delta = (consistentTiming && !pauseTimer.isActive()) ?
@@ -423,7 +423,7 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event)
if (event->timerId() == pauseTimer.timerId()) {
// update current time on all timers
- updateAnimationTimers(-1);
+ updateAnimationTimers();
restart();
}
}
@@ -585,7 +585,7 @@ void QAnimationTimer::ensureTimerUpdate()
QAnimationTimer *inst = QAnimationTimer::instance(false);
QUnifiedTimer *instU = QUnifiedTimer::instance(false);
if (instU && inst && inst->isPaused)
- instU->updateAnimationTimers(-1);
+ instU->updateAnimationTimers();
}
void QAnimationTimer::updateAnimationsTime(qint64 delta)
@@ -773,23 +773,19 @@ QAnimationDriver::~QAnimationDriver()
}
/*!
- Advances the animation based to the specified \a timeStep. This function should
- be continuously called by the driver subclasses while the animation is running.
-
- If \a timeStep is positive, it will be used as the current time in the
- calculations; otherwise, the current clock time will be used.
+ Advances the animation. This function should be continuously called by
+ the driver subclasses while the animation is running.
- Since 5.4, the timeStep argument is ignored and elapsed() will be
- used instead in combination with the internal time offsets of the
- animation system.
+ The calculation of the new current time will use elapsed() in combination
+ with the internal time offsets of the animation system.
*/
-void QAnimationDriver::advanceAnimation(qint64 timeStep)
+void QAnimationDriver::advanceAnimation()
{
QUnifiedTimer *instance = QUnifiedTimer::instance();
// update current time on all top level animations
- instance->updateAnimationTimers(timeStep);
+ instance->updateAnimationTimers();
instance->restart();
}
@@ -802,7 +798,7 @@ void QAnimationDriver::advanceAnimation(qint64 timeStep)
void QAnimationDriver::advance()
{
- advanceAnimation(-1);
+ advanceAnimation();
}
diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h
index ed0a75ea1b..2bb1d52582 100644
--- a/src/corelib/animation/qabstractanimation.h
+++ b/src/corelib/animation/qabstractanimation.h
@@ -152,8 +152,7 @@ Q_SIGNALS:
void stopped();
protected:
- // ### Qt6: Remove timestep argument
- void advanceAnimation(qint64 timeStep = -1);
+ void advanceAnimation();
virtual void start();
virtual void stop();
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index 037d3be74f..e59c770280 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -185,7 +185,7 @@ public:
void restart();
void maybeUpdateAnimationsToCurrentTime();
- void updateAnimationTimers(qint64 currentTick);
+ void updateAnimationTimers();
//useful for profiling/debugging
int runningAnimationCount();
diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp
index 98ac04a14f..8b364384f4 100644
--- a/src/corelib/animation/qsequentialanimationgroup.cpp
+++ b/src/corelib/animation/qsequentialanimationgroup.cpp
@@ -293,7 +293,7 @@ QPauseAnimation *QSequentialAnimationGroup::insertPause(int index, int msecs)
/*!
\property QSequentialAnimationGroup::currentAnimation
- Returns the animation in the current time.
+ \brief the animation in the current time.
*/
QAbstractAnimation *QSequentialAnimationGroup::currentAnimation() const
{
diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake
index 1288666a3d..095b12ea96 100644
--- a/src/corelib/configure.cmake
+++ b/src/corelib/configure.cmake
@@ -643,8 +643,8 @@ qt_feature("mimetype-database" PRIVATE
)
qt_feature("pcre2"
LABEL "PCRE2"
- ENABLE INPUT_pcre STREQUAL 'qt'
- DISABLE INPUT_pcre STREQUAL 'no' OR INPUT_pcre STREQUAL 'system'
+ ENABLE INPUT_pcre STREQUAL 'qt' OR QT_FEATURE_system_pcre2
+ DISABLE INPUT_pcre STREQUAL 'no'
)
qt_feature_config("pcre2" QMAKE_PRIVATE_CONFIG)
qt_feature("system-pcre2" PRIVATE
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index 27fff51a0f..5e0bd51ec9 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -691,8 +691,8 @@
},
"pcre2": {
"label": "PCRE2",
- "disable": "input.pcre == 'no' || input.pcre == 'system'",
- "enable": "input.pcre == 'qt'",
+ "disable": "input.pcre == 'no'",
+ "enable": "input.pcre == 'qt' || features.system-pcre2",
"output": [ "privateConfig" ]
},
"system-pcre2": {
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 73479e2309..a32ab7abeb 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -24,7 +24,7 @@ QMAKE_DOCS = $$PWD/doc/qtcore.qdocconf
ANDROID_LIB_DEPENDENCIES = \
plugins/platforms/libplugins_platforms_qtforandroid.so
ANDROID_BUNDLED_JAR_DEPENDENCIES = \
- jar/QtAndroid.jar
+ jar/Qt$${QT_MAJOR_VERSION}Android.jar
ANDROID_PERMISSIONS = \
android.permission.INTERNET \
android.permission.WRITE_EXTERNAL_STORAGE
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index 28b926b732..895dcb7b0a 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -26,7 +26,9 @@ qhp.QtCore.subprojects.classes.sortPages = true
tagfile = ../../../doc/qtcore/qtcore.tags
-depends += activeqt qtdbus qtgui qtwidgets qtnetwork qtdoc qtmacextras qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake qtwinextras qtqml qtcmake
+# Make QtCore depend on all doc modules; this ensures complete inheritance
+# information for classes
+depends = *
headerdirs += ..
@@ -49,8 +51,5 @@ excludefiles += ../../../examples/widgets/tools/customcompleter/doc/src/customco
# Included in qttestlib.qdocconf instead
excludefiles += ../kernel/qtestsupport_core.cpp
-manifestmeta.highlighted.names = "QtCore/JSON Save Game Example" \
- "QtCore/Local Fortune*"
-
navigation.landingpage = "Qt Core"
navigation.cppclassespage = "Qt Core C++ Classes"
diff --git a/src/corelib/doc/snippets/cmake-macros/examples.cmake b/src/corelib/doc/snippets/cmake-macros/examples.cmake
index 913b39cb4f..820b28cf88 100644
--- a/src/corelib/doc/snippets/cmake-macros/examples.cmake
+++ b/src/corelib/doc/snippets/cmake-macros/examples.cmake
@@ -65,10 +65,10 @@ qt5_import_plugins(myapp
#! [qt_import_plugins]
add_executable(myapp main.cpp)
-target_link_libraries(myapp Qt::Gui Qt::Sql)
+target_link_libraries(myapp Qt5::Gui Qt5::Sql)
qt_import_plugins(myapp
- INCLUDE Qt::QCocoaIntegrationPlugin
- EXCLUDE Qt::QMinimalIntegrationPlugin
+ INCLUDE Qt5::QCocoaIntegrationPlugin
+ EXCLUDE Qt5::QMinimalIntegrationPlugin
INCLUDE_BY_TYPE imageformats Qt5::QGifPlugin Qt5::QJpegPlugin
EXCLUDE_BY_TYPE sqldrivers
)
diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp
index aa8a72be8a..e5ccf0bb48 100644
--- a/src/corelib/doc/snippets/code/doc_src_containers.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp
@@ -316,6 +316,6 @@ int j = *i; // Undefined behavior!
QList<int> list { 1, 2, 3, 4, 4, 5 };
QSet<int> set(list.begin(), list.end());
/*
- Will generate a QSet containing 1, 2, 4, 5.
+ Will generate a QSet containing 1, 2, 3, 4, 5.
*/
//! [25]
diff --git a/src/corelib/doc/snippets/code/doc_src_properties.cpp b/src/corelib/doc/snippets/code/doc_src_properties.cpp
index e026a47e23..838cb980f7 100644
--- a/src/corelib/doc/snippets/code/doc_src_properties.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_properties.cpp
@@ -59,9 +59,10 @@ Q_PROPERTY(type name
[SCRIPTABLE bool]
[STORED bool]
[USER bool]
+ [BINDABLE bindableProperty]
[CONSTANT]
- [FINAL])
- [REQUIRED]
+ [FINAL]
+ [REQUIRED])
//! [0]
@@ -106,7 +107,7 @@ class MyClass : public QObject
Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
public:
- MyClass(QObject *parent = 0);
+ MyClass(QObject *parent = nullptr);
~MyClass();
enum Priority { High, Low, VeryHigh, VeryLow };
diff --git a/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp b/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp
index 58f6b196b4..6e4df4a912 100644
--- a/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp
@@ -49,316 +49,19 @@
****************************************************************************/
//! [0]
-QStringList list;
-list << "one" << "two" << "three";
-
-qFill(list.begin(), list.end(), "eleven");
-// list: [ "eleven", "eleven", "eleven" ]
-//! [0]
-
-
-//! [1]
-qFill(list.begin() + 1, list.end(), "six");
-// list: [ "eleven", "six", "six" ]
-//! [1]
-
-
-//! [2]
-QChar resolveEntity(const QString &entity)
-{
- static const QLatin1String name_table[] = {
- "AElig", "Aacute", ..., "zwnj"
- };
- static const ushort value_table[] = {
- 0x0061, 0x00c1, ..., 0x200c
- };
- int N = sizeof(name_table) / sizeof(name_table[0]);
-
- const QLatin1String *name = qBinaryFind(name_table, name_table + N,
- entity);
- int index = name - name_table;
- if (index == N)
- return QChar();
-
- return QChar(value_table[index]);
-}
-//! [2]
-
-
-//! [3]
-QChar resolveEntity(const QString &entity)
-{
- static QMap<QString, int> entityMap;
-
- if (!entityMap) {
- entityMap.insert("AElig", 0x0061);
- entityMap.insert("Aacute", 0x00c1);
- ...
- entityMap.insert("zwnj", 0x200c);
- }
- return QChar(entityMap.value(entity));
-}
-//! [3]
-
-
-//! [4]
-QStringList list;
-list << "one" << "two" << "three";
-
-QList<QString> list1(3);
-qCopy(list.begin(), list.end(), list1.begin());
-// list1: [ "one", "two", "three" ]
-
-QList<QString> list2(8);
-qCopy(list.begin(), list.end(), list2.begin() + 2);
-// list2: [ "", "", "one", "two", "three", "", "", "" ]
-//! [4]
-
-
-//! [5]
-QStringList list;
-list << "one" << "two" << "three";
-
-QList<QString> backList(5);
-qCopyBackward(list.begin(), list.end(), backList.end());
-// backList: [ "", "", "one", "two", "three" ]
-//! [5]
-
-
-//! [6]
-QStringList listLeft;
-listLeft << "one" << "two" << "three";
-
-QList<QString> listRight(3);
-listRight[0] = "one";
-listRight[1] = "two";
-listRight[2] = "three";
-
-bool ret1 = qEqual(listLeft.begin(), listLeft.end(), listRight.begin());
-// ret1 == true
-
-listRight[2] = "seven";
-bool ret2 = qEqual(listLeft.begin(), listLeft.end(), listRight.begin());
-// ret2 == false
-//! [6]
-
-
-//! [7]
-QStringList list;
-list << "one" << "two" << "three";
-
-qFill(list.begin(), list.end(), "eleven");
-// list: [ "eleven", "eleven", "eleven" ]
-
-qFill(list.begin() + 1, list.end(), "six");
-// list: [ "eleven", "six", "six" ]
-//! [7]
-
-
-//! [8]
-QStringList list;
-list << "one" << "two" << "three";
-
-QStringList::iterator i1 = qFind(list.begin(), list.end(), "two");
-// i1 == list.begin() + 1
-
-QStringList::iterator i2 = qFind(list.begin(), list.end(), "seventy");
-// i2 == list.end()
-//! [8]
-
-
-//! [9]
-QList<int> list;
-list << 3 << 3 << 6 << 6 << 6 << 8;
-
-int countOf6 = 0;
-qCount(list.begin(), list.end(), 6, countOf6);
-// countOf6 == 3
-
-int countOf7 = 0;
-qCount(list.begin(), list.end(), 7, countOf7);
-// countOf7 == 0
-//! [9]
-
-
-//! [10]
double pi = 3.14;
double e = 2.71;
qSwap(pi, e);
// pi == 2.71, e == 3.14
-//! [10]
-
-
-//! [11]
-QList<int> list;
-list << 33 << 12 << 68 << 6 << 12;
-qSort(list.begin(), list.end());
-// list: [ 6, 12, 12, 33, 68 ]
-//! [11]
-
-
-//! [12]
-bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
-{
- return s1.toLower() < s2.toLower();
-}
-
-int doSomething()
-{
- QStringList list;
- list << "AlPha" << "beTA" << "gamma" << "DELTA";
- qSort(list.begin(), list.end(), caseInsensitiveLessThan);
- // list: [ "AlPha", "beTA", "DELTA", "gamma" ]
-}
-//! [12]
-
-
-//! [13]
-QList<int> list;
-list << 33 << 12 << 68 << 6 << 12;
-qSort(list.begin(), list.end(), qGreater<int>());
-// list: [ 68, 33, 12, 12, 6 ]
-//! [13]
-
-
-//! [14]
-QStringList list;
-list << "AlPha" << "beTA" << "gamma" << "DELTA";
-
-QMap<QString, QString> map;
-foreach (const QString &str, list)
- map.insert(str.toLower(), str);
-
-list = map.values();
-//! [14]
-
-
-//! [15]
-QList<int> list;
-list << 33 << 12 << 68 << 6 << 12;
-qStableSort(list.begin(), list.end());
-// list: [ 6, 12, 12, 33, 68 ]
-//! [15]
-
-
-//! [16]
-bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
-{
- return s1.toLower() < s2.toLower();
-}
-
-int doSomething()
-{
- QStringList list;
- list << "AlPha" << "beTA" << "gamma" << "DELTA";
- qStableSort(list.begin(), list.end(), caseInsensitiveLessThan);
- // list: [ "AlPha", "beTA", "DELTA", "gamma" ]
-}
-//! [16]
-
-
-//! [17]
-QList<int> list;
-list << 33 << 12 << 68 << 6 << 12;
-qStableSort(list.begin(), list.end(), qGreater<int>());
-// list: [ 68, 33, 12, 12, 6 ]
-//! [17]
-
-
-//! [18]
-QList<int> list;
-list << 3 << 3 << 6 << 6 << 6 << 8;
-
-QList<int>::iterator i = qLowerBound(list.begin(), list.end(), 5);
-list.insert(i, 5);
-// list: [ 3, 3, 5, 6, 6, 6, 8 ]
-
-i = qLowerBound(list.begin(), list.end(), 12);
-list.insert(i, 12);
-// list: [ 3, 3, 5, 6, 6, 6, 8, 12 ]
-//! [18]
-
-
-//! [19]
-QList<int> list;
-list << 3 << 3 << 6 << 6 << 6 << 8;
-QList<int>::iterator begin6 =
- qLowerBound(list.begin(), list.end(), 6);
-QList<int>::iterator end6 =
- qUpperBound(begin6, list.end(), 6);
-
-QList<int>::iterator i = begin6;
-while (i != end6) {
- *i = 7;
- ++i;
-}
-// list: [ 3, 3, 7, 7, 7, 8 ]
-//! [19]
-
-
-//! [20]
-QList<int> list;
-list << 3 << 3 << 6 << 6 << 6 << 8;
-
-QList<int>::iterator i = qUpperBound(list.begin(), list.end(), 5);
-list.insert(i, 5);
-// list: [ 3, 3, 5, 6, 6, 6, 8 ]
-
-i = qUpperBound(list.begin(), list.end(), 12);
-list.insert(i, 12);
-// list: [ 3, 3, 5, 6, 6, 6, 8, 12 ]
-//! [20]
-
-
-//! [21]
-QList<int> list;
-list << 3 << 3 << 6 << 6 << 6 << 8;
-QList<int>::iterator begin6 =
- qLowerBound(list.begin(), list.end(), 6);
-QList<int>::iterator end6 =
- qUpperBound(list.begin(), list.end(), 6);
-
-QList<int>::iterator i = begin6;
-while (i != end6) {
- *i = 7;
- ++i;
-}
-// list: [ 3, 3, 7, 7, 7, 8 ]
-//! [21]
-
-
-//! [22]
-QList<int> list;
-list << 3 << 3 << 6 << 6 << 6 << 8;
-
-QList<int>::iterator i =
- qBinaryFind(list.begin(), list.end(), 6);
-// i == list.begin() + 2 (or 3 or 4)
-//! [22]
+//! [0]
-//! [23]
+//! [1]
QList<Employee *> list;
list.append(new Employee("Blackpool", "Stephen"));
list.append(new Employee("Twist", "Oliver"));
qDeleteAll(list.begin(), list.end());
list.clear();
-//! [23]
-
-
-//! [24]
-QList<int> list;
-list << 33 << 12 << 68 << 6 << 12;
-qSort(list.begin(), list.end(), qLess<int>());
-// list: [ 6, 12, 12, 33, 68 ]
-//! [24]
-
-
-//! [25]
-QList<int> list;
-list << 33 << 12 << 68 << 6 << 12;
-qSort(list.begin(), list.end(), qGreater<int>());
-// list: [ 68, 33, 12, 12, 6 ]
-//! [25]
+//! [1]
diff --git a/src/corelib/doc/snippets/code/doc_src_qiterator.cpp b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp
index 2ee618d394..44801dda09 100644
--- a/src/corelib/doc/snippets/code/doc_src_qiterator.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp
@@ -118,15 +118,6 @@ while (i.hasNext())
qDebug() << i.next();
//! [17]
-
-//! [18]
-QMutableSetIterator<float> i(set);
-i.toBack();
-while (i.hasPrevious())
- qDebug() << i.previous();
-//! [18]
-
-
//! [19]
QMutableListIterator<int> i(list);
while (i.hasNext()) {
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
index a540b88247..2d060fbb47 100644
--- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -553,7 +553,7 @@ private:
int *data;
};
-Q_DECLARE_TYPEINFO(Point2D, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(Point2D, Q_RELOCATABLE_TYPE);
//! [39]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp
index 36b47e6f6e..9ef08f1c6b 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp
@@ -126,8 +126,6 @@ private:
//! [6]
static inline QString tr(const char *sourceText,
const char *comment = nullptr);
-static inline QString trUtf8(const char *sourceText,
- const char *comment = nullptr);
//! [6]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp
index ca1ea21b02..1df3fa9edb 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp
@@ -71,7 +71,7 @@ v = QVariant(QStringList());
//! [1]
QVariant x, y(QString()), z(QString(""));
-x.convert(QVariant::Int);
+x.convert(QMetaType::Int);
// x.isNull() == true
// y.isNull() == true, z.isNull() == false
//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp b/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp
index a166439659..625f34e151 100644
--- a/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp
@@ -69,7 +69,7 @@ ba[4] = 0xca;
//! [2]
-for (int i = 0; i < ba.size(); ++i) {
+for (qsizetype i = 0; i < ba.size(); ++i) {
if (ba.at(i) >= 'a' && ba.at(i) <= 'f')
cout << "Found character in range [a-f]" << Qt::endl;
}
@@ -86,7 +86,7 @@ x.replace(5, 3, "&"); // x == "rock & roll"
//! [4]
QByteArray ba("We must be <b>bold</b>, very <b>bold</b>");
-int j = 0;
+qsizetype j = 0;
while ((j = ba.indexOf("<b>", j)) != -1) {
cout << "Found <b> tag at index position " << j << Qt::endl;
++j;
@@ -108,7 +108,7 @@ QByteArray("abc").isEmpty(); // returns false
//! [6]
QByteArray ba("Hello");
-int n = ba.size(); // n == 5
+qsizetype n = ba.size(); // n == 5
ba.data()[0]; // returns 'H'
ba.data()[4]; // returns 'o'
ba.data()[5]; // returns '\0'
@@ -276,22 +276,22 @@ if (url.endsWith(".html"))
//! [27]
QByteArray x("Pineapple");
-QByteArray y = x.left(4);
+QByteArray y = x.first(4);
// y == "Pine"
//! [27]
//! [28]
QByteArray x("Pineapple");
-QByteArray y = x.right(5);
+QByteArray y = x.last(5);
// y == "apple"
//! [28]
//! [29]
QByteArray x("Five pineapples");
-QByteArray y = x.mid(5, 4); // y == "pine"
-QByteArray z = x.mid(5); // z == "pineapples"
+QByteArray y = x.sliced(5, 4); // y == "pine"
+QByteArray z = x.sliced(5); // z == "pineapples"
//! [29]
@@ -422,7 +422,7 @@ text.data(); // returns "Qt is great!"
QByteArray::fromBase64("PHA+SGVsbG8/PC9wPg==", QByteArray::Base64Encoding); // returns "<p>Hello?</p>"
QByteArray::fromBase64("PHA-SGVsbG8_PC9wPg==", QByteArray::Base64UrlEncoding); // returns "<p>Hello?</p>"
-//! [44bis]
+//! [44]
//! [44ter]
void process(const QByteArray &);
diff --git a/src/corelib/doc/snippets/code/src_corelib_text_qcollator.cpp b/src/corelib/doc/snippets/code/src_corelib_text_qcollator.cpp
new file mode 100644
index 0000000000..9a2e0dac58
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_text_qcollator.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QStringList sortedStrings(QStringList seq)
+{
+ QCollator order;
+ std::sort(seq.begin(), seq.end(), order);
+ return seq;
+}
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_text_qregularexpression.cpp b/src/corelib/doc/snippets/code/src_corelib_text_qregularexpression.cpp
index b451ed5253..c418a1f279 100644
--- a/src/corelib/doc/snippets/code/src_corelib_text_qregularexpression.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_text_qregularexpression.cpp
@@ -355,4 +355,13 @@ QString wildcard = QRegularExpression::wildcardToRegularExpression("*.jpeg");
("", "day", "month", "year", "", "name")
//! [33]
+{
+//! [34]
+QRegularExpression re(R"(\w+)");
+QString subject("the quick fox");
+for (const QRegularExpressionMatch &match : re.globalMatch(subject)) {
+ // ...
+}
+//! [34]
+}
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp b/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp
index 4e79d1e27a..fade47cfc6 100644
--- a/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp
@@ -48,12 +48,6 @@
**
****************************************************************************/
-//! [0]
-DEFINES += QT_NO_CAST_FROM_ASCII \
- QT_NO_CAST_TO_ASCII
-//! [0]
-
-
//! [1]
QString url = QLatin1String("http://www.unicode.org/");
//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qexception.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qexception.cpp
index 723c1630f6..08bbee7dd3 100644
--- a/src/corelib/doc/snippets/code/src_corelib_thread_qexception.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qexception.cpp
@@ -83,3 +83,19 @@ void MyException::raise() const { throw *this; }
MyException *MyException::clone() const { return new MyException(*this); }
//! [3]
+
+//! [4]
+
+try {
+ auto f = QtConcurrent::run([] { throw MyException {}; });
+ // ...
+} catch (const QUnhandledException &e) {
+ try {
+ if (e.exception())
+ std::rethrow_exception(e.exception());
+ } catch (const MyException &ex) {
+ // Process 'ex'
+ }
+}
+
+//! [4]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
index 344fbb241d..ee9f88fc65 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
@@ -335,10 +335,6 @@ inline size_t qHash(const std::unordered_set<int> &key, size_t seed = 0)
}
//! [qhashrangecommutative]
-//! [29]
-qHash(qMakePair(key.first, key.second), seed);
-//! [29]
-
//! [30]
{0, 1, 2}
//! [30]
@@ -354,3 +350,13 @@ size_t qHash(const K &key);
size_t qHash(K key, size_t seed);
size_t qHash(const K &key, size_t seed);
//! [32]
+
+//! [33]
+namespace std {
+template <> struct hash<K>
+{
+ // seed is optional
+ size_t operator()(const K &key, size_t seed = 0) const;
+};
+}
+//! [33]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp
index e959915c5e..05027bc500 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp
@@ -71,7 +71,7 @@ if (list[0] == "Liz")
//! [4]
-for (int i = 0; i < list.size(); ++i) {
+for (qsizetype i = 0; i < list.size(); ++i) {
if (list.at(i) == "Alfonso")
cout << "Found Alfonso at position " << i << Qt::endl;
}
@@ -79,7 +79,7 @@ for (int i = 0; i < list.size(); ++i) {
//! [5]
-int i = list.indexOf("Harumi");
+qsizetype i = list.indexOf("Harumi");
if (i != -1)
cout << "First occurrence of Harumi is at position " << i << Qt::endl;
//! [5]
@@ -88,7 +88,7 @@ if (i != -1)
//! [6]
QList<int> list(10);
int *data = list.data();
-for (int i = 0; i < 10; ++i)
+for (qsizetype i = 0; i < 10; ++i)
data[i] = 2 * i;
//! [6]
@@ -191,20 +191,3 @@ list.lastIndexOf("B", 3); // returns 3
list.lastIndexOf("B", 2); // returns 1
list.lastIndexOf("X"); // returns -1
//! [13]
-
-//! [16]
-std::vector<double> stdvector;
-stdvector.push_back(1.2);
-stdvector.push_back(0.5);
-stdvector.push_back(3.14);
-
-QList<double> list = QList<double>::fromStdVector(stdvector);
-//! [16]
-
-
-//! [17]
-QList<double> list;
-list << 1.2 << 0.5 << 3.14;
-
-std::vector<double> stdvector = list.toStdVector();
-//! [17]
diff --git a/src/corelib/doc/snippets/eventfilters/filterobject.h b/src/corelib/doc/snippets/eventfilters/filterobject.h
index 354aa4ff5c..d249743a15 100644
--- a/src/corelib/doc/snippets/eventfilters/filterobject.h
+++ b/src/corelib/doc/snippets/eventfilters/filterobject.h
@@ -58,7 +58,7 @@ class FilterObject : public QObject
Q_OBJECT
public:
- FilterObject(QObject *parent = 0);
+ FilterObject(QObject *parent = nullptr);
bool eventFilter(QObject *object, QEvent *event) override;
void setFilteredObject(QObject *object);
diff --git a/src/corelib/doc/snippets/overview/using-qt-core.cmake b/src/corelib/doc/snippets/overview/using-qt-core.cmake
index a5f43c1472..a2c2034b8b 100644
--- a/src/corelib/doc/snippets/overview/using-qt-core.cmake
+++ b/src/corelib/doc/snippets/overview/using-qt-core.cmake
@@ -1,2 +1,2 @@
-find_package(Qt5 COMPONENTS Core REQUIRED)
-target_link_libraries(mytarget Qt5::Core)
+find_package(Qt6 COMPONENTS Core REQUIRED)
+target_link_libraries(mytarget PRIVATE Qt6::Core)
diff --git a/src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp b/src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp
index 2a7b310716..a79f07c3ae 100644
--- a/src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp
+++ b/src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp
@@ -55,7 +55,7 @@
class MyItemModel : public QStandardItemModel
{
public:
- MyItemModel(QWidget *parent = 0);
+ MyItemModel(QWidget *parent = nullptr);
};
MyItemModel::MyItemModel(QWidget *parent)
@@ -65,7 +65,7 @@ MyItemModel::MyItemModel(QWidget *parent)
class Widget : public QWidget
{
public:
- Widget(QWidget *parent = 0);
+ Widget(QWidget *parent = nullptr);
};
Widget::Widget(QWidget *parent)
diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp
index cb557ac023..8abe69ed42 100644
--- a/src/corelib/doc/snippets/qstring/main.cpp
+++ b/src/corelib/doc/snippets/qstring/main.cpp
@@ -55,7 +55,7 @@
class Widget : public QWidget
{
public:
- Widget(QWidget *parent = 0);
+ Widget(QWidget *parent = nullptr);
void constCharPointer();
void constCharArray();
@@ -85,9 +85,9 @@ public:
void isNullFunction();
void isEmptyFunction();
void lastIndexOfFunction();
- void leftFunction();
+ void firstFunction();
void leftJustifiedFunction();
- void midFunction();
+ void slicedFunction();
void numberFunction();
void prependFunction();
@@ -95,7 +95,7 @@ public:
void replaceFunction();
void reserveFunction();
void resizeFunction();
- void rightFunction();
+ void lastFunction();
void rightJustifiedFunction();
void sectionFunction();
void setNumFunction();
@@ -164,7 +164,7 @@ void Widget::atFunction()
//! [3]
QString str;
- for (int i = 0; i < str.size(); ++i) {
+ for (qsizetype i = 0; i < str.size(); ++i) {
if (str.at(i) >= QChar('a') && str.at(i) <= QChar('f'))
qDebug() << "Found character in range [a-f]";
}
@@ -197,7 +197,7 @@ void Widget::index()
{
//! [6]
QString str = "We must be <b>bold</b>, very <b>bold</b>";
- int j = 0;
+ qsizetype j = 0;
while ((j = str.indexOf("<b>", j)) != -1) {
qDebug() << "Found <b> tag at index position" << j;
@@ -478,11 +478,11 @@ void Widget::lastIndexOfFunction()
//! [94]
}
-void Widget::leftFunction()
+void Widget::firstFunction()
{
//! [31]
QString x = "Pineapple";
- QString y = x.left(4); // y == "Pine"
+ QString y = x.first(4); // y == "Pine"
//! [31]
}
@@ -499,12 +499,12 @@ void Widget::leftJustifiedFunction()
//! [33]
}
-void Widget::midFunction()
+void Widget::slicedFunction()
{
//! [34]
QString x = "Nine pineapples";
- QString y = x.mid(5, 4); // y == "pine"
- QString z = x.mid(5); // z == "pineapples"
+ QString y = x.sliced(5, 4); // y == "pine"
+ QString z = x.sliced(5); // z == "pineapples"
//! [34]
}
@@ -623,11 +623,11 @@ void Widget::resizeFunction()
//! [47]
}
-void Widget::rightFunction()
+void Widget::lastFunction()
{
//! [48]
QString x = "Pineapple";
- QString y = x.right(5); // y == "apple"
+ QString y = x.last(5); // y == "apple"
//! [48]
}
diff --git a/src/corelib/doc/snippets/qstring/stringbuilder.cpp b/src/corelib/doc/snippets/qstring/stringbuilder.cpp
index 74623aeb94..b81b40e10e 100644
--- a/src/corelib/doc/snippets/qstring/stringbuilder.cpp
+++ b/src/corelib/doc/snippets/qstring/stringbuilder.cpp
@@ -52,7 +52,7 @@
QString foo;
QString type = "long";
- foo->setText(QLatin1String("vector<") + type + QLatin1String(">::iterator"));
+ foo = QLatin1String("vector<") + type + QLatin1String(">::iterator");
if (foo.startsWith("(" + type + ") 0x"))
...
diff --git a/src/corelib/doc/snippets/qstringlist/main.cpp b/src/corelib/doc/snippets/qstringlist/main.cpp
index 5284a5fb78..fceadc4e99 100644
--- a/src/corelib/doc/snippets/qstringlist/main.cpp
+++ b/src/corelib/doc/snippets/qstringlist/main.cpp
@@ -55,7 +55,7 @@ using namespace std;
class Widget : public QWidget
{
public:
- Widget(QWidget *parent = 0);
+ Widget(QWidget *parent = nullptr);
};
Widget::Widget(QWidget *parent)
diff --git a/src/corelib/doc/snippets/qstringlistmodel/main.cpp b/src/corelib/doc/snippets/qstringlistmodel/main.cpp
index 4c9519d2b2..fa7f414526 100644
--- a/src/corelib/doc/snippets/qstringlistmodel/main.cpp
+++ b/src/corelib/doc/snippets/qstringlistmodel/main.cpp
@@ -53,7 +53,7 @@
class Widget : public QWidget
{
public:
- Widget(QWidget *parent = 0);
+ Widget(QWidget *parent = nullptr);
};
Widget::Widget(QWidget *parent)
diff --git a/src/corelib/doc/src/animation.qdoc b/src/corelib/doc/src/animation.qdoc
index 16569ded0b..d67ac2e505 100644
--- a/src/corelib/doc/src/animation.qdoc
+++ b/src/corelib/doc/src/animation.qdoc
@@ -93,15 +93,6 @@
animations. Note also that the groups are subclasses of
QAbstractAnimation, so groups can themselves contain other groups.
- The animation framework can be used on its own, but is also
- designed to be part of the state machine framework (See the
- \l{The State Machine Framework}{state machine framework} for an
- introduction to the Qt state machine). The state machine provides
- a special state that can play an animation. A QState can also set
- properties when the state is entered or exited, and this special
- animation state will interpolate between these values when given a
- QPropertyAnimation. We will look more closely at this later.
-
Behind the scenes, the animations are controlled by a global
timer, which sends \l{QAbstractAnimation::updateCurrentTime()}{updates} to
all animations that are playing.
diff --git a/src/corelib/doc/src/cmake-macros.qdoc b/src/corelib/doc/src/cmake-macros.qdoc
index 8788554616..a86913fed9 100644
--- a/src/corelib/doc/src/cmake-macros.qdoc
+++ b/src/corelib/doc/src/cmake-macros.qdoc
@@ -26,42 +26,11 @@
****************************************************************************/
/*!
-\page qtcore-cmake-qt5-wrap-cpp.html
-\ingroup cmake-macros-qtcore
-
-\title qt5_wrap_cpp
-
-\brief Creates \c{.moc} files from sources.
-
-\section1 Synopsis
-
-\badcode
-qt5_wrap_cpp(<VAR> src_file1 [src_file2 ...]
- [TARGET target]
- [OPTIONS ...]
- [DEPENDS ...])
-\endcode
-
-\section1 Description
-
-\include includes/qt_wrap_cpp.qdocinc description
-
-\note For compatibility with Qt 6, the command is also available under the name \l qt_wrap_cpp.
-
-\section1 Arguments
-
-\include includes/qt_wrap_cpp.qdocinc arguments
-
-\section1 Examples
-
-\snippet cmake-macros/examples.cmake qt5_wrap_cpp
-*/
-
-/*!
-\page qtcore-cmake-qt-wrap-cpp.html
+\page qt_wrap_cpp.html
\ingroup cmake-macros-qtcore
\title qt_wrap_cpp
+\target qt6_wrap_cpp
\brief Creates \c{.moc} files from sources.
@@ -72,60 +41,47 @@ qt_wrap_cpp(<VAR> src_file1 [src_file2 ...]
[TARGET target]
[OPTIONS ...]
[DEPENDS ...])
+
+qt6_wrap_cpp(<VAR> src_file1 [src_file2 ...]
+ [TARGET target]
+ [OPTIONS ...]
+ [DEPENDS ...])
\endcode
\section1 Description
-\include includes/qt_wrap_cpp.qdocinc description
+Creates rules for calling the \l{moc}{Meta-Object Compiler (moc)} on the given
+source files. For each input file, an output file is generated in the build
+directory. The paths of the generated files are added to \c{<VAR>}.
-This command was introduced in Qt 5.15. You can use \l qt5_wrap_cpp in older versions of Qt.
+\note This is a low-level macro. See the \l{CMake AUTOMOC Documentation} for a
+more convenient way to let source files be processed with \c{moc}.
\section1 Arguments
-\include includes/qt_wrap_cpp.qdocinc arguments
+You can set an explicit \c{TARGET}. This will make sure that the target
+properties \c{INCLUDE_DIRECTORIES} and \c{COMPILE_DEFINITIONS} are also used
+when scanning the source files with \c{moc}.
-\section1 Examples
+You can set additional \c{OPTIONS} that should be added to the \c{moc} calls.
+You can find possible options in the \l{moc}{moc documentation}.
-\snippet cmake-macros/examples.cmake qt_wrap_cpp
-*/
-
-/*!
-\page qtcore-cmake-qt5-add-resources.html
-\ingroup cmake-macros-qtcore
-
-\title qt5_add_resources
-
-\brief Compiles binary resources into source code.
-
-\section1 Synopsis
-
-\badcode
-qt5_add_resources(<VAR> file1.qrc [file2.qrc ...]
- [OPTIONS ...])
-\endcode
-
-\section1 Description
-
-\include includes/qt_add_resources.qdocinc arguments
-
-For embedding bigger resources, see \l qt5_add_big_resources.
-
-\note For compatibility with Qt 6, the command is also available under the name \l qt_add_resources.
-
-\section1 Arguments
-
-\include includes/qt_add_resources.qdocinc arguments
+\c{DEPENDS} allows you to add additional dependencies for recreation of the
+generated files. This is useful when the sources have implicit dependencies,
+like code for a Qt plugin that includes a \c{.json} file using the
+Q_PLUGIN_METADATA() macro.
\section1 Examples
-\snippet cmake-macros/examples.cmake qt5_add_resources
+\snippet cmake-macros/examples.cmake qt_wrap_cpp
*/
/*!
-\page qtcore-cmake-qt-add-resources.html
+\page qt_add_resources.html
\ingroup cmake-macros-qtcore
\title qt_add_resources
+\target qt6_add_resources
\brief Compiles binary resources into source code.
@@ -134,19 +90,23 @@ For embedding bigger resources, see \l qt5_add_big_resources.
\badcode
qt_add_resources(<VAR> file1.qrc [file2.qrc ...]
[OPTIONS ...])
+
+qt6_add_resources(<VAR> file1.qrc [file2.qrc ...]
+ [OPTIONS ...])
\endcode
\section1 Description
-\include includes/qt_add_resources.qdocinc arguments
+Creates source code from Qt resource files using the
+\l{Resource Compiler (rcc)}. Paths to the generated source files are added to
+\c{<VAR>}.
For embedding bigger resources, see \l qt_add_big_resources.
-This command was introduced in Qt 5.15. You can use \l qt5_add_resources in older versions of Qt.
-
\section1 Arguments
-\include includes/qt_add_resources.qdocinc arguments
+You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls.
+You can find possible options in the \l{rcc}{rcc documentation}.
\section1 Examples
@@ -154,40 +114,11 @@ This command was introduced in Qt 5.15. You can use \l qt5_add_resources in olde
*/
/*!
-\page qtcore-cmake-qt5-add-big-resources.html
-\ingroup cmake-macros-qtcore
-
-\title qt5_add_big_resources
-
-\brief Compiles big binary resources into object code.
-
-\section1 Synopsis
-
-\badcode
-qt5_add_big_resources(<VAR> file1.qrc [file2.qrc ...]
- [OPTIONS ...])
-\endcode
-
-\section1 Description
-
-\include includes/qt_add_big_resources.qdocinc description
-
-\note For compatibility with Qt 6, the command is also available under the name \l qt_add_big_resources.
-
-\section1 Arguments
-
-\include includes/qt_add_big_resources.qdocinc arguments
-
-\section1 Examples
-
-\snippet cmake-macros/examples.cmake qt5_add_big_resources
-*/
-
-/*!
-\page qtcore-cmake-qt-add-big-resources.html
+\page qt_add_bigresources.html
\ingroup cmake-macros-qtcore
\title qt_add_big_resources
+\target qt6_add_big_resources
\brief Compiles big binary resources into object code.
@@ -196,59 +127,40 @@ qt5_add_big_resources(<VAR> file1.qrc [file2.qrc ...]
\badcode
qt_add_big_resources(<VAR> file1.qrc [file2.qrc ...]
[OPTIONS ...])
-\endcode
-
-\section1 Description
-
-\include includes/qt_add_big_resources.qdocinc description
-
-This command was introduced in Qt 5.15. You can use \l qt5_add_big_resources in older versions of Qt.
-
-\section1 Arguments
-\include includes/qt_add_big_resources.qdocinc arguments
-
-\section1 Examples
-
-\snippet cmake-macros/examples.cmake qt_add_big_resources
-*/
-
-/*!
-\page qtcore-cmake-qt5_add_binary_resources.html
-\ingroup cmake-macros-qtcore
-
-\title qt5_add_binary_resources
-
-\brief Creates an \c{RCC} file from a list of Qt resource files.
-
-\section1 Synopsis
-
-\badcode
-qt5_add_binary_resources(target file1.qrc [file2.qrc ...]
- [DESTINATION ...]
- [OPTIONS ...])
+qt6_add_big_resources(<VAR> file1.qrc [file2.qrc ...]
+ [OPTIONS ...])
\endcode
\section1 Description
-\include includes/qt_add_binary_resources.qdocinc description
+Creates compiled object files from Qt resource files using the
+\l{Resource Compiler (rcc)}. Paths to the generated files are added to
+\c{<VAR>}.
+
+This is similar to \l qt_add_resources, but directly
+generates object files (\c .o, \c .obj) files instead of C++ source code.
+This allows to embed bigger resources, where compiling to C++ sources and then
+to binaries would be too time consuming or memory intensive.
-\note For compatibility with Qt 6, the command is also available under the name \l qt_add_binary_resources.
+\note This macro is only available if using \c{CMake} 3.9 or later.
\section1 Arguments
-\include includes/qt_add_binary_resources.qdocinc arguments
+You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls.
+You can find possible options in the \l{rcc}{rcc documentation}.
\section1 Examples
-\snippet cmake-macros/examples.cmake qt5_add_binary_resources
+\snippet cmake-macros/examples.cmake qt_add_big_resources
*/
/*!
-\page qtcore-cmake-qt_add_binary_resources.html
+\page qt_add_binary_resources.html
\ingroup cmake-macros-qtcore
\title qt_add_binary_resources
+\target qt6_add_binary_resources
\brief Creates an \c{RCC} file from a list of Qt resource files.
@@ -258,58 +170,36 @@ qt5_add_binary_resources(target file1.qrc [file2.qrc ...]
qt_add_binary_resources(target file1.qrc [file2.qrc ...]
[DESTINATION ...]
[OPTIONS ...])
-\endcode
-
-\section1 Description
-
-\include includes/qt_add_binary_resources.qdocinc description
-This command was introduced in Qt 5.15. You can use \l qt5_add_binary_resources in older versions of Qt.
-
-\section1 Arguments
-
-\include includes/qt_add_binary_resources.qdocinc arguments
-
-\section1 Examples
-
-\snippet cmake-macros/examples.cmake qt_add_binary_resources
-*/
-
-/*!
-\page qtcore-cmake-qt5-generate-moc.html
-\ingroup cmake-macros-qtcore
-
-\title qt5_generate_moc
-
-\brief Calls moc on an input file.
-
-\section1 Synopsis
-
-\badcode
-qt5_generate_moc(src_file dest_file
- [TARGET target])
+qt6_add_binary_resources(target file1.qrc [file2.qrc ...]
+ [DESTINATION ...]
+ [OPTIONS ...])
\endcode
\section1 Description
-\include includes/qt_generate_moc.qdocinc description
-
-\note For compatibility with Qt 6, the command is also available under the name \l qt_generate_moc.
+Adds a custom \c target that compiles Qt resource files into a binary \c{.rcc}
+file.
\section1 Arguments
-\include includes/qt_generate_moc.qdocinc arguments
+\c{DESTINATION} sets the path of the generated \c{.rcc} file. The default is
+\c{${CMAKE_CURRENT_BINARY_DIR}/${target}.rcc}.
+
+You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls.
+You can find possible options in the \l{rcc}{rcc documentation}.
\section1 Examples
-\snippet cmake-macros/examples.cmake qt5_generate_moc
+\snippet cmake-macros/examples.cmake qt_add_binary_resources
*/
/*!
-\page qtcore-cmake-qt-generate-moc.html
+\page qt_generate_moc.html
\ingroup cmake-macros-qtcore
\title qt_generate_moc
+\target qt6_generate_moc
\brief Calls moc on an input file.
@@ -318,17 +208,26 @@ qt5_generate_moc(src_file dest_file
\badcode
qt_generate_moc(src_file dest_file
[TARGET target])
+
+qt6_generate_moc(src_file dest_file
+ [TARGET target])
\endcode
\section1 Description
-\include includes/qt_generate_moc.qdocinc description
+Creates a rule to call the \l{moc}{Meta-Object Compiler (moc)} on \c src_file
+and store the output in \c dest_file.
-This command was introduced in Qt 5.15. You can use \l qt5_generate_moc in older versions of Qt.
+\note This is a low-level macro. See the \l{CMake AUTOMOC Documentation} for a
+more convenient way to let source files be processed with \c{moc}.
+\l qt_wrap_cpp is also similar, but automatically generates a temporary file
+path for you.
\section1 Arguments
-\include includes/qt_generate_moc.qdocinc arguments
+You can set an explicit \c{TARGET}. This will make sure that the target
+properties \c{INCLUDE_DIRECTORIES} and \c{COMPILE_DEFINITIONS} are also used
+when scanning the source files with \c{moc}.
\section1 Examples
@@ -336,50 +235,11 @@ This command was introduced in Qt 5.15. You can use \l qt5_generate_moc in older
*/
/*!
-\page qtcore-cmake-qt5-import-plugins.html
-\ingroup cmake-macros-qtcore
-
-\title qt5_import_plugins
-
-\brief Specifies a custom set of plugins to import for a static Qt build
-
-\section1 Synopsis
-
-\badcode
-qt5_import_plugins(target
- [INCLUDE plugin ...]
- [EXCLUDE plugin ...]
- [INCLUDE_BY_TYPE plugin_type plugin ...]
- [EXCLUDE_BY_TYPE plugin_type])
-\endcode
-
-\section1 Description
-
-\include includes/qt_import_plugins.qdocinc description
-
-\note For compatibility with Qt 6, the command is also available under the name \l qt_import_plugins.
-
-\section1 Examples
-
-\snippet cmake-macros/examples.cmake qt5_import_plugins
-
-In the snippet above, the following occurs with the executable \c myapp:
-
-\list
-\li The \c Qt5::QCocoaIntegrationPlugin is imported into myapp.
-\li The \c Qt5::QMinimalIntegrationPlugin plugin is
- excluded from being automatically imported into myapp.
-\li The default list of plugins for \c imageformats is
- overridden to only include Qt5::QGifPlugin and Qt5::QJpegPlugin.
-\li All \c sqldrivers plugins are excluded from automatic importing.
-\endlist
-*/
-
-/*!
-\page qtcore-cmake-qt-import-plugins.html
+\page qt_import_plugins.html
\ingroup cmake-macros-qtcore
\title qt_import_plugins
+\target qt6_import_plugins
\brief Specifies a custom set of plugins to import for a static Qt build
@@ -391,13 +251,43 @@ qt_import_plugins(target
[EXCLUDE plugin ...]
[INCLUDE_BY_TYPE plugin_type plugin ...]
[EXCLUDE_BY_TYPE plugin_type])
+
+qt6_import_plugins(target
+ [INCLUDE plugin ...]
+ [EXCLUDE plugin ...]
+ [INCLUDE_BY_TYPE plugin_type plugin ...]
+ [EXCLUDE_BY_TYPE plugin_type])
\endcode
\section1 Description
-\include includes/qt_import_plugins.qdocinc description
+Specifies a custom set of plugins to import. The optional arguments:
+\c INCLUDE, \c EXCLUDE, \c INCLUDE_BY_TYPE, and \c EXCLUDE_BY_TYPE,
+can be used more than once.
+
+\list
+\li \c INCLUDE -- can be used to specify a list of plugins to import.
+\li \c EXCLUDE -- can be used to specify a list of plugins to exclude.
+\li \c INCLUDE_BY_TYPE -- can be used to override the list of plugins to
+ import for a certain plugin type.
+\li \c EXCLUDE_BY_TYPE -- can be used to specify a plugin type to exclude;
+ then no plugins of that type are imported.
+\endlist
+
+Qt provides plugin types such as \c imageformats, \c platforms,
+and \c sqldrivers.
+
+If the command isn't used the target automatically links against
+a sane set of default plugins, for each Qt module that the target is linked
+against. For more information, see
+\l{CMake target_link_libraries Documentation}{target_link_libraries}.
+
+Each plugin comes with a C++ stub file that automatically
+initializes the plugin. Consequently, any target that links against a plugin
+has this C++ file added to its \c SOURCES.
-This command was introduced in Qt 5.15. You can use \l qt5_import_plugins in older versions of Qt.
+\note This command imports plugins from static Qt builds only.
+On shared builds, it does nothing.
\section1 Examples
@@ -406,11 +296,11 @@ This command was introduced in Qt 5.15. You can use \l qt5_import_plugins in old
In the snippet above, the following occurs with the executable \c myapp:
\list
-\li The \c Qt::QCocoaIntegrationPlugin is imported into myapp.
-\li The \c Qt::QMinimalIntegrationPlugin plugin is
+\li The \c Qt6::QCocoaIntegrationPlugin is imported into myapp.
+\li The \c Qt6::QMinimalIntegrationPlugin plugin is
excluded from being automatically imported into myapp.
\li The default list of plugins for \c imageformats is
- overridden to only include Qt::QGifPlugin and Qt::QJpegPlugin.
+ overridden to only include Qt6::QGifPlugin and Qt6::QJpegPlugin.
\li All \c sqldrivers plugins are excluded from automatic importing.
\endlist
*/
diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc
index 5b9b700669..c5b70c2675 100644
--- a/src/corelib/doc/src/containers.qdoc
+++ b/src/corelib/doc/src/containers.qdoc
@@ -56,15 +56,10 @@
in situations where they are used as read-only containers
by all threads used to access them.
- For traversing the items stored in a container, you can use one
- of two types of iterators: \l{Java-style iterators} and
- \l{STL-style iterators}. The Java-style iterators are easier to
- use and provide high-level functionality, whereas the STL-style
- iterators are slightly more efficient and can be used together
- with Qt's and STL's \l{generic algorithms}.
-
- Qt also offers a \l{foreach} keyword that make it very
- easy to iterate over all the items stored in a container.
+ The containers provide iterators for traversal. \l{STL-style iterators}
+ are the most efficient ones and can be used together with Qt's and
+ STL's \l{generic algorithms}.
+ \l{Java-style Iterators} are provided for backwards compatibility.
\note Since Qt 5.14, range constructors are available for most of the
container classes. QMultiMap is a notable exception. Their use is
@@ -223,178 +218,12 @@
\section1 The Iterator Classes
Iterators provide a uniform means to access items in a container.
- Qt's container classes provide two types of iterators: Java-style
- iterators and STL-style iterators. Iterators of both types are
+ Qt's container classes provide two types of iterators: STL-style
+ iterators and Java-style iterators. Iterators of both types are
invalidated when the data in the container is modified or detached
from \l{Implicit Sharing}{implicitly shared copies} due to a call
to a non-const member function.
- \section2 Java-Style Iterators
-
- The Java-style iterators are new in Qt 4 and are the standard
- ones used in Qt applications. They are more convenient to use than
- the STL-style iterators, at the price of being slightly less
- efficient. Their API is modelled on Java's iterator classes.
-
- For each container class, there are two Java-style iterator data
- types: one that provides read-only access and one that provides
- read-write access.
-
- \table
- \header \li Containers \li Read-only iterator
- \li Read-write iterator
- \li QMutableListIterator<T>
- \row \li QList<T>, QQueue<T>, QStack<T>, \li QListIterator<T>
- \li QMutableListIterator<T>
- \row \li QSet<T> \li QSetIterator<T>
- \li QMutableSetIterator<T>
- \row \li QMap<Key, T>, QMultiMap<Key, T> \li QMapIterator<Key, T>
- \li QMutableMapIterator<Key, T>
- \row \li QHash<Key, T>, QMultiHash<Key, T> \li QHashIterator<Key, T>
- \li QMutableHashIterator<Key, T>
- \endtable
-
- In this discussion, we will concentrate on QList and QMap. The
- iterator types for QSet have exactly
- the same interface as QList's iterators; similarly, the iterator
- types for QHash have the same interface as QMap's iterators.
-
- Unlike STL-style iterators (covered \l{STL-style
- iterators}{below}), Java-style iterators point \e between items
- rather than directly \e at items. For this reason, they are
- either pointing to the very beginning of the container (before
- the first item), at the very end of the container (after the last
- item), or between two items. The diagram below shows the valid
- iterator positions as red arrows for a list containing four
- items:
-
- \image javaiterators1.png
-
- Here's a typical loop for iterating through all the elements of a
- QList<QString> in order and printing them to the console:
-
- \snippet code/doc_src_containers.cpp 1
-
- It works as follows: The QList to iterate over is passed to the
- QListIterator constructor. At that point, the iterator is located
- just in front of the first item in the list (before item "A").
- Then we call \l{QListIterator::hasNext()}{hasNext()} to
- check whether there is an item after the iterator. If there is, we
- call \l{QListIterator::next()}{next()} to jump over that
- item. The next() function returns the item that it jumps over. For
- a QList<QString>, that item is of type QString.
-
- Here's how to iterate backward in a QList:
-
- \snippet code/doc_src_containers.cpp 2
-
- The code is symmetric with iterating forward, except that we
- start by calling \l{QListIterator::toBack()}{toBack()}
- to move the iterator after the last item in the list.
-
- The diagram below illustrates the effect of calling
- \l{QListIterator::next()}{next()} and
- \l{QListIterator::previous()}{previous()} on an iterator:
-
- \image javaiterators2.png
-
- The following table summarizes the QListIterator API:
-
- \table
- \header \li Function \li Behavior
- \row \li \l{QListIterator::toFront()}{toFront()}
- \li Moves the iterator to the front of the list (before the first item)
- \row \li \l{QListIterator::toBack()}{toBack()}
- \li Moves the iterator to the back of the list (after the last item)
- \row \li \l{QListIterator::hasNext()}{hasNext()}
- \li Returns \c true if the iterator isn't at the back of the list
- \row \li \l{QListIterator::next()}{next()}
- \li Returns the next item and advances the iterator by one position
- \row \li \l{QListIterator::peekNext()}{peekNext()}
- \li Returns the next item without moving the iterator
- \row \li \l{QListIterator::hasPrevious()}{hasPrevious()}
- \li Returns \c true if the iterator isn't at the front of the list
- \row \li \l{QListIterator::previous()}{previous()}
- \li Returns the previous item and moves the iterator back by one position
- \row \li \l{QListIterator::peekPrevious()}{peekPrevious()}
- \li Returns the previous item without moving the iterator
- \endtable
-
- QListIterator provides no functions to insert or remove items
- from the list as we iterate. To accomplish this, you must use
- QMutableListIterator. Here's an example where we remove all
- odd numbers from a QList<int> using QMutableListIterator:
-
- \snippet code/doc_src_containers.cpp 3
-
- The next() call in the loop is made every time. It jumps over the
- next item in the list. The
- \l{QMutableListIterator::remove()}{remove()} function removes the
- last item that we jumped over from the list. The call to
- \l{QMutableListIterator::remove()}{remove()} does not invalidate
- the iterator, so it is safe to continue using it. This works just
- as well when iterating backward:
-
- \snippet code/doc_src_containers.cpp 4
-
- If we just want to modify the value of an existing item, we can
- use \l{QMutableListIterator::setValue()}{setValue()}. In the code
- below, we replace any value larger than 128 with 128:
-
- \snippet code/doc_src_containers.cpp 5
-
- Just like \l{QMutableListIterator::remove()}{remove()},
- \l{QMutableListIterator::setValue()}{setValue()} operates on the
- last item that we jumped over. If we iterate forward, this is the
- item just before the iterator; if we iterate backward, this is
- the item just after the iterator.
-
- The \l{QMutableListIterator::next()}{next()} function returns a
- non-const reference to the item in the list. For simple
- operations, we don't even need
- \l{QMutableListIterator::setValue()}{setValue()}:
-
- \snippet code/doc_src_containers.cpp 6
-
- As mentioned above QSet's iterator
- classes have exactly the same API as QList's. We will now turn to
- QMapIterator, which is somewhat different because it iterates on
- (key, value) pairs.
-
- Like QListIterator, QMapIterator provides
- \l{QMapIterator::toFront()}{toFront()},
- \l{QMapIterator::toBack()}{toBack()},
- \l{QMapIterator::hasNext()}{hasNext()},
- \l{QMapIterator::next()}{next()},
- \l{QMapIterator::peekNext()}{peekNext()},
- \l{QMapIterator::hasPrevious()}{hasPrevious()},
- \l{QMapIterator::previous()}{previous()}, and
- \l{QMapIterator::peekPrevious()}{peekPrevious()}. The key and
- value components are extracted by calling \l{QMapIterator::key()}{key()} and \l{QMapIterator::value()}{value()} on
- the object returned by next(), peekNext(), previous(), or
- peekPrevious().
-
- The following example removes all (capital, country) pairs where
- the capital's name ends with "City":
-
- \snippet code/doc_src_containers.cpp 7
-
- QMapIterator also provides a \l{QMapIterator::key()}{key()} and a \l{QMapIterator::value()}{value()} function that
- operate directly on the iterator and that return the key and
- value of the last item that the iterator jumped above. For
- example, the following code copies the contents of a QMap into a
- QHash:
-
- \snippet code/doc_src_containers.cpp 8
-
- If we want to iterate through all the items with the same
- value, we can use \l{QMapIterator::findNext()}{findNext()}
- or \l{QMapIterator::findPrevious()}{findPrevious()}.
- Here's an example where we remove all the items with a particular
- value:
-
- \snippet code/doc_src_containers.cpp 9
-
\section2 STL-Style Iterators
STL-style iterators have been available since the release of Qt
@@ -438,10 +267,9 @@
\snippet code/doc_src_containers.cpp 10
- Unlike \l{Java-style iterators}, STL-style iterators point
- directly at items. The \l{QList::begin()}{begin()} function of a container returns an
- iterator that points to the first item in the container. The
- \l{QList::end()}{end()} function of a container returns an iterator to the
+ STL-style iterators point directly at items. The \l{QList::begin()}{begin()}
+ function of a container returns an iterator that points to the first item in the
+ container. The \l{QList::end()}{end()} function of a container returns an iterator to the
imaginary item one position past the last item in the container.
\l {QList::end()}{end()} marks an invalid position; it must never be dereferenced.
It is typically used in a loop's break condition. If the list is
@@ -524,68 +352,20 @@
The above example only shows a problem with QList, but
the problem exists for all the implicitly shared Qt containers.
- \target foreach
- \section1 The foreach Keyword
-
- If you just want to iterate over all the items in a container
- in order, you can use Qt's \c foreach keyword. The keyword is a
- Qt-specific addition to the C++ language, and is implemented
- using the preprocessor.
-
- Its syntax is: \c foreach (\e variable, \e container) \e
- statement. For example, here's how to use \c foreach to iterate
- over a QList<QString>:
-
- \snippet code/doc_src_containers.cpp 15
-
- The \c foreach code is significantly shorter than the equivalent
- code that uses iterators:
-
- \snippet code/doc_src_containers.cpp 16
-
- Unless the data type contains a comma (e.g., \c{QPair<int,
- int>}), the variable used for iteration can be defined within the
- \c foreach statement:
-
- \snippet code/doc_src_containers.cpp 17
-
- And like any other C++ loop construct, you can use braces around
- the body of a \c foreach loop, and you can use \c break to leave
- the loop:
-
- \snippet code/doc_src_containers.cpp 18
-
- With QMap and QHash, \c foreach accesses the value component of
- the (key, value) pairs automatically, so you should not call
- values() on the container (it would generate an unnecessary copy,
- see below). If you want to iterate over both the keys and the
- values, you can use iterators (which are faster), or you can
- obtain the keys, and use them to get the values too:
-
- \snippet code/doc_src_containers.cpp 19
-
- For a multi-valued map:
-
- \snippet code/doc_src_containers.cpp 20
-
- Qt automatically takes a copy of the container when it enters a
- \c foreach loop. If you modify the container as you are
- iterating, that won't affect the loop. (If you do not modify the
- container, the copy still takes place, but thanks to \l{implicit
- sharing} copying a container is very fast.)
+ \section2 Java-Style Iterators
+ \l{java-style-iterators}{Java-Style iterators} were introduced in Qt 4. Their API is modelled
+ on Java's iterator classes.
+ New code should should prefer \l{STL-Style Iterators}.
- Since foreach creates a copy of the container, using a non-const
- reference for the variable does not allow you to modify the original
- container. It only affects the copy, which is probably not what you
- want.
+ \section1 Container keywords
- An alternative to Qt's \c foreach loop is the range-based \c for that is
- part of C++ 11 and newer. However, keep in mind that the range-based
- \c for might force a Qt container to \l{Implicit Sharing}{detach}, whereas
- \c foreach would not. But using \c foreach always copies the container,
- which is usually not cheap for STL containers. If in doubt, prefer
- \c foreach for Qt containers, and range based \c for for STL ones.
+ \target foreach
+ \section2 The foreach Keyword
+ \l{foreach-keyword}{The foreach keyword} is discouraged, new code should
+ prefer C++11 range-based loops.
+ \target forever
+ \section2 The forever keyword.
In addition to \c foreach, Qt also provides a \c forever
pseudo-keyword for infinite loops:
@@ -596,6 +376,9 @@
\snippet code/doc_src_containers.cpp 22
+ \note The alternative macros Q_FOREACH and Q_FOREVER remain defined
+ regardless.
+
\section1 Other Container-Like Classes
Qt includes other template classes that resemble containers in
@@ -691,6 +474,29 @@
with the expected number of items before you insert the items.
The next section discusses this topic in more depth.
+ \section1 Optimizations for Primitive and Relocatable Types
+
+ Qt containers can use optimized code paths if the stored
+ elements are relocatable or even primitive.
+ However, whether types are primitive or relocatable
+ cannot be detected in all cases.
+ You can declare your types to be primitive or relocatable
+ by using the Q_DECLARE_TYPEINFO macro with the Q_PRIMITIVE_TYPE
+ flag or the Q_RELOCATABLE_TYPE flag. See the documentation
+ of Q_DECLARE_TYPEINFO for further details and usage examples.
+
+ If you do not use Q_DECLARE_TYPEINFO,
+ Qt will use
+ \l {https://en.cppreference.com/w/cpp/types/is_trivial} {std::is_trivial_v<T>}
+ to indentify primitive
+ types and it will require both
+ \l {https://en.cppreference.com/w/cpp/types/is_trivially_copyable} {std::is_trivially_copyable_v<T>}
+ and
+ \l {https://en.cppreference.com/w/cpp/types/is_destructible} {std::is_trivially_destructible_v<T>}
+ to identify relocatable types.
+ This is always a safe choice, albeit
+ of maybe suboptimal performance.
+
\section1 Growth Strategies
QList<T>, QString, and QByteArray store their items
@@ -707,39 +513,23 @@
We build the string \c out dynamically by appending one character
to it at a time. Let's assume that we append 15000 characters to
- the QString string. Then the following 18 reallocations (out of a
- possible 15000) occur when QString runs out of space: 4, 8, 12,
- 16, 20, 52, 116, 244, 500, 1012, 2036, 4084, 6132, 8180, 10228,
- 12276, 14324, 16372. At the end, the QString has 16372 Unicode
+ the QString string. Then the following 11 reallocations (out of a
+ possible 15000) occur when QString runs out of space: 8, 24, 56,
+ 120, 248, 504, 1016, 2040, 4088, 8184, 16376.
+ At the end, the QString has 16376 Unicode
characters allocated, 15000 of which are occupied.
- The values above may seem a bit strange, but here are the guiding
- principles:
- \list
- \li QString allocates 4 characters at a time until it reaches size 20.
- \li From 20 to 4084, it advances by doubling the size each time.
- More precisely, it advances to the next power of two, minus
- 12. (Some memory allocators perform worst when requested exact
- powers of two, because they use a few bytes per block for
- book-keeping.)
- \li From 4084 on, it advances by blocks of 2048 characters (4096
- bytes). This makes sense because modern operating systems
- don't copy the entire data when reallocating a buffer; the
- physical memory pages are simply reordered, and only the data
- on the first and last pages actually needs to be copied.
- \endlist
+ The values above may seem a bit strange, but there is a guiding
+ principle. It advances by doubling the size each time.
+ More precisely, it advances to the next power of two, minus
+ 16 bytes. 16 bytes corresponds to eight characters, as QString
+ uses UTF-16 internally.
+
+ QByteArray uses the same algorithm as
+ QString, but 16 bytes correspond to 16 characters.
- QByteArray uses more or less the same algorithm as
- QString.
-
- QList<T> also uses that algorithm for data types that can be
- moved around in memory using \c memcpy() (including the basic C++
- types, the pointer types, and Qt's \l{shared classes}) but uses a
- different algorithm for data types that can only be moved by
- calling the copy constructor and a destructor. Since the cost of
- reallocating is higher in that case, QList<T> reduces the
- number of reallocations by always doubling the memory when
- running out of space.
+ QList<T> also uses that algorithm, but 16 bytes correspond to
+ 16/sizeof(T) elements.
QHash<Key, T> is a totally different case. QHash's internal hash
table grows by powers of two, and each time it grows, the items
diff --git a/src/corelib/doc/src/foreach-keyword.qdoc b/src/corelib/doc/src/foreach-keyword.qdoc
new file mode 100644
index 0000000000..a36f8be608
--- /dev/null
+++ b/src/corelib/doc/src/foreach-keyword.qdoc
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU 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: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page foreach-keyword.html
+ \title Qt's foreach Keyword
+ \ingroup groups
+ \ingroup qt-basic-concepts
+
+ \brief Qt's foreach keyword.
+
+ \tableofcontents
+
+ \target foreach-keyword
+ \section1 The foreach Keyword
+
+ \note The foreach keyword was introduced before the C++11 range-based loops
+ existed. New code should prefer C++11 range-based loops.
+
+ The \c foreach keyword is a Qt-specific addition to the C++ language,
+ and is implemented using the preprocessor.
+
+ Its syntax is: \c foreach (\e variable, \e container) \e
+ statement. For example, here's how to use \c foreach to iterate
+ over a QList<QString>:
+
+ \snippet code/doc_src_containers.cpp 15
+
+ The \c foreach code is significantly shorter than the equivalent
+ code that uses iterators:
+
+ \snippet code/doc_src_containers.cpp 16
+
+ Unless the data type contains a comma (e.g., \c{QPair<int,
+ int>}), the variable used for iteration can be defined within the
+ \c foreach statement:
+
+ \snippet code/doc_src_containers.cpp 17
+
+ And like any other C++ loop construct, you can use braces around
+ the body of a \c foreach loop, and you can use \c break to leave
+ the loop:
+
+ \snippet code/doc_src_containers.cpp 18
+
+ With QMap and QHash, \c foreach accesses the value component of
+ the (key, value) pairs automatically, so you should not call
+ values() on the container (it would generate an unnecessary copy,
+ see below). If you want to iterate over both the keys and the
+ values, you can use iterators (which are faster), or you can
+ obtain the keys, and use them to get the values too:
+
+ \snippet code/doc_src_containers.cpp 19
+
+ For a multi-valued map:
+
+ \snippet code/doc_src_containers.cpp 20
+
+ Qt automatically takes a copy of the container when it enters a
+ \c foreach loop. If you modify the container as you are
+ iterating, that won't affect the loop. (If you do not modify the
+ container, the copy still takes place, but thanks to \l{implicit
+ sharing} copying a container is very fast.)
+
+ Since foreach creates a copy of the container, using a non-const
+ reference for the variable does not allow you to modify the original
+ container. It only affects the copy, which is probably not what you
+ want.
+
+ An alternative to Qt's \c foreach loop is the range-based \c for that is
+ part of C++11 and newer. However, keep in mind that the range-based
+ \c for might force a Qt container to \l{Implicit Sharing}{detach}, whereas
+ \c foreach would not. But using \c foreach always copies the container,
+ which is usually not cheap for STL containers. If in doubt, prefer
+ \c foreach for Qt containers, and range based \c for for STL ones.
+*/
diff --git a/src/corelib/doc/src/includes/qt_add_binary_resources.qdocinc b/src/corelib/doc/src/includes/qobject.qdocinc
index 21d3ca5990..1af4d3ae33 100644
--- a/src/corelib/doc/src/includes/qt_add_binary_resources.qdocinc
+++ b/src/corelib/doc/src/includes/qobject.qdocinc
@@ -25,15 +25,10 @@
**
****************************************************************************/
-//! [description]
-Adds a custom \c target that compiles Qt resource files into a binary \c{.rcc}
-file.
-//! [description]
-
-//! [arguments]
-\c{DESTINATION} sets the path of the generated \c{.rcc} file. The default is
-\c{${CMAKE_CURRENT_BINARY_DIR}/${target}.rcc}.
-
-You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls.
-You can find possible options in the \l{rcc}{rcc documentation}.
-//! [arguments]
+//! [disconnect-all]
+\note Disconnecting all signal-slot connections will also disconnect the
+\l QObject::destroyed() signal if it is connected. Doing so can adversely
+affect classes that rely on this signal for cleaning up resources. It is
+recommended to disconnect only the specific signals that were connected by
+application code.
+//! [disconnect-all]
diff --git a/src/corelib/doc/src/includes/qt_add_big_resources.qdocinc b/src/corelib/doc/src/includes/qt_add_big_resources.qdocinc
deleted file mode 100644
index 0a76bdd844..0000000000
--- a/src/corelib/doc/src/includes/qt_add_big_resources.qdocinc
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU 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: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [description]
-Creates compiled object files from Qt resource files using the
-\l{Resource Compiler (rcc)}. Paths to the generated files are added to
-\c{<VAR>}.
-
-This is similar to \l qt5_add_resources / \l qt_add_resources, but directly
-generates object files (\c .o, \c .obj) files instead of C++ source code.
-This allows to embed bigger resources, where compiling to C++ sources and then
-to binaries would be too time consuming or memory intensive.
-
-\note This macro is only available if using \c{CMake} 3.9 or later.
-//! [description]
-
-//! [arguments]
-You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls.
-You can find possible options in the \l{rcc}{rcc documentation}.
-//! [arguments]
diff --git a/src/corelib/doc/src/includes/qt_add_resources.qdocinc b/src/corelib/doc/src/includes/qt_add_resources.qdocinc
deleted file mode 100644
index b3c032a04b..0000000000
--- a/src/corelib/doc/src/includes/qt_add_resources.qdocinc
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU 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: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [description]
-Creates source code from Qt resource files using the
-\l{Resource Compiler (rcc)}. Paths to the generated source files are added to
-\c{<VAR>}.
-
-\note This is a low-level macro. See the \l{CMake AUTORCC Documentation} for a
-more convenient way to let Qt resource files be processed with \c{rcc}.
-//! [description]
-
-//! [arguments]
-You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls.
-You can find possible options in the \l{rcc}{rcc documentation}.
-//! [arguments]
diff --git a/src/corelib/doc/src/includes/qt_generate_moc.qdocinc b/src/corelib/doc/src/includes/qt_generate_moc.qdocinc
deleted file mode 100644
index c1c0ada978..0000000000
--- a/src/corelib/doc/src/includes/qt_generate_moc.qdocinc
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU 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: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [description]
-Creates a rule to call the \l{moc}{Meta-Object Compiler (moc)} on \c src_file
-and store the output in \c dest_file.
-
-\note This is a low-level macro. See the \l{CMake AUTOMOC Documentation} for a
-more convenient way to let source files be processed with \c{moc}.
-\l qt5_wrap_cpp is also similar, but automatically generates a temporary file
-path for you.
-//! [description]
-
-//! [arguments]
-You can set an explicit \c{TARGET}. This will make sure that the target
-properties \c{INCLUDE_DIRECTORIES} and \c{COMPILE_DEFINITIONS} are also used
-when scanning the source files with \c{moc}.
-//! [arguments]
diff --git a/src/corelib/doc/src/includes/qt_import_plugins.qdocinc b/src/corelib/doc/src/includes/qt_import_plugins.qdocinc
deleted file mode 100644
index 005a73d1d7..0000000000
--- a/src/corelib/doc/src/includes/qt_import_plugins.qdocinc
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU 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: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [description]
-Specifies a custom set of plugins to import. The optional arguments:
-\c INCLUDE, \c EXCLUDE, \c INCLUDE_BY_TYPE, and \c EXCLUDE_BY_TYPE,
-can be used more than once.
-
-This CMake command was introduced in Qt 5.14.
-
-\list
-\li \c INCLUDE -- can be used to specify a list of plugins to import.
-\li \c EXCLUDE -- can be used to specify a list of plugins to exclude.
-\li \c INCLUDE_BY_TYPE -- can be used to override the list of plugins to
- import for a certain plugin type.
-\li \c EXCLUDE_BY_TYPE -- can be used to specify a plugin type to exclude;
- then no plugins of that type are imported.
-\endlist
-
-Qt provides plugin types such as \c imageformats, \c platforms,
-and \c sqldrivers.
-
-If the command isn't used the target automatically links against
-a sane set of default plugins, for each Qt module that the target is linked
-against. For more information, see
-\l{CMake target_link_libraries Documentation}{target_link_libraries}.
-
-Each plugin comes with a C++ stub file that automatically
-initializes the plugin. Consequently, any target that links against a plugin
-has this C++ file added to its \c SOURCES.
-
-\note This command imports plugins from static Qt builds only.
-On shared builds, it does nothing.
-//! [description]
diff --git a/src/corelib/doc/src/includes/qt_wrap_cpp.qdocinc b/src/corelib/doc/src/includes/qt_wrap_cpp.qdocinc
deleted file mode 100644
index 3f6b278557..0000000000
--- a/src/corelib/doc/src/includes/qt_wrap_cpp.qdocinc
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU 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: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [description]
-Creates rules for calling the \l{moc}{Meta-Object Compiler (moc)} on the given
-source files. For each input file, an output file is generated in the build
-directory. The paths of the generated files are added to \c{<VAR>}.
-
-\note This is a low-level macro. See the \l{CMake AUTOMOC Documentation} for a
-more convenient way to let source files be processed with \c{moc}.
-//! [description]
-
-//! [arguments]
-You can set an explicit \c{TARGET}. This will make sure that the target
-properties \c{INCLUDE_DIRECTORIES} and \c{COMPILE_DEFINITIONS} are also used
-when scanning the source files with \c{moc}.
-
-You can set additional \c{OPTIONS} that should be added to the \c{moc} calls.
-You can find possible options in the \l{moc}{moc documentation}.
-
-\c{DEPENDS} allows you to add additional dependencies for recreation of the
-generated files. This is useful when the sources have implicit dependencies,
-like code for a Qt plugin that includes a \c{.json} file using the
-Q_PLUGIN_METADATA() macro.
-//! [arguments]
diff --git a/src/corelib/doc/src/java-style-iterators.qdoc b/src/corelib/doc/src/java-style-iterators.qdoc
new file mode 100644
index 0000000000..69b9592996
--- /dev/null
+++ b/src/corelib/doc/src/java-style-iterators.qdoc
@@ -0,0 +1,198 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU 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: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page java-style-iterators.html
+ \title Java-style Iterators in Qt
+ \ingroup groups
+ \ingroup qt-basic-concepts
+ \brief Java style iterators for Qt's containers.
+
+ \tableofcontents
+
+ \section1 Java-Style Iterators
+
+ For each container class, there are two Java-style iterator data
+ types: one that provides read-only access and one that provides
+ read-write access.
+
+ \note New code should use \l{STL-Style iterators} since these are more efficient
+ and can be used together with Qt's and STL's \l{generic algorithms}.
+
+ \table
+ \header \li Containers \li Read-only iterator
+ \li Read-write iterator
+ \row \li QList<T>, QQueue<T>, QStack<T>, \li QListIterator<T>
+ \li QMutableListIterator<T>
+ \row \li QSet<T> \li QSetIterator<T>
+ \li QMutableSetIterator<T>
+ \row \li QMap<Key, T>, QMultiMap<Key, T> \li QMapIterator<Key, T>
+ \li QMutableMapIterator<Key, T>
+ \row \li QHash<Key, T>, QMultiHash<Key, T> \li QHashIterator<Key, T>
+ \li QMutableHashIterator<Key, T>
+ \endtable
+
+ In this discussion, we will concentrate on QList and QMap. The
+ iterator types for QSet have exactly
+ the same interface as QList's iterators; similarly, the iterator
+ types for QHash have the same interface as QMap's iterators.
+
+ Unlike \l{STL-Style iterators}, Java-style iterators point \e between items
+ rather than directly \e at items. For this reason, they are either pointing
+ to the very beginning of the container (before the first item), at the very
+ end of the container (after the last item), or between two items. The
+ diagram below shows the valid iterator positions as red arrows for a list
+ containing four items:
+
+ \image javaiterators1.png
+
+ Here's a typical loop for iterating through all the elements of a
+ QList<QString> in order and printing them to the console:
+
+ \snippet code/doc_src_containers.cpp 1
+
+ It works as follows: The QList to iterate over is passed to the
+ QListIterator constructor. At that point, the iterator is located
+ just in front of the first item in the list (before item "A").
+ Then we call \l{QListIterator::hasNext()}{hasNext()} to
+ check whether there is an item after the iterator. If there is, we
+ call \l{QListIterator::next()}{next()} to jump over that
+ item. The next() function returns the item that it jumps over. For
+ a QList<QString>, that item is of type QString.
+
+ Here's how to iterate backward in a QList:
+
+ \snippet code/doc_src_containers.cpp 2
+
+ The code is symmetric with iterating forward, except that we
+ start by calling \l{QListIterator::toBack()}{toBack()}
+ to move the iterator after the last item in the list.
+
+ The diagram below illustrates the effect of calling
+ \l{QListIterator::next()}{next()} and
+ \l{QListIterator::previous()}{previous()} on an iterator:
+
+ \image javaiterators2.png
+
+ The following table summarizes the QListIterator API:
+
+ \table
+ \header \li Function \li Behavior
+ \row \li \l{QListIterator::toFront()}{toFront()}
+ \li Moves the iterator to the front of the list (before the first item)
+ \row \li \l{QListIterator::toBack()}{toBack()}
+ \li Moves the iterator to the back of the list (after the last item)
+ \row \li \l{QListIterator::hasNext()}{hasNext()}
+ \li Returns \c true if the iterator isn't at the back of the list
+ \row \li \l{QListIterator::next()}{next()}
+ \li Returns the next item and advances the iterator by one position
+ \row \li \l{QListIterator::peekNext()}{peekNext()}
+ \li Returns the next item without moving the iterator
+ \row \li \l{QListIterator::hasPrevious()}{hasPrevious()}
+ \li Returns \c true if the iterator isn't at the front of the list
+ \row \li \l{QListIterator::previous()}{previous()}
+ \li Returns the previous item and moves the iterator back by one position
+ \row \li \l{QListIterator::peekPrevious()}{peekPrevious()}
+ \li Returns the previous item without moving the iterator
+ \endtable
+
+ QListIterator provides no functions to insert or remove items
+ from the list as we iterate. To accomplish this, you must use
+ QMutableListIterator. Here's an example where we remove all
+ odd numbers from a QList<int> using QMutableListIterator:
+
+ \snippet code/doc_src_containers.cpp 3
+
+ The next() call in the loop is made every time. It jumps over the
+ next item in the list. The
+ \l{QMutableListIterator::remove()}{remove()} function removes the
+ last item that we jumped over from the list. The call to
+ \l{QMutableListIterator::remove()}{remove()} does not invalidate
+ the iterator, so it is safe to continue using it. This works just
+ as well when iterating backward:
+
+ \snippet code/doc_src_containers.cpp 4
+
+ If we just want to modify the value of an existing item, we can
+ use \l{QMutableListIterator::setValue()}{setValue()}. In the code
+ below, we replace any value larger than 128 with 128:
+
+ \snippet code/doc_src_containers.cpp 5
+
+ Just like \l{QMutableListIterator::remove()}{remove()},
+ \l{QMutableListIterator::setValue()}{setValue()} operates on the
+ last item that we jumped over. If we iterate forward, this is the
+ item just before the iterator; if we iterate backward, this is
+ the item just after the iterator.
+
+ The \l{QMutableListIterator::next()}{next()} function returns a
+ non-const reference to the item in the list. For simple
+ operations, we don't even need
+ \l{QMutableListIterator::setValue()}{setValue()}:
+
+ \snippet code/doc_src_containers.cpp 6
+
+ As mentioned above QSet's iterator
+ classes have exactly the same API as QList's. We will now turn to
+ QMapIterator, which is somewhat different because it iterates on
+ (key, value) pairs.
+
+ Like QListIterator, QMapIterator provides
+ \l{QMapIterator::toFront()}{toFront()},
+ \l{QMapIterator::toBack()}{toBack()},
+ \l{QMapIterator::hasNext()}{hasNext()},
+ \l{QMapIterator::next()}{next()},
+ \l{QMapIterator::peekNext()}{peekNext()},
+ \l{QMapIterator::hasPrevious()}{hasPrevious()},
+ \l{QMapIterator::previous()}{previous()}, and
+ \l{QMapIterator::peekPrevious()}{peekPrevious()}. The key and
+ value components are extracted by calling \l{QMapIterator::key()}{key()} and \l{QMapIterator::value()}{value()} on
+ the object returned by next(), peekNext(), previous(), or
+ peekPrevious().
+
+ The following example removes all (capital, country) pairs where
+ the capital's name ends with "City":
+
+ \snippet code/doc_src_containers.cpp 7
+
+ QMapIterator also provides a \l{QMapIterator::key()}{key()} and a \l{QMapIterator::value()}{value()} function that
+ operate directly on the iterator and that return the key and
+ value of the last item that the iterator jumped above. For
+ example, the following code copies the contents of a QMap into a
+ QHash:
+
+ \snippet code/doc_src_containers.cpp 8
+
+ If we want to iterate through all the items with the same
+ value, we can use \l{QMapIterator::findNext()}{findNext()}
+ or \l{QMapIterator::findPrevious()}{findPrevious()}.
+ Here's an example where we remove all the items with a particular
+ value:
+
+ \snippet code/doc_src_containers.cpp 9
+
+*/
diff --git a/src/corelib/doc/src/objectmodel/metaobjects.qdoc b/src/corelib/doc/src/objectmodel/metaobjects.qdoc
index 53b34fe120..ada6a6dea1 100644
--- a/src/corelib/doc/src/objectmodel/metaobjects.qdoc
+++ b/src/corelib/doc/src/objectmodel/metaobjects.qdoc
@@ -72,7 +72,7 @@
\li QObject::inherits() function returns whether an object is an
instance of a class that inherits a specified class within the
QObject inheritance tree.
- \li QObject::tr() and QObject::trUtf8() translate strings for
+ \li QObject::tr() translates strings for
\l{Internationalization with Qt}{internationalization}.
\li QObject::setProperty() and QObject::property()
dynamically set and get properties by name.
diff --git a/src/corelib/doc/src/objectmodel/properties.qdoc b/src/corelib/doc/src/objectmodel/properties.qdoc
index e3c506e8bc..9a2517e050 100644
--- a/src/corelib/doc/src/objectmodel/properties.qdoc
+++ b/src/corelib/doc/src/objectmodel/properties.qdoc
@@ -131,6 +131,12 @@
editable property for (checkable) buttons. Note that QItemDelegate
gets and sets a widget's \c USER property.
+ \li The \c {BINDABLE bindableProperty} attribute indicates that the
+ property supports bindings, and that it is possible to set and inspect
+ bindings to this property via the meta object system (QMetaProperty).
+ \c bindableProperty names a class member of type QBindable<T>, where T
+ is the property type. This attribute was introduced in Qt 6.0.
+
\li The presence of the \c CONSTANT attribute indicates that the property
value is constant. For a given object instance, the READ method of a
constant property must return the same value every time it is called. This
diff --git a/src/corelib/doc/src/qt6-changes.qdoc b/src/corelib/doc/src/qt6-changes.qdoc
index b0bd502eac..d789f42fc5 100644
--- a/src/corelib/doc/src/qt6-changes.qdoc
+++ b/src/corelib/doc/src/qt6-changes.qdoc
@@ -27,8 +27,8 @@
/*!
\page qtcore-changes-qt6.html
- \title Porting to Qt 6 - Qt Core
- \ingroup porting-guides-5-to-6
+ \title Changes to Qt Core
+ \ingroup changes-qt-5-to-6
\brief Migrate Qt Core to Qt 6.
Qt 6 is a result of the conscious effort to make the framework more
@@ -48,7 +48,7 @@
\section3 qHash() Signature
For custom types, QHash and QMultiHash rely on you providing
- a \l{The qHash() hashing function} {custom qHash() function}
+ a \l{qHash}{custom qHash() function}
in the same namespace. In Qt 4 and Qt 5, the return
value and optional second argument of a \c qHash function
was of type \c uint. In Qt 6, it is \c size_t.
@@ -87,4 +87,751 @@
In Qt 6, both types and use cases are distinct, and QHash::insertMulti
got removed.
+
+ \section2 QVector, QList
+
+ Prior to Qt 6, QVector and QList were separate classes. In Qt 6, they are
+ unified: Qt 5 QList implementation is gone and both classes use updated
+ QVector implementation instead. QList is the class with the actual
+ implementation and QVector is an alias (typedef) to QList.
+
+ QList's fromVector() and toVector(), and QVector's fromList() and toList(),
+ no longer involve data copying in Qt 6. They now return the object that they
+ were called for.
+
+ \section3 API Changes
+
+ QList's (and hence QVector's) size type is changed from \c int to \c
+ qsizetype. Together with the size type, all relevant methods' signatures are
+ updated to use \c qsizetype. This allows QList to hold more than 2^31 items
+ on 64 bit platforms.
+
+ When upgrading the code base to Qt 6, this API change would most likely
+ result in compiler warnings about narrowing type conversions. Having the
+ following example code:
+
+ \code
+ void myFunction(QList<MyType> &data) {
+ int size = data.size();
+ // ...
+ const int pos = getInsertPosition(size);
+ data.insert(pos, MyType());
+ // ...
+ }
+ \endcode
+
+ you would need to update it to use either \c qsizetype or an auto keyword:
+
+ \code
+ void myFunction(QList<MyType> &data) {
+ auto size = data.size();
+ // ...
+ const auto pos = getInsertPosition(size);
+ data.insert(pos, MyType());
+ // ...
+ }
+ \endcode
+
+ Alternatively, you may use type casting and cast everything to \c int or to
+ \c qsizetype.
+
+ \note If you want to build against both Qt 5 and Qt 6, the auto keyword is a
+ good solution to cover signature differences between the versions.
+
+ \section3 Memory Layout
+
+ QList received multiple changes related to the memory layout in Qt 6.
+
+ In Qt 5, \c{sizeof(QList<T>)} was equal to a size of a pointer. Now, the
+ extra pointer indirection is removed and QList data members are directly
+ stored in the object. By default, expect \c{sizeof(QList<T>)} to be equal to
+ the size of 3 pointers.
+
+ At the same time, memory layout of the elements is also updated. QList now
+ always stores its elements directly in the allocated memory region as
+ opposed to Qt 5, where certain objects were separately allocated on the heap
+ and pointers to the objects were placed into the QList instead.
+
+ Note that the latter, in particular, affects large objects. To have Qt 5
+ behavior, you could wrap your objects into smart pointers and store these
+ smart pointers in QList directly. In this case, the type of your QList would
+ be \c{QList<MySmartPointer<MyLargeObject>>} as opposed to
+ \c{QList<MyLargeObject>} in Qt 5.
+
+ \section3 Stability of References
+
+ There are several changes made to the QVector/QList implementation. The
+ QVector related one is: insertion at the beginning is optimized (similarly
+ to QList in Qt 5). The QList related one is: memory layout for the elements
+ is simplified.
+
+ \important These changes impact the stability of references. In Qt 6, you
+ should consider any size or capacity modifying method to invalidate all
+ references, even when QList is not \l{Implicit Sharing}{implicitly shared}.
+ Exceptions to this rule are documented explicitly.
+
+ Applications that rely on certain reference stability might run into
+ undefined behavior when upgraded to use Qt 6. You should pay extra attention
+ to cases where QVector or QList with a non C-compatible array layout were
+ used originally.
+
+ \section1 View classes in Qt6
+
+ \section2 General Overview
+
+ There are several new \c View classes coming with Qt6. There is the already
+ existing \l QStringView, now accompanied by \l QByteArrayView and followed
+ by a specialized \l QUtf8StringView and a more universal \l QAnyStringView.
+
+ \section2 Introduction to view classes on the example of QStringView
+
+ The QStringView class provides a unified view on UTF-16 strings with a
+ read-only subset of the QString API. Unlike QString, which keeps its own
+ copy of the string (possibly ref-counted), QStringView provides a view of
+ a string that is stored elsewhere.
+
+ \code
+ char hello[]{ "Hello." }; // narrow multi-byte string literal
+ QString str{hello}; // needs to make a copy of the string literal
+ QString strToStr(str); // atomic increment involved to not create a copy of hello again
+
+ // The above code can be re-written to avoid copying and atomic increment.
+
+ QStringView view{ u"Hello." }; // view to UTF-16 encoded string literal
+ QStringView viewToView{ view }; // view of the same UTF-16 encoded string literal
+ \endcode
+
+ The string \c "Hello." is stored in the binary and is not allocated at
+ run-time. \c view is only a view onto the string \c "Hello.", therefore
+ no copy has to be created. When we copy a QStringView, the \c viewToView
+ observes the same string as the copied-from \c view is observing. This
+ means that \c viewToView does not need to create a copy or an atomic
+ increment. They are views onto the existing string \c "Hello.".
+
+ \section2 Views as function argument
+
+ Views should be passed by value, not by reference-to-const.
+
+ \code
+ void myfun1(QStringView sv); // preferred
+ void myfun2(const QStringView &sv); // compiles and works, but slower
+ \endcode
+
+ \section2 View manipulation functions
+
+ QStringView supports functions that let us manipulate the view of the
+ string. This allows us to change the view without creating a partial copy
+ of the viewed string.
+
+ \code
+ QString pineapple = "Pineapple";
+ QString pine = pineapple.left(4);
+
+ // The above code can be re-written to avoid creating a partial copy.
+
+ QStringView pineappleView{ pineapple };
+ QStringView pineView = pineappleView.left(4);
+ \endcode
+
+ \section2 Non null-terminated strings and strings containing \c {'\0'}
+
+ QStringView supports both null-terminated and non null-terminated strings.
+ The difference comes from the way you initialize the QStringView:
+
+ \code
+ QChar aToE[]{ 'a', 'b', 'c', 'd', 'e' };
+
+ QStringView nonNull{ aToE, std::size(aToE) }; // with length given
+ QStringView nonNull{ aToE }; // automatically determines the length
+
+ QChar fToJ[]{ 'f', 'g', 'h', '\0', 'j' };
+
+ // uses given length, doesn't search for '\0', so '\0' at position 3
+ // is considered to be a part of the string similarly to 'h' and 'j
+ QStringView nonNull{ fToJ, std::size(fToJ) };
+ QStringView part{ fToJ }; //stops on the first encounter of '\0'
+ \endcode
+
+ \section2 Ownership model of views
+
+ As \c views do not own the memory they reference, care must be taken to
+ ensure that the referenced data (for example, owned by a \l QString)
+ outlives the \c view on all code paths.
+
+ \badcode
+ QStringView sayHello()
+ {
+ QString hello("Hello.");
+ return QStringView{ hello }; // hello gets out of scope and destroyed
+ }
+
+ void main()
+ {
+ QStringView hello{ sayHello() };
+ qDebug() << hello; // undefined behavior
+ }
+ \endcode
+
+ \section2 Converting an QStringView to QString
+
+ QStringView will not implicitly or explicitly convert to a QString, but can
+ create a deep copy of its data:
+
+ \code
+ void print(const QString &s) { qDebug() << s; }
+
+ void main()
+ {
+ QStringView string{ u"string"};
+
+ // print(string); // invalid, no implicit conversion
+ // QString str{ string }; // invalid, no explicit conversion
+
+ print(string.toString());
+ QString str = string.toString(); // create QString from view
+ }
+ \endcode
+
+ \section2 Important notes
+
+ By leveraging the new view classes, one can achieve a lot of performance
+ boost in many use cases. However, it is important to know that there might
+ be some caveats. Therefore it is important to remember:
+
+ \list
+ \li Views should be passed by value, not by reference-to-const.
+ \li Constructing a view with a negative length is undefined behavior.
+ \li Care must be taken to ensure that the referenced data (for example,
+ owned by a \l QString) outlives the view on all code paths.
+ \endlist
+
+ \section1 String related classes
+
+ \section2 QStringView
+
+ Starting with Qt6 it is generally recommended to use \l QStringView over
+ \c QStringRef. \l QStringView references a contiguous portion of a UTF-16
+ string it does not own. It acts as an interface type to all kinds of UTF-16
+ strings, without the need to construct a \l QString first. The \l QStringView
+ class exposes almost all read-only methods of \l QString and the previously
+ existing \c QStringRef class.
+
+ \note Care must be taken to ensure that the referenced string data (for
+ example, owned by a \l QString) outlives the \l QStringView on all code paths.
+
+ \note If a \l QStringView wraps a \l QString, care needs to be taken since
+ unlike \c QStringRef \l QStringView will not update the internal data pointer
+ once the \l QString data relocates.
+
+ \code
+ QString string = ...;
+ QStringView view{string};
+
+ // Appending something very long might cause a relocation and will
+ // ultimately result in a garbled QStringView.
+ string += ...;
+ \endcode
+
+ \section2 QStringRef
+
+ In Qt6 \l QStringRef got removed from Qt Core. To ease porting of existing
+ applications without touching the whole code-base, the \c QStringRef class
+ did not vanish completely and instead it got moved into the Qt5Compat module.
+
+ If you want to use \c QStringRef further, you need to link against the new
+ Qt5Compat module and add this line to your \l qmake \c .pro file:
+ \code
+ QT += core5compat
+ \endcode
+
+ In case you already ported your application or library to the
+ \l {Build with CMake}{cmake} build system, add the following to your
+ \c CMakeList.txt:
+ \code
+ PUBLIC_LIBRARIES
+ Qt::Core5Compat
+ \endcode
+
+ Unfortunately, some methods exposed by \l QString returning a \c QStringRef,
+ could not be moved to Qt5Compat. Therefore some manually porting may be
+ needed. If your code uses one or more of the following functions you need to
+ port them to use \l QStringView or \l QStringTokenizer. It is also
+ recommended to use \l {QStringView::tokenize} over \l {QStringView::split}
+ for performance critical code.
+
+ Change code using \c QStringRef:
+ \code
+ QString string = ...;
+ QStringRef left = string.leftRef(n);
+ QStringRef mid = string.midRef(n);
+ QStringRef right = string.rightRef(n);
+
+ QString value = ...;
+ const QVector<QStringRef> refs = string.splitRef(' ');
+ if (refs.contains(value))
+ return true;
+ \endcode
+
+ to:
+
+ \code
+ QString string = ...;
+ QStringView left = QStringView{string}.left(n);
+ QStringView mid = QStringView{string}.mid(n);
+ QStringView right = QStringView{string}.right(n);
+
+ QString value = ...;
+ const QList<QStringView> refs = QStringView{string}.split(u' ');
+ if (refs.contains(QStringView{value}))
+ return true;
+ // or
+ const auto refs = QStringView{string}.tokenize(u' ');
+ for (auto ref : refs) {
+ if (ref == value)
+ return true;
+ }
+ \endcode
+
+ \section1 QFuture and Related Classes
+
+ \section2 QFuture
+
+ To avoid unintended usage of QFuture, there were some changes to
+ QFuture API in Qt 6, which may introduce source compatibility breaks.
+
+ \section3 Implicit conversions between QFuture and other types
+
+ Conversion of \c QFuture<T> to \c T has been disabled. The casting
+ operator was calling QFuture::result(), which may lead to undefined
+ behavior if the user has moved the results from QFuture via
+ QFuture::takeResult() before trying to do the conversion. Use
+ QFuture::result() or QFuture::takeResult() methods explicitly,
+ where you need to convert \c QFuture<T> to \c T.
+
+ The implicit conversion from \c QFuture<T> to \c QFuture<void> has
+ been also disabled. If you really intend to do the conversion, use the
+ explicit \c {QFuture<void>(const QFuture<T> &)} constructor:
+
+ \code
+ QFuture<int> future = ...
+ QFuture<void> voidFuture = QFuture<void>(future);
+ \endcode
+
+ \section3 Equality operators
+
+ The equality operators of QFuture have been removed. They were comparing
+ the underlying d-pointers instead of comparing the results, which is not
+ what users might expect. If you need to compare QFuture objects, use
+ \c QFuture::result() or \c QFuture::takeResult() methods. For example:
+
+ \code
+ QFuture<int> future1 = ...;
+ QFuture<int> future2 = ...;
+ if (future1.result() == future2.result())
+ // ...
+ \endcode
+
+ \section2 Behavioral Changes to QFuture and QFutureWatcher
+
+ In Qt 6, there were some improvements to QFuture and QFutureWatcher which
+ caused the following behavioral changes:
+
+ \list
+
+ \li After pausing QFuture or QFutureWatcher (by calling \c pause() or
+ \c setPaused(true)), QFutureWatcher will not immediately stop delivering
+ progress and result ready signals. At the moment of pausing there may be
+ still computations that are in progress and cannot be stopped. Signals
+ for such computations may be still delivered after pause, instead of being
+ postponed and reported only after next resume. To get notified when pause
+ actually took effect, QFutureWatcher::suspended() signal can be used. In
+ addition, there are new \c isSuspending() and \c isSuspended() methods,
+ to check if the QFuture is in the process of suspending or it's already in
+ the suspended state. Note that for consistency reasons, for both QFuture
+ and QFutureWatcher the pause-related APIs were deprecated and replaced by
+ similar methods having "suspend" in the name instead.
+
+ \li QFuture::waitForFinished() will now wait until QFuture is actually in
+ the finished state, instead of exiting as soon as it is not in the running
+ state. This prevents \c waitForFinished() from exiting immediately, if at
+ the moment of calling it the future is not started yet. The same applies to
+ QFutureWatcher::waitForFinished(). This change won't affect the behavior of
+ code that was using QFuture with QtConcurrent. Only the code that was using
+ it with the undocumented \c QFutureInterface may be affected.
+
+ \endlist
+
+ \section2 QPromise
+
+ In Qt 6, the new QPromise class should be used instead of unofficial
+ QFutureInterface as a "setter" counterpart of QFuture.
+
+ \section1 IO Classes
+
+ \section2 QProcess
+
+ In Qt 6, the QProcess::start() overload that interprets a single command string
+ by splitting it into program name and arguments is renamed to QProcess::startCommand().
+ However, a QProcess::start() overload that takes a single string, as well as a QStringList
+ for arguments exists. Since the QStringList parameter defaults to the empty list, existing
+ code only passing a string will still compile, but will fail to execute the process if it
+ is a complete command string that includes arguments.
+
+ Qt 5.15 introduced deprecation warnings for the respective overload to make it easy to
+ discover and update existing code:
+
+ \code
+ QProcess process;
+
+ // compiles with warnings in 5.15, compiles but fails with Qt 6
+ process.start("dir \"My Documents\"");
+
+ // works with both Qt 5 and Qt 6; also see QProcess::splitCommand()
+ process.start("dir", QStringList({"My Documents"});
+
+ // works with Qt 6
+ process.startCommand("dir \"My Documents\"");
+ \endcode
+
+ QProcess::pid() and the Q_PID type have been removed; use QProcess::processId() instead to
+ get the native process identifier. Code using native Win32 APIs to access the data in the
+ Q_PID as a Win32 \c{PROCESS_INFORMATION} struct is no longer supported.
+
+ \section1 Meta-Type system
+
+ \section2 QVariant
+
+ \c QVariant has been rewritten to use \c QMetaType for all of its operations. This implies
+ behavior changes in a few methods:
+
+ \list
+
+ \li \c QVariant::isNull() now only returns \c true if the \c QVariant is empty or contains a
+ \c nullptr. In Qt 5, it also returned true for classes in qtbase which had an \c isNull method
+ themselves if that one returned true. Code relying on the old behavior needs to check whether
+ the contained value returs isNull – however such code is unlikely to occur in practice, as
+ \c isNull() is rarely the property one is interested in (compare \c QString::isEmpty() / \c isNull()
+ and \c QTime::isValid / \c isNull).
+
+ \li \c QVariant::operator== uses \c QMetaType::equals in Qt 6. Therefore, some graphical
+ types like \c QPixmap, \c QImage and \c QIcon will never compare equal. Moreover, floating
+ point numbers stored in \c QVariant are no longer compared with \c qFuzzyCompare, but instead
+ use exact comparisons.
+
+ \endlist
+
+ \section2 QMetaType
+
+ In Qt 6, registration of comparators, and \cQDebug and \QDataStream streaming operators is
+ done automatically. Consequently, \c QMetaType::registerEqualsComparator(),
+ \c QMetaType::registerComparators(), \c qRegisterMetaTypeStreamOperators() and
+ \c QMetaType::registerDebugStreamOperator() do no longer exist. Calls to those methods
+ have to be removed when porting to Qt 6.
+
+ \section2 Type registration
+
+ Types used in \c Q_PROPERTY have their meta-type stored in the class' \c QMetaObject. This
+ requires the types to be complete when moc sees them, which can lead to compilation errors
+ in code that worked in Qt 5. There are three ways to fix this issue:
+
+ \list
+
+ \li Include the header which defines the type.
+ \li Instead of using an include, use the \c Q_MOC_INCLUDE macro. This helps if including the header
+ would cause a cyclic dependency, or when it would slow down compilation.
+ \li If the header is present in the cpp file which implements the class, it is also possible to include
+ the moc generated file there.
+
+ \endlist
+
+ \section1 Regular expression classes
+
+ \section2 QRegularExpression
+
+ In Qt6, all methods taking the \c QRegExp got removed from our code-base.
+ Therefore it is very likely that you will have to port your application or
+ library to \l QRegularExpression.
+
+ \l QRegularExpression implements Perl-compatible regular expressions. It
+ fully supports Unicode. For an overview of the regular expression syntax
+ supported by \l QRegularExpression, please refer to the aforementioned
+ pcrepattern(3) man page. A regular expression is made up of two things: a
+ pattern string and a set of pattern options that change the meaning of the
+ pattern string.
+
+ There are some subtle differences between \l QRegularExpression and \c
+ QRegExp that will be explained by this document to ease the porting effort.
+
+ \l QRegularExpression is more strict when it comes to the syntax of the
+ regular expression. Therefore it is always good to check the expression
+ for \l {QRegularExpression::isValid}{validity}.
+
+ \l QRegularExpression can almost always be declared const (except when the
+ pattern changes), while \c QRegExp almost never could be.
+
+ There is no replacement for the \l {QRegExp::CaretMode}{CaretMode}
+ enumeration. The \l {QRegularExpression::AnchoredMatchOption} match option
+ can be used to emulate the QRegExp::CaretAtOffset behavior. There is no
+ equivalent for the other QRegExp::CaretMode modes.
+
+ \l QRegularExpression supports only Perl-compatible regular expressions.
+ Still, it does not support all the features available in Perl-compatible
+ regular expressions. The most notable one is the fact that duplicated names
+ for capturing groups are not supported, and using them can lead to
+ undefined behavior. This may change in a future version of Qt.
+
+ \section3 Wildcard matching
+
+ There is no direct way to do wildcard matching in \l QRegularExpression.
+ However, the \l {QRegularExpression::wildcardToRegularExpression} method
+ is provided to translate glob patterns into a Perl-compatible regular
+ expression that can be used for that purpose.
+
+ \oldcode
+ QRegExp wildcard("*.txt");
+ wildcard.setPatternSyntax(QRegExp::Wildcard);
+ \newcode
+ auto wildcard = QRegularExpression(QRegularExpression::wildcardToRegularExpression("*.txt"));
+ \endcode
+
+ Please note though that not all shell like wildcard pattern might be
+ translated in a way you would expect it. The following example code will
+ silently break if simply converted using the above mentioned function:
+
+ \code *
+ const QString fp1("C:/Users/dummy/files/content.txt");
+ const QString fp2("/home/dummy/files/content.txt");
+
+ QRegExp re1("\1/files/*");
+ re1.setPatternSyntax(QRegExp::Wildcard);
+ ... = re1.exactMatch(fp1); // returns true
+ ... = re1.exactMatch(fp2); // returns true
+
+ // but converted with QRegularExpression::wildcardToRegularExpression()
+
+ QRegularExpression re2(QRegularExpression::wildcardToRegularExpression("\1/files/*"));
+ ... = re2.match(fp1).hasMatch(); // returns false
+ ... = re2.match(fp2).hasMatch(); // returns false
+ \endcode
+
+ \section3 Searching forward
+
+ Forward searching inside a string was usually implemented with a loop using
+ \c {QRegExp::indexIn} and a growing offset, but can now be easily implemented
+ with \l QRegularExpressionMatchIterator or \l {QString::indexOf}.
+
+ \oldcode
+ QString subject("the quick fox");
+
+ int offset = 0;
+ QRegExp re("(\\w+)");
+ while ((offset = re.indexIn(subject, offset)) != -1) {
+ offset += re.matchedLength();
+ // ...
+ }
+ \newcode
+ QRegularExpression re("(\\w+)");
+ QString subject("the quick fox");
+
+ QRegularExpressionMatchIterator i = re.globalMatch(subject);
+ while (i.hasNext()) {
+ QRegularExpressionMatch match = i.next();
+ // ...
+ }
+
+ // or alternatively using QString::indexOf
+
+ qsizetype from = 0;
+ QRegularExpressionMatch match;
+ while ((from = subject.indexOf(re, from, &match)) != -1) {
+ from += match.capturedLength();
+ // ...
+ }
+ \endcode
+
+ \section3 Searching backwards
+
+ Backwards searching inside a string was usually often implemented as a loop
+ over \c {QRegExp::lastIndexIn}, but can now be easily implemented using
+ \l {QString::lastIndexOf} and \l {QRegularExpressionMatch}.
+
+ \note \l QRegularExpressionMatchIterator is not capable of performing a
+ backwards search.
+
+ \oldcode
+ int offset = -1;
+ QString subject("Lorem ipsum dolor sit amet, consetetur sadipscing.");
+
+ QRegExp re("\\s+([ids]\\w+)");
+ while ((offset = re.lastIndexIn(subject, offset)) != -1) {
+ --offset;
+ // ...
+ }
+ \newcode
+ qsizetype from = -1;
+ QString subject("Lorem ipsum dolor sit amet, consetetur sadipscing.");
+
+ QRegularExpressionMatch match;
+ QRegularExpression re("\\s+([ids]\\w+)");
+ while ((from = subject.lastIndexOf(re, from, &match)) != -1) {
+ --from;
+ // ...
+ }
+ \endcode
+
+ \section3 exactMatch vs. match.hasMatch
+
+ \c {QRegExp::exactMatch} served two purposes: it exactly matched a regular
+ expression against a subject string, and it implemented partial matching.
+ Exact matching indicates whether the regular expression matches the entire
+ subject string. For example:
+
+ \code
+ QString source("abc123");
+
+ QRegExp("\\d+").exactMatch(source); // returns false
+ QRegExp("[a-z]+\\d+").exactMatch(source); // returns true
+
+ QRegularExpression("\\d+").match(source).hasMatch(); // returns true
+ QRegularExpression("[a-z]+\\d+").match(source).hasMatch(); // returns true
+ \endcode
+
+ Exact matching is not reflected in \l QRegularExpression. If you want to be
+ sure that the subject string matches the regular expression exactly, you
+ can wrap the pattern using the \l {QRegularExpression::anchoredPattern}
+ function:
+
+ \code
+ QString source("abc123");
+
+ QString pattern("\\d+");
+ QRegularExpression(pattern).match(source).hasMatch(); // returns true
+
+ pattern = QRegularExpression::anchoredPattern(pattern);
+ QRegularExpression(pattern).match(source).hasMatch(); // returns false
+ \endcode
+
+ \section3 Minimal matching
+
+ \c QRegExp::setMinimal() implemented minimal matching by simply reversing
+ the greediness of the quantifiers (\c QRegExp did not support lazy
+ quantifiers, like *?, +?, etc.). QRegularExpression instead does support
+ greedy, lazy and possessive quantifiers. The \l
+ {QRegularExpression::InvertedGreedinessOption} pattern option can be useful
+ to emulate the effects of \c QRegExp::setMinimal(): if enabled, it inverts
+ the greediness of quantifiers (greedy ones become lazy and vice versa).
+
+ \section3 Different pattern syntax
+
+ Porting a regular expression from \c QRegExp to \l QRegularExpression may
+ require changes to the pattern itself. Therefore it is recommended to check
+ the pattern used with the \l {QRegularExpression::isValid} method. This is
+ especially important for user provided pattern or pattern not controlled by
+ the developer.
+
+ In other cases, a pattern ported from \c QRegExp to \l QRegularExpression may
+ silently change semantics. Therefore, it is necessary to review the patterns
+ used. The most notable cases of silent incompatibility are:
+
+ \list
+ \li Curly braces are needed in order to use a hexadecimal escape like \c
+ {\xHHHH} with more than 2 digits. A pattern like \c {\x2022} needs
+ to be ported to \c {\x{2022}}, or it will match a space \c {(0x20)}
+ followed by the string \c {"22"}. In general, it is highly recommended
+ to always use curly braces with the \c {\x} escape, no matter the
+ amount of digits specified.
+
+ \li A \c{0-to-n} quantification like \c {{,n}} needs to be ported to
+ \c {{0,n}} to preserve semantics. Otherwise, a pattern such as
+ \c {\d{,3}} would actually match a digit followed by the exact
+ string \c {"{,3}"}.
+ \endlist
+
+ \section3 Partial Matching
+
+ When using \c QRegExp::exactMatch(), if an exact match was not found, one
+ could still find out how much of the subject string was matched by the
+ regular expression by calling \c QRegExp::matchedLength(). If the returned
+ length was equal to the subject string's length, then one could conclude
+ that a partial match was found.
+ \l QRegularExpression supports partial matching explicitly by means of the
+ appropriate \l {QRegularExpression::MatchType}.
+
+ \section3 Global matching
+
+ Due to limitations of the \c QRegExp API it was impossible to implement
+ global matching correctly (that is, like Perl does). In particular, patterns
+ that can match zero characters (like "a*") are problematic. \l
+ {QRegularExpression::wildcardToRegularExpression} implements Perl global
+ match correctly, and the returned iterator can be used to examine each
+ result.
+
+ \section3 Unicode properties support
+
+ When using \c QRegExp, character classes such as \c{\w}, \c{\d}, etc. match
+ characters with the corresponding Unicode property: for instance, \c{\d}
+ matches any character with the Unicode Nd (decimal digit) property. Those
+ character classes only match ASCII characters by default. When using \l
+ QRegularExpression: for instance, \c{\d} matches exactly a character in the
+ 0-9 ASCII range. It is possible to change this behavior by using the \l
+ {QRegularExpression::UseUnicodePropertiesOption}
+ pattern option.
+
+ \section2 QRegExp
+
+ In Qt6 \l QRegExp got removed from Qt Core. If your application cannot be
+ ported right now, \c QRegExp still exists in Qt5Compat to keep these
+ code-bases working. If you want to use \c QRegExp further, you need to link
+ against the new Qt5Compat module and add this line to your \l qmake \c .pro
+ file:
+ \code
+ QT += core5compat
+ \endcode
+
+ In case you already ported your application or library to the
+ \l {Build with CMake}{cmake} build system, add the following to your
+ \c CMakeList.txt:
+ \code
+ PUBLIC_LIBRARIES
+ Qt::Core5Compat
+ \endcode
+
+ \section2 QEvent and subclasses
+
+ The QEvent class defined a copy constructor and an assignment operator,
+ in spite of being a polymorphic class. Copying classes with virtual methods
+ can result in slicing when assigning objects from different classes to each
+ other. Since copying and assigning often happens implicilty, this could
+ lead to hard-to-debug problems.
+
+ In Qt 6, the copy constructor and assignment operator for QEvent subclasses
+ have been made protected to prevent implicit copying. If you need to copy
+ events, use the \l{QEvent::}{clone} method, which will return a heap-allocated
+ copy of the QEvent object. Make sure you delete the clone, perhaps using
+ std::unique_ptr, unless you post it (in which case Qt will delete it once it
+ has been delivered).
+
+ In your QEvent subclasses, override clone(), and declare the protected and
+ default-implemented copy constructor and assignment operator like this:
+
+ \code
+ class MyEvent : public QEvent
+ {
+ public:
+ // ...
+
+ MyEvent *clone() const override { return new MyEvent(*this); }
+
+ protected:
+ MyEvent(const MyEvent &other) = default;
+ MyEvent &operator=(const MyEvent &other) = default;
+ MyEvent(MyEvent &&) = delete;
+ MyEvent &operator=(MyEvent &&) = delete;
+ // member data
+ };
+ \endcode
+
+ Note that if your MyEvent class allocates memory (e.g. through a
+ pointer-to-implementation pattern), then you will have to implement
+ custom copy semantics.
*/
diff --git a/src/corelib/doc/src/qtcore-index.qdoc b/src/corelib/doc/src/qtcore-index.qdoc
index f904cd774f..c74f173562 100644
--- a/src/corelib/doc/src/qtcore-index.qdoc
+++ b/src/corelib/doc/src/qtcore-index.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -31,9 +31,8 @@
\brief The Qt Core module is part of Qt's essential modules.
- \section1 Core Functionalities
- Qt Core adds these features to C++:
+ The Qt Core module adds these features to C++:
\list
\li a very powerful mechanism for seamless object communication called
@@ -56,11 +55,11 @@
\include module-use.qdocinc using qt module
\quotefile overview/using-qt-core.cmake
- See also the \l[QtDoc]{Build with CMake} overview.
+ See also the \l {Build with CMake} overview.
\section2 Building with qmake
- If you use \l qmake to build your projects, Qt5Core is linked by default.
+ If you use \l qmake to build your projects, Qt6Core is linked by default.
\section1 Threading and Concurrent Programming
@@ -97,14 +96,13 @@
\list
\li \l{The Animation Framework}
\li \l{JSON Support in Qt}
- \li \l{The State Machine Framework}
\li \l{How to Create Qt Plugins}
\li \l{The Event System}
\endlist
\section1 Module Evolution
- \l{Porting to Qt 6 - Qt Core} lists important changes in the module API
+ \l{Changes to Qt Core} lists important changes in the module API
and functionality that were done for the Qt 6 series of Qt.
\section1 Licenses and Attributions
@@ -116,7 +114,7 @@
See \l{Qt Licensing} for further details.
Executables on Windows potentially link
- against \l{The qtmain Library}. This library is available
+ against \l{The QtEntryPoint Library}. This library is available
under commercial licenses and also under the
\l{BSD 3-clause "New" or "Revised" License}.
@@ -135,7 +133,6 @@
\li \l{Container Classes}
\li \l{Plugin Classes}
\li \l{Implicitly Shared Classes}
- \li \l{State Machine Classes}
\li \l{Input/Output and Networking}{Input/Output Classes}
\li \l{Event Classes}
\endlist
diff --git a/src/corelib/doc/src/qtcore.qdoc b/src/corelib/doc/src/qtcore.qdoc
index 70b14e755a..483f39b77a 100644
--- a/src/corelib/doc/src/qtcore.qdoc
+++ b/src/corelib/doc/src/qtcore.qdoc
@@ -35,4 +35,6 @@
\brief Provides core non-GUI functionality.
All other Qt modules rely on this module.
+
+ The \l{Qt Core} page contains information about how to use the module.
*/
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index a556f91218..14067f638a 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -5,10 +5,10 @@ HEADERS += \
global/qoperatingsystemversion.h \
global/qoperatingsystemversion_p.h \
global/qsystemdetection.h \
+ global/qcompare.h \
global/qcompilerdetection.h \
global/qcontainerinfo.h \
global/qprocessordetection.h \
- global/qmemory_p.h \
global/qnamespace.h \
global/qendian.h \
global/qendian_p.h \
@@ -20,7 +20,6 @@ HEADERS += \
global/qlogging.h \
global/qtypeinfo.h \
global/qsysinfo.h \
- global/qisenum.h \
global/qsimd.h \
global/qsimd_p.h \
global/qflags.h \
diff --git a/src/corelib/global/qcompare.h b/src/corelib/global/qcompare.h
new file mode 100644
index 0000000000..07f4589984
--- /dev/null
+++ b/src/corelib/global/qcompare.h
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOMPARE_H
+#define QCOMPARE_H
+
+#if 0
+#pragma qt_class(QtCompare)
+#endif
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtPrivate {
+using CompareUnderlyingType = qint8;
+
+// [cmp.categories.pre] / 1
+enum class Ordering : CompareUnderlyingType
+{
+ Equal = 0,
+ Equivalent = Equal,
+ Less = -1,
+ Greater = 1
+};
+
+enum class Uncomparable : CompareUnderlyingType
+{
+ Unordered = -127
+};
+
+// [cmp.categories.pre] / 3, but using a safe bool trick
+// and also rejecting std::nullptr_t (unlike the example)
+class CompareAgainstLiteralZero {
+public:
+ using SafeZero = void (CompareAgainstLiteralZero::*)();
+ Q_IMPLICIT constexpr CompareAgainstLiteralZero(SafeZero) noexcept {}
+
+ template <typename T, std::enable_if_t<!std::is_same_v<T, int>, bool> = false>
+ CompareAgainstLiteralZero(T) = delete;
+};
+} // namespace QtPrivate
+
+// [cmp.partialord]
+class QPartialOrdering
+{
+public:
+ static const QPartialOrdering Less;
+ static const QPartialOrdering Equivalent;
+ static const QPartialOrdering Greater;
+ static const QPartialOrdering Unordered;
+
+ friend constexpr bool operator==(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+ { return p.isOrdered() && p.m_order == 0; }
+ friend constexpr bool operator!=(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+ { return p.isOrdered() && p.m_order != 0; }
+ friend constexpr bool operator< (QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+ { return p.isOrdered() && p.m_order < 0; }
+ friend constexpr bool operator<=(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+ { return p.isOrdered() && p.m_order <= 0; }
+ friend constexpr bool operator> (QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+ { return p.isOrdered() && p.m_order > 0; }
+ friend constexpr bool operator>=(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+ { return p.isOrdered() && p.m_order >= 0; }
+
+ friend constexpr bool operator==(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ { return p.isOrdered() && 0 == p.m_order; }
+ friend constexpr bool operator!=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ { return p.isOrdered() && 0 != p.m_order; }
+ friend constexpr bool operator< (QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ { return p.isOrdered() && 0 < p.m_order; }
+ friend constexpr bool operator<=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ { return p.isOrdered() && 0 <= p.m_order; }
+ friend constexpr bool operator> (QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ { return p.isOrdered() && 0 > p.m_order; }
+ friend constexpr bool operator>=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ { return p.isOrdered() && 0 >= p.m_order; }
+
+ friend constexpr bool operator==(QPartialOrdering p1, QPartialOrdering p2) noexcept
+ { return p1.m_order == p2.m_order; }
+ friend constexpr bool operator!=(QPartialOrdering p1, QPartialOrdering p2) noexcept
+ { return p1.m_order != p2.m_order; }
+
+private:
+ constexpr explicit QPartialOrdering(QtPrivate::Ordering order) noexcept
+ : m_order(static_cast<QtPrivate::CompareUnderlyingType>(order))
+ {}
+ constexpr explicit QPartialOrdering(QtPrivate::Uncomparable order) noexcept
+ : m_order(static_cast<QtPrivate::CompareUnderlyingType>(order))
+ {}
+
+ // instead of the exposition only is_ordered member in [cmp.partialord],
+ // use a private function
+ constexpr bool isOrdered() noexcept
+ { return m_order != static_cast<QtPrivate::CompareUnderlyingType>(QtPrivate::Uncomparable::Unordered); }
+
+ QtPrivate::CompareUnderlyingType m_order;
+};
+
+inline constexpr QPartialOrdering QPartialOrdering::Less(QtPrivate::Ordering::Less);
+inline constexpr QPartialOrdering QPartialOrdering::Equivalent(QtPrivate::Ordering::Equivalent);
+inline constexpr QPartialOrdering QPartialOrdering::Greater(QtPrivate::Ordering::Greater);
+inline constexpr QPartialOrdering QPartialOrdering::Unordered(QtPrivate::Uncomparable::Unordered);
+
+QT_END_NAMESPACE
+
+#endif // QCOMPARE_H
diff --git a/src/corelib/global/qcompare.qdoc b/src/corelib/global/qcompare.qdoc
new file mode 100644
index 0000000000..795e908ecf
--- /dev/null
+++ b/src/corelib/global/qcompare.qdoc
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU 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: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QPartialOrdering
+ \inmodule QtCore
+ \brief QPartialOrdering represents the result of a comparison that allows for unordered results.
+ \since 6.0
+
+ A value of type QPartialOrdering is typically returned from a
+ three-way comparison function. Such a function compares two
+ objects, and it may either establish that the two objects are
+ ordered relative to each other, or that they are not ordered. The
+ QPartialOrdering value returned from the comparison function
+ represents one of those possibilities.
+
+ The possible values of type QPartialOrdering are, in fact, fully
+ represented by the following four static values:
+
+ \list
+
+ \li \c QPartialOrdering::Less represents that the first object is
+ less than the second;
+
+ \li \c QPartialOrdering::Equivalent represents that the first
+ object is equivalent to the second;
+
+ \li \c QPartialOrdering::Greater represents that the first object
+ is equivalent to the second;
+
+ \li \c QPartialOrdering::Unordered represents that the first object
+ is \e{not ordered} with respect to the second.
+
+ \endlist
+
+ QPartialOrdering is idiomatically used by comparing an instance
+ against a literal zero, for instance like this:
+
+ \code
+
+ // given a, b, c, d as objects of some type that allows for a 3-way compare
+
+ QPartialOrdering result = a.compare(b);
+ if (result < 0) {
+ // a is less than b
+ }
+
+ if (c.compare(d) >= 0) {
+ // c is greater than or equal to d
+ }
+
+ \endcode
+
+ A QPartialOrdering value which represents an unordered result will
+ always return false when compared against literal 0.
+*/
+
+/*!
+ \fn bool QPartialOrdering::operator==(QPartialOrdering p1, QPartialOrdering p2) noexcept
+
+ Return true if \a p1 and \a p2 represent the same result;
+ otherwise, returns false.
+*/
+
+/*!
+ \fn bool QPartialOrdering::operator!=(QPartialOrdering p1, QPartialOrdering p2) noexcept
+
+ Return true if \a p1 and \a p2 represent different results;
+ otherwise, returns true.
+*/
+
+/*!
+ \fn bool operator==(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+ \fn bool operator!=(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+ \fn bool operator< (QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+ \fn bool operator<=(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+ \fn bool operator> (QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+ \fn bool operator>=(QPartialOrdering p, QtPrivate::CompareAgainstLiteralZero) noexcept
+
+ \fn bool operator==(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ \fn bool operator!=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ \fn bool operator< (QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ \fn bool operator<=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ \fn bool operator> (QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ \fn bool operator>=(QtPrivate::CompareAgainstLiteralZero, QPartialOrdering p) noexcept
+ \relates QPartialOrdering
+ \internal
+*/
+
+/*!
+ \variable QPartialOrdering::Less
+ Represents the result of a comparison where the value on the left
+ hand side is less than the value on right hand side.
+*/
+
+/*!
+ \variable QPartialOrdering::Equivalent
+ Represents the result of a comparison where the value on the left
+ hand side is equivalent to the value on right hand side.
+*/
+
+/*!
+ \variable QPartialOrdering::Greater
+ Represents the result of a comparison where the value on the left
+ hand side is greater than the value on right hand side.
+*/
+
+/*!
+ \variable QPartialOrdering::Unordered
+ Represents the result of a comparison where the value on the left
+ hand side is not ordered with respect to the value on right hand
+ side.
+*/
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index a140e78739..d1ce56fd0a 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1142,18 +1142,21 @@
# define Q_DECL_UNUSED [[maybe_unused]]
#endif
+#if __has_cpp_attribute(deprecated)
+# ifdef Q_DECL_DEPRECATED
+# undef Q_DECL_DEPRECATED
+# endif
+# ifdef Q_DECL_DEPRECATED_X
+# undef Q_DECL_DEPRECATED_X
+# endif
+# define Q_DECL_DEPRECATED [[deprecated]]
+# define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]]
+#endif
+
#if defined(__cpp_enumerator_attributes) && __cpp_enumerator_attributes >= 201411
-#if defined(Q_CC_MSVC)
-// Can't mark enum values as __declspec(deprecated) with MSVC, also can't move
-// everything to [[deprecated]] because MSVC gives a compilation error when marking
-// friend methods of a class as [[deprecated("text")]], breaking qstring.h
-# define Q_DECL_ENUMERATOR_DEPRECATED [[deprecated]]
-# define Q_DECL_ENUMERATOR_DEPRECATED_X(x) [[deprecated(x)]]
-#else
# define Q_DECL_ENUMERATOR_DEPRECATED Q_DECL_DEPRECATED
# define Q_DECL_ENUMERATOR_DEPRECATED_X(x) Q_DECL_DEPRECATED_X(x)
#endif
-#endif
/*
* Fallback macros to certain compiler features
diff --git a/src/corelib/global/qcontainerinfo.h b/src/corelib/global/qcontainerinfo.h
index e0025fcef0..21683440f8 100644
--- a/src/corelib/global/qcontainerinfo.h
+++ b/src/corelib/global/qcontainerinfo.h
@@ -45,8 +45,7 @@
QT_BEGIN_NAMESPACE
-namespace QContainerTraits
-{
+namespace QContainerInfo {
template<typename C>
using value_type = typename C::value_type;
@@ -68,189 +67,189 @@ QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-const-variable")
template<typename C, typename = void>
-constexpr bool has_value_type_v = false;
+inline constexpr bool has_value_type_v = false;
template<typename C>
-constexpr bool has_value_type_v<C, std::void_t<value_type<C>>> = true;
+inline constexpr bool has_value_type_v<C, std::void_t<value_type<C>>> = true;
template<typename C, typename = void>
-constexpr bool has_key_type_v = false;
+inline constexpr bool has_key_type_v = false;
template<typename C>
-constexpr bool has_key_type_v<C, std::void_t<key_type<C>>> = true;
+inline constexpr bool has_key_type_v<C, std::void_t<key_type<C>>> = true;
template<typename C, typename = void>
-constexpr bool has_mapped_type_v = false;
+inline constexpr bool has_mapped_type_v = false;
template<typename C>
-constexpr bool has_mapped_type_v<C, std::void_t<mapped_type<C>>> = true;
+inline constexpr bool has_mapped_type_v<C, std::void_t<mapped_type<C>>> = true;
template<typename C, typename = void>
-constexpr bool has_size_v = false;
+inline constexpr bool has_size_v = false;
template<typename C>
-constexpr bool has_size_v<C, std::void_t<decltype(C().size())>> = true;
+inline constexpr bool has_size_v<C, std::void_t<decltype(C().size())>> = true;
template<typename C, typename = void>
-constexpr bool has_clear_v = false;
+inline constexpr bool has_clear_v = false;
template<typename C>
-constexpr bool has_clear_v<C, std::void_t<decltype(C().clear())>> = true;
+inline constexpr bool has_clear_v<C, std::void_t<decltype(C().clear())>> = true;
template<typename, typename = void>
-constexpr bool has_at_index_v = false;
+inline constexpr bool has_at_index_v = false;
template<typename C>
-constexpr bool has_at_index_v<C, std::void_t<decltype(C().at(0))>> = true;
+inline constexpr bool has_at_index_v<C, std::void_t<decltype(C().at(0))>> = true;
template<typename, typename = void>
-constexpr bool has_at_key_v = false;
+inline constexpr bool has_at_key_v = false;
template<typename C>
-constexpr bool has_at_key_v<C, std::void_t<decltype(C().at(key_type<C>()))>> = true;
+inline constexpr bool has_at_key_v<C, std::void_t<decltype(C().at(key_type<C>()))>> = true;
template<typename, typename = void>
-constexpr bool can_get_at_index_v = false;
+inline constexpr bool can_get_at_index_v = false;
template<typename C>
-constexpr bool can_get_at_index_v<C, std::void_t<value_type<C>(decltype(C()[0]))>> = true;
+inline constexpr bool can_get_at_index_v<C, std::void_t<value_type<C>(decltype(C()[0]))>> = true;
template<typename, typename = void>
-constexpr bool can_set_at_index_v = false;
+inline constexpr bool can_set_at_index_v = false;
template<typename C>
-constexpr bool can_set_at_index_v<C, std::void_t<decltype(C()[0] = value_type<C>())>> = true;
+inline constexpr bool can_set_at_index_v<C, std::void_t<decltype(C()[0] = value_type<C>())>> = true;
template<typename, typename = void>
-constexpr bool has_push_front_v = false;
+inline constexpr bool has_push_front_v = false;
template<typename C>
-constexpr bool has_push_front_v<C, std::void_t<decltype(C().push_front(value_type<C>()))>> = true;
+inline constexpr bool has_push_front_v<C, std::void_t<decltype(C().push_front(value_type<C>()))>> = true;
template<typename, typename = void>
-constexpr bool has_push_back_v = false;
+inline constexpr bool has_push_back_v = false;
template<typename C>
-constexpr bool has_push_back_v<C, std::void_t<decltype(C().push_back(value_type<C>()))>> = true;
+inline constexpr bool has_push_back_v<C, std::void_t<decltype(C().push_back(value_type<C>()))>> = true;
template<typename, typename = void>
-constexpr bool has_insert_v = false;
+inline constexpr bool has_insert_v = false;
template<typename C>
-constexpr bool has_insert_v<C, std::void_t<decltype(C().insert(value_type<C>()))>> = true;
+inline constexpr bool has_insert_v<C, std::void_t<decltype(C().insert(value_type<C>()))>> = true;
template<typename, typename = void>
-constexpr bool has_pop_front_v = false;
+inline constexpr bool has_pop_front_v = false;
template<typename C>
-constexpr bool has_pop_front_v<C, std::void_t<decltype(C().pop_front())>> = true;
+inline constexpr bool has_pop_front_v<C, std::void_t<decltype(C().pop_front())>> = true;
template<typename, typename = void>
-constexpr bool has_pop_back_v = false;
+inline constexpr bool has_pop_back_v = false;
template<typename C>
-constexpr bool has_pop_back_v<C, std::void_t<decltype(C().pop_back())>> = true;
+inline constexpr bool has_pop_back_v<C, std::void_t<decltype(C().pop_back())>> = true;
template<typename, typename = void>
-constexpr bool has_iterator_v = false;
+inline constexpr bool has_iterator_v = false;
template<typename C>
-constexpr bool has_iterator_v<C, std::void_t<iterator<C>>> = true;
+inline constexpr bool has_iterator_v<C, std::void_t<iterator<C>>> = true;
template<typename, typename = void>
-constexpr bool has_const_iterator_v = false;
+inline constexpr bool has_const_iterator_v = false;
template<typename C>
-constexpr bool has_const_iterator_v<C, std::void_t<const_iterator<C>>> = true;
+inline constexpr bool has_const_iterator_v<C, std::void_t<const_iterator<C>>> = true;
template<typename, typename = void>
-constexpr bool can_set_value_at_iterator_v = false;
+inline constexpr bool can_set_value_at_iterator_v = false;
template<typename C>
-constexpr bool can_set_value_at_iterator_v<C, std::void_t<decltype(*C().begin() = value_type<C>())>> = true;
+inline constexpr bool can_set_value_at_iterator_v<C, std::void_t<decltype(*C().begin() = value_type<C>())>> = true;
template<typename, typename = void>
-constexpr bool can_set_mapped_at_iterator_v = false;
+inline constexpr bool can_set_mapped_at_iterator_v = false;
template<typename C>
-constexpr bool can_set_mapped_at_iterator_v<C, std::void_t<decltype(*C().begin() = mapped_type<C>())>> = true;
+inline constexpr bool can_set_mapped_at_iterator_v<C, std::void_t<decltype(*C().begin() = mapped_type<C>())>> = true;
template<typename, typename = void>
-constexpr bool can_insert_value_at_iterator_v = false;
+inline constexpr bool can_insert_value_at_iterator_v = false;
template<typename C>
-constexpr bool can_insert_value_at_iterator_v<C, std::void_t<decltype(C().insert(C().begin(), value_type<C>()))>> = true;
+inline constexpr bool can_insert_value_at_iterator_v<C, std::void_t<decltype(C().insert(C().begin(), value_type<C>()))>> = true;
template<typename, typename = void>
-constexpr bool can_erase_at_iterator_v = false;
+inline constexpr bool can_erase_at_iterator_v = false;
template<typename C>
-constexpr bool can_erase_at_iterator_v<C, std::void_t<decltype(C().erase(C().begin()))>> = true;
+inline constexpr bool can_erase_at_iterator_v<C, std::void_t<decltype(C().erase(C().begin()))>> = true;
template<typename, typename = void>
-constexpr bool can_erase_range_at_iterator_v = false;
+inline constexpr bool can_erase_range_at_iterator_v = false;
template<typename C>
-constexpr bool can_erase_range_at_iterator_v<C, std::void_t<decltype(C().erase(C().begin(), C().end()))>> = true;
+inline constexpr bool can_erase_range_at_iterator_v<C, std::void_t<decltype(C().erase(C().begin(), C().end()))>> = true;
template<typename, typename = void>
-constexpr bool can_get_at_key_v = false;
+inline constexpr bool can_get_at_key_v = false;
template<typename C>
-constexpr bool can_get_at_key_v<C, std::void_t<mapped_type<C>(decltype(C()[key_type<C>()]))>> = true;
+inline constexpr bool can_get_at_key_v<C, std::void_t<mapped_type<C>(decltype(C()[key_type<C>()]))>> = true;
template<typename, typename = void>
-constexpr bool can_set_at_key_v = false;
+inline constexpr bool can_set_at_key_v = false;
template<typename C>
-constexpr bool can_set_at_key_v<C, std::void_t<decltype(C()[key_type<C>()] = mapped_type<C>())>> = true;
+inline constexpr bool can_set_at_key_v<C, std::void_t<decltype(C()[key_type<C>()] = mapped_type<C>())>> = true;
template<typename, typename = void>
-constexpr bool can_erase_at_key_v = false;
+inline constexpr bool can_erase_at_key_v = false;
template<typename C>
-constexpr bool can_erase_at_key_v<C, std::void_t<decltype(C().erase(key_type<C>()))>> = true;
+inline constexpr bool can_erase_at_key_v<C, std::void_t<decltype(C().erase(key_type<C>()))>> = true;
template<typename, typename = void>
-constexpr bool can_remove_at_key_v = false;
+inline constexpr bool can_remove_at_key_v = false;
template<typename C>
-constexpr bool can_remove_at_key_v<C, std::void_t<decltype(C().remove(key_type<C>()))>> = true;
+inline constexpr bool can_remove_at_key_v<C, std::void_t<decltype(C().remove(key_type<C>()))>> = true;
template<typename, typename = void>
-constexpr bool can_insert_key_v = false;
+inline constexpr bool can_insert_key_v = false;
template<typename C>
-constexpr bool can_insert_key_v<C, std::void_t<decltype(C().insert(key_type<C>()))>> = true;
+inline constexpr bool can_insert_key_v<C, std::void_t<decltype(C().insert(key_type<C>()))>> = true;
template<typename, typename = void>
-constexpr bool can_insert_pair_v = false;
+inline constexpr bool can_insert_pair_v = false;
template<typename C>
-constexpr bool can_insert_pair_v<C, std::void_t<decltype(C().insert({key_type<C>(), mapped_type<C>()}))>> = true;
+inline constexpr bool can_insert_pair_v<C, std::void_t<decltype(C().insert({key_type<C>(), mapped_type<C>()}))>> = true;
template<typename, typename = void>
-constexpr bool can_insert_key_mapped_v = false;
+inline constexpr bool can_insert_key_mapped_v = false;
template<typename C>
-constexpr bool can_insert_key_mapped_v<C, std::void_t<decltype(C().insert(key_type<C>(), mapped_type<C>()))>> = true;
+inline constexpr bool can_insert_key_mapped_v<C, std::void_t<decltype(C().insert(key_type<C>(), mapped_type<C>()))>> = true;
template<typename, typename = void>
-constexpr bool has_contains_v = false;
+inline constexpr bool has_contains_v = false;
template<typename C>
-constexpr bool has_contains_v<C, std::void_t<decltype(bool(C().contains(key_type<C>())))>> = true;
+inline constexpr bool has_contains_v<C, std::void_t<decltype(bool(C().contains(key_type<C>())))>> = true;
template<typename, typename = void>
-constexpr bool has_find_v = false;
+inline constexpr bool has_find_v = false;
template<typename C>
-constexpr bool has_find_v<C, std::void_t<decltype(C().find(key_type<C>()))>> = true;
+inline constexpr bool has_find_v<C, std::void_t<decltype(C().find(key_type<C>()))>> = true;
template<typename, typename = void>
-constexpr bool iterator_dereferences_to_value_v = false;
+inline constexpr bool iterator_dereferences_to_value_v = false;
template<typename C>
-constexpr bool iterator_dereferences_to_value_v<C, std::void_t<decltype(value_type<C>(*C().begin()))>> = true;
+inline constexpr bool iterator_dereferences_to_value_v<C, std::void_t<decltype(value_type<C>(*C().begin()))>> = true;
template<typename, typename = void>
-constexpr bool iterator_has_key_v = false;
+inline constexpr bool iterator_has_key_v = false;
template<typename C>
-constexpr bool iterator_has_key_v<C, std::void_t<decltype(key_type<C>(C().begin().key()))>> = true;
+inline constexpr bool iterator_has_key_v<C, std::void_t<decltype(key_type<C>(C().begin().key()))>> = true;
template<typename, typename = void>
-constexpr bool value_type_has_first_v = false;
+inline constexpr bool value_type_has_first_v = false;
template<typename C>
-constexpr bool value_type_has_first_v<C, std::void_t<decltype(key_type<C>(value_type<C>().first))>> = true;
+inline constexpr bool value_type_has_first_v<C, std::void_t<decltype(key_type<C>(value_type<C>().first))>> = true;
template<typename, typename = void>
-constexpr bool iterator_dereferences_to_key_v = false;
+inline constexpr bool iterator_dereferences_to_key_v = false;
template<typename C>
-constexpr bool iterator_dereferences_to_key_v<C, std::void_t<decltype(key_type<C>(*C().begin()))>> = true;
+inline constexpr bool iterator_dereferences_to_key_v<C, std::void_t<decltype(key_type<C>(*C().begin()))>> = true;
template<typename, typename = void>
-constexpr bool iterator_has_value_v = false;
+inline constexpr bool iterator_has_value_v = false;
template<typename C>
-constexpr bool iterator_has_value_v<C, std::void_t<decltype(mapped_type<C>(C().begin().value()))>> = true;
+inline constexpr bool iterator_has_value_v<C, std::void_t<decltype(mapped_type<C>(C().begin().value()))>> = true;
template<typename, typename = void>
-constexpr bool value_type_has_second_v = false;
+inline constexpr bool value_type_has_second_v = false;
template<typename C>
-constexpr bool value_type_has_second_v<C, std::void_t<decltype(mapped_type<C>(value_type<C>().second))>> = true;
+inline constexpr bool value_type_has_second_v<C, std::void_t<decltype(mapped_type<C>(value_type<C>().second))>> = true;
template<typename, typename = void>
-constexpr bool iterator_dereferences_to_mapped_v = false;
+inline constexpr bool iterator_dereferences_to_mapped_v = false;
template<typename C>
-constexpr bool iterator_dereferences_to_mapped_v<C, std::void_t<decltype(mapped_type<C>(*C().begin()))>> = true;
+inline constexpr bool iterator_dereferences_to_mapped_v<C, std::void_t<decltype(mapped_type<C>(*C().begin()))>> = true;
QT_WARNING_POP
diff --git a/src/corelib/global/qendian.cpp b/src/corelib/global/qendian.cpp
index c69572cccf..cc9158e34d 100644
--- a/src/corelib/global/qendian.cpp
+++ b/src/corelib/global/qendian.cpp
@@ -815,7 +815,7 @@ size_t simdSwapLoop(const uchar *src, size_t bytes, uchar *dst) noexcept
size_t i = sseSwapLoop(src, bytes, dst, shuffleMaskPtr);
// epilogue
- for (size_t _i = 0 ; i < bytes && _i < sizeof(__m128i); i += sizeof(T), _i += sizeof(T))
+ for (size_t _i = 0; i < bytes && _i < sizeof(__m128i); i += sizeof(T), _i += sizeof(T))
qbswap(qFromUnaligned<T>(src + i), dst + i);
// return the total, so the bswapLoop below does nothing
@@ -886,12 +886,13 @@ void *bswapLoop(const uchar *src, size_t n, uchar *dst) noexcept
size_t i = simdSwapLoop<T>(src, n, dst);
- for ( ; i < n; i += sizeof(T))
+ for (; i < n; i += sizeof(T))
qbswap(qFromUnaligned<T>(src + i), dst + i);
return dst + i;
}
-template <> void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcept
+template<>
+void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcept
{
const uchar *src = reinterpret_cast<const uchar *>(source);
uchar *dst = reinterpret_cast<uchar *>(dest);
@@ -899,7 +900,8 @@ template <> void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcep
return bswapLoop<quint16>(src, n << 1, dst);
}
-template <> void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcept
+template<>
+void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcept
{
const uchar *src = reinterpret_cast<const uchar *>(source);
uchar *dst = reinterpret_cast<uchar *>(dest);
@@ -907,7 +909,8 @@ template <> void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcep
return bswapLoop<quint32>(src, n << 2, dst);
}
-template <> void *qbswap<8>(const void *source, qsizetype n, void *dest) noexcept
+template<>
+void *qbswap<8>(const void *source, qsizetype n, void *dest) noexcept
{
const uchar *src = reinterpret_cast<const uchar *>(source);
uchar *dst = reinterpret_cast<uchar *>(dest);
diff --git a/src/corelib/global/qendian_p.h b/src/corelib/global/qendian_p.h
index d0d79d4ce4..bc6194fb06 100644
--- a/src/corelib/global/qendian_p.h
+++ b/src/corelib/global/qendian_p.h
@@ -73,12 +73,12 @@ public:
// FIXME: val is public until qtdeclarative is fixed to not access it directly.
UT val;
- QSpecialIntegerBitfield &operator =(T t)
+ QSpecialIntegerBitfield &operator=(T t)
{
UT i = S::fromSpecial(val);
i &= ~mask();
i |= (UT(t) << pos) & mask();
- val = S::toSpecial(i);
+ val = S::toSpecial(i);
return *this;
}
operator T() const
@@ -93,32 +93,26 @@ public:
return (S::fromSpecial(val) & mask()) >> pos;
}
- bool operator !() const { return !(val & S::toSpecial(mask())); }
- bool operator ==(QSpecialIntegerBitfield<S, pos, width> i) const
- { return ((val ^ i.val) & S::toSpecial(mask())) == 0; }
- bool operator !=(QSpecialIntegerBitfield<S, pos, width> i) const
- { return ((val ^ i.val) & S::toSpecial(mask())) != 0; }
+ bool operator!() const { return !(val & S::toSpecial(mask())); }
+ bool operator==(QSpecialIntegerBitfield<S, pos, width> i) const
+ {
+ return ((val ^ i.val) & S::toSpecial(mask())) == 0;
+ }
+ bool operator!=(QSpecialIntegerBitfield<S, pos, width> i) const
+ {
+ return ((val ^ i.val) & S::toSpecial(mask())) != 0;
+ }
- QSpecialIntegerBitfield &operator +=(T i)
- { return (*this = (T(*this) + i)); }
- QSpecialIntegerBitfield &operator -=(T i)
- { return (*this = (T(*this) - i)); }
- QSpecialIntegerBitfield &operator *=(T i)
- { return (*this = (T(*this) * i)); }
- QSpecialIntegerBitfield &operator /=(T i)
- { return (*this = (T(*this) / i)); }
- QSpecialIntegerBitfield &operator %=(T i)
- { return (*this = (T(*this) % i)); }
- QSpecialIntegerBitfield &operator |=(T i)
- { return (*this = (T(*this) | i)); }
- QSpecialIntegerBitfield &operator &=(T i)
- { return (*this = (T(*this) & i)); }
- QSpecialIntegerBitfield &operator ^=(T i)
- { return (*this = (T(*this) ^ i)); }
- QSpecialIntegerBitfield &operator >>=(T i)
- { return (*this = (T(*this) >> i)); }
- QSpecialIntegerBitfield &operator <<=(T i)
- { return (*this = (T(*this) << i)); }
+ QSpecialIntegerBitfield &operator+=(T i) { return (*this = (T(*this) + i)); }
+ QSpecialIntegerBitfield &operator-=(T i) { return (*this = (T(*this) - i)); }
+ QSpecialIntegerBitfield &operator*=(T i) { return (*this = (T(*this) * i)); }
+ QSpecialIntegerBitfield &operator/=(T i) { return (*this = (T(*this) / i)); }
+ QSpecialIntegerBitfield &operator%=(T i) { return (*this = (T(*this) % i)); }
+ QSpecialIntegerBitfield &operator|=(T i) { return (*this = (T(*this) | i)); }
+ QSpecialIntegerBitfield &operator&=(T i) { return (*this = (T(*this) & i)); }
+ QSpecialIntegerBitfield &operator^=(T i) { return (*this = (T(*this) ^ i)); }
+ QSpecialIntegerBitfield &operator>>=(T i) { return (*this = (T(*this) >> i)); }
+ QSpecialIntegerBitfield &operator<<=(T i) { return (*this = (T(*this) << i)); }
};
template<typename T, int pos, int width>
@@ -136,7 +130,6 @@ using qint32_be_bitfield = QBEIntegerBitfield<int, pos, width>;
template<int pos, int width>
using quint32_be_bitfield = QBEIntegerBitfield<uint, pos, width>;
-
QT_END_NAMESPACE
#endif // QENDIAN_P_H
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index e576128bce..94d9e45acb 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -89,14 +89,10 @@ template<typename Enum>
class QFlags
{
static_assert((sizeof(Enum) <= sizeof(int)),
- "QFlags uses an int as storage, so an enum with underlying "
- "long long will overflow.");
+ "QFlags uses an int as storage, so an enum with underlying "
+ "long long will overflow.");
static_assert((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types.");
-#if QT_DEPRECATED_SINCE(5,15)
- struct Private;
- typedef int (Private::*Zero);
-#endif
public:
#if defined(Q_CC_MSVC) || defined(Q_CLANG_QDOC)
// see above for MSVC
@@ -117,9 +113,6 @@ public:
#endif
constexpr inline QFlags() noexcept : i(0) {}
constexpr inline QFlags(Enum flags) noexcept : i(Int(flags)) {}
-#if QT_DEPRECATED_SINCE(5,15)
- QT_DEPRECATED_X("Use default constructor instead") constexpr inline QFlags(Zero) noexcept : i(0) {}
-#endif
constexpr inline QFlags(QFlag flag) noexcept : i(flag) {}
constexpr inline QFlags(std::initializer_list<Enum> flags) noexcept
diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp
index c97331748b..7dd2f7b331 100644
--- a/src/corelib/global/qfloat16.cpp
+++ b/src/corelib/global/qfloat16.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2016 by Southwest Research Institute (R)
** Contact: http://www.qt-project.org/legal
**
@@ -73,43 +73,27 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \macro QT_NO_FLOAT16_OPERATORS
- \relates qfloat16
- \since 5.12.4
-
- Defining this macro disables the arithmetic operators for qfloat16.
-
- This is only necessary on Visual Studio 2017 (and earlier) when including
- \c {<QFloat16>} and \c{<bitset>} in the same translation unit, which would
- otherwise cause a compilation error due to a toolchain bug (see
- [QTBUG-72073]).
-*/
-
-/*!
\fn bool qIsInf(qfloat16 f)
\relates qfloat16
+ \overload qIsInf(float)
Returns true if the \c qfloat16 \a {f} is equivalent to infinity.
-
- \sa qIsInf
*/
/*!
\fn bool qIsNaN(qfloat16 f)
\relates qfloat16
+ \overload qIsNaN(float)
Returns true if the \c qfloat16 \a {f} is not a number (NaN).
-
- \sa qIsNaN
*/
/*!
\fn bool qIsFinite(qfloat16 f)
\relates qfloat16
+ \overload qIsFinite(float)
Returns true if the \c qfloat16 \a {f} is a finite number.
-
- \sa qIsFinite
*/
/*!
@@ -118,8 +102,6 @@ QT_BEGIN_NAMESPACE
\fn bool qfloat16::isInf() const noexcept
Tests whether this \c qfloat16 value is an infinity.
-
- \sa qIsInf()
*/
/*!
@@ -128,8 +110,6 @@ QT_BEGIN_NAMESPACE
\fn bool qfloat16::isNaN() const noexcept
Tests whether this \c qfloat16 value is "not a number".
-
- \sa qIsNaN()
*/
/*!
@@ -147,8 +127,6 @@ QT_BEGIN_NAMESPACE
\fn bool qfloat16::isFinite() const noexcept
Tests whether this \c qfloat16 value is finite.
-
- \sa qIsFinite()
*/
/*!
@@ -160,11 +138,18 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn int qFpClassify(qfloat16 val)
+ \relates qfloat16
+ \since 5.14
+ \overload qFpClassify(float)
+
+ Returns the floating-point class of \a val.
+*/
+
+/*!
\internal
\since 5.14
Implements qFpClassify() for qfloat16.
-
- \sa qFpClassify()
*/
int qfloat16::fpClassify() const noexcept
{
@@ -174,22 +159,21 @@ int qfloat16::fpClassify() const noexcept
/*! \fn int qRound(qfloat16 value)
\relates qfloat16
+ \overload qRound(float)
Rounds \a value to the nearest integer.
-
- \sa qRound
*/
/*! \fn qint64 qRound64(qfloat16 value)
\relates qfloat16
+ \overload qRound64(float)
Rounds \a value to the nearest 64-bit integer.
-
- \sa qRound64
*/
/*! \fn bool qFuzzyCompare(qfloat16 p1, qfloat16 p2)
\relates qfloat16
+ \overload qFuzzyCompare(float, float)
Compares the floating point value \a p1 and \a p2 and
returns \c true if they are considered equal, otherwise \c false.
diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h
index 136571bbaf..b589b68fff 100644
--- a/src/corelib/global/qfloat16.h
+++ b/src/corelib/global/qfloat16.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2016 by Southwest Research Institute (R)
** Contact: http://www.qt-project.org/legal
**
@@ -112,9 +112,91 @@ private:
Q_CORE_EXPORT static const quint32 roundtable[];
friend bool qIsNull(qfloat16 f) noexcept;
-#if !defined(QT_NO_FLOAT16_OPERATORS)
- friend qfloat16 operator-(qfloat16 a) noexcept;
-#endif
+
+ friend inline qfloat16 operator-(qfloat16 a) noexcept
+ {
+ qfloat16 f;
+ f.b16 = a.b16 ^ quint16(0x8000);
+ return f;
+ }
+
+ friend inline qfloat16 operator+(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) + static_cast<float>(b)); }
+ friend inline qfloat16 operator-(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) - static_cast<float>(b)); }
+ friend inline qfloat16 operator*(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) * static_cast<float>(b)); }
+ friend inline qfloat16 operator/(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) / static_cast<float>(b)); }
+
+#define QF16_MAKE_ARITH_OP_FP(FP, OP) \
+ friend inline FP operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast<FP>(lhs) OP rhs; } \
+ friend inline FP operator OP(FP lhs, qfloat16 rhs) noexcept { return lhs OP static_cast<FP>(rhs); }
+#define QF16_MAKE_ARITH_OP_EQ_FP(FP, OP_EQ, OP) \
+ friend inline qfloat16& operator OP_EQ(qfloat16& lhs, FP rhs) noexcept \
+ { lhs = qfloat16(float(static_cast<FP>(lhs) OP rhs)); return lhs; }
+#define QF16_MAKE_ARITH_OP(FP) \
+ QF16_MAKE_ARITH_OP_FP(FP, +) \
+ QF16_MAKE_ARITH_OP_FP(FP, -) \
+ QF16_MAKE_ARITH_OP_FP(FP, *) \
+ QF16_MAKE_ARITH_OP_FP(FP, /) \
+ QF16_MAKE_ARITH_OP_EQ_FP(FP, +=, +) \
+ QF16_MAKE_ARITH_OP_EQ_FP(FP, -=, -) \
+ QF16_MAKE_ARITH_OP_EQ_FP(FP, *=, *) \
+ QF16_MAKE_ARITH_OP_EQ_FP(FP, /=, /)
+
+ QF16_MAKE_ARITH_OP(long double)
+ QF16_MAKE_ARITH_OP(double)
+ QF16_MAKE_ARITH_OP(float)
+#undef QF16_MAKE_ARITH_OP
+#undef QF16_MAKE_ARITH_OP_FP
+
+#define QF16_MAKE_ARITH_OP_INT(OP) \
+ friend inline double operator OP(qfloat16 lhs, int rhs) noexcept { return static_cast<double>(lhs) OP rhs; } \
+ friend inline double operator OP(int lhs, qfloat16 rhs) noexcept { return lhs OP static_cast<double>(rhs); }
+
+ QF16_MAKE_ARITH_OP_INT(+)
+ QF16_MAKE_ARITH_OP_INT(-)
+ QF16_MAKE_ARITH_OP_INT(*)
+ QF16_MAKE_ARITH_OP_INT(/)
+#undef QF16_MAKE_ARITH_OP_INT
+
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_FLOAT_COMPARE
+
+ friend inline bool operator>(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) > static_cast<float>(b); }
+ friend inline bool operator<(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) < static_cast<float>(b); }
+ friend inline bool operator>=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) >= static_cast<float>(b); }
+ friend inline bool operator<=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) <= static_cast<float>(b); }
+ friend inline bool operator==(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) == static_cast<float>(b); }
+ friend inline bool operator!=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) != static_cast<float>(b); }
+
+#define QF16_MAKE_BOOL_OP_FP(FP, OP) \
+ friend inline bool operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast<FP>(lhs) OP rhs; } \
+ friend inline bool operator OP(FP lhs, qfloat16 rhs) noexcept { return lhs OP static_cast<FP>(rhs); }
+#define QF16_MAKE_BOOL_OP(FP) \
+ QF16_MAKE_BOOL_OP_FP(FP, <) \
+ QF16_MAKE_BOOL_OP_FP(FP, >) \
+ QF16_MAKE_BOOL_OP_FP(FP, >=) \
+ QF16_MAKE_BOOL_OP_FP(FP, <=) \
+ QF16_MAKE_BOOL_OP_FP(FP, ==) \
+ QF16_MAKE_BOOL_OP_FP(FP, !=)
+
+ QF16_MAKE_BOOL_OP(long double)
+ QF16_MAKE_BOOL_OP(double)
+ QF16_MAKE_BOOL_OP(float)
+#undef QF16_MAKE_BOOL_OP
+#undef QF16_MAKE_BOOL_OP_FP
+
+#define QF16_MAKE_BOOL_OP_INT(OP) \
+ friend inline bool operator OP(qfloat16 a, int b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); } \
+ friend inline bool operator OP(int a, qfloat16 b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); }
+
+ QF16_MAKE_BOOL_OP_INT(>)
+ QF16_MAKE_BOOL_OP_INT(<)
+ QF16_MAKE_BOOL_OP_INT(>=)
+ QF16_MAKE_BOOL_OP_INT(<=)
+ QF16_MAKE_BOOL_OP_INT(==)
+ QF16_MAKE_BOOL_OP_INT(!=)
+#undef QF16_MAKE_BOOL_OP_INT
+
+QT_WARNING_POP
};
Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE);
@@ -123,20 +205,20 @@ Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length)
Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length) noexcept;
// Complement qnumeric.h:
-Q_REQUIRED_RESULT inline bool qIsInf(qfloat16 f) noexcept { return f.isInf(); }
-Q_REQUIRED_RESULT inline bool qIsNaN(qfloat16 f) noexcept { return f.isNaN(); }
-Q_REQUIRED_RESULT inline bool qIsFinite(qfloat16 f) noexcept { return f.isFinite(); }
-Q_REQUIRED_RESULT inline int qFpClassify(qfloat16 f) noexcept { return f.fpClassify(); }
-// Q_REQUIRED_RESULT quint32 qFloatDistance(qfloat16 a, qfloat16 b);
+[[nodiscard]] inline bool qIsInf(qfloat16 f) noexcept { return f.isInf(); }
+[[nodiscard]] inline bool qIsNaN(qfloat16 f) noexcept { return f.isNaN(); }
+[[nodiscard]] inline bool qIsFinite(qfloat16 f) noexcept { return f.isFinite(); }
+[[nodiscard]] inline int qFpClassify(qfloat16 f) noexcept { return f.fpClassify(); }
+// [[nodiscard]] quint32 qFloatDistance(qfloat16 a, qfloat16 b);
// The remainder of these utility functions complement qglobal.h
-Q_REQUIRED_RESULT inline int qRound(qfloat16 d) noexcept
+[[nodiscard]] inline int qRound(qfloat16 d) noexcept
{ return qRound(static_cast<float>(d)); }
-Q_REQUIRED_RESULT inline qint64 qRound64(qfloat16 d) noexcept
+[[nodiscard]] inline qint64 qRound64(qfloat16 d) noexcept
{ return qRound64(static_cast<float>(d)); }
-Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
+[[nodiscard]] inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
{
float f1 = static_cast<float>(p1);
float f2 = static_cast<float>(p2);
@@ -149,7 +231,7 @@ Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
return (qAbs(f1 - f2) * 102.5f <= qMin(qAbs(f1), qAbs(f2)));
}
-Q_REQUIRED_RESULT inline bool qIsNull(qfloat16 f) noexcept
+[[nodiscard]] inline bool qIsNull(qfloat16 f) noexcept
{
return (f.b16 & static_cast<quint16>(0x7fff)) == 0;
}
@@ -215,93 +297,10 @@ inline qfloat16::operator float() const noexcept
}
#endif
-#if !defined(QT_NO_FLOAT16_OPERATORS)
-inline qfloat16 operator-(qfloat16 a) noexcept
-{
- qfloat16 f;
- f.b16 = a.b16 ^ quint16(0x8000);
- return f;
-}
-
-inline qfloat16 operator+(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) + static_cast<float>(b)); }
-inline qfloat16 operator-(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) - static_cast<float>(b)); }
-inline qfloat16 operator*(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) * static_cast<float>(b)); }
-inline qfloat16 operator/(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) / static_cast<float>(b)); }
-
-#define QF16_MAKE_ARITH_OP_FP(FP, OP) \
- inline FP operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast<FP>(lhs) OP rhs; } \
- inline FP operator OP(FP lhs, qfloat16 rhs) noexcept { return lhs OP static_cast<FP>(rhs); }
-#define QF16_MAKE_ARITH_OP_EQ_FP(FP, OP_EQ, OP) \
- inline qfloat16& operator OP_EQ(qfloat16& lhs, FP rhs) noexcept \
- { lhs = qfloat16(float(static_cast<FP>(lhs) OP rhs)); return lhs; }
-#define QF16_MAKE_ARITH_OP(FP) \
- QF16_MAKE_ARITH_OP_FP(FP, +) \
- QF16_MAKE_ARITH_OP_FP(FP, -) \
- QF16_MAKE_ARITH_OP_FP(FP, *) \
- QF16_MAKE_ARITH_OP_FP(FP, /) \
- QF16_MAKE_ARITH_OP_EQ_FP(FP, +=, +) \
- QF16_MAKE_ARITH_OP_EQ_FP(FP, -=, -) \
- QF16_MAKE_ARITH_OP_EQ_FP(FP, *=, *) \
- QF16_MAKE_ARITH_OP_EQ_FP(FP, /=, /)
-QF16_MAKE_ARITH_OP(long double)
-QF16_MAKE_ARITH_OP(double)
-QF16_MAKE_ARITH_OP(float)
-#undef QF16_MAKE_ARITH_OP
-#undef QF16_MAKE_ARITH_OP_FP
-
-#define QF16_MAKE_ARITH_OP_INT(OP) \
- inline double operator OP(qfloat16 lhs, int rhs) noexcept { return static_cast<double>(lhs) OP rhs; } \
- inline double operator OP(int lhs, qfloat16 rhs) noexcept { return lhs OP static_cast<double>(rhs); }
-QF16_MAKE_ARITH_OP_INT(+)
-QF16_MAKE_ARITH_OP_INT(-)
-QF16_MAKE_ARITH_OP_INT(*)
-QF16_MAKE_ARITH_OP_INT(/)
-#undef QF16_MAKE_ARITH_OP_INT
-
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_FLOAT_COMPARE
-
-inline bool operator>(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) > static_cast<float>(b); }
-inline bool operator<(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) < static_cast<float>(b); }
-inline bool operator>=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) >= static_cast<float>(b); }
-inline bool operator<=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) <= static_cast<float>(b); }
-inline bool operator==(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) == static_cast<float>(b); }
-inline bool operator!=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) != static_cast<float>(b); }
-
-#define QF16_MAKE_BOOL_OP_FP(FP, OP) \
- inline bool operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast<FP>(lhs) OP rhs; } \
- inline bool operator OP(FP lhs, qfloat16 rhs) noexcept { return lhs OP static_cast<FP>(rhs); }
-#define QF16_MAKE_BOOL_OP(FP) \
- QF16_MAKE_BOOL_OP_FP(FP, <) \
- QF16_MAKE_BOOL_OP_FP(FP, >) \
- QF16_MAKE_BOOL_OP_FP(FP, >=) \
- QF16_MAKE_BOOL_OP_FP(FP, <=) \
- QF16_MAKE_BOOL_OP_FP(FP, ==) \
- QF16_MAKE_BOOL_OP_FP(FP, !=)
-QF16_MAKE_BOOL_OP(long double)
-QF16_MAKE_BOOL_OP(double)
-QF16_MAKE_BOOL_OP(float)
-#undef QF16_MAKE_BOOL_OP
-#undef QF16_MAKE_BOOL_OP_FP
-
-#define QF16_MAKE_BOOL_OP_INT(OP) \
- inline bool operator OP(qfloat16 a, int b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); } \
- inline bool operator OP(int a, qfloat16 b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); }
-QF16_MAKE_BOOL_OP_INT(>)
-QF16_MAKE_BOOL_OP_INT(<)
-QF16_MAKE_BOOL_OP_INT(>=)
-QF16_MAKE_BOOL_OP_INT(<=)
-QF16_MAKE_BOOL_OP_INT(==)
-QF16_MAKE_BOOL_OP_INT(!=)
-#undef QF16_MAKE_BOOL_OP_INT
-
-QT_WARNING_POP
-#endif // QT_NO_FLOAT16_OPERATORS
-
/*!
\internal
*/
-Q_REQUIRED_RESULT inline bool qFuzzyIsNull(qfloat16 f) noexcept
+[[nodiscard]] inline bool qFuzzyIsNull(qfloat16 f) noexcept
{
return qAbs(static_cast<float>(f)) <= 0.001f;
}
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 1c55cb8f9f..ee857d61ac 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2017 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -132,6 +132,9 @@ static_assert(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorr
static_assert(sizeof(float) == 4, "Qt assumes that float is 32 bits");
static_assert(sizeof(char16_t) == 2, "Qt assumes that char16_t is 16 bits");
static_assert(sizeof(char32_t) == 4, "Qt assumes that char32_t is 32 bits");
+#if defined(Q_OS_WIN)
+static_assert(sizeof(wchar_t) == sizeof(char16_t));
+#endif
static_assert(std::numeric_limits<int>::radix == 2,
"Qt assumes binary integers");
static_assert((std::numeric_limits<int>::max() + std::numeric_limits<int>::lowest()) == -1,
@@ -318,16 +321,6 @@ static_assert((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn template <typename Enum> QFlags<Enum>::QFlags(Zero)
- \deprecated
-
- Constructs a QFlags object with no flags set. The parameter must be a
- literal 0 value.
-
- Deprecated, use default constructor instead.
-*/
-
-/*!
\fn template <typename Enum> QFlags<Enum>::QFlags(QFlag flag)
Constructs a QFlags object initialized with the integer \a flag.
@@ -975,6 +968,8 @@ static_assert((std::is_same<qsizetype, qptrdiff>::value));
Rounds half away from zero (e.g. 0.5 -> 1, -0.5 -> -1).
+ \note This function does not guarantee correctness for high precisions.
+
Example:
\snippet code/src_corelib_global_qglobal.cpp 11A
@@ -987,6 +982,8 @@ static_assert((std::is_same<qsizetype, qptrdiff>::value));
Rounds half away from zero (e.g. 0.5f -> 1, -0.5f -> -1).
+ \note This function does not guarantee correctness for high precisions.
+
Example:
\snippet code/src_corelib_global_qglobal.cpp 11B
@@ -999,6 +996,8 @@ static_assert((std::is_same<qsizetype, qptrdiff>::value));
Rounds half away from zero (e.g. 0.5 -> 1, -0.5 -> -1).
+ \note This function does not guarantee correctness for high precisions.
+
Example:
\snippet code/src_corelib_global_qglobal.cpp 12A
@@ -1011,6 +1010,8 @@ static_assert((std::is_same<qsizetype, qptrdiff>::value));
Rounds half away from zero (e.g. 0.5f -> 1, -0.5f -> -1).
+ \note This function does not guarantee correctness for high precisions.
+
Example:
\snippet code/src_corelib_global_qglobal.cpp 12B
@@ -1963,7 +1964,7 @@ QWindowsSockInit::QWindowsSockInit()
WSAData wsadata;
// IPv6 requires Winsock v2.0 or better.
- if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) {
+ if (WSAStartup(MAKEWORD(2, 0), &wsadata) != 0) {
qWarning("QTcpSocketAPI: WinSock v2.0 initialization failed.");
} else {
version = 0x20;
@@ -2095,7 +2096,7 @@ static bool readEtcFile(QUnixOSVersion &v, const char *filename,
const char *end = buffer.constEnd();
const char *eol;
QByteArray line;
- for ( ; ptr != end; ptr = eol + 1) {
+ for (; ptr != end; ptr = eol + 1) {
// find the end of the line after ptr
eol = static_cast<const char *>(memchr(ptr, '\n', end - ptr));
if (!eol)
@@ -3135,17 +3136,17 @@ void qt_assert_x(const char *where, const char *what, const char *file, int line
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION unsigned int qt_int_sqrt(unsigned int n)
{
// n must be in the range 0...UINT_MAX/2-1
- if (n >= (UINT_MAX>>2)) {
+ if (n >= (UINT_MAX >> 2)) {
unsigned int r = 2 * qt_int_sqrt(n / 4);
unsigned int r2 = r + 1;
return (n >= r2 * r2) ? r2 : r;
}
- uint h, p= 0, q= 1, r= n;
+ uint h, p = 0, q = 1, r = n;
while (q <= n)
q <<= 2;
while (q != 1) {
q >>= 2;
- h= p + q;
+ h = p + q;
p >>= 1;
if (r >= h) {
p += q;
@@ -3229,7 +3230,6 @@ QByteArray qgetenv(const char *varName)
#endif
}
-
/*!
\fn QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
\fn QString qEnvironmentVariable(const char *varName)
@@ -3459,7 +3459,7 @@ bool qEnvironmentVariableIsSet(const char *varName) noexcept
\sa qgetenv(), qEnvironmentVariable()
*/
-bool qputenv(const char *varName, const QByteArray& value)
+bool qputenv(const char *varName, const QByteArray &value)
{
const auto locker = qt_scoped_lock(environmentMutex);
#if defined(Q_CC_MSVC)
@@ -3471,7 +3471,7 @@ bool qputenv(const char *varName, const QByteArray& value)
QByteArray buffer(varName);
buffer += '=';
buffer += value;
- char* envVar = qstrdup(buffer.constData());
+ char *envVar = qstrdup(buffer.constData());
int result = putenv(envVar);
if (result != 0) // error. we have to delete the string.
delete[] envVar;
@@ -3981,13 +3981,14 @@ bool qunsetenv(const char *varName)
\list
\li \c Q_PRIMITIVE_TYPE specifies that \a Type is a POD (plain old
- data) type with no constructor or destructor, or else a type where
- every bit pattern is a valid object and memcpy() creates a valid
- independent copy of the object.
- \li \c Q_MOVABLE_TYPE specifies that \a Type has a constructor
+ data) type with no constructor or destructor, and for which memcpy()ing
+ creates a valid independent copy of the object.
+ \li \c Q_RELOCATABLE_TYPE specifies that \a Type has a constructor
and/or a destructor but can be moved in memory using \c
- memcpy(). Note: despite the name, this has nothing to do with move
- constructors or C++ move semantics.
+ memcpy().
+ \li \c Q_MOVABLE_TYPE is the same as \c Q_RELOCATABLE_TYPE. Prefer to use
+ \c Q_RELOCATABLE_TYPE in new code. Note: despite the name, this
+ has nothing to do with move constructors or C++ move semantics.
\li \c Q_COMPLEX_TYPE (the default) specifies that \a Type has
constructors and/or a destructor and that it may not be moved
in memory.
@@ -4002,16 +4003,21 @@ bool qunsetenv(const char *varName)
pattern still represents a valid object, and memcpy() can be used
to create a valid independent copy of a QUuid object.
- Example of a movable type:
+ Example of a relocatable type:
\snippet code/src_corelib_global_qglobal.cpp 39
- Qt will try to detect the class of a type using std::is_trivial or
- std::is_trivially_copyable. Use this macro to tune the behavior.
- For instance many types would be candidates for Q_MOVABLE_TYPE despite
- not being trivially-copyable. For binary compatibility reasons, QList
- optimizations are only enabled if there is an explicit
- Q_DECLARE_TYPEINFO even for trivially-copyable types.
+ Qt will try to detect the class of a type using
+ \l {https://en.cppreference.com/w/cpp/types/is_trivial} {std::is_trivial_v<T>}
+ to indentify primitive
+ types and it will require both
+ \l {https://en.cppreference.com/w/cpp/types/is_trivially_copyable} {std::is_trivially_copyable_v<T>}
+ and
+ \l {https://en.cppreference.com/w/cpp/types/is_destructible} {std::is_trivially_destructible_v<T>}
+ to identify relocatable types.
+ Use this macro to tune the behavior.
+ For instance many types would be candidates for Q_RELOCATABLE_TYPE despite
+ not being trivially-copyable.
*/
/*!
@@ -4024,7 +4030,8 @@ bool qunsetenv(const char *varName)
with meaningful parameter names in their signatures.
*/
-struct QInternal_CallBackTable {
+struct QInternal_CallBackTable
+{
QList<QList<qInternalCallback>> callbacks;
};
@@ -4046,7 +4053,7 @@ bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback)
if (unsigned(cb) < unsigned(QInternal::LastCallback)) {
if (global_callback_table.exists()) {
QInternal_CallBackTable *cbt = global_callback_table();
- return (bool) cbt->callbacks[cb].removeAll(callback);
+ return cbt->callbacks[cb].removeAll(callback) > 0;
}
}
return false;
@@ -4063,7 +4070,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
if (cbt && cb < cbt->callbacks.size()) {
QList<qInternalCallback> callbacks = cbt->callbacks[cb];
bool ret = false;
- for (int i=0; i<callbacks.size(); ++i)
+ for (int i = 0; i < callbacks.size(); ++i)
ret |= (callbacks.at(i))(parameters);
return ret;
}
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index c268d59e8f..fbadab4f3b 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -275,7 +275,7 @@ typedef double qreal;
# undef QT_DEPRECATED_VARIABLE
# define QT_DEPRECATED_VARIABLE Q_DECL_VARIABLE_DEPRECATED
# undef QT_DEPRECATED_CONSTRUCTOR
-# define QT_DEPRECATED_CONSTRUCTOR explicit Q_DECL_CONSTRUCTOR_DEPRECATED
+# define QT_DEPRECATED_CONSTRUCTOR Q_DECL_CONSTRUCTOR_DEPRECATED explicit
#else
# undef QT_DEPRECATED
# define QT_DEPRECATED
@@ -366,6 +366,14 @@ typedef double qreal;
# define QT_DEPRECATED_VERSION_6_0
#endif
+#if QT_DEPRECATED_WARNINGS_SINCE >= QT_VERSION_CHECK(6, 1, 0)
+# define QT_DEPRECATED_VERSION_X_6_1(text) QT_DEPRECATED_X(text)
+# define QT_DEPRECATED_VERSION_6_1 QT_DEPRECATED
+#else
+# define QT_DEPRECATED_VERSION_X_6_1(text)
+# define QT_DEPRECATED_VERSION_6_1
+#endif
+
#define QT_DEPRECATED_VERSION_X_5(minor, text) QT_DEPRECATED_VERSION_X_5_##minor(text)
#define QT_DEPRECATED_VERSION_X(major, minor, text) QT_DEPRECATED_VERSION_X_##major##_##minor(text)
@@ -376,7 +384,7 @@ typedef double qreal;
// A tag to help mark stuff deprecated (cf. QStringViewLiteral)
namespace QtPrivate {
enum class Deprecated_t {};
-Q_DECL_UNUSED constexpr Deprecated_t Deprecated = {};
+constexpr inline Deprecated_t Deprecated = {};
}
#endif
@@ -432,6 +440,51 @@ Q_DECL_UNUSED constexpr Deprecated_t Deprecated = {};
Q_DISABLE_MOVE(Class)
/*
+ Implementing a move assignment operator using an established
+ technique (move-and-swap, pure swap) is just boilerplate.
+ Here's a couple of *private* macros for convenience.
+
+ To know which one to use:
+
+ * if you don't have a move constructor (*) => use pure swap;
+ * if you have a move constructor, then
+ * if your class holds just memory (no file handles, no user-defined
+ datatypes, etc.) => use pure swap;
+ * use move and swap.
+
+ The preference should always go for the move-and-swap one, as it
+ will deterministically destroy the data previously held in *this,
+ and not "dump" it in the moved-from object (which may then be alive
+ for longer).
+
+ The requirement for either macro is the presence of a member swap(),
+ which any value class that defines its own special member functions
+ should have anyhow.
+
+ (*) Many value classes in Qt do not have move constructors; mostly,
+ the implicitly shared classes using QSharedDataPointer and friends.
+ The reason is mostly historical: those classes require either an
+ out-of-line move constructor, which we could not provide before we
+ made C++11 mandatory (and that we don't like anyhow), or
+ an out-of-line dtor for the Q(E)DSP<Private> member (cf. QPixmap).
+
+ If you can however add a move constructor to a class lacking it,
+ consider doing so, then reevaluate which macro to choose.
+*/
+#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(Class) \
+ Class &operator=(Class &&other) noexcept { \
+ Class moved(std::move(other)); \
+ swap(moved); \
+ return *this; \
+ }
+
+#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(Class) \
+ Class &operator=(Class &&other) noexcept { \
+ swap(other); \
+ return *this; \
+ }
+
+/*
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.
@@ -508,8 +561,8 @@ template <> struct QIntegerForSize<16> { __extension__ typedef unsigned __int
template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Signed qregisterint;
typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint;
-typedef QIntegerForSizeof<void*>::Unsigned quintptr;
-typedef QIntegerForSizeof<void*>::Signed qptrdiff;
+typedef QIntegerForSizeof<void *>::Unsigned quintptr;
+typedef QIntegerForSizeof<void *>::Signed qptrdiff;
typedef qptrdiff qintptr;
using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
@@ -566,7 +619,7 @@ using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
//defines the type for the WNDPROC on windows
//the alignment needs to be forced for sse2 to not crash with mingw
#if defined(Q_OS_WIN)
-# if defined(Q_CC_MINGW) && !defined(Q_OS_WIN64)
+# if defined(Q_CC_MINGW) && defined(Q_PROCESSOR_X86_32)
# define QT_ENSURE_STACK_ALIGNED_FOR_SSE __attribute__ ((force_align_arg_pointer))
# else
# define QT_ENSURE_STACK_ALIGNED_FOR_SSE
@@ -581,6 +634,29 @@ using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
template <typename T>
constexpr inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
+// gcc < 10 doesn't have __has_builtin
+#if defined(Q_PROCESSOR_ARM_64) && (__has_builtin(__builtin_round) || defined(Q_CC_GNU)) && !defined(Q_CC_CLANG)
+// ARM64 has a single instruction that can do C++ rounding with conversion to integer.
+// Note current clang versions have non-constexpr __builtin_round, ### allow clang this path when they fix it.
+constexpr inline int qRound(double d)
+{ return int(__builtin_round(d)); }
+constexpr inline int qRound(float f)
+{ return int(__builtin_roundf(f)); }
+constexpr inline qint64 qRound64(double d)
+{ return qint64(__builtin_round(d)); }
+constexpr inline qint64 qRound64(float f)
+{ return qint64(__builtin_roundf(f)); }
+#elif defined(__SSE2__) && (__has_builtin(__builtin_copysign) || defined(Q_CC_GNU))
+// SSE has binary operations directly on floating point making copysign fast
+constexpr inline int qRound(double d)
+{ return int(d + __builtin_copysign(0.5, d)); }
+constexpr inline int qRound(float f)
+{ return int(f + __builtin_copysignf(0.5f, f)); }
+constexpr inline qint64 qRound64(double d)
+{ return qint64(d + __builtin_copysign(0.5, d)); }
+constexpr inline qint64 qRound64(float f)
+{ return qint64(f + __builtin_copysignf(0.5f, f)); }
+#else
constexpr inline int qRound(double d)
{ return d >= 0.0 ? int(d + 0.5) : int(d - 0.5); }
constexpr inline int qRound(float d)
@@ -590,6 +666,7 @@ constexpr inline qint64 qRound64(double d)
{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - 0.5); }
constexpr inline qint64 qRound64(float d)
{ return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - 0.5f); }
+#endif
namespace QTypeTraits {
@@ -597,7 +674,9 @@ namespace detail {
template<typename T, typename U,
typename = std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U> &&
std::is_floating_point_v<T> == std::is_floating_point_v<U> &&
- std::is_signed_v<T> == std::is_signed_v<U>> >
+ std::is_signed_v<T> == std::is_signed_v<U> &&
+ !std::is_same_v<T, bool> && !std::is_same_v<U, bool> &&
+ !std::is_same_v<T, char> && !std::is_same_v<U, char>>>
struct Promoted
{
using type = decltype(T() + U());
@@ -864,22 +943,22 @@ typedef void (*QFunctionPointer)();
# define Q_UNIMPLEMENTED() qWarning("Unimplemented code.")
#endif
-Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyCompare(double p1, double p2)
+[[nodiscard]] constexpr bool qFuzzyCompare(double p1, double p2)
{
return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2)));
}
-Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyCompare(float p1, float p2)
+[[nodiscard]] constexpr bool qFuzzyCompare(float p1, float p2)
{
return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2)));
}
-Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyIsNull(double d)
+[[nodiscard]] constexpr bool qFuzzyIsNull(double d)
{
return qAbs(d) <= 0.000000000001;
}
-Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyIsNull(float f)
+[[nodiscard]] constexpr bool qFuzzyIsNull(float f)
{
return qAbs(f) <= 0.00001f;
}
@@ -887,12 +966,12 @@ Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qFuzzyIsNull(float
QT_WARNING_PUSH
QT_WARNING_DISABLE_FLOAT_COMPARE
-Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qIsNull(double d) noexcept
+[[nodiscard]] constexpr bool qIsNull(double d) noexcept
{
return d == 0.0;
}
-Q_REQUIRED_RESULT Q_DECL_UNUSED constexpr static inline bool qIsNull(float f) noexcept
+[[nodiscard]] constexpr bool qIsNull(float f) noexcept
{
return f == 0.0f;
}
@@ -981,29 +1060,6 @@ QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantic
# endif
#endif
-// Work around MSVC warning about use of 3-arg algorithms
-// until we can depend on the C++14 4-arg ones.
-//
-// These algortithms do NOT check for equal length.
-// They need to be treated as if they called the 3-arg version (which they do)!
-#ifdef Q_CC_MSVC
-# define QT_3ARG_ALG(alg, f1, l1, f2, l2) \
- std::alg(f1, l1, f2, l2)
-#else
-# define QT_3ARG_ALG(alg, f1, l1, f2, l2) \
- [&f1, &l1, &f2, &l2]() { \
- Q_UNUSED(l2); \
- return std::alg(f1, l1, f2); \
- }()
-#endif
-template <typename ForwardIterator1, typename ForwardIterator2>
-inline bool qt_is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
- ForwardIterator2 first2, ForwardIterator2 last2)
-{
- return QT_3ARG_ALG(is_permutation, first1, last1, first2, last2);
-}
-#undef QT_3ARG_ALG
-
// this adds const to non-const objects (like std::as_const)
template <typename T>
constexpr typename std::add_const<T>::type &qAsConst(T &t) noexcept { return t; }
@@ -1020,6 +1076,12 @@ constexpr T qExchange(T &t, U &&newValue)
return old;
}
+#ifdef __cpp_conditional_explicit
+#define Q_IMPLICIT explicit(false)
+#else
+#define Q_IMPLICIT
+#endif
+
#ifndef QT_NO_FOREACH
namespace QtPrivate {
@@ -1053,9 +1115,23 @@ public:
int control = 1;
};
+// Containers that have a detach function are considered shared, and are OK in a foreach loop
+template <typename T, typename = decltype(std::declval<T>().detach())>
+inline void warnIfContainerIsNotShared(int) {}
+
+#if QT_DEPRECATED_SINCE(6, 0)
+// Other containers will copy themselves if used in foreach, this use is deprecated
+template <typename T>
+QT_DEPRECATED_VERSION_X_6_0("Do not use foreach/Q_FOREACH with containers which are not implicitly shared. "
+ "Prefer using a range-based for loop with these containers: `for (const auto &it : container)`, "
+ "keeping in mind that range-based for doesn't copy the container as Q_FOREACH does")
+inline void warnIfContainerIsNotShared(...) {}
+#endif
+
template<typename T>
QForeachContainer<typename std::decay<T>::type> qMakeForeachContainer(T &&t)
{
+ warnIfContainerIsNotShared<typename std::decay<T>::type>(0);
return QForeachContainer<typename std::decay<T>::type>(std::forward<T>(t));
}
@@ -1081,28 +1157,29 @@ for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \
# endif
#endif
-template <typename T> inline T *qGetPtrHelper(T *ptr) { return ptr; }
-template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) -> decltype(ptr.get()) { return ptr.get(); }
+template <typename T> inline T *qGetPtrHelper(T *ptr) noexcept { return ptr; }
+template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) noexcept -> decltype(ptr.get())
+{ static_assert(noexcept(ptr.get()), "Smart d pointers for Q_DECLARE_PRIVATE must have noexcept get()"); return ptr.get(); }
// The body must be a statement:
#define Q_CAST_IGNORE_ALIGN(body) QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wcast-align") body QT_WARNING_POP
#define Q_DECLARE_PRIVATE(Class) \
- inline Class##Private* d_func() \
+ inline Class##Private* d_func() noexcept \
{ Q_CAST_IGNORE_ALIGN(return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr));) } \
- inline const Class##Private* d_func() const \
+ inline const Class##Private* d_func() const noexcept \
{ Q_CAST_IGNORE_ALIGN(return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr));) } \
friend class Class##Private;
#define Q_DECLARE_PRIVATE_D(Dptr, Class) \
- inline Class##Private* d_func() \
+ inline Class##Private* d_func() noexcept \
{ Q_CAST_IGNORE_ALIGN(return reinterpret_cast<Class##Private *>(qGetPtrHelper(Dptr));) } \
- inline const Class##Private* d_func() const \
+ inline const Class##Private* d_func() const noexcept \
{ Q_CAST_IGNORE_ALIGN(return reinterpret_cast<const Class##Private *>(qGetPtrHelper(Dptr));) } \
friend class Class##Private;
#define Q_DECLARE_PUBLIC(Class) \
- inline Class* q_func() { return static_cast<Class *>(q_ptr); } \
- inline const Class* q_func() const { return static_cast<const Class *>(q_ptr); } \
+ inline Class* q_func() noexcept { return static_cast<Class *>(q_ptr); } \
+ inline const Class* q_func() const noexcept { return static_cast<const Class *>(q_ptr); } \
friend class Class;
#define Q_D(Class) Class##Private * const d = d_func()
@@ -1115,7 +1192,7 @@ template <typename Ptr> inline auto qGetPtrHelper(Ptr &ptr) -> decltype(ptr.get(
#define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
#define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
-#ifndef QT_NO_TRANSLATION // ### Qt6: This should enclose the NOOPs above
+#ifndef QT_NO_TRANSLATION
#define QT_TR_N_NOOP(x) x
#define QT_TRANSLATE_N_NOOP(scope, x) x
@@ -1130,22 +1207,8 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
#endif // QT_NO_TRANSLATION
-/*
- When RTTI is not available, define this macro to force any uses of
- dynamic_cast to cause a compile failure.
-*/
-
-#if defined(QT_NO_DYNAMIC_CAST) && !defined(dynamic_cast)
-# define dynamic_cast QT_PREPEND_NAMESPACE(qt_dynamic_cast_check)
-
- template<typename T, typename X>
- T qt_dynamic_cast_check(X, T* = 0)
- { return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; }
-#endif
-
#ifdef Q_QDOC
-
// Just for documentation generation
template<typename T>
auto qOverload(T functionPointer);
@@ -1153,9 +1216,7 @@ template<typename T>
auto qConstOverload(T memberFunctionPointer);
template<typename T>
auto qNonConstOverload(T memberFunctionPointer);
-
-#elif defined(Q_COMPILER_VARIADIC_TEMPLATES)
-
+#else
template <typename... Args>
struct QNonConstOverload
{
@@ -1197,12 +1258,9 @@ struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
{ return ptr; }
};
-#if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 // C++14
-template <typename... Args> Q_DECL_UNUSED constexpr QOverload<Args...> qOverload = {};
-template <typename... Args> Q_DECL_UNUSED constexpr QConstOverload<Args...> qConstOverload = {};
-template <typename... Args> Q_DECL_UNUSED constexpr QNonConstOverload<Args...> qNonConstOverload = {};
-#endif
-
+template <typename... Args> constexpr inline QOverload<Args...> qOverload = {};
+template <typename... Args> constexpr inline QConstOverload<Args...> qConstOverload = {};
+template <typename... Args> constexpr inline QNonConstOverload<Args...> qNonConstOverload = {};
#endif
@@ -1239,21 +1297,26 @@ inline int qIntCast(float f) { return int(f); }
// Ensures that the interface's typeinfo is exported so that
// dynamic casts work reliably, and protects the destructor
// so that pointers to the interface can't be deleted.
-#define QT_DECLARE_PLATFORM_INTERFACE(InterfaceClass) \
+#define QT_DECLARE_NATIVE_INTERFACE(InterfaceClass) \
protected: virtual ~InterfaceClass(); public:
+// Declares an accessor for the native interface
+#define QT_DECLARE_NATIVE_INTERFACE_ACCESSOR \
+ template <typename QNativeInterface> \
+ QNativeInterface *nativeInterface() const;
+
// Provides a definition for the interface destructor
-#define QT_DEFINE_PLATFORM_INTERFACE2(Namespace, InterfaceClass) \
+#define QT_DEFINE_NATIVE_INTERFACE2(Namespace, InterfaceClass) \
QT_PREPEND_NAMESPACE(Namespace)::InterfaceClass::~InterfaceClass() = default
// Provides a definition for the destructor, and an explicit
-// template instantiation of the platform interface accessor.
-#define QT_DEFINE_PLATFORM_INTERFACE3(Namespace, InterfaceClass, PublicClass) \
- QT_DEFINE_PLATFORM_INTERFACE2(Namespace, InterfaceClass); \
- template Q_DECL_EXPORT QT_PREPEND_NAMESPACE(Namespace)::InterfaceClass *PublicClass::platformInterface() const
+// template instantiation of the native interface accessor.
+#define QT_DEFINE_NATIVE_INTERFACE3(Namespace, InterfaceClass, PublicClass) \
+ QT_DEFINE_NATIVE_INTERFACE2(Namespace, InterfaceClass); \
+ template Q_DECL_EXPORT QT_PREPEND_NAMESPACE(Namespace)::InterfaceClass *PublicClass::nativeInterface() const
-#define QT_DEFINE_PLATFORM_INTERFACE(...) QT_OVERLOADED_MACRO(QT_DEFINE_PLATFORM_INTERFACE, QPlatformInterface, __VA_ARGS__)
-#define QT_DEFINE_PRIVATE_PLATFORM_INTERFACE(...) QT_OVERLOADED_MACRO(QT_DEFINE_PLATFORM_INTERFACE, QPlatformInterface::Private, __VA_ARGS__)
+#define QT_DEFINE_NATIVE_INTERFACE(...) QT_OVERLOADED_MACRO(QT_DEFINE_NATIVE_INTERFACE, QNativeInterface, __VA_ARGS__)
+#define QT_DEFINE_PRIVATE_NATIVE_INTERFACE(...) QT_OVERLOADED_MACRO(QT_DEFINE_NATIVE_INTERFACE, QNativeInterface::Private, __VA_ARGS__)
// This macro can be used to calculate member offsets for types with a non standard layout.
// It uses the fact that offsetof() is allowed to support those types since C++17 as an optional
diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h
index e56fe1dbcb..a0dfd462fd 100644
--- a/src/corelib/global/qglobalstatic.h
+++ b/src/corelib/global/qglobalstatic.h
@@ -132,17 +132,29 @@ struct QGlobalStatic
bool isDestroyed() const { return guard.loadRelaxed() <= QtGlobalStatic::Destroyed; }
bool exists() const { return guard.loadRelaxed() == QtGlobalStatic::Initialized; }
- operator Type *() { if (isDestroyed()) return nullptr; return innerFunction(); }
- Type *operator()() { if (isDestroyed()) return nullptr; return innerFunction(); }
+ operator Type *()
+ {
+ if (isDestroyed())
+ return nullptr;
+ return innerFunction();
+ }
+ Type *operator()()
+ {
+ if (isDestroyed())
+ return nullptr;
+ return innerFunction();
+ }
Type *operator->()
{
- Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed");
- return innerFunction();
+ Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC",
+ "The global static was used after being destroyed");
+ return innerFunction();
}
Type &operator*()
{
- Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed");
- return *innerFunction();
+ Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC",
+ "The global static was used after being destroyed");
+ return *innerFunction();
}
};
diff --git a/src/corelib/global/qisenum.h b/src/corelib/global/qisenum.h
deleted file mode 100644
index 8f784ef6e3..0000000000
--- a/src/corelib/global/qisenum.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qglobal.h>
-
-#ifndef QISENUM_H
-#define QISENUM_H
-
-// Use of Q_IS_ENUM is deprecated since 5.8
-#define Q_IS_ENUM(x) std::is_enum<x>::value
-
-// shut up syncqt
-QT_BEGIN_NAMESPACE
-QT_END_NAMESPACE
-#endif // QISENUM_H
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 19ff39ad74..301c3ab89a 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -597,8 +597,8 @@ QString qmake_abslocation();
static QString getPrefixFromHostBinDir(const char *hostBinDirToPrefixPath)
{
- const QFileInfo qmfi = QFileInfo(qmake_abslocation()).canonicalFilePath();
- return QDir::cleanPath(qmfi.absolutePath() + QLatin1Char('/')
+ const QString canonicalQMakePath = QFileInfo(qmake_abslocation()).canonicalPath();
+ return QDir::cleanPath(canonicalQMakePath + QLatin1Char('/')
+ QLatin1String(hostBinDirToPrefixPath));
}
@@ -636,7 +636,7 @@ static QString getPrefix(
}
#endif // QT_BUILD_QMAKE_BOOTSTRAP
-/*! \fn QString QLibraryInfo::path(LibraryPath loc)
+/*! \fn QString QLibraryInfo::location(LibraryLocation loc)
\obsolete Use path() instead.
Returns the path specified by \a loc.
@@ -644,7 +644,8 @@ static QString getPrefix(
*/
/*!
- Returns the path specified by \a p.
+ \since 6.0
+ Returns the path specified by \a p.
*/
QString QLibraryInfo::path(LibraryPath p)
{
@@ -662,7 +663,7 @@ QString QLibraryInfo::path(LibraryPath p)
QString
QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group)
{
-#endif // QT_BUILD_QMAKE, started inside location !
+#endif // QT_BUILD_QMAKE, started inside path!
QString ret;
bool fromConf = false;
#if QT_CONFIG(settings)
@@ -699,7 +700,7 @@ QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group)
}
#endif
- if(!key.isNull()) {
+ if (!key.isNull()) {
QSettings *config = QLibraryInfoPrivate::configuration();
config->beginGroup(QLatin1String(
#ifdef QT_BUILD_QMAKE
@@ -853,27 +854,31 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName)
\keyword library location
- This enum type is used to specify a specific location
- specifier:
+ This enum type is used to query for a specific path:
\value PrefixPath The default prefix for all paths.
- \value DocumentationPath The location for documentation upon install.
- \value HeadersPath The location for all headers.
- \value LibrariesPath The location of installed libraries.
- \value LibraryExecutablesPath The location of installed executables required by libraries at runtime.
- \value BinariesPath The location of installed Qt binaries (tools and applications).
- \value PluginsPath The location of installed Qt plugins.
- \value Qml2ImportsPath The location of installed QML extensions to import (QML 2.x).
- \value ArchDataPath The location of general architecture-dependent Qt data.
- \value DataPath The location of general architecture-independent Qt data.
- \value TranslationsPath The location of translation information for Qt strings.
- \value ExamplesPath The location for examples upon install.
- \value TestsPath The location of installed Qt testcases.
- \value SettingsPath The location for Qt settings. Not applicable on Windows.
+ \value DocumentationPath The path to documentation upon install.
+ \value HeadersPath The path to all headers.
+ \value LibrariesPath The path to installed libraries.
+ \value LibraryExecutablesPath The path to installed executables required by libraries at runtime.
+ \value BinariesPath The path to installed Qt binaries (tools and applications).
+ \value PluginsPath The path to installed Qt plugins.
+ \value Qml2ImportsPath The path to installed QML extensions to import (QML 2.x).
+ \value ArchDataPath The path to general architecture-dependent Qt data.
+ \value DataPath The path to general architecture-independent Qt data.
+ \value TranslationsPath The path to translation information for Qt strings.
+ \value ExamplesPath The path to examples upon install.
+ \value TestsPath The path to installed Qt testcases.
+ \value SettingsPath The path to Qt settings. Not applicable on Windows.
\sa path()
*/
+/*!
+ \typealias QLibraryInfo::LibraryLocation
+ \obsolete Use LibraryPath with QLibraryInfo::path() instead.
+*/
+
QT_END_NAMESPACE
#if defined(Q_CC_GNU) && defined(ELF_INTERPRETER)
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index bb5c9a8e08..04956052b3 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QLibraryInfo
{
public:
- static const char * build() noexcept;
+ static const char *build() noexcept;
static bool isDebugBuild();
@@ -57,8 +57,7 @@ public:
static QVersionNumber version() noexcept Q_DECL_CONST_FUNCTION;
#endif
- enum LibraryPath
- {
+ enum LibraryPath {
PrefixPath = 0,
DocumentationPath,
HeadersPath,
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 0e9dd3b5ee..04468d7aac 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1069,8 +1069,8 @@ static const char emptyTokenC[] = "";
static const char defaultPattern[] = "%{if-category}%{category}: %{endif}%{message}";
-
-struct QMessagePattern {
+struct QMessagePattern
+{
QMessagePattern();
~QMessagePattern();
@@ -1078,13 +1078,14 @@ struct QMessagePattern {
// 0 terminated arrays of literal tokens / literal or placeholder tokens
std::unique_ptr<std::unique_ptr<const char[]>[]> literals;
- std::unique_ptr<const char*[]> tokens;
- QList<QString> timeArgs; // timeFormats in sequence of %{time
+ std::unique_ptr<const char *[]> tokens;
+ QList<QString> timeArgs; // timeFormats in sequence of %{time
#ifndef QT_BOOTSTRAPPED
QElapsedTimer timer;
#endif
#ifdef QLOGGING_HAVE_BACKTRACE
- struct BacktraceParams {
+ struct BacktraceParams
+ {
QString backtraceSeparator;
int backtraceDepth;
};
@@ -1095,7 +1096,7 @@ struct QMessagePattern {
static QBasicMutex mutex;
};
#ifdef QLOGGING_HAVE_BACKTRACE
-Q_DECLARE_TYPEINFO(QMessagePattern::BacktraceParams, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QMessagePattern::BacktraceParams, Q_RELOCATABLE_TYPE);
#endif
QBasicMutex QMessagePattern::mutex;
@@ -1115,8 +1116,7 @@ QMessagePattern::QMessagePattern()
}
}
-QMessagePattern::~QMessagePattern()
- = default;
+QMessagePattern::~QMessagePattern() = default;
void QMessagePattern::setPattern(const QString &pattern)
{
@@ -1158,7 +1158,7 @@ void QMessagePattern::setPattern(const QString &pattern)
// tokenizer
std::vector<std::unique_ptr<const char[]>> literalsVar;
- tokens.reset(new const char*[lexemes.size() + 1]);
+ tokens.reset(new const char *[lexemes.size() + 1]);
tokens[lexemes.size()] = nullptr;
bool nestedIfError = false;
@@ -1290,7 +1290,7 @@ static QStringList backtraceFramesForLogMessage(int frameCount)
// This code is protected by QMessagePattern::mutex so it is thread safe on all compilers
static const QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$"));
- QVarLengthArray<void*, 32> buffer(8 + frameCount);
+ QVarLengthArray<void *, 32> buffer(8 + frameCount);
int n = backtrace(buffer.data(), buffer.size());
if (n > 0) {
int numberPrinted = 0;
@@ -1642,11 +1642,21 @@ static bool android_default_message_handler(QtMsgType type,
android_LogPriority priority = ANDROID_LOG_DEBUG;
switch (type) {
- case QtDebugMsg: priority = ANDROID_LOG_DEBUG; break;
- case QtInfoMsg: priority = ANDROID_LOG_INFO; break;
- case QtWarningMsg: priority = ANDROID_LOG_WARN; break;
- case QtCriticalMsg: priority = ANDROID_LOG_ERROR; break;
- case QtFatalMsg: priority = ANDROID_LOG_FATAL; break;
+ case QtDebugMsg:
+ priority = ANDROID_LOG_DEBUG;
+ break;
+ case QtInfoMsg:
+ priority = ANDROID_LOG_INFO;
+ break;
+ case QtWarningMsg:
+ priority = ANDROID_LOG_WARN;
+ break;
+ case QtCriticalMsg:
+ priority = ANDROID_LOG_ERROR;
+ break;
+ case QtFatalMsg:
+ priority = ANDROID_LOG_FATAL;
+ break;
};
__android_log_print(priority, qPrintable(QCoreApplication::applicationName()), "%s\n", qPrintable(formattedMessage));
@@ -1666,8 +1676,8 @@ static void win_outputDebugString_helper(QStringView message)
OutputDebugString(reinterpret_cast<const wchar_t *>(message.utf16()));
} else {
wchar_t *messagePart = new wchar_t[maxOutputStringLength + 1];
- for (int i = 0; i < message.length(); i += maxOutputStringLength ) {
- const int length = std::min(message.length() - i, maxOutputStringLength );
+ for (int i = 0; i < message.length(); i += maxOutputStringLength) {
+ const int length = std::min(message.length() - i, maxOutputStringLength);
const int len = message.mid(i, length).toWCharArray(messagePart);
Q_ASSERT(len == length);
messagePart[len] = 0;
diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h
index e905929c78..ecf60f747c 100644
--- a/src/corelib/global/qlogging.h
+++ b/src/corelib/global/qlogging.h
@@ -57,7 +57,14 @@ QT_BEGIN_NAMESPACE
class QDebug;
class QNoDebug;
-enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtInfoMsg, QtSystemMsg = QtCriticalMsg };
+enum QtMsgType {
+ QtDebugMsg,
+ QtWarningMsg,
+ QtCriticalMsg,
+ QtFatalMsg,
+ QtInfoMsg,
+ QtSystemMsg = QtCriticalMsg
+};
class QMessageLogContext
{
diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp
index fbea0e5689..aeba9ed19b 100644
--- a/src/corelib/global/qmalloc.cpp
+++ b/src/corelib/global/qmalloc.cpp
@@ -58,9 +58,9 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align
{
// fake an aligned allocation
void *actualptr = oldptr ? static_cast<void **>(oldptr)[-1] : nullptr;
- if (alignment <= sizeof(void*)) {
+ if (alignment <= sizeof(void *)) {
// special, fast case
- void **newptr = static_cast<void **>(realloc(actualptr, newsize + sizeof(void*)));
+ void **newptr = static_cast<void **>(realloc(actualptr, newsize + sizeof(void *)));
if (!newptr)
return nullptr;
if (newptr == actualptr) {
@@ -112,4 +112,3 @@ void qFreeAligned(void *ptr)
}
QT_END_NAMESPACE
-
diff --git a/src/corelib/global/qmemory_p.h b/src/corelib/global/qmemory_p.h
deleted file mode 100644
index ac791385bd..0000000000
--- a/src/corelib/global/qmemory_p.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QMEMORY_P_H
-#define QMEMORY_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-
-#include <memory>
-#include <type_traits>
-#include <utility>
-
-QT_BEGIN_NAMESPACE
-
-// Like std::make_unique, but less ambitious, so keep as private API, for use in Qt itself:
-template <typename T, typename... Args>
-typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type
-qt_make_unique(Args &&...args)
-{
- return std::unique_ptr<T>{new T(std::forward<Args>(args)...)};
-}
-
-QT_END_NAMESPACE
-
-#endif /* QMEMORY_P_H */
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 6edd84534b..4bc0186210 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -359,7 +359,6 @@ namespace Qt {
WA_ShowModal = 70, // ## deprecated since since 4.5.1 but still in use :-(
WA_MouseNoMask = 71,
- WA_GroupLeader = 72, // ## deprecated since since 4.5.1 but still in use :-(
WA_NoMousePropagation = 73, // for now, might go away.
WA_Hover = 74,
WA_InputMethodTransparent = 75, // Don't reset IM when user clicks on this (for virtual keyboards on embedded)
@@ -402,7 +401,7 @@ namespace Qt {
WA_NativeWindow = 100,
WA_DontCreateNativeAncestors = 101,
- WA_MacVariableSize = 102, // Mac only
+ // Formerly WA_MacVariableSize = 102, // Mac only
WA_DontShowOnScreen = 103,
@@ -430,7 +429,7 @@ namespace Qt {
WA_TouchPadAcceptSingleTouchEvents = 123,
WA_X11DoNotAcceptFocus = 126,
- WA_MacNoShadow = 127,
+ // Formerly, 127 was WA_MacNoShadow
WA_AlwaysStackOnTop = 128,
@@ -1602,16 +1601,10 @@ namespace Qt {
TitleBarArea // For move
};
-#if defined(Q_COMPILER_CONSTEXPR)
enum class Initialization {
Uninitialized
};
- Q_DECL_UNUSED static constexpr Initialization Uninitialized = Initialization::Uninitialized;
-#else
- enum Initialization {
- Uninitialized
- };
-#endif
+ inline constexpr Initialization Uninitialized = Initialization::Uninitialized;
enum CoordinateSystem {
DeviceCoordinates,
@@ -1842,7 +1835,6 @@ public:
Pbuffer = 0x06, // GL pbuffer
FramebufferObject = 0x07, // GL framebuffer object
CustomRaster = 0x08,
- MacQuartz = 0x09,
PaintBuffer = 0x0a,
OpenGL = 0x0b
};
@@ -1874,7 +1866,7 @@ class QKeyCombination
int combination;
public:
- constexpr /* implicit */ QKeyCombination(Qt::Key key = Qt::Key_unknown) noexcept
+ constexpr Q_IMPLICIT QKeyCombination(Qt::Key key = Qt::Key_unknown) noexcept
: combination(int(key))
{}
@@ -1910,7 +1902,7 @@ public:
#if QT_DEPRECATED_SINCE(6, 0)
QT_DEPRECATED_VERSION_X(6, 0, "Use QKeyCombination instead of int")
- constexpr /* implicit */ operator int() const noexcept
+ constexpr Q_IMPLICIT operator int() const noexcept
{
return combination;
}
@@ -1927,7 +1919,7 @@ public:
}
};
-Q_DECLARE_TYPEINFO(QKeyCombination, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QKeyCombination, Q_RELOCATABLE_TYPE);
constexpr QKeyCombination operator|(Qt::Modifier modifier, Qt::Key key) noexcept
{
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index bdc6574b53..4aded8643e 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -664,41 +664,67 @@
/*!
\enum Qt::DateFormat
- \value TextDate The default Qt format, which includes the day and month name,
- the day number in the month, and the year in full. The day and month names will
- be short names in English. This is basically equivalent to using the date format
- string, "ddd MMM d yyyy". See QDate::toString() for more information.
-
- \value ISODate \l{ISO 8601} extended format: either \c{yyyy-MM-dd} for dates or
- \c{yyyy-MM-ddTHH:mm:ss} (e.g. 2017-07-24T15:46:29), or with a time-zone
- suffix (Z for UTC otherwise an offset as [+|-]HH:mm) where appropriate
- for combined dates and times.
-
- \value ISODateWithMs \l{ISO 8601} extended format, including milliseconds if applicable.
-
- \value RFC2822Date \l{RFC 2822}, \l{RFC 850} and \l{RFC 1036} format:
- either \c{[ddd,] dd MMM yyyy [HH:mm[:ss]][ ±tzoff]}
- or \c{ddd MMM dd[ HH:mm:ss] yyyy[ ±tzoff]} are recognized for combined dates
- and times, where \c{tzoff} is a timezone offset in \c{HHmm} format. For
- dates and times separately, the same formats are matched and the unwanted
- parts are ignored. In particular, note that a time is not recognized without
- an accompanying date. When converting dates to string form,
- format \c{dd MMM yyyy} is used, for times the format is \c{HH:mm:ss}. For
- combined date and time, these are combined
+ \value TextDate The default Qt format, which includes the day and month
+ name, the day number in the month, and the year in full. The day and month
+ names will be short names in English (C locale). This effectively uses, for
+ a date, format \c{ddd MMM d yyyy}, for a time \c{HH:mm:ss} and combines
+ these as \c{ddd MMM d HH:mm:ss yyyy} for a date-time, with an optional
+ suffix indicating time-zone or offset from UTC, where relevant. A fractional
+ part is also recognized on the seconds of a time part, as \c{HH:mm:ss.zzz},
+ when reading from a string.
+
+ \value ISODateWithMs \l{ISO 8601} extended format: uses \c{yyyy-MM-dd} for
+ dates, \c{HH:mm:ss.zzz} for times or \c{yyyy-MM-ddTHH:mm:ss.zzz}
+ (e.g. 2017-07-24T15:46:29.739) for combined dates and times, optionally with
+ a time-zone suffix (Z for UTC otherwise an offset as ±HH:mm) where
+ appropriate. When parsed, a single space, \c{' '}, may be used in place of
+ the \c{'T'} separator between date and time; no other spacing characters are
+ permitted. This format also accepts \c{HH:mm} and plain \c{HH} formats for
+ the time part, either of which may include a fractional part, \c{HH:mm.zzz}
+ or \c{HH.zzz}, applied to the last field present (hour or minute).
+
+ \value ISODate \l{ISO 8601} extended format, as for \c ISODateWithMs, but
+ omitting the milliseconds (\c{.zzz}) part when converting to a string. There
+ is no difference when reading from a string: if a fractional part is present
+ on the last time field, either format will accept it.
+
+ \value RFC2822Date \l{RFC 2822}, \l{RFC 850} and \l{RFC 1036} format: when
+ converting dates to string form, format \c{dd MMM yyyy} is used, for times
+ the format is \c{HH:mm:ss}. For combined date and time, these are combined
as \c{dd MMM yyyy HH:mm:ss ±tzoff} (omitting the optional leading day of the
- week from the first format recognized).
+ week from the first format recognized). When reading from a string either
+ \c{[ddd,] dd MMM yyyy [HH:mm[:ss]][ ±tzoff]} or \c{ddd MMM dd[ HH:mm:ss]
+ yyyy[ ±tzoff]} will be recognized for combined dates and times, where
+ \c{tzoff} is a timezone offset in \c{HHmm} format. Arbitrary spacing may
+ appear before or after the text and any non-empty spacing may replace the
+ spaces in this format. For dates and times separately, the same formats are
+ matched and the unwanted parts are ignored. In particular, note that a time
+ is not recognized without an accompanying date.
\note For \c ISODate formats, each \c y, \c M and \c d represents a single
digit of the year, month, and day used to specify the date. Each \c H, \c m,
and \c s represents a single digit of the hour (up to 24), minute and second
- used to specify the time. The presence of a literal \c T character is used
- to separate the date and time when both are specified. For the \c
- RFC2822Date format, MMM stands for the first three letters of the month name
- in English, the other format characters have the same meaning as for the
- ISODate format.
+ used to specify the time. An hour of 24, with zero for all other time
+ fields, is understood as the start of the next day. A \c{.zzz} stands for a
+ fractional part suffix on the preceding field, which may be separated from
+ that field either by a comma \c{','} or the dot \c{'.'} shown. Precision
+ beyond milliseconds is accepted but discarded, rounding to the nearest
+ representable millisecond. The presence of a literal \c T character is used
+ to separate the date and time when both are specified. For the \c TextDate
+ and \c RFC2822Date formats, \c{ddd} stands for the first three letters of
+ the name of the day of the week and \c{MMM} stands for the first three
+ letters of the month name. The names of days and months are always in
+ English (C locale) regardless of user preferences or system settings. The
+ other format characters have the same meaning as for the ISODate format,
+ except that 24 is not accepted as an hour. Parts of a format enclosed in
+ square brackets \c{[...]} are optional; the square brackets do not form part
+ of the format. The plus-or-minus character \c{'±'} here stands for either
+ sign character, \c{'-'} for minus or \c{'+'} for plus.
+
+ \sa QDate::toString(), QTime::toString(), QDateTime::toString(),
+ QDate::fromString(), QTime::fromString(), QDateTime::fromString()
*/
-
/*!
\enum Qt::TimeSpec
@@ -920,9 +946,6 @@
This implies WA_UpdatesDisabled. This is set/cleared by
QWidget::setUpdatesEnabled().
- \value WA_GroupLeader \e{This attribute has been deprecated.} Use
- QWidget::windowModality instead.
-
\value WA_Hover Forces Qt to generate paint events when the mouse
enters or leaves the widget. This feature is typically used when
implementing custom styles; see the \l{widgets/styles}{Styles}
@@ -985,10 +1008,6 @@
size for widgets in \macos. This attribute is only applicable to
\macos.
- \value WA_MacVariableSize Indicates the widget can choose between
- alternative sizes for widgets to avoid clipping.
- This attribute is only applicable to \macos.
-
\value WA_Mapped Indicates that the widget is mapped on screen.
This is set/cleared by the Qt kernel.
@@ -1287,7 +1306,6 @@
\omitvalue WA_WState_ExplicitShowHide
\omitvalue WA_InputMethodTransparent
\omitvalue WA_DropSiteRegistered
- \omitvalue WA_ForceAcceptDrops
\omitvalue WA_NoX11EventCompression
\omitvalue WA_TintedBackground
\omitvalue WA_X11OpenGLOverlay
@@ -1297,7 +1315,6 @@
\omitvalue WA_SetWindowModality
\omitvalue WA_WState_WindowOpacitySet
\omitvalue WA_WState_AcceptedTouchBeginEvent
- \omitvalue WA_MacNoShadow
\omitvalue WA_StyleSheet
\omitvalue WA_AttributeCount
*/
@@ -2130,8 +2147,7 @@
\value SplashScreen Indicates that the window is a splash screen.
This is the default type for QSplashScreen.
- \omitvalue Desktop Indicates that this widget is the desktop. This
- is the type for QDesktopWidget.
+ \omitvalue Desktop Indicates that this widget is the desktop.
\value SubWindow Indicates that this widget is a sub-window, such
as a QMdiSubWindow widget.
@@ -2988,6 +3004,7 @@
This enum represents the state of a touch point at the time a
QTouchEvent occurred.
+ \value TouchPointUnknownState The state of the touch point is not known.
\value TouchPointPressed The touch point is now pressed.
\value TouchPointMoved The touch point moved.
\value TouchPointStationary The touch point did not move.
@@ -3221,8 +3238,7 @@
decide how non-integer scale factors (such as Windows 150%) are handled.
The active policy is set by calling QGuiApplication::setHighDdpiScaleFactorRoundingPolicy() before
- the application object is created, or by setting the QT_SCALE_FACTOR_ROUNDING_POLICY
- environment variable.
+ the application object is created.
\sa QGuiApplication::setHighDpiScaleFactorRoundingPolicy()
@@ -3336,16 +3352,14 @@
#endif
/*!
- \fn bool operator==(QKeyCombination lhs, QKeyCombination rhs) noexcept
- \relates QKeyCombination
+ \fn bool QKeyCombination::operator==(QKeyCombination lhs, QKeyCombination rhs) noexcept
Returns \c true if \a lhs and \a rhs have the same combination
of key and modifiers, and \c false otherwise.
*/
/*!
- \fn bool operator!=(QKeyCombination lhs, QKeyCombination rhs) noexcept
- \relates QKeyCombination
+ \fn bool QKeyCombination::operator!=(QKeyCombination lhs, QKeyCombination rhs) noexcept
Returns \c true if \a lhs and \a rhs have different combinations
of key and modifiers, otherwise \c false.
diff --git a/src/corelib/global/qnumeric.cpp b/src/corelib/global/qnumeric.cpp
index b754155b30..e00f0af283 100644
--- a/src/corelib/global/qnumeric.cpp
+++ b/src/corelib/global/qnumeric.cpp
@@ -104,6 +104,9 @@ Q_CORE_EXPORT double qQNaN() { return qt_qnan(); }
Q_CORE_EXPORT double qInf() { return qt_inf(); }
/*!
+ \fn int qFpClassify(double val)
+ \fn int qFpClassify(float val)
+
\relates <QtGlobal>
Classifies a floating-point value.
@@ -118,10 +121,6 @@ Q_CORE_EXPORT double qInf() { return qt_inf(); }
\endlist
*/
Q_CORE_EXPORT int qFpClassify(double val) { return qt_fpclassify(val); }
-
-/*!
- \overload
-*/
Q_CORE_EXPORT int qFpClassify(float val) { return qt_fpclassify(val); }
diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h
index 2c5d19d274..a11057dfff 100644
--- a/src/corelib/global/qnumeric_p.h
+++ b/src/corelib/global/qnumeric_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Copyright (C) 2018 Intel Corporation.
+** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2020 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -55,6 +55,7 @@
#include "QtCore/private/qglobal_p.h"
#include <cmath>
#include <limits>
+#include <type_traits>
#if defined(Q_CC_MSVC)
# include <intrin.h>
@@ -129,7 +130,7 @@ Q_DECL_CONST_FUNCTION static inline int fpclassify(float f) { return std::fpclas
constexpr Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept
{
static_assert(std::numeric_limits<double>::has_infinity,
- "platform has no definition for infinity for type double");
+ "platform has no definition for infinity for type double");
return std::numeric_limits<double>::infinity();
}
@@ -137,7 +138,7 @@ constexpr Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept
constexpr Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept
{
static_assert(std::numeric_limits<double>::has_signaling_NaN,
- "platform has no definition for signaling NaN for type double");
+ "platform has no definition for signaling NaN for type double");
return std::numeric_limits<double>::signaling_NaN();
}
#endif
@@ -146,7 +147,7 @@ constexpr Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept
constexpr Q_DECL_CONST_FUNCTION static inline double qt_qnan() noexcept
{
static_assert(std::numeric_limits<double>::has_quiet_NaN,
- "platform has no definition for quiet NaN for type double");
+ "platform has no definition for quiet NaN for type double");
return std::numeric_limits<double>::quiet_NaN();
}
@@ -202,7 +203,8 @@ namespace {
This function works for v containing infinities, but not NaN. It's the
caller's responsibility to exclude that possibility before calling it.
*/
-template <typename T> static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgrade = true)
+template<typename T>
+static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgrade = true)
{
static_assert(std::numeric_limits<T>::is_integer);
@@ -255,6 +257,7 @@ QT_WARNING_POP
#if ((defined(Q_CC_INTEL) ? (Q_CC_INTEL >= 1800 && !defined(Q_OS_WIN)) : defined(Q_CC_GNU)) \
&& Q_CC_GNU >= 500) || __has_builtin(__builtin_add_overflow)
// GCC 5, ICC 18, and Clang 3.8 have builtins to detect overflows
+#define Q_INTRINSIC_MUL_OVERFLOW64
template <typename T> inline
typename std::enable_if<std::is_unsigned<T>::value || std::is_signed<T>::value, bool>::type
@@ -409,6 +412,83 @@ template <> inline bool add_overflow(quint64 v1, quint64 v2, quint64 *r)
}
# endif // MSVC X86
#endif // !GCC
+
+// Implementations for addition, subtraction or multiplication by a
+// compile-time constant. For addition and subtraction, we simply call the code
+// that detects overflow at runtime. For multiplication, we compare to the
+// maximum possible values before multiplying to ensure no overflow happens.
+
+template <typename T, T V2> bool add_overflow(T v1, std::integral_constant<T, V2>, T *r)
+{
+ return add_overflow(v1, V2, r);
+}
+
+template <auto V2, typename T> bool add_overflow(T v1, T *r)
+{
+ return add_overflow(v1, std::integral_constant<T, V2>{}, r);
+}
+
+template <typename T, T V2> bool sub_overflow(T v1, std::integral_constant<T, V2>, T *r)
+{
+ return sub_overflow(v1, V2, r);
+}
+
+template <auto V2, typename T> bool sub_overflow(T v1, T *r)
+{
+ return sub_overflow(v1, std::integral_constant<T, V2>{}, r);
+}
+
+template <typename T, T V2> bool mul_overflow(T v1, std::integral_constant<T, V2>, T *r)
+{
+ // Runtime detection for anything smaller than or equal to a register
+ // width, as most architectures' multiplication instructions actually
+ // produce a result twice as wide as the input registers, allowing us to
+ // efficiently detect the overflow.
+ if constexpr (sizeof(T) <= sizeof(qregisteruint)) {
+ return mul_overflow(v1, V2, r);
+
+#ifdef Q_INTRINSIC_MUL_OVERFLOW64
+ } else if constexpr (sizeof(T) <= sizeof(quint64)) {
+ // If we have intrinsics detecting overflow of 64-bit multiplications,
+ // then detect overflows through them up to 64 bits.
+ return mul_overflow(v1, V2, r);
+#endif
+
+ } else if constexpr (V2 == 0 || V2 == 1) {
+ // trivial cases (and simplify logic below due to division by zero)
+ *r = v1 * V2;
+ return false;
+ } else if constexpr (V2 == -1) {
+ // multiplication by -1 is valid *except* for signed minimum values
+ // (necessary to avoid diving min() by -1, which is an overflow)
+ if (v1 < 0 && v1 == std::numeric_limits<T>::min())
+ return true;
+ *r = -v1;
+ return false;
+ } else {
+ // For 64-bit multiplications on 32-bit platforms, let's instead compare v1
+ // against the bounds that would overflow.
+ constexpr T Highest = std::numeric_limits<T>::max() / V2;
+ constexpr T Lowest = std::numeric_limits<T>::min() / V2;
+ if constexpr (Highest > Lowest) {
+ if (v1 > Highest || v1 < Lowest)
+ return true;
+ } else {
+ // this can only happen if V2 < 0
+ static_assert(V2 < 0);
+ if (v1 > Lowest || v1 < Highest)
+ return true;
+ }
+
+ *r = v1 * V2;
+ return false;
+ }
+}
+
+template <auto V2, typename T> bool mul_overflow(T v1, T *r)
+{
+ return mul_overflow(v1, std::integral_constant<T, V2>{}, r);
+}
}
#endif // Q_CLANG_QDOC
diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp
index 6a0b86dd6e..ca16566c1c 100644
--- a/src/corelib/global/qrandom.cpp
+++ b/src/corelib/global/qrandom.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 Intel Corporation.
+** Copyright (C) 2020 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -181,7 +181,8 @@ struct QRandomGenerator::SystemGenerator
// For std::mersenne_twister_engine implementations that use something
// other than quint32 (unsigned int) to fill their buffers.
- template <typename T> void generate(T *begin, T *end)
+ template<typename T>
+ void generate(T *begin, T *end)
{
static_assert(sizeof(T) >= sizeof(quint32));
if (sizeof(T) == sizeof(quint32)) {
@@ -360,15 +361,13 @@ struct QRandomGenerator::SystemAndGlobalGenerators
SystemGenerator sys;
alignas(64) std::aligned_storage<sizeof(QRandomGenerator64), 64>::type global_;
-#ifdef Q_COMPILER_CONSTEXPR
constexpr SystemAndGlobalGenerators()
: globalPRNGMutex{}, system_{0}, sys{}, global_{}
{}
-#endif
void confirmLiteral()
{
-#if defined(Q_COMPILER_CONSTEXPR) && !defined(Q_CC_MSVC) && !defined(Q_OS_INTEGRITY)
+#if !defined(Q_CC_MSVC) && !defined(Q_OS_INTEGRITY)
// Currently fails to compile with MSVC 2017, saying QBasicMutex is not
// a literal type. Disassembly with MSVC 2013 and 2015 shows it is
// actually a literal; MSVC 2017 has a bug relating to this, so we're
@@ -414,7 +413,8 @@ struct QRandomGenerator::SystemAndGlobalGenerators
new (&rng->storage.engine()) RandomEngine(self()->sys);
}
- struct PRNGLocker {
+ struct PRNGLocker
+ {
const bool locked;
PRNGLocker(const QRandomGenerator *that)
: locked(that == globalNoInit())
@@ -691,12 +691,11 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
*/
/*!
- \fn bool operator!=(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
- \relates QRandomGenerator
+ \fn bool QRandomGenerator::operator!=(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
- Returns true if the two the two engines \a rng1 and \a rng2 are at
+ Returns \c true if the two the two engines \a rng1 and \a rng2 are at
different states or if one of them is reading from the operating system
- facilities and the other is not, false otherwise.
+ facilities and the other is not, \c false otherwise.
*/
/*!
@@ -876,7 +875,8 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
\a highest (exclusive). The same result may also be obtained by using
\l{http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution}{\c std::uniform_int_distribution}
with parameters 0 and \c{highest - 1}. That class can also be used to obtain
- quantities larger than 32 bits.
+ quantities larger than 32 bits; for 64 bits, the 64-bit bounded() overload
+ can be used too.
For example, to obtain a value between 0 and 255 (inclusive), one would write:
@@ -905,6 +905,45 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
*/
/*!
+ \fn quint64 QRandomGenerator::bounded(quint64 highest)
+ \overload
+
+ Generates one random 64-bit quantity in the range between 0 (inclusive) and
+ \a highest (exclusive). The same result may also be obtained by using
+ \l{http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution}{\c std::uniform_int_distribution<quint64>}
+ with parameters 0 and \c{highest - 1}.
+
+ Note that this function cannot be used to obtain values in the full 64-bit
+ range of \c{quint64}. Instead, use generate64().
+
+ \note This function is implemented as a loop, which depends on the random
+ value obtained. On the long run, on average it should loop just under 2
+ times, but if the random generator is defective, this function may take
+ considerably longer to execute.
+
+ \sa generate(), generate64(), generateDouble()
+ */
+
+/*!
+ \fn qint64 QRandomGenerator::bounded(qint64 highest)
+ \overload
+
+ Generates one random 64-bit quantity in the range between 0 (inclusive) and
+ \a highest (exclusive). \a highest must be positive.
+
+ Note that this function cannot be used to obtain values in the full 64-bit
+ range of \c{qint64}. Instead, use generate64() and cast to qint64 or instead
+ use the unsigned version of this function.
+
+ \note This function is implemented as a loop, which depends on the random
+ value obtained. On the long run, on average it should loop just under 2
+ times, but if the random generator is defective, this function may take
+ considerably longer to execute.
+
+ \sa generate(), generate64(), generateDouble()
+ */
+
+/*!
\fn quint32 QRandomGenerator::bounded(quint32 lowest, quint32 highest)
\overload
@@ -943,6 +982,60 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
*/
/*!
+ \fn quint64 QRandomGenerator::bounded(quint64 lowest, quint64 highest)
+ \overload
+
+ Generates one random 64-bit quantity in the range between \a lowest
+ (inclusive) and \a highest (exclusive). The \a highest parameter must be
+ greater than \a lowest.
+
+ The same result may also be obtained by using
+ \l{http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution}{\c std::uniform_int_distribution<quint64>}
+ with parameters \a lowest and \c{\a highest - 1}.
+
+ Note that this function cannot be used to obtain values in the full 64-bit
+ range of \c{quint64}. Instead, use generate64().
+
+ \note This function is implemented as a loop, which depends on the random
+ value obtained. On the long run, on average it should loop just under 2
+ times, but if the random generator is defective, this function may take
+ considerably longer to execute.
+
+ \sa generate(), generate64(), generateDouble()
+ */
+
+/*!
+ \fn qint64 QRandomGenerator::bounded(qint64 lowest, qint64 highest)
+ \overload
+
+ Generates one random 64-bit quantity in the range between \a lowest
+ (inclusive) and \a highest (exclusive), both of which may be negative, but
+ \a highest must be greater than \a lowest.
+
+ Note that this function cannot be used to obtain values in the full 64-bit
+ range of \c{qint64}. Instead, use generate64() and cast to qint64.
+
+ \note This function is implemented as a loop, which depends on the random
+ value obtained. On the long run, on average it should loop just under 2
+ times, but if the random generator is defective, this function may take
+ considerably longer to execute.
+
+ \sa generate(), generate64(), generateDouble()
+ */
+
+/*!
+ \fn qint64 QRandomGenerator::bounded(int lowest, qint64 highest)
+ \fn qint64 QRandomGenerator::bounded(qint64 lowest, int highest)
+ \fn quint64 QRandomGenerator::bounded(unsigned lowest, quint64 highest)
+ \fn quint64 QRandomGenerator::bounded(quint64 lowest, unsigned highest)
+ \overload
+
+ This function exists to help with overload resolution when the types of the
+ parameters don't exactly match. They will promote the smaller type to the
+ type of the larger one and call the correct overload.
+ */
+
+/*!
\fn QRandomGenerator *QRandomGenerator::system()
\threadsafe
@@ -1177,22 +1270,32 @@ bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
/*!
\internal
- Fills the range pointed by \a buffer and \a bufferEnd with 32-bit random
- values. The buffer must be correctly aligned.
+ Fills the range pointed by \a buffer with \a count 32-bit random values.
+ The buffer must be correctly aligned.
+
+ Returns the value of the first two 32-bit entries as a \c{quint64}.
*/
-void QRandomGenerator::_fillRange(void *buffer, void *bufferEnd)
+quint64 QRandomGenerator::_fillRange(void *buffer, qptrdiff count)
{
// Verify that the pointers are properly aligned for 32-bit
Q_ASSERT(quintptr(buffer) % sizeof(quint32) == 0);
- Q_ASSERT(quintptr(bufferEnd) % sizeof(quint32) == 0);
- quint32 *begin = static_cast<quint32 *>(buffer);
- quint32 *end = static_cast<quint32 *>(bufferEnd);
-
- if (type == SystemRNG || Q_UNLIKELY(uint(qt_randomdevice_control.loadAcquire()) & (UseSystemRNG|SetRandomData)))
- return SystemGenerator::self().generate(begin, end);
+ Q_ASSERT(count >= 0);
+ Q_ASSERT(buffer || count <= 2);
+
+ quint64 dummy;
+ quint32 *begin = static_cast<quint32 *>(buffer ? buffer : &dummy);
+ quint32 *end = begin + count;
+
+ if (type == SystemRNG || Q_UNLIKELY(uint(qt_randomdevice_control.loadAcquire()) & (UseSystemRNG|SetRandomData))) {
+ SystemGenerator::self().generate(begin, end);
+ } else {
+ SystemAndGlobalGenerators::PRNGLocker lock(this);
+ std::generate(begin, end, [this]() { return storage.engine()(); });
+ }
- SystemAndGlobalGenerators::PRNGLocker lock(this);
- std::generate(begin, end, [this]() { return storage.engine()(); });
+ if (end - begin == 1)
+ return *begin;
+ return begin[0] | (quint64(begin[1]) << 32);
}
namespace {
diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h
index 7bb90de2bb..d6b8bd742e 100644
--- a/src/corelib/global/qrandom.h
+++ b/src/corelib/global/qrandom.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 Intel Corporation.
+** Copyright (C) 2020 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -40,7 +40,7 @@
#ifndef QRANDOM_H
#define QRANDOM_H
-#include <QtCore/qglobal.h>
+#include <QtCore/qalgorithms.h>
#include <algorithm> // for std::generate
#include <random> // for std::mt19937
@@ -83,16 +83,12 @@ public:
quint32 generate()
{
- quint32 ret;
- fillRange(&ret, 1);
- return ret;
+ return _fillRange(nullptr, 1);
}
quint64 generate64()
{
- quint32 buf[2];
- fillRange(buf);
- return buf[0] | (quint64(buf[1]) << 32);
+ return _fillRange(nullptr, sizeof(quint64) / sizeof(quint32));
}
double generateDouble()
@@ -139,16 +135,54 @@ public:
return bounded(highest - lowest) + lowest;
}
+ quint64 bounded(quint64 highest);
+
+ quint64 bounded(quint64 lowest, quint64 highest)
+ {
+ Q_ASSERT(highest > lowest);
+ return bounded(highest - lowest) + lowest;
+ }
+
+ qint64 bounded(qint64 highest)
+ {
+ Q_ASSERT(highest > 0);
+ return qint64(bounded(quint64(0), quint64(highest)));
+ }
+
+ qint64 bounded(qint64 lowest, qint64 highest)
+ {
+ return bounded(highest - lowest) + lowest;
+ }
+
+ // these functions here only to help with ambiguous overloads
+ qint64 bounded(int lowest, qint64 highest)
+ {
+ return bounded(qint64(lowest), qint64(highest));
+ }
+ qint64 bounded(qint64 lowest, int highest)
+ {
+ return bounded(qint64(lowest), qint64(highest));
+ }
+
+ quint64 bounded(unsigned lowest, quint64 highest)
+ {
+ return bounded(quint64(lowest), quint64(highest));
+ }
+ quint64 bounded(quint64 lowest, unsigned highest)
+ {
+ return bounded(quint64(lowest), quint64(highest));
+ }
+
template <typename UInt, IfValidUInt<UInt> = true>
void fillRange(UInt *buffer, qsizetype count)
{
- _fillRange(buffer, buffer + count);
+ _fillRange(buffer, count * sizeof(UInt) / sizeof(quint32));
}
template <typename UInt, size_t N, IfValidUInt<UInt> = true>
void fillRange(UInt (&buffer)[N])
{
- _fillRange(buffer, buffer + N);
+ _fillRange(buffer, N * sizeof(UInt) / sizeof(quint32));
}
// API like std::seed_seq
@@ -160,7 +194,7 @@ public:
void generate(quint32 *begin, quint32 *end)
{
- _fillRange(begin, end);
+ _fillRange(begin, end - begin);
}
// API like std:: random engines
@@ -181,7 +215,7 @@ protected:
QRandomGenerator(System);
private:
- Q_CORE_EXPORT void _fillRange(void *buffer, void *bufferEnd);
+ Q_CORE_EXPORT quint64 _fillRange(void *buffer, qptrdiff count);
friend class QRandomGenerator64;
struct SystemGenerator;
@@ -253,6 +287,24 @@ public:
#endif // Q_QDOC
};
+inline quint64 QRandomGenerator::bounded(quint64 highest)
+{
+ // Implement an algorithm similar to libc++'s uniform_int_distribution:
+ // loop around getting a random number, mask off any bits that "highest"
+ // will never need, then check if it's higher than "highest". The number of
+ // times the loop will run is unbounded but the probability of terminating
+ // is better than 1/2 on each iteration. Therefore, the average loop count
+ // should be less than 2.
+
+ const int width = qCountLeadingZeroBits(highest - 1);
+ const quint64 mask = (quint64(1) << (std::numeric_limits<quint64>::digits - width)) - 1;
+ quint64 v;
+ do {
+ v = generate64() & mask;
+ } while (v >= highest);
+ return v;
+}
+
inline QRandomGenerator *QRandomGenerator::system()
{
return QRandomGenerator64::system();
diff --git a/src/corelib/global/qrandom_p.h b/src/corelib/global/qrandom_p.h
index 934a9282b8..052aef262e 100644
--- a/src/corelib/global/qrandom_p.h
+++ b/src/corelib/global/qrandom_p.h
@@ -76,13 +76,12 @@ Q_CORE_EXPORT QBasicAtomicInteger<uint> qt_randomdevice_control = Q_BASIC_ATOMIC
#elif defined(QT_BUILD_INTERNAL)
extern Q_CORE_EXPORT QBasicAtomicInteger<uint> qt_randomdevice_control;
#else
-static const struct {
+static const struct
+{
uint loadAcquire() const { return 0; }
} qt_randomdevice_control;
#endif
-
-
QT_END_NAMESPACE
#endif // QRANDOM_P_H
diff --git a/src/corelib/global/qsimd.cpp b/src/corelib/global/qsimd.cpp
index d91c1542c2..c2db117853 100644
--- a/src/corelib/global/qsimd.cpp
+++ b/src/corelib/global/qsimd.cpp
@@ -428,38 +428,46 @@ static quint64 detectProcessorFeatures()
// QSimpleBuffer, which has the bare minimum needed to use memory
// dynamically and read lines from /proc/cpuinfo of arbitrary sizes.
//
-struct QSimpleBuffer {
+struct QSimpleBuffer
+{
static const int chunk_size = 256;
char *data;
unsigned alloc;
unsigned size;
- QSimpleBuffer(): data(0), alloc(0), size(0) {}
+ QSimpleBuffer() : data(nullptr), alloc(0), size(0) { }
~QSimpleBuffer() { ::free(data); }
- void resize(unsigned newsize) {
+ void resize(unsigned newsize)
+ {
if (newsize > alloc) {
unsigned newalloc = chunk_size * ((newsize / chunk_size) + 1);
- if (newalloc < newsize) newalloc = newsize;
+ if (newalloc < newsize)
+ newalloc = newsize;
if (newalloc != alloc) {
- data = static_cast<char*>(::realloc(data, newalloc));
+ data = static_cast<char *>(::realloc(data, newalloc));
alloc = newalloc;
}
}
size = newsize;
}
- void append(const QSimpleBuffer &other, unsigned appendsize) {
+ void append(const QSimpleBuffer &other, unsigned appendsize)
+ {
unsigned oldsize = size;
resize(oldsize + appendsize);
::memcpy(data + oldsize, other.data, appendsize);
}
- void popleft(unsigned amount) {
- if (amount >= size) return resize(0);
+ void popleft(unsigned amount)
+ {
+ if (amount >= size)
+ return resize(0);
size -= amount;
::memmove(data, data + amount, size);
}
- char* cString() {
- if (!alloc) resize(1);
+ char *cString()
+ {
+ if (!alloc)
+ resize(1);
return (data[size] = '\0', data);
}
};
@@ -473,7 +481,7 @@ struct QSimpleBuffer {
static void bufReadLine(int fd, QSimpleBuffer &line, QSimpleBuffer &buffer)
{
for (;;) {
- char *newline = static_cast<char*>(::memchr(buffer.data, '\n', buffer.size));
+ char *newline = static_cast<char *>(::memchr(buffer.data, '\n', buffer.size));
if (newline) {
unsigned piece_size = newline - buffer.data + 1;
line.append(buffer, piece_size);
@@ -486,9 +494,12 @@ static void bufReadLine(int fd, QSimpleBuffer &line, QSimpleBuffer &buffer)
buffer.resize(buffer.size + QSimpleBuffer::chunk_size);
buffer.size = oldsize;
}
- ssize_t read_bytes = ::qt_safe_read(fd, buffer.data + buffer.size, QSimpleBuffer::chunk_size);
- if (read_bytes > 0) buffer.size += read_bytes;
- else return;
+ ssize_t read_bytes =
+ ::qt_safe_read(fd, buffer.data + buffer.size, QSimpleBuffer::chunk_size);
+ if (read_bytes > 0)
+ buffer.size += read_bytes;
+ else
+ return;
}
}
@@ -509,7 +520,7 @@ static bool procCpuinfoContains(const char *prefix, const char *string)
do {
line.resize(0);
bufReadLine(cpuinfo_fd, line, buffer);
- char *colon = static_cast<char*>(::memchr(line.data, ':', line.size));
+ char *colon = static_cast<char *>(::memchr(line.data, ':', line.size));
if (colon && line.size > prefix_len + string_len) {
if (!::strncmp(prefix, line.data, prefix_len)) {
// prefix matches, next character must be ':' or space
@@ -657,10 +668,10 @@ static QT_FUNCTION_TARGET(RDSEED) unsigned *qt_random_rdseed(unsigned *ptr, unsi
// If the independent bit generator used by RDSEED is out of entropy, it
// may take time to replenish.
// https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide
- while (ptr + sizeof(randuint)/sizeof(*ptr) <= end) {
+ while (ptr + sizeof(randuint) / sizeof(*ptr) <= end) {
if (_rdseedXX_step(reinterpret_cast<randuint *>(ptr)) == 0)
goto out;
- ptr += sizeof(randuint)/sizeof(*ptr);
+ ptr += sizeof(randuint) / sizeof(*ptr);
}
if (sizeof(*ptr) != sizeof(randuint) && ptr != end) {
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index a6d9104d2d..89e761c662 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -50,7 +50,8 @@ QT_BEGIN_NAMESPACE
*/
class QString;
-class Q_CORE_EXPORT QSysInfo {
+class Q_CORE_EXPORT QSysInfo
+{
public:
enum Sizes {
WordSize = (sizeof(void *)<<3)
diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h
index 67ba27f072..7ffe313f00 100644
--- a/src/corelib/global/qt_windows.h
+++ b/src/corelib/global/qt_windows.h
@@ -54,7 +54,7 @@
# define _WIN32_WINNT 0x601
# endif
# ifndef NTDDI_VERSION
-# define NTDDI_VERSION 0x06000000
+# define NTDDI_VERSION 0x06010000
# endif
#endif
diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h
index c0617a41f2..e5914414f2 100644
--- a/src/corelib/global/qtypeinfo.h
+++ b/src/corelib/global/qtypeinfo.h
@@ -55,7 +55,7 @@ class QDebug;
*/
template <typename T>
-static constexpr bool qIsRelocatable = std::is_trivially_copyable_v<T> && std::is_trivially_destructible_v<T>;
+inline constexpr bool qIsRelocatable = std::is_trivially_copyable_v<T> && std::is_trivially_destructible_v<T>;
/*
The catch-all template.
@@ -117,9 +117,8 @@ public:
};
#define Q_DECLARE_MOVABLE_CONTAINER(CONTAINER) \
-template <typename T> class CONTAINER; \
-template <typename T> \
-class QTypeInfo< CONTAINER<T> > \
+template <typename ...T> \
+class QTypeInfo<CONTAINER<T...>> \
{ \
public: \
enum { \
@@ -134,27 +133,11 @@ Q_DECLARE_MOVABLE_CONTAINER(QList);
Q_DECLARE_MOVABLE_CONTAINER(QQueue);
Q_DECLARE_MOVABLE_CONTAINER(QStack);
Q_DECLARE_MOVABLE_CONTAINER(QSet);
-
-#undef Q_DECLARE_MOVABLE_CONTAINER
-
-#define Q_DECLARE_MOVABLE_CONTAINER(CONTAINER) \
-template <typename K, typename V> class CONTAINER; \
-template <typename K, typename V> \
-class QTypeInfo< CONTAINER<K, V> > \
-{ \
-public: \
- enum { \
- isPointer = false, \
- isIntegral = false, \
- isComplex = true, \
- isRelocatable = true, \
- }; \
-}
-
Q_DECLARE_MOVABLE_CONTAINER(QMap);
Q_DECLARE_MOVABLE_CONTAINER(QMultiMap);
Q_DECLARE_MOVABLE_CONTAINER(QHash);
Q_DECLARE_MOVABLE_CONTAINER(QMultiHash);
+Q_DECLARE_MOVABLE_CONTAINER(QCache);
#undef Q_DECLARE_MOVABLE_CONTAINER
@@ -205,7 +188,7 @@ Q_DECLARE_TYPEINFO_BODY(QFlags<T>, Q_PRIMITIVE_TYPE);
namespace as Qt for this to work.
If the type was already released without Q_DECLARE_SHARED applied,
- _and_ without an explicit Q_DECLARE_TYPEINFO(type, Q_MOVABLE_TYPE),
+ _and_ without an explicit Q_DECLARE_TYPEINFO(type, Q_RELOCATABLE_TYPE),
then use Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(type) to mark the
type shared (incl. swap()), without marking it movable (which
would change the memory layout of QList, a BiC change.
@@ -216,9 +199,9 @@ Q_DECLARE_TYPEINFO(TYPE, FLAGS); \
inline void swap(TYPE &value1, TYPE &value2) \
noexcept(noexcept(value1.swap(value2))) \
{ value1.swap(value2); }
-#define Q_DECLARE_SHARED(TYPE) Q_DECLARE_SHARED_IMPL(TYPE, Q_MOVABLE_TYPE)
+#define Q_DECLARE_SHARED(TYPE) Q_DECLARE_SHARED_IMPL(TYPE, Q_RELOCATABLE_TYPE)
#define Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(TYPE) \
- Q_DECLARE_SHARED_IMPL(TYPE, QT_VERSION >= QT_VERSION_CHECK(6,0,0) ? Q_MOVABLE_TYPE : Q_RELOCATABLE_TYPE)
+ Q_DECLARE_SHARED_IMPL(TYPE, Q_RELOCATABLE_TYPE)
namespace QTypeTraits
{
@@ -250,11 +233,14 @@ struct is_container<T, std::void_t<
// Checks the existence of the comparison operator for the class itself
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_FLOAT_COMPARE
template <typename, typename = void>
struct has_operator_equal : std::false_type {};
template <typename T>
struct has_operator_equal<T, std::void_t<decltype(bool(std::declval<const T&>() == std::declval<const T&>()))>>
: std::true_type {};
+QT_WARNING_POP
// Two forward declarations
template<typename T, bool = is_container<T>::value>
@@ -332,17 +318,17 @@ struct is_dereferenceable<T, std::void_t<decltype(std::declval<T>().operator->()
: std::true_type {};
template <typename T>
-constexpr bool is_dereferenceable_v = is_dereferenceable<T>::value;
+inline constexpr bool is_dereferenceable_v = is_dereferenceable<T>::value;
template<typename T>
struct has_operator_equal : detail::expand_operator_equal<T> {};
template<typename T>
-constexpr bool has_operator_equal_v = has_operator_equal<T>::value;
+inline constexpr bool has_operator_equal_v = has_operator_equal<T>::value;
template<typename T>
struct has_operator_less_than : detail::expand_operator_less_than<T> {};
template<typename T>
-constexpr bool has_operator_less_than_v = has_operator_less_than<T>::value;
+inline constexpr bool has_operator_less_than_v = has_operator_less_than<T>::value;
template <typename ...T>
using compare_eq_result = std::enable_if_t<std::conjunction_v<QTypeTraits::has_operator_equal<T>...>, bool>;
@@ -353,7 +339,7 @@ using compare_lt_result = std::enable_if_t<std::conjunction_v<QTypeTraits::has_o
namespace detail {
template<typename T>
-const T const_value();
+const T &const_reference();
template<typename T>
T &reference();
@@ -362,10 +348,10 @@ T &reference();
template <typename Stream, typename, typename = void>
struct has_ostream_operator : std::false_type {};
template <typename Stream, typename T>
-struct has_ostream_operator<Stream, T, std::void_t<decltype(detail::reference<Stream>() << detail::const_value<T>())>>
+struct has_ostream_operator<Stream, T, std::void_t<decltype(detail::reference<Stream>() << detail::const_reference<T>())>>
: std::true_type {};
template <typename Stream, typename T>
-constexpr bool has_ostream_operator_v = has_ostream_operator<Stream, T>::value;
+inline constexpr bool has_ostream_operator_v = has_ostream_operator<Stream, T>::value;
template <typename Stream, typename, typename = void>
struct has_istream_operator : std::false_type {};
@@ -373,10 +359,10 @@ template <typename Stream, typename T>
struct has_istream_operator<Stream, T, std::void_t<decltype(detail::reference<Stream>() >> detail::reference<T>())>>
: std::true_type {};
template <typename Stream, typename T>
-constexpr bool has_istream_operator_v = has_istream_operator<Stream, T>::value;
+inline constexpr bool has_istream_operator_v = has_istream_operator<Stream, T>::value;
template <typename Stream, typename T>
-constexpr bool has_stream_operator_v = has_ostream_operator_v<Stream, T> && has_istream_operator_v<Stream, T>;
+inline constexpr bool has_stream_operator_v = has_ostream_operator_v<Stream, T> && has_istream_operator_v<Stream, T>;
}
diff --git a/src/corelib/io/PSL-LICENSE.txt b/src/corelib/io/PSL-LICENSE.txt
deleted file mode 100644
index d0a1fa1482..0000000000
--- a/src/corelib/io/PSL-LICENSE.txt
+++ /dev/null
@@ -1,373 +0,0 @@
-Mozilla Public License Version 2.0
-==================================
-
-1. Definitions
---------------
-
-1.1. "Contributor"
- means each individual or legal entity that creates, contributes to
- the creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
- means the combination of the Contributions of others (if any) used
- by a Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
- means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
- means Source Code Form to which the initial Contributor has attached
- the notice in Exhibit A, the Executable Form of such Source Code
- Form, and Modifications of such Source Code Form, in each case
- including portions thereof.
-
-1.5. "Incompatible With Secondary Licenses"
- means
-
- (a) that the initial Contributor has attached the notice described
- in Exhibit B to the Covered Software; or
-
- (b) that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the
- terms of a Secondary License.
-
-1.6. "Executable Form"
- means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
- means a work that combines Covered Software with other material, in
- a separate file or files, that is not Covered Software.
-
-1.8. "License"
- means this document.
-
-1.9. "Licensable"
- means having the right to grant, to the maximum extent possible,
- whether at the time of the initial grant or subsequently, any and
- all of the rights conveyed by this License.
-
-1.10. "Modifications"
- means any of the following:
-
- (a) any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered
- Software; or
-
- (b) any new file in Source Code Form that contains any Covered
- Software.
-
-1.11. "Patent Claims" of a Contributor
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the
- License, by the making, using, selling, offering for sale, having
- made, import, or transfer of either its Contributions or its
- Contributor Version.
-
-1.12. "Secondary License"
- means either the GNU General Public License, Version 2.0, the GNU
- Lesser General Public License, Version 2.1, the GNU Affero General
- Public License, Version 3.0, or any later versions of those
- licenses.
-
-1.13. "Source Code Form"
- means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
- means an individual or a legal entity exercising rights under this
- License. For legal entities, "You" includes any entity that
- controls, is controlled by, or is under common control with You. For
- purposes of this definition, "control" means (a) the power, direct
- or indirect, to cause the direction or management of such entity,
- whether by contract or otherwise, or (b) ownership of more than
- fifty percent (50%) of the outstanding shares or beneficial
- ownership of such entity.
-
-2. License Grants and Conditions
---------------------------------
-
-2.1. Grants
-
-Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-
-(b) under Patent Claims of such Contributor to make, use, sell, offer
- for sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
-
-2.2. Effective Date
-
-The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
-The licenses granted in this Section 2 are the only rights granted under
-this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
-
-(a) for any code that a Contributor has removed from Covered Software;
- or
-
-(b) for infringements caused by: (i) Your and any other third party's
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
-(c) under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
-No Contributor makes additional grants as a result of Your choice to
-distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
-
-2.5. Representation
-
-Each Contributor represents that the Contributor believes its
-Contributions are its original creation(s) or it has sufficient rights
-to grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
-This License is not intended to limit any rights You have under
-applicable copyright doctrines of fair use, fair dealing, or other
-equivalents.
-
-2.7. Conditions
-
-Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
-in Section 2.1.
-
-3. Responsibilities
--------------------
-
-3.1. Distribution of Source Form
-
-All distribution of Covered Software in Source Code Form, including any
-Modifications that You create or to which You contribute, must be under
-the terms of this License. You must inform recipients that the Source
-Code Form of the Covered Software is governed by the terms of this
-License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
-
-3.2. Distribution of Executable Form
-
-If You distribute Covered Software in Executable Form then:
-
-(a) such Covered Software must also be made available in Source Code
- Form, as described in Section 3.1, and You must inform recipients of
- the Executable Form how they can obtain a copy of such Source Code
- Form by reasonable means in a timely manner, at a charge no more
- than the cost of distribution to the recipient; and
-
-(b) You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter
- the recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
-You may create and distribute a Larger Work under terms of Your choice,
-provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
-
-3.4. Notices
-
-You may not remove or alter the substance of any license notices
-(including copyright notices, patent notices, disclaimers of warranty,
-or limitations of liability) contained within the Source Code Form of
-the Covered Software, except that You may alter any license notices to
-the extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
----------------------------------------------------
-
-If it is impossible for You to comply with any of the terms of this
-License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: (a) comply with
-the terms of this License to the maximum extent possible; and (b)
-describe the limitations and the code they affect. Such description must
-be placed in a text file included with all distributions of the Covered
-Software under this License. Except to the extent prohibited by statute
-or regulation, such description must be sufficiently detailed for a
-recipient of ordinary skill to be able to understand it.
-
-5. Termination
---------------
-
-5.1. The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated (a) provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and (b) on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
-infringement claim (excluding declaratory judgment actions,
-counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
-You by any and all Contributors for the Covered Software under Section
-2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all
-end user license agreements (excluding distributors and resellers) which
-have been validly granted by You or Your distributors under this License
-prior to termination shall survive termination.
-
-************************************************************************
-* *
-* 6. Disclaimer of Warranty *
-* ------------------------- *
-* *
-* Covered Software is provided under this License on an "as is" *
-* basis, without warranty of any kind, either expressed, implied, or *
-* statutory, including, without limitation, warranties that the *
-* Covered Software is free of defects, merchantable, fit for a *
-* particular purpose or non-infringing. The entire risk as to the *
-* quality and performance of the Covered Software is with You. *
-* Should any Covered Software prove defective in any respect, You *
-* (not any Contributor) assume the cost of any necessary servicing, *
-* repair, or correction. This disclaimer of warranty constitutes an *
-* essential part of this License. No use of any Covered Software is *
-* authorized under this License except under this disclaimer. *
-* *
-************************************************************************
-
-************************************************************************
-* *
-* 7. Limitation of Liability *
-* -------------------------- *
-* *
-* Under no circumstances and under no legal theory, whether tort *
-* (including negligence), contract, or otherwise, shall any *
-* Contributor, or anyone who distributes Covered Software as *
-* permitted above, be liable to You for any direct, indirect, *
-* special, incidental, or consequential damages of any character *
-* including, without limitation, damages for lost profits, loss of *
-* goodwill, work stoppage, computer failure or malfunction, or any *
-* and all other commercial damages or losses, even if such party *
-* shall have been informed of the possibility of such damages. This *
-* limitation of liability shall not apply to liability for death or *
-* personal injury resulting from such party's negligence to the *
-* extent applicable law prohibits such limitation. Some *
-* jurisdictions do not allow the exclusion or limitation of *
-* incidental or consequential damages, so this exclusion and *
-* limitation may not apply to You. *
-* *
-************************************************************************
-
-8. Litigation
--------------
-
-Any litigation relating to this License may be brought only in the
-courts of a jurisdiction where the defendant maintains its principal
-place of business and such litigation shall be governed by laws of that
-jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
-cross-claims or counter-claims.
-
-9. Miscellaneous
-----------------
-
-This License represents the complete agreement concerning the subject
-matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent
-necessary to make it enforceable. Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-shall not be used to construe this License against a Contributor.
-
-10. Versions of the License
----------------------------
-
-10.1. New Versions
-
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
-
-10.2. Effect of New Versions
-
-You may distribute the Covered Software under the terms of the version
-of the License under which You originally received the Covered Software,
-or under the terms of any subsequent version published by the license
-steward.
-
-10.3. Modified Versions
-
-If you create software not governed by this License, and you want to
-create a new license for such software, you may create and use a
-modified version of this License if you rename the license and remove
-any references to the name of the license steward (except to note that
-such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
-Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
--------------------------------------------
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular
-file, then You may include the notice in a location (such as a LICENSE
-file in a relevant directory) where a recipient would be likely to look
-for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
----------------------------------------------------------
-
- This Source Code Form is "Incompatible With Secondary Licenses", as
- defined by the Mozilla Public License, v. 2.0.
diff --git a/src/corelib/io/qbuffer.h b/src/corelib/io/qbuffer.h
index 39e1e7b39d..c2aba92a10 100644
--- a/src/corelib/io/qbuffer.h
+++ b/src/corelib/io/qbuffer.h
@@ -45,7 +45,6 @@
QT_BEGIN_NAMESPACE
-
class QObject;
class QBufferPrivate;
@@ -57,11 +56,11 @@ class Q_CORE_EXPORT QBuffer : public QIODevice
public:
#ifndef QT_NO_QOBJECT
- explicit QBuffer(QObject *parent = nullptr);
- QBuffer(QByteArray *buf, QObject *parent = nullptr);
+ explicit QBuffer(QObject *parent = nullptr);
+ QBuffer(QByteArray *buf, QObject *parent = nullptr);
#else
- QBuffer();
- explicit QBuffer(QByteArray *buf);
+ QBuffer();
+ explicit QBuffer(QByteArray *buf);
#endif
~QBuffer();
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index c711c28f62..b1ebf097cf 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -663,6 +663,23 @@ QDebug &QDebug::resetFormat()
*/
/*!
+ \since 6.0
+ \fn QDebug &QDebug::operator<<(QUtf8StringView s)
+
+ Writes the string view, \a s, to the stream and returns a reference to the
+ stream.
+
+ Normally, QDebug prints the data inside quotes and transforms control or
+ non-US-ASCII characters to their C escape sequences (\\xAB). This way, the
+ output is always 7-bit clean and the string can be copied from the output
+ and pasted back into C++ sources, if necessary.
+
+ To print non-printable characters without transformation, enable the
+ noquote() functionality. Note that some QDebug backends might not be 8-bit
+ clean.
+*/
+
+/*!
\fn QDebug &QDebug::operator<<(QLatin1String t)
Writes the string, \a t, to the stream and returns a reference to the
@@ -698,6 +715,25 @@ QDebug &QDebug::resetFormat()
*/
/*!
+ \since 6.0
+ \fn QDebug &QDebug::operator<<(QByteArrayView t)
+
+ Writes the data of the observed byte array, \a t, to the stream and returns
+ a reference to the stream.
+
+ Normally, QDebug prints the data inside quotes and transforms control or
+ non-US-ASCII characters to their C escape sequences (\\xAB). This way, the
+ output is always 7-bit clean and the string can be copied from the output
+ and pasted back into C++ sources, if necessary.
+
+ To print non-printable characters without transformation, enable the
+ noquote() functionality. Note that some QDebug backends might not be 8-bit
+ clean.
+
+ See the QByteArray overload for examples.
+*/
+
+/*!
\fn QDebug &QDebug::operator<<(const void *t)
Writes a pointer, \a t, to the stream and returns a reference to the stream.
@@ -714,14 +750,7 @@ QDebug &QDebug::resetFormat()
*/
/*!
- \fn template <class T> QString QDebug::toString(const T &object)
- \since 6.0
-
- \include qdebug-toString.qdocinc
-*/
-
-/*!
- \fn template <class T> QString QDebug::toString(const T *object)
+ \fn template <class T> QString QDebug::toString(T &&object)
\since 6.0
\include qdebug-toString.qdocinc
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index 45af766db9..5e23c76cba 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -102,8 +102,7 @@ public:
QDebug(const QDebug &o) : stream(o.stream) { ++stream->ref; }
QDebug(QDebug &&other) noexcept : stream{qExchange(other.stream, nullptr)} {}
inline QDebug &operator=(const QDebug &other);
- QDebug &operator=(QDebug &&other) noexcept
- { QDebug{std::move(other)}.swap(*this); return *this; }
+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QDebug)
~QDebug();
inline void swap(QDebug &other) noexcept { qSwap(stream, other.stream); }
@@ -145,8 +144,10 @@ public:
inline QDebug &operator<<(const QString & t) { putString(t.constData(), uint(t.length())); return maybeSpace(); }
#endif
inline QDebug &operator<<(QStringView s) { putString(s.data(), size_t(s.size())); return maybeSpace(); }
+ inline QDebug &operator<<(QUtf8StringView s) { putByteArray(reinterpret_cast<const char*>(s.data()), s.size(), ContainsBinary); return maybeSpace(); }
inline QDebug &operator<<(QLatin1String t) { putByteArray(t.latin1(), t.size(), ContainsLatin1); return maybeSpace(); }
inline QDebug &operator<<(const QByteArray & t) { putByteArray(t.constData(), t.size(), ContainsBinary); return maybeSpace(); }
+ inline QDebug &operator<<(QByteArrayView t) { putByteArray(t.constData(), t.size(), ContainsBinary); return maybeSpace(); }
inline QDebug &operator<<(const void * t) { stream->ts << t; return maybeSpace(); }
inline QDebug &operator<<(std::nullptr_t) { stream->ts << "(nullptr)"; return maybeSpace(); }
inline QDebug &operator<<(QTextStreamFunction f) {
@@ -158,20 +159,11 @@ public:
{ stream->ts << m; return *this; }
template <typename T>
- static QString toString(const T &object)
+ static QString toString(T &&object)
{
QString buffer;
QDebug stream(&buffer);
- stream.nospace() << object;
- return buffer;
- }
-
- template <typename T>
- static QString toString(const T *object)
- {
- QString buffer;
- QDebug stream(&buffer);
- stream.nospace() << object;
+ stream.nospace() << std::forward<T>(object);
return buffer;
}
};
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 16fd09efdb..9dd0f4ac1d 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -63,6 +63,7 @@
#endif
#include <algorithm>
+#include <memory>
#include <stdlib.h>
QT_BEGIN_NAMESPACE
@@ -1022,12 +1023,12 @@ bool QDir::cd(const QString &dirName)
}
}
- QScopedPointer<QDirPrivate> dir(new QDirPrivate(*d_ptr.constData()));
+ std::unique_ptr<QDirPrivate> dir(new QDirPrivate(*d_ptr.constData()));
dir->setPath(newPath);
if (!dir->exists())
return false;
- d_ptr = dir.take();
+ d_ptr = dir.release();
return true;
}
@@ -1730,7 +1731,7 @@ bool QDir::isRelative() const
bool QDir::makeAbsolute()
{
const QDirPrivate *d = d_ptr.constData();
- QScopedPointer<QDirPrivate> dir;
+ std::unique_ptr<QDirPrivate> dir;
if (!!d->fileEngine) {
QString absolutePath = d->fileEngine->fileName(QAbstractFileEngine::AbsoluteName);
if (QDir::isRelativePath(absolutePath))
@@ -1743,7 +1744,7 @@ bool QDir::makeAbsolute()
dir.reset(new QDirPrivate(*d_ptr.constData()));
dir->setPath(d->absoluteDirEntry.filePath());
}
- d_ptr = dir.take(); // actually detach
+ d_ptr = dir.release(); // actually detach
return true;
}
diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h
index 8b8aa05223..86ab33a2fc 100644
--- a/src/corelib/io/qdir.h
+++ b/src/corelib/io/qdir.h
@@ -121,7 +121,7 @@ public:
~QDir();
QDir &operator=(const QDir &);
- QDir &operator=(QDir &&other) noexcept { swap(other); return *this; }
+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QDir)
void swap(QDir &other) noexcept
{ qSwap(d_ptr, other.d_ptr); }
@@ -213,7 +213,7 @@ public:
bool makeAbsolute();
bool operator==(const QDir &dir) const;
- inline bool operator!=(const QDir &dir) const { return !operator==(dir); }
+ inline bool operator!=(const QDir &dir) const { return !operator==(dir); }
bool remove(const QString &fileName);
bool rename(const QString &oldName, const QString &newName);
@@ -266,12 +266,8 @@ protected:
private:
friend class QDirIterator;
// Q_DECLARE_PRIVATE equivalent for shared data pointers
- QDirPrivate* d_func();
- inline const QDirPrivate* d_func() const
- {
- return d_ptr.constData();
- }
-
+ QDirPrivate *d_func();
+ const QDirPrivate *d_func() const { return d_ptr.constData(); }
};
Q_DECLARE_SHARED(QDir)
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index 7a6c4f1edb..9799c9b075 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -125,7 +125,7 @@ class QDirIteratorPrivate
{
public:
QDirIteratorPrivate(const QFileSystemEntry &entry, const QStringList &nameFilters,
- QDir::Filters filters, QDirIterator::IteratorFlags flags, bool resolveEngine = true);
+ QDir::Filters _filters, QDirIterator::IteratorFlags flags, bool resolveEngine = true);
void advance();
@@ -161,10 +161,10 @@ public:
\internal
*/
QDirIteratorPrivate::QDirIteratorPrivate(const QFileSystemEntry &entry, const QStringList &nameFilters,
- QDir::Filters filters, QDirIterator::IteratorFlags flags, bool resolveEngine)
+ QDir::Filters _filters, QDirIterator::IteratorFlags flags, bool resolveEngine)
: dirEntry(entry)
, nameFilters(nameFilters.contains(QLatin1String("*")) ? QStringList() : nameFilters)
- , filters(QDir::NoFilter == filters ? QDir::AllEntries : filters)
+ , filters(QDir::NoFilter == _filters ? QDir::AllEntries : _filters)
, iteratorFlags(flags)
{
#if QT_CONFIG(regularexpression)
@@ -355,9 +355,9 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf
// skip symlinks
const bool skipSymlinks = (filters & QDir::NoSymLinks);
const bool includeSystem = (filters & QDir::System);
- if(skipSymlinks && fi.isSymLink()) {
+ if (skipSymlinks && fi.isSymLink()) {
// The only reason to save this file is if it is a broken link and we are requesting system files.
- if(!includeSystem || fi.exists())
+ if (!includeSystem || fi.exists())
return false;
}
diff --git a/src/corelib/io/qdiriterator.h b/src/corelib/io/qdiriterator.h
index a8f769eac0..acfe040a26 100644
--- a/src/corelib/io/qdiriterator.h
+++ b/src/corelib/io/qdiriterator.h
@@ -44,9 +44,9 @@
QT_BEGIN_NAMESPACE
-
class QDirIteratorPrivate;
-class Q_CORE_EXPORT QDirIterator {
+class Q_CORE_EXPORT QDirIterator
+{
public:
enum IteratorFlag {
NoIteratorFlags = 0x0,
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 77c83d08b6..223745b73c 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -55,8 +55,6 @@
# include "qcoreapplication.h"
#endif
-#include <private/qmemory_p.h>
-
#ifdef QT_NO_QOBJECT
#define tr(X) QString::fromLatin1(X)
#endif
@@ -87,7 +85,7 @@ QFilePrivate::openExternalFile(int flags, int fd, QFile::FileHandleFlags handleF
Q_UNUSED(fd);
return false;
#else
- auto fs = qt_make_unique<QFSFileEngine>();
+ auto fs = std::make_unique<QFSFileEngine>();
auto fe = fs.get();
fileEngine = std::move(fs);
return fe->open(QIODevice::OpenMode(flags), fd, handleFlags);
@@ -102,7 +100,7 @@ QFilePrivate::openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handl
Q_UNUSED(fh);
return false;
#else
- auto fs = qt_make_unique<QFSFileEngine>();
+ auto fs = std::make_unique<QFSFileEngine>();
auto fe = fs.get();
fileEngine = std::move(fs);
return fe->open(QIODevice::OpenMode(flags), fh, handleFlags);
@@ -453,7 +451,7 @@ QFile::remove()
}
unsetError();
close();
- if(error() == QFile::NoError) {
+ if (error() == QFile::NoError) {
if (d->engine()->remove()) {
unsetError();
return true;
@@ -630,7 +628,7 @@ QFile::rename(const QString &newName)
}
unsetError();
close();
- if(error() == QFile::NoError) {
+ if (error() == QFile::NoError) {
if (changingCase ? d->engine()->renameOverwrite(newName) : d->engine()->rename(newName)) {
unsetError();
// engine was able to handle the new name so we just reset it
@@ -661,7 +659,7 @@ QFile::rename(const QString &newName)
d->setError(QFile::RenameError, errorString());
error = true;
}
- if(!error) {
+ if (!error) {
if (!remove()) {
d->setError(QFile::RenameError, tr("Cannot remove source file"));
error = true;
@@ -785,13 +783,13 @@ QFile::copy(const QString &newName)
}
unsetError();
close();
- if(error() == QFile::NoError) {
+ if (error() == QFile::NoError) {
if (d->engine()->copy(newName)) {
unsetError();
return true;
} else {
bool error = false;
- if(!open(QFile::ReadOnly)) {
+ if (!open(QFile::ReadOnly)) {
error = true;
d->setError(QFile::CopyError, tr("Cannot open %1 for input").arg(d->fileName));
} else {
@@ -855,7 +853,7 @@ QFile::copy(const QString &newName)
#endif
}
}
- if(!error) {
+ if (!error) {
QFile::setPermissions(newName, permissions());
close();
unsetError();
@@ -920,7 +918,7 @@ bool QFile::open(OpenMode mode)
return true;
}
QFile::FileError err = d->fileEngine->error();
- if(err == QFile::UnspecifiedError)
+ if (err == QFile::UnspecifiedError)
err = QFile::OpenError;
d->setError(err, d->fileEngine->errorString());
return false;
diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp
index 4b1809010b..58c78108c8 100644
--- a/src/corelib/io/qfiledevice.cpp
+++ b/src/corelib/io/qfiledevice.cpp
@@ -42,8 +42,6 @@
#include "qfiledevice_p.h"
#include "qfsfileengine_p.h"
-#include <private/qmemory_p.h>
-
#ifdef QT_NO_QOBJECT
#define tr(X) QString::fromLatin1(X)
#endif
@@ -61,13 +59,12 @@ QFileDevicePrivate::QFileDevicePrivate()
writeBufferChunkSize = QFILE_WRITEBUFFER_SIZE;
}
-QFileDevicePrivate::~QFileDevicePrivate()
- = default;
+QFileDevicePrivate::~QFileDevicePrivate() = default;
-QAbstractFileEngine * QFileDevicePrivate::engine() const
+QAbstractFileEngine *QFileDevicePrivate::engine() const
{
if (!fileEngine)
- fileEngine = qt_make_unique<QFSFileEngine>();
+ fileEngine = std::make_unique<QFSFileEngine>();
return fileEngine.get();
}
@@ -670,7 +667,7 @@ bool QFileDevice::setPermissions(Permissions permissions)
}
/*!
- \enum QFileDevice::MemoryMapFlags
+ \enum QFileDevice::MemoryMapFlag
\since 4.4
This enum describes special options that may be used by the map()
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 3e6032785f..4b81467687 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -359,7 +359,7 @@ QFileInfo::QFileInfo(const QString &file) : d_ptr(new QFileInfoPrivate(file))
\sa isRelative()
*/
-QFileInfo::QFileInfo(const QFile &file) : d_ptr(new QFileInfoPrivate(file.fileName()))
+QFileInfo::QFileInfo(const QFileDevice &file) : d_ptr(new QFileInfoPrivate(file.fileName()))
{
}
@@ -502,7 +502,7 @@ void QFileInfo::setFile(const QString &file)
\sa isRelative()
*/
-void QFileInfo::setFile(const QFile &file)
+void QFileInfo::setFile(const QFileDevice &file)
{
setFile(file.fileName());
}
@@ -890,7 +890,6 @@ QString QFileInfo::suffix() const
QDir QFileInfo::dir() const
{
Q_D(const QFileInfo);
- // ### Qt 6: Maybe rename this to parentDirectory(), considering what it actually does?
return QDir(d->fileEntry.path());
}
@@ -1622,5 +1621,62 @@ QDebug operator<<(QDebug dbg, const QFileInfo &fi)
Returns symLinkTarget() as a \c{std::filesystem::path}.
\sa symLinkTarget()
*/
+/*!
+ \macro QT_IMPLICIT_QFILEINFO_CONSTRUCTION
+ \since 6.0
+ \relates QFileInfo
+
+ Defining this macro makes most QFileInfo constructors implicit
+ instead of explicit. Since construction of QFileInfo objects is
+ expensive, one should avoid accidentally creating them, especially
+ if cheaper alternatives exist. For instance:
+
+ \badcode
+
+ QDirIterator it(dir);
+ while (it.hasNext()) {
+ // Implicit conversion from QString (returned by it.next()):
+ // may create unnecessary data strucutres and cause additional
+ // accesses to the file system. Unless this macro is defined,
+ // this line does not compile.
+
+ QFileInfo fi = it.next();
+
+ ~~~
+ }
+
+ \endcode
+
+ Instead, use the right API:
+
+ \code
+
+ QDirIterator it(dir);
+ while (it.hasNext()) {
+ it.next();
+
+ // Extract the QFileInfo from the iterator directly:
+ QFileInfo fi = it.fileInfo();
+
+ ~~~
+ }
+
+ \endcode
+
+ Construction from QString, QFile, and so on is always possible by
+ using direct initialization instead of copy initialization:
+
+ \code
+
+ QFileInfo fi1 = some_string; // Does not compile unless this macro is defined
+ QFileInfo fi2(some_string); // OK
+ QFileInfo fi3{some_string}; // Possibly better, avoids the risk of the Most Vexing Parse
+ auto fi4 = QFileInfo(some_string); // OK
+
+ \endcode
+
+ This macro is provided for compatibility reason. Its usage is not
+ recommended in new code.
+*/
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h
index 40cb0125ed..90be1c2540 100644
--- a/src/corelib/io/qfileinfo.h
+++ b/src/corelib/io/qfileinfo.h
@@ -59,27 +59,36 @@ class Q_CORE_EXPORT QFileInfo
public:
explicit QFileInfo(QFileInfoPrivate *d);
+#ifdef QT_IMPLICIT_QFILEINFO_CONSTRUCTION
+#define QFILEINFO_MAYBE_EXPLICIT Q_IMPLICIT
+#else
+#define QFILEINFO_MAYBE_EXPLICIT explicit
+#endif
+
QFileInfo();
- QFileInfo(const QString &file);
- QFileInfo(const QFile &file);
- QFileInfo(const QDir &dir, const QString &file);
+ QFILEINFO_MAYBE_EXPLICIT QFileInfo(const QString &file);
+ QFILEINFO_MAYBE_EXPLICIT QFileInfo(const QFileDevice &file);
+ QFILEINFO_MAYBE_EXPLICIT QFileInfo(const QDir &dir, const QString &file);
QFileInfo(const QFileInfo &fileinfo);
#ifdef Q_CLANG_QDOC
QFileInfo(const std::filesystem::path &file);
QFileInfo(const QDir &dir, const std::filesystem::path &file);
#elif QT_CONFIG(cxx17_filesystem)
template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
- QFileInfo(const T &file) : QFileInfo(QtPrivate::fromFilesystemPath(file)) { }
+ QFILEINFO_MAYBE_EXPLICIT QFileInfo(const T &file) : QFileInfo(QtPrivate::fromFilesystemPath(file)) { }
template<typename T, QtPrivate::ForceFilesystemPath<T> = 0>
- QFileInfo(const QDir &dir, const T &file) : QFileInfo(dir, QtPrivate::fromFilesystemPath(file))
+ QFILEINFO_MAYBE_EXPLICIT QFileInfo(const QDir &dir, const T &file) : QFileInfo(dir, QtPrivate::fromFilesystemPath(file))
{
}
#endif // QT_CONFIG(cxx17_filesystem)
+
+#undef QFILEINFO_MAYBE_EXPLICIT
+
~QFileInfo();
QFileInfo &operator=(const QFileInfo &fileinfo);
- QFileInfo &operator=(QFileInfo &&other) noexcept { swap(other); return *this; }
+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QFileInfo)
void swap(QFileInfo &other) noexcept
{ qSwap(d_ptr, other.d_ptr); }
@@ -88,7 +97,7 @@ public:
inline bool operator!=(const QFileInfo &fileinfo) const { return !(operator==(fileinfo)); }
void setFile(const QString &file);
- void setFile(const QFile &file);
+ void setFile(const QFileDevice &file);
void setFile(const QDir &dir, const QString &file);
#ifdef Q_CLANG_QDOC
void setFile(const std::filesystem::path &file);
@@ -152,7 +161,7 @@ public:
bool isBundle() const;
QString symLinkTarget() const;
-#if QT_CONFIG(cxx17_filesystem)
+#if QT_CONFIG(cxx17_filesystem) || defined(Q_CLANG_QDOC)
std::filesystem::path filesystemSymLinkTarget() const
{ return QtPrivate::toFilesystemPath(symLinkTarget()); }
#endif // QT_CONFIG(cxx17_filesystem)
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 1aa5179ee3..167b21f8b1 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -233,51 +233,51 @@ qint64 timespecToMSecs(const timespec &spec)
}
// fallback set
-Q_DECL_UNUSED qint64 atime(const QT_STATBUF &statBuffer, ulong) { return qint64(statBuffer.st_atime) * 1000; }
-Q_DECL_UNUSED qint64 birthtime(const QT_STATBUF &, ulong) { return Q_INT64_C(0); }
-Q_DECL_UNUSED qint64 ctime(const QT_STATBUF &statBuffer, ulong) { return qint64(statBuffer.st_ctime) * 1000; }
-Q_DECL_UNUSED qint64 mtime(const QT_STATBUF &statBuffer, ulong) { return qint64(statBuffer.st_mtime) * 1000; }
+[[maybe_unused]] qint64 atime(const QT_STATBUF &statBuffer, ulong) { return qint64(statBuffer.st_atime) * 1000; }
+[[maybe_unused]] qint64 birthtime(const QT_STATBUF &, ulong) { return Q_INT64_C(0); }
+[[maybe_unused]] qint64 ctime(const QT_STATBUF &statBuffer, ulong) { return qint64(statBuffer.st_ctime) * 1000; }
+[[maybe_unused]] qint64 mtime(const QT_STATBUF &statBuffer, ulong) { return qint64(statBuffer.st_mtime) * 1000; }
// Xtim, POSIX.1-2008
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_atim, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_atim, true), qint64>::type
atime(const T &statBuffer, int)
{ return timespecToMSecs(statBuffer.st_atim); }
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_birthtim, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_birthtim, true), qint64>::type
birthtime(const T &statBuffer, int)
{ return timespecToMSecs(statBuffer.st_birthtim); }
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_ctim, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_ctim, true), qint64>::type
ctime(const T &statBuffer, int)
{ return timespecToMSecs(statBuffer.st_ctim); }
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_mtim, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_mtim, true), qint64>::type
mtime(const T &statBuffer, int)
{ return timespecToMSecs(statBuffer.st_mtim); }
#ifndef st_mtimespec
// Xtimespec
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_atimespec, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_atimespec, true), qint64>::type
atime(const T &statBuffer, int)
{ return timespecToMSecs(statBuffer.st_atimespec); }
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_birthtimespec, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_birthtimespec, true), qint64>::type
birthtime(const T &statBuffer, int)
{ return timespecToMSecs(statBuffer.st_birthtimespec); }
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_ctimespec, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_ctimespec, true), qint64>::type
ctime(const T &statBuffer, int)
{ return timespecToMSecs(statBuffer.st_ctimespec); }
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_mtimespec, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_mtimespec, true), qint64>::type
mtime(const T &statBuffer, int)
{ return timespecToMSecs(statBuffer.st_mtimespec); }
#endif
@@ -285,22 +285,22 @@ mtime(const T &statBuffer, int)
#if !defined(st_mtimensec) && !defined(__alpha__)
// Xtimensec
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_atimensec, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_atimensec, true), qint64>::type
atime(const T &statBuffer, int)
{ return statBuffer.st_atime * Q_INT64_C(1000) + statBuffer.st_atimensec / 1000000; }
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_birthtimensec, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_birthtimensec, true), qint64>::type
birthtime(const T &statBuffer, int)
{ return statBuffer.st_birthtime * Q_INT64_C(1000) + statBuffer.st_birthtimensec / 1000000; }
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_ctimensec, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_ctimensec, true), qint64>::type
ctime(const T &statBuffer, int)
{ return statBuffer.st_ctime * Q_INT64_C(1000) + statBuffer.st_ctimensec / 1000000; }
template <typename T>
-Q_DECL_UNUSED static typename std::enable_if<(&T::st_mtimensec, true), qint64>::type
+[[maybe_unused]] static typename std::enable_if<(&T::st_mtimensec, true), qint64>::type
mtime(const T &statBuffer, int)
{ return statBuffer.st_mtime * Q_INT64_C(1000) + statBuffer.st_mtimensec / 1000000; }
#endif
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index b3d7ecfed8..f27040b07c 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -567,7 +567,7 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
// can be //server or //server/share
QString absPath;
QVarLengthArray<wchar_t, MAX_PATH> buf(qMax(MAX_PATH, path.size() + 1));
- wchar_t *fileName = 0;
+ wchar_t *fileName = nullptr;
DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName);
if (retLen > (DWORD)buf.size()) {
buf.resize(retLen);
@@ -792,7 +792,7 @@ bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSyst
DWORD res = GetNamedSecurityInfo(reinterpret_cast<const wchar_t*>(fname.utf16()), SE_FILE_OBJECT,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
&pOwner, &pGroup, &pDacl, 0, &pSD);
- if(res == ERROR_SUCCESS) {
+ if (res == ERROR_SUCCESS) {
ACCESS_MASK access_mask;
TRUSTEE_W trustee;
if (what & QFileSystemMetaData::UserPermissions) { // user
@@ -845,11 +845,11 @@ bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSyst
BuildTrusteeWithSid(&trustee, pOwner);
if (GetEffectiveRightsFromAcl(pDacl, &trustee, &access_mask) != ERROR_SUCCESS)
access_mask = (ACCESS_MASK)-1;
- if(access_mask & ReadMask)
+ if (access_mask & ReadMask)
data.entryFlags |= QFileSystemMetaData::OwnerReadPermission;
- if(access_mask & WriteMask)
+ if (access_mask & WriteMask)
data.entryFlags |= QFileSystemMetaData::OwnerWritePermission;
- if(access_mask & ExecMask)
+ if (access_mask & ExecMask)
data.entryFlags |= QFileSystemMetaData::OwnerExecutePermission;
}
if (what & QFileSystemMetaData::GroupPermissions) { // group
@@ -857,22 +857,22 @@ bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSyst
BuildTrusteeWithSid(&trustee, pGroup);
if (GetEffectiveRightsFromAcl(pDacl, &trustee, &access_mask) != ERROR_SUCCESS)
access_mask = (ACCESS_MASK)-1;
- if(access_mask & ReadMask)
+ if (access_mask & ReadMask)
data.entryFlags |= QFileSystemMetaData::GroupReadPermission;
- if(access_mask & WriteMask)
+ if (access_mask & WriteMask)
data.entryFlags |= QFileSystemMetaData::GroupWritePermission;
- if(access_mask & ExecMask)
+ if (access_mask & ExecMask)
data.entryFlags |= QFileSystemMetaData::GroupExecutePermission;
}
if (what & QFileSystemMetaData::OtherPermissions) { // other (world)
data.knownFlagsMask |= QFileSystemMetaData::OtherPermissions;
if (GetEffectiveRightsFromAcl(pDacl, &worldTrusteeW, &access_mask) != ERROR_SUCCESS)
access_mask = (ACCESS_MASK)-1; // ###
- if(access_mask & ReadMask)
+ if (access_mask & ReadMask)
data.entryFlags |= QFileSystemMetaData::OtherReadPermission;
- if(access_mask & WriteMask)
+ if (access_mask & WriteMask)
data.entryFlags |= QFileSystemMetaData::OtherWritePermission;
- if(access_mask & ExecMask)
+ if (access_mask & ExecMask)
data.entryFlags |= QFileSystemMetaData::OwnerExecutePermission;
}
LocalFree(pSD);
@@ -1281,7 +1281,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
{
QFileSystemMetaData meta;
fillMetaData(entry, meta, QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType);
- if(!(meta.exists() && meta.isDirectory()))
+ if (!(meta.exists() && meta.isDirectory()))
return false;
//TODO: this should really be using nativeFilePath(), but that returns a path in long format \\?\c:\foo
@@ -1326,7 +1326,7 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst
{
bool ret = ::CopyFile((wchar_t*)source.nativeFilePath().utf16(),
(wchar_t*)target.nativeFilePath().utf16(), true) != 0;
- if(!ret)
+ if (!ret)
error = QSystemError(::GetLastError(), QSystemError::NativeError);
return ret;
}
@@ -1339,7 +1339,7 @@ bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSy
bool ret = ::MoveFile((wchar_t*)source.nativeFilePath().utf16(),
(wchar_t*)target.nativeFilePath().utf16()) != 0;
- if(!ret)
+ if (!ret)
error = QSystemError(::GetLastError(), QSystemError::NativeError);
return ret;
}
@@ -1364,7 +1364,7 @@ bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &
Q_CHECK_FILE_NAME(entry, false);
bool ret = ::DeleteFile((wchar_t*)entry.nativeFilePath().utf16()) != 0;
- if(!ret)
+ if (!ret)
error = QSystemError(::GetLastError(), QSystemError::NativeError);
return ret;
}
@@ -1477,7 +1477,7 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per
return false;
bool ret = ::_wchmod(reinterpret_cast<const wchar_t*>(entry.nativeFilePath().utf16()), mode) == 0;
- if(!ret)
+ if (!ret)
error = QSystemError(errno, QSystemError::StandardLibraryError);
return ret;
}
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
index c69138e3ba..cf01eeff15 100644
--- a/src/corelib/io/qfilesystemiterator_unix.cpp
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -56,7 +56,7 @@ static bool checkNameDecodable(const char *d_name, qsizetype len)
// This function is called in a loop from advance() below, but the loop is
// usually run only once.
- return QUtf8::isValidUtf8(d_name, len).isValidUtf8;
+ return QUtf8::isValidUtf8(QByteArrayView(d_name, len)).isValidUtf8;
}
QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters,
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 1712fec751..bd5a73da84 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -121,7 +121,7 @@ void QFileSystemWatcherPrivate::init()
void QFileSystemWatcherPrivate::initPollerEngine()
{
- if(poller)
+ if (poller)
return;
Q_Q(QFileSystemWatcher);
@@ -379,7 +379,7 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths)
}
#endif
// Normal runtime case - search intelligently for best engine
- if(d->native) {
+ if (d->native) {
return d->native;
} else {
d_func()->initPollerEngine();
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index b131524614..31c6b747a7 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -406,7 +406,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
pathInfo = fileInfo;
// Look for a thread
- QWindowsFileSystemWatcherEngineThread *thread = 0;
+ QWindowsFileSystemWatcherEngineThread *thread = nullptr;
QWindowsFileSystemWatcherEngine::Handle handle;
QList<QWindowsFileSystemWatcherEngineThread *>::const_iterator jt, end;
end = threads.constEnd();
@@ -596,7 +596,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path
}
}
- threads.removeAll(0);
+ threads.removeAll(nullptr);
return unhandled;
}
diff --git a/src/corelib/io/qfilesystemwatcher_win_p.h b/src/corelib/io/qfilesystemwatcher_win_p.h
index 7808aff2ac..778ed8ce23 100644
--- a/src/corelib/io/qfilesystemwatcher_win_p.h
+++ b/src/corelib/io/qfilesystemwatcher_win_p.h
@@ -138,7 +138,7 @@ public:
bool operator==(const QFileSystemWatcherPathKey &other) const { return !compare(other, Qt::CaseInsensitive); }
};
-Q_DECLARE_TYPEINFO(QFileSystemWatcherPathKey, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QFileSystemWatcherPathKey, Q_RELOCATABLE_TYPE);
inline size_t qHash(const QFileSystemWatcherPathKey &key) { return qHash(key.toCaseFolded()); }
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index 639c01571a..d6e7ecb592 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -61,7 +61,8 @@
QT_BEGIN_NAMESPACE
-struct ProcessOpenModeResult {
+struct ProcessOpenModeResult
+{
bool ok;
QIODevice::OpenMode openMode;
QString error;
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 6b1ab5739e..84ba42f55a 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -842,7 +842,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
NULL);
// Since this is a special case, we check if the return value was NULL and if so
// we change it to INVALID_HANDLE_VALUE to follow the logic inside this function.
- if(0 == handle)
+ if (!handle)
handle = INVALID_HANDLE_VALUE;
#endif
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 924876b785..5c8c0e6a27 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -846,7 +846,7 @@ qint64 QIODevice::pos() const
*/
qint64 QIODevice::size() const
{
- return d_func()->isSequential() ? bytesAvailable() : qint64(0);
+ return d_func()->isSequential() ? bytesAvailable() : qint64(0);
}
/*!
@@ -1353,7 +1353,7 @@ qint64 QIODevice::readLine(char *data, qint64 maxSize)
// QRingBuffer::readLine() terminates the line with '\0'
readSoFar = d->buffer.readLine(data, maxSize + 1);
if (d->buffer.isEmpty())
- readData(data,0);
+ readData(data, 0);
if (!sequential)
d->pos += readSoFar;
}
@@ -1470,6 +1470,7 @@ QByteArray QIODevice::readLine(qint64 maxSize)
else
result.resize(readBytes);
+ result.squeeze();
return result;
}
diff --git a/src/corelib/io/qiodevice.h b/src/corelib/io/qiodevice.h
index fa43efdb4d..e4388b8972 100644
--- a/src/corelib/io/qiodevice.h
+++ b/src/corelib/io/qiodevice.h
@@ -98,7 +98,7 @@ public:
virtual bool open(OpenMode mode);
virtual void close();
- // ### Qt 6: pos() and seek() should not be virtual, and
+ // ### Qt 7 - QTBUG-76492: pos() and seek() should not be virtual, and
// ### seek() should call a virtual seekData() function.
virtual qint64 pos() const;
virtual qint64 size() const;
diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h
index 8113f08237..3f8e459d88 100644
--- a/src/corelib/io/qiodevice_p.h
+++ b/src/corelib/io/qiodevice_p.h
@@ -89,7 +89,8 @@ public:
qint64 devicePos = 0;
qint64 transactionPos = 0;
- class QRingBufferRef {
+ class QRingBufferRef
+ {
QRingBuffer *m_buf;
inline QRingBufferRef() : m_buf(nullptr) { }
friend class QIODevicePrivate;
diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp
index aa84ce6bc1..ba2dc28339 100644
--- a/src/corelib/io/qlockfile.cpp
+++ b/src/corelib/io/qlockfile.cpp
@@ -151,6 +151,14 @@ QLockFile::~QLockFile()
}
/*!
+ * Returns the file name of the lock file
+ */
+QString QLockFile::fileName() const
+{
+ return d_ptr->fileName;
+}
+
+/*!
Sets \a staleLockTime to be the time in milliseconds after which
a lock file is considered stale.
The default value is 30000, i.e. 30 seconds.
diff --git a/src/corelib/io/qlockfile.h b/src/corelib/io/qlockfile.h
index 8b94900901..ba955241b6 100644
--- a/src/corelib/io/qlockfile.h
+++ b/src/corelib/io/qlockfile.h
@@ -53,6 +53,8 @@ public:
QLockFile(const QString &fileName);
~QLockFile();
+ QString fileName() const;
+
bool lock();
bool tryLock(int timeout = 0);
void unlock();
diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp
index 77cdf66694..46a6b9da5e 100644
--- a/src/corelib/io/qlockfile_win.cpp
+++ b/src/corelib/io/qlockfile_win.cpp
@@ -167,21 +167,24 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
void QLockFile::unlock()
{
Q_D(QLockFile);
- if (!d->isLocked)
+ if (!d->isLocked)
return;
- CloseHandle(d->fileHandle);
- int attempts = 0;
- static const int maxAttempts = 500; // 500ms
- while (!QFile::remove(d->fileName) && ++attempts < maxAttempts) {
- // Someone is reading the lock file right now (on Windows this prevents deleting it).
- QThread::msleep(1);
- }
- if (attempts == maxAttempts) {
- qWarning() << "Could not remove our own lock file" << d->fileName << ". Either other users of the lock file are reading it constantly for 500 ms, or we (no longer) have permissions to delete the file";
- // This is bad because other users of this lock file will now have to wait for the stale-lock-timeout...
- }
- d->lockError = QLockFile::NoError;
- d->isLocked = false;
+ CloseHandle(d->fileHandle);
+ int attempts = 0;
+ static const int maxAttempts = 500; // 500ms
+ while (!QFile::remove(d->fileName) && ++attempts < maxAttempts) {
+ // Someone is reading the lock file right now (on Windows this prevents deleting it).
+ QThread::msleep(1);
+ }
+ if (attempts == maxAttempts) {
+ qWarning() << "Could not remove our own lock file" << d->fileName
+ << ". Either other users of the lock file are reading it constantly for 500 ms, "
+ "or we (no longer) have permissions to delete the file";
+ // This is bad because other users of this lock file will now have to wait for the
+ // stale-lock-timeout...
+ }
+ d->lockError = QLockFile::NoError;
+ d->isLocked = false;
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h
index 1a924f07dc..9687a0e20d 100644
--- a/src/corelib/io/qloggingregistry_p.h
+++ b/src/corelib/io/qloggingregistry_p.h
@@ -74,7 +74,7 @@ public:
FullText = 0x1,
LeftFilter = 0x2,
RightFilter = 0x4,
- MidFilter = LeftFilter | RightFilter
+ MidFilter = LeftFilter | RightFilter
};
Q_DECLARE_FLAGS(PatternFlags, PatternFlag)
@@ -88,7 +88,7 @@ private:
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QLoggingRule::PatternFlags)
-Q_DECLARE_TYPEINFO(QLoggingRule, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QLoggingRule, Q_RELOCATABLE_TYPE);
class Q_AUTOTEST_EXPORT QLoggingSettingsParser
{
@@ -144,7 +144,7 @@ private:
// protected by mutex:
QList<QLoggingRule> ruleSets[NumRuleSets];
- QHash<QLoggingCategory*,QtMsgType> categories;
+ QHash<QLoggingCategory *, QtMsgType> categories;
QLoggingCategory::CategoryFilter categoryFilter;
friend class ::tst_QLoggingRegistry;
diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp
index df0197e8eb..cf2da0c896 100644
--- a/src/corelib/io/qnoncontiguousbytedevice.cpp
+++ b/src/corelib/io/qnoncontiguousbytedevice.cpp
@@ -297,7 +297,7 @@ QNonContiguousByteDeviceIoDeviceImpl::~QNonContiguousByteDeviceIoDeviceImpl()
delete currentReadBuffer;
}
-const char* QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLength, qint64 &len)
+const char *QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLength, qint64 &len)
{
if (eof == true) {
len = -1;
@@ -360,7 +360,6 @@ bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount)
currentReadBufferAmount = 0;
}
-
return true;
}
@@ -374,7 +373,7 @@ bool QNonContiguousByteDeviceIoDeviceImpl::reset()
bool reset = (initialPosition == 0) ? device->reset() : device->seek(initialPosition);
if (reset) {
eof = false; // assume eof is false, it will be true after a read has been attempted
- totalAdvancements = 0; //reset the progress counter
+ totalAdvancements = 0; // reset the progress counter
if (currentReadBuffer) {
delete currentReadBuffer;
currentReadBuffer = nullptr;
@@ -441,8 +440,7 @@ qint64 QByteDeviceWrappingIoDevice::size() const
return byteDevice->size();
}
-
-qint64 QByteDeviceWrappingIoDevice::readData( char * data, qint64 maxSize)
+qint64 QByteDeviceWrappingIoDevice::readData(char *data, qint64 maxSize)
{
qint64 len;
const char *readPointer = byteDevice->readPointer(maxSize, len);
@@ -454,7 +452,7 @@ qint64 QByteDeviceWrappingIoDevice::readData( char * data, qint64 maxSize)
return len;
}
-qint64 QByteDeviceWrappingIoDevice::writeData( const char* data, qint64 maxSize)
+qint64 QByteDeviceWrappingIoDevice::writeData(const char *data, qint64 maxSize)
{
Q_UNUSED(data);
Q_UNUSED(maxSize);
@@ -482,10 +480,10 @@ qint64 QByteDeviceWrappingIoDevice::writeData( const char* data, qint64 maxSize)
\internal
*/
-QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *device)
+QNonContiguousByteDevice *QNonContiguousByteDeviceFactory::create(QIODevice *device)
{
// shortcut if it is a QBuffer
- if (QBuffer* buffer = qobject_cast<QBuffer*>(device)) {
+ if (QBuffer *buffer = qobject_cast<QBuffer *>(device)) {
return new QNonContiguousByteDeviceBufferImpl(buffer);
}
@@ -566,7 +564,7 @@ QSharedPointer<QNonContiguousByteDevice> QNonContiguousByteDeviceFactory::create
\internal
*/
-QIODevice* QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice* byteDevice)
+QIODevice *QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice *byteDevice)
{
// ### FIXME if it already has been based on QIoDevice, we could that one out again
// and save some calling
diff --git a/src/corelib/io/qnoncontiguousbytedevice_p.h b/src/corelib/io/qnoncontiguousbytedevice_p.h
index bbc4ea5ae2..aa762766af 100644
--- a/src/corelib/io/qnoncontiguousbytedevice_p.h
+++ b/src/corelib/io/qnoncontiguousbytedevice_p.h
@@ -64,7 +64,7 @@ class Q_CORE_EXPORT QNonContiguousByteDevice : public QObject
{
Q_OBJECT
public:
- virtual const char* readPointer(qint64 maximumLength, qint64 &len) = 0;
+ virtual const char *readPointer(qint64 maximumLength, qint64 &len) = 0;
virtual bool advanceReadPointer(qint64 amount) = 0;
virtual bool atEnd() const = 0;
virtual qint64 pos() const { return -1; }
@@ -76,7 +76,6 @@ public:
protected:
QNonContiguousByteDevice();
-
Q_SIGNALS:
void readyRead();
void readProgress(qint64 current, qint64 total);
@@ -85,16 +84,16 @@ Q_SIGNALS:
class Q_CORE_EXPORT QNonContiguousByteDeviceFactory
{
public:
- static QNonContiguousByteDevice* create(QIODevice *device);
+ static QNonContiguousByteDevice *create(QIODevice *device);
static QSharedPointer<QNonContiguousByteDevice> createShared(QIODevice *device);
- static QNonContiguousByteDevice* create(QByteArray *byteArray);
+ static QNonContiguousByteDevice *create(QByteArray *byteArray);
static QSharedPointer<QNonContiguousByteDevice> createShared(QByteArray *byteArray);
- static QNonContiguousByteDevice* create(QSharedPointer<QRingBuffer> ringBuffer);
+ static QNonContiguousByteDevice *create(QSharedPointer<QRingBuffer> ringBuffer);
static QSharedPointer<QNonContiguousByteDevice> createShared(QSharedPointer<QRingBuffer> ringBuffer);
- static QIODevice* wrap(QNonContiguousByteDevice* byteDevice);
+ static QIODevice *wrap(QNonContiguousByteDevice *byteDevice);
};
// the actual implementations
@@ -105,14 +104,15 @@ class QNonContiguousByteDeviceByteArrayImpl : public QNonContiguousByteDevice
public:
QNonContiguousByteDeviceByteArrayImpl(QByteArray *ba);
~QNonContiguousByteDeviceByteArrayImpl();
- const char* readPointer(qint64 maximumLength, qint64 &len) override;
+ const char *readPointer(qint64 maximumLength, qint64 &len) override;
bool advanceReadPointer(qint64 amount) override;
bool atEnd() const override;
bool reset() override;
qint64 size() const override;
qint64 pos() const override;
+
protected:
- QByteArray* byteArray;
+ QByteArray *byteArray;
qint64 currentPosition;
};
@@ -121,33 +121,34 @@ class QNonContiguousByteDeviceRingBufferImpl : public QNonContiguousByteDevice
public:
QNonContiguousByteDeviceRingBufferImpl(QSharedPointer<QRingBuffer> rb);
~QNonContiguousByteDeviceRingBufferImpl();
- const char* readPointer(qint64 maximumLength, qint64 &len) override;
+ const char *readPointer(qint64 maximumLength, qint64 &len) override;
bool advanceReadPointer(qint64 amount) override;
bool atEnd() const override;
bool reset() override;
qint64 size() const override;
qint64 pos() const override;
+
protected:
QSharedPointer<QRingBuffer> ringBuffer;
qint64 currentPosition;
};
-
class QNonContiguousByteDeviceIoDeviceImpl : public QNonContiguousByteDevice
{
Q_OBJECT
public:
QNonContiguousByteDeviceIoDeviceImpl(QIODevice *d);
~QNonContiguousByteDeviceIoDeviceImpl();
- const char* readPointer(qint64 maximumLength, qint64 &len) override;
+ const char *readPointer(qint64 maximumLength, qint64 &len) override;
bool advanceReadPointer(qint64 amount) override;
bool atEnd() const override;
bool reset() override;
qint64 size() const override;
qint64 pos() const override;
+
protected:
- QIODevice* device;
- QByteArray* currentReadBuffer;
+ QIODevice *device;
+ QByteArray *currentReadBuffer;
qint64 currentReadBufferSize;
qint64 currentReadBufferAmount;
qint64 currentReadBufferPosition;
@@ -162,32 +163,34 @@ class QNonContiguousByteDeviceBufferImpl : public QNonContiguousByteDevice
public:
QNonContiguousByteDeviceBufferImpl(QBuffer *b);
~QNonContiguousByteDeviceBufferImpl();
- const char* readPointer(qint64 maximumLength, qint64 &len) override;
+ const char *readPointer(qint64 maximumLength, qint64 &len) override;
bool advanceReadPointer(qint64 amount) override;
bool atEnd() const override;
bool reset() override;
qint64 size() const override;
+
protected:
- QBuffer* buffer;
+ QBuffer *buffer;
QByteArray byteArray;
- QNonContiguousByteDeviceByteArrayImpl* arrayImpl;
+ QNonContiguousByteDeviceByteArrayImpl *arrayImpl;
};
// ... and the reverse thing
class QByteDeviceWrappingIoDevice : public QIODevice
{
public:
- QByteDeviceWrappingIoDevice (QNonContiguousByteDevice *bd);
- ~QByteDeviceWrappingIoDevice ();
+ QByteDeviceWrappingIoDevice(QNonContiguousByteDevice *bd);
+ ~QByteDeviceWrappingIoDevice();
bool isSequential() const override;
bool atEnd() const override;
bool reset() override;
qint64 size() const override;
+
protected:
qint64 readData(char *data, qint64 maxSize) override;
qint64 writeData(const char *data, qint64 maxSize) override;
- QNonContiguousByteDevice *byteDevice;
+ QNonContiguousByteDevice *byteDevice;
};
QT_END_NAMESPACE
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 4fdc94a202..8b29a8964f 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -290,7 +290,7 @@ bool QProcessEnvironment::isEmpty() const
*/
void QProcessEnvironment::clear()
{
- if (d)
+ if (d.constData())
d->vars.clear();
// Unix: Don't clear d->nameMap, as the environment is likely to be
// re-populated with the same keys again.
@@ -339,9 +339,9 @@ void QProcessEnvironment::insert(const QString &name, const QString &value)
*/
void QProcessEnvironment::remove(const QString &name)
{
- if (d) {
- d.detach(); // detach before prepareName()
- d->vars.remove(d->prepareName(name));
+ if (d.constData()) {
+ QProcessEnvironmentPrivate *p = d.data();
+ p->vars.remove(p->prepareName(name));
}
}
@@ -828,27 +828,6 @@ QProcessPrivate::QProcessPrivate()
{
readBufferChunkSize = QRINGBUFFER_CHUNKSIZE;
writeBufferChunkSize = QRINGBUFFER_CHUNKSIZE;
- processChannelMode = QProcess::SeparateChannels;
- inputChannelMode = QProcess::ManagedInputChannel;
- processError = QProcess::UnknownError;
- processState = QProcess::NotRunning;
- pid = 0;
- sequenceNumber = 0;
- exitCode = 0;
- exitStatus = QProcess::NormalExit;
- startupSocketNotifier = nullptr;
- deathNotifier = nullptr;
- childStartedPipe[0] = INVALID_Q_PIPE;
- childStartedPipe[1] = INVALID_Q_PIPE;
- forkfd = -1;
- crashed = false;
- dying = false;
- emittedReadyRead = false;
- emittedBytesWritten = false;
-#ifdef Q_OS_WIN
- stdinWriteTrigger = 0;
- processFinishedNotifier = 0;
-#endif // Q_OS_WIN
}
/*!
@@ -1623,24 +1602,6 @@ void QProcess::setWorkingDirectory(const QString &dir)
d->workingDirectory = dir;
}
-
-/*!
- \deprecated
- Use processId() instead.
-
- Returns the native process identifier for the running process, if
- available. If no process is currently running, \c 0 is returned.
-
- \note Unlike \l processId(), pid() returns an integer on Unix and a pointer on Windows.
-
- \sa Q_PID, processId()
-*/
-Q_PID QProcess::pid() const // ### Qt 6 remove or rename this method to processInformation()
-{
- Q_D(const QProcess);
- return d->pid;
-}
-
/*!
\since 5.3
@@ -2149,7 +2110,6 @@ void QProcess::startCommand(const QString &command, OpenMode mode)
\sa start()
\sa startDetached(const QString &program, const QStringList &arguments,
const QString &workingDirectory, qint64 *pid)
- \sa startDetached(const QString &command)
*/
bool QProcess::startDetached(qint64 *pid)
{
@@ -2544,17 +2504,6 @@ QString QProcess::nullDevice()
#endif
}
-/*!
- \typedef Q_PID
- \relates QProcess
-
- Typedef for the identifiers used to represent processes on the underlying
- platform. On Unix, this corresponds to \l qint64; on Windows, it
- corresponds to \c{_PROCESS_INFORMATION*}.
-
- \sa QProcess::pid()
-*/
-
#endif // QT_CONFIG(process)
QT_END_NAMESPACE
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index 541086e1b0..cfa86c8508 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -48,13 +48,13 @@
QT_REQUIRE_CONFIG(processenvironment);
-#ifdef Q_OS_WIN
-typedef struct _PROCESS_INFORMATION *Q_PID;
-#endif
-
#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
-typedef struct _SECURITY_ATTRIBUTES Q_SECURITY_ATTRIBUTES;
-typedef struct _STARTUPINFOW Q_STARTUPINFO;
+struct _PROCESS_INFORMATION;
+struct _SECURITY_ATTRIBUTES;
+struct _STARTUPINFOW;
+using Q_PROCESS_INFORMATION = _PROCESS_INFORMATION;
+using Q_SECURITY_ATTRIBUTES = _SECURITY_ATTRIBUTES;
+using Q_STARTUPINFO = _STARTUPINFOW;
#endif
QT_BEGIN_NAMESPACE
@@ -62,17 +62,13 @@ QT_BEGIN_NAMESPACE
class QProcessPrivate;
class QProcessEnvironmentPrivate;
-#ifndef Q_OS_WIN
-typedef qint64 Q_PID;
-#endif
-
class Q_CORE_EXPORT QProcessEnvironment
{
public:
QProcessEnvironment();
QProcessEnvironment(const QProcessEnvironment &other);
~QProcessEnvironment();
- QProcessEnvironment &operator=(QProcessEnvironment && other) noexcept { swap(other); return *this; }
+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QProcessEnvironment)
QProcessEnvironment &operator=(const QProcessEnvironment &other);
void swap(QProcessEnvironment &other) noexcept { qSwap(d, other.d); }
@@ -200,7 +196,7 @@ public:
void *environment;
const wchar_t *currentDirectory;
Q_STARTUPINFO *startupInfo;
- Q_PID processInformation;
+ Q_PROCESS_INFORMATION *processInformation;
};
typedef std::function<void(CreateProcessArguments *)> CreateProcessArgumentModifier;
CreateProcessArgumentModifier createProcessArgumentsModifier() const;
@@ -222,8 +218,6 @@ public:
QProcess::ProcessError error() const;
QProcess::ProcessState state() const;
- // #### Qt 5: Q_PID is a pointer on Windows and a value on Unix
- Q_PID pid() const;
qint64 processId() const;
bool waitForStarted(int msecs = 30000);
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index 7cb70cc95c..1f449bd4c8 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -99,7 +99,7 @@ inline bool operator<(const QProcEnvKey &a, const QProcEnvKey &b)
return a.compare(b, Qt::CaseInsensitive) < 0;
}
-Q_DECLARE_TYPEINFO(QProcEnvKey, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QProcEnvKey, Q_RELOCATABLE_TYPE);
typedef QString QProcEnvValue;
#else
@@ -133,7 +133,7 @@ public:
mutable QByteArray byteValue;
mutable QString stringValue;
};
-Q_DECLARE_TYPEINFO(QProcEnvValue, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QProcEnvValue, Q_RELOCATABLE_TYPE);
#endif
class QProcessEnvironmentPrivate: public QSharedData
@@ -147,7 +147,7 @@ public:
inline Value prepareValue(const QString &value) const { return value; }
inline QString valueToString(const Value &value) const { return value; }
#else
- struct NameMapMutexLocker : public QMutexLocker
+ struct NameMapMutexLocker : public QMutexLocker<QMutex>
{
NameMapMutexLocker(const QProcessEnvironmentPrivate *d) : QMutexLocker(&d->nameMapMutex) {}
};
@@ -297,17 +297,21 @@ public:
bool _q_startupNotification();
bool _q_processDied();
- QProcess::ProcessChannelMode processChannelMode;
- QProcess::InputChannelMode inputChannelMode;
- QProcess::ProcessError processError;
- QProcess::ProcessState processState;
+ QProcess::ProcessChannelMode processChannelMode = QProcess::SeparateChannels;
+ QProcess::InputChannelMode inputChannelMode = QProcess::ManagedInputChannel;
+ QProcess::ProcessError processError = QProcess::UnknownError;
+ QProcess::ProcessState processState = QProcess::NotRunning;
QString workingDirectory;
- Q_PID pid;
+#ifdef Q_OS_WIN
+ Q_PROCESS_INFORMATION *pid = nullptr;
+#else
+ qint64 pid = 0;
+#endif
int sequenceNumber;
- bool dying;
- bool emittedReadyRead;
- bool emittedBytesWritten;
+ bool dying = false;
+ bool emittedReadyRead = false;
+ bool emittedBytesWritten = false;
Channel stdinChannel;
Channel stdoutChannel;
@@ -327,17 +331,17 @@ public:
#endif
QProcessEnvironment environment;
- Q_PIPE childStartedPipe[2];
+ Q_PIPE childStartedPipe[2] = {INVALID_Q_PIPE, INVALID_Q_PIPE};
void destroyPipe(Q_PIPE pipe[2]);
- QSocketNotifier *startupSocketNotifier;
- QSocketNotifier *deathNotifier;
+ QSocketNotifier *startupSocketNotifier = nullptr;
+ QSocketNotifier *deathNotifier = nullptr;
- int forkfd;
+ int forkfd = -1;
#ifdef Q_OS_WIN
- QTimer *stdinWriteTrigger;
- QWinEventNotifier *processFinishedNotifier;
+ QTimer *stdinWriteTrigger = nullptr;
+ QWinEventNotifier *processFinishedNotifier = nullptr;
#endif
void start(QIODevice::OpenMode mode);
@@ -361,9 +365,9 @@ public:
bool startDetached(qint64 *pPid);
- int exitCode;
- QProcess::ExitStatus exitStatus;
- bool crashed;
+ int exitCode = 0;
+ QProcess::ExitStatus exitStatus = QProcess::NormalExit;
+ bool crashed = false;
bool waitForStarted(int msecs = 30000);
bool waitForReadyRead(int msecs = 30000);
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 5fce848c2c..9e5b26b3d6 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -450,17 +450,7 @@ void QProcessPrivate::startProcess()
workingDirPtr = encodedWorkingDirectory.constData();
}
- // Select FFD_USE_FORK and FFD_VFORK_SEMANTICS based on whether there's
- // user code running in the child process: if there is, we don't know what
- // the user will want to do, so we err on the safe side and request an
- // actual fork() (for example, the user could attempt to do some
- // synchronization with the parent process). But if there isn't, then our
- // code in execChild() is just a handful of dup2() and a chdir(), so it's
- // safe with vfork semantics: suspend the parent execution until the child
- // either execve()s or _exit()s.
int ffdflags = FFD_CLOEXEC;
- if (childProcessModifier)
- ffdflags |= FFD_USE_FORK;
// QTBUG-86285
#if !QT_CONFIG(forkfd_pidfd)
@@ -503,7 +493,8 @@ void QProcessPrivate::startProcess()
::_exit(-1);
}
- pid = Q_PID(childPid);
+ pid = qint64(childPid);
+ Q_ASSERT(pid > 0);
// parent
// close the ends we don't use and make all pipes non-blocking
@@ -691,18 +682,18 @@ bool QProcessPrivate::writeToStdin()
void QProcessPrivate::terminateProcess()
{
#if defined (QPROCESS_DEBUG)
- qDebug("QProcessPrivate::terminateProcess()");
+ qDebug("QProcessPrivate::terminateProcess() pid=%jd", intmax_t(pid));
#endif
- if (pid)
+ if (pid > 0)
::kill(pid_t(pid), SIGTERM);
}
void QProcessPrivate::killProcess()
{
#if defined (QPROCESS_DEBUG)
- qDebug("QProcessPrivate::killProcess()");
+ qDebug("QProcessPrivate::killProcess() pid=%jd", intmax_t(pid));
#endif
- if (pid)
+ if (pid > 0)
::kill(pid_t(pid), SIGKILL);
}
@@ -758,17 +749,14 @@ bool QProcessPrivate::waitForReadyRead(int msecs)
return false;
}
+ // This calls QProcessPrivate::tryReadFromChannel(), which returns true
+ // if we emitted readyRead() signal on the current read channel.
bool readyReadEmitted = false;
- if (qt_pollfd_check(poller.stdoutPipe(), POLLIN)) {
- bool canRead = _q_canReadStandardOutput();
- if (currentReadChannel == QProcess::StandardOutput && canRead)
- readyReadEmitted = true;
- }
- if (qt_pollfd_check(poller.stderrPipe(), POLLIN)) {
- bool canRead = _q_canReadStandardError();
- if (currentReadChannel == QProcess::StandardError && canRead)
- readyReadEmitted = true;
- }
+ if (qt_pollfd_check(poller.stdoutPipe(), POLLIN) && _q_canReadStandardOutput())
+ readyReadEmitted = true;
+ if (qt_pollfd_check(poller.stderrPipe(), POLLIN) && _q_canReadStandardError())
+ readyReadEmitted = true;
+
if (readyReadEmitted)
return true;
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 2663316de0..58cec1ba3a 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -758,18 +758,12 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
return true;
// If we wouldn't write anything, check if we can read stdout.
- if (stdoutChannel.pipe[0] != INVALID_Q_PIPE
- && bytesAvailableInChannel(&stdoutChannel) != 0) {
- tryReadFromChannel(&stdoutChannel);
+ if (stdoutChannel.reader && stdoutChannel.reader->waitForReadyRead(0))
timer.resetIncrements();
- }
// Check if we can read stderr.
- if (stderrChannel.pipe[0] != INVALID_Q_PIPE
- && bytesAvailableInChannel(&stderrChannel) != 0) {
- tryReadFromChannel(&stderrChannel);
+ if (stderrChannel.reader && stderrChannel.reader->waitForReadyRead(0))
timer.resetIncrements();
- }
// Check if the process died while reading.
if (!pid)
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 0333f62870..a5995df211 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -107,13 +107,15 @@ public:
{
}
- inline bool hasNext() {
+ inline bool hasNext()
+ {
while (m_pos < m_len && m_data[m_pos] == m_splitChar)
++m_pos;
return m_pos < m_len;
}
- inline QStringView next() {
+ inline QStringView next()
+ {
int start = m_pos;
while (m_pos < m_len && m_data[m_pos] != m_splitChar)
++m_pos;
@@ -126,18 +128,17 @@ public:
QChar m_splitChar = QLatin1Char('/');
};
-
-//resource glue
+// resource glue
class QResourceRoot
{
public:
- enum Flags
- {
+ enum Flags {
// must match rcc.h
Compressed = 0x01,
Directory = 0x02,
CompressedZstd = 0x04
};
+
private:
const uchar *tree, *names, *payloads;
int version;
@@ -193,7 +194,7 @@ static QString cleanPath(const QString &_path)
return path;
}
-Q_DECLARE_TYPEINFO(QResourceRoot, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QResourceRoot, Q_RELOCATABLE_TYPE);
typedef QList<QResourceRoot*> ResourceList;
struct QResourceGlobalData
@@ -305,7 +306,7 @@ public:
QLocale locale;
QString fileName, absoluteFilePath;
- QList<QResourceRoot*> related;
+ QList<QResourceRoot *> related;
mutable qint64 size;
mutable quint64 lastModified;
mutable const uchar *data;
@@ -318,8 +319,7 @@ public:
Q_DECLARE_PUBLIC(QResource)
};
-void
-QResourcePrivate::clear()
+void QResourcePrivate::clear()
{
absoluteFilePath.clear();
compressionAlgo = QResource::NoCompression;
@@ -328,28 +328,27 @@ QResourcePrivate::clear()
children.clear();
lastModified = 0;
container = 0;
- for(int i = 0; i < related.size(); ++i) {
+ for (int i = 0; i < related.size(); ++i) {
QResourceRoot *root = related.at(i);
- if(!root->ref.deref())
+ if (!root->ref.deref())
delete root;
}
related.clear();
}
-bool
-QResourcePrivate::load(const QString &file)
+bool QResourcePrivate::load(const QString &file)
{
related.clear();
const auto locker = qt_scoped_lock(resourceMutex());
const ResourceList *list = resourceList();
QString cleaned = cleanPath(file);
- for(int i = 0; i < list->size(); ++i) {
+ for (int i = 0; i < list->size(); ++i) {
QResourceRoot *res = list->at(i);
const int node = res->findNode(cleaned, locale);
- if(node != -1) {
- if(related.isEmpty()) {
+ if (node != -1) {
+ if (related.isEmpty()) {
container = res->isContainer(node);
- if(!container) {
+ if (!container) {
data = res->data(node, &size);
compressionAlgo = res->compressionAlgo(node);
} else {
@@ -358,12 +357,13 @@ QResourcePrivate::load(const QString &file)
compressionAlgo = QResource::NoCompression;
}
lastModified = res->lastModified(node);
- } else if(res->isContainer(node) != container) {
- qWarning("QResourceInfo: Resource [%s] has both data and children!", file.toLatin1().constData());
+ } else if (res->isContainer(node) != container) {
+ qWarning("QResourceInfo: Resource [%s] has both data and children!",
+ file.toLatin1().constData());
}
res->ref.ref();
related.append(res);
- } else if(res->mappingRootSubdir(file)) {
+ } else if (res->mappingRootSubdir(file)) {
container = true;
data = nullptr;
size = 0;
@@ -376,31 +376,30 @@ QResourcePrivate::load(const QString &file)
return !related.isEmpty();
}
-void
-QResourcePrivate::ensureInitialized() const
+void QResourcePrivate::ensureInitialized() const
{
- if(!related.isEmpty())
+ if (!related.isEmpty())
return;
QResourcePrivate *that = const_cast<QResourcePrivate *>(this);
- if(fileName == QLatin1String(":"))
+ if (fileName == QLatin1String(":"))
that->fileName += QLatin1Char('/');
that->absoluteFilePath = fileName;
- if(!that->absoluteFilePath.startsWith(QLatin1Char(':')))
+ if (!that->absoluteFilePath.startsWith(QLatin1Char(':')))
that->absoluteFilePath.prepend(QLatin1Char(':'));
QStringView path(fileName);
- if(path.startsWith(QLatin1Char(':')))
+ if (path.startsWith(QLatin1Char(':')))
path = path.mid(1);
- if(path.startsWith(QLatin1Char('/'))) {
+ if (path.startsWith(QLatin1Char('/'))) {
that->load(path.toString());
} else {
const auto locker = qt_scoped_lock(resourceMutex());
QStringList searchPaths = *resourceSearchPaths();
searchPaths << QLatin1String("");
- for(int i = 0; i < searchPaths.size(); ++i) {
+ for (int i = 0; i < searchPaths.size(); ++i) {
const QString searchPath(searchPaths.at(i) + QLatin1Char('/') + path);
- if(that->load(searchPath)) {
+ if (that->load(searchPath)) {
that->absoluteFilePath = QLatin1Char(':') + searchPath;
break;
}
@@ -408,29 +407,28 @@ QResourcePrivate::ensureInitialized() const
}
}
-void
-QResourcePrivate::ensureChildren() const
+void QResourcePrivate::ensureChildren() const
{
ensureInitialized();
- if(!children.isEmpty() || !container || related.isEmpty())
+ if (!children.isEmpty() || !container || related.isEmpty())
return;
QString path = absoluteFilePath, k;
- if(path.startsWith(QLatin1Char(':')))
+ if (path.startsWith(QLatin1Char(':')))
path = path.mid(1);
QDuplicateTracker<QString> kids;
kids.reserve(related.size());
QString cleaned = cleanPath(path);
- for(int i = 0; i < related.size(); ++i) {
+ for (int i = 0; i < related.size(); ++i) {
QResourceRoot *res = related.at(i);
- if(res->mappingRootSubdir(path, &k) && !k.isEmpty()) {
+ if (res->mappingRootSubdir(path, &k) && !k.isEmpty()) {
if (!kids.hasSeen(k))
children += k;
} else {
const int node = res->findNode(cleaned);
- if(node != -1) {
+ if (node != -1) {
QStringList related_children = res->children(node);
- for(int kid = 0; kid < related_children.size(); ++kid) {
+ for (int kid = 0; kid < related_children.size(); ++kid) {
k = related_children.at(kid);
if (!kids.hasSeen(k))
children += k;
@@ -466,7 +464,6 @@ qint64 QResourcePrivate::uncompressedSize() const
Q_UNREACHABLE();
#endif
}
-
}
return -1;
}
@@ -483,8 +480,8 @@ qsizetype QResourcePrivate::decompress(char *buffer, qsizetype bufferSize) const
case QResource::ZlibCompression: {
#ifndef QT_NO_COMPRESS
uLong len = uLong(bufferSize);
- int res = ::uncompress(reinterpret_cast<Bytef *>(buffer), &len,
- data + sizeof(quint32), uLong(size - sizeof(quint32)));
+ int res = ::uncompress(reinterpret_cast<Bytef *>(buffer), &len, data + sizeof(quint32),
+ uLong(size - sizeof(quint32)));
if (res != Z_OK) {
qWarning("QResource: error decompressing zlib content (%d)", res);
return -1;
@@ -707,7 +704,7 @@ const uchar *QResource::data() const
\note If the data was compressed, this function will decompress every time
it is called. The result is not cached between calls.
- \sa uncompressedSize(), size(), isCompressed(), isFile()
+ \sa uncompressedSize(), size(), compressionAlgorithm(), isFile()
*/
QByteArray QResource::uncompressedData() const
@@ -776,16 +773,16 @@ QStringList QResource::children() const
inline uint QResourceRoot::hash(int node) const
{
- if(!node) //root
+ if (!node) // root
return 0;
const int offset = findOffset(node);
qint32 name_offset = qFromBigEndian<qint32>(tree + offset);
- name_offset += 2; //jump past name length
+ name_offset += 2; // jump past name length
return qFromBigEndian<quint32>(names + name_offset);
}
inline QString QResourceRoot::name(int node) const
{
- if(!node) // root
+ if (!node) // root
return QString();
const int offset = findOffset(node);
@@ -793,7 +790,7 @@ inline QString QResourceRoot::name(int node) const
qint32 name_offset = qFromBigEndian<qint32>(tree + offset);
quint16 name_length = qFromBigEndian<qint16>(names + name_offset);
name_offset += 2;
- name_offset += 4; //jump past hash
+ name_offset += 4; // jump past hash
ret.resize(name_length);
QChar *strData = ret.data();
@@ -806,15 +803,15 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
QString path = _path;
{
QString root = mappingRoot();
- if(!root.isEmpty()) {
- if(root == path) {
+ if (!root.isEmpty()) {
+ if (root == path) {
path = QLatin1Char('/');
} else {
- if(!root.endsWith(QLatin1Char('/')))
+ if (!root.endsWith(QLatin1Char('/')))
root += QLatin1Char('/');
- if(path.size() >= root.size() && path.startsWith(root))
- path = path.mid(root.length()-1);
- if(path.isEmpty())
+ if (path.size() >= root.size() && path.startsWith(root))
+ path = path.mid(root.length() - 1);
+ if (path.isEmpty())
path = QLatin1Char('/');
}
}
@@ -823,14 +820,14 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
qDebug() << "!!!!" << "START" << path << locale.country() << locale.language();
#endif
- if(path == QLatin1String("/"))
+ if (path == QLatin1String("/"))
return 0;
- //the root node is always first
+ // the root node is always first
qint32 child_count = qFromBigEndian<qint32>(tree + 6);
qint32 child = qFromBigEndian<qint32>(tree + 10);
- //now iterate up the tree
+ // now iterate up the tree
int node = -1;
QStringSplitter splitter(path);
@@ -839,20 +836,20 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
#ifdef DEBUG_RESOURCE_MATCH
qDebug() << " CHILDREN" << segment;
- for(int j = 0; j < child_count; ++j) {
- qDebug() << " " << child+j << " :: " << name(child+j);
+ for (int j = 0; j < child_count; ++j) {
+ qDebug() << " " << child + j << " :: " << name(child + j);
}
#endif
const uint h = qt_hash(segment);
- //do the binary search for the hash
- int l = 0, r = child_count-1;
- int sub_node = (l+r+1)/2;
- while(r != l) {
- const uint sub_node_hash = hash(child+sub_node);
- if(h == sub_node_hash)
+ // do the binary search for the hash
+ int l = 0, r = child_count - 1;
+ int sub_node = (l + r + 1) / 2;
+ while (r != l) {
+ const uint sub_node_hash = hash(child + sub_node);
+ if (h == sub_node_hash)
break;
- else if(h < sub_node_hash)
+ else if (h < sub_node_hash)
r = sub_node - 1;
else
l = sub_node;
@@ -860,25 +857,26 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
}
sub_node += child;
- //now do the "harder" compares
+ // now do the "harder" compares
bool found = false;
- if(hash(sub_node) == h) {
- while(sub_node > child && hash(sub_node-1) == h) //backup for collisions
+ if (hash(sub_node) == h) {
+ while (sub_node > child && hash(sub_node - 1) == h) // backup for collisions
--sub_node;
- for(; sub_node < child+child_count && hash(sub_node) == h; ++sub_node) { //here we go...
- if(name(sub_node) == segment) {
+ for (; sub_node < child + child_count && hash(sub_node) == h;
+ ++sub_node) { // here we go...
+ if (name(sub_node) == segment) {
found = true;
int offset = findOffset(sub_node);
#ifdef DEBUG_RESOURCE_MATCH
qDebug() << " TRY" << sub_node << name(sub_node) << offset;
#endif
- offset += 4; //jump past name
+ offset += 4; // jump past name
const qint16 flags = qFromBigEndian<qint16>(tree + offset);
offset += 2;
- if(!splitter.hasNext()) {
- if(!(flags & Directory)) {
+ if (!splitter.hasNext()) {
+ if (!(flags & Directory)) {
const qint16 country = qFromBigEndian<qint16>(tree + offset);
offset += 2;
@@ -887,13 +885,15 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
#ifdef DEBUG_RESOURCE_MATCH
qDebug() << " " << "LOCALE" << country << language;
#endif
- if(country == locale.country() && language == locale.language()) {
+ if (country == locale.country() && language == locale.language()) {
#ifdef DEBUG_RESOURCE_MATCH
qDebug() << "!!!!" << "FINISHED" << __LINE__ << sub_node;
#endif
return sub_node;
- } else if((country == QLocale::AnyCountry && language == locale.language()) ||
- (country == QLocale::AnyCountry && language == QLocale::C && node == -1)) {
+ } else if ((country == QLocale::AnyCountry
+ && language == locale.language())
+ || (country == QLocale::AnyCountry && language == QLocale::C
+ && node == -1)) {
node = sub_node;
}
continue;
@@ -906,7 +906,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
}
}
- if(!(flags & Directory))
+ if (!(flags & Directory))
return -1;
child_count = qFromBigEndian<qint32>(tree + offset);
@@ -916,7 +916,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
}
}
}
- if(!found)
+ if (!found)
break;
}
#ifdef DEBUG_RESOURCE_MATCH
@@ -926,28 +926,28 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
}
short QResourceRoot::flags(int node) const
{
- if(node == -1)
+ if (node == -1)
return 0;
- const int offset = findOffset(node) + 4; //jump past name
+ const int offset = findOffset(node) + 4; // jump past name
return qFromBigEndian<qint16>(tree + offset);
}
const uchar *QResourceRoot::data(int node, qint64 *size) const
{
- if(node == -1) {
+ if (node == -1) {
*size = 0;
return nullptr;
}
- int offset = findOffset(node) + 4; //jump past name
+ int offset = findOffset(node) + 4; // jump past name
const qint16 flags = qFromBigEndian<qint16>(tree + offset);
offset += 2;
- offset += 4; //jump past locale
+ offset += 4; // jump past locale
- if(!(flags & Directory)) {
+ if (!(flags & Directory)) {
const qint32 data_offset = qFromBigEndian<qint32>(tree + offset);
const quint32 data_length = qFromBigEndian<quint32>(payloads + data_offset);
- const uchar *ret = payloads+data_offset+4;
+ const uchar *ret = payloads + data_offset + 4;
*size = data_length;
return ret;
}
@@ -967,20 +967,20 @@ quint64 QResourceRoot::lastModified(int node) const
QStringList QResourceRoot::children(int node) const
{
- if(node == -1)
+ if (node == -1)
return QStringList();
- int offset = findOffset(node) + 4; //jump past name
+ int offset = findOffset(node) + 4; // jump past name
const qint16 flags = qFromBigEndian<qint16>(tree + offset);
offset += 2;
QStringList ret;
- if(flags & Directory) {
+ if (flags & Directory) {
const qint32 child_count = qFromBigEndian<qint32>(tree + offset);
offset += 4;
const qint32 child_off = qFromBigEndian<qint32>(tree + offset);
ret.reserve(child_count);
- for(int i = child_off; i < child_off+child_count; ++i)
+ for (int i = child_off; i < child_off + child_count; ++i)
ret << name(i);
}
return ret;
@@ -1024,7 +1024,7 @@ Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree,
break;
}
}
- if(!found) {
+ if (!found) {
QResourceRoot *root = new QResourceRoot(version, tree, name, data);
root->ref.ref();
list->append(root);
@@ -1044,10 +1044,10 @@ Q_CORE_EXPORT bool qUnregisterResourceData(int version, const unsigned char *tre
if (version >= 0x01 && version <= 0x3) {
QResourceRoot res(version, tree, name, data);
ResourceList *list = resourceList();
- for (int i = 0; i < list->size(); ) {
+ for (int i = 0; i < list->size();) {
if (*list->at(i) == res) {
QResourceRoot *root = list->takeAt(i);
- if(!root->ref.deref())
+ if (!root->ref.deref())
delete root;
} else {
++i;
@@ -1058,9 +1058,9 @@ Q_CORE_EXPORT bool qUnregisterResourceData(int version, const unsigned char *tre
return false;
}
-//run time resource creation
+// run time resource creation
-class QDynamicBufferResourceRoot: public QResourceRoot
+class QDynamicBufferResourceRoot : public QResourceRoot
{
QString root;
const uchar *buffer;
@@ -1079,12 +1079,12 @@ public:
if (size >= 0 && size < 20)
return false;
- //setup the data now
+ // setup the data now
int offset = 0;
- //magic number
- if(b[offset+0] != 'q' || b[offset+1] != 'r' ||
- b[offset+2] != 'e' || b[offset+3] != 's') {
+ // magic number
+ if (b[offset + 0] != 'q' || b[offset + 1] != 'r' || b[offset + 2] != 'e'
+ || b[offset + 3] != 's') {
return false;
}
offset += 4;
@@ -1123,14 +1123,14 @@ public:
if (version >= 0x01 && version <= 0x03) {
buffer = b;
- setSource(version, b+tree_offset, b+name_offset, b+data_offset);
+ setSource(version, b + tree_offset, b + name_offset, b + data_offset);
return true;
}
return false;
}
};
-class QDynamicFileResourceRoot: public QDynamicBufferResourceRoot
+class QDynamicFileResourceRoot : public QDynamicBufferResourceRoot
{
QString fileName;
// for mmap'ed files, this is what needs to be unmapped.
@@ -1144,13 +1144,13 @@ public:
~QDynamicFileResourceRoot() {
#if defined(QT_USE_MMAP)
if (unmapPointer) {
- munmap((char*)unmapPointer, unmapLength);
+ munmap(reinterpret_cast<char *>(unmapPointer), unmapLength);
unmapPointer = nullptr;
unmapLength = 0;
} else
#endif
{
- delete [] mappingBuffer();
+ delete[] mappingBuffer();
}
}
QString mappingFile() const { return fileName; }
@@ -1173,7 +1173,7 @@ bool QDynamicFileResourceRoot::registerSelf(const QString &f)
qsizetype data_len = 0;
#if defined(QT_USE_MMAP)
- int fd = QT_OPEN(QFile::encodeName(f), O_RDONLY, 0666);
+ int fd = QT_OPEN(QFile::encodeName(f), O_RDONLY);
if (fd >= 0) {
QT_STATBUF st;
if (!QT_FSTAT(fd, &st) && st.st_size <= std::numeric_limits<qsizetype>::max()) {
@@ -1199,11 +1199,11 @@ bool QDynamicFileResourceRoot::registerSelf(const QString &f)
if (fsize <= std::numeric_limits<qsizetype>::max()) {
data_len = file.size();
data = new uchar[data_len];
- ok = (data_len == file.read((char*)data, data_len));
+ ok = (data_len == file.read(reinterpret_cast<char *>(data), data_len));
}
}
if (!ok) {
- delete [] data;
+ delete[] data;
data = nullptr;
data_len = 0;
return false;
@@ -1221,17 +1221,17 @@ bool QDynamicFileResourceRoot::registerSelf(const QString &f)
return false;
}
-static QString qt_resource_fixResourceRoot(QString r) {
- if(!r.isEmpty()) {
- if(r.startsWith(QLatin1Char(':')))
+static QString qt_resource_fixResourceRoot(QString r)
+{
+ if (!r.isEmpty()) {
+ if (r.startsWith(QLatin1Char(':')))
r = r.mid(1);
- if(!r.isEmpty())
+ if (!r.isEmpty())
r = QDir::cleanPath(r);
}
return r;
}
-
/*!
\fn bool QResource::registerResource(const QString &rccFileName, const QString &mapRoot)
@@ -1242,18 +1242,18 @@ static QString qt_resource_fixResourceRoot(QString r) {
\sa unregisterResource()
*/
-bool
-QResource::registerResource(const QString &rccFilename, const QString &resourceRoot)
+bool QResource::registerResource(const QString &rccFilename, const QString &resourceRoot)
{
QString r = qt_resource_fixResourceRoot(resourceRoot);
- if(!r.isEmpty() && r[0] != QLatin1Char('/')) {
- qWarning("QDir::registerResource: Registering a resource [%ls] must be rooted in an absolute path (start with /) [%ls]",
+ if (!r.isEmpty() && r[0] != QLatin1Char('/')) {
+ qWarning("QDir::registerResource: Registering a resource [%ls] must be rooted in an "
+ "absolute path (start with /) [%ls]",
qUtf16Printable(rccFilename), qUtf16Printable(resourceRoot));
return false;
}
QDynamicFileResourceRoot *root = new QDynamicFileResourceRoot(r);
- if(root->registerSelf(rccFilename)) {
+ if (root->registerSelf(rccFilename)) {
root->ref.ref();
const auto locker = qt_scoped_lock(resourceMutex());
resourceList()->append(root);
@@ -1274,20 +1274,19 @@ QResource::registerResource(const QString &rccFilename, const QString &resourceR
\sa registerResource()
*/
-bool
-QResource::unregisterResource(const QString &rccFilename, const QString &resourceRoot)
+bool QResource::unregisterResource(const QString &rccFilename, const QString &resourceRoot)
{
QString r = qt_resource_fixResourceRoot(resourceRoot);
const auto locker = qt_scoped_lock(resourceMutex());
ResourceList *list = resourceList();
- for(int i = 0; i < list->size(); ++i) {
+ for (int i = 0; i < list->size(); ++i) {
QResourceRoot *res = list->at(i);
- if(res->type() == QResourceRoot::Resource_File) {
- QDynamicFileResourceRoot *root = reinterpret_cast<QDynamicFileResourceRoot*>(res);
+ if (res->type() == QResourceRoot::Resource_File) {
+ QDynamicFileResourceRoot *root = reinterpret_cast<QDynamicFileResourceRoot *>(res);
if (root->mappingFile() == rccFilename && root->mappingRoot() == r) {
list->removeAt(i);
- if(!root->ref.deref()) {
+ if (!root->ref.deref()) {
delete root;
return true;
}
@@ -1298,7 +1297,6 @@ QResource::unregisterResource(const QString &rccFilename, const QString &resourc
return false;
}
-
/*!
\fn bool QResource::registerResource(const uchar *rccData, const QString &mapRoot)
\since 4.3
@@ -1313,12 +1311,12 @@ QResource::unregisterResource(const QString &rccFilename, const QString &resourc
\sa unregisterResource()
*/
-bool
-QResource::registerResource(const uchar *rccData, const QString &resourceRoot)
+bool QResource::registerResource(const uchar *rccData, const QString &resourceRoot)
{
QString r = qt_resource_fixResourceRoot(resourceRoot);
- if(!r.isEmpty() && r[0] != QLatin1Char('/')) {
- qWarning("QDir::registerResource: Registering a resource [%p] must be rooted in an absolute path (start with /) [%ls]",
+ if (!r.isEmpty() && r[0] != QLatin1Char('/')) {
+ qWarning("QDir::registerResource: Registering a resource [%p] must be rooted in an "
+ "absolute path (start with /) [%ls]",
rccData, qUtf16Printable(resourceRoot));
return false;
}
@@ -1345,20 +1343,19 @@ QResource::registerResource(const uchar *rccData, const QString &resourceRoot)
\sa registerResource()
*/
-bool
-QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot)
+bool QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot)
{
QString r = qt_resource_fixResourceRoot(resourceRoot);
const auto locker = qt_scoped_lock(resourceMutex());
ResourceList *list = resourceList();
- for(int i = 0; i < list->size(); ++i) {
+ for (int i = 0; i < list->size(); ++i) {
QResourceRoot *res = list->at(i);
- if(res->type() == QResourceRoot::Resource_Buffer) {
- QDynamicBufferResourceRoot *root = reinterpret_cast<QDynamicBufferResourceRoot*>(res);
+ if (res->type() == QResourceRoot::Resource_Buffer) {
+ QDynamicBufferResourceRoot *root = reinterpret_cast<QDynamicBufferResourceRoot *>(res);
if (root->mappingBuffer() == rccData && root->mappingRoot() == r) {
list->removeAt(i);
- if(!root->ref.deref()) {
+ if (!root->ref.deref()) {
delete root;
return true;
}
@@ -1370,7 +1367,7 @@ QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot)
}
#if !defined(QT_BOOTSTRAPPED)
-//resource engine
+// resource engine
class QResourceFileEnginePrivate : public QAbstractFileEnginePrivate
{
protected:
@@ -1466,14 +1463,14 @@ bool QResourceFileEngine::flush()
qint64 QResourceFileEngine::read(char *data, qint64 len)
{
Q_D(QResourceFileEngine);
- if(len > size()-d->offset)
- len = size()-d->offset;
- if(len <= 0)
+ if (len > size() - d->offset)
+ len = size() - d->offset;
+ if (len <= 0)
return 0;
if (!d->uncompressed.isNull())
- memcpy(data, d->uncompressed.constData()+d->offset, len);
+ memcpy(data, d->uncompressed.constData() + d->offset, len);
else
- memcpy(data, d->resource.data()+d->offset, len);
+ memcpy(data, d->resource.data() + d->offset, len);
d->offset += len;
return len;
}
@@ -1518,7 +1515,7 @@ qint64 QResourceFileEngine::pos() const
bool QResourceFileEngine::atEnd() const
{
Q_D(const QResourceFileEngine);
- if(!d->resource.isValid())
+ if (!d->resource.isValid())
return true;
return d->offset == size();
}
@@ -1526,10 +1523,10 @@ bool QResourceFileEngine::atEnd() const
bool QResourceFileEngine::seek(qint64 pos)
{
Q_D(QResourceFileEngine);
- if(!d->resource.isValid())
+ if (!d->resource.isValid())
return false;
- if(d->offset > size())
+ if (d->offset > size())
return false;
d->offset = pos;
return true;
@@ -1544,20 +1541,21 @@ QAbstractFileEngine::FileFlags QResourceFileEngine::fileFlags(QAbstractFileEngin
{
Q_D(const QResourceFileEngine);
QAbstractFileEngine::FileFlags ret;
- if(!d->resource.isValid())
+ if (!d->resource.isValid())
return ret;
- if(type & PermsMask)
- ret |= QAbstractFileEngine::FileFlags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm);
- if(type & TypesMask) {
- if(d->resource.isDir())
+ if (type & PermsMask)
+ ret |= QAbstractFileEngine::FileFlags(ReadOwnerPerm | ReadUserPerm | ReadGroupPerm
+ | ReadOtherPerm);
+ if (type & TypesMask) {
+ if (d->resource.isDir())
ret |= DirectoryType;
else
ret |= FileType;
}
- if(type & FlagsMask) {
+ if (type & FlagsMask) {
ret |= ExistsFlag;
- if(d->resource.absoluteFilePath() == QLatin1String(":/"))
+ if (d->resource.absoluteFilePath() == QLatin1String(":/"))
ret |= RootFlag;
}
return ret;
@@ -1571,13 +1569,14 @@ bool QResourceFileEngine::setPermissions(uint)
QString QResourceFileEngine::fileName(FileName file) const
{
Q_D(const QResourceFileEngine);
- if(file == BaseName) {
+ if (file == BaseName) {
int slash = d->resource.fileName().lastIndexOf(QLatin1Char('/'));
if (slash == -1)
return d->resource.fileName();
return d->resource.fileName().mid(slash + 1);
- } else if(file == PathName || file == AbsolutePathName) {
- const QString path = (file == AbsolutePathName) ? d->resource.absoluteFilePath() : d->resource.fileName();
+ } else if (file == PathName || file == AbsolutePathName) {
+ const QString path = (file == AbsolutePathName) ? d->resource.absoluteFilePath()
+ : d->resource.fileName();
const int slash = path.lastIndexOf(QLatin1Char('/'));
if (slash == -1)
return QLatin1String(":");
@@ -1585,9 +1584,9 @@ QString QResourceFileEngine::fileName(FileName file) const
return QLatin1String(":/");
return path.left(slash);
- } else if(file == CanonicalName || file == CanonicalPathName) {
+ } else if (file == CanonicalName || file == CanonicalPathName) {
const QString absoluteFilePath = d->resource.absoluteFilePath();
- if(file == CanonicalPathName) {
+ if (file == CanonicalPathName) {
const int slash = absoluteFilePath.lastIndexOf(QLatin1Char('/'));
if (slash != -1)
return absoluteFilePath.left(slash);
@@ -1604,7 +1603,7 @@ bool QResourceFileEngine::isRelativePath() const
uint QResourceFileEngine::ownerId(FileOwner) const
{
- static const uint nobodyID = (uint) -2;
+ static const uint nobodyID = static_cast<uint>(-2);
return nobodyID;
}
@@ -1642,13 +1641,13 @@ bool QResourceFileEngine::extension(Extension extension, const ExtensionOption *
{
Q_D(QResourceFileEngine);
if (extension == MapExtension) {
- const MapExtensionOption *options = (const MapExtensionOption*)(option);
- MapExtensionReturn *returnValue = static_cast<MapExtensionReturn*>(output);
+ const auto *options = static_cast<const MapExtensionOption *>(option);
+ auto *returnValue = static_cast<MapExtensionReturn *>(output);
returnValue->address = d->map(options->offset, options->size, options->flags);
return (returnValue->address != nullptr);
}
if (extension == UnMapExtension) {
- const UnMapExtensionOption *options = (const UnMapExtensionOption*)option;
+ const auto *options = static_cast<const UnMapExtensionOption *>(option);
return d->unmap(options->address);
}
return false;
diff --git a/src/corelib/io/qresource.h b/src/corelib/io/qresource.h
index 8f17c1f075..0361f435b3 100644
--- a/src/corelib/io/qresource.h
+++ b/src/corelib/io/qresource.h
@@ -61,7 +61,7 @@ public:
ZstdCompression
};
- QResource(const QString &file=QString(), const QLocale &locale=QLocale());
+ QResource(const QString &file = QString(), const QLocale &locale = QLocale());
~QResource();
void setFileName(const QString &file);
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 42a0f38be3..c32a534a14 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -108,7 +108,7 @@ struct QConfFileCustomFormat
QSettings::WriteFunc writeFunc;
Qt::CaseSensitivity caseSensitivity;
};
-Q_DECLARE_TYPEINFO(QConfFileCustomFormat, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QConfFileCustomFormat, Q_RELOCATABLE_TYPE);
typedef QHash<QString, QConfFile *> ConfFileHash;
typedef QCache<QString, QConfFile> ConfFileCache;
@@ -381,7 +381,7 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
{
QString result;
- switch (v.userType()) {
+ switch (v.metaType().id()) {
case QMetaType::UnknownType:
result = QLatin1String("@Invalid()");
break;
@@ -667,7 +667,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result)
escapeNextIfDigit = true;
} else if (useCodec) {
// slow
- result += toUtf8(&unicode[i], 1);
+ result += toUtf8(unicode[i]);
} else {
result += (char)ch;
}
@@ -815,7 +815,7 @@ StNormal:
++j;
}
- stringResult += fromUtf8(str.constData() + i, j - i);
+ stringResult += fromUtf8(QByteArrayView(str).first(j).sliced(i));
i = j;
}
}
@@ -1715,7 +1715,7 @@ public:
int position;
};
-Q_DECLARE_TYPEINFO(QSettingsIniKey, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QSettingsIniKey, Q_RELOCATABLE_TYPE);
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
{
@@ -1734,7 +1734,7 @@ struct QSettingsIniSection
inline QSettingsIniSection() : position(-1) {}
};
-Q_DECLARE_TYPEINFO(QSettingsIniSection, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QSettingsIniSection, Q_RELOCATABLE_TYPE);
typedef QMap<QString, QSettingsIniSection> IniMap;
@@ -1815,8 +1815,8 @@ bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSetti
QVariant(QString("foo")).toList() returns an empty
list, not a list containing "foo".
*/
- if (value.userType() == QMetaType::QStringList
- || (value.userType() == QMetaType::QVariantList && value.toList().size() != 1)) {
+ if (value.metaType().id() == QMetaType::QStringList
+ || (value.metaType().id() == QMetaType::QVariantList && value.toList().size() != 1)) {
iniEscapedStringList(variantListToStringList(value.toList()), block);
} else {
iniEscapedString(variantToString(value), block);
@@ -2171,7 +2171,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
\endlist
\note If XDG_CONFIG_DIRS is unset, the default value of \c{/etc/xdg} is used.
- On \macos versions 10.2 and 10.3, these files are used by
+ On \macos and iOS, if the file format is NativeFormat, these files are used by
default:
\list 1
@@ -2338,7 +2338,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
\endlist
- \sa QVariant, QSessionManager, {Settings Editor Example}, {Application Example}
+ \sa QVariant, QSessionManager, {Settings Editor Example}, {Qt Widgets - Application Example}