summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in2
-rw-r--r--src/corelib/Qt5CoreMacros.cmake3
-rw-r--r--src/corelib/animation/qanimationgroup_p.h4
-rw-r--r--src/corelib/animation/qparallelanimationgroup_p.h4
-rw-r--r--src/corelib/animation/qpropertyanimation_p.h4
-rw-r--r--src/corelib/animation/qsequentialanimationgroup_p.h4
-rw-r--r--src/corelib/animation/qvariantanimation_p.h4
-rw-r--r--src/corelib/arch/arch.pri4
-rw-r--r--src/corelib/arch/qatomic_msvc.h42
-rw-r--r--src/corelib/codecs/codecs.pri28
-rw-r--r--src/corelib/codecs/cp949codetbl_p.h2
-rw-r--r--src/corelib/codecs/qbig5codec_p.h1
-rw-r--r--src/corelib/codecs/qeuckrcodec_p.h1
-rw-r--r--src/corelib/codecs/qgb18030codec_p.h1
-rw-r--r--src/corelib/codecs/qiconvcodec.cpp2
-rw-r--r--src/corelib/codecs/qiconvcodec_p.h7
-rw-r--r--src/corelib/codecs/qicucodec.cpp10
-rw-r--r--src/corelib/codecs/qicucodec_p.h2
-rw-r--r--src/corelib/codecs/qisciicodec_p.h1
-rw-r--r--src/corelib/codecs/qjiscodec.cpp2
-rw-r--r--src/corelib/codecs/qjpunicode_p.h2
-rw-r--r--src/corelib/codecs/qlatincodec_p.h1
-rw-r--r--src/corelib/codecs/qsimplecodec_p.h1
-rw-r--r--src/corelib/codecs/qtextcodec.cpp6
-rw-r--r--src/corelib/codecs/qtextcodec_p.h1
-rw-r--r--src/corelib/codecs/qtsciicodec_p.h1
-rw-r--r--src/corelib/codecs/qutfcodec.cpp87
-rw-r--r--src/corelib/codecs/qwindowscodec.cpp2
-rw-r--r--src/corelib/codecs/qwindowscodec_p.h1
-rw-r--r--src/corelib/configure.json611
-rw-r--r--src/corelib/corelib.pro19
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp36
-rw-r--r--src/corelib/doc/src/animation.qdoc2
-rw-r--r--src/corelib/doc/src/qtcore-index.qdoc14
-rw-r--r--src/corelib/global/qcompilerdetection.h26
-rw-r--r--src/corelib/global/qconfig-dist.h48
-rw-r--r--src/corelib/global/qconfig-large.h140
-rw-r--r--src/corelib/global/qconfig-medium.h241
-rw-r--r--src/corelib/global/qconfig-minimal.h463
-rw-r--r--src/corelib/global/qconfig-nacl.h233
-rw-r--r--src/corelib/global/qconfig-small.h281
-rw-r--r--src/corelib/global/qfeatures.txt6
-rw-r--r--src/corelib/global/qflags.h9
-rw-r--r--src/corelib/global/qglobal.cpp413
-rw-r--r--src/corelib/global/qglobal.h125
-rw-r--r--src/corelib/global/qglobal_p.h62
-rw-r--r--src/corelib/global/qhooks.cpp2
-rw-r--r--src/corelib/global/qhooks_p.h2
-rw-r--r--src/corelib/global/qlibraryinfo.cpp43
-rw-r--r--src/corelib/global/qlibraryinfo.h11
-rw-r--r--src/corelib/global/qlogging.cpp12
-rw-r--r--src/corelib/global/qnamespace.h8
-rw-r--r--src/corelib/global/qnamespace.qdoc33
-rw-r--r--src/corelib/global/qnumeric_p.h4
-rw-r--r--src/corelib/global/qprocessordetection.h2
-rw-r--r--src/corelib/global/qsysinfo.h20
-rw-r--r--src/corelib/global/qsystemdetection.h20
-rw-r--r--src/corelib/global/qt_windows.h17
-rw-r--r--src/corelib/io/io.pri39
-rw-r--r--src/corelib/io/qabstractfileengine_p.h1
-rw-r--r--src/corelib/io/qdatastream.cpp1
-rw-r--r--src/corelib/io/qdatastream.h5
-rw-r--r--src/corelib/io/qdatastream_p.h1
-rw-r--r--src/corelib/io/qdataurl_p.h1
-rw-r--r--src/corelib/io/qdebug.h4
-rw-r--r--src/corelib/io/qdebug_p.h1
-rw-r--r--src/corelib/io/qdir.cpp10
-rw-r--r--src/corelib/io/qfileselector.cpp13
-rw-r--r--src/corelib/io/qfileselector_p.h2
-rw-r--r--src/corelib/io/qfilesystemengine.cpp29
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp7
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp260
-rw-r--r--src/corelib/io/qfilesystementry_p.h1
-rw-r--r--src/corelib/io/qfilesystemiterator_win.cpp5
-rw-r--r--src/corelib/io/qfilesystemmetadata_p.h16
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp4
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents.mm8
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents_p.h6
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify_p.h6
-rw-r--r--src/corelib/io/qfilesystemwatcher_kqueue_p.h6
-rw-r--r--src/corelib/io/qfilesystemwatcher_p.h6
-rw-r--r--src/corelib/io/qfilesystemwatcher_polling_p.h6
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp10
-rw-r--r--src/corelib/io/qfilesystemwatcher_win_p.h6
-rw-r--r--src/corelib/io/qfsfileengine.cpp8
-rw-r--r--src/corelib/io/qfsfileengine_p.h9
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp141
-rw-r--r--src/corelib/io/qiodevice.cpp45
-rw-r--r--src/corelib/io/qiodevice_p.h4
-rw-r--r--src/corelib/io/qipaddress_p.h7
-rw-r--r--src/corelib/io/qlockfile.cpp13
-rw-r--r--src/corelib/io/qlockfile_p.h1
-rw-r--r--src/corelib/io/qlockfile_unix.cpp4
-rw-r--r--src/corelib/io/qlockfile_win.cpp4
-rw-r--r--src/corelib/io/qloggingregistry_p.h1
-rw-r--r--src/corelib/io/qprocess.cpp14
-rw-r--r--src/corelib/io/qprocess_unix.cpp2
-rw-r--r--src/corelib/io/qprocess_win.cpp4
-rw-r--r--src/corelib/io/qprocess_wince.cpp308
-rw-r--r--src/corelib/io/qresource.cpp4
-rw-r--r--src/corelib/io/qsettings.cpp106
-rw-r--r--src/corelib/io/qsettings_mac.cpp55
-rw-r--r--src/corelib/io/qsettings_p.h4
-rw-r--r--src/corelib/io/qsettings_win.cpp10
-rw-r--r--src/corelib/io/qstandardpaths.h7
-rw-r--r--src/corelib/io/qstandardpaths_mac.mm4
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp2
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp42
-rw-r--r--src/corelib/io/qstorageinfo_p.h3
-rw-r--r--src/corelib/io/qtemporaryfile.cpp27
-rw-r--r--src/corelib/io/qtemporaryfile_p.h5
-rw-r--r--src/corelib/io/qtextstream.cpp3
-rw-r--r--src/corelib/io/qtextstream_p.h1
-rw-r--r--src/corelib/io/qtldurl_p.h1
-rw-r--r--src/corelib/io/qurl.cpp62
-rw-r--r--src/corelib/io/qurl.h16
-rw-r--r--src/corelib/io/qurl_p.h1
-rw-r--r--src/corelib/io/qurltlds_p.h2
-rw-r--r--src/corelib/io/qwindowspipereader.cpp17
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp5
-rw-r--r--src/corelib/io/qwindowspipewriter_p.h1
-rw-r--r--src/corelib/io/qwinoverlappedionotifier_p.h1
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp58
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h10
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel_p.h2
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.h11
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp35
-rw-r--r--src/corelib/json/qjson.cpp4
-rw-r--r--src/corelib/json/qjson_p.h20
-rw-r--r--src/corelib/json/qjsondocument.cpp4
-rw-r--r--src/corelib/json/qjsonparser_p.h1
-rw-r--r--src/corelib/json/qjsonvalue.cpp3
-rw-r--r--src/corelib/json/qjsonwriter_p.h2
-rw-r--r--src/corelib/kernel/kernel.pri45
-rw-r--r--src/corelib/kernel/qcfsocketnotifier_p.h1
-rw-r--r--src/corelib/kernel/qcore_foundation.mm537
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm4
-rw-r--r--src/corelib/kernel/qcore_mac_p.h2
-rw-r--r--src/corelib/kernel/qcore_unix_p.h5
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp45
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp34
-rw-r--r--src/corelib/kernel/qcorecmdlineargs_p.h89
-rw-r--r--src/corelib/kernel/qcoreglobaldata_p.h1
-rw-r--r--src/corelib/kernel/qcrashhandler_p.h2
-rw-r--r--src/corelib/kernel/qdeadlinetimer.cpp825
-rw-r--r--src/corelib/kernel/qdeadlinetimer.h191
-rw-r--r--src/corelib/kernel/qdeadlinetimer_p.h (renamed from src/corelib/io/qurl_mac.mm)54
-rw-r--r--src/corelib/kernel/qelapsedtimer.cpp (renamed from src/corelib/tools/qelapsedtimer.cpp)7
-rw-r--r--src/corelib/kernel/qelapsedtimer.h (renamed from src/corelib/tools/qelapsedtimer.h)0
-rw-r--r--src/corelib/kernel/qelapsedtimer_generic.cpp (renamed from src/corelib/tools/qelapsedtimer_generic.cpp)9
-rw-r--r--src/corelib/kernel/qelapsedtimer_mac.cpp (renamed from src/corelib/tools/qelapsedtimer_mac.cpp)29
-rw-r--r--src/corelib/kernel/qelapsedtimer_unix.cpp (renamed from src/corelib/tools/qelapsedtimer_unix.cpp)14
-rw-r--r--src/corelib/kernel/qelapsedtimer_win.cpp (renamed from src/corelib/tools/qelapsedtimer_win.cpp)71
-rw-r--r--src/corelib/kernel/qeventdispatcher_cf.mm16
-rw-r--r--src/corelib/kernel/qeventdispatcher_cf_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp266
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt.cpp113
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt_p.h1
-rw-r--r--src/corelib/kernel/qeventloop_p.h1
-rw-r--r--src/corelib/kernel/qfunctions_fake_env_p.h6
-rw-r--r--src/corelib/kernel/qfunctions_p.h6
-rw-r--r--src/corelib/kernel/qfunctions_wince.cpp407
-rw-r--r--src/corelib/kernel/qfunctions_wince.h473
-rw-r--r--src/corelib/kernel/qjni_p.h2
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp132
-rw-r--r--src/corelib/kernel/qjnihelpers_p.h14
-rw-r--r--src/corelib/kernel/qmath.h22
-rw-r--r--src/corelib/kernel/qmetaobject.cpp23
-rw-r--r--src/corelib/kernel/qmetaobject.h11
-rw-r--r--src/corelib/kernel/qmetaobject_moc_p.h2
-rw-r--r--src/corelib/kernel/qmetaobject_p.h15
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder_p.h1
-rw-r--r--src/corelib/kernel/qmetatype.cpp10
-rw-r--r--src/corelib/kernel/qmetatype.h23
-rw-r--r--src/corelib/kernel/qmetatype_p.h1
-rw-r--r--src/corelib/kernel/qmimedata.cpp4
-rw-r--r--src/corelib/kernel/qobject.cpp79
-rw-r--r--src/corelib/kernel/qobject.h4
-rw-r--r--src/corelib/kernel/qobject_impl.h16
-rw-r--r--src/corelib/kernel/qobject_p.h1
-rw-r--r--src/corelib/kernel/qobjectdefs.h11
-rw-r--r--src/corelib/kernel/qobjectdefs_impl.h46
-rw-r--r--src/corelib/kernel/qppsattribute_p.h1
-rw-r--r--src/corelib/kernel/qppsobject.cpp24
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp8
-rw-r--r--src/corelib/kernel/qsystemerror.cpp25
-rw-r--r--src/corelib/kernel/qsystemerror_p.h1
-rw-r--r--src/corelib/kernel/qsystemsemaphore_p.h4
-rw-r--r--src/corelib/kernel/qsystemsemaphore_posix.cpp4
-rw-r--r--src/corelib/kernel/qsystemsemaphore_systemv.cpp3
-rw-r--r--src/corelib/kernel/qsystemsemaphore_win.cpp4
-rw-r--r--src/corelib/kernel/qtimer.cpp72
-rw-r--r--src/corelib/kernel/qtimer.h99
-rw-r--r--src/corelib/kernel/qtimerinfo_unix.cpp3
-rw-r--r--src/corelib/kernel/qtimerinfo_unix_p.h2
-rw-r--r--src/corelib/kernel/qtranslator.cpp5
-rw-r--r--src/corelib/kernel/qtranslator_p.h2
-rw-r--r--src/corelib/kernel/qvariant.cpp6
-rw-r--r--src/corelib/mimetypes/mimetypes.pri6
-rw-r--r--src/corelib/mimetypes/qmimeglobpattern.cpp2
-rw-r--r--src/corelib/mimetypes/qmimeglobpattern_p.h2
-rw-r--r--src/corelib/mimetypes/qmimemagicrule_p.h2
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp40
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp9
-rw-r--r--src/corelib/mimetypes/qmimetype_p.h1
-rw-r--r--src/corelib/mimetypes/qmimetypeparser.cpp2
-rw-r--r--src/corelib/plugin/plugin.pri4
-rw-r--r--src/corelib/plugin/qelfparser_p.h2
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp12
-rw-r--r--src/corelib/plugin/qfactoryloader_p.h64
-rw-r--r--src/corelib/plugin/qlibrary.cpp8
-rw-r--r--src/corelib/plugin/qlibrary_p.h1
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp16
-rw-r--r--src/corelib/plugin/qlibrary_win.cpp21
-rw-r--r--src/corelib/plugin/qmachparser.cpp3
-rw-r--r--src/corelib/plugin/qmachparser_p.h2
-rw-r--r--src/corelib/plugin/qpluginloader.cpp5
-rw-r--r--src/corelib/plugin/qsystemlibrary.cpp16
-rw-r--r--src/corelib/plugin/qsystemlibrary_p.h6
-rw-r--r--src/corelib/plugin/quuid.cpp37
-rw-r--r--src/corelib/plugin/quuid.h6
-rw-r--r--src/corelib/plugin/quuid_darwin.mm75
-rw-r--r--src/corelib/statemachine/qabstractstate_p.h8
-rw-r--r--src/corelib/statemachine/qhistorystate_p.h6
-rw-r--r--src/corelib/statemachine/qsignaleventgenerator_p.h1
-rw-r--r--src/corelib/statemachine/qsignaltransition.h1
-rw-r--r--src/corelib/statemachine/qstate.h1
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp12
-rw-r--r--src/corelib/statemachine/qstatemachine.h2
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h6
-rw-r--r--src/corelib/statemachine/statemachine.pri10
-rw-r--r--src/corelib/thread/qfuture.h25
-rw-r--r--src/corelib/thread/qfutureinterface.h10
-rw-r--r--src/corelib/thread/qfutureinterface_p.h1
-rw-r--r--src/corelib/thread/qmutex.cpp55
-rw-r--r--src/corelib/thread/qmutex.h57
-rw-r--r--src/corelib/thread/qmutex_p.h2
-rw-r--r--src/corelib/thread/qmutex_win.cpp4
-rw-r--r--src/corelib/thread/qmutexpool_p.h5
-rw-r--r--src/corelib/thread/qorderedmutexlocker_p.h1
-rw-r--r--src/corelib/thread/qreadwritelock_p.h2
-rw-r--r--src/corelib/thread/qthread.cpp4
-rw-r--r--src/corelib/thread/qthread_unix.cpp4
-rw-r--r--src/corelib/thread/qthread_win.cpp44
-rw-r--r--src/corelib/thread/qwaitcondition.h3
-rw-r--r--src/corelib/thread/qwaitcondition.qdoc15
-rw-r--r--src/corelib/thread/qwaitcondition_win.cpp5
-rw-r--r--src/corelib/tools/qalgorithms.h209
-rw-r--r--src/corelib/tools/qbytearray.cpp85
-rw-r--r--src/corelib/tools/qbytearray.h8
-rw-r--r--src/corelib/tools/qbytearray_mac.mm99
-rw-r--r--src/corelib/tools/qbytearraylist.h2
-rw-r--r--src/corelib/tools/qbytedata_p.h1
-rw-r--r--src/corelib/tools/qchar.h12
-rw-r--r--src/corelib/tools/qcollator_p.h1
-rw-r--r--src/corelib/tools/qcommandlineoption.cpp58
-rw-r--r--src/corelib/tools/qcommandlineoption.h16
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp28
-rw-r--r--src/corelib/tools/qcryptographichash.h3
-rw-r--r--src/corelib/tools/qdatetime.cpp1051
-rw-r--r--src/corelib/tools/qdatetime.h89
-rw-r--r--src/corelib/tools/qdatetime_mac.mm74
-rw-r--r--src/corelib/tools/qdatetime_p.h71
-rw-r--r--src/corelib/tools/qdatetimeparser.cpp11
-rw-r--r--src/corelib/tools/qdatetimeparser_p.h1
-rw-r--r--src/corelib/tools/qfreelist_p.h1
-rw-r--r--src/corelib/tools/qharfbuzz_p.h2
-rw-r--r--src/corelib/tools/qhash.cpp20
-rw-r--r--src/corelib/tools/qhash.h21
-rw-r--r--src/corelib/tools/qline.cpp23
-rw-r--r--src/corelib/tools/qline.h14
-rw-r--r--src/corelib/tools/qlinkedlist.h16
-rw-r--r--src/corelib/tools/qlist.h5
-rw-r--r--src/corelib/tools/qlocale.cpp1
-rw-r--r--src/corelib/tools/qlocale_data_p.h2
-rw-r--r--src/corelib/tools/qlocale_mac.mm3
-rw-r--r--src/corelib/tools/qlocale_p.h1
-rw-r--r--src/corelib/tools/qlocale_win.cpp122
-rw-r--r--src/corelib/tools/qpodlist_p.h1
-rw-r--r--src/corelib/tools/qpoint.h13
-rw-r--r--src/corelib/tools/qrect.h13
-rw-r--r--src/corelib/tools/qregexp.cpp6
-rw-r--r--src/corelib/tools/qringbuffer.cpp46
-rw-r--r--src/corelib/tools/qringbuffer_p.h9
-rw-r--r--src/corelib/tools/qscopedpointer.cpp42
-rw-r--r--src/corelib/tools/qscopedpointer.h45
-rw-r--r--src/corelib/tools/qscopedpointer_p.h2
-rw-r--r--src/corelib/tools/qsharedpointer.cpp112
-rw-r--r--src/corelib/tools/qsharedpointer.h14
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h162
-rw-r--r--src/corelib/tools/qsimd.cpp29
-rw-r--r--src/corelib/tools/qsimd_p.h66
-rw-r--r--src/corelib/tools/qsize.h13
-rw-r--r--src/corelib/tools/qstring.cpp248
-rw-r--r--src/corelib/tools/qstring.h213
-rw-r--r--src/corelib/tools/qstring_mac.mm83
-rw-r--r--src/corelib/tools/qstringiterator_p.h1
-rw-r--r--src/corelib/tools/qstringlist.cpp40
-rw-r--r--src/corelib/tools/qstringlist.h9
-rw-r--r--src/corelib/tools/qtimezoneprivate_data_p.h2
-rw-r--r--src/corelib/tools/qtimezoneprivate_win.cpp6
-rw-r--r--src/corelib/tools/qtools_p.h2
-rw-r--r--src/corelib/tools/qunicodetables_p.h2
-rw-r--r--src/corelib/tools/qunicodetools.cpp4
-rw-r--r--src/corelib/tools/qunicodetools_p.h1
-rw-r--r--src/corelib/tools/tools.pri36
-rw-r--r--src/corelib/xml/qxmlstream.cpp24
-rw-r--r--src/corelib/xml/qxmlstream_p.h16
-rw-r--r--src/corelib/xml/qxmlutils_p.h1
310 files changed, 6283 insertions, 6273 deletions
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index a5ed8b2ea3..545b9a3d1e 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -116,7 +116,7 @@ set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS $<$<
set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_FEATURES cxx_decltype)
-!!IF contains(QT_CONFIG, reduce_exports)
+!!IF qtConfig(reduce_exports)
set(QT_VISIBILITY_AVAILABLE \"True\")
!!ENDIF
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index 9235641544..23909c9f3f 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -90,6 +90,9 @@ macro(QT5_GET_MOC_FLAGS _moc_flags)
if(WIN32)
set(${_moc_flags} ${${_moc_flags}} -DWIN32)
endif()
+ if (MSVC)
+ set(${_moc_flags} --compiler-flavor=msvc)
+ endif()
endmacro()
diff --git a/src/corelib/animation/qanimationgroup_p.h b/src/corelib/animation/qanimationgroup_p.h
index 240e5100b9..31c2cd08e8 100644
--- a/src/corelib/animation/qanimationgroup_p.h
+++ b/src/corelib/animation/qanimationgroup_p.h
@@ -44,8 +44,8 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of QIODevice. This header file may change from version to
+// 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.
diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h
index 752a7c5359..069ba8e51a 100644
--- a/src/corelib/animation/qparallelanimationgroup_p.h
+++ b/src/corelib/animation/qparallelanimationgroup_p.h
@@ -44,8 +44,8 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of QIODevice. This header file may change from version to
+// 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.
diff --git a/src/corelib/animation/qpropertyanimation_p.h b/src/corelib/animation/qpropertyanimation_p.h
index 5e189f4ced..cfb1f247e0 100644
--- a/src/corelib/animation/qpropertyanimation_p.h
+++ b/src/corelib/animation/qpropertyanimation_p.h
@@ -44,8 +44,8 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of QIODevice. This header file may change from version to
+// 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.
diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h
index edcae7db2a..1b07e1330a 100644
--- a/src/corelib/animation/qsequentialanimationgroup_p.h
+++ b/src/corelib/animation/qsequentialanimationgroup_p.h
@@ -44,8 +44,8 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of QIODevice. This header file may change from version to
+// 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.
diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h
index c75933dff8..37318a5339 100644
--- a/src/corelib/animation/qvariantanimation_p.h
+++ b/src/corelib/animation/qvariantanimation_p.h
@@ -44,8 +44,8 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of QIODevice. This header file may change from version to
+// 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.
diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri
index ec617386a4..b628bcc6ec 100644
--- a/src/corelib/arch/arch.pri
+++ b/src/corelib/arch/arch.pri
@@ -1,7 +1,7 @@
-win32|wince:HEADERS += arch/qatomic_msvc.h
+win32:HEADERS += arch/qatomic_msvc.h
HEADERS += \
arch/qatomic_bootstrap.h \
arch/qatomic_cxx11.h
-atomic64-libatomic: LIBS += -latomic
+qtConfig(libatomic): QMAKE_USE += libatomic
diff --git a/src/corelib/arch/qatomic_msvc.h b/src/corelib/arch/qatomic_msvc.h
index 62d54ded55..5eae2bdc48 100644
--- a/src/corelib/arch/qatomic_msvc.h
+++ b/src/corelib/arch/qatomic_msvc.h
@@ -45,8 +45,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
-#ifndef Q_OS_WINCE
-
// use compiler intrinsics for all atomic functions
# define QT_INTERLOCKED_PREFIX _
# define QT_INTERLOCKED_PROTOTYPE
@@ -58,36 +56,6 @@
# define Q_ATOMIC_INT64_IS_SUPPORTED
# endif
-#else // Q_OS_WINCE
-
-# if _WIN32_WCE < 0x600 && defined(_X86_)
-// For X86 Windows CE, include winbase.h to catch inline functions which
-// override the regular definitions inside of coredll.dll.
-// Though one could use the original version of Increment/Decrement, others are
-// not exported at all.
-# include <winbase.h>
-
-// It's safer to remove the volatile and let the compiler add it as needed.
-# define QT_INTERLOCKED_VOLATILE
-
-# else // _WIN32_WCE >= 0x600 || !_X86_
-
-# define QT_INTERLOCKED_PROTOTYPE __cdecl
-# define QT_INTERLOCKED_DECLARE_PROTOTYPES
-
-# if _WIN32_WCE >= 0x600
-# if defined(_X86_)
-# define QT_INTERLOCKED_PREFIX _
-# define QT_INTERLOCKED_INTRINSIC
-# endif
-# else
-# define QT_INTERLOCKED_VOLATILE
-# endif
-
-# endif // _WIN32_WCE >= 0x600 || !_X86_
-
-#endif // Q_OS_WINCE
-
////////////////////////////////////////////////////////////////////////////////////////////////////
// Prototype declaration
@@ -128,7 +96,7 @@ extern "C" {
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange )(long QT_INTERLOCKED_VOLATILE *, long);
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long);
-# if !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+# if !defined(__i386__) && !defined(_M_IX86)
void * QT_INTERLOCKED_FUNCTION( CompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *);
void * QT_INTERLOCKED_FUNCTION( ExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *);
__int64 QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64);
@@ -165,7 +133,7 @@ extern "C" {
# pragma intrinsic (_InterlockedCompareExchange)
# pragma intrinsic (_InterlockedExchangeAdd)
-# if !defined(Q_OS_WINCE) && !defined(_M_IX86)
+# if !defined(_M_IX86)
# pragma intrinsic (_InterlockedCompareExchangePointer)
# pragma intrinsic (_InterlockedExchangePointer)
# pragma intrinsic (_InterlockedExchangeAdd64)
@@ -176,7 +144,7 @@ extern "C" {
////////////////////////////////////////////////////////////////////////////////////////////////////
// Interlocked* replacement macros
-#if defined(Q_OS_WINCE) || defined(__i386__) || defined(_M_IX86)
+#if defined(__i386__) || defined(_M_IX86)
# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
reinterpret_cast<void *>( \
@@ -195,7 +163,7 @@ extern "C" {
reinterpret_cast<long QT_INTERLOCKED_VOLATILE *>(value), \
(valueToAdd))
-#else // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+#else // !defined(__i386__) && !defined(_M_IX86)
# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
QT_INTERLOCKED_FUNCTION(CompareExchangePointer)( \
@@ -213,7 +181,7 @@ extern "C" {
reinterpret_cast<qint64 QT_INTERLOCKED_VOLATILE *>(value), \
(valueToAdd))
-#endif // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+#endif // !defined(__i386__) && !defined(_M_IX86)
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
index bfb677e6fb..4fa778d042 100644
--- a/src/corelib/codecs/codecs.pri
+++ b/src/corelib/codecs/codecs.pri
@@ -17,7 +17,7 @@ SOURCES += \
codecs/qtsciicodec.cpp \
codecs/qutfcodec.cpp
-contains(QT_CONFIG,icu) {
+qtConfig(icu) {
HEADERS += \
codecs/qicucodec_p.h
SOURCES += \
@@ -40,23 +40,17 @@ contains(QT_CONFIG,icu) {
codecs/qeuckrcodec.cpp \
codecs/qbig5codec.cpp
- unix:!qnx:!mac:!ios:!linux-android-* {
- contains(QT_CONFIG,iconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- } else:contains(QT_CONFIG,gnu-libiconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- DEFINES += GNU_LIBICONV
- LIBS_PRIVATE *= -liconv
- } else:contains(QT_CONFIG,sun-libiconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- DEFINES += GNU_LIBICONV
- }
- } else:!win32-msvc* {
- DEFINES += QT_NO_ICONV
+ qtConfig(iconv) {
+ HEADERS += codecs/qiconvcodec_p.h
+ SOURCES += codecs/qiconvcodec.cpp
+ qtConfig(gnu-libiconv) {
+ DEFINES += GNU_LIBICONV
+ QMAKE_USE_PRIVATE += iconv
+ } else: qtConfig(sun-libiconv) {
+ DEFINES += GNU_LIBICONV
+ }
}
+
win32 {
SOURCES += codecs/qwindowscodec.cpp
HEADERS += codecs/qwindowscodec_p.h
diff --git a/src/corelib/codecs/cp949codetbl_p.h b/src/corelib/codecs/cp949codetbl_p.h
index 3d55bcfac9..3b615d4e17 100644
--- a/src/corelib/codecs/cp949codetbl_p.h
+++ b/src/corelib/codecs/cp949codetbl_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
static const unsigned short cp949_icode_to_unicode[] = {
0xac02, 0xac03, 0xac05, 0xac06, 0xac0b, 0xac0c, 0xac0d, 0xac0e, 0xac0f, 0xac18, 0xac1e, 0xac1f, 0xac21, 0xac22, 0xac23,
0xac25, 0xac26, 0xac27, 0xac28, 0xac29, 0xac2a, 0xac2b, 0xac2e, 0xac32, 0xac33, 0xac34, 0xac35, 0xac36, 0xac37, 0xac3a,
diff --git a/src/corelib/codecs/qbig5codec_p.h b/src/corelib/codecs/qbig5codec_p.h
index 24a520a119..9dbcf41a6d 100644
--- a/src/corelib/codecs/qbig5codec_p.h
+++ b/src/corelib/codecs/qbig5codec_p.h
@@ -55,6 +55,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qtextcodec.h>
#include <QtCore/qlist.h>
diff --git a/src/corelib/codecs/qeuckrcodec_p.h b/src/corelib/codecs/qeuckrcodec_p.h
index 0311fb689c..2cf950a350 100644
--- a/src/corelib/codecs/qeuckrcodec_p.h
+++ b/src/corelib/codecs/qeuckrcodec_p.h
@@ -76,6 +76,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qtextcodec.h>
#include <QtCore/qlist.h>
diff --git a/src/corelib/codecs/qgb18030codec_p.h b/src/corelib/codecs/qgb18030codec_p.h
index 3884eea6fd..dd136aeddb 100644
--- a/src/corelib/codecs/qgb18030codec_p.h
+++ b/src/corelib/codecs/qgb18030codec_p.h
@@ -53,6 +53,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qtextcodec.h>
#include <QtCore/qlist.h>
diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp
index 96f1ee16ac..845155dce0 100644
--- a/src/corelib/codecs/qiconvcodec.cpp
+++ b/src/corelib/codecs/qiconvcodec.cpp
@@ -411,7 +411,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
switch (errno) {
case EILSEQ:
++invalidCount;
- // fall through
+ Q_FALLTHROUGH();
case EINVAL:
{
inBytes += sizeof(QChar);
diff --git a/src/corelib/codecs/qiconvcodec_p.h b/src/corelib/codecs/qiconvcodec_p.h
index 4c7f7084e6..238351bc81 100644
--- a/src/corelib/codecs/qiconvcodec_p.h
+++ b/src/corelib/codecs/qiconvcodec_p.h
@@ -44,13 +44,14 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// 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/private/qglobal_p.h>
#include "qtextcodec.h"
#if defined(Q_OS_UNIX) && !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp
index aa2095d9da..ee9f1d0048 100644
--- a/src/corelib/codecs/qicucodec.cpp
+++ b/src/corelib/codecs/qicucodec.cpp
@@ -527,7 +527,7 @@ QTextCodec *QIcuCodec::codecForNameUnlocked(const char *name)
// check whether there is really a converter for the name available.
UConverter *conv = ucnv_open(standardName, &error);
if (!conv) {
- qDebug() << "codecForName: ucnv_open failed" << standardName << u_errorName(error);
+ qDebug("codecForName: ucnv_open failed %s %s", standardName, u_errorName(error));
return 0;
}
//qDebug() << "QIcuCodec: Standard name for " << name << "is" << standardName;
@@ -577,7 +577,7 @@ UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const
ucnv_setSubstChars(static_cast<UConverter *>(state->d),
state->flags & QTextCodec::ConvertInvalidToNull ? "\0" : "?", 1, &error);
if (U_FAILURE(error))
- qDebug() << "getConverter(state) ucnv_open failed" << m_name << u_errorName(error);
+ qDebug("getConverter(state) ucnv_open failed %s %s", m_name, u_errorName(error));
}
conv = static_cast<UConverter *>(state->d);
}
@@ -587,7 +587,7 @@ UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const
conv = ucnv_open(m_name, &error);
ucnv_setSubstChars(conv, "?", 1, &error);
if (U_FAILURE(error))
- qDebug() << "getConverter(no state) ucnv_open failed" << m_name << u_errorName(error);
+ qDebug("getConverter(no state) ucnv_open failed %s %s", m_name, u_errorName(error));
}
return conv;
}
@@ -610,7 +610,7 @@ QString QIcuCodec::convertToUnicode(const char *chars, int length, QTextCodec::C
&chars, end,
0, false, &error);
if (!U_SUCCESS(error) && error != U_BUFFER_OVERFLOW_ERROR) {
- qDebug() << "convertToUnicode failed:" << u_errorName(error);
+ qDebug("convertToUnicode failed: %s", u_errorName(error));
break;
}
@@ -647,7 +647,7 @@ QByteArray QIcuCodec::convertFromUnicode(const QChar *unicode, int length, QText
&uc, end,
0, false, &error);
if (!U_SUCCESS(error))
- qDebug() << "convertFromUnicode failed:" << u_errorName(error);
+ qDebug("convertFromUnicode failed: %s", u_errorName(error));
convertedChars = ch - string.data();
if (uc >= end)
break;
diff --git a/src/corelib/codecs/qicucodec_p.h b/src/corelib/codecs/qicucodec_p.h
index a277529dc4..3a373ce5b3 100644
--- a/src/corelib/codecs/qicucodec_p.h
+++ b/src/corelib/codecs/qicucodec_p.h
@@ -53,6 +53,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
extern "C" {
typedef struct UConverter UConverter;
}
diff --git a/src/corelib/codecs/qisciicodec_p.h b/src/corelib/codecs/qisciicodec_p.h
index 94a3171d7d..f92c0091ce 100644
--- a/src/corelib/codecs/qisciicodec_p.h
+++ b/src/corelib/codecs/qisciicodec_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qtextcodec.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/codecs/qjiscodec.cpp b/src/corelib/codecs/qjiscodec.cpp
index 9c628c6012..a8625db054 100644
--- a/src/corelib/codecs/qjiscodec.cpp
+++ b/src/corelib/codecs/qjiscodec.cpp
@@ -288,7 +288,7 @@ QString QJisCodec::convertToUnicode(const char* chars, int len, ConverterState *
result += QLatin1Char(ch);
break;
}
- /* fall through */
+ Q_FALLTHROUGH();
case JISX0201_Latin:
u = conv->jisx0201ToUnicode(ch);
result += QValidChar(u);
diff --git a/src/corelib/codecs/qjpunicode_p.h b/src/corelib/codecs/qjpunicode_p.h
index 104f540b66..4fa2b9f757 100644
--- a/src/corelib/codecs/qjpunicode_p.h
+++ b/src/corelib/codecs/qjpunicode_p.h
@@ -80,7 +80,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/codecs/qlatincodec_p.h b/src/corelib/codecs/qlatincodec_p.h
index b3556a411a..1042c3b80d 100644
--- a/src/corelib/codecs/qlatincodec_p.h
+++ b/src/corelib/codecs/qlatincodec_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qtextcodec.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/codecs/qsimplecodec_p.h b/src/corelib/codecs/qsimplecodec_p.h
index d45cf2377f..d268a9f5b8 100644
--- a/src/corelib/codecs/qsimplecodec_p.h
+++ b/src/corelib/codecs/qsimplecodec_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qtextcodec.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index edb03af447..5098ac4242 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -132,7 +132,7 @@ bool qTextCodecNameMatch(const char *n, const char *h)
}
-#if !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE) && !defined(QT_LOCALE_IS_UTF8)
+#if !defined(Q_OS_WIN32) && !defined(QT_LOCALE_IS_UTF8)
static QTextCodec *checkForCodec(const QByteArray &name) {
QTextCodec *c = QTextCodec::codecForName(name);
if (!c) {
@@ -169,7 +169,7 @@ static QTextCodec *setupLocaleMapper()
#if defined(QT_LOCALE_IS_UTF8)
locale = QTextCodec::codecForName("UTF-8");
-#elif defined(Q_OS_WIN) || defined(Q_OS_WINCE)
+#elif defined(Q_OS_WIN)
locale = QTextCodec::codecForName("System");
#else
@@ -289,7 +289,7 @@ static void setup()
#if !defined(QT_NO_ICONV)
(void) new QIconvCodec;
#endif
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN32)
(void) new QWindowsLocalCodec;
#endif // Q_OS_WIN32
#endif // !QT_NO_CODECS && !QT_BOOTSTRAPPED
diff --git a/src/corelib/codecs/qtextcodec_p.h b/src/corelib/codecs/qtextcodec_p.h
index ad05d01b90..f3c2d090c9 100644
--- a/src/corelib/codecs/qtextcodec_p.h
+++ b/src/corelib/codecs/qtextcodec_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qtextcodec.h"
#include <string.h>
diff --git a/src/corelib/codecs/qtsciicodec_p.h b/src/corelib/codecs/qtsciicodec_p.h
index 6beb22cf6a..68ab01f7b5 100644
--- a/src/corelib/codecs/qtsciicodec_p.h
+++ b/src/corelib/codecs/qtsciicodec_p.h
@@ -80,6 +80,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qtextcodec.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index f1054ceb98..74a716db4a 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -52,6 +52,19 @@ enum { Endian = 0, Data = 1 };
static const uchar utf8bom[] = { 0xef, 0xbb, 0xbf };
+#if (defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)) \
+ || (defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64))
+static Q_ALWAYS_INLINE uint qBitScanReverse(unsigned v) Q_DECL_NOTHROW
+{
+ uint result = qCountLeadingZeroBits(v);
+ // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31
+ // and the lsb index is 0. The result for _bit_scan_reverse is expected to be the index when
+ // counting up: msb index is 0 (because it starts there), and the lsb index is 31.
+ result ^= sizeof(unsigned) * 8 - 1;
+ return result;
+}
+#endif
+
#if defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)
static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const ushort *&src, const ushort *end)
{
@@ -81,9 +94,9 @@ static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const
// find the next probable ASCII character
// we don't want to load 32 bytes again in this loop if we know there are non-ASCII
// characters still coming
- nextAscii = src + _bit_scan_reverse(n) + 1;
+ nextAscii = src + qBitScanReverse(n) + 1;
- n = _bit_scan_forward(n);
+ n = qCountTrailingZeroBits(n);
dst += n;
src += n;
return false;
@@ -132,13 +145,81 @@ static inline bool simdDecodeAscii(ushort *&dst, const uchar *&nextAscii, const
// find the next probable ASCII character
// we don't want to load 16 bytes again in this loop if we know there are non-ASCII
// characters still coming
- n = _bit_scan_reverse(n);
+ n = qBitScanReverse(n);
nextAscii = src + (n / BitSpacing) + 1;
return false;
}
return src == end;
}
+#elif defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64) // vaddv is only available on Aarch64
+static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const ushort *&src, const ushort *end)
+{
+ uint16x8_t maxAscii = vdupq_n_u16(0x7f);
+ uint16x8_t mask1 = { 1, 1 << 2, 1 << 4, 1 << 6, 1 << 8, 1 << 10, 1 << 12, 1 << 14 };
+ uint16x8_t mask2 = vshlq_n_u16(mask1, 1);
+
+ // do sixteen characters at a time
+ for ( ; end - src >= 16; src += 16, dst += 16) {
+ // load 2 lanes (or: "load interleaved")
+ uint16x8x2_t in = vld2q_u16(src);
+
+ // check if any of the elements > 0x7f, select 1 bit per element (element 0 -> bit 0, element 1 -> bit 1, etc),
+ // add those together into a scalar, and merge the scalars.
+ uint16_t nonAscii = vaddvq_u16(vandq_u16(vcgtq_u16(in.val[0], maxAscii), mask1))
+ | vaddvq_u16(vandq_u16(vcgtq_u16(in.val[1], maxAscii), mask2));
+
+ // merge the two lanes by shifting the values of the second by 8 and inserting them
+ uint16x8_t out = vsliq_n_u16(in.val[0], in.val[1], 8);
+
+ // store, even if there are non-ASCII characters here
+ vst1q_u8(dst, vreinterpretq_u8_u16(out));
+
+ if (nonAscii) {
+ // find the next probable ASCII character
+ // we don't want to load 32 bytes again in this loop if we know there are non-ASCII
+ // characters still coming
+ nextAscii = src + qBitScanReverse(nonAscii) + 1;
+
+ nonAscii = qCountTrailingZeroBits(nonAscii);
+ dst += nonAscii;
+ src += nonAscii;
+ return false;
+ }
+ }
+ return src == end;
+}
+
+static inline bool simdDecodeAscii(ushort *&dst, const uchar *&nextAscii, const uchar *&src, const uchar *end)
+{
+ // do eight characters at a time
+ uint8x8_t msb_mask = vdup_n_u8(0x80);
+ uint8x8_t add_mask = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 };
+ for ( ; end - src >= 8; src += 8, dst += 8) {
+ uint8x8_t c = vld1_u8(src);
+ uint8_t n = vaddv_u8(vand_u8(vcge_u8(c, msb_mask), add_mask));
+ if (!n) {
+ // store
+ vst1q_u16(dst, vmovl_u8(c));
+ continue;
+ }
+
+ // copy the front part that is still ASCII
+ while (!(n & 1)) {
+ *dst++ = *src++;
+ n >>= 1;
+ }
+
+ // find the next probable ASCII character
+ // we don't want to load 16 bytes again in this loop if we know there are non-ASCII
+ // characters still coming
+ n = qBitScanReverse(n);
+ nextAscii = src + n + 1;
+ return false;
+
+ }
+ return src == end;
+}
#else
static inline bool simdEncodeAscii(uchar *, const ushort *, const ushort *, const ushort *)
{
diff --git a/src/corelib/codecs/qwindowscodec.cpp b/src/corelib/codecs/qwindowscodec.cpp
index b802ab7249..813d3c8153 100644
--- a/src/corelib/codecs/qwindowscodec.cpp
+++ b/src/corelib/codecs/qwindowscodec.cpp
@@ -157,7 +157,7 @@ QString QWindowsLocalCodec::convertToUnicodeCharByChar(const char *chars, int le
state->remainingChars = 0;
}
const char *mb = mbcs;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
const char *next = 0;
QString s;
while ((next = CharNextExA(CP_ACP, mb, 0)) != mb) {
diff --git a/src/corelib/codecs/qwindowscodec_p.h b/src/corelib/codecs/qwindowscodec_p.h
index 529c621b2e..2fd3c35378 100644
--- a/src/corelib/codecs/qwindowscodec_p.h
+++ b/src/corelib/codecs/qwindowscodec_p.h
@@ -50,6 +50,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qtextcodec.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
new file mode 100644
index 0000000000..b0c78f5122
--- /dev/null
+++ b/src/corelib/configure.json
@@ -0,0 +1,611 @@
+{
+ "module": "core",
+ "testDir": "../../config.tests",
+
+ "commandline": {
+ "options": {
+ "doubleconversion": { "type": "enum", "values": [ "no", "qt", "system" ] },
+ "eventfd": "boolean",
+ "glib": "boolean",
+ "iconv": { "type": "enum", "values": [ "no", "yes", "posix", "sun", "gnu" ] },
+ "icu": "boolean",
+ "inotify": "boolean",
+ "journald": "boolean",
+ "pcre": { "type": "enum", "values": [ "qt", "system" ] },
+ "posix-ipc": { "type": "boolean", "name": "ipc_posix" },
+ "pps": { "type": "boolean", "name": "qqnx_pps" },
+ "slog2": "boolean",
+ "syslog": "boolean"
+ }
+ },
+
+ "libraries": {
+ "doubleconversion": {
+ "label": "DoubleConversion",
+ "test": "unix/doubleconversion",
+ "sources": [
+ "-ldouble-conversion"
+ ]
+ },
+ "glib": {
+ "label": "GLib",
+ "test": "unix/glib",
+ "sources": [
+ { "type": "pkgConfig", "args": "glib-2.0 gthread-2.0" }
+ ]
+ },
+ "gnu_iconv": {
+ "label": "GNU libiconv",
+ "export": "iconv",
+ "test": "unix/gnu-libiconv",
+ "sources": [
+ "-liconv"
+ ]
+ },
+ "icu": {
+ "label": "ICU",
+ "export": "",
+ "test": "unix/icu",
+ "sources": [
+ {
+ "builds": {
+ "debug": "-lsicuind -lsicuucd -lsicudtd",
+ "release": "-lsicuin -lsicuuc -lsicudt"
+ },
+ "condition": "config.win32 && !features.shared"
+ },
+ { "libs": "-licuin -licuuc -licudt", "condition": "config.win32 && features.shared" },
+ { "libs": "-licui18n -licuuc -licudata", "condition": "!config.win32" }
+ ]
+ },
+ "journald": {
+ "label": "journald",
+ "test": "unix/journald",
+ "export": "",
+ "sources": [
+ { "type": "pkgConfig", "args": "libsystemd" },
+ { "type": "pkgConfig", "args": "libsystemd-journal" }
+ ]
+ },
+ "libatomic": {
+ "label": "64 bit atomics in libatomic",
+ "test": "common/atomic64",
+ "sources": [
+ "-latomic"
+ ]
+ },
+ "libdl": {
+ "label": "dlopen() in libdl",
+ "export": "",
+ "test": "unix/dlopen",
+ "sources": [
+ "-ldl"
+ ]
+ },
+ "pcre": {
+ "label": "PCRE",
+ "test": "unix/pcre",
+ "sources": [
+ "-lpcre16"
+ ]
+ },
+ "pps": {
+ "label": "PPS",
+ "test": "unix/pps",
+ "sources": [
+ "-lpps"
+ ]
+ },
+ "slog2": {
+ "label": "slog2",
+ "test": "unix/slog2",
+ "export": "",
+ "sources": [
+ "-lslog2"
+ ]
+ }
+ },
+
+ "tests": {
+ "atomic64": {
+ "label": "64 bit atomics",
+ "type": "compile",
+ "test": "common/atomic64"
+ },
+ "atomicfptr": {
+ "label": "working std::atomic for function pointers",
+ "type": "compile",
+ "test": "common/atomicfptr"
+ },
+ "clock-gettime": {
+ "label": "clock_gettime()",
+ "type": "compile",
+ "test": "unix/clock-gettime"
+ },
+ "clock-monotonic": {
+ "label": "POSIX monotonic clock",
+ "type": "compile",
+ "test": "unix/clock-monotonic"
+ },
+ "cloexec": {
+ "label": "O_CLOEXEC",
+ "type": "compile",
+ "test": "unix/cloexec"
+ },
+ "dlopen": {
+ "label": "dlopen() in libc",
+ "type": "compile",
+ "test": "unix/dlopen"
+ },
+ "eventfd": {
+ "label": "eventfd",
+ "type": "compile",
+ "test": "unix/eventfd"
+ },
+ "posix-iconv": {
+ "label": "POSIX iconv",
+ "type": "compile",
+ "test": "unix/iconv"
+ },
+ "sun-iconv": {
+ "label": "SUN libiconv",
+ "type": "compile",
+ "test": "unix/sun-libiconv"
+ },
+ "inotify": {
+ "label": "inotify",
+ "type": "compile",
+ "test": "unix/inotify"
+ },
+ "ipc_sysv": {
+ "label": "SysV IPC",
+ "type": "compile",
+ "test": "unix/ipc_sysv"
+ },
+ "ipc_posix": {
+ "label": "POSIX IPC",
+ "type": "compile",
+ "test": "unix/ipc_posix"
+ },
+ "journald": {
+ "label": "journald",
+ "type": "compile",
+ "test": "unix/journald"
+ },
+ "ppoll": {
+ "label": "ppoll()",
+ "type": "compile",
+ "test": "unix/ppoll"
+ },
+ "pollts": {
+ "label": "pollts()",
+ "type": "compile",
+ "test": "unix/pollts"
+ },
+ "poll": {
+ "label": "poll()",
+ "type": "compile",
+ "test": "unix/poll"
+ },
+ "syslog": {
+ "label": "syslog",
+ "type": "compile",
+ "test": "unix/syslog"
+ },
+ "xlocalescanprint": {
+ "label": "xlocale.h (or equivalents)",
+ "type": "compile",
+ "test": "common/xlocalescanprint"
+ }
+ },
+
+ "features": {
+ "clock-gettime": {
+ "label": "clock_gettime()",
+ "condition": "tests.clock-gettime",
+ "output": [ "privateFeature" ]
+ },
+ "clock-monotonic": {
+ "label": "POSIX monotonic clock",
+ "condition": "features.clock-gettime && tests.clock-monotonic",
+ "output": [ "feature" ]
+ },
+ "dlopen": {
+ "label": "dlopen()",
+ "condition": "tests.dlopen || libs.libdl",
+ "output": [ { "type": "define", "negative": true, "name": "QT_NO_DYNAMIC_LIBRARY" } ]
+ },
+ "libdl": {
+ "label": "dlopen() in libdl",
+ "condition": "!tests.dlopen && libs.libdl",
+ "output": [ { "type": "privateConfig", "negative": true } ]
+ },
+ "doubleconversion": {
+ "label": "DoubleConversion",
+ "output": [ "privateFeature", "feature" ]
+ },
+ "system-doubleconversion": {
+ "label": " Using system DoubleConversion",
+ "enable": "input.doubleconversion == 'system'",
+ "disable": "input.doubleconversion == 'qt'",
+ "condition": "features.doubleconversion && libs.doubleconversion",
+ "output": [ "privateFeature" ]
+ },
+ "eventfd": {
+ "label": "eventfd",
+ "condition": "tests.eventfd",
+ "output": [ "feature" ]
+ },
+ "glib": {
+ "label": "GLib",
+ "autoDetect": "!config.win32",
+ "condition": "libs.glib",
+ "output": [ "privateFeature", "feature" ]
+ },
+ "iconv": {
+ "label": "iconv",
+ "purpose": "Provides internationalization on Unix.",
+ "section": "Internationalization",
+ "condition": "features.posix-libiconv || features.sun-libiconv || features.gnu-libiconv",
+ "output": [ "privateFeature", "feature" ]
+ },
+ "posix-libiconv": {
+ "label": "POSIX iconv",
+ "enable": "input.iconv == 'posix'",
+ "disable": "input.iconv == 'sun' || input.iconv == 'gnu' || input.iconv == 'no'",
+ "condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && tests.posix-iconv"
+ },
+ "sun-libiconv": {
+ "label": "SUN iconv",
+ "enable": "input.iconv == 'sun'",
+ "disable": "input.iconv == 'posix' || input.iconv == 'gnu' || input.iconv == 'no'",
+ "condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && !features.posix-libiconv && tests.sun-iconv",
+ "output": [ "privateFeature", "publicQtConfig" ]
+ },
+ "gnu-libiconv": {
+ "label": "GNU iconv",
+ "enable": "input.iconv == 'gnu'",
+ "disable": "input.iconv == 'posix' || input.iconv == 'sun' || input.iconv == 'no'",
+ "condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && !features.posix-libiconv && !features.sun-libiconv && libs.gnu_iconv",
+ "output": [ "privateFeature" ]
+ },
+ "icu": {
+ "label": "ICU",
+ "autoDetect": "!config.win32",
+ "condition": "libs.icu",
+ "output": [ "privateFeature" ]
+ },
+ "inotify": {
+ "label": "inotify",
+ "condition": "tests.inotify",
+ "output": [ "privateFeature", "feature" ]
+ },
+ "ipc_posix": {
+ "label": "Using POSIX IPC",
+ "autoDetect": "!config.win32",
+ "condition": "!tests.ipc_sysv && tests.ipc_posix",
+ "output": [ { "type": "define", "name": "QT_POSIX_IPC" } ]
+ },
+ "journald": {
+ "label": "journald",
+ "autoDetect": false,
+ "condition": "libs.journald",
+ "output": [ "privateConfig" ]
+ },
+ "std-atomic64": {
+ "label": "64 bit atomic operations",
+ "condition": "tests.atomic64 || libs.libatomic",
+ "output": [ { "type": "define", "negative": true, "name": "QT_NO_STD_ATOMIC64" } ]
+ },
+ "libatomic": {
+ "label": "64 bit atomic operations in libatomic",
+ "condition": "!tests.atomic64 && libs.libatomic",
+ "output": [ "privateFeature" ]
+ },
+ "mimetype": {
+ "label": "Mimetype handling",
+ "purpose": "Provides MIME type handling.",
+ "section": "Utilities",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "system-pcre": {
+ "label": "Using system PCRE",
+ "disable": "input.pcre == 'qt'",
+ "enable": "input.pcre == 'system'",
+ "condition": "libs.pcre",
+ "output": [
+ "privateFeature",
+ { "type": "privateConfig", "negative": true, "name": "pcre" }
+ ]
+ },
+ "poll_ppoll": {
+ "label": "Native ppoll()",
+ "emitIf": "!config.win32",
+ "condition": "tests.ppoll",
+ "output": [ "privateFeature" ]
+ },
+ "poll_pollts": {
+ "label": "Native pollts()",
+ "emitIf": "!config.win32",
+ "condition": "!features.poll_ppoll && tests.pollts",
+ "output": [ "privateFeature" ]
+ },
+ "poll_poll": {
+ "label": "Native poll()",
+ "emitIf": "!config.win32",
+ "condition": "!features.poll_ppoll && !features.poll_pollts && tests.poll",
+ "output": [ "privateFeature" ]
+ },
+ "poll_select": {
+ "label": "Emulated poll()",
+ "emitIf": "!config.win32",
+ "condition": "!features.poll_ppoll && !features.poll_pollts && !features.poll_poll",
+ "output": [
+ "privateFeature",
+ { "type": "define", "name": "QT_NO_NATIVE_POLL" }
+ ]
+ },
+ "qqnx_pps": {
+ "label": "PPS",
+ "emitIf": "config.qnx",
+ "condition": "libs.pps",
+ "output": [ "privateConfig" ]
+ },
+ "qeventtransition": {
+ "label": "QEventTransition class",
+ "output": [ "publicFeature" ]
+ },
+ "sharedmemory": {
+ "label": "Enable QSharedMemory",
+ "condition": "config.android || config.win32 || tests.ipc_sysv || tests.ipc_posix",
+ "output": [ { "type": "define", "negative": true, "name": "QT_NO_SHAREDMEMORY" } ]
+ },
+ "slog2": {
+ "label": "slog2",
+ "condition": "libs.slog2",
+ "emitIf": "config.qnx",
+ "output": [ "privateConfig" ]
+ },
+ "syslog": {
+ "label": "syslog",
+ "autoDetect": false,
+ "condition": "tests.syslog",
+ "output": [ "privateConfig" ]
+ },
+ "systemsemaphore": {
+ "label": "Enable QSystemSemaphore",
+ "condition": "config.android || config.win32 || tests.ipc_sysv || tests.ipc_posix",
+ "output": [ { "type": "define", "negative": true, "name": "QT_NO_SYSTEMSEMAPHORE" } ]
+ },
+ "threadsafe-cloexec": {
+ "label": "Threadsafe pipe creation",
+ "condition": "tests.cloexec",
+ "output": [
+ "publicQtConfig",
+ { "type": "define", "name": "QT_THREADSAFE_CLOEXEC", "value": 1 }
+ ]
+ },
+ "properties": {
+ "label": "Properties",
+ "purpose": "Supports scripting Qt-based applications.",
+ "section": "Kernel",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "regularexpression": {
+ "label": "QRegularExpression",
+ "purpose": "Provides an API to Perl-compatible regular expressions.",
+ "section": "Kernel",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "sharedmemory": {
+ "label": "QSharedMemory",
+ "purpose": "Provides access to a shared memory segment.",
+ "section": "Kernel",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "systemsemaphore": {
+ "label": "QSystemSemaphore",
+ "purpose": "Provides a general counting system semaphore.",
+ "section": "Kernel",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "xmlstream": {
+ "label": "XML Streaming APIs",
+ "purpose": "Provides a simple streaming API for XML.",
+ "section": "Kernel",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "xmlstreamreader": {
+ "label": "QXmlStreamReader",
+ "purpose": "Provides a well-formed XML parser with a simple streaming API.",
+ "section": "Kernel",
+ "condition": "features.xmlstream",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "xmlstreamwriter": {
+ "label": "QXmlStreamWriter",
+ "purpose": "Provides a XML writer with a simple streaming API.",
+ "section": "Kernel",
+ "condition": "features.xmlstream",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "textdate": {
+ "label": "Text Date",
+ "purpose": "Supports month and day names in dates.",
+ "section": "Data structures",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "datestring": {
+ "label": "QDate/QTime/QDateTime",
+ "purpose": "Provides convertion between dates and strings.",
+ "section": "Data structures",
+ "condition": "features.textdate",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "process": {
+ "label": "QProcess",
+ "purpose": "Supports external process invocation.",
+ "section": "File I/O",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "temporaryfile": {
+ "label": "QTemporaryFile",
+ "purpose": "Provides an I/O device that operates on temporary files.",
+ "section": "File I/O",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "library": {
+ "label": "QLibrary",
+ "purpose": "Provides a wrapper for dynamically loaded libraries.",
+ "section": "File I/O",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "settings": {
+ "label": "QSettings",
+ "purpose": "Provides persistent application settings.",
+ "section": "File I/O",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "filesystemwatcher": {
+ "label": "QFileSystemWatcher",
+ "purpose": "Provides an interface for monitoring files and directories for modifications.",
+ "section": "File I/O",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "filesystemiterator": {
+ "label": "QFileSystemIterator",
+ "purpose": "Provides fast file system iteration.",
+ "section": "File I/O",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "itemmodel": {
+ "label": "Qt Item Model",
+ "purpose": "Provides the item model for item views",
+ "section": "ItemViews",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "proxymodel": {
+ "label": "QAbstractProxyModel",
+ "purpose": "Supports processing of data passed between another model and a view.",
+ "section": "ItemViews",
+ "condition": "features.itemmodel",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "sortfilterproxymodel": {
+ "label": "QSortFilterProxyModel",
+ "purpose": "Supports sorting and filtering of data passed between another model and a view.",
+ "section": "ItemViews",
+ "condition": "features.proxymodel",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "identityproxymodel": {
+ "label": "QIdentityProxyModel",
+ "purpose": "Supports proxying a source model unmodified.",
+ "section": "ItemViews",
+ "condition": "features.proxymodel",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "stringlistmodel": {
+ "label": "QStringListModel",
+ "purpose": "Provides a model that supplies strings to views.",
+ "section": "ItemViews",
+ "condition": "features.itemmodel",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "translation": {
+ "label": "Translation",
+ "purpose": "Supports translations using QObject::tr().",
+ "section": "Internationalization",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "textcodec": {
+ "label": "QTextCodec",
+ "purpose": "Supports conversions between text encodings.",
+ "section": "Internationalization",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "codecs": {
+ "label": "Codecs",
+ "purpose": "Supports non-unicode text conversions.",
+ "section": "Internationalization",
+ "condition": "features.textcodec",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "big_codecs": {
+ "label": "Big Codecs",
+ "purpose": "Supports big codecs, e.g. CJK.",
+ "section": "Internationalization",
+ "condition": "features.textcodec",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "animation": {
+ "label": "Animation",
+ "purpose": "Provides a framework for animations.",
+ "section": "Utilities",
+ "condition": "features.properties",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "statemachine": {
+ "label": "State machine",
+ "purpose": "Provides hierarchical finite state machines.",
+ "section": "Utilities",
+ "condition": "features.properties",
+ "output": [ "publicFeature", "feature" ]
+ },
+ "gestures": {
+ "label": "Gesture",
+ "purpose": "Provides a framework for gestures.",
+ "section": "Utilities",
+ "output": [ "publicFeature", "feature" ]
+ }
+ },
+
+ "report": [
+ {
+ "type": "note",
+ "condition": "features.journald || features.syslog || (config.qnx && features.slog2)",
+ "message": "journald, syslog or slog2 integration is enabled.
+If your users intend to develop applications against this build,
+ensure that the IDEs they use either set QT_LOGGING_TO_CONSOLE to 1
+or are able to read the logged output from journald, syslog or slog2."
+ },
+ {
+ "type": "error",
+ "condition": "input.doubleconversion == 'no' && !tests.xlocalescanprint",
+ "message": "Your C library does not provide sscanf_l or snprintf_l.
+You need to use libdouble-conversion for double/string conversion."
+ },
+ {
+ "type": "error",
+ "condition": "!tests.atomicfptr",
+ "message": "detected a std::atomic implementation that fails for function pointers.
+Please apply the patch corresponding to your Standard Library vendor, found in
+ qtbase/config.tests/common/atomicfptr"
+ }
+ ],
+
+ "summary": [
+ {
+ "section": "Qt Core",
+ "entries": [
+ "doubleconversion",
+ "system-doubleconversion",
+ "glib",
+ "iconv",
+ "icu",
+ {
+ "section": "Logging backends",
+ "entries": [
+ "journald", "syslog", "slog2"
+ ]
+ },
+ {
+ "type": "feature",
+ "args": "qqnx_pps",
+ "condition": "config.qnx"
+ },
+ "system-pcre"
+ ]
+ }
+ ]
+}
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 2faa97eb17..616a9641a1 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -31,8 +31,6 @@ ANDROID_PERMISSIONS = \
# OpenBSD 6.0 will include environ in libc.
freebsd|openbsd: QMAKE_LFLAGS_NOUNDEF =
-load(qfeatures)
-
include(animation/animation.pri)
include(arch/arch.pri)
include(global/global.pri)
@@ -48,11 +46,19 @@ include(statemachine/statemachine.pri)
include(mimetypes/mimetypes.pri)
include(xml/xml.pri)
-# otherwise mingw headers do not declare common functions like putenv
-mingw: CONFIG -= strict_c++
+win32 {
+ mingw {
+ # otherwise mingw headers do not declare common functions like putenv
+ CONFIG -= strict_c++
+ # Override MinGW's definition in _mingw.h
+ DEFINES += WINVER=0x600 _WIN32_WINNT=0x0600
+ }
+
+ !winrt: LIBS_PRIVATE += -lwinmm
+}
-mac|darwin {
- !ios {
+darwin {
+ osx {
LIBS_PRIVATE += -framework ApplicationServices
LIBS_PRIVATE += -framework CoreServices
}
@@ -92,6 +98,7 @@ cmake_umbrella_config_version_file.output = $$DESTDIR/cmake/Qt5/Qt5ConfigVersion
load(cmake_functions)
+##### This requires fixing, so that the feature system works with cmake as well
CMAKE_DISABLED_FEATURES = $$join(QT_DISABLED_FEATURES, "$$escape_expand(\\n) ")
CMAKE_HOST_DATA_DIR = $$cmakeRelativePath($$[QT_HOST_DATA/src], $$[QT_INSTALL_PREFIX])
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 54b5c95a34..1169ad5536 100644
--- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -131,26 +131,46 @@ absoluteValue = qAbs(myValue);
//! [10]
-//! [11]
-qreal valueA = 2.3;
-qreal valueB = 2.7;
+//! [11A]
+double valueA = 2.3;
+double valueB = 2.7;
int roundedValueA = qRound(valueA);
// roundedValueA = 2
int roundedValueB = qRound(valueB);
// roundedValueB = 3
-//! [11]
+//! [11A]
+//! [11B]
+float valueA = 2.3;
+float valueB = 2.7;
-//! [12]
-qreal valueA = 42949672960.3;
-qreal valueB = 42949672960.7;
+int roundedValueA = qRound(valueA);
+// roundedValueA = 2
+int roundedValueB = qRound(valueB);
+// roundedValueB = 3
+//! [11B]
+
+
+//! [12A]
+double valueA = 42949672960.3;
+double valueB = 42949672960.7;
+
+qint64 roundedValueA = qRound64(valueA);
+// roundedValueA = 42949672960
+qint64 roundedValueB = qRound64(valueB);
+// roundedValueB = 42949672961
+//! [12A]
+
+//! [12B]
+float valueA = 42949672960.3;
+float valueB = 42949672960.7;
qint64 roundedValueA = qRound64(valueA);
// roundedValueA = 42949672960
qint64 roundedValueB = qRound64(valueB);
// roundedValueB = 42949672961
-//! [12]
+//! [12B]
//! [13]
diff --git a/src/corelib/doc/src/animation.qdoc b/src/corelib/doc/src/animation.qdoc
index 4e71ed4268..0c1b2aed17 100644
--- a/src/corelib/doc/src/animation.qdoc
+++ b/src/corelib/doc/src/animation.qdoc
@@ -121,7 +121,7 @@
As mentioned in the previous section, the QPropertyAnimation class can
interpolate over Qt properties. It is often this class that should be used
for animation of values; in fact, its superclass, QVariantAnimation, has an
- empty implementation of \l{QAbstractAnimation::}{updateCurrentValue()}, and
+ empty implementation of \l{QVariantAnimation::}{updateCurrentValue()}, and
does not change any value unless we change it ourselves on the
\l{QVariantAnimation::valueChanged()}{valueChanged signal}.
diff --git a/src/corelib/doc/src/qtcore-index.qdoc b/src/corelib/doc/src/qtcore-index.qdoc
index e2fce5797d..fe9b43507c 100644
--- a/src/corelib/doc/src/qtcore-index.qdoc
+++ b/src/corelib/doc/src/qtcore-index.qdoc
@@ -101,7 +101,19 @@
\li \l{The Event System}
\endlist
- \section1 Related Information
+ \section1 Licenses and Attributions
+
+ Qt Core is available under commercial licenses from \l{The Qt Company}.
+ In addition, it is available under the
+ \l{GNU Lesser General Public License, version 3}, or
+ the \l{GNU General Public License, version 2}.
+ See \l{Qt Licensing} for further details.
+
+ Furthermore Qt Core potentially contains third party
+ modules under following permissive licenses:
+
+ \generatelist{groupsbymodule attributions-qtcore}
+
\section1 Reference
These are links to the API reference materials.
\list
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index d0eb2af423..a3d816f0c3 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -656,14 +656,6 @@
/* General C++ features */
# define Q_COMPILER_RESTRICTED_VLA
# define Q_COMPILER_THREADSAFE_STATICS
-# if !__has_feature(cxx_exceptions)
-# ifndef QT_NO_EXCEPTIONS
-# define QT_NO_EXCEPTIONS
-# endif
-# endif
-# if !__has_feature(cxx_rtti)
-# define QT_NO_RTTI
-# endif
# if __has_feature(attribute_deprecated_with_message)
# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
# endif
@@ -1039,7 +1031,8 @@
// critical definitions. (Reported as Intel Issue ID 6000117277)
# define __USE_CONSTEXPR 1
# define __USE_NOEXCEPT 1
-# elif defined(Q_CC_MSVC) && (defined(Q_CC_CLANG) || defined(Q_CC_INTEL))
+# endif
+# if defined(Q_CC_MSVC) && defined(Q_CC_CLANG)
// Clang and the Intel compiler support more C++ features than the Microsoft compiler
// so make sure we don't enable them if the MS headers aren't properly adapted.
# ifndef _HAS_CONSTEXPR
@@ -1066,7 +1059,8 @@
# ifndef _HAS_VARIADIC_TEMPLATES
# undef Q_COMPILER_VARIADIC_TEMPLATES
# endif
-# elif defined(_LIBCPP_VERSION)
+# endif
+# if defined(_LIBCPP_VERSION)
// libc++ uses __has_feature(cxx_atomic), so disable the feature if the compiler
// doesn't support it. That's required for the Intel compiler 14.x or earlier on OS X, for example.
# if !__has_feature(cxx_atomic)
@@ -1351,6 +1345,18 @@
Q_ASSUME_IMPL(valueOfExpression);\
} while (0)
+#if QT_HAS_CPP_ATTRIBUTE(fallthrough)
+# define Q_FALLTHROUGH() [[fallthrough]]
+#elif defined(__cplusplus)
+/* Clang can not parse namespaced attributes in C mode, but defines __has_cpp_attribute */
+# if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
+# define Q_FALLTHROUGH() [[clang::fallthrough]]
+# endif
+#endif
+#ifndef Q_FALLTHROUGH
+# define Q_FALLTHROUGH() (void)0
+#endif
+
/*
Sanitize compiler feature availability
diff --git a/src/corelib/global/qconfig-dist.h b/src/corelib/global/qconfig-dist.h
deleted file mode 100644
index c9739db990..0000000000
--- a/src/corelib/global/qconfig-dist.h
+++ /dev/null
@@ -1,48 +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$
-**
-****************************************************************************/
-
-
-/*
- Empty leaves all features enabled. See doc/html/emb-features.html for choices.
-
- Note that disabling some features will produce a libqt that is not
- compatible with other libqt builds. Such modifications are only
- supported on Qt for Embedded Linux where reducing the library size is
- important and where the application suite is often a fixed set.
-*/
diff --git a/src/corelib/global/qconfig-large.h b/src/corelib/global/qconfig-large.h
deleted file mode 100644
index 270858e65b..0000000000
--- a/src/corelib/global/qconfig-large.h
+++ /dev/null
@@ -1,140 +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$
-**
-****************************************************************************/
-
-/* Dialogs */
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-
-/* Widgets */
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_DIAL
-# define QT_NO_DIAL
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
diff --git a/src/corelib/global/qconfig-medium.h b/src/corelib/global/qconfig-medium.h
deleted file mode 100644
index 830e936924..0000000000
--- a/src/corelib/global/qconfig-medium.h
+++ /dev/null
@@ -1,241 +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$
-**
-****************************************************************************/
-
-/* Dialogs */
-#ifndef QT_NO_COLORDIALOG
-# define QT_NO_COLORDIALOG
-#endif
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_BIG_CODECS
-# define QT_NO_BIG_CODECS
-#endif
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_ACTION
-# define QT_NO_ACTION
-#endif
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHORTCUT
-# define QT_NO_SHORTCUT
-#endif
-#ifndef QT_NO_WHEELEVENT
-# define QT_NO_WHEELEVENT
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_NETWORKPROXY
-# define QT_NO_NETWORKPROXY
-#endif
-#ifndef QT_NO_SOCKS5
-# define QT_NO_SOCKS5
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-
-/* Utilities */
-#ifndef QT_NO_UNDOCOMMAND
-# define QT_NO_UNDOCOMMAND
-#endif
-#ifndef QT_NO_UNDOGROUP
-# define QT_NO_UNDOGROUP
-#endif
-#ifndef QT_NO_UNDOSTACK
-# define QT_NO_UNDOSTACK
-#endif
-#ifndef QT_NO_UNDOVIEW
-# define QT_NO_UNDOVIEW
-#endif
-#ifndef QT_NO_GESTURES
-# define QT_NO_GESTURES
-#endif
-
-/* Widgets */
-#ifndef QT_NO_LCDNUMBER
-# define QT_NO_LCDNUMBER
-#endif
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_MENU
-# define QT_NO_MENU
-#endif
-#ifndef QT_NO_CONTEXTMENU
-# define QT_NO_CONTEXTMENU
-#endif
-#ifndef QT_NO_MAINWINDOW
-# define QT_NO_MAINWINDOW
-#endif
-#ifndef QT_NO_DOCKWIDGET
-# define QT_NO_DOCKWIDGET
-#endif
-#ifndef QT_NO_TOOLBAR
-# define QT_NO_TOOLBAR
-#endif
-#ifndef QT_NO_MENUBAR
-# define QT_NO_MENUBAR
-#endif
-#ifndef QT_NO_PROGRESSBAR
-# define QT_NO_PROGRESSBAR
-#endif
-#ifndef QT_NO_SIZEGRIP
-# define QT_NO_SIZEGRIP
-#endif
-#ifndef QT_NO_DIAL
-# define QT_NO_DIAL
-#endif
-#ifndef QT_NO_STACKEDWIDGET
-# define QT_NO_STACKEDWIDGET
-#endif
-#ifndef QT_NO_TABWIDGET
-# define QT_NO_TABWIDGET
-#endif
-#ifndef QT_NO_STATUSBAR
-# define QT_NO_STATUSBAR
-#endif
-#ifndef QT_NO_STATUSTIP
-# define QT_NO_STATUSTIP
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TOOLBUTTON
-# define QT_NO_TOOLBUTTON
-#endif
-#ifndef QT_NO_TABBAR
-# define QT_NO_TABBAR
-#endif
-#ifndef QT_NO_TOOLBOX
-# define QT_NO_TOOLBOX
-#endif
-#ifndef QT_NO_WHATSTHIS
-# define QT_NO_WHATSTHIS
-#endif
-#ifndef QT_NO_TOOLTIP
-# define QT_NO_TOOLTIP
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
diff --git a/src/corelib/global/qconfig-minimal.h b/src/corelib/global/qconfig-minimal.h
deleted file mode 100644
index 305655b1c9..0000000000
--- a/src/corelib/global/qconfig-minimal.h
+++ /dev/null
@@ -1,463 +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$
-**
-****************************************************************************/
-
-/* Data structures */
-#ifndef QT_NO_TEXTDATE
-# define QT_NO_TEXTDATE
-#endif
-#ifndef QT_NO_DATESTRING
-# define QT_NO_DATESTRING
-#endif
-
-/* Dialogs */
-#ifndef QT_NO_COLORDIALOG
-# define QT_NO_COLORDIALOG
-#endif
-#ifndef QT_NO_ERRORMESSAGE
-# define QT_NO_ERRORMESSAGE
-#endif
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_MESSAGEBOX
-# define QT_NO_MESSAGEBOX
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PRINTPREVIEWDIALOG
-# define QT_NO_PRINTPREVIEWDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-#ifndef QT_NO_WIZARD
-# define QT_NO_WIZARD
-#endif
-
-/* File I/O */
-#ifndef QT_NO_DOM
-# define QT_NO_DOM
-#endif
-#ifndef QT_NO_FILESYSTEMWATCHER
-# define QT_NO_FILESYSTEMWATCHER
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
-# define QT_NO_FILESYSTEMMODEL
-#endif
-#ifndef QT_NO_PROCESS
-# define QT_NO_PROCESS
-#endif
-#ifndef QT_NO_TEMPORARYFILE
-# define QT_NO_TEMPORARYFILE
-#endif
-#ifndef QT_NO_SETTINGS
-# define QT_NO_SETTINGS
-#endif
-#ifndef QT_NO_LIBRARY
-# define QT_NO_LIBRARY
-#endif
-
-/* Fonts */
-#ifndef QT_NO_FREETYPE
-# define QT_NO_FREETYPE
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-# define QT_NO_IMAGEFORMATPLUGIN
-#endif
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
-# define QT_NO_IMAGEFORMAT_JPEG
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PNG
-# define QT_NO_IMAGEFORMAT_PNG
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XBM
-# define QT_NO_IMAGEFORMAT_XBM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XPM
-# define QT_NO_IMAGEFORMAT_XPM
-#endif
-#ifndef QT_NO_IMAGE_HEURISTIC_MASK
-# define QT_NO_IMAGE_HEURISTIC_MASK
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_BIG_CODECS
-# define QT_NO_BIG_CODECS
-#endif
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_ITEMVIEWS
-# define QT_NO_ITEMVIEWS
-#endif
-#ifndef QT_NO_DATAWIDGETMAPPER
-# define QT_NO_DATAWIDGETMAPPER
-#endif
-#ifndef QT_NO_DIRMODEL
-# define QT_NO_DIRMODEL
-#endif
-#ifndef QT_NO_LISTVIEW
-# define QT_NO_LISTVIEW
-#endif
-#ifndef QT_NO_COLUMNVIEW
-# define QT_NO_COLUMNVIEW
-#endif
-#ifndef QT_NO_PROXYMODEL
-# define QT_NO_PROXYMODEL
-#endif
-#ifndef QT_NO_SORTFILTERPROXYMODEL
-# define QT_NO_SORTFILTERPROXYMODEL
-#endif
-#ifndef QT_NO_STANDARDITEMMODEL
-# define QT_NO_STANDARDITEMMODEL
-#endif
-#ifndef QT_NO_STRINGLISTMODEL
-# define QT_NO_STRINGLISTMODEL
-#endif
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_ACTION
-# define QT_NO_ACTION
-#endif
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_CSSPARSER
-# define QT_NO_CSSPARSER
-#endif
-#ifndef QT_NO_CURSOR
-# define QT_NO_CURSOR
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHAREDMEMORY
-# define QT_NO_SHAREDMEMORY
-#endif
-#ifndef QT_NO_SHORTCUT
-# define QT_NO_SHORTCUT
-#endif
-#ifndef QT_NO_SYSTEMSEMAPHORE
-# define QT_NO_SYSTEMSEMAPHORE
-#endif
-#ifndef QT_NO_TABLETEVENT
-# define QT_NO_TABLETEVENT
-#endif
-#ifndef QT_NO_TEXTHTMLPARSER
-# define QT_NO_TEXTHTMLPARSER
-#endif
-#ifndef QT_NO_CONCURRENT
-# define QT_NO_CONCURRENT
-#endif
-#ifndef QT_NO_WHEELEVENT
-# define QT_NO_WHEELEVENT
-#endif
-#ifndef QT_NO_XMLSTREAM
-# define QT_NO_XMLSTREAM
-#endif
-#ifndef QT_NO_XMLSTREAMREADER
-# define QT_NO_XMLSTREAMREADER
-#endif
-#ifndef QT_NO_XMLSTREAMWRITER
-# define QT_NO_XMLSTREAMWRITER
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_NETWORKPROXY
-# define QT_NO_NETWORKPROXY
-#endif
-#ifndef QT_NO_SOCKS5
-# define QT_NO_SOCKS5
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PAINT_DEBUG
-# define QT_NO_PAINT_DEBUG
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_FUSION
-# define QT_NO_STYLE_FUSION
-#endif
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-#ifndef QT_NO_STYLE_WINDOWSCE
-# define QT_NO_STYLE_WINDOWSCE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSMOBILE
-# define QT_NO_STYLE_WINDOWSMOBILE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSVISTA
-# define QT_NO_STYLE_WINDOWSVISTA
-#endif
-#ifndef QT_NO_STYLE_WINDOWSXP
-# define QT_NO_STYLE_WINDOWSXP
-#endif
-
-/* Utilities */
-#ifndef QT_NO_ACCESSIBILITY
-# define QT_NO_ACCESSIBILITY
-#endif
-#ifndef QT_NO_COMPLETER
-# define QT_NO_COMPLETER
-#endif
-#ifndef QT_NO_DESKTOPSERVICES
-# define QT_NO_DESKTOPSERVICES
-#endif
-#ifndef QT_NO_MIMETYPE
-# define QT_NO_MIMETYPE
-#endif
-#ifndef QT_NO_SYSTEMTRAYICON
-# define QT_NO_SYSTEMTRAYICON
-#endif
-#ifndef QT_NO_UNDOCOMMAND
-# define QT_NO_UNDOCOMMAND
-#endif
-#ifndef QT_NO_UNDOGROUP
-# define QT_NO_UNDOGROUP
-#endif
-#ifndef QT_NO_UNDOSTACK
-# define QT_NO_UNDOSTACK
-#endif
-#ifndef QT_NO_UNDOVIEW
-# define QT_NO_UNDOVIEW
-#endif
-#ifndef QT_NO_GESTURES
-# define QT_NO_GESTURES
-#endif
-
-/* Widgets */
-#ifndef QT_NO_GROUPBOX
-# define QT_NO_GROUPBOX
-#endif
-#ifndef QT_NO_BUTTONGROUP
-# define QT_NO_BUTTONGROUP
-#endif
-#ifndef QT_NO_LCDNUMBER
-# define QT_NO_LCDNUMBER
-#endif
-#ifndef QT_NO_LINEEDIT
-# define QT_NO_LINEEDIT
-#endif
-#ifndef QT_NO_COMBOBOX
-# define QT_NO_COMBOBOX
-#endif
-#ifndef QT_NO_FONTCOMBOBOX
-# define QT_NO_FONTCOMBOBOX
-#endif
-#ifndef QT_NO_SPINBOX
-# define QT_NO_SPINBOX
-#endif
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_LISTWIDGET
-# define QT_NO_LISTWIDGET
-#endif
-#ifndef QT_NO_MENU
-# define QT_NO_MENU
-#endif
-#ifndef QT_NO_CONTEXTMENU
-# define QT_NO_CONTEXTMENU
-#endif
-#ifndef QT_NO_MAINWINDOW
-# define QT_NO_MAINWINDOW
-#endif
-#ifndef QT_NO_DOCKWIDGET
-# define QT_NO_DOCKWIDGET
-#endif
-#ifndef QT_NO_TOOLBAR
-# define QT_NO_TOOLBAR
-#endif
-#ifndef QT_NO_MENUBAR
-# define QT_NO_MENUBAR
-#endif
-#ifndef QT_NO_PROGRESSBAR
-# define QT_NO_PROGRESSBAR
-#endif
-#ifndef QT_NO_RESIZEHANDLER
-# define QT_NO_RESIZEHANDLER
-#endif
-#ifndef QT_NO_RUBBERBAND
-# define QT_NO_RUBBERBAND
-#endif
-#ifndef QT_NO_SPLITTER
-# define QT_NO_SPLITTER
-#endif
-#ifndef QT_NO_SIZEGRIP
-# define QT_NO_SIZEGRIP
-#endif
-#ifndef QT_NO_SLIDER
-# define QT_NO_SLIDER
-#endif
-#ifndef QT_NO_DIAL
-# define QT_NO_DIAL
-#endif
-#ifndef QT_NO_SCROLLBAR
-# define QT_NO_SCROLLBAR
-#endif
-#ifndef QT_NO_SCROLLAREA
-# define QT_NO_SCROLLAREA
-#endif
-#ifndef QT_NO_GRAPHICSVIEW
-# define QT_NO_GRAPHICSVIEW
-#endif
-#ifndef QT_NO_PRINTPREVIEWWIDGET
-# define QT_NO_PRINTPREVIEWWIDGET
-#endif
-#ifndef QT_NO_MDIAREA
-# define QT_NO_MDIAREA
-#endif
-#ifndef QT_NO_TEXTEDIT
-# define QT_NO_TEXTEDIT
-#endif
-#ifndef QT_NO_SYNTAXHIGHLIGHTER
-# define QT_NO_SYNTAXHIGHLIGHTER
-#endif
-#ifndef QT_NO_TEXTBROWSER
-# define QT_NO_TEXTBROWSER
-#endif
-#ifndef QT_NO_SPINWIDGET
-# define QT_NO_SPINWIDGET
-#endif
-#ifndef QT_NO_SPLASHSCREEN
-# define QT_NO_SPLASHSCREEN
-#endif
-#ifndef QT_NO_STACKEDWIDGET
-# define QT_NO_STACKEDWIDGET
-#endif
-#ifndef QT_NO_TABWIDGET
-# define QT_NO_TABWIDGET
-#endif
-#ifndef QT_NO_STATUSBAR
-# define QT_NO_STATUSBAR
-#endif
-#ifndef QT_NO_STATUSTIP
-# define QT_NO_STATUSTIP
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TOOLBUTTON
-# define QT_NO_TOOLBUTTON
-#endif
-#ifndef QT_NO_TABBAR
-# define QT_NO_TABBAR
-#endif
-#ifndef QT_NO_TOOLBOX
-# define QT_NO_TOOLBOX
-#endif
-#ifndef QT_NO_WHATSTHIS
-# define QT_NO_WHATSTHIS
-#endif
-#ifndef QT_NO_TOOLTIP
-# define QT_NO_TOOLTIP
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
-#ifndef QT_NO_VALIDATOR
-# define QT_NO_VALIDATOR
-#endif
diff --git a/src/corelib/global/qconfig-nacl.h b/src/corelib/global/qconfig-nacl.h
deleted file mode 100644
index 10292c05c3..0000000000
--- a/src/corelib/global/qconfig-nacl.h
+++ /dev/null
@@ -1,233 +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$
-**
-****************************************************************************/
-
-#if 0
-#pragma qt_sync_stop_processing
-#endif
-
-#define QT_FONTS_ARE_RESOURCES
-
-/* Data structures */
-#ifndef QT_NO_TEXTDATE
-# define QT_NO_TEXTDATE
-#endif
-#ifndef QT_NO_DATESTRING
-# define QT_NO_DATESTRING
-#endif
-
-/* Dialogs */
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PRINTPREVIEWDIALOG
-# define QT_NO_PRINTPREVIEWDIALOG
-#endif
-
-
-/* File I/O */
-#ifndef QT_NO_DOM
-# define QT_NO_DOM
-#endif
-#ifndef QT_NO_FILESYSTEMWATCHER
-# define QT_NO_FILESYSTEMWATCHER
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
-# define QT_NO_FILESYSTEMMODEL
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
-# define QT_NO_FILESYSTEMMODEL
-#endif
-#ifndef QT_NO_PROCESS
-# define QT_NO_PROCESS
-#endif
-#ifndef QT_NO_TEMPORARYFILE
-# define QT_NO_TEMPORARYFILE
-#endif
-#ifndef QT_NO_SETTINGS
-# define QT_NO_SETTINGS
-#endif
-#ifndef QT_NO_LIBRARY
-# define QT_NO_LIBRARY
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-# define QT_NO_IMAGEFORMATPLUGIN
-#endif
-#ifndef QT_NO_IMAGE_HEURISTIC_MASK
-# define QT_NO_IMAGE_HEURISTIC_MASK
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_BIG_CODECS
-# define QT_NO_BIG_CODECS
-#endif
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-
-#ifndef QT_NO_DIRMODEL
-# define QT_NO_DIRMODEL
-#endif
-
-/* Kernel */
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_CSSPARSER
-# define QT_NO_CSSPARSER
-#endif
-#ifndef QT_NO_CURSOR
-# define QT_NO_CURSOR
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHAREDMEMORY
-# define QT_NO_SHAREDMEMORY
-#endif
-#ifndef QT_NO_SYSTEMLOCALE
-# define QT_NO_SYSTEMSEMAPHORE
-#endif
-#ifndef QT_NO_SYSTEMSEMAPHORE
-# define QT_NO_SYSTEMSEMAPHORE
-#endif
-#ifndef QT_NO_TABLETEVENT
-# define QT_NO_TABLETEVENT
-#endif
-#ifndef QT_NO_CRASHHANDLER
-# define QT_NO_CRASHHANDLER
-#endif
-#ifndef QT_NO_CONCURRENT
-# define QT_NO_CONCURRENT
-#endif
-#ifndef QT_NO_XMLSTREAM
-# define QT_NO_XMLSTREAM
-#endif
-#ifndef QT_NO_XMLSTREAMREADER
-# define QT_NO_XMLSTREAMREADER
-#endif
-#ifndef QT_NO_XMLSTREAMWRITER
-# define QT_NO_XMLSTREAMWRITER
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_NETWORKPROXY
-# define QT_NO_NETWORKPROXY
-#endif
-#ifndef QT_NO_SOCKS5
-# define QT_NO_SOCKS5
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PAINT_DEBUG
-# define QT_NO_PAINT_DEBUG
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-#ifndef QT_NO_STYLE_WINDOWSCE
-# define QT_NO_STYLE_WINDOWSCE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSMOBILE
-# define QT_NO_STYLE_WINDOWSMOBILE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSVISTA
-# define QT_NO_STYLE_WINDOWSVISTA
-#endif
-#ifndef QT_NO_STYLE_WINDOWSXP
-# define QT_NO_STYLE_WINDOWSXP
-#endif
-
-/* Utilities */
-#ifndef QT_NO_ACCESSIBILITY
-# define QT_NO_ACCESSIBILITY
-#endif
-#ifndef QT_NO_COMPLETER
-# define QT_NO_COMPLETER
-#endif
-#ifndef QT_NO_DESKTOPSERVICES
-# define QT_NO_DESKTOPSERVICES
-#endif
-#ifndef QT_NO_SYSTEMTRAYICON
-# define QT_NO_SYSTEMTRAYICON
-#endif
diff --git a/src/corelib/global/qconfig-small.h b/src/corelib/global/qconfig-small.h
deleted file mode 100644
index 1f1bff91a3..0000000000
--- a/src/corelib/global/qconfig-small.h
+++ /dev/null
@@ -1,281 +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$
-**
-****************************************************************************/
-
-/* Dialogs */
-#ifndef QT_NO_COLORDIALOG
-# define QT_NO_COLORDIALOG
-#endif
-#ifndef QT_NO_ERRORMESSAGE
-# define QT_NO_ERRORMESSAGE
-#endif
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_MESSAGEBOX
-# define QT_NO_MESSAGEBOX
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-
-/* File I/O */
-#ifndef QT_NO_SETTINGS
-# define QT_NO_SETTINGS
-#endif
-#ifndef QT_NO_LIBRARY
-# define QT_NO_LIBRARY
-#endif
-
-/* Fonts */
-#ifndef QT_NO_FREETYPE
-# define QT_NO_FREETYPE
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-# define QT_NO_IMAGEFORMATPLUGIN
-#endif
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
-# define QT_NO_IMAGEFORMAT_JPEG
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XBM
-# define QT_NO_IMAGEFORMAT_XBM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XPM
-# define QT_NO_IMAGEFORMAT_XPM
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_DIRMODEL
-# define QT_NO_DIRMODEL
-#endif
-#ifndef QT_NO_PROXYMODEL
-# define QT_NO_PROXYMODEL
-#endif
-#ifndef QT_NO_SORTFILTERPROXYMODEL
-# define QT_NO_SORTFILTERPROXYMODEL
-#endif
-#ifndef QT_NO_STRINGLISTMODEL
-# define QT_NO_STRINGLISTMODEL
-#endif
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_ACTION
-# define QT_NO_ACTION
-#endif
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHORTCUT
-# define QT_NO_SHORTCUT
-#endif
-#ifndef QT_NO_WHEELEVENT
-# define QT_NO_WHEELEVENT
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_FUSION
-# define QT_NO_STYLE_FUSION
-#endif
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-#ifndef QT_NO_STYLE_WINDOWSVISTA
-# define QT_NO_STYLE_WINDOWSVISTA
-#endif
-
-/* Utilities */
-#ifndef QT_NO_COMPLETER
-# define QT_NO_COMPLETER
-#endif
-#ifndef QT_NO_DESKTOPSERVICES
-# define QT_NO_DESKTOPSERVICES
-#endif
-#ifndef QT_NO_MIMETYPE
-# define QT_NO_MIMETYPE
-#endif
-#ifndef QT_NO_SYSTEMTRAYICON
-# define QT_NO_SYSTEMTRAYICON
-#endif
-#ifndef QT_NO_GESTURES
-# define QT_NO_GESTURES
-#endif
-
-/* Widgets */
-#ifndef QT_NO_LCDNUMBER
-# define QT_NO_LCDNUMBER
-#endif
-#ifndef QT_NO_FONTCOMBOBOX
-# define QT_NO_FONTCOMBOBOX
-#endif
-#ifndef QT_NO_SPINBOX
-# define QT_NO_SPINBOX
-#endif
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_MENU
-# define QT_NO_MENU
-#endif
-#ifndef QT_NO_CONTEXTMENU
-# define QT_NO_CONTEXTMENU
-#endif
-#ifndef QT_NO_MAINWINDOW
-# define QT_NO_MAINWINDOW
-#endif
-#ifndef QT_NO_DOCKWIDGET
-# define QT_NO_DOCKWIDGET
-#endif
-#ifndef QT_NO_TOOLBAR
-# define QT_NO_TOOLBAR
-#endif
-#ifndef QT_NO_MENUBAR
-# define QT_NO_MENUBAR
-#endif
-#ifndef QT_NO_PROGRESSBAR
-# define QT_NO_PROGRESSBAR
-#endif
-#ifndef QT_NO_SPLITTER
-# define QT_NO_SPLITTER
-#endif
-#ifndef QT_NO_SIZEGRIP
-# define QT_NO_SIZEGRIP
-#endif
-#ifndef QT_NO_STACKEDWIDGET
-# define QT_NO_STACKEDWIDGET
-#endif
-#ifndef QT_NO_TABWIDGET
-# define QT_NO_TABWIDGET
-#endif
-#ifndef QT_NO_STATUSBAR
-# define QT_NO_STATUSBAR
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TOOLBUTTON
-# define QT_NO_TOOLBUTTON
-#endif
-#ifndef QT_NO_TABBAR
-# define QT_NO_TABBAR
-#endif
-#ifndef QT_NO_TOOLBOX
-# define QT_NO_TOOLBOX
-#endif
-#ifndef QT_NO_WHATSTHIS
-# define QT_NO_WHATSTHIS
-#endif
-#ifndef QT_NO_TOOLTIP
-# define QT_NO_TOOLTIP
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
-#ifndef QT_NO_VALIDATOR
-# define QT_NO_VALIDATOR
-#endif
diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt
index dec16eaef1..458f87ec16 100644
--- a/src/corelib/global/qfeatures.txt
+++ b/src/corelib/global/qfeatures.txt
@@ -107,7 +107,7 @@ Name: QSharedMemory
Feature: SYSTEMSEMAPHORE
Description: Provides a general counting system semaphore.
Section: Kernel
-Requires:
+Requires: SHAREDMEMORY
Name: QSystemSemaphore
Feature: XMLSTREAM
@@ -500,7 +500,7 @@ Name: QColorDialog
Feature: FILEDIALOG
Description: Supports a dialog widget for selecting files or directories.
Section: Dialogs
-Requires: DIRMODEL TREEVIEW COMBOBOX TOOLBUTTON BUTTONGROUP TOOLTIP SPLITTER STACKEDWIDGET PROXYMODEL
+Requires: FILESYSTEMMODEL TREEVIEW COMBOBOX TOOLBUTTON BUTTONGROUP TOOLTIP SPLITTER STACKEDWIDGET PROXYMODEL
Name: QFileDialog
Feature: FONTDIALOG
@@ -512,7 +512,7 @@ Name: QFontDialog
Feature: PRINTDIALOG
Description: Supports a dialog widget for specifying printer configuration.
Section: Dialogs
-Requires: PRINTER COMBOBOX BUTTONGROUP SPINBOX TREEVIEW TABWIDGET
+Requires: PRINTER COMBOBOX BUTTONGROUP SPINBOX TABWIDGET
Name: QPrintDialog
Feature: PRINTPREVIEWDIALOG
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index b907caa9b6..a6bd37c33f 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -111,8 +111,8 @@ public:
typedef Enum enum_type;
// compiler-generated copy/move ctor/assignment operators are fine!
#ifdef Q_QDOC
- inline QFlags(const QFlags &other);
- inline QFlags &operator=(const QFlags &other);
+ Q_DECL_CONSTEXPR inline QFlags(const QFlags &other);
+ Q_DECL_CONSTEXPR inline QFlags &operator=(const QFlags &other);
#endif
Q_DECL_CONSTEXPR inline QFlags(Enum f) Q_DECL_NOTHROW : i(Int(f)) {}
Q_DECL_CONSTEXPR inline QFlags(Zero = Q_NULLPTR) Q_DECL_NOTHROW : i(0) {}
@@ -163,8 +163,10 @@ private:
Int i;
};
+#ifndef Q_MOC_RUN
#define Q_DECLARE_FLAGS(Flags, Enum)\
typedef QFlags<Enum> Flags;
+#endif
#define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
Q_DECL_CONSTEXPR inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) Q_DECL_NOTHROW \
@@ -179,8 +181,11 @@ Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1,
#else /* Q_NO_TYPESAFE_FLAGS */
+#ifndef Q_MOC_RUN
#define Q_DECLARE_FLAGS(Flags, Enum)\
typedef uint Flags;
+#endif
+
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
#endif /* Q_NO_TYPESAFE_FLAGS */
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index c14f774bd6..743d9d14a5 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -47,7 +47,6 @@
#include "qdatetime.h"
#include <private/qlocale_tools_p.h>
-#include <private/qsystemlibrary_p.h>
#include <qmutex.h>
#ifndef QT_NO_QOBJECT
@@ -64,11 +63,9 @@
# include <exception>
#endif
-#if !defined(Q_OS_WINCE)
-# include <errno.h>
-# if defined(Q_CC_MSVC)
-# include <crtdbg.h>
-# endif
+#include <errno.h>
+#if defined(Q_CC_MSVC)
+# include <crtdbg.h>
#endif
#ifdef Q_OS_WINRT
@@ -573,11 +570,11 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
\snippet code/src_corelib_global_qglobal.cpp 4
The remaining functions are qRound() and qRound64(), which both
- accept a \l qreal value as their argument returning the value
- rounded up to the nearest integer and 64-bit integer respectively,
- the qInstallMessageHandler() function which installs the given
- QtMessageHandler, and the qVersion() function which returns the
- version number of Qt at run-time as a string.
+ accept a \c double or \c float value as their argument returning
+ the value rounded up to the nearest integer and 64-bit integer
+ respectively, the qInstallMessageHandler() function which installs
+ the given QtMessageHandler, and the qVersion() function which
+ returns the version number of Qt at run-time as a string.
\section1 Macros
@@ -864,24 +861,44 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
\snippet code/src_corelib_global_qglobal.cpp 10
*/
-/*! \fn int qRound(qreal value)
+/*! \fn int qRound(double value)
+ \relates <QtGlobal>
+
+ Rounds \a value to the nearest integer.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 11A
+*/
+
+/*! \fn int qRound(float value)
\relates <QtGlobal>
Rounds \a value to the nearest integer.
Example:
- \snippet code/src_corelib_global_qglobal.cpp 11
+ \snippet code/src_corelib_global_qglobal.cpp 11B
*/
-/*! \fn qint64 qRound64(qreal value)
+/*! \fn qint64 qRound64(double value)
\relates <QtGlobal>
Rounds \a value to the nearest 64-bit integer.
Example:
- \snippet code/src_corelib_global_qglobal.cpp 12
+ \snippet code/src_corelib_global_qglobal.cpp 12A
+*/
+
+/*! \fn qint64 qRound64(float value)
+ \relates <QtGlobal>
+
+ Rounds \a value to the nearest 64-bit integer.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 12B
*/
/*! \fn const T &qMin(const T &value1, const T &value2)
@@ -1016,7 +1033,7 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
example, "4.1.2"). This may be a different version than the
version the application was compiled against.
- \sa QT_VERSION_STR
+ \sa QT_VERSION_STR, QLibraryInfo::version()
*/
const char *qVersion() Q_DECL_NOTHROW
@@ -1147,20 +1164,20 @@ bool qSharedBuild() Q_DECL_NOTHROW
\value WV_6_3 Operating system version 6.3, corresponds to Windows 8.1, introduced in Qt 5.2
\value WV_10_0 Operating system version 10.0, corresponds to Windows 10, introduced in Qt 5.5
- \omitvalue WV_CE
- \omitvalue WV_CENET
- \omitvalue WV_CE_5
- \omitvalue WV_CE_6
-
The following masks can be used for testing whether a Windows
version is MS-DOS-based or NT-based:
\value WV_DOS_based MS-DOS-based version of Windows
\value WV_NT_based NT-based version of Windows
- \omitvalue WV_CE_based
\value WV_None Operating system other than Windows.
+ \omitvalue WV_CE
+ \omitvalue WV_CENET
+ \omitvalue WV_CE_5
+ \omitvalue WV_CE_6
+ \omitvalue WV_CE_based
+
\sa MacVersion
*/
@@ -1221,6 +1238,12 @@ bool qSharedBuild() Q_DECL_NOTHROW
\value MV_IOS_9_3 iOS 9.3
\value MV_IOS_10_0 iOS 10.0
+ \value MV_TVOS tvOS (any)
+ \value MV_TVOS_9_0 tvOS 9.0
+ \value MV_TVOS_9_1 tvOS 9.1
+ \value MV_TVOS_9_2 tvOS 9.2
+ \value MV_TVOS_10_0 tvOS 10.0
+
\value MV_None Not a Darwin operating system
\sa WinVersion
@@ -1927,13 +1950,37 @@ QSysInfo::MacVersion QSysInfo::macVersion()
return QSysInfo::MacVersion(Q_MV_OSX(version.major, version.minor));
#elif defined(Q_OS_IOS)
return QSysInfo::MacVersion(Q_MV_IOS(version.major, version.minor));
+#elif defined(Q_OS_TVOS)
+ return QSysInfo::MacVersion(Q_MV_TVOS(version.major, version.minor));
+#elif defined(Q_OS_WATCHOS)
+ return QSysInfo::MacVersion(Q_MV_WATCHOS(version.major, version.minor));
#else
return QSysInfo::MV_Unknown;
#endif
}
const QSysInfo::MacVersion QSysInfo::MacintoshVersion = QSysInfo::macVersion();
-#elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#ifdef Q_OS_OSX
+static const char *osxVer_helper(QAppleOperatingSystemVersion version = qt_apple_os_version())
+{
+ if (version.major == 10) {
+ switch (version.minor) {
+ case 9:
+ return "Mavericks";
+ case 10:
+ return "Yosemite";
+ case 11:
+ return "El Capitan";
+ case 12:
+ return "Sierra";
+ }
+ }
+ // unknown, future version
+ return 0;
+}
+#endif
+
+#elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINRT)
QT_BEGIN_INCLUDE_NAMESPACE
#include "qt_windows.h"
@@ -1986,9 +2033,7 @@ static inline OSVERSIONINFOEX determineWinOsVersion()
{
OSVERSIONINFOEX result = { sizeof(OSVERSIONINFOEX), 0, 0, 0, 0, {'\0'}, 0, 0, 0, 0, 0};
-#ifndef Q_OS_WINCE
#define GetProcAddressA GetProcAddress
-#endif
// GetModuleHandle is not supported in WinRT and linking to it at load time
// will not pass the Windows App Certification Kit... but it exists and is functional,
@@ -2037,113 +2082,66 @@ static inline OSVERSIONINFOEX determineWinOsVersion()
static OSVERSIONINFOEX winOsVersion()
{
- static OSVERSIONINFOEX result = determineWinOsVersion();
- return result;
-}
-
-QSysInfo::WinVersion QSysInfo::windowsVersion()
-{
-#ifndef VER_PLATFORM_WIN32s
-#define VER_PLATFORM_WIN32s 0
-#endif
-#ifndef VER_PLATFORM_WIN32_WINDOWS
-#define VER_PLATFORM_WIN32_WINDOWS 1
-#endif
-#ifndef VER_PLATFORM_WIN32_NT
-#define VER_PLATFORM_WIN32_NT 2
-#endif
-#ifndef VER_PLATFORM_WIN32_CE
-#define VER_PLATFORM_WIN32_CE 3
-#endif
-
- static QSysInfo::WinVersion winver;
- if (winver)
- return winver;
- winver = QSysInfo::WV_NT;
- const OSVERSIONINFOEX osver = winOsVersion();
- if (osver.dwMajorVersion == 0)
- return QSysInfo::WV_None;
-#ifdef Q_OS_WINCE
- DWORD qt_cever = 0;
- qt_cever = osver.dwMajorVersion * 100;
- qt_cever += osver.dwMinorVersion * 10;
-#endif
- switch (osver.dwPlatformId) {
- case VER_PLATFORM_WIN32s:
- winver = QSysInfo::WV_32s;
- break;
- case VER_PLATFORM_WIN32_WINDOWS:
- // We treat Windows Me (minor 90) the same as Windows 98
- if (osver.dwMinorVersion == 90)
- winver = QSysInfo::WV_Me;
- else if (osver.dwMinorVersion == 10)
- winver = QSysInfo::WV_98;
- else
- winver = QSysInfo::WV_95;
- break;
-#ifdef Q_OS_WINCE
- case VER_PLATFORM_WIN32_CE:
- if (qt_cever >= 600)
- winver = QSysInfo::WV_CE_6;
- if (qt_cever >= 500)
- winver = QSysInfo::WV_CE_5;
- else if (qt_cever >= 400)
- winver = QSysInfo::WV_CENET;
- else
- winver = QSysInfo::WV_CE;
- break;
-#endif
- default: // VER_PLATFORM_WIN32_NT
- if (osver.dwMajorVersion < 5) {
- winver = QSysInfo::WV_NT;
- } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 0) {
- winver = QSysInfo::WV_2000;
- } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1) {
- winver = QSysInfo::WV_XP;
- } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2) {
- winver = QSysInfo::WV_2003;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0) {
- winver = QSysInfo::WV_VISTA;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1) {
- winver = QSysInfo::WV_WINDOWS7;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2) {
- winver = QSysInfo::WV_WINDOWS8;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3) {
- winver = QSysInfo::WV_WINDOWS8_1;
- } else if (osver.dwMajorVersion == 10 && osver.dwMinorVersion == 0) {
- winver = QSysInfo::WV_WINDOWS10;
- } else {
- winver = QSysInfo::WV_NT_based;
- }
- }
-
+ OSVERSIONINFOEX realResult = determineWinOsVersion();
#ifdef QT_DEBUG
{
if (Q_UNLIKELY(qEnvironmentVariableIsSet("QT_WINVER_OVERRIDE"))) {
+ OSVERSIONINFOEX result = realResult;
+ result.dwMajorVersion = 0;
+ result.dwMinorVersion = 0;
+
+ // Erase any build number and service pack information
+ result.dwBuildNumber = 0;
+ result.szCSDVersion[0] = L'\0';
+ result.wServicePackMajor = 0;
+ result.wServicePackMinor = 0;
+
const QByteArray winVerOverride = qgetenv("QT_WINVER_OVERRIDE");
- if (winVerOverride == "NT")
- winver = QSysInfo::WV_NT;
- else if (winVerOverride == "2000")
- winver = QSysInfo::WV_2000;
- else if (winVerOverride == "2003")
- winver = QSysInfo::WV_2003;
- else if (winVerOverride == "XP")
- winver = QSysInfo::WV_XP;
- else if (winVerOverride == "VISTA")
- winver = QSysInfo::WV_VISTA;
- else if (winVerOverride == "WINDOWS7")
- winver = QSysInfo::WV_WINDOWS7;
- else if (winVerOverride == "WINDOWS8")
- winver = QSysInfo::WV_WINDOWS8;
- else if (winVerOverride == "WINDOWS8_1")
- winver = QSysInfo::WV_WINDOWS8_1;
- else if (winVerOverride == "WINDOWS10")
- winver = QSysInfo::WV_WINDOWS10;
+ if (winVerOverride == "WINDOWS7" || winVerOverride == "2008_R2") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 1;
+ } else if (winVerOverride == "WINDOWS8" || winVerOverride == "2012") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 2;
+ } else if (winVerOverride == "WINDOWS8_1" || winVerOverride == "2012_R2") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 3;
+ } else if (winVerOverride == "WINDOWS10" || winVerOverride == "2016") {
+ result.dwMajorVersion = 10;
+ } else {
+ return realResult;
+ }
+
+ if (winVerOverride == "2008_R2"
+ || winVerOverride == "2012"
+ || winVerOverride == "2012_R2"
+ || winVerOverride == "2016") {
+ // If the current host OS is a domain controller and the override OS
+ // is also a server type OS, preserve that information
+ if (result.wProductType == VER_NT_WORKSTATION)
+ result.wProductType = VER_NT_SERVER;
+ } else {
+ // Any other OS must be a workstation OS type
+ result.wProductType = VER_NT_WORKSTATION;
+ }
}
}
#endif
+ return realResult;
+}
- return winver;
+QSysInfo::WinVersion QSysInfo::windowsVersion()
+{
+ const OSVERSIONINFOEX osver = winOsVersion();
+ if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1)
+ return QSysInfo::WV_WINDOWS7;
+ if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2)
+ return QSysInfo::WV_WINDOWS8;
+ if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3)
+ return QSysInfo::WV_WINDOWS8_1;
+ if (osver.dwMajorVersion == 10 && osver.dwMinorVersion == 0)
+ return QSysInfo::WV_WINDOWS10;
+ return QSysInfo::WV_NT_based;
}
static QString winSp_helper()
@@ -2162,37 +2160,21 @@ static QString winSp_helper()
static const char *winVer_helper()
{
- const bool workstation = winOsVersion().wProductType == VER_NT_WORKSTATION;
-
- switch (int(QSysInfo::WindowsVersion)) {
- case QSysInfo::WV_NT:
- return "NT";
- case QSysInfo::WV_2000:
- return "2000";
- case QSysInfo::WV_XP:
- return "XP";
- case QSysInfo::WV_2003:
- return "2003";
- case QSysInfo::WV_VISTA:
- return workstation ? "Vista" : "Server 2008";
- case QSysInfo::WV_WINDOWS7:
+ const OSVERSIONINFOEX osver = winOsVersion();
+ const bool workstation = osver.wProductType == VER_NT_WORKSTATION;
+
+#define Q_WINVER(major, minor) (major << 8 | minor)
+ switch (Q_WINVER(osver.dwMajorVersion, osver.dwMinorVersion)) {
+ case Q_WINVER(6, 1):
return workstation ? "7" : "Server 2008 R2";
- case QSysInfo::WV_WINDOWS8:
+ case Q_WINVER(6, 2):
return workstation ? "8" : "Server 2012";
- case QSysInfo::WV_WINDOWS8_1:
+ case Q_WINVER(6, 3):
return workstation ? "8.1" : "Server 2012 R2";
- case QSysInfo::WV_WINDOWS10:
+ case Q_WINVER(10, 0):
return workstation ? "10" : "Server 2016";
-
- case QSysInfo::WV_CE:
- return "CE";
- case QSysInfo::WV_CENET:
- return "CENET";
- case QSysInfo::WV_CE_5:
- return "CE5";
- case QSysInfo::WV_CE_6:
- return "CE6";
}
+#undef Q_WINVER
// unknown, future version
return 0;
}
@@ -2449,7 +2431,7 @@ QString QSysInfo::buildCpuArchitecture()
*/
QString QSysInfo::currentCpuArchitecture()
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
// We don't need to catch all the CPU architectures in this function;
// only those where the host CPU might be different than the build target
// (usually, 64-bit platforms).
@@ -2601,9 +2583,7 @@ static QString unknownText()
*/
QString QSysInfo::kernelType()
{
-#if defined(Q_OS_WINCE)
- return QStringLiteral("wince");
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
return QStringLiteral("winnt");
#elif defined(Q_OS_UNIX)
struct utsname u;
@@ -2617,7 +2597,7 @@ QString QSysInfo::kernelType()
\since 5.4
Returns the release version of the operating system kernel. On Windows, it
- returns the version of the NT or CE kernel. On Unix systems, including
+ returns the version of the NT kernel. On Unix systems, including
Android and \macos, it returns the same as the \c{uname -r}
command would return.
@@ -2659,9 +2639,10 @@ QString QSysInfo::kernelVersion()
to determine the distribution name and returns that. If determining the
distribution name failed, it returns "unknown".
- \b{Darwin, \macos and iOS note}: this function returns "macos" for macOS
- systems, "ios" for iOS systems and "darwin" in case the system could not be
- determined.
+ \b{Darwin, \macos, iOS, tvOS, and watchOS note}: this function returns
+ "macos" for \macos systems, "ios" for iOS systems, "tvos" for tvOS systems,
+ "watchos" for watchOS systems, and "darwin" in case the system could not
+ be determined.
\b{OS X note}: this function returns "osx" for versions of \macos prior to 10.12.
@@ -2682,8 +2663,6 @@ QString QSysInfo::productType()
return QStringLiteral("winphone");
#elif defined(Q_OS_WINRT)
return QStringLiteral("winrt");
-#elif defined(Q_OS_WINCE)
- return QStringLiteral("wince");
#elif defined(Q_OS_WIN)
return QStringLiteral("windows");
@@ -2695,6 +2674,10 @@ QString QSysInfo::productType()
#elif defined(Q_OS_IOS)
return QStringLiteral("ios");
+#elif defined(Q_OS_TVOS)
+ return QStringLiteral("tvos");
+#elif defined(Q_OS_WATCHOS)
+ return QStringLiteral("watchos");
#elif defined(Q_OS_MACOS)
const QAppleOperatingSystemVersion version = qt_apple_os_version();
if (version.major == 10 && version.minor < 12)
@@ -2728,9 +2711,8 @@ QString QSysInfo::productType()
In all other Unix-type systems, this function always returns "unknown".
- \note The version string returned from this function is only guaranteed to
- be orderable on Android, \macos and iOS. On Windows, some Windows
- versions are text ("XP" and "Vista", for example). On Linux, the version of
+ \note The version string returned from this function is not guaranteed to
+ be orderable. On Linux, the version of
the distribution may jump unexpectedly, please refer to the distribution's
documentation for versioning practices.
@@ -2781,53 +2763,40 @@ QString QSysInfo::prettyProductName()
{
#if defined(Q_OS_IOS)
return QLatin1String("iOS ") + productVersion();
+#elif defined(Q_OS_TVOS)
+ return QLatin1String("tvOS ") + productVersion();
+#elif defined(Q_OS_WATCHOS)
+ return QLatin1String("watchOS ") + productVersion();
#elif defined(Q_OS_MACOS)
- // get the known codenames
- const char *basename = 0;
- switch (int(MacintoshVersion)) {
- case MV_CHEETAH:
- case MV_PUMA:
- case MV_JAGUAR:
- case MV_PANTHER:
- case MV_TIGER:
- // This version of Qt does not run on those versions of OS X
- // so this case label will never be reached
- Q_UNREACHABLE();
- break;
- case MV_LEOPARD:
- basename = "Mac OS X Leopard (";
- break;
- case MV_SNOWLEOPARD:
- basename = "Mac OS X Snow Leopard (";
- break;
- case MV_LION:
- basename = "OS X Lion (";
- break;
- case MV_MOUNTAINLION:
- basename = "OS X Mountain Lion (";
- break;
- case MV_MAVERICKS:
- basename = "OS X Mavericks (";
- break;
- case MV_YOSEMITE:
- basename = "OS X Yosemite (";
- break;
- case MV_ELCAPITAN:
- basename = "OS X El Capitan (";
- break;
- case MV_SIERRA:
- basename = "macOS Sierra (";
- break;
+ const QAppleOperatingSystemVersion version = qt_apple_os_version();
+ const char *name = osxVer_helper(version);
+ if (name) {
+ return (version.major == 10 && version.minor < 12
+ ? QLatin1String("OS X ")
+ : QLatin1String("macOS "))
+ + QLatin1String(name)
+ + QLatin1String(" (") + QString::number(version.major)
+ + QLatin1Char('.') + QString::number(version.minor)
+ + QLatin1Char(')');
+ } else {
+ return QLatin1String("macOS ")
+ + QString::number(version.major) + QLatin1Char('.')
+ + QString::number(version.minor);
}
- if (basename)
- return QLatin1String(basename) + productVersion() + QLatin1Char(')');
-
- // a future version of macOS
- return QLatin1String("macOS ") + productVersion();
#elif defined(Q_OS_WINPHONE)
return QLatin1String("Windows Phone ") + QLatin1String(winVer_helper());
#elif defined(Q_OS_WIN)
- return QLatin1String("Windows ") + QLatin1String(winVer_helper()) + winSp_helper();
+ const char *name = winVer_helper();
+ const OSVERSIONINFOEX osver = winOsVersion();
+ if (name)
+ return QLatin1String("Windows ") + QLatin1String(name) + winSp_helper()
+ + QLatin1String(" (") + QString::number(osver.dwMajorVersion)
+ + QLatin1Char('.') + QString::number(osver.dwMinorVersion)
+ + QLatin1Char(')');
+ else
+ return QLatin1String("Windows ")
+ + QString::number(osver.dwMajorVersion) + QLatin1Char('.')
+ + QString::number(osver.dwMinorVersion);
#elif defined(Q_OS_ANDROID)
return QLatin1String("Android ") + productVersion();
#elif defined(Q_OS_HAIKU)
@@ -2994,6 +2963,20 @@ QString QSysInfo::machineHostName()
*/
/*!
+ \macro void Q_FALLTHROUGH()
+ \relates <QtGlobal>
+ \since 5.8
+
+ Can be used in switch statements at the end of case block to tell the compiler
+ and other developers that that the lack of a break statement is intentional.
+
+ This is useful since a missing break statement is often a bug, and some
+ compilers can be configured to emit warnings when one is not found.
+
+ \sa Q_UNREACHABLE()
+*/
+
+/*!
\macro void Q_CHECK_PTR(void *pointer)
\relates <QtGlobal>
@@ -4291,6 +4274,24 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
*/
/*!
+ \fn bool qFuzzyIsNull(double d)
+ \relates <QtGlobal>
+ \since 4.4
+ \threadsafe
+
+ Returns true if the absolute value of \a d is within 0.000000000001 of 0.0.
+*/
+
+/*!
+ \fn bool qFuzzyIsNull(float f)
+ \relates <QtGlobal>
+ \since 4.4
+ \threadsafe
+
+ Returns true if the absolute value of \a f is within 0.00001f of 0.0.
+*/
+
+/*!
\macro QT_REQUIRE_VERSION(int argc, char **argv, const char *version)
\relates <QtGlobal>
@@ -4505,7 +4506,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
On QNX the message is sent to slogger2
If you are using the \b{default message handler} this function will
- abort on Unix systems to create a core dump. On Windows, for debug builds,
+ abort to create a core dump. On Windows, for debug builds,
this function will report a _CRT_ERROR enabling you to connect a debugger
to the application.
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 118203f720..dd8b6110b3 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -56,19 +56,30 @@
*/
#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
-#if !defined(QT_BUILD_QMAKE) && !defined(QT_BUILD_CONFIGURE)
+#ifndef QT_BOOTSTRAPPED
#include <QtCore/qconfig.h>
-#include <QtCore/qfeatures.h>
+#include <QtCore/qtcore-config.h>
#endif
// The QT_SUPPORTS macro is deprecated. Don't use it in new code.
-// Instead, use #ifdef/ndef QT_NO_feature.
+// Instead, use QT_CONFIG(feature)
// ### Qt6: remove macro
#ifdef _MSC_VER
# define QT_SUPPORTS(FEATURE) (!defined QT_NO_##FEATURE)
#else
# define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE))
#endif
+
+/*
+ The QT_CONFIG macro implements a safe compile time check for features of Qt.
+ Features can be in three states:
+ 0 or undefined: This will lead to a compile error when testing for it
+ -1: The feature is not available
+ 1: The feature is available
+*/
+#define QT_CONFIG(feature) (1/QT_FEATURE_##feature == 1)
+#define QT_REQUIRE_CONFIG(feature) Q_STATIC_ASSERT_X(QT_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " not vailable.")
+
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
# define QT_NO_UNSHARABLE_CONTAINERS
#endif
@@ -296,26 +307,8 @@ typedef double qreal;
# else
# define Q_CORE_EXPORT Q_DECL_IMPORT
# endif
-# if defined(QT_BUILD_GUI_LIB)
-# define Q_GUI_EXPORT Q_DECL_EXPORT
-# else
-# define Q_GUI_EXPORT Q_DECL_IMPORT
-# endif
-# if defined(QT_BUILD_WIDGETS_LIB)
-# define Q_WIDGETS_EXPORT Q_DECL_EXPORT
-# else
-# define Q_WIDGETS_EXPORT Q_DECL_IMPORT
-# endif
-# if defined(QT_BUILD_NETWORK_LIB)
-# define Q_NETWORK_EXPORT Q_DECL_EXPORT
-# else
-# define Q_NETWORK_EXPORT Q_DECL_IMPORT
-# endif
#else
# define Q_CORE_EXPORT
-# define Q_GUI_EXPORT
-# define Q_WIDGETS_EXPORT
-# define Q_NETWORK_EXPORT
#endif
/*
@@ -469,7 +462,7 @@ typedef qptrdiff qintptr;
# define QT_ASCII_CAST_WARN
#endif
-#if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE)
+#if defined(__i386__) || defined(_WIN32)
# if defined(Q_CC_GNU)
# define QT_FASTCALL __attribute__((regparm(3)))
# elif defined(Q_CC_MSVC)
@@ -529,23 +522,11 @@ Q_DECL_CONSTEXPR inline int qRound(double d)
{ return d >= 0.0 ? int(d + 0.5) : int(d - double(int(d-1)) + 0.5) + int(d-1); }
Q_DECL_CONSTEXPR inline int qRound(float d)
{ return d >= 0.0f ? int(d + 0.5f) : int(d - float(int(d-1)) + 0.5f) + int(d-1); }
-#ifdef Q_QDOC
-/*
- Just for documentation generation
-*/
-int qRound(qreal d);
-#endif
Q_DECL_CONSTEXPR inline qint64 qRound64(double d)
{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - double(qint64(d-1)) + 0.5) + qint64(d-1); }
Q_DECL_CONSTEXPR inline qint64 qRound64(float d)
{ return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); }
-#ifdef Q_QDOC
-/*
- Just for documentation generation
-*/
-qint64 qRound64(qreal d);
-#endif
template <typename T>
Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
@@ -568,25 +549,53 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max
#ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
# define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
#endif
+#ifndef Q_FORWARD_DECLARE_CG_TYPE
+#define Q_FORWARD_DECLARE_CG_TYPE(type) typedef const struct type *type ## Ref;
+#endif
+#ifndef Q_FORWARD_DECLARE_MUTABLE_CG_TYPE
+#define Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(type) typedef struct type *type ## Ref;
+#endif
-#ifdef Q_OS_MAC
-# define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) \
- ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= osx) || \
- (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios))
+#ifdef Q_OS_DARWIN
+# define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos) \
+ ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= macos) || \
+ (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios) || \
+ (defined(__TV_OS_VERSION_MAX_ALLOWED) && tvos != __TVOS_NA && __TV_OS_VERSION_MAX_ALLOWED >= tvos) || \
+ (defined(__WATCH_OS_VERSION_MAX_ALLOWED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MAX_ALLOWED >= watchos))
-# define QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, ios) \
- ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < osx) || \
- (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios))
+# define QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, tvos, watchos) \
+ ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < macos) || \
+ (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios) || \
+ (defined(__TV_OS_VERSION_MIN_REQUIRED) && tvos != __TVOS_NA && __TV_OS_VERSION_MIN_REQUIRED < tvos) || \
+ (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MIN_REQUIRED < watchos))
+# define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios) \
+ QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, __TVOS_NA, __WATCHOS_NA)
+# define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos) \
+ QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
# define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) \
- QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, ios)
-# define QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(osx) \
- QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, __IPHONE_NA)
-
+ QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
+# define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos) \
+ QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
+# define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos) \
+ QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
+
+# define QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(macos, ios) \
+ QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, __TVOS_NA, __WATCHOS_NA)
+# define QT_MACOS_DEPLOYMENT_TARGET_BELOW(macos) \
+ QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
# define QT_IOS_DEPLOYMENT_TARGET_BELOW(ios) \
- QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios)
-# define QT_OSX_DEPLOYMENT_TARGET_BELOW(osx) \
- QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, __IPHONE_NA)
+ QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
+# define QT_TVOS_DEPLOYMENT_TARGET_BELOW(tvos) \
+ QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
+# define QT_WATCHOS_DEPLOYMENT_TARGET_BELOW(watchos) \
+ QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
+
+# define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios)
+# define QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, ios) QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(osx, ios)
+
+# define QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(osx) QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(osx)
+# define QT_OSX_DEPLOYMENT_TARGET_BELOW(osx) QT_MACOS_DEPLOYMENT_TARGET_BELOW(osx)
// Implemented in qcore_mac_objc.mm
class Q_CORE_EXPORT QMacAutoReleasePool
@@ -599,7 +608,7 @@ private:
void *pool;
};
-#endif // Q_OS_MAC
+#endif // Q_OS_DARWIN
/*
Data stream functions are provided by many classes (defined in qdatastream.h)
@@ -622,7 +631,7 @@ class QDataStream;
# define QT_NO_SOCKS5
#endif
-#if defined(Q_OS_IOS)
+#if defined(QT_PLATFORM_UIKIT)
# define QT_NO_PROCESS
#endif
@@ -795,18 +804,12 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2)
return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2)));
}
-/*!
- \internal
-*/
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) Q_REQUIRED_RESULT Q_DECL_UNUSED;
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d)
{
return qAbs(d) <= 0.000000000001;
}
-/*!
- \internal
-*/
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) Q_REQUIRED_RESULT Q_DECL_UNUSED;
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f)
{
@@ -941,10 +944,11 @@ template <typename T>
class QForeachContainer {
QForeachContainer &operator=(const QForeachContainer &) Q_DECL_EQ_DELETE;
public:
- inline QForeachContainer(const T& t) : c(t), i(c.begin()), e(c.end()), control(1) { }
+ QForeachContainer(const T &t) : c(t) {}
+ QForeachContainer(T &&t) : c(std::move(t)) {}
const T c;
- typename T::const_iterator i, e;
- int control;
+ typename T::const_iterator i = c.begin(), e = c.end();
+ int control = 1;
};
// Explanation of the control word:
@@ -1032,8 +1036,11 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
#ifdef Q_QDOC
// Just for documentation generation
+template<typename T>
auto qOverload(T functionPointer);
+template<typename T>
auto qConstOverload(T memberFunctionPointer);
+template<typename T>
auto qNonConstOverload(T memberFunctionPointer);
#elif defined(Q_COMPILER_VARIADIC_TEMPLATES)
diff --git a/src/corelib/global/qglobal_p.h b/src/corelib/global/qglobal_p.h
new file mode 100644
index 0000000000..c329357f46
--- /dev/null
+++ b/src/corelib/global/qglobal_p.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGLOBAL_P_H
+#define QGLOBAL_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 "qglobal.h"
+#include "qglobal_p.h" // include self to avoid syncqt warning - no-op
+
+#ifndef QT_BOOTSTRAPPED
+#include <QtCore/private/qconfig_p.h>
+#include <QtCore/private/qtcore-config_p.h>
+#endif
+
+#define QT_LIBRARY_VERSION(lib) QT_LIBRARY_VERSION_##lib
+#define QT_LIBRARY_VERSION_MAJOR(lib) (QT_LIBRARY_VERSION_##lib >> 16)
+#define QT_LIBRARY_VERSION_MINOR(lib) ((QT_LIBRARY_VERSION_##lib >> 8) & 0xff)
+#define QT_LIBRARY_VERSION_PATCH(lib) (QT_LIBRARY_VERSION_##lib & 0xff)
+
+#endif // QGLOBAL_P_H
+
diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp
index b91ec64786..7b9a3db30d 100644
--- a/src/corelib/global/qhooks.cpp
+++ b/src/corelib/global/qhooks.cpp
@@ -67,7 +67,7 @@ quintptr Q_CORE_EXPORT qtHookData[] = {
// The required sizes and offsets are tested in tests/auto/other/toolsupport.
// When this fails and the change was intentional, adjust the test and
// adjust this value here.
- 5
+ 15
};
Q_STATIC_ASSERT(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0]));
diff --git a/src/corelib/global/qhooks_p.h b/src/corelib/global/qhooks_p.h
index 47270d8ad2..a51a2ec86b 100644
--- a/src/corelib/global/qhooks_p.h
+++ b/src/corelib/global/qhooks_p.h
@@ -52,7 +52,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 458200180e..1a7d64780f 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -229,30 +229,30 @@ QLibraryInfo::QLibraryInfo()
{ }
/*!
- Returns the person to whom this build of Qt is licensed.
-
- \sa licensedProducts()
+ \deprecated
+ This function used to return the person to whom this build of Qt is licensed, now returns an empty string.
*/
+#if QT_DEPRECATED_SINCE(5, 8)
QString
QLibraryInfo::licensee()
{
- const char * volatile str = QT_CONFIGURE_LICENSEE;
- return QString::fromLocal8Bit(str);
+ return QString();
}
+#endif
/*!
- Returns the products that the license for this build of Qt has access to.
-
- \sa licensee()
+ \deprecated
+ This function used to return the products that the license for this build of Qt has access to, now returns an empty string.
*/
+#if QT_DEPRECATED_SINCE(5, 8)
QString
QLibraryInfo::licensedProducts()
{
- const char * volatile str = QT_CONFIGURE_LICENSED_PRODUCTS;
- return QString::fromLatin1(str);
+ return QString();
}
+#endif
/*!
\since 4.6
@@ -366,6 +366,19 @@ QLibraryInfo::isDebugBuild()
#endif
}
+#ifndef QT_BOOTSTRAPPED
+/*!
+ \since 5.8
+ Returns the version of the Qt library.
+
+ \sa qVersion()
+*/
+QVersionNumber QLibraryInfo::version() Q_DECL_NOTHROW
+{
+ return QVersionNumber(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH);
+}
+#endif // QT_BOOTSTRAPPED
+
#endif // QT_BUILD_QMAKE
/*
@@ -519,7 +532,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
reg_var.setMinimal(true);
while((rep = reg_var.indexIn(ret)) != -1) {
ret.replace(rep, reg_var.matchedLength(),
- QString::fromLocal8Bit(qgetenv(ret.mid(rep + 2,
+ QString::fromLocal8Bit(qgetenv(ret.midRef(rep + 2,
reg_var.matchedLength() - 3).toLatin1().constData()).constData()));
}
@@ -603,10 +616,10 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName)
#if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS)
QScopedPointer<const QSettings> settings(QLibraryInfoPrivate::findConfiguration());
if (!settings.isNull()) {
- QString key = QLatin1String(platformsSection);
- key += QLatin1Char('/');
- key += platformName;
- key += QLatin1String("Arguments");
+ const QString key = QLatin1String(platformsSection)
+ + QLatin1Char('/')
+ + platformName
+ + QLatin1String("Arguments");
return settings->value(key).toStringList();
}
#endif // !QT_BUILD_QMAKE && !QT_NO_SETTINGS
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index 362d47dea3..55be706382 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -42,6 +42,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qdatetime.h>
+#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
@@ -50,8 +51,10 @@ class QStringList;
class Q_CORE_EXPORT QLibraryInfo
{
public:
- static QString licensee();
- static QString licensedProducts();
+#if QT_DEPRECATED_SINCE(5, 8)
+ static QT_DEPRECATED QString licensee();
+ static QT_DEPRECATED QString licensedProducts();
+#endif
#ifndef QT_NO_DATESTRING
#if QT_DEPRECATED_SINCE(5, 5)
@@ -63,6 +66,10 @@ public:
static bool isDebugBuild();
+#ifndef QT_BOOTSTRAPPED
+ static QVersionNumber version() Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+#endif
+
enum LibraryLocation
{
PrefixPath = 0,
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 5842b26ecb..6c7cd9c5c6 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -140,6 +140,8 @@ static QT_PREPEND_NAMESPACE(qint64) qt_gettid()
#endif
#endif // !QT_BOOTSTRAPPED
+#include <cstdlib>
+
#include <stdio.h>
QT_BEGIN_NAMESPACE
@@ -170,7 +172,7 @@ static bool isFatal(QtMsgType msgType)
static bool willLogToConsole()
{
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
// these systems have no stderr, so always log to the system log
return false;
#elif defined(QT_BOOTSTRAPPED)
@@ -1176,7 +1178,7 @@ void QMessagePattern::setPattern(const QString &pattern)
else if (inIf)
error += QLatin1String("QT_MESSAGE_PATTERN: missing %{endif}\n");
if (!error.isEmpty()) {
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
OutputDebugString(reinterpret_cast<const wchar_t*>(error.utf16()));
if (0)
#elif defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
@@ -1677,11 +1679,7 @@ static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const
Q_UNUSED(message);
#endif
-#if (defined(Q_OS_UNIX) || defined(Q_CC_MINGW))
- abort(); // trap; generates core dump
-#else
- exit(1); // goodbye cruel world
-#endif
+ std::abort();
}
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 2a0b8461cd..edb568a2d6 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -301,12 +301,7 @@ public:
MacWindowToolBarButtonHint = 0x10000000,
BypassGraphicsProxyWidget = 0x20000000,
NoDropShadowWindowHint = 0x40000000,
- WindowFullscreenButtonHint = 0x80000000,
-
- // The following enums have overlapping values with other enums.
- // This was not intentional, but it's too late to change now.
- WindowOkButtonHint = 0x00080000, // WindowTransparentForInput
- WindowCancelButtonHint = 0x00100000 // WindowOverridesSystemGestures
+ WindowFullscreenButtonHint = 0x80000000
};
Q_DECLARE_FLAGS(WindowFlags, WindowType)
@@ -509,6 +504,7 @@ public:
AA_DontUseNativeDialogs = 23,
AA_SynthesizeMouseForUnhandledTabletEvents = 24,
AA_CompressHighFrequencyEvents = 25,
+ AA_DontCheckOpenGLContextThreadAffinity = 26,
// Add new attributes before this line
AA_AttributeCount
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 86c38839d2..d8df25dcc6 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -250,6 +250,13 @@
If your application needs to handle all events with no compression,
you can unset this attribute. This value has been added in Qt 5.7.
+ \value AA_DontCheckOpenGLContextThreadAffinity When making a context
+ current using QOpenGLContext, do not check that the
+ \l{QObject#Thread Affinity}{QObject thread affinity}
+ of the QOpenGLContext object is the same thread calling
+ \l{QOpenGLContext::makeCurrent}{makeCurrent()}. This value has been
+ added in Qt 5.8.
+
The following values are obsolete:
\value AA_ImmediateWidgetCreation This attribute is no longer fully
@@ -753,27 +760,25 @@
\value MonoOnly The pixmap becomes monochrome. If necessary,
it is dithered using the chosen dithering algorithm.
- Dithering mode preference for RGB channels:
+ Dithering mode preference:
- \value DiffuseDither (default) - A high-quality dither.
- \value OrderedDither A faster, more ordered dither.
+ \value DiffuseDither (default) - A high-quality dither using error diffusion.
+ \value OrderedDither A faster, ordered dither.
\value ThresholdDither No dithering; closest color is used.
- Dithering mode preference for alpha channel:
+ Dithering mode preference for 1-bit alpha masks:
\value ThresholdAlphaDither (default) - No dithering.
- \value OrderedAlphaDither A faster, more ordered dither.
- \value DiffuseAlphaDither A high-quality dither.
+ \value OrderedAlphaDither A faster, ordered dither.
+ \value DiffuseAlphaDither A high-quality dither using error diffusion.
\omitvalue NoAlpha
Color matching versus dithering preference:
- \value PreferDither (default when converting to a pixmap) - Always dither
- 32-bit images when the image is converted to 8 bits.
- \value AvoidDither (default when converting for the purpose of saving to
- file) - Dither 32-bit images only if the image has more than 256
- colors and it is being converted to 8 bits.
- \omitvalue AutoDither
+ \value PreferDither Always dither images when converting to smaller color-spaces.
+ \value AvoidDither Only dither to indexed formats if the source image uses more
+ different colors than the size of the color table of the destination format.
+ \value AutoDither (default) - Only dither when down-converting to 1 or 8-bit indexed formats.
\omitvalue ColorMode_Mask
\omitvalue Dither_Mask
@@ -2218,10 +2223,6 @@
the bottom. This window hint is currently not implemented
for \macos.
- \omitvalue WindowOkButtonHint
-
- \omitvalue WindowCancelButtonHint
-
\value WindowTransparentForInput Informs the window system that this window
is used only for output (displaying something) and does not take input.
Therefore input events should pass through as if it wasn't there.
diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h
index 3451b2158d..ef40a45dc4 100644
--- a/src/corelib/global/qnumeric_p.h
+++ b/src/corelib/global/qnumeric_p.h
@@ -52,11 +52,11 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include "QtCore/private/qglobal_p.h"
#include <cmath>
#include <limits>
-#if defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)
+#if defined(Q_CC_MSVC)
# include <intrin.h>
#elif defined(Q_CC_INTEL)
# include <immintrin.h> // for _addcarry_u<nn>
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index 6ecd41bc30..566d76d3d2 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -334,7 +334,7 @@
# elif defined(__BIG_ENDIAN__) || defined(_big_endian__) || defined(_BIG_ENDIAN)
# define Q_BYTE_ORDER Q_BIG_ENDIAN
# elif defined(__LITTLE_ENDIAN__) || defined(_little_endian__) || defined(_LITTLE_ENDIAN) \
- || defined(_WIN32_WCE) || defined(WINAPI_FAMILY) // Windows CE is always little-endian according to MSDN.
+ || defined(WINAPI_FAMILY) // WinRT is always little-endian according to MSDN.
# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
# else
# error "Unable to determine byte order!"
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index d1a4102f29..23f412aa6a 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -69,7 +69,7 @@ public:
LittleEndian
# ifdef Q_QDOC
- , ByteOrder = <platform-dependent>
+ , ByteOrder = BigEndian or LittleEndian
# elif Q_BYTE_ORDER == Q_BIG_ENDIAN
, ByteOrder = BigEndian
# elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN
@@ -127,6 +127,8 @@ public:
#define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0))
#define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor)
+#define Q_MV_TVOS(major, minor) (QSysInfo::MV_TVOS | major << 4 | minor)
+#define Q_MV_WATCHOS(major, minor) (QSysInfo::MV_WATCHOS | major << 4 | minor)
enum MacVersion {
MV_None = 0xffff,
MV_Unknown = 0x0000,
@@ -180,7 +182,21 @@ public:
MV_IOS_9_1 = Q_MV_IOS(9, 1),
MV_IOS_9_2 = Q_MV_IOS(9, 2),
MV_IOS_9_3 = Q_MV_IOS(9, 3),
- MV_IOS_10_0 = Q_MV_IOS(10, 0)
+ MV_IOS_10_0 = Q_MV_IOS(10, 0),
+
+ /* tvOS */
+ MV_TVOS = 1 << 9,
+ MV_TVOS_9_0 = Q_MV_TVOS(9, 0),
+ MV_TVOS_9_1 = Q_MV_TVOS(9, 1),
+ MV_TVOS_9_2 = Q_MV_TVOS(9, 2),
+ MV_TVOS_10_0 = Q_MV_TVOS(10, 0),
+
+ /* watchOS */
+ MV_WATCHOS = 1 << 10,
+ MV_WATCHOS_2_0 = Q_MV_WATCHOS(2, 0),
+ MV_WATCHOS_2_1 = Q_MV_WATCHOS(2, 1),
+ MV_WATCHOS_2_2 = Q_MV_WATCHOS(2, 2),
+ MV_WATCHOS_3_0 = Q_MV_WATCHOS(3, 0)
};
#if defined(Q_OS_MAC)
static const MacVersion MacintoshVersion;
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index 1e852ae538..3b486b8f6f 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -47,7 +47,7 @@
/*
The operating system, must be one of: (Q_OS_x)
- DARWIN - Any Darwin system (OS X, iOS, watchOS, tvOS)
+ DARWIN - Any Darwin system (macOS, iOS, watchOS, tvOS)
MACOS - macOS
IOS - iOS
WATCHOS - watchOS
@@ -56,7 +56,6 @@
OS2 - OS/2
OS2EMX - XFree86 on OS/2 (not PM)
WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
- WINCE - WinCE (Windows CE 5.0)
WINRT - WinRT (Windows 8 Runtime)
CYGWIN - Cygwin
SOLARIS - Sun Solaris
@@ -103,18 +102,19 @@
# define Q_OS_DARWIN32
# endif
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
-# if defined(TARGET_OS_TV) && TARGET_OS_TV
-# define Q_OS_TVOS
-# elif defined(TARGET_OS_WATCH) && TARGET_OS_WATCH
+# define QT_PLATFORM_UIKIT
+# if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH
# define Q_OS_WATCHOS
+# elif defined(TARGET_OS_TV) && TARGET_OS_TV
+# define Q_OS_TVOS
# else
# // TARGET_OS_IOS is only available in newer SDKs,
# // so assume any other iOS-based platform is iOS for now
# define Q_OS_IOS
# endif
# else
-# // there is no "real" OS X define (rdar://22640089),
-# // assume any non iOS-based platform is OS X for now
+# // TARGET_OS_OSX is only available in newer SDKs,
+# // so assume any non iOS-based platform is macOS for now
# define Q_OS_MACOS
# endif
# else
@@ -129,9 +129,7 @@
# define Q_OS_WIN32
# define Q_OS_WIN64
#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
-# if defined(WINCE) || defined(_WIN32_WCE)
-# define Q_OS_WINCE
-# elif defined(WINAPI_FAMILY)
+# if defined(WINAPI_FAMILY)
# ifndef WINAPI_FAMILY_PC_APP
# define WINAPI_FAMILY_PC_APP WINAPI_FAMILY_APP
# endif
@@ -209,7 +207,7 @@
# error "Qt has not been ported to this OS - see http://www.qt-project.org/"
#endif
-#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINRT)
# define Q_OS_WIN
#endif
diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h
index 8ac3c2135d..7b95501c08 100644
--- a/src/corelib/global/qt_windows.h
+++ b/src/corelib/global/qt_windows.h
@@ -48,10 +48,10 @@
#if defined(Q_CC_MINGW)
// mingw's windows.h does not set _WIN32_WINNT, resulting breaking compilation
# ifndef WINVER
-# define WINVER 0x501
+# define WINVER 0x600
# endif
# ifndef _WIN32_WINNT
-# define _WIN32_WINNT 0x0501
+# define _WIN32_WINNT 0x600
# endif
#endif
@@ -67,10 +67,6 @@
# define _WIN32_IE 0x0501
#endif
-#ifdef _WIN32_WCE
-#include <ceconfig.h>
-#endif
-
// already defined when compiled with WINVER >= 0x0500
#ifndef SPI_SETMENUANIMATION
#define SPI_SETMENUANIMATION 0x1003
@@ -144,13 +140,4 @@
#define CLEARTYPE_QUALITY 5
#endif
-#ifdef Q_OS_WINCE
-#ifndef LR_DEFAULTSIZE
-#define LR_DEFAULTSIZE 0
-#endif
-#ifndef LR_SHARED
-#define LR_SHARED 0
-#endif
-#endif // Q_OS_WINCE
-
#endif // QT_WINDOWS_H
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index 1cb2909c2a..0414ae966a 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -106,25 +106,21 @@ win32 {
SOURCES += io/qfilesystemiterator_win.cpp
!winrt {
- SOURCES += io/qsettings_win.cpp
- SOURCES += io/qstandardpaths_win.cpp
+ HEADERS += \
+ io/qwindowspipereader_p.h \
+ io/qwindowspipewriter_p.h \
+ io/qwinoverlappedionotifier_p.h
- wince* {
- SOURCES += io/qprocess_wince.cpp \
- io/qstorageinfo_stub.cpp
- } else {
- HEADERS += \
- io/qwinoverlappedionotifier_p.h \
- io/qwindowspipereader_p.h \
- io/qwindowspipewriter_p.h
- SOURCES += \
- io/qprocess_win.cpp \
- io/qwinoverlappedionotifier.cpp \
- io/qwindowspipereader.cpp \
- io/qwindowspipewriter.cpp \
- io/qstorageinfo_win.cpp
- LIBS += -lmpr
- }
+ SOURCES += \
+ io/qprocess_win.cpp \
+ io/qsettings_win.cpp \
+ io/qstandardpaths_win.cpp \
+ io/qstorageinfo_win.cpp \
+ io/qwindowspipereader.cpp \
+ io/qwindowspipewriter.cpp \
+ io/qwinoverlappedionotifier.cpp
+
+ LIBS += -lmpr
} else {
SOURCES += \
io/qstandardpaths_winrt.cpp \
@@ -139,7 +135,7 @@ win32 {
io/qprocess_unix.cpp \
io/qfilesystemiterator_unix.cpp
- !integrity {
+ !integrity:!uikit {
SOURCES += io/forkfd_qt.cpp
HEADERS += \
../3rdparty/forkfd/forkfd.h
@@ -147,7 +143,6 @@ win32 {
}
!nacl:mac: {
SOURCES += io/qsettings_mac.cpp
- OBJECTIVE_SOURCES += io/qurl_mac.mm
}
mac {
SOURCES += io/qstorageinfo_mac.cpp
@@ -156,7 +151,7 @@ win32 {
OBJECTIVE_SOURCES += io/qfilesystemwatcher_fsevents.mm
HEADERS += io/qfilesystemwatcher_fsevents_p.h
LIBS += -framework DiskArbitration -framework IOKit
- } else:ios {
+ } else {
LIBS += -framework MobileCoreServices
}
} else:android {
@@ -174,7 +169,7 @@ win32 {
io/qstorageinfo_unix.cpp
}
- linux|if(qnx:contains(QT_CONFIG, inotify)) {
+ linux|if(qnx:qtConfig(inotify)) {
SOURCES += io/qfilesystemwatcher_inotify.cpp
HEADERS += io/qfilesystemwatcher_inotify_p.h
}
diff --git a/src/corelib/io/qabstractfileengine_p.h b/src/corelib/io/qabstractfileengine_p.h
index 0293184645..48b3dec324 100644
--- a/src/corelib/io/qabstractfileengine_p.h
+++ b/src/corelib/io/qabstractfileengine_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qfile.h"
#include "QtCore/qdir.h"
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index de1fc18cd0..b4eb98e062 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -556,6 +556,7 @@ void QDataStream::setByteOrder(ByteOrder bo)
\value Qt_5_5 Same as Qt_5_4
\value Qt_5_6 Version 17 (Qt 5.6)
\value Qt_5_7 Same as Qt_5_6
+ \value Qt_5_8 Same as Qt_5_6
\omitvalue Qt_DefaultCompiledVersion
\sa setVersion(), version()
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index e8634fddef..ac58677b77 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -94,10 +94,11 @@ public:
Qt_5_5 = Qt_5_4,
Qt_5_6 = 17,
Qt_5_7 = Qt_5_6,
-#if QT_VERSION >= 0x050800
+ Qt_5_8 = Qt_5_7,
+#if QT_VERSION >= 0x050900
#error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion
#endif
- Qt_DefaultCompiledVersion = Qt_5_7
+ Qt_DefaultCompiledVersion = Qt_5_8
};
enum ByteOrder {
diff --git a/src/corelib/io/qdatastream_p.h b/src/corelib/io/qdatastream_p.h
index 73f57e2d6c..3ca0ae840e 100644
--- a/src/corelib/io/qdatastream_p.h
+++ b/src/corelib/io/qdatastream_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qdatastream.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/io/qdataurl_p.h b/src/corelib/io/qdataurl_p.h
index d2fa247b95..fd5c7df50b 100644
--- a/src/corelib/io/qdataurl_p.h
+++ b/src/corelib/io/qdataurl_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qurl.h"
#include "QtCore/qbytearray.h"
#include "QtCore/qstring.h"
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index 8021f29e16..abc2abeaec 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -438,8 +438,8 @@ inline QDebug operator<<(QDebug debug, const QFlags<T> &flags)
#define QT_FORWARD_DECLARE_CF_TYPE(type) Q_FORWARD_DECLARE_CF_TYPE(type);
#define QT_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type);
-#define QT_FORWARD_DECLARE_CG_TYPE(type) typedef const struct type *type ## Ref;
-#define QT_FORWARD_DECLARE_MUTABLE_CG_TYPE(type) typedef struct type *type ## Ref;
+#define QT_FORWARD_DECLARE_CG_TYPE(type) Q_FORWARD_DECLARE_CG_TYPE(type);
+#define QT_FORWARD_DECLARE_MUTABLE_CG_TYPE(type) Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(type);
QT_END_NAMESPACE
Q_FORWARD_DECLARE_CF_TYPE(CFString);
diff --git a/src/corelib/io/qdebug_p.h b/src/corelib/io/qdebug_p.h
index ead86bbb6d..a1887655d2 100644
--- a/src/corelib/io/qdebug_p.h
+++ b/src/corelib/io/qdebug_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qdebug.h"
#include "QtCore/qmetaobject.h"
#include "QtCore/qflags.h"
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index f8fae711f2..91953ebf26 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -146,9 +146,11 @@ inline QStringList QDirPrivate::splitFilters(const QString &nameFilter, QChar se
{
if (sep.isNull())
sep = getFilterSepChar(nameFilter);
- QStringList ret = nameFilter.split(sep);
- for (int i = 0; i < ret.count(); ++i)
- ret[i] = ret[i].trimmed();
+ const QVector<QStringRef> split = nameFilter.splitRef(sep);
+ QStringList ret;
+ ret.reserve(split.size());
+ for (const auto &e : split)
+ ret.append(e.trimmed().toString());
return ret;
}
@@ -2187,7 +2189,7 @@ QString QDir::cleanPath(const QString &path)
name.replace(dir_separator, QLatin1Char('/'));
bool allowUncPaths = false;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) //allow unc paths
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) //allow unc paths
allowUncPaths = true;
#endif
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index b2f4b6931f..920281cef7 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -55,8 +55,6 @@ QT_BEGIN_NAMESPACE
//Environment variable to allow tooling full control of file selectors
static const char env_override[] = "QT_NO_BUILTIN_SELECTORS";
-static const ushort selectorIndicator = '+';
-
Q_GLOBAL_STATIC(QFileSelectorSharedData, sharedData);
static QBasicMutex sharedDataMutex;
@@ -267,7 +265,7 @@ QUrl QFileSelector::select(const QUrl &filePath) const
return ret;
}
-static QString selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors)
+QString QFileSelectorPrivate::selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors, const QChar &indicator)
{
/* selectionHelper does a depth-first search of possible selected files. Because there is strict
selector ordering in the API, we can stop checking as soon as we find the file in a directory
@@ -276,12 +274,15 @@ static QString selectionHelper(const QString &path, const QString &fileName, con
Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));
for (const QString &s : selectors) {
- QString prospectiveBase = path + QLatin1Char(selectorIndicator) + s + QLatin1Char('/');
+ QString prospectiveBase = path;
+ if (!indicator.isNull())
+ prospectiveBase += indicator;
+ prospectiveBase += s + QLatin1Char('/');
QStringList remainingSelectors = selectors;
remainingSelectors.removeAll(s);
if (!QDir(prospectiveBase).exists())
continue;
- QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors);
+ QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors, indicator);
if (!prospectiveFile.isEmpty())
return prospectiveFile;
}
@@ -369,7 +370,7 @@ QStringList QFileSelectorPrivate::platformSelectors()
#if defined(Q_OS_WIN)
// can't fall back to QSysInfo because we need both "winphone" and "winrt" for the Windows Phone case
ret << QStringLiteral("windows");
- ret << QSysInfo::kernelType(); // "wince" and "winnt"
+ ret << QSysInfo::kernelType(); // "winnt"
# if defined(Q_OS_WINRT)
ret << QStringLiteral("winrt");
# if defined(Q_OS_WINPHONE)
diff --git a/src/corelib/io/qfileselector_p.h b/src/corelib/io/qfileselector_p.h
index f93eb0ccb3..024d0b190d 100644
--- a/src/corelib/io/qfileselector_p.h
+++ b/src/corelib/io/qfileselector_p.h
@@ -70,6 +70,8 @@ public:
static void updateSelectors();
static QStringList platformSelectors();
static void addStatics(const QStringList &); //For loading GUI statics from other Qt modules
+ static QString selectionHelper(const QString &path, const QString &fileName,
+ const QStringList &selectors, const QChar &indicator = QLatin1Char('+'));
QFileSelectorPrivate();
QString select(const QString &filePath) const;
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index fd8f251ccb..6424012a9a 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -91,7 +91,7 @@ QString QFileSystemEngine::slowCanonicalized(const QString &path)
if (separatorPos != -1) {
if (fi.isDir() && !target.endsWith(slash))
target.append(slash);
- target.append(tmpPath.mid(separatorPos));
+ target.append(tmpPath.midRef(separatorPos));
}
tmpPath = QDir::cleanPath(target);
separatorPos = 0;
@@ -227,14 +227,27 @@ static void fillStat64fromStat32(struct stat64 *statBuf64, const struct stat &st
{
statBuf64->st_mode = statBuf32.st_mode;
statBuf64->st_size = statBuf32.st_size;
+#if _POSIX_VERSION >= 200809L
+ statBuf64->st_ctim = statBuf32.st_ctim;
+ statBuf64->st_mtim = statBuf32.st_mtim;
+ statBuf64->st_atim = statBuf32.st_atim;
+#else
statBuf64->st_ctime = statBuf32.st_ctime;
statBuf64->st_mtime = statBuf32.st_mtime;
statBuf64->st_atime = statBuf32.st_atime;
+#endif
statBuf64->st_uid = statBuf32.st_uid;
statBuf64->st_gid = statBuf32.st_gid;
}
#endif
+#if _POSIX_VERSION >= 200809L
+static qint64 timespecToMSecs(const timespec &spec)
+{
+ return (qint64(spec.tv_sec) * 1000) + (spec.tv_nsec / 1000000);
+}
+#endif
+
void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
{
// Permissions
@@ -278,9 +291,17 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
#endif
// Times
- creationTime_ = statBuffer.st_ctime ? statBuffer.st_ctime : statBuffer.st_mtime;
- modificationTime_ = statBuffer.st_mtime;
- accessTime_ = statBuffer.st_atime;
+#if _POSIX_VERSION >= 200809L
+ modificationTime_ = timespecToMSecs(statBuffer.st_mtim);
+ creationTime_ = timespecToMSecs(statBuffer.st_ctim);
+ if (!creationTime_)
+ creationTime_ = modificationTime_;
+ accessTime_ = timespecToMSecs(statBuffer.st_atim);
+#else
+ creationTime_ = qint64(statBuffer.st_ctime ? statBuffer.st_ctime : statBuffer.st_mtime) * 1000;
+ modificationTime_ = qint64(statBuffer.st_mtime) * 1000;
+ accessTime_ = qint64(statBuffer.st_atime) * 1000;
+#endif
userId_ = statBuffer.st_uid;
groupId_ = statBuffer.st_gid;
}
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 75797e58da..6aaaa4c05a 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -61,7 +61,7 @@
#include <CoreServices/CoreServices.h>
#endif
-#ifdef Q_OS_IOS
+#if defined(QT_PLATFORM_UIKIT)
#include <MobileCoreServices/MobileCoreServices.h>
#endif
@@ -182,8 +182,9 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link,
#endif
if (!ret.startsWith(QLatin1Char('/'))) {
- if (link.filePath().startsWith(QLatin1Char('/'))) {
- ret.prepend(link.filePath().left(link.filePath().lastIndexOf(QLatin1Char('/')))
+ const QString linkFilePath = link.filePath();
+ if (linkFilePath.startsWith(QLatin1Char('/'))) {
+ ret.prepend(linkFilePath.leftRef(linkFilePath.lastIndexOf(QLatin1Char('/')))
+ QLatin1Char('/'));
} else {
ret.prepend(QDir::currentPath() + QLatin1Char('/'));
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 85c795fadd..cdb64d08e1 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -52,14 +52,11 @@
#include "qvarlengtharray.h"
#include "qdatetime.h"
#include "qt_windows.h"
+#include "qvector.h"
-#if !defined(Q_OS_WINCE)
-# include <sys/types.h>
-# include <direct.h>
-# include <winioctl.h>
-#else
-# include <types.h>
-#endif
+#include <sys/types.h>
+#include <direct.h>
+#include <winioctl.h>
#include <objbase.h>
#ifndef Q_OS_WINRT
# include <shlobj.h>
@@ -116,8 +113,7 @@ typedef INT_PTR intptr_t;
# define INVALID_FILE_ATTRIBUTES (DWORD (-1))
#endif
-#if !defined(Q_OS_WINCE)
-# if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
+#if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
typedef struct _REPARSE_DATA_BUFFER {
ULONG ReparseTag;
USHORT ReparseDataLength;
@@ -143,32 +139,31 @@ typedef struct _REPARSE_DATA_BUFFER {
} GenericReparseBuffer;
};
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
-# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
-# endif // !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
+# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
+#endif // !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
-# ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE
-# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384
-# endif
-# ifndef IO_REPARSE_TAG_SYMLINK
-# define IO_REPARSE_TAG_SYMLINK (0xA000000CL)
-# endif
-# ifndef FSCTL_GET_REPARSE_POINT
-# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
-# endif
-#endif // !defined(Q_OS_WINCE)
+#ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE
+# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384
+#endif
+#ifndef IO_REPARSE_TAG_SYMLINK
+# define IO_REPARSE_TAG_SYMLINK (0xA000000CL)
+#endif
+#ifndef FSCTL_GET_REPARSE_POINT
+# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#endif
QT_BEGIN_NAMESPACE
Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0;
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
static QString qfsPrivateCurrentDir = QLatin1String("");
-// As none of the functions we try to resolve do exist on Windows CE
+// As none of the functions we try to resolve do exist on WinRT
// we use QT_NO_LIBRARY to shorten everything up a little bit.
-#ifndef QT_NO_LIBRARY
-#define QT_NO_LIBRARY 1
-#endif
-#endif
+# ifndef QT_NO_LIBRARY
+# define QT_NO_LIBRARY 1
+# endif
+#endif // Q_OS_WINRT
#if !defined(QT_NO_LIBRARY)
QT_BEGIN_INCLUDE_NAMESPACE
@@ -182,8 +177,6 @@ typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACC
static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0;
typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD);
static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0;
-typedef BOOL (WINAPI *PtrGetVolumePathNamesForVolumeNameW)(LPCWSTR,LPWSTR,DWORD,PDWORD);
-static PtrGetVolumePathNamesForVolumeNameW ptrGetVolumePathNamesForVolumeNameW = 0;
QT_END_INCLUDE_NAMESPACE
static TRUSTEE_W currentUserTrusteeW;
@@ -233,7 +226,6 @@ static void resolveLibs()
#endif
triedResolve = true;
-#if !defined(Q_OS_WINCE)
HINSTANCE advapiHnd = QSystemLibrary::load(L"advapi32");
if (advapiHnd) {
ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW");
@@ -279,10 +271,6 @@ static void resolveLibs()
HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv");
if (userenvHnd)
ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW");
- HINSTANCE kernel32 = LoadLibrary(L"kernel32");
- if(kernel32)
- ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)GetProcAddress(kernel32, "GetVolumePathNamesForVolumeNameW");
-#endif
}
}
#endif // QT_NO_LIBRARY
@@ -309,14 +297,14 @@ static bool resolveUNCLibs()
}
#endif
triedResolve = true;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
HINSTANCE hLib = QSystemLibrary::load(L"Netapi32");
if (hLib) {
ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum");
if (ptrNetShareEnum)
ptrNetApiBufferFree = (PtrNetApiBufferFree)GetProcAddress(hLib, "NetApiBufferFree");
}
-#endif // !Q_OS_WINCE && !Q_OS_WINRT
+#endif // !Q_OS_WINRT
}
return ptrNetShareEnum && ptrNetApiBufferFree;
}
@@ -324,7 +312,7 @@ static bool resolveUNCLibs()
static QString readSymLink(const QFileSystemEntry &link)
{
QString result;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
HANDLE handle = CreateFile((wchar_t*)link.nativeFilePath().utf16(),
FILE_READ_EA,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
@@ -357,27 +345,24 @@ static QString readSymLink(const QFileSystemEntry &link)
#if !defined(QT_NO_LIBRARY)
resolveLibs();
- if (ptrGetVolumePathNamesForVolumeNameW) {
- QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
- if(matchVolName.indexIn(result) == 0) {
- DWORD len;
- wchar_t buffer[MAX_PATH];
- QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\"));
- if(ptrGetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0)
- result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
- }
+ QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
+ if (matchVolName.indexIn(result) == 0) {
+ DWORD len;
+ wchar_t buffer[MAX_PATH];
+ const QString volumeName = QLatin1String("\\\\?\\") + result.leftRef(matchVolName.matchedLength());
+ if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()), buffer, MAX_PATH, &len) != 0)
+ result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
}
-#endif // !Q_OS_WINCE && !Q_OS_WINRT
+#endif // !Q_OS_WINRT
}
#else
Q_UNUSED(link);
-#endif // Q_OS_WINCE || Q_OS_WINRT
+#endif // Q_OS_WINRT
return result;
}
static QString readLink(const QFileSystemEntry &link)
{
-#if !defined(Q_OS_WINCE)
#if !defined(QT_NO_LIBRARY)
QString ret;
@@ -418,31 +403,16 @@ static QString readLink(const QFileSystemEntry &link)
Q_UNUSED(link);
return QString();
#endif // QT_NO_LIBRARY
-#elif !defined(QT_NO_WINCE_SHELLSDK)
- wchar_t target[MAX_PATH];
- QString result;
- if (SHGetShortcutTarget((wchar_t*)QFileInfo(link.filePath()).absoluteFilePath().replace(QLatin1Char('/'),QLatin1Char('\\')).utf16(), target, MAX_PATH)) {
- result = QString::fromWCharArray(target);
- if (result.startsWith(QLatin1Char('"')))
- result.remove(0,1);
- if (result.endsWith(QLatin1Char('"')))
- result.remove(result.size()-1,1);
- }
- return result;
-#else // QT_NO_WINCE_SHELLSDK
- Q_UNUSED(link);
- return QString();
-#endif // Q_OS_WINCE
}
static bool uncShareExists(const QString &server)
{
// This code assumes the UNC path is always like \\?\UNC\server...
- QStringList parts = server.split(QLatin1Char('\\'), QString::SkipEmptyParts);
+ const QVector<QStringRef> parts = server.splitRef(QLatin1Char('\\'), QString::SkipEmptyParts);
if (parts.count() >= 3) {
QStringList shares;
if (QFileSystemEngine::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(2), &shares))
- return parts.count() >= 4 ? shares.contains(parts.at(3), Qt::CaseInsensitive) : true;
+ return parts.count() < 4 || shares.contains(parts.at(3).toString(), Qt::CaseInsensitive);
}
return false;
}
@@ -533,7 +503,7 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
{
// can be //server or //server/share
QString absPath;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
+#if !defined(Q_OS_WINRT_WIN81)
QVarLengthArray<wchar_t, MAX_PATH> buf(qMax(MAX_PATH, path.size() + 1));
wchar_t *fileName = 0;
DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName);
@@ -553,17 +523,12 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
if (absPath.size() < rootPath.size() && rootPath.startsWith(absPath))
absPath = rootPath;
# endif // Q_OS_WINRT
-#elif !defined(Q_OS_WINCE)
+#else // !Q_OS_WINRT_WIN81
if (QDir::isRelativePath(path))
absPath = QDir::toNativeSeparators(QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + path));
else
absPath = QDir::toNativeSeparators(QDir::cleanPath(path));
-#else // Q_OS_WINRT
- if (path.startsWith(QLatin1Char('/')) || path.startsWith(QLatin1Char('\\')))
- absPath = QDir::toNativeSeparators(path);
- else
- absPath = QDir::toNativeSeparators(QDir::cleanPath(qfsPrivateCurrentDir + QLatin1Char('/') + path));
-#endif // Q_OS_WINCE
+#endif // Q_OS_WINRT_WIN81
// This is really ugly, but GetFullPathName strips off whitespace at the end.
// If you for instance write ". " in the lineedit of QFileDialog,
// (which is an invalid filename) this function will strip the space off and viola,
@@ -580,15 +545,10 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
QString ret;
if (!entry.isRelative()) {
-#if !defined(Q_OS_WINCE)
- if (entry.isAbsolute() && entry.isClean()) {
+ if (entry.isAbsolute() && entry.isClean())
ret = entry.filePath();
- } else {
+ else
ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath()));
- }
-#else
- ret = entry.filePath();
-#endif
} else {
#ifndef Q_OS_WINRT_WIN81
ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath());
@@ -617,25 +577,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
}
-#ifndef Q_OS_WINCE
-
-// FILE_INFO_BY_HANDLE_CLASS has been extended by FileIdInfo = 18 as of VS2012.
-typedef enum { Q_FileIdInfo = 18 } Q_FILE_INFO_BY_HANDLE_CLASS;
-
-# if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
-
-// MinGW-64 defines FILE_ID_128 as of gcc-4.8.1 along with FILE_SUPPORTS_INTEGRITY_STREAMS
-# if !(defined(Q_CC_MINGW) && defined(FILE_SUPPORTS_INTEGRITY_STREAMS))
-typedef struct _FILE_ID_128 {
- BYTE Identifier[16];
-} FILE_ID_128, *PFILE_ID_128;
-# endif // !(Q_CC_MINGW && FILE_SUPPORTS_INTEGRITY_STREAMS)
+#if defined(Q_CC_MINGW) && WINVER < 0x0602 // Windows 8 onwards
typedef struct _FILE_ID_INFO {
ULONGLONG VolumeSerialNumber;
FILE_ID_128 FileId;
} FILE_ID_INFO, *PFILE_ID_INFO;
-# endif // if defined (Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
+
+#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
// File ID for Windows up to version 7.
static inline QByteArray fileId(HANDLE handle)
@@ -658,44 +607,26 @@ static inline QByteArray fileId(HANDLE handle)
// File ID for Windows starting from version 8.
QByteArray fileIdWin8(HANDLE handle)
{
-#ifndef Q_OS_WINRT
- typedef BOOL (WINAPI* GetFileInformationByHandleExType)(HANDLE, Q_FILE_INFO_BY_HANDLE_CLASS, void *, DWORD);
-
- // Dynamically resolve GetFileInformationByHandleEx (Vista onwards).
- static GetFileInformationByHandleExType getFileInformationByHandleEx = 0;
- if (!getFileInformationByHandleEx) {
- QSystemLibrary library(QLatin1String("kernel32"));
- getFileInformationByHandleEx = (GetFileInformationByHandleExType)library.resolve("GetFileInformationByHandleEx");
- }
- QByteArray result;
- if (getFileInformationByHandleEx) {
- FILE_ID_INFO infoEx;
- if (getFileInformationByHandleEx(handle, Q_FileIdInfo,
- &infoEx, sizeof(FILE_ID_INFO))) {
- result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
- result += ':';
- // Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
- result += QByteArray((char *)&infoEx.FileId, sizeof(infoEx.FileId)).toHex();
- }
- }
-#else // !Q_OS_WINRT
+#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)
QByteArray result;
FILE_ID_INFO infoEx;
- if (GetFileInformationByHandleEx(handle, FileIdInfo,
+ if (GetFileInformationByHandleEx(handle,
+ static_cast<FILE_INFO_BY_HANDLE_CLASS>(18), // FileIdInfo in Windows 8
&infoEx, sizeof(FILE_ID_INFO))) {
result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
result += ':';
- result += QByteArray((char *)infoEx.FileId.Identifier, sizeof(infoEx.FileId.Identifier)).toHex();
+ // Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
+ result += QByteArray(reinterpret_cast<const char *>(&infoEx.FileId), int(sizeof(infoEx.FileId))).toHex();
}
-#endif // Q_OS_WINRT
return result;
+#else // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
+ return fileId(handle);
+#endif
}
-#endif // !Q_OS_WINCE
//static
QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
{
-#ifndef Q_OS_WINCE
QByteArray result;
const HANDLE handle =
#ifndef Q_OS_WINRT
@@ -711,9 +642,6 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
CloseHandle(handle);
}
return result;
-#else // !Q_OS_WINCE
- return entry.nativeFilePath().toLower().toLatin1();
-#endif
}
//static
@@ -882,7 +810,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa
{
bool entryExists = false;
DWORD fileAttrib = 0;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
if (fname.isDriveRoot()) {
// a valid drive ??
const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
@@ -925,7 +853,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa
fileAttrib = FILE_ATTRIBUTE_DIRECTORY;
entryExists = true;
}
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
}
#endif
if (entryExists)
@@ -949,7 +877,6 @@ static bool tryFindFallback(const QFileSystemEntry &fname, QFileSystemMetaData &
return filledData;
}
-#if !defined(Q_OS_WINCE)
//static
bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data,
QFileSystemMetaData::MetaDataFlags what)
@@ -960,7 +887,6 @@ bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data,
}
return false;
}
-#endif
//static
bool QFileSystemEngine::fillMetaData(HANDLE fHandle, QFileSystemMetaData &data,
@@ -1069,25 +995,6 @@ static inline bool mkDir(const QString &path, DWORD *lastError = 0)
{
if (lastError)
*lastError = 0;
-#if defined(Q_OS_WINCE)
- // Unfortunately CreateDirectory returns true for paths longer than
- // 256, but does not create a directory. It starts to fail, when
- // path length > MAX_PATH, which is 260 usually on CE.
- // This only happens on a Windows Mobile device. Windows CE seems
- // not to be affected by this.
- static int platformId = 0;
- if (platformId == 0) {
- wchar_t platformString[64];
- if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformString)/sizeof(*platformString),platformString,0)) {
- if (0 == wcscmp(platformString, L"PocketPC") || 0 == wcscmp(platformString, L"Smartphone"))
- platformId = 1;
- else
- platformId = 2;
- }
- }
- if (platformId == 1 && QFSFileEnginePrivate::longFileName(path).size() > 256)
- return false;
-#endif
const QString longPath = QFSFileEnginePrivate::longFileName(path);
const bool result = ::CreateDirectory((wchar_t*)longPath.utf16(), 0);
if (lastError) // Capture lastError before any QString is freed since custom allocators might change it.
@@ -1200,9 +1107,10 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo
if (removeEmptyParents) {
dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName));
for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) {
- QString chunk = dirName.left(slash);
- if (chunk.length() == 2 && chunk.at(0).isLetter() && chunk.at(1) == QLatin1Char(':'))
+ const QStringRef chunkRef = dirName.leftRef(slash);
+ if (chunkRef.length() == 2 && chunkRef.at(0).isLetter() && chunkRef.at(1) == QLatin1Char(':'))
break;
+ const QString chunk = chunkRef.toString();
if (!isDirPath(chunk, 0))
return false;
if (!rmDir(chunk))
@@ -1217,9 +1125,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo
//static
QString QFileSystemEngine::rootPath()
{
-#if defined(Q_OS_WINCE)
- QString ret = QLatin1String("/");
-#elif defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
// We specify the package root as root directory
QString ret = QLatin1String("/");
// Get package location
@@ -1285,13 +1191,8 @@ QString QFileSystemEngine::homePath()
+ QString::fromLocal8Bit(qgetenv("HOMEPATH"));
if (ret.isEmpty() || !QFile::exists(ret)) {
ret = QString::fromLocal8Bit(qgetenv("HOME"));
- if (ret.isEmpty() || !QFile::exists(ret)) {
-#if defined(Q_OS_WINCE)
- ret = QLatin1String("\\My Documents");
- if (!QFile::exists(ret))
-#endif
- ret = rootPath();
- }
+ if (ret.isEmpty() || !QFile::exists(ret))
+ ret = rootPath();
}
}
}
@@ -1304,10 +1205,6 @@ QString QFileSystemEngine::tempPath()
#ifndef Q_OS_WINRT
wchar_t tempPath[MAX_PATH];
const DWORD len = GetTempPath(MAX_PATH, tempPath);
-#ifdef Q_OS_WINCE
- if (len)
- ret = QString::fromWCharArray(tempPath, len);
-#else // Q_OS_WINCE
if (len) { // GetTempPath() can return short names, expand.
wchar_t longTempPath[MAX_PATH];
const DWORD longLen = GetLongPathName(tempPath, longTempPath, MAX_PATH);
@@ -1315,7 +1212,6 @@ QString QFileSystemEngine::tempPath()
QString::fromWCharArray(longTempPath, longLen) :
QString::fromWCharArray(tempPath, len);
}
-#endif // !Q_OS_WINCE
if (!ret.isEmpty()) {
while (ret.endsWith(QLatin1Char('\\')))
ret.chop(1);
@@ -1343,11 +1239,7 @@ QString QFileSystemEngine::tempPath()
ret = QDir::fromNativeSeparators(QString::fromWCharArray(path.GetRawBuffer(nullptr)));
#endif // Q_OS_WINRT
if (ret.isEmpty()) {
-#if !defined(Q_OS_WINCE)
ret = QLatin1String("C:/tmp");
-#else
- ret = QLatin1String("/Temp");
-#endif
} else if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
return ret;
@@ -1360,7 +1252,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
if(!(meta.exists() && meta.isDirectory()))
return false;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
+#if !defined(Q_OS_WINRT_WIN81)
//TODO: this should really be using nativeFilePath(), but that returns a path in long format \\?\c:\foo
//which causes many problems later on when it's returned through currentPath()
return ::SetCurrentDirectory(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(entry.filePath()).utf16())) != 0;
@@ -1373,7 +1265,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
QFileSystemEntry QFileSystemEngine::currentPath()
{
QString ret;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
+#if !defined(Q_OS_WINRT_WIN81)
DWORD size = 0;
wchar_t currentName[PATH_MAX];
size = ::GetCurrentDirectory(PATH_MAX, currentName);
@@ -1389,17 +1281,13 @@ QFileSystemEntry QFileSystemEngine::currentPath()
}
if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
-#else // !Q_OS_WINCE && !Q_OS_WINRT_WIN81
+#else // !Q_OS_WINRT_WIN81
//TODO - a race condition exists when using currentPath / setCurrentPath from multiple threads
if (qfsPrivateCurrentDir.isEmpty())
-#ifndef Q_OS_WINRT_WIN81
- qfsPrivateCurrentDir = QCoreApplication::applicationDirPath();
-#else
qfsPrivateCurrentDir = QDir::rootPath();
-#endif
ret = qfsPrivateCurrentDir;
-#endif // Q_OS_WINCE || Q_OS_WINRT_WIN81
+#endif // Q_OS_WINRT_WIN81
return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath());
}
@@ -1482,31 +1370,11 @@ static inline QDateTime fileTimeToQDateTime(const FILETIME *time)
{
QDateTime ret;
-#if defined(Q_OS_WINCE)
- SYSTEMTIME systime;
- FILETIME ftime;
- systime.wYear = 1970;
- systime.wMonth = 1;
- systime.wDay = 1;
- systime.wHour = 0;
- systime.wMinute = 0;
- systime.wSecond = 0;
- systime.wMilliseconds = 0;
- systime.wDayOfWeek = 4;
- SystemTimeToFileTime(&systime, &ftime);
- unsigned __int64 acttime = (unsigned __int64)time->dwHighDateTime << 32 | time->dwLowDateTime;
- FileTimeToSystemTime(time, &systime);
- unsigned __int64 time1970 = (unsigned __int64)ftime.dwHighDateTime << 32 | ftime.dwLowDateTime;
- unsigned __int64 difftime = acttime - time1970;
- difftime /= 10000000;
- ret.setTime_t((unsigned int)difftime);
-#else
SYSTEMTIME sTime, lTime;
FileTimeToSystemTime(time, &sTime);
SystemTimeToTzSpecificLocalTime(0, &sTime, &lTime);
ret.setDate(QDate(lTime.wYear, lTime.wMonth, lTime.wDay));
ret.setTime(QTime(lTime.wHour, lTime.wMinute, lTime.wSecond, lTime.wMilliseconds));
-#endif
return ret;
}
diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h
index 6bb8fc2400..300a375377 100644
--- a/src/corelib/io/qfilesystementry_p.h
+++ b/src/corelib/io/qfilesystementry_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qstring.h>
#include <QtCore/qbytearray.h>
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp
index ba195b2330..2ce7bd7a4b 100644
--- a/src/corelib/io/qfilesystemiterator_win.cpp
+++ b/src/corelib/io/qfilesystemiterator_win.cpp
@@ -40,6 +40,7 @@
#include "qfilesystemiterator_p.h"
#include "qfilesystemengine_p.h"
#include "qplatformdefs.h"
+#include "qvector.h"
#include <QtCore/qt_windows.h>
@@ -92,12 +93,10 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
haveData = true;
int infoLevel = 0 ; // FindExInfoStandard;
DWORD dwAdditionalFlags = 0;
-#ifndef Q_OS_WINCE
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) {
dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH
infoLevel = 1 ; // FindExInfoBasic;
}
-#endif
int searchOps = 0; // FindExSearchNameMatch
if (onlyDirs)
searchOps = 1 ; // FindExSearchLimitToDirectories
@@ -105,7 +104,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
FINDEX_SEARCH_OPS(searchOps), 0, dwAdditionalFlags);
if (findFileHandle == INVALID_HANDLE_VALUE) {
if (nativePath.startsWith(QLatin1String("\\\\?\\UNC\\"))) {
- QStringList parts = nativePath.split(QLatin1Char('\\'), QString::SkipEmptyParts);
+ const QVector<QStringRef> parts = nativePath.splitRef(QLatin1Char('\\'), QString::SkipEmptyParts);
if (parts.count() == 4 && QFileSystemEngine::uncListSharesOnServer(
QLatin1String("\\\\") + parts.at(2), &uncShares)) {
if (uncShares.isEmpty())
diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h
index 7135c9b19b..091552f86e 100644
--- a/src/corelib/io/qfilesystemmetadata_p.h
+++ b/src/corelib/io/qfilesystemmetadata_p.h
@@ -237,9 +237,10 @@ private:
FILETIME lastAccessTime_;
FILETIME lastWriteTime_;
#else
- time_t creationTime_;
- time_t modificationTime_;
- time_t accessTime_;
+ // msec precision
+ qint64 creationTime_;
+ qint64 modificationTime_;
+ qint64 accessTime_;
uint userId_;
uint groupId_;
@@ -276,9 +277,9 @@ inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime tim
#endif
#if defined(Q_OS_UNIX)
-inline QDateTime QFileSystemMetaData::creationTime() const { return QDateTime::fromTime_t(creationTime_); }
-inline QDateTime QFileSystemMetaData::modificationTime() const { return QDateTime::fromTime_t(modificationTime_); }
-inline QDateTime QFileSystemMetaData::accessTime() const { return QDateTime::fromTime_t(accessTime_); }
+inline QDateTime QFileSystemMetaData::creationTime() const { return QDateTime::fromMSecsSinceEpoch(creationTime_); }
+inline QDateTime QFileSystemMetaData::modificationTime() const { return QDateTime::fromMSecsSinceEpoch(modificationTime_); }
+inline QDateTime QFileSystemMetaData::accessTime() const { return QDateTime::fromMSecsSinceEpoch(accessTime_); }
inline uint QFileSystemMetaData::userId() const { return userId_; }
inline uint QFileSystemMetaData::groupId() const { return groupId_; }
@@ -331,13 +332,10 @@ inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, boo
if (setLinkType) {
knownFlagsMask |= LinkType;
entryFlags &= ~LinkType;
-#if !defined(Q_OS_WINCE)
if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT)
&& (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
entryFlags |= LinkType;
}
-#endif
-
}
}
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index a3915cdf02..a1d90c76f4 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -58,7 +58,7 @@
# include "qfilesystemwatcher_win_p.h"
#elif defined(USE_INOTIFY)
# include "qfilesystemwatcher_inotify_p.h"
-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_IOS)
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(QT_PLATFORM_UIKIT)
# include "qfilesystemwatcher_kqueue_p.h"
#elif defined(Q_OS_OSX)
# include "qfilesystemwatcher_fsevents_p.h"
@@ -74,7 +74,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject
// there is a chance that inotify may fail on Linux pre-2.6.13 (August
// 2005), so we can't just new inotify directly.
return QInotifyFileSystemWatcherEngine::create(parent);
-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_IOS)
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(QT_PLATFORM_UIKIT)
return QKqueueFileSystemWatcherEngine::create(parent);
#elif defined(Q_OS_OSX)
return QFseventsFileSystemWatcherEngine::create(parent);
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm
index be9eef889a..beb8acb05f 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents.mm
+++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm
@@ -198,7 +198,7 @@ void QFseventsFileSystemWatcherEngine::processEvent(ConstFSEventStreamRef stream
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[])
{
-#if defined(Q_OS_OSX) && MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_6
+#if defined(Q_OS_OSX)
Q_UNUSED(streamRef);
bool needsRestart = false;
@@ -256,12 +256,6 @@ void QFseventsFileSystemWatcherEngine::processEvent(ConstFSEventStreamRef stream
if (needsRestart)
emit scheduleStreamRestart();
#else
- // This is a work-around for moc: when we put the version check at the top of the header file,
- // moc will still see the Q_OBJECT macro and generate a meta-object when compiling for 10.6,
- // which obviously won't link.
- //
- // So the trick is to still compile this class on 10.6, but never instantiate it.
-
Q_UNUSED(streamRef);
Q_UNUSED(numEvents);
Q_UNUSED(eventPaths);
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents_p.h b/src/corelib/io/qfilesystemwatcher_fsevents_p.h
index 5281d64d63..dc4e5bf38b 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents_p.h
+++ b/src/corelib/io/qfilesystemwatcher_fsevents_p.h
@@ -44,9 +44,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// 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.
//
diff --git a/src/corelib/io/qfilesystemwatcher_inotify_p.h b/src/corelib/io/qfilesystemwatcher_inotify_p.h
index 57a5abba4f..777d62dc8a 100644
--- a/src/corelib/io/qfilesystemwatcher_inotify_p.h
+++ b/src/corelib/io/qfilesystemwatcher_inotify_p.h
@@ -44,9 +44,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// 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.
//
diff --git a/src/corelib/io/qfilesystemwatcher_kqueue_p.h b/src/corelib/io/qfilesystemwatcher_kqueue_p.h
index 27910a0543..9d4b6d1fe6 100644
--- a/src/corelib/io/qfilesystemwatcher_kqueue_p.h
+++ b/src/corelib/io/qfilesystemwatcher_kqueue_p.h
@@ -44,9 +44,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// 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.
//
diff --git a/src/corelib/io/qfilesystemwatcher_p.h b/src/corelib/io/qfilesystemwatcher_p.h
index 1ceda492ef..6c64411f92 100644
--- a/src/corelib/io/qfilesystemwatcher_p.h
+++ b/src/corelib/io/qfilesystemwatcher_p.h
@@ -44,9 +44,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// 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.
//
diff --git a/src/corelib/io/qfilesystemwatcher_polling_p.h b/src/corelib/io/qfilesystemwatcher_polling_p.h
index 9101f73c16..6dff08ac05 100644
--- a/src/corelib/io/qfilesystemwatcher_polling_p.h
+++ b/src/corelib/io/qfilesystemwatcher_polling_p.h
@@ -44,9 +44,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// 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.
//
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index e8b49db9f3..be56d8dd1d 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -86,13 +86,9 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
QString path = it.next();
QString normalPath = path;
if ((normalPath.endsWith(QLatin1Char('/')) && !normalPath.endsWith(QLatin1String(":/")))
- || (normalPath.endsWith(QLatin1Char('\\')) && !normalPath.endsWith(QLatin1String(":\\")))
-#ifdef Q_OS_WINCE
- && normalPath.size() > 1)
-#else
- )
-#endif
- normalPath.chop(1);
+ || (normalPath.endsWith(QLatin1Char('\\')) && !normalPath.endsWith(QLatin1String(":\\")))) {
+ normalPath.chop(1);
+ }
QFileInfo fileInfo(normalPath);
if (!fileInfo.exists())
continue;
diff --git a/src/corelib/io/qfilesystemwatcher_win_p.h b/src/corelib/io/qfilesystemwatcher_win_p.h
index 83f3831c5c..e8f5c49dec 100644
--- a/src/corelib/io/qfilesystemwatcher_win_p.h
+++ b/src/corelib/io/qfilesystemwatcher_win_p.h
@@ -44,9 +44,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// 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.
//
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index cd24a54fd0..0b9cd0557f 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -48,9 +48,7 @@
#ifndef QT_NO_FSFILEENGINE
-#if !defined(Q_OS_WINCE)
#include <errno.h>
-#endif
#if defined(Q_OS_UNIX)
#include "private/qcore_unix_p.h"
#endif
@@ -125,10 +123,8 @@ void QFSFileEnginePrivate::init()
{
is_sequential = 0;
tried_stat = 0;
-#if !defined(Q_OS_WINCE)
need_lstat = 1;
is_link = 0;
-#endif
openMode = QIODevice::NotOpen;
fd = -1;
fh = 0;
@@ -139,10 +135,8 @@ void QFSFileEnginePrivate::init()
fileAttrib = INVALID_FILE_ATTRIBUTES;
fileHandle = INVALID_HANDLE_VALUE;
mapHandle = NULL;
-#ifndef Q_OS_WINCE
cachedFd = -1;
#endif
-#endif
}
/*!
@@ -551,7 +545,7 @@ bool QFSFileEnginePrivate::seekFdFh(qint64 pos)
} else {
// Unbuffered stdio mode.
if (QT_LSEEK(fd, QT_OFF_T(pos), SEEK_SET) == -1) {
- qWarning() << "QFile::at: Cannot set file position" << pos;
+ qWarning("QFile::at: Cannot set file position %lld", pos);
q->setError(QFile::PositionError, qt_error_string(errno));
return false;
}
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index dd498a5bc5..593ecc2687 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -61,10 +61,6 @@
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_WINCE_STD) && _WIN32_WCE < 0x600
-#define Q_USE_DEPRECATED_MAP_API 1
-#endif
-
class QFSFileEnginePrivate;
class Q_CORE_EXPORT QFSFileEngine : public QAbstractFileEngine
@@ -184,10 +180,7 @@ public:
HANDLE mapHandle;
QHash<uchar *, DWORD /* offset % AllocationGranularity */> maps;
-#ifndef Q_OS_WINCE
mutable int cachedFd;
-#endif
-
mutable DWORD fileAttrib;
#else
QHash<uchar *, QPair<int /*offset % PageSize*/, size_t /*length + offset % PageSize*/> > maps;
@@ -206,10 +199,8 @@ public:
mutable uint is_sequential : 2;
mutable uint tried_stat : 1;
-#if !defined(Q_OS_WINCE)
mutable uint need_lstat : 1;
mutable uint is_link : 1;
-#endif
#if defined(Q_OS_WIN)
bool doStat(QFileSystemMetaData::MetaDataFlags flags) const;
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index af026b8976..5c79a745fa 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -50,13 +50,9 @@
#include "qdatetime.h"
#include "qt_windows.h"
-#if !defined(Q_OS_WINCE)
-# include <sys/types.h>
-# include <direct.h>
-# include <winioctl.h>
-#else
-# include <types.h>
-#endif
+#include <sys/types.h>
+#include <direct.h>
+#include <winioctl.h>
#include <objbase.h>
#ifndef Q_OS_WINRT
# include <shlobj.h>
@@ -77,14 +73,12 @@
QT_BEGIN_NAMESPACE
-#if !defined(Q_OS_WINCE)
static inline bool isUncPath(const QString &path)
{
// Starts with \\, but not \\.
return (path.startsWith(QLatin1String("\\\\"))
&& path.size() > 2 && path.at(2) != QLatin1Char('.'));
}
-#endif
/*!
\internal
@@ -95,7 +89,7 @@ QString QFSFileEnginePrivate::longFileName(const QString &path)
return path;
QString absPath = QFileSystemEngine::nativeAbsoluteFilePath(path);
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
QString prefix = QLatin1String("\\\\?\\");
if (isUncPath(absPath)) {
prefix.append(QLatin1String("UNC\\")); // "\\\\?\\UNC\\"
@@ -171,7 +165,6 @@ bool QFSFileEnginePrivate::nativeClose()
// Windows native mode.
bool ok = true;
-#ifndef Q_OS_WINCE
if (cachedFd != -1) {
if (::_close(cachedFd) && !::CloseHandle(fileHandle)) {
q->setError(QFile::UnspecifiedError, qt_error_string());
@@ -184,7 +177,6 @@ bool QFSFileEnginePrivate::nativeClose()
return ok;
}
-#endif
if ((fileHandle == INVALID_HANDLE_VALUE || !::CloseHandle(fileHandle))) {
q->setError(QFile::UnspecifiedError, qt_error_string());
@@ -238,24 +230,6 @@ qint64 QFSFileEnginePrivate::nativeSize() const
// Always retrive the current information
metaData.clearFlags(QFileSystemMetaData::SizeAttribute);
-#if defined(Q_OS_WINCE)
- // Buffered stdlib mode.
- if (fh) {
- QT_OFF_T oldPos = QT_FTELL(fh);
- QT_FSEEK(fh, 0, SEEK_END);
- qint64 fileSize = (qint64)QT_FTELL(fh);
- QT_FSEEK(fh, oldPos, SEEK_SET);
- if (fileSize == -1) {
- fileSize = 0;
- thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno));
- }
- return fileSize;
- }
- if (fd != -1) {
- thatQ->setError(QFile::UnspecifiedError, QLatin1String("Not implemented!"));
- return 0;
- }
-#endif
bool filled = false;
if (fileHandle != INVALID_HANDLE_VALUE && openMode != QIODevice::NotOpen )
filled = QFileSystemEngine::fillMetaData(fileHandle, metaData,
@@ -287,7 +261,6 @@ qint64 QFSFileEnginePrivate::nativePos() const
if (fileHandle == INVALID_HANDLE_VALUE)
return 0;
-#if !defined(Q_OS_WINCE)
LARGE_INTEGER currentFilePos;
LARGE_INTEGER offset;
offset.QuadPart = 0;
@@ -297,18 +270,6 @@ qint64 QFSFileEnginePrivate::nativePos() const
}
return qint64(currentFilePos.QuadPart);
-#else
- LARGE_INTEGER filepos;
- filepos.HighPart = 0;
- DWORD newFilePointer = SetFilePointer(fileHandle, 0, &filepos.HighPart, FILE_CURRENT);
- if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) {
- thatQ->setError(QFile::UnspecifiedError, qt_error_string());
- return 0;
- }
-
- filepos.LowPart = newFilePointer;
- return filepos.QuadPart;
-#endif
}
/*
@@ -323,7 +284,6 @@ bool QFSFileEnginePrivate::nativeSeek(qint64 pos)
return seekFdFh(pos);
}
-#if !defined(Q_OS_WINCE)
LARGE_INTEGER currentFilePos;
LARGE_INTEGER offset;
offset.QuadPart = pos;
@@ -333,17 +293,6 @@ bool QFSFileEnginePrivate::nativeSeek(qint64 pos)
}
return true;
-#else
- DWORD newFilePointer;
- LARGE_INTEGER *li = reinterpret_cast<LARGE_INTEGER*>(&pos);
- newFilePointer = SetFilePointer(fileHandle, li->LowPart, &li->HighPart, FILE_BEGIN);
- if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) {
- q->setError(QFile::PositionError, qt_error_string());
- return false;
- }
-
- return true;
-#endif
}
/*
@@ -460,7 +409,6 @@ int QFSFileEnginePrivate::nativeHandle() const
{
if (fh || fd != -1)
return fh ? QT_FILENO(fh) : fd;
-#ifndef Q_OS_WINCE
if (cachedFd != -1)
return cachedFd;
@@ -471,9 +419,6 @@ int QFSFileEnginePrivate::nativeHandle() const
flags |= _O_RDONLY;
cachedFd = _open_osfhandle((intptr_t) fileHandle, flags);
return cachedFd;
-#else
- return -1;
-#endif
}
/*
@@ -481,7 +426,7 @@ int QFSFileEnginePrivate::nativeHandle() const
*/
bool QFSFileEnginePrivate::nativeIsSequential() const
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
HANDLE handle = fileHandle;
if (fh || fd != -1)
handle = (HANDLE)_get_osfhandle(fh ? QT_FILENO(fh) : fd);
@@ -529,35 +474,9 @@ bool QFSFileEngine::rename(const QString &newName)
bool QFSFileEngine::renameOverwrite(const QString &newName)
{
Q_D(QFSFileEngine);
-#if defined(Q_OS_WINCE)
- // Windows Embedded Compact 7 does not have MoveFileEx, simulate it with the following sequence:
- // 1. DeleteAndRenameFile (Should work on RAM FS when both files exist)
- // 2. DeleteFile/MoveFile (Should work on all file systems)
- //
- // DeleteFile/MoveFile fallback implementation violates atomicity, but it is more acceptable than
- // alternative CopyFile/DeleteFile sequence for the following reasons:
- //
- // 1. DeleteFile/MoveFile is way faster than CopyFile/DeleteFile and thus more atomic.
- // 2. Given the intended use case of this function in QSaveFile, DeleteFile/MoveFile sequence will
- // delete the old content, but leave a file "filename.ext.XXXXXX" in the same directory if MoveFile fails.
- // With CopyFile/DeleteFile sequence, it can happen that new data is partially copied to target file
- // (because CopyFile is not atomic either), thus leaving *some* content to target file.
- // This makes the need for application level recovery harder to detect than in DeleteFile/MoveFile
- // sequence where target file simply does not exist.
- //
- bool ret = ::DeleteAndRenameFile((wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16(),
- (wchar_t*)d->fileEntry.nativeFilePath().utf16()) != 0;
- if (!ret) {
- ret = ::DeleteFile((wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0;
- if (ret || ::GetLastError() == ERROR_FILE_NOT_FOUND)
- ret = ::MoveFile((wchar_t*)d->fileEntry.nativeFilePath().utf16(),
- (wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0;
- }
-#else
bool ret = ::MoveFileEx((wchar_t*)d->fileEntry.nativeFilePath().utf16(),
(wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16(),
MOVEFILE_REPLACE_EXISTING) != 0;
-#endif
if (!ret)
setError(QFile::RenameError, QSystemError(::GetLastError(), QSystemError::NativeError).toString());
return ret;
@@ -585,7 +504,7 @@ bool QFSFileEngine::setCurrentPath(const QString &path)
QString QFSFileEngine::currentPath(const QString &fileName)
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
QString ret;
//if filename is a drive: then get the pwd of that drive
if (fileName.length() >= 2 &&
@@ -604,10 +523,10 @@ QString QFSFileEngine::currentPath(const QString &fileName)
if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
return ret;
-#else // !Q_OS_WINCE && !Q_OS_WINRT
+#else // !Q_OS_WINRT
Q_UNUSED(fileName);
return QFileSystemEngine::currentPath().filePath();
-#endif // Q_OS_WINCE || Q_OS_WINRT
+#endif // Q_OS_WINRT
}
QString QFSFileEngine::homePath()
@@ -628,12 +547,12 @@ QString QFSFileEngine::tempPath()
QFileInfoList QFSFileEngine::drives()
{
QFileInfoList ret;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
-#if defined(Q_OS_WIN32)
+#if !defined(Q_OS_WINRT)
+# if defined(Q_OS_WIN32)
const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
quint32 driveBits = (quint32) GetLogicalDrives() & 0x3ffffff;
::SetErrorMode(oldErrorMode);
-#endif
+# endif
char driveName[] = "A:/";
while (driveBits) {
@@ -643,10 +562,10 @@ QFileInfoList QFSFileEngine::drives()
driveBits = driveBits >> 1;
}
return ret;
-#else // !Q_OS_WINCE && !Q_OS_WINRT
+#else // !Q_OS_WINRT
ret.append(QFileInfo(QLatin1String("/")));
return ret;
-#endif // Q_OS_WINCE || Q_OS_WINRT
+#endif // Q_OS_WINRT
}
bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) const
@@ -654,13 +573,11 @@ bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) cons
if (!tried_stat || !metaData.hasFlags(flags)) {
tried_stat = true;
-#if !defined(Q_OS_WINCE)
int localFd = fd;
if (fh && fileEntry.isEmpty())
localFd = QT_FILENO(fh);
if (localFd != -1)
QFileSystemEngine::fillMetaData(localFd, metaData, flags);
-#endif
if (metaData.missingFlags(flags) && !fileEntry.isEmpty())
QFileSystemEngine::fillMetaData(fileEntry, metaData, metaData.missingFlags(flags));
}
@@ -671,8 +588,8 @@ bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) cons
bool QFSFileEngine::link(const QString &newName)
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
-#if !defined(QT_NO_LIBRARY)
+#if !defined(Q_OS_WINRT)
+# if !defined(QT_NO_LIBRARY)
bool ret = false;
QString linkName = newName;
@@ -713,24 +630,11 @@ bool QFSFileEngine::link(const QString &newName)
CoUninitialize();
return ret;
-#else
+# else // QT_NO_LIBRARY
Q_UNUSED(newName);
return false;
-#endif // QT_NO_LIBRARY
-#elif defined(Q_OS_WINCE) && !defined(QT_NO_WINCE_SHELLSDK)
- QString linkName = newName;
- linkName.replace(QLatin1Char('/'), QLatin1Char('\\'));
- if (!linkName.endsWith(QLatin1String(".lnk")))
- linkName += QLatin1String(".lnk");
- QString orgName = fileName(AbsoluteName).replace(QLatin1Char('/'), QLatin1Char('\\'));
- // Need to append on our own
- orgName.prepend(QLatin1Char('"'));
- orgName.append(QLatin1Char('"'));
- bool ret = SUCCEEDED(SHCreateShortcut((wchar_t*)linkName.utf16(), (wchar_t*)orgName.utf16()));
- if (!ret)
- setError(QFile::RenameError, qt_error_string());
- return ret;
-#else // Q_OS_WINCE && !QT_NO_WINCE_SHELLSDK
+# endif // QT_NO_LIBRARY
+#else // !Q_OS_WINRT
Q_UNUSED(newName);
Q_UNIMPLEMENTED();
return false;
@@ -811,7 +715,6 @@ QString QFSFileEngine::fileName(FileName file) const
QString ret;
if (!isRelativePath()) {
-#if !defined(Q_OS_WINCE)
if (d->fileEntry.filePath().startsWith(QLatin1Char('/')) || // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt
d->fileEntry.filePath().size() == 2 || // It's a drive letter that needs to get a working dir appended
(d->fileEntry.filePath().size() > 2 && d->fileEntry.filePath().at(2) != QLatin1Char('/')) || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt
@@ -819,9 +722,7 @@ QString QFSFileEngine::fileName(FileName file) const
d->fileEntry.filePath().endsWith(QLatin1String("/..")) || d->fileEntry.filePath().endsWith(QLatin1String("/.")))
{
ret = QDir::fromNativeSeparators(QFileSystemEngine::nativeAbsoluteFilePath(d->fileEntry.filePath()));
- } else
-#endif
- {
+ } else {
ret = d->fileEntry.filePath();
}
} else {
@@ -903,14 +804,12 @@ bool QFSFileEngine::setSize(qint64 size)
if (d->fileHandle != INVALID_HANDLE_VALUE || d->fd != -1 || d->fh) {
// resize open file
HANDLE fh = d->fileHandle;
-#if !defined(Q_OS_WINCE)
if (fh == INVALID_HANDLE_VALUE) {
if (d->fh)
fh = (HANDLE)_get_osfhandle(QT_FILENO(d->fh));
else
fh = (HANDLE)_get_osfhandle(d->fd);
}
-#endif
if (fh == INVALID_HANDLE_VALUE)
return false;
qint64 currentPos = pos();
@@ -982,10 +881,8 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
// get handle to the file
HANDLE handle = fileHandle;
-#ifndef Q_OS_WINCE
if (handle == INVALID_HANDLE_VALUE && fh)
handle = (HANDLE)::_get_osfhandle(QT_FILENO(fh));
-#endif
#ifdef Q_USE_DEPRECATED_MAP_API
nativeClose();
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index f5b17318be..c560bc7a03 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -739,6 +739,18 @@ void QIODevicePrivate::setWriteChannelCount(int count)
}
/*!
+ \internal
+*/
+bool QIODevicePrivate::allWriteBuffersEmpty() const
+{
+ for (const QRingBuffer &ringBuffer : writeBuffers) {
+ if (!ringBuffer.isEmpty())
+ return false;
+ }
+ return true;
+}
+
+/*!
Opens the device and sets its OpenMode to \a mode. Returns \c true if successful;
otherwise returns \c false. This function should be called from any
reimplementations of open() or other functions that open the device.
@@ -1148,34 +1160,31 @@ QByteArray QIODevice::read(qint64 maxSize)
Q_D(QIODevice);
QByteArray result;
- CHECK_MAXLEN(read, result);
-
#if defined QIODEVICE_DEBUG
printf("%p QIODevice::read(%lld), d->pos = %lld, d->buffer.size() = %lld\n",
this, maxSize, d->pos, d->buffer.size());
#endif
+ // Try to prevent the data from being copied, if we have a chunk
+ // with the same size in the read buffer.
+ if (maxSize == d->buffer.nextDataBlockSize() && !d->transactionStarted
+ && (d->openMode & (QIODevice::ReadOnly | QIODevice::Text)) == QIODevice::ReadOnly) {
+ result = d->buffer.read();
+ if (!d->isSequential())
+ d->pos += maxSize;
+ if (d->buffer.isEmpty())
+ readData(nullptr, 0);
+ return result;
+ }
+
+ CHECK_MAXLEN(read, result);
if (maxSize >= MaxByteArraySize) {
checkWarnMessage(this, "read", "maxSize argument exceeds QByteArray size limit");
maxSize = MaxByteArraySize - 1;
}
- qint64 readBytes = 0;
- if (maxSize) {
- result.resize(int(maxSize));
- if (!result.size()) {
- // If resize fails, read incrementally.
- qint64 readResult;
- do {
- result.resize(int(qMin(maxSize, qint64(result.size() + d->readBufferChunkSize))));
- readResult = read(result.data() + readBytes, result.size() - readBytes);
- if (readResult > 0 || readBytes == 0)
- readBytes += readResult;
- } while (readResult == d->readBufferChunkSize);
- } else {
- readBytes = read(result.data(), result.size());
- }
- }
+ result.resize(int(maxSize));
+ qint64 readBytes = read(result.data(), result.size());
if (readBytes <= 0)
result.clear();
diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h
index d264bfd31d..76bec89ef2 100644
--- a/src/corelib/io/qiodevice_p.h
+++ b/src/corelib/io/qiodevice_p.h
@@ -92,6 +92,8 @@ public:
friend class QIODevicePrivate;
public:
// wrap functions from QRingBuffer
+ inline void setChunkSize(int size) { Q_ASSERT(m_buf); m_buf->setChunkSize(size); }
+ inline int chunkSize() const { Q_ASSERT(m_buf); return m_buf->chunkSize(); }
inline qint64 nextDataBlockSize() const { return (m_buf ? m_buf->nextDataBlockSize() : Q_INT64_C(0)); }
inline const char *readPointer() const { return (m_buf ? m_buf->readPointer() : Q_NULLPTR); }
inline const char *readPointerAtPosition(qint64 pos, qint64 &length) const { Q_ASSERT(m_buf); return m_buf->readPointerAtPosition(pos, length); }
@@ -152,6 +154,8 @@ public:
return buffer.isEmpty() || (transactionStarted && isSequential()
&& transactionPos == buffer.size());
}
+ bool allWriteBuffersEmpty() const;
+
void seekBuffer(qint64 newPos);
inline void setCurrentReadChannel(int channel)
diff --git a/src/corelib/io/qipaddress_p.h b/src/corelib/io/qipaddress_p.h
index 52fa9c05ad..d95cccb3bd 100644
--- a/src/corelib/io/qipaddress_p.h
+++ b/src/corelib/io/qipaddress_p.h
@@ -44,13 +44,14 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience of
-// qurl*.cpp This header file may change from version to version without
-// notice, or even be removed.
+// 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/private/qglobal_p.h>
#include "qstring.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp
index cb61a52c04..ae3a7c6abc 100644
--- a/src/corelib/io/qlockfile.cpp
+++ b/src/corelib/io/qlockfile.cpp
@@ -42,7 +42,7 @@
#include "qlockfile_p.h"
#include <QtCore/qthread.h>
-#include <QtCore/qelapsedtimer.h>
+#include <QtCore/qdeadlinetimer.h>
#include <QtCore/qdatetime.h>
QT_BEGIN_NAMESPACE
@@ -210,9 +210,7 @@ bool QLockFile::lock()
bool QLockFile::tryLock(int timeout)
{
Q_D(QLockFile);
- QElapsedTimer timer;
- if (timeout > 0)
- timer.start();
+ QDeadlineTimer timer(qMax(timeout, -1)); // QDT only takes -1 as "forever"
int sleepTime = 100;
forever {
d->lockError = d->tryLock_sys();
@@ -235,8 +233,13 @@ bool QLockFile::tryLock(int timeout)
}
break;
}
- if (timeout == 0 || (timeout > 0 && timer.hasExpired(timeout)))
+
+ int remainingTime = timer.remainingTime();
+ if (remainingTime == 0)
return false;
+ else if (uint(sleepTime) > uint(remainingTime))
+ sleepTime = remainingTime;
+
QThread::msleep(sleepTime);
if (sleepTime < 5 * 1000)
sleepTime *= 2;
diff --git a/src/corelib/io/qlockfile_p.h b/src/corelib/io/qlockfile_p.h
index d7f2a1d52d..86a606ec00 100644
--- a/src/corelib/io/qlockfile_p.h
+++ b/src/corelib/io/qlockfile_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qlockfile.h>
#include <QtCore/qfile.h>
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index fda012dad3..82beb15912 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -70,7 +70,7 @@
# include <cstdio>
#elif defined(Q_OS_HAIKU)
# include <kernel/OS.h>
-#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+#elif defined(Q_OS_BSD4) && !defined(QT_PLATFORM_UIKIT)
# include <sys/cdefs.h>
# include <sys/param.h>
# include <sys/sysctl.h>
@@ -283,7 +283,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
if (get_thread_info(pid, &info) != B_OK)
return QString();
return QFile::decodeName(info.name);
-#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+#elif defined(Q_OS_BSD4) && !defined(QT_PLATFORM_UIKIT)
# if defined(Q_OS_NETBSD)
struct kinfo_proc2 kp;
int mib[6] = { CTL_KERN, KERN_PROC2, KERN_PROC_PID, (int)pid, sizeof(struct kinfo_proc2), 1 };
diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp
index 4afab3d135..baaff8da17 100644
--- a/src/corelib/io/qlockfile_win.cpp
+++ b/src/corelib/io/qlockfile_win.cpp
@@ -100,7 +100,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
? QLockFile::LockFailedError
: QLockFile::PermissionError;
default:
- qWarning() << "Got unexpected locking error" << lastError;
+ qWarning("Got unexpected locking error %llu", quint64(lastError));
return QLockFile::UnknownError;
}
}
@@ -165,7 +165,7 @@ bool QLockFilePrivate::isApparentlyStale() const
QString QLockFilePrivate::processNameByPid(qint64 pid)
{
-#if !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
+#if !defined(Q_OS_WINRT)
typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
HMODULE hPsapi = LoadLibraryA("psapi");
diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h
index b8b62e034f..5197da1ba4 100644
--- a/src/corelib/io/qloggingregistry_p.h
+++ b/src/corelib/io/qloggingregistry_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qloggingcategory.h>
#include <QtCore/qmap.h>
#include <QtCore/qmutex.h>
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 1d10e34018..23a3cc1a16 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -48,9 +48,6 @@
#if defined QPROCESS_DEBUG
#include <qstring.h>
#include <ctype.h>
-#if !defined(Q_OS_WINCE)
-#include <errno.h>
-#endif
QT_BEGIN_NAMESPACE
/*
@@ -1975,13 +1972,6 @@ qint64 QProcess::writeData(const char *data, qint64 len)
{
Q_D(QProcess);
-#if defined(Q_OS_WINCE)
- Q_UNUSED(data);
- Q_UNUSED(len);
- d->setErrorAndEmit(QProcess::WriteError);
- return -1;
-#endif
-
if (d->stdinChannel.closed) {
#if defined QPROCESS_DEBUG
qDebug("QProcess::writeData(%p \"%s\", %lld) == 0 (write channel closing)",
@@ -2158,7 +2148,6 @@ void QProcessPrivate::start(QIODevice::OpenMode mode)
mode &= ~QIODevice::ReadOnly; // not open for reading
if (mode == 0)
mode = QIODevice::Unbuffered;
-#ifndef Q_OS_WINCE
if ((mode & QIODevice::ReadOnly) == 0) {
if (stdoutChannel.type == QProcessPrivate::Channel::Normal)
q->setStandardOutputFile(q->nullDevice());
@@ -2166,7 +2155,6 @@ void QProcessPrivate::start(QIODevice::OpenMode mode)
&& processChannelMode != QProcess::MergedChannels)
q->setStandardErrorFile(q->nullDevice());
}
-#endif
q->QIODevice::open(mode);
@@ -2524,7 +2512,7 @@ QT_BEGIN_INCLUDE_NAMESPACE
#if defined(Q_OS_MACX)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
-#elif defined(Q_OS_WINCE) || defined(Q_OS_IOS)
+#elif defined(QT_PLATFORM_UIKIT)
static char *qt_empty_environ[] = { 0 };
#define environ qt_empty_environ
#elif !defined(Q_OS_WIN)
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 8c5589538d..1d425653a3 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -322,7 +322,7 @@ QT_END_INCLUDE_NAMESPACE
QProcessEnvironment QProcessEnvironment::systemEnvironment()
{
QProcessEnvironment env;
-#if !defined(Q_OS_IOS)
+#if !defined(QT_PLATFORM_UIKIT)
const char *entry;
for (int count = 0; (entry = environ[count]); ++count) {
const char *equal = strchr(entry, '=');
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 96b39efe3a..8579db1694 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -867,13 +867,15 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
bool success = false;
PROCESS_INFORMATION pinfo;
+ DWORD dwCreationFlags = (GetConsoleWindow() ? 0 : CREATE_NO_WINDOW);
+ dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT;
STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
(ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
(ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
success = CreateProcess(0, (wchar_t*)args.utf16(),
- 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0,
+ 0, 0, FALSE, dwCreationFlags, 0,
workingDir.isEmpty() ? 0 : (wchar_t*)workingDir.utf16(),
&startupInfo, &pinfo);
diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp
deleted file mode 100644
index 824a6158dc..0000000000
--- a/src/corelib/io/qprocess_wince.cpp
+++ /dev/null
@@ -1,308 +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 "qprocess.h"
-#include "qprocess_p.h"
-
-#include <qdir.h>
-#include <qfileinfo.h>
-#include <qregexp.h>
-#include <qtimer.h>
-#include <qwineventnotifier.h>
-#include <qdebug.h>
-#include <private/qthread_p.h>
-
-#ifndef QT_NO_PROCESS
-
-QT_BEGIN_NAMESPACE
-
-//#define QPROCESS_DEBUG
-
-void QProcessPrivate::destroyPipe(Q_PIPE pipe[2])
-{
- Q_UNUSED(pipe);
-}
-
-void QProcessPrivate::closeChannel(Channel *channel)
-{
- Q_UNUSED(channel);
-}
-
-static QString qt_create_commandline(const QString &program, const QStringList &arguments)
-{
- QString args;
- if (!program.isEmpty()) {
- QString programName = program;
- if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' ')))
- programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
- programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
-
- // add the prgram as the first arg ... it works better
- args = programName + QLatin1Char(' ');
- }
-
- for (int i=0; i<arguments.size(); ++i) {
- QString tmp = arguments.at(i);
- // Quotes are escaped and their preceding backslashes are doubled.
- tmp.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\""));
- if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
- // The argument must not end with a \ since this would be interpreted
- // as escaping the quote -- rather put the \ behind the quote: e.g.
- // rather use "foo"\ than "foo\"
- int i = tmp.length();
- while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\'))
- --i;
- tmp.insert(i, QLatin1Char('"'));
- tmp.prepend(QLatin1Char('"'));
- }
- args += QLatin1Char(' ') + tmp;
- }
- return args;
-}
-
-QProcessEnvironment QProcessEnvironment::systemEnvironment()
-{
- QProcessEnvironment env;
- return env;
-}
-
-void QProcessPrivate::startProcess()
-{
- Q_Q(QProcess);
-
- bool success = false;
-
- if (pid) {
- CloseHandle(pid->hThread);
- CloseHandle(pid->hProcess);
- delete pid;
- pid = 0;
- }
- pid = new PROCESS_INFORMATION;
- memset(pid, 0, sizeof(PROCESS_INFORMATION));
-
- q->setProcessState(QProcess::Starting);
-
- QString args = qt_create_commandline(QString(), arguments);
- if (!nativeArguments.isEmpty()) {
- if (!args.isEmpty())
- args += QLatin1Char(' ');
- args += nativeArguments;
- }
-
-#if defined QPROCESS_DEBUG
- qDebug("Creating process");
- qDebug(" program : [%s]", program.toLatin1().constData());
- qDebug(" args : %s", args.toLatin1().constData());
- qDebug(" pass environment : %s", environment.isEmpty() ? "no" : "yes");
-#endif
-
- QString fullPathProgram = program;
- if (!QDir::isAbsolutePath(fullPathProgram))
- fullPathProgram = QFileInfo(fullPathProgram).absoluteFilePath();
- fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\'));
- success = CreateProcess((wchar_t*)fullPathProgram.utf16(),
- (wchar_t*)args.utf16(),
- 0, 0, false, 0, 0, 0, 0, pid);
-
- if (!success) {
- cleanup();
- setErrorAndEmit(QProcess::FailedToStart);
- q->setProcessState(QProcess::NotRunning);
- return;
- }
-
- q->setProcessState(QProcess::Running);
- // User can call kill()/terminate() from the stateChanged() slot
- // so check before proceeding
- if (!pid)
- return;
-
- if (threadData->hasEventDispatcher()) {
- processFinishedNotifier = new QWinEventNotifier(pid->hProcess, q);
- QObject::connect(processFinishedNotifier, SIGNAL(activated(HANDLE)), q, SLOT(_q_processDied()));
- processFinishedNotifier->setEnabled(true);
- }
-
- // give the process a chance to start ...
- Sleep(20);
- _q_startupNotification();
-}
-
-bool QProcessPrivate::processStarted(QString * /*errorMessage*/)
-{
- return processState == QProcess::Running;
-}
-
-qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *) const
-{
- return 0;
-}
-
-qint64 QProcessPrivate::readFromChannel(const Channel *, char *data, qint64 maxlen)
-{
- return -1;
-}
-
-static BOOL QT_WIN_CALLBACK qt_terminateApp(HWND hwnd, LPARAM procId)
-{
- DWORD currentProcId = 0;
- GetWindowThreadProcessId(hwnd, &currentProcId);
- if (currentProcId == (DWORD)procId)
- PostMessage(hwnd, WM_CLOSE, 0, 0);
-
- return TRUE;
-}
-
-void QProcessPrivate::terminateProcess()
-{
- if (pid) {
- EnumWindows(qt_terminateApp, (LPARAM)pid->dwProcessId);
- PostThreadMessage(pid->dwThreadId, WM_CLOSE, 0, 0);
- }
-}
-
-void QProcessPrivate::killProcess()
-{
- if (pid)
- TerminateProcess(pid->hProcess, 0xf291);
-}
-
-bool QProcessPrivate::waitForStarted(int)
-{
- Q_Q(QProcess);
-
- if (processStarted())
- return true;
-
- if (processError == QProcess::FailedToStart)
- return false;
-
- setError(QProcess::Timedout);
- return false;
-}
-
-bool QProcessPrivate::drainOutputPipes()
-{
- return true;
-}
-
-bool QProcessPrivate::waitForReadyRead(int msecs)
-{
- return false;
-}
-
-bool QProcessPrivate::waitForBytesWritten(int msecs)
-{
- return false;
-}
-
-bool QProcessPrivate::waitForFinished(int msecs)
-{
- Q_Q(QProcess);
-#if defined QPROCESS_DEBUG
- qDebug("QProcessPrivate::waitForFinished(%d)", msecs);
-#endif
-
- if (!pid)
- return true;
-
- if (WaitForSingleObject(pid->hProcess, msecs == -1 ? INFINITE : msecs) == WAIT_OBJECT_0) {
- _q_processDied();
- return true;
- }
-
- setError(QProcess::Timedout);
- return false;
-}
-
-void QProcessPrivate::findExitCode()
-{
- DWORD theExitCode;
- if (GetExitCodeProcess(pid->hProcess, &theExitCode)) {
- exitCode = theExitCode;
- //### for now we assume a crash if exit code is less than -1 or the magic number
- crashed = (exitCode == 0xf291 || (int)exitCode < 0);
- }
-}
-
-void QProcessPrivate::flushPipeWriter()
-{
-}
-
-qint64 QProcessPrivate::pipeWriterBytesToWrite() const
-{
- return 0;
-}
-
-bool QProcessPrivate::writeToStdin()
-{
- return false;
-}
-
-bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDir, qint64 *pid)
-{
- Q_UNUSED(workingDir);
- QString args = qt_create_commandline(QString(), arguments);
-
- bool success = false;
-
- PROCESS_INFORMATION pinfo;
-
- QString fullPathProgram = program;
- if (!QDir::isAbsolutePath(fullPathProgram))
- fullPathProgram.prepend(QDir::currentPath().append(QLatin1Char('/')));
- fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\'));
- success = CreateProcess((wchar_t*)fullPathProgram.utf16(),
- (wchar_t*)args.utf16(),
- 0, 0, false, CREATE_NEW_CONSOLE, 0, 0, 0, &pinfo);
-
- if (success) {
- CloseHandle(pinfo.hThread);
- CloseHandle(pinfo.hProcess);
- if (pid)
- *pid = pinfo.dwProcessId;
- }
-
- return success;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PROCESS
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 96957ac11d..7fe3753da4 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -303,12 +303,12 @@ QResourcePrivate::ensureInitialized() const
if(!that->absoluteFilePath.startsWith(QLatin1Char(':')))
that->absoluteFilePath.prepend(QLatin1Char(':'));
- QString path = fileName;
+ QStringRef path(&fileName);
if(path.startsWith(QLatin1Char(':')))
path = path.mid(1);
if(path.startsWith(QLatin1Char('/'))) {
- that->load(path);
+ that->load(path.toString());
} else {
QMutexLocker lock(resourceMutex());
QStringList searchPaths = *resourceSearchPaths();
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 8bdd148e28..fcdc1e362b 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -81,7 +81,6 @@
#include <stdlib.h>
#ifdef Q_OS_WIN // for homedirpath reading from registry
-# include <private/qsystemlibrary_p.h>
# include <qt_windows.h>
# ifndef Q_OS_WINRT
# include <shlobj.h>
@@ -110,7 +109,7 @@ using namespace ABI::Windows::Storage;
#define Q_XDG_PLATFORM
#endif
-#if !defined(QT_NO_STANDARDPATHS) && (defined(Q_XDG_PLATFORM) || defined(Q_OS_IOS))
+#if !defined(QT_NO_STANDARDPATHS) && (defined(Q_XDG_PLATFORM) || defined(QT_PLATFORM_UIKIT))
#define QSETTINGS_USE_QSTANDARDPATHS
#endif
@@ -814,7 +813,7 @@ StNormal:
++i;
goto StSkipSpaces;
}
- // fallthrough
+ Q_FALLTHROUGH();
default: {
int j = i + 1;
while (j < to) {
@@ -966,21 +965,12 @@ static QString windowsConfigPath(int type)
if (result.isEmpty()) {
switch (type) {
-#ifndef Q_OS_WINCE
case CSIDL_COMMON_APPDATA:
result = QLatin1String("C:\\temp\\qt-common");
break;
case CSIDL_APPDATA:
result = QLatin1String("C:\\temp\\qt-user");
break;
-#else
- case CSIDL_COMMON_APPDATA:
- result = QLatin1String("\\Temp\\qt-common");
- break;
- case CSIDL_APPDATA:
- result = QLatin1String("\\Temp\\qt-user");
- break;
-#endif
default:
;
}
@@ -1365,7 +1355,6 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
{
QConfFile *confFile = confFiles[confFileNo].data();
bool readOnly = confFile->addedKeys.isEmpty() && confFile->removedKeys.isEmpty();
- bool ok;
/*
We can often optimize the read-only case, if the file on disk
@@ -1425,31 +1414,26 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
because they don't exist) are treated as empty files.
*/
if (file.isReadable() && fileInfo.size() != 0) {
+ bool ok = false;
#ifdef Q_OS_MAC
if (format == QSettings::NativeFormat) {
- ok = readPlistFile(confFile->name, &confFile->originalKeys);
+ QByteArray data = file.readAll();
+ ok = readPlistFile(data, &confFile->originalKeys);
} else
#endif
- {
- if (format <= QSettings::IniFormat) {
- QByteArray data = file.readAll();
- ok = readIniFile(data, &confFile->unparsedIniSections);
- } else {
- if (readFunc) {
- QSettings::SettingsMap tempNewKeys;
- ok = readFunc(file, tempNewKeys);
-
- if (ok) {
- QSettings::SettingsMap::const_iterator i = tempNewKeys.constBegin();
- while (i != tempNewKeys.constEnd()) {
- confFile->originalKeys.insert(QSettingsKey(i.key(),
- caseSensitivity),
- i.value());
- ++i;
- }
- }
- } else {
- ok = false;
+ if (format <= QSettings::IniFormat) {
+ QByteArray data = file.readAll();
+ ok = readIniFile(data, &confFile->unparsedIniSections);
+ } else if (readFunc) {
+ QSettings::SettingsMap tempNewKeys;
+ ok = readFunc(file, tempNewKeys);
+
+ if (ok) {
+ QSettings::SettingsMap::const_iterator i = tempNewKeys.constBegin();
+ while (i != tempNewKeys.constEnd()) {
+ confFile->originalKeys.insert(QSettingsKey(i.key(), caseSensitivity),
+ i.value());
+ ++i;
}
}
}
@@ -1467,44 +1451,42 @@ void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
so everything is under control.
*/
if (!readOnly) {
+ bool ok = false;
ensureAllSectionsParsed(confFile);
ParsedSettingsMap mergedKeys = confFile->mergedKeyMap();
-#ifdef Q_OS_MAC
- if (format == QSettings::NativeFormat) {
- ok = writePlistFile(confFile->name, mergedKeys);
- } else
-#endif
- {
#ifndef QT_BOOTSTRAPPED
- QSaveFile sf(confFile->name);
+ QSaveFile sf(confFile->name);
#else
- QFile sf(confFile->name);
+ QFile sf(confFile->name);
#endif
- if (!sf.open(QIODevice::WriteOnly)) {
- setStatus(QSettings::AccessError);
- ok = false;
- } else if (format <= QSettings::IniFormat) {
- ok = writeIniFile(sf, mergedKeys);
- } else {
- if (writeFunc) {
- QSettings::SettingsMap tempOriginalKeys;
+ if (!sf.open(QIODevice::WriteOnly)) {
+ setStatus(QSettings::AccessError);
+ return;
+ }
- ParsedSettingsMap::const_iterator i = mergedKeys.constBegin();
- while (i != mergedKeys.constEnd()) {
- tempOriginalKeys.insert(i.key(), i.value());
- ++i;
- }
- ok = writeFunc(sf, tempOriginalKeys);
- } else {
- ok = false;
- }
+#ifdef Q_OS_MAC
+ if (format == QSettings::NativeFormat) {
+ ok = writePlistFile(sf, mergedKeys);
+ } else
+#endif
+ if (format <= QSettings::IniFormat) {
+ ok = writeIniFile(sf, mergedKeys);
+ } else if (writeFunc) {
+ QSettings::SettingsMap tempOriginalKeys;
+
+ ParsedSettingsMap::const_iterator i = mergedKeys.constBegin();
+ while (i != mergedKeys.constEnd()) {
+ tempOriginalKeys.insert(i.key(), i.value());
+ ++i;
}
+ ok = writeFunc(sf, tempOriginalKeys);
+ }
+
#ifndef QT_BOOTSTRAPPED
- if (ok)
- ok = sf.commit();
+ if (ok)
+ ok = sf.commit();
#endif
- }
if (ok) {
confFile->unparsedIniSections.clear();
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index d73cc4d298..bc397055ff 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -181,7 +181,7 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value)
QDateTime dt = value.toDateTime();
if (dt.timeSpec() == Qt::LocalTime) {
QDateTime reference;
- reference.setTime_t((uint)kCFAbsoluteTimeIntervalSince1970);
+ reference.setSecsSinceEpoch(qint64(kCFAbsoluteTimeIntervalSince1970));
result = CFDateCreate(kCFAllocatorDefault, CFAbsoluteTime(reference.secsTo(dt)));
} else {
goto string_case;
@@ -293,7 +293,7 @@ static QVariant qtValue(CFPropertyListRef cfvalue)
return map;
} else if (typeId == CFDateGetTypeID()) {
QDateTime dt;
- dt.setTime_t((uint)kCFAbsoluteTimeIntervalSince1970);
+ dt.setSecsSinceEpoch(qint64(kCFAbsoluteTimeIntervalSince1970));
return dt.addSecs((int)CFDateGetAbsoluteTime(static_cast<CFDateRef>(cfvalue)));
}
return QVariant();
@@ -541,31 +541,7 @@ void QMacSettingsPrivate::sync()
domains[i].userName, hostNames[j]);
// only report failures for the primary file (the one we write to)
if (!ok && i == 0 && hostNames[j] == hostName && status == QSettings::NoError) {
-#if 1
- if (QSysInfo::macVersion() < QSysInfo::MV_10_7) {
- // work around what seems to be a bug in CFPreferences:
- // don't report an error if there are no preferences for the application
- QCFType<CFArrayRef> appIds = CFPreferencesCopyApplicationList(domains[i].userName,
- hostNames[j]);
-
- // iterate through all the applications and see if we're there
- CFIndex size = CFArrayGetCount(appIds);
- for (CFIndex k = 0; k < size; ++k) {
- const void *cfvalue = CFArrayGetValueAtIndex(appIds, k);
- if (CFGetTypeID(cfvalue) == CFStringGetTypeID()) {
- if (CFStringCompare(static_cast<CFStringRef>(cfvalue),
- domains[i].applicationOrSuiteId,
- kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
- setStatus(QSettings::AccessError);
- break;
- }
- }
- }
- } else
-#endif
- {
- setStatus(QSettings::AccessError);
- }
+ setStatus(QSettings::AccessError);
}
}
}
@@ -637,24 +613,11 @@ QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format,
}
}
-static QCFType<CFURLRef> urlFromFileName(const QString &fileName)
-{
- return CFURLCreateWithFileSystemPath(kCFAllocatorDefault, QCFString(fileName),
- kCFURLPOSIXPathStyle, false);
-}
-
-bool QConfFileSettingsPrivate::readPlistFile(const QString &fileName, ParsedSettingsMap *map) const
+bool QConfFileSettingsPrivate::readPlistFile(const QByteArray &data, ParsedSettingsMap *map) const
{
- QCFType<CFDataRef> resource;
- SInt32 code;
- if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, urlFromFileName(fileName),
- &resource, 0, 0, &code))
- return false;
-
- QCFString errorStr;
+ QCFType<CFDataRef> cfData = data.toRawCFData();
QCFType<CFPropertyListRef> propertyList =
- CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resource, kCFPropertyListImmutable,
- &errorStr);
+ CFPropertyListCreateWithData(kCFAllocatorDefault, cfData, kCFPropertyListImmutable, Q_NULLPTR, Q_NULLPTR);
if (!propertyList)
return true;
@@ -675,8 +638,7 @@ bool QConfFileSettingsPrivate::readPlistFile(const QString &fileName, ParsedSett
return true;
}
-bool QConfFileSettingsPrivate::writePlistFile(const QString &fileName,
- const ParsedSettingsMap &map) const
+bool QConfFileSettingsPrivate::writePlistFile(QIODevice &file, const ParsedSettingsMap &map) const
{
QVarLengthArray<QCFType<CFStringRef> > cfkeys(map.size());
QVarLengthArray<QCFType<CFPropertyListRef> > cfvalues(map.size());
@@ -699,8 +661,7 @@ bool QConfFileSettingsPrivate::writePlistFile(const QString &fileName,
QCFType<CFDataRef> xmlData = CFPropertyListCreateData(
kCFAllocatorDefault, propertyList, kCFPropertyListXMLFormat_v1_0, 0, 0);
- SInt32 code;
- return CFURLWriteDataAndPropertiesToResource(urlFromFileName(fileName), xmlData, 0, &code);
+ return file.write(QByteArray::fromRawCFData(xmlData)) == CFDataGetLength(xmlData);
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h
index 9d7b667514..e6d3413bab 100644
--- a/src/corelib/io/qsettings_p.h
+++ b/src/corelib/io/qsettings_p.h
@@ -296,8 +296,8 @@ private:
void syncConfFile(int confFileNo);
bool writeIniFile(QIODevice &device, const ParsedSettingsMap &map);
#ifdef Q_OS_MAC
- bool readPlistFile(const QString &fileName, ParsedSettingsMap *map) const;
- bool writePlistFile(const QString &fileName, const ParsedSettingsMap &map) const;
+ bool readPlistFile(const QByteArray &data, ParsedSettingsMap *map) const;
+ bool writePlistFile(QIODevice &file, const ParsedSettingsMap &map) const;
#endif
void ensureAllSectionsParsed(QConfFile *confFile) const;
void ensureSectionParsed(QConfFile *confFile, const QSettingsKey &key) const;
diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp
index 05ed51e999..3f06ab7043 100644
--- a/src/corelib/io/qsettings_win.cpp
+++ b/src/corelib/io/qsettings_win.cpp
@@ -609,16 +609,12 @@ HKEY QWinSettingsPrivate::writeHandle() const
QWinSettingsPrivate::~QWinSettingsPrivate()
{
if (deleteWriteHandleOnExit && writeHandle() != 0) {
-#if defined(Q_OS_WINCE)
- remove(regList.at(0).key());
-#else
QString emptyKey;
DWORD res = RegDeleteKey(writeHandle(), reinterpret_cast<const wchar_t *>(emptyKey.utf16()));
if (res != ERROR_SUCCESS) {
qWarning("QSettings: Failed to delete key \"%s\": %s",
regList.at(0).key().toLatin1().data(), errorCodeToString(res).toLatin1().data());
}
-#endif
}
for (int i = 0; i < regList.size(); ++i)
@@ -660,10 +656,6 @@ void QWinSettingsPrivate::remove(const QString &uKey)
}
}
} else {
-#if defined(Q_OS_WINCE)
- // For WinCE always Close the handle first.
- RegCloseKey(handle);
-#endif
res = RegDeleteKey(writeHandle(), reinterpret_cast<const wchar_t *>(rKey.utf16()));
if (res != ERROR_SUCCESS) {
@@ -750,7 +742,7 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value)
}
case QVariant::ByteArray:
- // fallthrough intended
+ Q_FALLTHROUGH();
default: {
// If the string does not contain '\0', we can use REG_SZ, the native registry
diff --git a/src/corelib/io/qstandardpaths.h b/src/corelib/io/qstandardpaths.h
index fff1a29bf3..df76d73eae 100644
--- a/src/corelib/io/qstandardpaths.h
+++ b/src/corelib/io/qstandardpaths.h
@@ -41,6 +41,7 @@
#define QSTANDARDPATHS_H
#include <QtCore/qstringlist.h>
+#include <QtCore/qobjectdefs.h>
QT_BEGIN_NAMESPACE
@@ -49,6 +50,8 @@ QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QStandardPaths
{
+ Q_GADGET
+
public:
// Do not re-order, must match QDesktopServices
enum StandardLocation {
@@ -73,6 +76,7 @@ public:
AppConfigLocation,
AppLocalDataLocation = DataLocation
};
+ Q_ENUM(StandardLocation)
static QString writableLocation(StandardLocation type);
static QStringList standardLocations(StandardLocation type);
@@ -82,6 +86,7 @@ public:
LocateDirectory = 0x1
};
Q_DECLARE_FLAGS(LocateOptions, LocateOption)
+ Q_FLAG(LocateOptions)
static QString locate(StandardLocation type, const QString &fileName, LocateOptions options = LocateFile);
static QStringList locateAll(StandardLocation type, const QString &fileName, LocateOptions options = LocateFile);
@@ -103,6 +108,8 @@ private:
~QStandardPaths();
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStandardPaths::LocateOptions)
+
#endif // QT_NO_STANDARDPATHS
QT_END_NAMESPACE
diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm
index f08a6dac53..dc3d7737b6 100644
--- a/src/corelib/io/qstandardpaths_mac.mm
+++ b/src/corelib/io/qstandardpaths_mac.mm
@@ -117,7 +117,7 @@ static QString baseWritableLocation(QStandardPaths::StandardLocation type,
case QStandardPaths::TempLocation:
path = QDir::tempPath();
break;
-#ifdef Q_OS_IOS
+#if defined(QT_PLATFORM_UIKIT)
// These locations point to non-existing write-protected paths. Use sensible fallbacks.
case QStandardPaths::MusicLocation:
path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Music");
@@ -204,7 +204,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
{
QStringList dirs;
-#ifdef Q_OS_IOS
+#if defined(QT_PLATFORM_UIKIT)
if (type == PicturesLocation)
dirs << writableLocation(PicturesLocation) << QLatin1String("assets-library://");
#endif
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index bcbc9664ef..0561e5833f 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -223,7 +223,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
if (!value.isEmpty()) {
// value can start with $HOME
if (value.startsWith(QLatin1String("$HOME")))
- value = QDir::homePath() + value.mid(5);
+ value = QDir::homePath() + value.midRef(5);
if (value.length() > 1 && value.endsWith(QLatin1Char('/')))
value.chop(1);
return value;
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index 9bd5a9e3b6..38c63553ea 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -51,13 +51,7 @@ const GUID qCLSID_FOLDERID_Downloads = { 0x374de290, 0x123f, 0x4565, { 0x91, 0x6
#include <qt_windows.h>
#include <shlobj.h>
-#if !defined(Q_OS_WINCE)
-# include <intshcut.h>
-#else
-# if !defined(STANDARDSHELL_UI_MODEL)
-# include <winx.h>
-# endif
-#endif
+#include <intshcut.h>
#ifndef CSIDL_MYMUSIC
#define CSIDL_MYMUSIC 13
@@ -117,7 +111,6 @@ static inline void appendTestMode(QString &path)
// Map QStandardPaths::StandardLocation to CLSID of SHGetSpecialFolderPath()
static int writableSpecialFolderClsid(QStandardPaths::StandardLocation type)
{
-#ifndef Q_OS_WINCE
static const int clsids[] = {
CSIDL_DESKTOPDIRECTORY, // DesktopLocation
CSIDL_PERSONAL, // DocumentsLocation
@@ -137,27 +130,6 @@ static int writableSpecialFolderClsid(QStandardPaths::StandardLocation type)
CSIDL_APPDATA, // AppDataLocation ("Roaming" path)
CSIDL_LOCAL_APPDATA, // AppConfigLocation ("Local" path)
};
-#else // !Q_OS_WINCE
- static const int clsids[] = {
- CSIDL_DESKTOPDIRECTORY, // DesktopLocation
- CSIDL_PERSONAL, // DocumentsLocation
- CSIDL_FONTS, // FontsLocation
- CSIDL_PROGRAMS, // ApplicationsLocation
- CSIDL_MYMUSIC, // MusicLocation
- CSIDL_MYVIDEO, // MoviesLocation
- CSIDL_MYPICTURES, // PicturesLocation
- -1, -1, // TempLocation/HomeLocation
- CSIDL_APPDATA, // AppLocalDataLocation, AppLocalDataLocation = DataLocation
- -1, // CacheLocation
- CSIDL_APPDATA, // GenericDataLocation
- -1, // RuntimeLocation
- CSIDL_APPDATA, // ConfigLocation
- -1, -1, // DownloadLocation/GenericCacheLocation
- CSIDL_APPDATA, // GenericConfigLocation
- CSIDL_APPDATA, // AppDataLocation
- CSIDL_APPDATA, // AppConfigLocation
- };
-#endif // Q_OS_WINCE
Q_STATIC_ASSERT(sizeof(clsids) / sizeof(clsids[0]) == size_t(QStandardPaths::AppConfigLocation + 1));
return size_t(type) < sizeof(clsids) / sizeof(clsids[0]) ? clsids[type] : -1;
@@ -183,7 +155,6 @@ static QString sHGetSpecialFolderPath(int clsid, QStandardPaths::StandardLocatio
static QString sHGetKnownFolderPath(const GUID &clsid, QStandardPaths::StandardLocation type, bool warn = false)
{
QString result;
-#ifndef Q_OS_WINCE
typedef HRESULT (WINAPI *GetKnownFolderPath)(const GUID&, DWORD, HANDLE, LPWSTR*);
static const GetKnownFolderPath sHGetKnownFolderPath = // Vista onwards.
@@ -199,11 +170,6 @@ static QString sHGetKnownFolderPath(const GUID &clsid, QStandardPaths::StandardL
qPrintable(displayName(type)));
}
}
-#else // !Q_OS_WINCE
- Q_UNUSED(clsid)
- Q_UNUSED(type)
- Q_UNUSED(warn)
-#endif
return result;
}
@@ -266,7 +232,6 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
dirs.append(localDir);
// type-specific handling goes here
-#ifndef Q_OS_WINCE
if (isConfigLocation(type)) {
QString programData = sHGetSpecialFolderPath(CSIDL_COMMON_APPDATA, type);
if (!programData.isEmpty()) {
@@ -274,12 +239,11 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
appendOrganizationAndApp(programData);
dirs.append(programData);
}
-# ifndef QT_BOOTSTRAPPED
+#ifndef QT_BOOTSTRAPPED
dirs.append(QCoreApplication::applicationDirPath());
dirs.append(QCoreApplication::applicationDirPath() + QLatin1String("/data"));
-# endif // !QT_BOOTSTRAPPED
+#endif // !QT_BOOTSTRAPPED
} // isConfigLocation()
-#endif // !Q_OS_WINCE
return dirs;
}
diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h
index 744653ea42..a14fa8480a 100644
--- a/src/corelib/io/qstorageinfo_p.h
+++ b/src/corelib/io/qstorageinfo_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qstorageinfo.h"
QT_BEGIN_NAMESPACE
@@ -70,7 +71,7 @@ public:
static QStorageInfo root();
protected:
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void retrieveVolumeInfo();
void retrieveDiskFreeSpace();
#elif defined(Q_OS_MAC)
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 0b0446a37e..c430c7714a 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -404,7 +404,12 @@ bool QTemporaryFileEngine::close()
//************* QTemporaryFilePrivate
-QTemporaryFilePrivate::QTemporaryFilePrivate() : autoRemove(true)
+QTemporaryFilePrivate::QTemporaryFilePrivate()
+{
+}
+
+QTemporaryFilePrivate::QTemporaryFilePrivate(const QString &templateNameIn)
+ : templateName(templateNameIn)
{
}
@@ -498,15 +503,11 @@ QString QTemporaryFilePrivate::defaultTemplateName()
QTemporaryFile::QTemporaryFile()
: QFile(*new QTemporaryFilePrivate)
{
- Q_D(QTemporaryFile);
- d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
QTemporaryFile::QTemporaryFile(const QString &templateName)
- : QFile(*new QTemporaryFilePrivate)
+ : QFile(*new QTemporaryFilePrivate(templateName))
{
- Q_D(QTemporaryFile);
- d->templateName = templateName;
}
#else
@@ -519,10 +520,8 @@ QTemporaryFile::QTemporaryFile(const QString &templateName)
\sa setFileTemplate(), QDir::tempPath()
*/
QTemporaryFile::QTemporaryFile()
- : QFile(*new QTemporaryFilePrivate, 0)
+ : QTemporaryFile(nullptr)
{
- Q_D(QTemporaryFile);
- d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
/*!
@@ -540,10 +539,8 @@ QTemporaryFile::QTemporaryFile()
\sa open(), fileTemplate()
*/
QTemporaryFile::QTemporaryFile(const QString &templateName)
- : QFile(*new QTemporaryFilePrivate, 0)
+ : QTemporaryFile(templateName, nullptr)
{
- Q_D(QTemporaryFile);
- d->templateName = templateName;
}
/*!
@@ -557,8 +554,6 @@ QTemporaryFile::QTemporaryFile(const QString &templateName)
QTemporaryFile::QTemporaryFile(QObject *parent)
: QFile(*new QTemporaryFilePrivate, parent)
{
- Q_D(QTemporaryFile);
- d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
/*!
@@ -577,10 +572,8 @@ QTemporaryFile::QTemporaryFile(QObject *parent)
\sa open(), fileTemplate()
*/
QTemporaryFile::QTemporaryFile(const QString &templateName, QObject *parent)
- : QFile(*new QTemporaryFilePrivate, parent)
+ : QFile(*new QTemporaryFilePrivate(templateName), parent)
{
- Q_D(QTemporaryFile);
- d->templateName = templateName;
}
#endif
diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h
index 58cc318ffd..d057603034 100644
--- a/src/corelib/io/qtemporaryfile_p.h
+++ b/src/corelib/io/qtemporaryfile_p.h
@@ -67,13 +67,14 @@ class QTemporaryFilePrivate : public QFilePrivate
protected:
QTemporaryFilePrivate();
+ explicit QTemporaryFilePrivate(const QString &templateNameIn);
~QTemporaryFilePrivate();
QAbstractFileEngine *engine() const;
void resetFileEngine() const;
- bool autoRemove;
- QString templateName;
+ bool autoRemove = true;
+ QString templateName = defaultTemplateName();
static QString defaultTemplateName();
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 27b7570226..4fdb1505ff 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -231,9 +231,7 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384;
#include "qnumeric.h"
#include "qvarlengtharray.h"
-#ifndef Q_OS_WINCE
#include <locale.h>
-#endif
#include "private/qlocale_p.h"
#include <stdlib.h>
@@ -2646,6 +2644,7 @@ QTextStream &QTextStream::operator<<(const char *string)
{
Q_D(QTextStream);
CHECK_VALID_STREAM(*this);
+ // ### Qt6: consider changing to UTF-8
d->putString(QLatin1String(string));
return *this;
}
diff --git a/src/corelib/io/qtextstream_p.h b/src/corelib/io/qtextstream_p.h
index 684cff6aa1..a642beddc4 100644
--- a/src/corelib/io/qtextstream_p.h
+++ b/src/corelib/io/qtextstream_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qtextstream.h"
#ifndef QT_NO_TEXTCODEC
#include "qtextcodec.h"
diff --git a/src/corelib/io/qtldurl_p.h b/src/corelib/io/qtldurl_p.h
index b1fde0c700..b9fbdebbc5 100644
--- a/src/corelib/io/qtldurl_p.h
+++ b/src/corelib/io/qtldurl_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qurl.h"
#include "QtCore/qstring.h"
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index b79ec78aa9..42a742213b 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -413,9 +413,6 @@
#include "qtldurl_p.h"
#include "private/qipaddress_p.h"
#include "qurlquery.h"
-#if defined(Q_OS_WINCE_WM)
-#pragma optimize("g", off)
-#endif
QT_BEGIN_NAMESPACE
extern QString qt_normalizePathSegments(const QString &name, bool allowUncPaths); // qdir.cpp
@@ -836,7 +833,7 @@ recodeFromUser(const QString &input, const ushort *actions, int from, int to)
// appendXXXX functions: copy from the internal form to the external, user form.
// the internal value is stored in its PrettyDecoded form, so that case is easy.
-static inline void appendToUser(QString &appendTo, const QString &value, QUrl::FormattingOptions options,
+static inline void appendToUser(QString &appendTo, const QStringRef &value, QUrl::FormattingOptions options,
const ushort *actions)
{
if (options == QUrl::PrettyDecoded) {
@@ -844,10 +841,17 @@ static inline void appendToUser(QString &appendTo, const QString &value, QUrl::F
return;
}
- if (!qt_urlRecode(appendTo, value.constData(), value.constEnd(), options, actions))
+ if (!qt_urlRecode(appendTo, value.data(), value.end(), options, actions))
appendTo += value;
}
+static inline void appendToUser(QString &appendTo, const QString &value, QUrl::FormattingOptions options,
+ const ushort *actions)
+{
+ appendToUser(appendTo, QStringRef(&value), options, actions);
+}
+
+
inline void QUrlPrivate::appendAuthority(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const
{
if ((options & QUrl::RemoveUserInfo) != QUrl::RemoveUserInfo) {
@@ -927,21 +931,22 @@ inline void QUrlPrivate::appendPath(QString &appendTo, QUrl::FormattingOptions o
if (options & QUrl::NormalizePathSegments) {
thePath = qt_normalizePathSegments(path, false);
}
+
+ QStringRef thePathRef(&thePath);
if (options & QUrl::RemoveFilename) {
const int slash = path.lastIndexOf(QLatin1Char('/'));
if (slash == -1)
return;
- thePath = path.left(slash+1);
+ thePathRef = path.leftRef(slash + 1);
}
// check if we need to remove trailing slashes
if (options & QUrl::StripTrailingSlash) {
- while (thePath.length() > 1 && thePath.endsWith(QLatin1Char('/')))
- thePath.chop(1);
+ while (thePathRef.length() > 1 && thePathRef.endsWith(QLatin1Char('/')))
+ thePathRef.chop(1);
}
- appendToUser(appendTo, thePath, options,
+ appendToUser(appendTo, thePathRef, options,
appendingTo == FullUrl || options & QUrl::EncodeDelimiters ? pathInUrl : pathInIsolation);
-
}
inline void QUrlPrivate::appendFragment(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const
@@ -3456,33 +3461,6 @@ QByteArray QUrl::toPercentEncoding(const QString &input, const QByteArray &exclu
return input.toUtf8().toPercentEncoding(exclude, include);
}
-/*! \fn QUrl QUrl::fromCFURL(CFURLRef url)
- \since 5.2
-
- Constructs a QUrl containing a copy of the CFURL \a url.
-*/
-
-/*! \fn CFURLRef QUrl::toCFURL() const
- \since 5.2
-
- Creates a CFURL from a QUrl. The caller owns the CFURL and is
- responsible for releasing it.
-*/
-
-/*!
- \fn QUrl QUrl::fromNSURL(const NSURL *url)
- \since 5.2
-
- Constructs a QUrl containing a copy of the NSURL \a url.
-*/
-
-/*!
- \fn NSURL* QUrl::toNSURL() const
- \since 5.2
-
- Creates a NSURL from a QUrl. The NSURL is autoreleased.
-*/
-
/*!
\internal
\since 5.0
@@ -3816,13 +3794,13 @@ QUrl QUrl::fromLocalFile(const QString &localFile)
} else if (deslashified.startsWith(QLatin1String("//"))) {
// magic for shared drive on windows
int indexOfPath = deslashified.indexOf(QLatin1Char('/'), 2);
- QString hostSpec = deslashified.mid(2, indexOfPath - 2);
+ QStringRef hostSpec = deslashified.midRef(2, indexOfPath - 2);
// Check for Windows-specific WebDAV specification: "//host@SSL/path".
if (hostSpec.endsWith(webDavSslTag(), Qt::CaseInsensitive)) {
- hostSpec.chop(4);
+ hostSpec.truncate(hostSpec.size() - 4);
scheme = webDavScheme();
}
- url.setHost(hostSpec);
+ url.setHost(hostSpec.toString());
if (indexOfPath > 2)
deslashified = deslashified.right(deslashified.length() - indexOfPath);
@@ -4287,8 +4265,8 @@ QUrl QUrl::fromUserInput(const QString &userInput)
if (urlPrepended.isValid() && (!urlPrepended.host().isEmpty() || !urlPrepended.path().isEmpty()))
{
int dotIndex = trimmedString.indexOf(QLatin1Char('.'));
- const QString hostscheme = trimmedString.left(dotIndex).toLower();
- if (hostscheme == ftpScheme())
+ const QStringRef hostscheme = trimmedString.leftRef(dotIndex);
+ if (hostscheme.compare(ftpScheme(), Qt::CaseInsensitive) == 0)
urlPrepended.setScheme(ftpScheme());
return adjustFtpPath(urlPrepended);
}
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 947b3bbb55..bce271fcb1 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -48,11 +48,9 @@
#include <QtCore/qpair.h>
#include <QtCore/qglobal.h>
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFURL);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSURL);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -164,6 +162,12 @@ public:
};
Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)
#ifdef Q_QDOC
+private:
+ // We need to let qdoc think that FormattingOptions is a normal QFlags, but
+ // it needs to be a QUrlTwoFlags for compiling default arguments of somme functions.
+ template<typename T> struct QFlags : QUrlTwoFlags<T, ComponentFormattingOption>
+ { using QUrlTwoFlags<T, ComponentFormattingOption>::QUrlTwoFlags; };
+public:
Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)
#else
typedef QUrlTwoFlags<UrlFormattingOption, ComponentFormattingOption> FormattingOptions;
@@ -271,13 +275,11 @@ public:
static QByteArray toPercentEncoding(const QString &,
const QByteArray &exclude = QByteArray(),
const QByteArray &include = QByteArray());
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QUrl fromCFURL(CFURLRef url);
CFURLRef toCFURL() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QUrl fromNSURL(const NSURL *url);
NSURL *toNSURL() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
#if QT_DEPRECATED_SINCE(5,0)
@@ -372,6 +374,7 @@ Q_DECLARE_SHARED(QUrl)
Q_DECLARE_OPERATORS_FOR_FLAGS(QUrl::ComponentFormattingOptions)
//Q_DECLARE_OPERATORS_FOR_FLAGS(QUrl::FormattingOptions)
+#ifndef Q_QDOC
Q_DECL_CONSTEXPR inline QUrl::FormattingOptions operator|(QUrl::UrlFormattingOption f1, QUrl::UrlFormattingOption f2)
{ return QUrl::FormattingOptions(f1) | f2; }
Q_DECL_CONSTEXPR inline QUrl::FormattingOptions operator|(QUrl::UrlFormattingOption f1, QUrl::FormattingOptions f2)
@@ -399,6 +402,7 @@ Q_DECL_CONSTEXPR inline QUrl::FormattingOptions operator|(QUrl::ComponentFormatt
//inline QUrl::UrlFormattingOption &operator=(const QUrl::UrlFormattingOption &i, QUrl::ComponentFormattingOptions f)
//{ i = int(f); f; }
+#endif // Q_QDOC
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QUrl &);
diff --git a/src/corelib/io/qurl_p.h b/src/corelib/io/qurl_p.h
index 49dcdeb144..cb88cac35e 100644
--- a/src/corelib/io/qurl_p.h
+++ b/src/corelib/io/qurl_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qurl.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/io/qurltlds_p.h b/src/corelib/io/qurltlds_p.h
index 69d0701faa..2bd5c68c7b 100644
--- a/src/corelib/io/qurltlds_p.h
+++ b/src/corelib/io/qurltlds_p.h
@@ -52,6 +52,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
QT_BEGIN_NAMESPACE
// note to maintainer:
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index 15fb276be9..b8df8e8084 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -71,21 +71,6 @@ QWindowsPipeReader::QWindowsPipeReader(QObject *parent)
this, &QWindowsPipeReader::emitPendingReadyRead, Qt::QueuedConnection);
}
-bool qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped)
-{
- typedef BOOL (WINAPI *PtrCancelIoEx)(HANDLE, LPOVERLAPPED);
- static PtrCancelIoEx ptrCancelIoEx = 0;
- if (!ptrCancelIoEx) {
- HMODULE kernel32 = GetModuleHandleA("kernel32");
- if (kernel32)
- ptrCancelIoEx = PtrCancelIoEx(GetProcAddress(kernel32, "CancelIoEx"));
- }
- if (ptrCancelIoEx)
- return ptrCancelIoEx(handle, overlapped);
- else
- return CancelIo(handle);
-}
-
QWindowsPipeReader::~QWindowsPipeReader()
{
stop();
@@ -110,7 +95,7 @@ void QWindowsPipeReader::stop()
{
stopped = true;
if (readSequenceStarted) {
- if (!qt_cancelIo(handle, &overlapped)) {
+ if (!CancelIoEx(handle, &overlapped)) {
const DWORD dwError = GetLastError();
if (dwError != ERROR_NOT_FOUND) {
qErrnoWarning(dwError, "QWindowsPipeReader: qt_cancelIo on handle %x failed.",
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index b0ca0d979b..3ab2c70c75 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -42,9 +42,6 @@
QT_BEGIN_NAMESPACE
-extern bool qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped); // from qwindowspipereader.cpp
-
-
QWindowsPipeWriter::Overlapped::Overlapped(QWindowsPipeWriter *pipeWriter)
: pipeWriter(pipeWriter)
{
@@ -211,7 +208,7 @@ void QWindowsPipeWriter::stop()
bytesWrittenPending = false;
pendingBytesWrittenValue = 0;
if (writeSequenceStarted) {
- if (!qt_cancelIo(handle, &overlapped)) {
+ if (!CancelIoEx(handle, &overlapped)) {
const DWORD dwError = GetLastError();
if (dwError != ERROR_NOT_FOUND) {
qErrnoWarning(dwError, "QWindowsPipeWriter: qt_cancelIo on handle %x failed.",
diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h
index 3c641670b6..5a0d04855f 100644
--- a/src/corelib/io/qwindowspipewriter_p.h
+++ b/src/corelib/io/qwindowspipewriter_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qelapsedtimer.h>
#include <qobject.h>
#include <qbytearray.h>
diff --git a/src/corelib/io/qwinoverlappedionotifier_p.h b/src/corelib/io/qwinoverlappedionotifier_p.h
index febdfe310f..276a1d861e 100644
--- a/src/corelib/io/qwinoverlappedionotifier_p.h
+++ b/src/corelib/io/qwinoverlappedionotifier_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qobject.h>
typedef struct _OVERLAPPED OVERLAPPED;
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index d645205155..7fdf107383 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -47,6 +47,7 @@
#include <qvector.h>
#include <qstack.h>
#include <qbitarray.h>
+#include <qdatetime.h>
#include <limits.h>
@@ -363,7 +364,7 @@ quintptr QPersistentModelIndex::internalId() const
Returns the parent QModelIndex for this persistent index, or an invalid
QModelIndex if it has no parent.
- \sa child(), sibling(), model()
+ \sa sibling(), model()
*/
QModelIndex QPersistentModelIndex::parent() const
{
@@ -376,7 +377,7 @@ QModelIndex QPersistentModelIndex::parent() const
Returns the sibling at \a row and \a column or an invalid QModelIndex if
there is no sibling at this position.
- \sa parent(), child()
+ \sa parent()
*/
QModelIndex QPersistentModelIndex::sibling(int row, int column) const
@@ -386,7 +387,12 @@ QModelIndex QPersistentModelIndex::sibling(int row, int column) const
return QModelIndex();
}
+#if QT_DEPRECATED_SINCE(5, 8)
/*!
+ \obsolete
+
+ Use QAbstractItemModel::index() instead.
+
Returns the child of the model index that is stored in the given \a row
and \a column.
@@ -396,9 +402,10 @@ QModelIndex QPersistentModelIndex::sibling(int row, int column) const
QModelIndex QPersistentModelIndex::child(int row, int column) const
{
if (d)
- return d->index.child(row, column);
+ return d->index.model()->index(row, column, d->index);
return QModelIndex();
}
+#endif
/*!
Returns the data for the given \a role for the item referred to by the
@@ -547,6 +554,43 @@ const QHash<int,QByteArray> &QAbstractItemModelPrivate::defaultRoleNames()
return *qDefaultRoleNames();
}
+bool QAbstractItemModelPrivate::isVariantLessThan(const QVariant &left, const QVariant &right,
+ Qt::CaseSensitivity cs, bool isLocaleAware)
+{
+ if (left.userType() == QVariant::Invalid)
+ return false;
+ if (right.userType() == QVariant::Invalid)
+ return true;
+ switch (left.userType()) {
+ case QVariant::Int:
+ return left.toInt() < right.toInt();
+ case QVariant::UInt:
+ return left.toUInt() < right.toUInt();
+ case QVariant::LongLong:
+ return left.toLongLong() < right.toLongLong();
+ case QVariant::ULongLong:
+ return left.toULongLong() < right.toULongLong();
+ case QMetaType::Float:
+ return left.toFloat() < right.toFloat();
+ case QVariant::Double:
+ return left.toDouble() < right.toDouble();
+ case QVariant::Char:
+ return left.toChar() < right.toChar();
+ case QVariant::Date:
+ return left.toDate() < right.toDate();
+ case QVariant::Time:
+ return left.toTime() < right.toTime();
+ case QVariant::DateTime:
+ return left.toDateTime() < right.toDateTime();
+ case QVariant::String:
+ default:
+ if (isLocaleAware)
+ return left.toString().localeAwareCompare(right.toString()) < 0;
+ else
+ return left.toString().compare(right.toString(), cs) < 0;
+ }
+}
+
static uint typeOfVariant(const QVariant &value)
{
@@ -1061,12 +1105,16 @@ void QAbstractItemModel::resetInternalData()
Returns the sibling at \a row and \a column. If there is no sibling at this
position, an invalid QModelIndex is returned.
- \sa parent(), child()
+ \sa parent()
*/
/*!
\fn QModelIndex QModelIndex::child(int row, int column) const
+ \obsolete
+
+ Use QAbstractItemModel::index() instead.
+
Returns the child of the model index that is stored in the given \a row and
\a column.
@@ -1115,7 +1163,7 @@ void QAbstractItemModel::resetInternalData()
Returns the parent of the model index, or QModelIndex() if it has no
parent.
- \sa child(), sibling(), model()
+ \sa sibling(), model()
*/
/*!
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index 0820626452..907ba09676 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -63,7 +63,9 @@ public:
inline void *internalPointer() const Q_DECL_NOTHROW { return reinterpret_cast<void*>(i); }
inline QModelIndex parent() const;
inline QModelIndex sibling(int row, int column) const;
- inline QModelIndex child(int row, int column) const;
+#if QT_DEPRECATED_SINCE(5, 8)
+ QT_DEPRECATED_X("Use QAbstractItemModel::index") inline QModelIndex child(int row, int column) const;
+#endif
inline QVariant data(int role = Qt::DisplayRole) const;
inline Qt::ItemFlags flags() const;
Q_DECL_CONSTEXPR inline const QAbstractItemModel *model() const Q_DECL_NOTHROW { return m; }
@@ -128,7 +130,9 @@ public:
quintptr internalId() const;
QModelIndex parent() const;
QModelIndex sibling(int row, int column) const;
- QModelIndex child(int row, int column) const;
+#if QT_DEPRECATED_SINCE(5, 8)
+ QT_DEPRECATED_X("Use QAbstractItemModel::index") QModelIndex child(int row, int column) const;
+#endif
QVariant data(int role = Qt::DisplayRole) const;
Qt::ItemFlags flags() const;
const QAbstractItemModel *model() const;
@@ -419,8 +423,10 @@ inline QModelIndex QModelIndex::parent() const
inline QModelIndex QModelIndex::sibling(int arow, int acolumn) const
{ return m ? (r == arow && c == acolumn) ? *this : m->sibling(arow, acolumn, *this) : QModelIndex(); }
+#if QT_DEPRECATED_SINCE(5, 8)
inline QModelIndex QModelIndex::child(int arow, int acolumn) const
{ return m ? m->index(arow, acolumn, *this) : QModelIndex(); }
+#endif
inline QVariant QModelIndex::data(int arole) const
{ return m ? m->data(*this, arole) : QVariant(); }
diff --git a/src/corelib/itemmodels/qabstractitemmodel_p.h b/src/corelib/itemmodels/qabstractitemmodel_p.h
index 9ff40cd60e..7086ae730a 100644
--- a/src/corelib/itemmodels/qabstractitemmodel_p.h
+++ b/src/corelib/itemmodels/qabstractitemmodel_p.h
@@ -150,6 +150,8 @@ public:
QHash<int,QByteArray> roleNames;
static const QHash<int,QByteArray> &defaultRoleNames();
+ static bool isVariantLessThan(const QVariant &left, const QVariant &right,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive, bool isLocaleAware = false);
};
Q_DECLARE_TYPEINFO(QAbstractItemModelPrivate::Change, Q_MOVABLE_TYPE);
diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h
index d79b99541e..3d3cb00750 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.h
+++ b/src/corelib/itemmodels/qitemselectionmodel.h
@@ -40,6 +40,10 @@
#ifndef QITEMSELECTIONMODEL_H
#define QITEMSELECTIONMODEL_H
+#include <QtCore/qglobal.h>
+
+#ifndef QT_NO_ITEMVIEWS
+
#include <QtCore/qset.h>
#include <QtCore/qvector.h>
#include <QtCore/qlist.h>
@@ -47,9 +51,6 @@
QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_ITEMVIEWS
-
class Q_CORE_EXPORT QItemSelectionRange
{
@@ -272,11 +273,11 @@ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QItemSelection)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QItemSelectionRange &);
#endif
-#endif // QT_NO_ITEMVIEWS
-
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QItemSelectionRange)
Q_DECLARE_METATYPE(QItemSelection)
+#endif // QT_NO_ITEMVIEWS
+
#endif // QITEMSELECTIONMODEL_H
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index 0f45862035..b0ddfa879d 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -2654,40 +2654,7 @@ bool QSortFilterProxyModel::lessThan(const QModelIndex &source_left, const QMode
Q_D(const QSortFilterProxyModel);
QVariant l = (source_left.model() ? source_left.model()->data(source_left, d->sort_role) : QVariant());
QVariant r = (source_right.model() ? source_right.model()->data(source_right, d->sort_role) : QVariant());
- // Duplicated in QStandardItem::operator<()
- if (l.userType() == QVariant::Invalid)
- return false;
- if (r.userType() == QVariant::Invalid)
- return true;
- switch (l.userType()) {
- case QVariant::Int:
- return l.toInt() < r.toInt();
- case QVariant::UInt:
- return l.toUInt() < r.toUInt();
- case QVariant::LongLong:
- return l.toLongLong() < r.toLongLong();
- case QVariant::ULongLong:
- return l.toULongLong() < r.toULongLong();
- case QMetaType::Float:
- return l.toFloat() < r.toFloat();
- case QVariant::Double:
- return l.toDouble() < r.toDouble();
- case QVariant::Char:
- return l.toChar() < r.toChar();
- case QVariant::Date:
- return l.toDate() < r.toDate();
- case QVariant::Time:
- return l.toTime() < r.toTime();
- case QVariant::DateTime:
- return l.toDateTime() < r.toDateTime();
- case QVariant::String:
- default:
- if (d->sort_localeaware)
- return l.toString().localeAwareCompare(r.toString()) < 0;
- else
- return l.toString().compare(r.toString(), d->sort_casesensitivity) < 0;
- }
- return false;
+ return QAbstractItemModelPrivate::isVariantLessThan(l, r, d->sort_casesensitivity, d->sort_localeaware);
}
/*!
diff --git a/src/corelib/json/qjson.cpp b/src/corelib/json/qjson.cpp
index 4b98ef076c..e9a1366af0 100644
--- a/src/corelib/json/qjson.cpp
+++ b/src/corelib/json/qjson.cpp
@@ -339,7 +339,7 @@ bool Value::isValid(const Base *b) const
case QJsonValue::Double:
if (latinOrIntValue)
break;
- // fall through
+ Q_FALLTHROUGH();
case QJsonValue::String:
case QJsonValue::Array:
case QJsonValue::Object:
@@ -418,7 +418,7 @@ uint Value::valueToStore(const QJsonValue &v, uint offset)
if (c != INT_MAX)
return c;
}
- // fall through
+ Q_FALLTHROUGH();
case QJsonValue::String:
case QJsonValue::Array:
case QJsonValue::Object:
diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h
index 8eeff01b59..4be62172a2 100644
--- a/src/corelib/json/qjson_p.h
+++ b/src/corelib/json/qjson_p.h
@@ -151,6 +151,14 @@ public:
val = qToLittleEndian(qFromLittleEndian(val) + i);
return *this;
}
+ q_littleendian &operator |=(T i) {
+ val = qToLittleEndian(qFromLittleEndian(val) | i);
+ return *this;
+ }
+ q_littleendian &operator &=(T i) {
+ val = qToLittleEndian(qFromLittleEndian(val) & i);
+ return *this;
+ }
};
} // namespace QJsonPrivate
@@ -205,6 +213,14 @@ public:
*this = (uint(*this) - i);
return *this;
}
+ qle_bitfield &operator |=(uint i) {
+ *this = (uint(*this) | i);
+ return *this;
+ }
+ qle_bitfield &operator &=(uint i) {
+ *this = (uint(*this) & i);
+ return *this;
+ }
};
template<int pos, int width>
@@ -396,7 +412,7 @@ public:
const ushort *uc = (const ushort *)str.unicode();
int i = 0;
#ifdef __SSE2__
- for ( ; i + 16 < len; i += 16) {
+ for ( ; i + 16 <= len; i += 16) {
__m128i chunk1 = _mm_loadu_si128((__m128i*)&uc[i]); // load
__m128i chunk2 = _mm_loadu_si128((__m128i*)&uc[i + 8]); // load
// pack the two vector to 16 x 8bits elements
@@ -405,7 +421,7 @@ public:
}
# ifdef Q_PROCESSOR_X86_64
// we can do one more round, of 8 characters
- if (i + 8 < len) {
+ if (i + 8 <= len) {
__m128i chunk = _mm_loadu_si128((__m128i*)&uc[i]); // load
// pack with itself, we'll discard the high part anyway
chunk = _mm_packus_epi16(chunk, chunk);
diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp
index 6eca54bdf0..86fd63ead4 100644
--- a/src/corelib/json/qjsondocument.cpp
+++ b/src/corelib/json/qjsondocument.cpp
@@ -260,7 +260,7 @@ QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidati
Creates a QJsonDocument from the QVariant \a variant.
If the \a variant contains any other type than a QVariantMap,
- QVariantList or QStringList, the returned document
+ QVariantHash, QVariantList or QStringList, the returned document
document is invalid.
\sa toVariant()
@@ -270,6 +270,8 @@ QJsonDocument QJsonDocument::fromVariant(const QVariant &variant)
QJsonDocument doc;
if (variant.type() == QVariant::Map) {
doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
+ } else if (variant.type() == QVariant::Hash) {
+ doc.setObject(QJsonObject::fromVariantHash(variant.toHash()));
} else if (variant.type() == QVariant::List) {
doc.setArray(QJsonArray::fromVariantList(variant.toList()));
} else if (variant.type() == QVariant::StringList) {
diff --git a/src/corelib/json/qjsonparser_p.h b/src/corelib/json/qjsonparser_p.h
index ceb366b0f8..e3b95109c6 100644
--- a/src/corelib/json/qjsonparser_p.h
+++ b/src/corelib/json/qjsonparser_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qjsondocument.h>
#include <qvarlengtharray.h>
diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp
index 718dfa43b3..5a906dda7b 100644
--- a/src/corelib/json/qjsonvalue.cpp
+++ b/src/corelib/json/qjsonvalue.cpp
@@ -438,7 +438,7 @@ QJsonValue QJsonValue::fromVariant(const QVariant &variant)
The QJsonValue types will be converted as follows:
- \value Null \l {QVariant::}{QVariant()}
+ \value Null QMetaType::Nullptr
\value Bool QMetaType::Bool
\value Double QMetaType::Double
\value String QString
@@ -466,6 +466,7 @@ QVariant QJsonValue::toVariant() const
QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() :
QVariantMap();
case Null:
+ return QVariant::fromValue(nullptr);
case Undefined:
break;
}
diff --git a/src/corelib/json/qjsonwriter_p.h b/src/corelib/json/qjsonwriter_p.h
index b9cdbb6976..76a8460449 100644
--- a/src/corelib/json/qjsonwriter_p.h
+++ b/src/corelib/json/qjsonwriter_p.h
@@ -50,6 +50,8 @@
//
// We mean it.
//
+
+#include <QtCore/private/qglobal_p.h>
#include <qjsonvalue.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 8c16e10c27..a78397e46c 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -4,6 +4,9 @@ HEADERS += \
kernel/qabstracteventdispatcher.h \
kernel/qabstractnativeeventfilter.h \
kernel/qbasictimer.h \
+ kernel/qdeadlinetimer.h \
+ kernel/qdeadlinetimer_p.h \
+ kernel/qelapsedtimer.h \
kernel/qeventloop.h\
kernel/qpointer.h \
kernel/qcorecmdlineargs_p.h \
@@ -45,6 +48,8 @@ SOURCES += \
kernel/qabstracteventdispatcher.cpp \
kernel/qabstractnativeeventfilter.cpp \
kernel/qbasictimer.cpp \
+ kernel/qdeadlinetimer.cpp \
+ kernel/qelapsedtimer.cpp \
kernel/qeventloop.cpp \
kernel/qcoreapplication.cpp \
kernel/qcoreevent.cpp \
@@ -69,6 +74,7 @@ SOURCES += \
win32 {
SOURCES += \
kernel/qcoreapplication_win.cpp \
+ kernel/qelapsedtimer_win.cpp \
kernel/qwineventnotifier.cpp \
kernel/qsharedmemory_win.cpp \
kernel/qsystemsemaphore_win.cpp
@@ -84,14 +90,6 @@ win32 {
}
}
-wince {
- SOURCES += \
- kernel/qfunctions_wince.cpp
- HEADERS += \
- kernel/qfunctions_fake_env_p.h \
- kernel/qfunctions_wince.h
-}
-
winrt {
SOURCES += \
kernel/qfunctions_winrt.cpp
@@ -109,7 +107,9 @@ mac {
SOURCES += \
kernel/qcfsocketnotifier.cpp \
kernel/qcoreapplication_mac.cpp \
- kernel/qcore_mac.cpp
+ kernel/qcore_mac.cpp \
+ kernel/qcore_foundation.mm
+ !nacl: SOURCES += kernel/qelapsedtimer_mac.cpp
OBJECTIVE_SOURCES += \
kernel/qcore_mac_objc.mm \
@@ -119,10 +119,15 @@ mac {
osx: LIBS_PRIVATE += -framework CoreServices -framework AppKit
- ios {
+ uikit {
# We need UIKit for UIDevice
LIBS_PRIVATE += -framework UIKit
}
+
+ watchos {
+ # We need WatchKit for WKExtension in qeventdispatcher_cf.mm
+ LIBS_PRIVATE += -framework WatchKit
+ }
}
nacl {
@@ -138,6 +143,7 @@ unix|integrity {
kernel/qcrashhandler.cpp \
kernel/qeventdispatcher_unix.cpp \
kernel/qtimerinfo_unix.cpp
+ !darwin|nacl: SOURCES += kernel/qelapsedtimer_unix.cpp
HEADERS += \
kernel/qcore_unix_p.h \
@@ -146,21 +152,20 @@ unix|integrity {
kernel/qpoll_p.h \
kernel/qtimerinfo_unix_p.h
- contains(QT_CONFIG, poll_select): SOURCES += kernel/qpoll.cpp
- contains(QT_CONFIG, poll_poll): DEFINES += QT_HAVE_POLL
- contains(QT_CONFIG, poll_ppoll): DEFINES += QT_HAVE_POLL QT_HAVE_PPOLL
- contains(QT_CONFIG, poll_pollts): DEFINES += QT_HAVE_POLL QT_HAVE_POLLTS
+ qtConfig(poll_select): SOURCES += kernel/qpoll.cpp
+ qtConfig(poll_poll): DEFINES += QT_HAVE_POLL
+ qtConfig(poll_ppoll): DEFINES += QT_HAVE_POLL QT_HAVE_PPOLL
+ qtConfig(poll_pollts): DEFINES += QT_HAVE_POLL QT_HAVE_POLLTS
- contains(QT_CONFIG, glib) {
+ qtConfig(glib) {
SOURCES += \
kernel/qeventdispatcher_glib.cpp
HEADERS += \
kernel/qeventdispatcher_glib_p.h
- QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
- LIBS_PRIVATE +=$$QT_LIBS_GLIB
+ QMAKE_USE_PRIVATE += glib
}
- contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
+ qtConfig(clock-gettime): include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
!android {
SOURCES += kernel/qsharedmemory_posix.cpp \
@@ -183,7 +188,7 @@ vxworks {
}
qqnx_pps {
- LIBS_PRIVATE += -lpps
+ QMAKE_USE_PRIVATE += pps
SOURCES += \
kernel/qppsattribute.cpp \
kernel/qppsobject.cpp
@@ -203,3 +208,5 @@ android {
kernel/qjnihelpers_p.h \
kernel/qjni_p.h
}
+
+!darwin:!unix:!win32: SOURCES += kernel/qelapsedtimer_generic.cpp
diff --git a/src/corelib/kernel/qcfsocketnotifier_p.h b/src/corelib/kernel/qcfsocketnotifier_p.h
index c11c345361..12c5bf6334 100644
--- a/src/corelib/kernel/qcfsocketnotifier_p.h
+++ b/src/corelib/kernel/qcfsocketnotifier_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qabstracteventdispatcher.h>
#include <QtCore/qhash.h>
diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm
new file mode 100644
index 0000000000..2291017a5d
--- /dev/null
+++ b/src/corelib/kernel/qcore_foundation.mm
@@ -0,0 +1,537 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2014 Samuel Gaist <samuel.gaist@edeltech.ch>
+** Copyright (C) 2014 Petroules Corporation.
+** 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/qstring.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/quuid.h>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qrect.h>
+
+#import <Foundation/Foundation.h>
+
+#if defined(QT_PLATFORM_UIKIT)
+#import <CoreGraphics/CoreGraphics.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \since 5.3
+
+ Constructs a new QByteArray containing a copy of the CFData \a data.
+
+ \sa fromRawCFData(), fromRawData(), toRawCFData(), toCFData()
+*/
+QByteArray QByteArray::fromCFData(CFDataRef data)
+{
+ if (!data)
+ return QByteArray();
+
+ return QByteArray(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
+}
+
+/*!
+ \since 5.3
+
+ Constructs a QByteArray that uses the bytes of the CFData \a data.
+
+ The \a data's bytes are not copied.
+
+ The caller guarantees that the CFData will not be deleted
+ or modified as long as this QByteArray object exists.
+
+ \sa fromCFData(), fromRawData(), toRawCFData(), toCFData()
+*/
+QByteArray QByteArray::fromRawCFData(CFDataRef data)
+{
+ if (!data)
+ return QByteArray();
+
+ return QByteArray::fromRawData(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
+}
+
+/*!
+ \since 5.3
+
+ Creates a CFData from a QByteArray. The caller owns the CFData object
+ and is responsible for releasing it.
+
+ \sa toRawCFData(), fromCFData(), fromRawCFData(), fromRawData()
+*/
+CFDataRef QByteArray::toCFData() const
+{
+ return CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()), length());
+}
+
+/*!
+ \since 5.3
+
+ Constructs a CFData that uses the bytes of the QByteArray.
+
+ The QByteArray's bytes are not copied.
+
+ The caller guarantees that the QByteArray will not be deleted
+ or modified as long as this CFData object exists.
+
+ \sa toCFData(), fromRawCFData(), fromCFData(), fromRawData()
+*/
+CFDataRef QByteArray::toRawCFData() const
+{
+ return CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()),
+ length(), kCFAllocatorNull);
+}
+
+/*!
+ \since 5.3
+
+ Constructs a new QByteArray containing a copy of the NSData \a data.
+
+ \sa fromRawNSData(), fromRawData(), toNSData(), toRawNSData()
+*/
+QByteArray QByteArray::fromNSData(const NSData *data)
+{
+ if (!data)
+ return QByteArray();
+ return QByteArray(reinterpret_cast<const char *>([data bytes]), [data length]);
+}
+
+/*!
+ \since 5.3
+
+ Constructs a QByteArray that uses the bytes of the NSData \a data.
+
+ The \a data's bytes are not copied.
+
+ The caller guarantees that the NSData will not be deleted
+ or modified as long as this QByteArray object exists.
+
+ \sa fromNSData(), fromRawData(), toRawNSData(), toNSData()
+*/
+QByteArray QByteArray::fromRawNSData(const NSData *data)
+{
+ if (!data)
+ return QByteArray();
+ return QByteArray::fromRawData(reinterpret_cast<const char *>([data bytes]), [data length]);
+}
+
+/*!
+ \since 5.3
+
+ Creates a NSData from a QByteArray. The NSData object is autoreleased.
+
+ \sa fromNSData(), fromRawNSData(), fromRawData(), toRawNSData()
+*/
+NSData *QByteArray::toNSData() const
+{
+ return [NSData dataWithBytes:constData() length:size()];
+}
+
+/*!
+ \since 5.3
+
+ Constructs a NSData that uses the bytes of the QByteArray.
+
+ The QByteArray's bytes are not copied.
+
+ The caller guarantees that the QByteArray will not be deleted
+ or modified as long as this NSData object exists.
+
+ \sa fromRawNSData(), fromNSData(), fromRawData(), toNSData()
+*/
+NSData *QByteArray::toRawNSData() const
+{
+ // const_cast is fine here because NSData is immutable thus will never modify bytes we're giving it
+ return [NSData dataWithBytesNoCopy:const_cast<char *>(constData()) length:size() freeWhenDone:NO];
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.2
+
+ Constructs a new QString containing a copy of the \a string CFString.
+
+ \note this function is only available on OS X and iOS.
+*/
+QString QString::fromCFString(CFStringRef string)
+{
+ if (!string)
+ return QString();
+ CFIndex length = CFStringGetLength(string);
+
+ // Fast path: CFStringGetCharactersPtr does not copy but may
+ // return null for any and no reason.
+ const UniChar *chars = CFStringGetCharactersPtr(string);
+ if (chars)
+ return QString(reinterpret_cast<const QChar *>(chars), length);
+
+ QString ret(length, Qt::Uninitialized);
+ CFStringGetCharacters(string, CFRangeMake(0, length), reinterpret_cast<UniChar *>(ret.data()));
+ return ret;
+}
+
+/*!
+ \since 5.2
+
+ Creates a CFString from a QString. The caller owns the CFString and is
+ responsible for releasing it.
+
+ \note this function is only available on OS X and iOS.
+*/
+CFStringRef QString::toCFString() const
+{
+ return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(unicode()), length());
+}
+
+/*!
+ \since 5.2
+
+ Constructs a new QString containing a copy of the \a string NSString.
+
+ \note this function is only available on OS X and iOS.
+*/
+QString QString::fromNSString(const NSString *string)
+{
+ if (!string)
+ return QString();
+ QString qstring;
+ qstring.resize([string length]);
+ [string getCharacters: reinterpret_cast<unichar*>(qstring.data()) range: NSMakeRange(0, [string length])];
+ return qstring;
+}
+
+/*!
+ \since 5.2
+
+ Creates a NSString from a QString. The NSString is autoreleased.
+
+ \note this function is only available on OS X and iOS.
+*/
+NSString *QString::toNSString() const
+{
+ return [NSString stringWithCharacters: reinterpret_cast<const UniChar*>(unicode()) length: length()];
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.7
+
+ Constructs a new QUuid containing a copy of the \a uuid CFUUID.
+
+ \note this function is only available on Apple platforms.
+*/
+QUuid QUuid::fromCFUUID(CFUUIDRef uuid)
+{
+ if (!uuid)
+ return QUuid();
+ const CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid);
+ return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(&bytes), sizeof(bytes)));
+}
+
+/*!
+ \since 5.7
+
+ Creates a CFUUID from a QUuid. The caller owns the CFUUID and is
+ responsible for releasing it.
+
+ \note this function is only available on Apple platforms.
+*/
+CFUUIDRef QUuid::toCFUUID() const
+{
+ const QByteArray bytes = toRfc4122();
+ return CFUUIDCreateFromUUIDBytes(0, *reinterpret_cast<const CFUUIDBytes *>(bytes.constData()));
+}
+
+/*!
+ \since 5.7
+
+ Constructs a new QUuid containing a copy of the \a uuid NSUUID.
+
+ \note this function is only available on Apple platforms.
+*/
+QUuid QUuid::fromNSUUID(const NSUUID *uuid)
+{
+ if (!uuid)
+ return QUuid();
+ uuid_t bytes;
+ [uuid getUUIDBytes:bytes];
+ return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(bytes), sizeof(bytes)));
+}
+
+/*!
+ \since 5.7
+
+ Creates a NSUUID from a QUuid. The NSUUID is autoreleased.
+
+ \note this function is only available on Apple platforms.
+*/
+NSUUID *QUuid::toNSUUID() const
+{
+ const QByteArray bytes = toRfc4122();
+ return [[[NSUUID alloc] initWithUUIDBytes:*reinterpret_cast<const uuid_t *>(bytes.constData())] autorelease];
+}
+
+// ----------------------------------------------------------------------------
+
+
+/*!
+ \since 5.2
+
+ Constructs a QUrl containing a copy of the CFURL \a url.
+*/
+QUrl QUrl::fromCFURL(CFURLRef url)
+{
+ return QUrl(QString::fromCFString(CFURLGetString(url)));
+}
+
+/*!
+ \since 5.2
+
+ Creates a CFURL from a QUrl. The caller owns the CFURL and is
+ responsible for releasing it.
+*/
+CFURLRef QUrl::toCFURL() const
+{
+ CFURLRef url = 0;
+ CFStringRef str = toString(FullyEncoded).toCFString();
+ if (str) {
+ url = CFURLCreateWithString(0, str, 0);
+ CFRelease(str);
+ }
+ return url;
+}
+
+/*!
+ \since 5.2
+
+ Constructs a QUrl containing a copy of the NSURL \a url.
+*/
+QUrl QUrl::fromNSURL(const NSURL *url)
+{
+ return QUrl(QString::fromNSString([url absoluteString]));
+}
+
+/*!
+ \since 5.2
+
+ Creates a NSURL from a QUrl. The NSURL is autoreleased.
+*/
+NSURL *QUrl::toNSURL() const
+{
+ return [NSURL URLWithString:toString(FullyEncoded).toNSString()];
+}
+
+// ----------------------------------------------------------------------------
+
+
+/*!
+ \since 5.5
+
+ Constructs a new QDateTime containing a copy of the CFDate \a date.
+
+ \sa toCFDate()
+*/
+QDateTime QDateTime::fromCFDate(CFDateRef date)
+{
+ if (!date)
+ return QDateTime();
+ return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>((CFDateGetAbsoluteTime(date)
+ + kCFAbsoluteTimeIntervalSince1970) * 1000));
+}
+
+/*!
+ \since 5.5
+
+ Creates a CFDate from a QDateTime. The caller owns the CFDate object
+ and is responsible for releasing it.
+
+ \sa fromCFDate()
+*/
+CFDateRef QDateTime::toCFDate() const
+{
+ return CFDateCreate(kCFAllocatorDefault, (static_cast<CFAbsoluteTime>(toMSecsSinceEpoch())
+ / 1000) - kCFAbsoluteTimeIntervalSince1970);
+}
+
+/*!
+ \since 5.5
+
+ Constructs a new QDateTime containing a copy of the NSDate \a date.
+
+ \sa toNSDate()
+*/
+QDateTime QDateTime::fromNSDate(const NSDate *date)
+{
+ if (!date)
+ return QDateTime();
+ return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>([date timeIntervalSince1970] * 1000));
+}
+
+/*!
+ \since 5.5
+
+ Creates an NSDate from a QDateTime. The NSDate object is autoreleased.
+
+ \sa fromNSDate()
+*/
+NSDate *QDateTime::toNSDate() const
+{
+ return [NSDate
+ dateWithTimeIntervalSince1970:static_cast<NSTimeInterval>(toMSecsSinceEpoch()) / 1000];
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.8
+
+ Creates a CGRect from a QRect.
+
+ \sa fromCGRect()
+*/
+CGRect QRect::toCGRect() const Q_DECL_NOTHROW
+{
+ return CGRectMake(x(), y(), width(), height());
+}
+
+/*!
+ \since 5.8
+
+ Creates a CGRect from a QRectF.
+
+ \sa fromCGRect()
+*/
+CGRect QRectF::toCGRect() const Q_DECL_NOTHROW
+{
+ return CGRectMake(x(), y(), width(), height());
+}
+
+/*!
+ \since 5.8
+
+ Creates a QRectF from a CGRect.
+
+ \sa toCGRect()
+*/
+QRectF QRectF::fromCGRect(CGRect rect) Q_DECL_NOTHROW
+{
+ return QRectF(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.8
+
+ Creates a CGPoint from a QPoint.
+
+ \sa fromCGPoint()
+*/
+CGPoint QPoint::toCGPoint() const Q_DECL_NOTHROW
+{
+ return CGPointMake(x(), y());
+}
+
+/*!
+ \since 5.8
+
+ Creates a CGPoint from a QPointF.
+
+ \sa fromCGPoint()
+*/
+CGPoint QPointF::toCGPoint() const Q_DECL_NOTHROW
+{
+ return CGPointMake(x(), y());
+}
+
+/*!
+ \since 5.8
+
+ Creates a QRectF from a CGPoint.
+
+ \sa toCGPoint()
+*/
+QPointF QPointF::fromCGPoint(CGPoint point) Q_DECL_NOTHROW
+{
+ return QPointF(point.x, point.y);
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.8
+
+ Creates a CGSize from a QSize.
+
+ \sa fromCGSize()
+*/
+CGSize QSize::toCGSize() const Q_DECL_NOTHROW
+{
+ return CGSizeMake(width(), height());
+}
+
+/*!
+ \since 5.8
+
+ Creates a CGSize from a QSizeF.
+
+ \sa fromCGSize()
+*/
+CGSize QSizeF::toCGSize() const Q_DECL_NOTHROW
+{
+ return CGSizeMake(width(), height());
+}
+
+/*!
+ \since 5.8
+
+ Creates a QRectF from a CGSize.
+
+ \sa toCGSize()
+*/
+QSizeF QSizeF::fromCGSize(CGSize size) Q_DECL_NOTHROW
+{
+ return QSizeF(size.width, size.height);
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index de491dd43d..ee1a290386 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -47,7 +47,7 @@
#include <qdebug.h>
-#ifdef Q_OS_IOS
+#if defined(Q_OS_IOS)
#import <UIKit/UIKit.h>
#endif
@@ -101,7 +101,7 @@ QT_FOR_EACH_MUTABLE_CORE_GRAPHICS_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TY
QAppleOperatingSystemVersion qt_apple_os_version()
{
QAppleOperatingSystemVersion v = {0, 0, 0};
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0)
+#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0) || defined(Q_OS_TVOS) || defined(Q_OS_WATCHOS)
if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) {
NSOperatingSystemVersion osv = NSProcessInfo.processInfo.operatingSystemVersion;
v.major = osv.majorVersion;
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index b94aac1093..63e1cb48dc 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -61,7 +61,7 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
-#include "qglobal.h"
+#include "private/qglobal_p.h"
#ifdef __OBJC__
#include <Foundation/Foundation.h>
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index 125ced6fc9..b5756af994 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qplatformdefs.h"
#include "qatomic.h"
#include "qhash.h"
@@ -298,8 +299,8 @@ static inline int qt_safe_close(int fd)
#undef QT_CLOSE
#define QT_CLOSE qt_safe_close
-// - VxWorks doesn't have processes
-#if !defined(Q_OS_VXWORKS)
+// - VxWorks & iOS/tvOS/watchOS don't have processes
+#if !defined(Q_OS_VXWORKS) && !defined(QT_NO_PROCESS)
static inline int qt_safe_execve(const char *filename, char *const argv[],
char *const envp[])
{
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 2179a0d323..0413e06665 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -72,7 +72,7 @@
#ifndef QT_NO_QOBJECT
#if defined(Q_OS_UNIX)
-# if defined(Q_OS_OSX)
+# if defined(Q_OS_DARWIN)
# include "qeventdispatcher_cf_p.h"
# else
# if !defined(QT_NO_GLIB)
@@ -483,7 +483,7 @@ void QCoreApplicationPrivate::createEventDispatcher()
{
Q_Q(QCoreApplication);
#if defined(Q_OS_UNIX)
-# if defined(Q_OS_OSX)
+# if defined(Q_OS_DARWIN)
bool ok = false;
int value = qEnvironmentVariableIntValue("QT_EVENT_DISPATCHER_CORE_FOUNDATION", &ok);
if (ok && value > 0)
@@ -1299,19 +1299,6 @@ void QCoreApplication::exit(int returnCode)
QEventLoop *eventLoop = data->eventLoops.at(i);
eventLoop->exit(returnCode);
}
-#ifdef Q_OS_WINRT
- qWarning("QCoreApplication::exit: It is not recommended to explicitly exit an application on Windows Store Apps");
- ComPtr<ICoreApplication> app;
- HRESULT hr = RoGetActivationFactory(Wrappers::HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(),
- IID_PPV_ARGS(&app));
- RETURN_VOID_IF_FAILED("Could not acquire ICoreApplication object");
- ComPtr<ICoreApplicationExit> appExit;
-
- hr = app.As(&appExit);
- RETURN_VOID_IF_FAILED("Could not acquire ICoreApplicationExit object");
- hr = appExit->Exit();
- RETURN_VOID_IF_FAILED("Could not exit application");
-#endif // Q_OS_WINRT
}
/*****************************************************************************
@@ -2259,14 +2246,6 @@ QStringList QCoreApplication::arguments()
// classes by index.
QString cmdline = QString::fromWCharArray(GetCommandLine());
-#if defined(Q_OS_WINCE)
- wchar_t tempFilename[MAX_PATH+1];
- if (GetModuleFileName(0, tempFilename, MAX_PATH)) {
- tempFilename[MAX_PATH] = 0;
- cmdline.prepend(QLatin1Char('\"') + QString::fromWCharArray(tempFilename) + QLatin1String("\" "));
- }
-#endif // Q_OS_WINCE
-
const QCoreApplicationPrivate *d = self->d_func();
if (d->origArgv) {
const QStringList allArguments = qWinCmdArgs(cmdline);
@@ -2497,6 +2476,26 @@ QStringList QCoreApplication::libraryPaths()
}
}
+#ifdef Q_OS_DARWIN
+ // Check the main bundle's PlugIns directory as this is a standard location for Apple OSes.
+ // Note that the QLibraryInfo::PluginsPath below will coincidentally be the same as this value
+ // but with a different casing, so it can't be relied upon when the underlying filesystem
+ // is case sensitive (and this is always the case on newer OSes like iOS).
+ if (CFBundleRef bundleRef = CFBundleGetMainBundle()) {
+ if (QCFType<CFURLRef> urlRef = CFBundleCopyBuiltInPlugInsURL(bundleRef)) {
+ if (QCFType<CFURLRef> absoluteUrlRef = CFURLCopyAbsoluteURL(urlRef)) {
+ if (QCFString path = CFURLCopyFileSystemPath(absoluteUrlRef, kCFURLPOSIXPathStyle)) {
+ if (QFile::exists(path)) {
+ path = QDir(path).canonicalPath();
+ if (!app_libpaths->contains(path))
+ app_libpaths->append(path);
+ }
+ }
+ }
+ }
+ }
+#endif // Q_OS_DARWIN
+
QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
if (QFile::exists(installPathPlugins)) {
// Make sure we convert from backslashes to slashes.
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 0e2d4e2324..67e509eeef 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -122,6 +122,7 @@ QString QCoreApplicationPrivate::appName() const
#ifndef Q_OS_WINRT
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle
{
return GetModuleHandle(0);
@@ -145,12 +146,13 @@ Q_CORE_EXPORT int qWinAppCmdShow() // get main window sho
: SW_SHOWDEFAULT;
#endif
}
+#endif
/*****************************************************************************
qWinMain() - Initializes Windows. Called from WinMain() in qtmain_win.cpp
*****************************************************************************/
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
// ### Qt6: FIXME: Consider removing this function. It is here for Active Qt
// servers and for binary for compatibility to applications built with Qt 5.3
@@ -171,30 +173,7 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam,
argv.append(_strdup(wArg.toLocal8Bit().constData()));
}
-#elif defined(Q_OS_WINCE)
-
-Q_CORE_EXPORT void __cdecl qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam,
- int cmdShow, int &argc, QVector<char *> &argv)
-{
- static bool already_called = false;
-
- if (already_called) {
- qWarning("Qt: Internal error: qWinMain should be called only once");
- return;
- }
- already_called = true;
-
- // Create command line
- argv = qWinCmdLine<char>(cmdParam, int(strlen(cmdParam)), argc);
-
- appCmdShow = cmdShow;
-
- // Ignore Windows parameters
- Q_UNUSED(instance);
- Q_UNUSED(prevInstance);
-}
-
-#endif // Q_OS_WINCE
+#endif // !Q_OS_WINRT
#ifndef QT_NO_QOBJECT
@@ -212,11 +191,6 @@ QT_END_INCLUDE_NAMESPACE
# define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
# define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
#endif
-#ifdef _WIN32_WCE
-# ifndef WM_NCACTIVATE
-# define WM_NCACTIVATE 0x86
-# endif
-#endif
// The values below should never change. Note that none of the usual
// WM_...FIRST & WM_...LAST values are in the list, as they normally have other
diff --git a/src/corelib/kernel/qcorecmdlineargs_p.h b/src/corelib/kernel/qcorecmdlineargs_p.h
index 2d8de08f2d..33445a1625 100644
--- a/src/corelib/kernel/qcorecmdlineargs_p.h
+++ b/src/corelib/kernel/qcorecmdlineargs_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qstring.h"
#include "QtCore/qstringlist.h"
@@ -81,93 +82,7 @@ static inline QStringList qWinCmdArgs(const QString &cmdLine)
return result;
}
-#elif defined(Q_OS_WINCE) // Q_OS_WIN32
-
-// template implementation of the parsing algorithm
-// this is used from qcoreapplication_win.cpp and the tools (rcc, uic...)
-
-template<typename Char>
-static QVector<Char*> qWinCmdLine(Char *cmdParam, int length, int &argc)
-{
- QVector<Char*> argv(8);
- Char *p = cmdParam;
- Char *p_end = p + length;
-
- argc = 0;
-
- while (*p && p < p_end) { // parse cmd line arguments
- while (QChar((short)(*p)).isSpace()) // skip white space
- p++;
- if (*p && p < p_end) { // arg starts
- int quote;
- Char *start, *r;
- if (*p == Char('\"')) {
- quote = *p;
- start = ++p;
- } else {
- quote = 0;
- start = p;
- }
- r = start;
- while (*p && p < p_end) {
- if (quote) {
- if (*p == quote) {
- p++;
- if (QChar((short)(*p)).isSpace())
- break;
- quote = 0;
- }
- }
- if (*p == '\\') { // escape char?
- // testing by looking at argc, argv shows that it only escapes quotes
- if (p < p_end && (*(p+1) == Char('\"')))
- p++;
- } else {
- if (!quote && (*p == Char('\"'))) {
- quote = *p++;
- continue;
- } else if (QChar((short)(*p)).isSpace() && !quote)
- break;
- }
- if (*p)
- *r++ = *p++;
- }
- if (*p && p < p_end)
- p++;
- *r = Char('\0');
-
- if (argc >= (int)argv.size()-1) // expand array
- argv.resize(argv.size()*2);
- argv[argc++] = start;
- }
- }
- argv[argc] = 0;
-
- return argv;
-}
-
-static inline QStringList qWinCmdArgs(QString cmdLine) // not const-ref: this might be modified
-{
- QStringList args;
-
- int argc = 0;
- QVector<wchar_t*> argv = qWinCmdLine<wchar_t>((wchar_t *)cmdLine.utf16(), cmdLine.length(), argc);
- for (int a = 0; a < argc; ++a) {
- args << QString::fromWCharArray(argv[a]);
- }
-
- return args;
-}
-
-static inline QStringList qCmdLineArgs(int argc, char *argv[])
-{
- Q_UNUSED(argc)
- Q_UNUSED(argv)
- QString cmdLine = QString::fromWCharArray(GetCommandLine());
- return qWinCmdArgs(cmdLine);
-}
-
-#elif defined(Q_OS_WINRT) // Q_OS_WINCE
+#elif defined(Q_OS_WINRT) // Q_OS_WIN32
static inline QStringList qCmdLineArgs(int argc, char *argv[])
{
diff --git a/src/corelib/kernel/qcoreglobaldata_p.h b/src/corelib/kernel/qcoreglobaldata_p.h
index 4f97449c75..32b5becf4f 100644
--- a/src/corelib/kernel/qcoreglobaldata_p.h
+++ b/src/corelib/kernel/qcoreglobaldata_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qmap.h"
#include "QtCore/qstringlist.h"
#include "QtCore/qreadwritelock.h"
diff --git a/src/corelib/kernel/qcrashhandler_p.h b/src/corelib/kernel/qcrashhandler_p.h
index 1fd0ff3af8..64c15ce66c 100644
--- a/src/corelib/kernel/qcrashhandler_p.h
+++ b/src/corelib/kernel/qcrashhandler_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#ifndef QT_NO_CRASHHANDLER
diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp
new file mode 100644
index 0000000000..957d985c31
--- /dev/null
+++ b/src/corelib/kernel/qdeadlinetimer.cpp
@@ -0,0 +1,825 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeadlinetimer.h"
+#include "qdeadlinetimer_p.h"
+#include <qpair.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECL_CONST_FUNCTION static inline QPair<qint64, qint64> toSecsAndNSecs(qint64 nsecs)
+{
+ qint64 secs = nsecs / (1000*1000*1000);
+ if (nsecs < 0)
+ --secs;
+ nsecs -= secs * 1000*1000*1000;
+ return qMakePair(secs, nsecs);
+}
+
+/*!
+ \class QDeadlineTimer
+ \inmodule QtCore
+ \brief The QDeadlineTimer class marks a deadline in the future.
+ \since 5.8
+
+ \reentrant
+ \ingroup tools
+
+ The QDeadlineTimer class is usually used to calculate future deadlines and
+ verify whether the deadline has expired. QDeadlineTimer can also be used
+ for deadlines without expiration ("forever"). It forms a counterpart to
+ QElapsedTimer, which calculates how much time has elapsed since
+ QElapsedTimer::start() was called.
+
+ QDeadlineTimer provides a more convenient API compared to
+ QElapsedTimer::hasExpired().
+
+ The typical use-case for the class is to create a QDeadlineTimer before the
+ operation in question is started, and then use remainingTime() or
+ hasExpired() to determine whether to continue trying the operation.
+ QDeadlineTimer objects can be passed to functions being called to execute
+ this operation so they know how long to still operate.
+
+ \code
+ void executeOperation(int msecs)
+ {
+ QDeadlineTimer deadline(msecs);
+ do {
+ if (readFromDevice(deadline.remainingTime())
+ break;
+ waitForReadyRead(deadline);
+ } while (!deadline.hasExpired());
+ }
+ \endcode
+
+ Many QDeadlineTimer functions deal with time out values, which all are
+ measured in milliseconds. There are two special values, the same as many
+ other Qt functions named \c{waitFor} or similar:
+
+ \list
+ \o 0: no time left, expired
+ \o -1: infinite time left, timer never expires
+ \endlist
+
+ \section1 Reference Clocks
+
+ QDeadlineTimer will use the same clock as QElapsedTimer (see
+ QElapsedTimer::clockType() and QElapsedTimer::isMonotonic()).
+
+ \section1 Timer types
+
+ Like QTimer, QDeadlineTimer can select among different levels of coarseness
+ on the timers. You can select precise timing by passing Qt::PreciseTimer to
+ the functions that set of change the timer, or you can select coarse timing
+ by passing Qt::CoarseTimer. Qt::VeryCoarseTimer is currently interpreted
+ the same way as Qt::CoarseTimer.
+
+ This feature is dependent on support from the operating system: if the OS
+ does not support a coarse timer functionality, then QDeadlineTimer will
+ behave like Qt::PreciseTimer was passed.
+
+ QDeadlineTimer defaults to Qt::CoarseTimer because on operating systems
+ that do support coarse timing, making timing calls to that clock source is
+ often much more efficient. The level of coarseness depends on the
+ operating system, but should be in the order of a couple of milliseconds.
+
+ \section1 \c{std::chrono} Compatibility
+
+ QDeadlineTimer is compatible with the \c{std::chrono} API from C++11 and
+ can be constructed from or compared to both \c{std::chrono::duration} and
+ \c{std::chrono::time_point} objects. In addition, it is fully compatible
+ with the time literals from C++14, which allow one to write code as:
+
+ \code
+ using namespace std::chrono;
+
+ QDeadlineTimer deadline(30s);
+ device->waitForReadyRead(deadline);
+ if (deadline.remainingTime<nanoseconds>() > 300ms)
+ cleanup();
+ \endcode
+
+ As can be seen in the example above, QDeadlineTimer offers a templated
+ version of remainingTime() and deadline() that can be used to return
+ \c{std::chrono} objects.
+
+ Note that comparing to \c{time_point} is not as efficient as comparing to
+ \c{duration}, since QDeadlineTimer may need to convert from its own
+ internal clock source to the clock source used by the \c{time_point} object.
+ Also note that, due to this conversion, the deadlines will not be precise,
+ so the following code is not expected to compare equally:
+
+ \code
+ using namespace std::chrono;
+ auto now = steady_clock::now();
+ QDeadlineTimer deadline(now + 1s);
+ Q_ASSERT(deadline == now + 1s);
+ \endcode
+
+ \sa QTime, QTimer, QDeadlineTimer, Qt::TimerType
+*/
+
+/*!
+ \enum QDeadlineTimer::ForeverConstant
+
+ \value Forever Used when creating a QDeadlineTimer to indicate the
+ deadline should not expire
+*/
+
+/*!
+ \fn QDeadlineTimer::QDeadlineTimer(Qt::TimerType timerType)
+
+ Constructs an expired QDeadlineTimer object. For this object,
+ remainingTime() will return 0.
+
+ The timer type \a timerType may be ignored, since the timer is already
+ expired. Similarly, for optimization purposes, this function will not
+ attempt to obtain the current time and will use a value known to be in the
+ past. Therefore, deadline() may return an unexpected value and this object
+ cannot be used in calculation of how long it is overdue. If that
+ functionality is required, use QDeadlineTimer::current().
+
+ \sa hasExpired(), remainingTime(), timerType(), current()
+*/
+
+/*!
+ \fn QDeadlineTimer::QDeadlineTimer(ForeverConstant, Qt::TimerType timerType)
+
+ Constructs a QDeadlineTimer object that never expires. For this object,
+ remainingTime() will return -1, deadline() will return the maximum value,
+ and isForever() will return true.
+
+ The timer type \a timerType may be ignored, since the timer is already
+ expired.
+
+ \sa hasExpired(), isForever(), remainingTime(), timerType()
+*/
+
+/*!
+ Constructs a QDeadlineTimer object with an expiry time of \a msecs msecs
+ from the moment of the creation of this object, if msecs is positive. If \a
+ msecs is zero, this QDeadlineTimer will be marked as expired, causing
+ remainingTime() to return zero and deadline() to return an indeterminate
+ time point in the past. If \a msecs is -1, the timer will be set it to
+ never expire, causing remainingTime() to return -1 and deadline() to return
+ the maximum value.
+
+ The QDeadlineTimer object will be constructed with a timer type of \a
+ timerType.
+
+ For optimization purposes, if \a msecs is zero, this function may skip
+ obtaining the current time and may instead use a value known to be in the
+ past. If that happens, deadline() may return an unexpected value and this
+ object cannot be used in calculation of how long it is overdue. If that
+ functionality is required, use QDeadlineTimer::current() and add time to
+ it.
+
+ \sa hasExpired(), isForever(), remainingTime(), setRemainingTime()
+*/
+QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW
+ : t2(0)
+{
+ setRemainingTime(msecs, type);
+}
+
+/*!
+ \fn QDeadlineTimer::QDeadlineTimer(std::chrono::time_point<Clock, Duration> deadline, Qt::TimerType type)
+
+ Constructs a QDeadlineTimer object with a deadline at \a deadline time
+ point, converting from the clock source \c{Clock} to Qt's internal clock
+ source (see QElapsedTimer::clcokType()).
+
+ If \a deadline is in the past, this QDeadlineTimer object is set to
+ expired, whereas if \a deadline is equal to \c{Duration::max()}, then this
+ object is set to never expire.
+
+ The QDeadlineTimer object will be constructed with a timer type of \a
+ timerType.
+
+ \sa hasExpired(), isForever(), remainingTime<Duration>(), setDeadline()
+*/
+
+/*!
+ \fn QDeadlineTimer::QDeadlineTimer(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type)
+
+ Constructs a QDeadlineTimer object with a remaining time of \a remaining.
+ If \a remaining is zero or negative, this QDeadlineTimer object will be
+ mark as expired, whereas if \a remaining is equal to \c{duration::max()},
+ the object will be set to never expire.
+
+ The QDeadlineTimer object will be constructed with a timer type of \a
+ timerType.
+
+ This constructor can be used with C++14's user-defined literals for time, such as in:
+
+ \code
+ using namespace std::chrono;
+ QDeadlineTimer deadline(250ms);
+ \endcode
+
+ For optimization purposes, if \a remaining is zero or negative, this
+ function may skip obtaining the current time and may instead use a value
+ known to be in the past. If that happens, deadline() may return an
+ unexpected value and this object cannot be used in calculation of how long
+ it is overdue. If that functionality is required, use
+ QDeadlineTimer::current() and add time to it.
+
+ \sa hasExpired(), isForever(), remainingTime<Duration>(), setRemainingTime()
+*/
+
+/*!
+ \fn void QDeadlineTimer::setDeadline(std::chrono::time_point<Clock, Duration> deadline, Qt::TimerType type)
+
+ Sets this QDeadlineTimer to the deadline marked by \a deadline time
+ point, converting from the clock source \c{Clock} to Qt's internal clock
+ source (see QElapsedTimer::clcokType()).
+
+ If \a deadline is in the past, this QDeadlineTimer object is set to
+ expired, whereas if \a deadline is equal to \c{Duration::max()}, then this
+ object is set to never expire.
+
+ The timer type for this QDeadlineTimer object will be set to \a timerType type.
+
+ \sa hasExpired(), isForever(), remainingTime<Duration>(),
+*/
+
+/*!
+ Sets the remaining time for this QDeadlineTimer object to \a msecs
+ milliseconds from now, if \a msecs has a positive value. If \a msecs is
+ zero, this QDeadlineTimer object will be marked as expired, whereas a value
+ of -1 will set it to never expire.
+
+ The timer type for this QDeadlineTimer object will be set to \a timerType type.
+
+ \sa setPreciseRemainingTime(), hasExpired(), isForever(), remainingTime()
+*/
+void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ if (msecs == -1)
+ *this = QDeadlineTimer(Forever, timerType);
+ else
+ setPreciseRemainingTime(0, msecs * 1000 * 1000, timerType);
+}
+
+/*!
+ Sets the remaining time for this QDeadlineTimer object to \a secs seconds
+ plus \a nsecs nanoseconds from now, if \a secs has a positive value. If \a
+ secs is -1, this QDeadlineTimer will be set it to never expire. If both
+ parameters are zero, this QDeadlineTimer will be marked as expired.
+
+ The timer type for this QDeadlineTimer object will be set to \a timerType type.
+
+ \sa setRemainingTime(), hasExpired(), isForever(), remainingTime()
+*/
+void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ if (secs == -1) {
+ *this = QDeadlineTimer(Forever, timerType);
+ return;
+ }
+
+ *this = current(timerType);
+ if (QDeadlineTimerNanosecondsInT2) {
+ t1 += secs + toSecsAndNSecs(nsecs).first;
+ t2 += toSecsAndNSecs(nsecs).second;
+ if (t2 > 1000*1000*1000) {
+ t2 -= 1000*1000*1000;
+ ++t1;
+ }
+ } else {
+ t1 += secs * 1000 * 1000 * 1000 + nsecs;
+ }
+}
+
+/*!
+ \overload
+ \fn void QDeadlineTimer::setRemainingTime(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type)
+
+ Sets the remaining time for this QDeadlineTimer object to \a remaining. If
+ \a remaining is zero or negative, this QDeadlineTimer object will be mark
+ as expired, whereas if \a remaining is equal to \c{duration::max()}, the
+ object will be set to never expire.
+
+ The timer type for this QDeadlineTimer object will be set to \a timerType type.
+
+ This function can be used with C++14's user-defined literals for time, such as in:
+
+ \code
+ using namespace std::chrono;
+ deadline.setRemainingTime(250ms);
+ \endcode
+
+ \sa setDeadline(), remainingTime<Duration>(), hasExpired(), isForever()
+*/
+
+/*!
+ \fn void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, unsigned nsecs, Qt::TimerType type)
+
+ Sets the remaining time for this QDeadlineTimer object to \a secs seconds
+ and \a nsecs nanoseconds from now, if \a secs is a positive value. If both
+ values are zero, this QDeadlineTimer object will be marked as expired,
+ whereas if \a secs is -1, it will set it to never expire.
+
+ If value of \a nsecs is more than 1 billion nanoseconds (1 second), this
+ function will adjust \a secs accordingly.
+
+ The timer type for this QDeadlineTimer object will be set to \a timerType type.
+
+ \sa setRemainingTime(), hasExpired(), isForever(), remainingTime()
+*/
+
+/*!
+ \overload
+ \fn Duration QDeadlineTimer::remainingTime() const
+
+ Returns a \c{std::chrono::duration} object of type \c{Duration} containing
+ the remaining time in this QDeadlineTimer, if it still has time left. If
+ the deadline has passed, this returns \c{Duration::zero()}, whereas if the
+ object is set to never expire, it returns \c{Duration::max()} (instead of
+ -1).
+
+ It is not possible to obtain the overdue time for expired timers with this
+ function. To do that, see deadline().
+
+ \note The overload of this function without template parameter always
+ returns milliseconds.
+
+ \sa setRemainingTime(), deadline<Clock, Duration>()
+*/
+
+/*!
+ \overload
+ \fn std::chrono::time_point<Clock, Duration> QDeadlineTimer::deadline() const
+
+ Returns the absolute time point for the deadline stored in QDeadlineTimer
+ object as a \c{std::chrono::time_point} object. The template parameter
+ \c{Clock} is mandatory and indicates which of the C++ timekeeping clocks to
+ use as a reference. The value will be in the past if this QDeadlineTimer
+ has expired.
+
+ If this QDeadlineTimer never expires, this function returns
+ \c{std::chrono::time_point<Clock, Duration>::max()}.
+
+ This function can be used to calculate the amount of time a timer is
+ overdue, by subtracting the current time point of the reference clock, as
+ in the following example:
+
+ \code
+ auto realTimeLeft = std::chrono::nanoseconds::max();
+ auto tp = deadline.deadline<std::chrono::steady_clock>();
+ if (tp != std::chrono::steady_clock::max())
+ realTimeLeft = tp - std::chrono::steady_clock::now();
+ \endcode
+
+ \note Timers that were created as expired have an indetermine time point in
+ the past as their deadline, so the above calculation may not work.
+
+ \sa remainingTime(), deadlineNSecs(), setDeadline()
+*/
+
+/*!
+ \fn bool QDeadlineTimer::isForever() const
+
+ Returns true if this QDeadlineTimer object never expires, false otherwise.
+ For timers that never expire, remainingTime() always returns -1 and
+ deadline() returns the maximum value.
+
+ \sa ForeverConstant, hasExpired(), remainingTime()
+*/
+
+/*!
+ Returns true if this QDeadlineTimer object has expired, false if there
+ remains time left. For objects that have expired, remainingTime() will
+ return zero and deadline() will return a time point in the past.
+
+ QDeadlineTimer objects created with the \ref{ForeverConstant} never expire
+ and this function always returns false for them.
+
+ \sa isForever(), remainingTime()
+*/
+bool QDeadlineTimer::hasExpired() const Q_DECL_NOTHROW
+{
+ if (isForever())
+ return false;
+ return *this <= current(timerType());
+}
+
+/*!
+ \fn Qt::TimerType QDeadlineTimer::timerType() const Q_DECL_NOTHROW
+
+ Returns the timer type is active for this object.
+
+ \sa setTimerType()
+*/
+
+/*!
+ Changes the timer type for this object to \a timerType.
+
+ The behavior for each possible value of \a timerType is operating-system
+ dependent. Qt::PreciseTimer will use the most precise timer that Qt can
+ find, with resolution of 1 millisecond or better, whereas QDeadlineTimer
+ will try to use a more coarse timer for Qt::CoarseTimer and
+ Qt::VeryCoarseTimer.
+
+ \sa timerType()
+ */
+void QDeadlineTimer::setTimerType(Qt::TimerType timerType)
+{
+ type = timerType;
+}
+
+/*!
+ Returns the remaining time in this QDeadlineTimer object in milliseconds.
+ If the timer has already expired, this function will return zero and it is
+ not possible to obtain the amount of time overdue with this function (to do
+ that, see deadline()). If the timer was set to never expire, this function
+ returns -1.
+
+ This function is suitable for use in Qt APIs that take a millisecond
+ timeout, such as the many \ref QIODevice \c waitFor functions or the timed
+ lock functions in \ref QMutex, \ref QWaitCondition, \ref QSemaphore, or
+ \ref QReadWriteLock. For example:
+
+ \code
+ mutex.tryLock(deadline.remainingTime());
+ \code
+
+ \sa remainingTimeNSecs(), isForever(), hasExpired()
+*/
+qint64 QDeadlineTimer::remainingTime() const Q_DECL_NOTHROW
+{
+ qint64 ns = remainingTimeNSecs();
+ return ns <= 0 ? ns : ns / (1000 * 1000);
+}
+
+/*!
+ Returns the remaining time in this QDeadlineTimer object in nanoseconds. If
+ the timer has already expired, this function will return zero and it is not
+ possible to obtain the amount of time overdue with this function. If the
+ timer was set to never expire, this function returns -1.
+
+ \sa remainingTime(), isForever(), hasExpired()
+*/
+qint64 QDeadlineTimer::remainingTimeNSecs() const Q_DECL_NOTHROW
+{
+ if (isForever())
+ return -1;
+ qint64 raw = rawRemainingTimeNSecs();
+ return raw < 0 ? 0 : raw;
+}
+
+/*!
+ \internal
+ Same as remainingTimeNSecs, but may return negative remaining times. Does
+ not deal with Forever.
+*/
+qint64 QDeadlineTimer::rawRemainingTimeNSecs() const Q_DECL_NOTHROW
+{
+ QDeadlineTimer now = current(timerType());
+ if (QDeadlineTimerNanosecondsInT2)
+ return (t1 - now.t1) * (1000*1000*1000) + t2 - now.t2;
+ return t1 - now.t1;
+}
+
+/*!
+ Returns the absolute time point for the deadline stored in QDeadlineTimer
+ object, calculated in milliseconds relative to the reference clock, the
+ same as QElapsedTimer::msecsSinceReference(). The value will be in the past
+ if this QDeadlineTimer has expired.
+
+ If this QDeadlineTimer never expires, this function returns
+ \c{std::numeric_limits<qint64>::max()}.
+
+ This function can be used to calculate the amount of time a timer is
+ overdue, by subtracting QDeadlineTimer::current() or
+ QElapsedTimer::msecsSinceReference(), as in the following example:
+
+ \code
+ qint64 realTimeLeft = deadline.deadline();
+ if (realTimeLeft != (std::numeric_limits<qint64>::max)()) {
+ realTimeLeft -= QDeadlineTimer::current().deadline();
+ // or:
+ //QElapsedTimer timer;
+ //timer.start();
+ //realTimeLeft -= timer.msecsSinceReference();
+ }
+ \endcode
+
+ \note Timers that were created as expired have an indetermine time point in
+ the past as their deadline, so the above calculation may not work.
+
+ \sa remainingTime(), deadlineNSecs(), setDeadline()
+*/
+qint64 QDeadlineTimer::deadline() const Q_DECL_NOTHROW
+{
+ if (isForever())
+ return t1;
+ return deadlineNSecs() / (1000 * 1000);
+}
+
+/*!
+ Returns the absolute time point for the deadline stored in QDeadlineTimer
+ object, calculated in nanoseconds relative to the reference clock, the
+ same as QElapsedTimer::msecsSinceReference(). The value will be in the past
+ if this QDeadlineTimer has expired.
+
+ If this QDeadlineTimer never expires, this function returns
+ \c{std::numeric_limits<qint64>::max()}.
+
+ This function can be used to calculate the amount of time a timer is
+ overdue, by subtracting QDeadlineTimer::current(), as in the following
+ example:
+
+ \code
+ qint64 realTimeLeft = deadline.deadlineNSecs();
+ if (realTimeLeft != std::numeric_limits<qint64>::max())
+ realTimeLeft -= QDeadlineTimer::current().deadlineNSecs();
+ \endcode
+
+ \note Timers that were created as expired have an indetermine time point in
+ the past as their deadline, so the above calculation may not work.
+
+ \sa remainingTime(), deadlineNSecs()
+*/
+qint64 QDeadlineTimer::deadlineNSecs() const Q_DECL_NOTHROW
+{
+ if (isForever())
+ return t1;
+ if (QDeadlineTimerNanosecondsInT2)
+ return t1 * 1000 * 1000 * 1000 + t2;
+ return t1;
+}
+
+/*!
+ Sets the deadline for this QDeadlineTimer object to be the \a msecs
+ absolute time point, counted in milliseconds since the reference clock (the
+ same as QElapsedTimer::msecsSinceReference()), and the timer type to \a
+ timerType. If the value is in the past, this QDeadlineTimer will be marked
+ as expired.
+
+ If \a msecs is \c{std::numeric_limits<qint64>::max()}, this QDeadlineTimer
+ will be set to never expire.
+
+ \sa setPreciseDeadline(), deadline(), deadlineNSecs(), setRemainingTime()
+*/
+void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ if (msecs == (std::numeric_limits<qint64>::max)()) {
+ setPreciseDeadline(msecs, 0, timerType); // msecs == MAX implies Forever
+ } else {
+ setPreciseDeadline(msecs / 1000, msecs % 1000 * 1000 * 1000, timerType);
+ }
+}
+
+/*!
+ Sets the deadline for this QDeadlineTimer object to be \a secs seconds and
+ \a nsecs nanoseconds since the reference clock epoch (the same as
+ QElapsedTimer::msecsSinceReference()), and the timer type to \a timerType.
+ If the value is in the past, this QDeadlineTimer will be marked as expired.
+
+ If \a secs or \a nsecs is \c{std::numeric_limits<qint64>::max()}, this
+ QDeadlineTimer will be set to never expire. If \a nsecs is more than 1
+ billion nanoseconds (1 second), then \a secs will be adjusted accordingly.
+
+ \sa setDeadline(), deadline(), deadlineNSecs(), setRemainingTime()
+*/
+void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs, Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ type = timerType;
+ if (secs == (std::numeric_limits<qint64>::max)() || nsecs == (std::numeric_limits<qint64>::max)()) {
+ *this = QDeadlineTimer(Forever, timerType);
+ } else if (QDeadlineTimerNanosecondsInT2) {
+ t1 = secs + toSecsAndNSecs(nsecs).first;
+ t2 = toSecsAndNSecs(nsecs).second;
+ } else {
+ t1 = secs * (1000*1000*1000) + nsecs;
+ }
+}
+
+/*!
+ Returns a QDeadlineTimer object whose deadline is extended from \a dt's
+ deadline by \a nsecs nanoseconds. If \a dt was set to never expire, this
+ function returns a QDeadlineTimer that will not expire either.
+
+ \note if \a dt was created as expired, its deadline is indeterminate and
+ adding an amount of time may or may not cause it to become unexpired.
+*/
+QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) Q_DECL_NOTHROW
+{
+ if (dt.isForever() || nsecs == (std::numeric_limits<qint64>::max)()) {
+ dt = QDeadlineTimer(Forever, dt.timerType());
+ } else if (QDeadlineTimerNanosecondsInT2) {
+ dt.t1 += toSecsAndNSecs(nsecs).first;
+ dt.t2 += toSecsAndNSecs(nsecs).second;
+ if (dt.t2 > 1000*1000*1000) {
+ dt.t2 -= 1000*1000*1000;
+ ++dt.t1;
+ }
+ } else {
+ dt.t1 += nsecs;
+ }
+ return dt;
+}
+
+/*!
+ \fn QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType)
+
+ Returns a QDeadlineTimer that is expired but is guaranteed to contain the
+ current time. Objects created by this function can participate in the
+ calculation of how long a timer is overdue, using the deadline() function.
+
+ The QDeadlineTimer object will be constructed with a timer type of \a
+ timerType.
+*/
+
+/*!
+ \fn qint64 QDeadlineTimer::resolution(Qt::TimerType timerType)
+
+ Returns the resolution in nanoseconds of the system clock that backs timers
+ of type \a timerType, or 0 if the resolution could not be determined.
+
+ The resolution is not a guarantee that applications will get time values
+ with an accuracy down to that level. It is only the minimum change value
+ that can be expected.
+*/
+
+/*!
+ \fn bool operator==(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 and the deadline in \a d2 are the
+ same, false otherwise. The timer type used to create the two deadlines is
+ ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() == d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn bool operator!=(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 and the deadline in \a d2 are
+ diferent, false otherwise. The timer type used to create the two deadlines
+ is ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() != d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn bool operator<(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 is earlier than the deadline in \a
+ d2, false otherwise. The timer type used to create the two deadlines is
+ ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() < d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn bool operator<=(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 is earlier than or the same as the
+ deadline in \a d2, false otherwise. The timer type used to create the two
+ deadlines is ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() <= d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn bool operator>(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 is later than the deadline in \a
+ d2, false otherwise. The timer type used to create the two deadlines is
+ ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() > d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 is later than or the same as the
+ deadline in \a d2, false otherwise. The timer type used to create the two
+ deadlines is ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() >= d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn QDeadlineTimer operator+(QDeadlineTimer dt, qint64 msecs)
+ \related QDeadlineTimer
+
+ Returns a QDeadlineTimer object whose deadline is \a msecs later than the
+ deadline stored in \a dt. If \a dt is set to never expire, this function
+ returns a QDeadlineTimer that does not expire either.
+
+ To add times of precision greater than 1 millisecond, use addNSecs().
+*/
+
+/*!
+ \fn QDeadlineTimer operator+(qint64 msecs, QDeadlineTimer dt)
+ \related QDeadlineTimer
+
+ Returns a QDeadlineTimer object whose deadline is \a msecs later than the
+ deadline stored in \a dt. If \a dt is set to never expire, this function
+ returns a QDeadlineTimer that does not expire either.
+
+ To add times of precision greater than 1 millisecond, use addNSecs().
+*/
+
+/*!
+ \fn QDeadlineTimer operator-(QDeadlineTimer dt, qint64 msecs)
+ \related QDeadlineTimer
+
+ Returns a QDeadlineTimer object whose deadline is \a msecs before the
+ deadline stored in \a dt. If \a dt is set to never expire, this function
+ returns a QDeadlineTimer that does not expire either.
+
+ To subtract times of precision greater than 1 millisecond, use addNSecs().
+*/
+
+/*!
+ \fn QDeadlineTimer &QDeadlineTimer::operator+=(qint64 msecs)
+
+ Extends this QDeadlineTimer object by \a msecs milliseconds and returns
+ itself. If this object is set to never expire, this function does nothing.
+
+ To add times of precision greater than 1 millisecond, use addNSecs().
+*/
+
+/*!
+ \fn QDeadlineTimer &QDeadlineTimer::operator-=(qint64 msecs)
+
+ Shortens this QDeadlineTimer object by \a msecs milliseconds and returns
+ itself. If this object is set to never expire, this function does nothing.
+
+ To subtract times of precision greater than 1 millisecond, use addNSecs().
+*/
+
+// the rest of the functions are in qelapsedtimer_xxx.cpp
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h
new file mode 100644
index 0000000000..3b97b89359
--- /dev/null
+++ b/src/corelib/kernel/qdeadlinetimer.h
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDEADLINETIMER_H
+#define QDEADLINETIMER_H
+
+#include <QtCore/qelapsedtimer.h>
+#include <QtCore/qmetatype.h>
+#include <QtCore/qnamespace.h>
+
+#ifdef max
+// un-pollute the namespace. We need std::numeric_limits::max() and std::chrono::duration::max()
+# undef max
+#endif
+
+#include <limits>
+
+#if QT_HAS_INCLUDE(<chrono>)
+# include <chrono>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class Q_CORE_EXPORT QDeadlineTimer
+{
+public:
+ enum ForeverConstant { Forever };
+
+ Q_DECL_CONSTEXPR QDeadlineTimer(Qt::TimerType type_ = Qt::CoarseTimer) Q_DECL_NOTHROW
+ : t1(0), t2(0), type(type_) {}
+ Q_DECL_CONSTEXPR QDeadlineTimer(ForeverConstant, Qt::TimerType type_ = Qt::CoarseTimer) Q_DECL_NOTHROW
+ : t1(std::numeric_limits<qint64>::max()), t2(0), type(type_) {}
+ explicit QDeadlineTimer(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW;
+
+ void swap(QDeadlineTimer &other)
+ { qSwap(t1, other.t1); qSwap(t2, other.t2); qSwap(type, other.type); }
+
+ Q_DECL_CONSTEXPR bool isForever() const Q_DECL_NOTHROW
+ { return t1 == (std::numeric_limits<qint64>::max)(); }
+ bool hasExpired() const Q_DECL_NOTHROW;
+
+ Qt::TimerType timerType() const Q_DECL_NOTHROW
+ { return Qt::TimerType(type & 0xff); }
+ void setTimerType(Qt::TimerType type);
+
+ qint64 remainingTime() const Q_DECL_NOTHROW;
+ qint64 remainingTimeNSecs() const Q_DECL_NOTHROW;
+ void setRemainingTime(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW;
+ void setPreciseRemainingTime(qint64 secs, qint64 nsecs = 0,
+ Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW;
+
+ qint64 deadline() const Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION;
+ qint64 deadlineNSecs() const Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION;
+ void setDeadline(qint64 msecs, Qt::TimerType timerType = Qt::CoarseTimer) Q_DECL_NOTHROW;
+ void setPreciseDeadline(qint64 secs, qint64 nsecs = 0,
+ Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW;
+
+ static QDeadlineTimer addNSecs(QDeadlineTimer dt, qint64 nsecs) Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION;
+ static QDeadlineTimer current(Qt::TimerType timerType = Qt::CoarseTimer) Q_DECL_NOTHROW;
+
+ friend bool operator==(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return d1.t1 == d2.t1 && d1.t2 == d2.t2; }
+ friend bool operator!=(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return !(d1 == d2); }
+ friend bool operator<(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return d1.t1 < d2.t1 || (d1.t1 == d2.t1 && d1.t2 < d2.t2); }
+ friend bool operator<=(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return d1 == d2 || d1 < d2; }
+ friend bool operator>(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return d2 < d1; }
+ friend bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return !(d1 < d2); }
+
+ friend QDeadlineTimer operator+(QDeadlineTimer dt, qint64 msecs)
+ { return QDeadlineTimer::addNSecs(dt, msecs * 1000 * 1000); }
+ friend QDeadlineTimer operator+(qint64 msecs, QDeadlineTimer dt)
+ { return dt + msecs; }
+ friend QDeadlineTimer operator-(QDeadlineTimer dt, qint64 msecs)
+ { return dt + (-msecs); }
+ friend qint64 operator-(QDeadlineTimer dt1, QDeadlineTimer dt2)
+ { return (dt1.deadlineNSecs() - dt2.deadlineNSecs()) / (1000 * 1000); }
+ QDeadlineTimer &operator+=(qint64 msecs)
+ { *this = *this + msecs; return *this; }
+ QDeadlineTimer &operator-=(qint64 msecs)
+ { *this = *this + (-msecs); return *this; }
+
+#if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC)
+ template <class Clock, class Duration>
+ QDeadlineTimer(std::chrono::time_point<Clock, Duration> deadline_,
+ Qt::TimerType type_ = Qt::CoarseTimer) : t2(0)
+ { setDeadline(deadline_, type_); }
+ template <class Clock, class Duration>
+ QDeadlineTimer &operator=(std::chrono::time_point<Clock, Duration> deadline_)
+ { setDeadline(deadline_); return *this; }
+
+ template <class Clock, class Duration>
+ void setDeadline(std::chrono::time_point<Clock, Duration> deadline_,
+ Qt::TimerType type_ = Qt::CoarseTimer)
+ { setRemainingTime(deadline_ == deadline_.max() ? Duration::max() : deadline_ - Clock::now(), type_); }
+
+ template <class Clock, class Duration = typename Clock::duration>
+ std::chrono::time_point<Clock, Duration> deadline() const
+ {
+ auto val = std::chrono::nanoseconds(rawRemainingTimeNSecs()) + Clock::now();
+ return std::chrono::time_point_cast<Duration>(val);
+ }
+
+ template <class Rep, class Period>
+ QDeadlineTimer(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type_ = Qt::CoarseTimer)
+ : t2(0)
+ { setRemainingTime(remaining, type_); }
+
+ template <class Rep, class Period>
+ QDeadlineTimer &operator=(std::chrono::duration<Rep, Period> remaining)
+ { setRemainingTime(remaining); return *this; }
+
+ template <class Rep, class Period>
+ void setRemainingTime(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type_ = Qt::CoarseTimer)
+ {
+ if (remaining == remaining.max())
+ *this = QDeadlineTimer(Forever, type_);
+ else
+ setPreciseRemainingTime(0, std::chrono::nanoseconds(remaining).count(), type_);
+ }
+
+ std::chrono::nanoseconds remainingTimeAsDuration() const Q_DECL_NOTHROW
+ {
+ if (isForever())
+ return std::chrono::nanoseconds::max();
+ qint64 nsecs = rawRemainingTimeNSecs();
+ if (nsecs <= 0)
+ return std::chrono::nanoseconds::zero();
+ return std::chrono::nanoseconds(nsecs);
+ }
+
+ template <class Rep, class Period>
+ friend QDeadlineTimer operator+(QDeadlineTimer dt, std::chrono::duration<Rep, Period> value)
+ { return QDeadlineTimer::addNSecs(dt, std::chrono::duration_cast<std::chrono::nanoseconds>(value).count()); }
+ template <class Rep, class Period>
+ friend QDeadlineTimer operator+(std::chrono::duration<Rep, Period> value, QDeadlineTimer dt)
+ { return dt + value; }
+ template <class Rep, class Period>
+ friend QDeadlineTimer operator+=(QDeadlineTimer &dt, std::chrono::duration<Rep, Period> value)
+ { return dt = dt + value; }
+#endif
+
+private:
+ qint64 t1;
+ unsigned t2;
+ unsigned type;
+
+ qint64 rawRemainingTimeNSecs() const Q_DECL_NOTHROW;
+};
+
+Q_DECLARE_SHARED(QDeadlineTimer)
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeadlineTimer)
+
+#endif // QDEADLINETIMER_H
diff --git a/src/corelib/io/qurl_mac.mm b/src/corelib/kernel/qdeadlinetimer_p.h
index 04d05f1b23..46e12de6c1 100644
--- a/src/corelib/io/qurl_mac.mm
+++ b/src/corelib/kernel/qdeadlinetimer_p.h
@@ -37,38 +37,34 @@
**
****************************************************************************/
-#include "qurl.h"
+#ifndef QDEADLINETIMER_P_H
+#define QDEADLINETIMER_P_H
-#ifdef Q_OS_MAC
-#include <Foundation/Foundation.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QUrl QUrl::fromCFURL(CFURLRef url)
-{
- return QUrl(QString::fromCFString(CFURLGetString(url)));
-}
+//
+// 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.
+//
-CFURLRef QUrl::toCFURL() const
-{
- CFURLRef url = 0;
- CFStringRef str = toString(FullyEncoded).toCFString();
- if (str) {
- url = CFURLCreateWithString(0, str, 0);
- CFRelease(str);
- }
- return url;
-}
+#include <QtCore/qglobal.h>
-QUrl QUrl::fromNSURL(const NSURL *url)
-{
- return QUrl(QString::fromNSString([url absoluteString]));
-}
+QT_BEGIN_NAMESPACE
-NSURL *QUrl::toNSURL() const
-{
- return [NSURL URLWithString:toString(FullyEncoded).toNSString()];
-}
+enum {
+#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
+ // t1 contains seconds and t2 contains nanoseconds
+ QDeadlineTimerNanosecondsInT2 = 1
+#else
+ // t1 contains nanoseconds, t2 is always zero
+ QDeadlineTimerNanosecondsInT2 = 0
+#endif
+};
QT_END_NAMESPACE
+
+#endif
diff --git a/src/corelib/tools/qelapsedtimer.cpp b/src/corelib/kernel/qelapsedtimer.cpp
index addecc0236..5e9d1317ac 100644
--- a/src/corelib/tools/qelapsedtimer.cpp
+++ b/src/corelib/kernel/qelapsedtimer.cpp
@@ -83,6 +83,9 @@ QT_BEGIN_NAMESPACE
\snippet qelapsedtimer/main.cpp 2
+ It is often more convenient to use \ref{QDeadlineTimer} in this case, which
+ counts towards a timeout in the future instead of tracking elapsed time.
+
\section1 Reference Clocks
QElapsedTimer will use the platform's monotonic reference clock in all
@@ -120,7 +123,7 @@ QT_BEGIN_NAMESPACE
The information on which clocks types may overflow and how to remedy that
issue is documented along with the clock types.
- \sa QTime, QTimer
+ \sa QTime, QTimer, QDeadlineTimer
*/
/*!
@@ -255,7 +258,7 @@ bool QElapsedTimer::isValid() const Q_DECL_NOTHROW
The value of \a timeout can be -1 to indicate that this timer does not
expire, in which case this function will always return false.
- \sa elapsed()
+ \sa elapsed(), QDeadlineTimer
*/
bool QElapsedTimer::hasExpired(qint64 timeout) const Q_DECL_NOTHROW
{
diff --git a/src/corelib/tools/qelapsedtimer.h b/src/corelib/kernel/qelapsedtimer.h
index 7954b41bf4..7954b41bf4 100644
--- a/src/corelib/tools/qelapsedtimer.h
+++ b/src/corelib/kernel/qelapsedtimer.h
diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/kernel/qelapsedtimer_generic.cpp
index 29ba1517ed..fdeb385188 100644
--- a/src/corelib/tools/qelapsedtimer_generic.cpp
+++ b/src/corelib/kernel/qelapsedtimer_generic.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qelapsedtimer.h"
+#include "qdeadlinetimer.h"
#include "qdatetime.h"
QT_BEGIN_NAMESPACE
@@ -201,4 +202,12 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW
return v1.t1 < v2.t1;
}
+QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ QDeadlineTimer result;
+ result.t1 = QDateTime::currentMSecsSinceEpoch() * 1000 * 1000;
+ result.type = timerType;
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qelapsedtimer_mac.cpp b/src/corelib/kernel/qelapsedtimer_mac.cpp
index 886e0f41b2..7490693991 100644
--- a/src/corelib/tools/qelapsedtimer_mac.cpp
+++ b/src/corelib/kernel/qelapsedtimer_mac.cpp
@@ -41,6 +41,8 @@
#define _POSIX_C_SOURCE 200809L
#include "qelapsedtimer.h"
+#include "qdeadlinetimer.h"
+#include "qdeadlinetimer_p.h"
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
@@ -50,6 +52,12 @@
QT_BEGIN_NAMESPACE
+#ifdef __LP64__
+typedef __int128_t LargeInt;
+#else
+typedef qint64 LargeInt;
+#endif
+
QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW
{
return MachAbsoluteTime;
@@ -65,13 +73,13 @@ static qint64 absoluteToNSecs(qint64 cpuTime)
{
if (info.denom == 0)
mach_timebase_info(&info);
-#ifdef __LP64__
- __uint128_t nsecs = static_cast<__uint128_t>(cpuTime) * info.numer / info.denom;
- return static_cast<qint64>(nsecs);
-#else
- qint64 nsecs = cpuTime * info.numer / info.denom;
+
+ // don't do multiplication & division if those are equal
+ // (mathematically it would be the same, but it's computationally expensive)
+ if (info.numer == info.denom)
+ return cpuTime;
+ qint64 nsecs = LargeInt(cpuTime) * info.numer / info.denom;
return nsecs;
-#endif
}
static qint64 absoluteToMSecs(qint64 cpuTime)
@@ -146,4 +154,13 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW
return v1.t1 < v2.t1;
}
+QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2);
+ QDeadlineTimer result;
+ result.type = timerType;
+ result.t1 = absoluteToNSecs(mach_absolute_time());
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/kernel/qelapsedtimer_unix.cpp
index e2c3ae6280..e166d4e3d2 100644
--- a/src/corelib/tools/qelapsedtimer_unix.cpp
+++ b/src/corelib/kernel/qelapsedtimer_unix.cpp
@@ -39,6 +39,8 @@
****************************************************************************/
#include "qelapsedtimer.h"
+#include "qdeadlinetimer.h"
+#include "qdeadlinetimer_p.h"
#if defined(Q_OS_VXWORKS)
#include "qfunctions_vxworks.h"
#else
@@ -248,4 +250,16 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW
return v1.t1 < v2.t1 || (v1.t1 == v2.t1 && v1.t2 < v2.t2);
}
+QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2);
+ QDeadlineTimer result;
+ qint64 cursec, curnsec;
+ do_gettime(&cursec, &curnsec);
+ result.t1 = cursec;
+ result.t2 = curnsec;
+ result.type = timerType;
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/kernel/qelapsedtimer_win.cpp
index 734aaf80f2..0c380b2f6a 100644
--- a/src/corelib/tools/qelapsedtimer_win.cpp
+++ b/src/corelib/kernel/qelapsedtimer_win.cpp
@@ -38,37 +38,25 @@
****************************************************************************/
#include "qelapsedtimer.h"
+#include "qdeadlinetimer.h"
+#include "qdeadlinetimer_p.h"
#include <qt_windows.h>
-typedef ULONGLONG (WINAPI *PtrGetTickCount64)(void);
-#if defined(Q_OS_WINRT)
- static const PtrGetTickCount64 ptrGetTickCount64 = &GetTickCount64;
-#else
- static PtrGetTickCount64 ptrGetTickCount64 = 0;
-#endif
-
QT_BEGIN_NAMESPACE
// Result of QueryPerformanceFrequency, 0 indicates that the high resolution timer is unavailable
static quint64 counterFrequency = 0;
-static void resolveLibs()
+static void resolveCounterFrequency()
{
static bool done = false;
if (done)
return;
-#if !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
- // try to get GetTickCount64 from the system
- HMODULE kernel32 = GetModuleHandleW(L"kernel32");
- if (!kernel32)
- return;
- ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, "GetTickCount64");
-#endif // !Q_OS_WINRT && !Q_OS_WINCE
-
// Retrieve the number of high-resolution performance counter ticks per second
LARGE_INTEGER frequency;
if (!QueryPerformanceFrequency(&frequency)) {
+ qFatal("QueryPerformanceFrequency failed, even though Microsoft documentation promises it wouldn't.");
counterFrequency = 0;
} else {
counterFrequency = frequency.QuadPart;
@@ -90,37 +78,33 @@ static inline qint64 ticksToNanoseconds(qint64 ticks)
}
}
+static inline qint64 nanosecondsToTicks(qint64 nsec)
+{
+ if (counterFrequency > 0) {
+ // QueryPerformanceCounter uses an arbitrary frequency
+ return double(nsec) * counterFrequency / 1000000000.;
+ } else {
+ // GetTickCount(64) uses milliseconds
+ return nsec / 1000000;
+ }
+}
+
static quint64 getTickCount()
{
- resolveLibs();
+ resolveCounterFrequency();
// This avoids a division by zero and disables the high performance counter if it's not available
if (counterFrequency > 0) {
LARGE_INTEGER counter;
- if (QueryPerformanceCounter(&counter)) {
- return counter.QuadPart;
- } else {
- qWarning("QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded.");
- return 0;
- }
+ bool ok = QueryPerformanceCounter(&counter);
+ Q_ASSERT_X(ok, "QElapsedTimer::start()",
+ "QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded.");
+ Q_UNUSED(ok);
+ return counter.QuadPart;
}
-#ifndef Q_OS_WINRT
- if (ptrGetTickCount64)
- return ptrGetTickCount64();
-
- static quint32 highdword = 0;
- static quint32 lastval = 0;
- quint32 val = GetTickCount();
- if (val < lastval)
- ++highdword;
- lastval = val;
- return val | (quint64(highdword) << 32);
-#else // !Q_OS_WINRT
- // ptrGetTickCount64 is always set on WinRT but GetTickCount is not available
- return ptrGetTickCount64();
-#endif // Q_OS_WINRT
+ return GetTickCount64();
}
quint64 qt_msectime()
@@ -130,7 +114,7 @@ quint64 qt_msectime()
QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW
{
- resolveLibs();
+ resolveCounterFrequency();
if (counterFrequency > 0)
return PerformanceCounter;
@@ -190,4 +174,13 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW
return (v1.t1 - v2.t1) < 0;
}
+QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2);
+ QDeadlineTimer result;
+ result.t1 = ticksToNanoseconds(getTickCount());
+ result.type = timerType;
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qeventdispatcher_cf.mm b/src/corelib/kernel/qeventdispatcher_cf.mm
index 55f27a5b60..eecc72fd94 100644
--- a/src/corelib/kernel/qeventdispatcher_cf.mm
+++ b/src/corelib/kernel/qeventdispatcher_cf.mm
@@ -51,6 +51,8 @@
#ifdef Q_OS_OSX
# include <AppKit/NSApplication.h>
+#elif defined(Q_OS_WATCHOS)
+# include <WatchKit/WatchKit.h>
#else
# include <UIKit/UIApplication.h>
#endif
@@ -75,6 +77,8 @@ QT_USE_NAMESPACE
name:nil
#ifdef Q_OS_OSX
object:[NSApplication sharedApplication]];
+#elif defined(Q_OS_WATCHOS)
+ object:[WKExtension sharedExtension]];
#else
object:[UIApplication sharedApplication]];
#endif
@@ -210,6 +214,13 @@ QEventDispatcherCoreFoundation::~QEventDispatcherCoreFoundation()
m_cfSocketNotifier.removeSocketNotifiers();
}
+QEventLoop *QEventDispatcherCoreFoundation::currentEventLoop() const
+{
+ QEventLoop *eventLoop = QThreadData::current()->eventLoops.top();
+ Q_ASSERT(eventLoop);
+ return eventLoop;
+}
+
/*!
Processes all pending events that match \a flags until there are no
more events to process. Returns \c true if pending events were handled;
@@ -302,10 +313,7 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
// to exit, and then unwind back to the previous event loop which will break
// immediately, since it has already been exited.
- QEventLoop *currentEventLoop = QThreadData::current()->eventLoops.top();
- Q_ASSERT(currentEventLoop);
-
- if (!currentEventLoop->isRunning()) {
+ if (!currentEventLoop()->isRunning()) {
qEventDispatcherDebug() << "Top level event loop was exited";
break;
} else {
diff --git a/src/corelib/kernel/qeventdispatcher_cf_p.h b/src/corelib/kernel/qeventdispatcher_cf_p.h
index c2592cacc8..e6581e2bac 100644
--- a/src/corelib/kernel/qeventdispatcher_cf_p.h
+++ b/src/corelib/kernel/qeventdispatcher_cf_p.h
@@ -228,6 +228,8 @@ public:
void flush();
protected:
+ QEventLoop *currentEventLoop() const;
+
virtual bool processPostedEvents();
struct ProcessEventsState
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 166e509635..1a0efae2dc 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -55,7 +55,6 @@
QT_BEGIN_NAMESPACE
-HINSTANCE qWinAppInst();
extern uint qGlobalPostedEventsCount();
#ifndef TIME_KILL_SYNCHRONOUS
@@ -63,11 +62,7 @@ extern uint qGlobalPostedEventsCount();
#endif
#ifndef QS_RAWINPUT
-# ifdef Q_OS_WINCE
-# define QS_RAWINPUT 0x0000
-# else
# define QS_RAWINPUT 0x0400
-# endif
#endif
#ifndef WM_TOUCH
@@ -89,230 +84,14 @@ enum {
SendPostedEventsWindowsTimerId = ~1u
};
-#if defined(Q_OS_WINCE)
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <winsock.h>
-QT_END_INCLUDE_NAMESPACE
-// Asynchronous Winsocks ------------------------------------------
-#ifndef QT_NO_THREAD
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <qthread.h>
-#include <qmap.h>
-#include <qmutex.h>
-QT_END_INCLUDE_NAMESPACE
-
-//#define QCE_ASYNC_DEBUG
-
-namespace {
- class SocketAsyncHandler;
-
- class SocketAsyncHandler : public QThread
- {
- public:
- SocketAsyncHandler();
- ~SocketAsyncHandler();
- void run();
- void select(SOCKET sock, HWND handle, unsigned int msg, long ev);
- void removeSelect(SOCKET sock);
- void safeRemove(SOCKET sock);
- private:
- struct SockInfo {
- HWND handle;
- unsigned int msg;
- long ev;
- };
- QMap<SOCKET, SockInfo> sockets;
- QMutex mutex;
- QWaitCondition cond;
- bool supposedToDie;
- };
-
- SocketAsyncHandler::SocketAsyncHandler()
- : supposedToDie(false)
- {
- }
-
- SocketAsyncHandler::~SocketAsyncHandler()
- {
- mutex.lock();
- supposedToDie = true;
- mutex.unlock();
- cond.wakeOne();
- wait();
- while (sockets.size() > 0)
- removeSelect(sockets.begin().key());
- }
-
- void SocketAsyncHandler::removeSelect(SOCKET sock)
- {
- if (!sockets.contains(sock))
- return;
- sockets.remove(sock);
- return;
- }
-
- void SocketAsyncHandler::safeRemove(SOCKET sock)
- {
- QMutexLocker locker(&mutex);
- removeSelect(sock);
- }
-
- void SocketAsyncHandler::select(SOCKET sock, HWND handle, unsigned int msg, long ev)
- {
- QMutexLocker locker(&mutex);
-
- if (sockets.contains(sock))
- sockets.remove(sock);
-
- SockInfo info;
- info.handle = handle;
- info.msg = msg;
- info.ev = ev;
- sockets.insert(sock, info);
- cond.wakeOne();
- }
-
- void SocketAsyncHandler::run()
- {
- do {
- mutex.lock();
-
- while (!supposedToDie && sockets.isEmpty()) {
- cond.wait(&mutex);
- }
-
- if (supposedToDie) {
- mutex.unlock();
- break;
- }
-
- // Copy current items to reduce lock time
- // and to be able to use SendMessage
- QMap<SOCKET, SockInfo> currentSockets = sockets;
- mutex.unlock();
-
- fd_set readS, writeS, exS;
- FD_ZERO(&readS);
- FD_ZERO(&writeS);
- FD_ZERO(&exS);
-
- int maxFd = 0;
-
- for (QMap<SOCKET, SockInfo>::iterator it = currentSockets.begin(); it != currentSockets.end(); ++it) {
- const SockInfo &info = it.value();
- int socket = it.key();
- maxFd = qMax(maxFd, socket);
-
- if ((info.ev & FD_READ) || (info.ev & FD_CLOSE) || (info.ev & FD_ACCEPT))
- FD_SET(socket, &readS);
- if ((info.ev & FD_WRITE)|| (info.ev & FD_CONNECT))
- FD_SET(socket, &writeS);
- if (info.ev & FD_OOB)
- FD_SET(socket, &exS);
- }
-
- timeval timeout;
- timeout.tv_sec = 0;
- timeout.tv_usec = 50000;
- int result = ::select(maxFd + 1, &readS, &writeS, &exS, &timeout);
- if (result > 0) {
- HWND handle;
- unsigned int tmpMsg;
- SOCKET sock;
- HRESULT ret;
- for (QMap<SOCKET, SockInfo>::const_iterator it = currentSockets.constBegin();
- it != currentSockets.constEnd(); ++it) {
- handle = (*it).handle;
- tmpMsg = (*it).msg;
- sock = it.key();
- if (FD_ISSET(sock, &readS))
- ret = SendMessage(handle, tmpMsg, sock, FD_READ);
-
- if (FD_ISSET(sock, &writeS))
- ret = SendMessage(handle, tmpMsg, sock, FD_WRITE);
-
- if (FD_ISSET(sock, &exS))
- ret = SendMessage(handle, tmpMsg, sock, FD_OOB);
- }
- }
-
-#ifdef QCE_ASYNC_DEBUG
- else if (result == 0) { //timeout
- qDebug(" WSAAsync select timeout");
- } else if (result < 0) { // SocketError
- // This might happen because of two reasons
- // 1. We already closed a socket in between the copy and the select
- // and thus select() returns an error
- // 2. Something is really wrong, then
- // ### Loop on all descriptors, try to select and remove the
- // ### broken one.
- qWarning("WSAAsync select error %d", WSAGetLastError());
- }
-#endif
- } while(true);
- }
-} // namespace
-
-Q_GLOBAL_STATIC(SocketAsyncHandler, qt_async_handler)
-
-int WSAAsyncSelect(SOCKET sock, HWND handle, unsigned int msg, long ev)
-{
- if (sock == 0 || handle == 0 || handle == INVALID_HANDLE_VALUE) {
- WSASetLastError(WSAEINVAL);
- return SOCKET_ERROR;
- }
-
- if (msg == 0 && ev == 0)
- qt_async_handler()->safeRemove(sock);
- else
- qt_async_handler()->select(sock, handle, msg, ev);
-
- qt_async_handler()->start(QThread::LowPriority);
- WSASetLastError(0);
- return 0;
-}
-#else // QT_NO_THREAD
-int WSAAsyncSelect(SOCKET, HWND, unsigned int, long)
-{
- return SOCKET_ERROR;
-}
-#endif
-#endif // Q_OS_WINCE
-
class QEventDispatcherWin32Private;
#if !defined(DWORD_PTR) && !defined(Q_OS_WIN64)
#define DWORD_PTR DWORD
#endif
-typedef MMRESULT(WINAPI *ptimeSetEvent)(UINT, UINT, LPTIMECALLBACK, DWORD_PTR, UINT);
-typedef MMRESULT(WINAPI *ptimeKillEvent)(UINT);
-
-static ptimeSetEvent qtimeSetEvent = 0;
-static ptimeKillEvent qtimeKillEvent = 0;
-
LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
-static void resolveTimerAPI()
-{
- static bool triedResolve = false;
- if (!triedResolve) {
-#ifndef QT_NO_THREAD
- QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
- if (triedResolve)
- return;
-#endif
- triedResolve = true;
-#if !defined(Q_OS_WINCE)
- qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeSetEvent");
- qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeKillEvent");
-#else
- qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeSetEvent");
- qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeKillEvent");
-#endif
- }
-}
-
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
: threadId(GetCurrentThreadId()), interrupt(false), closingDown(false), internalHwnd(0),
getMessageHook(0), serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0),
@@ -321,7 +100,6 @@ QEventDispatcherWin32Private::QEventDispatcherWin32Private()
, activateNotifiersPosted(false)
#endif
{
- resolveTimerAPI();
}
QEventDispatcherWin32Private::~QEventDispatcherWin32Private()
@@ -502,11 +280,7 @@ LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
}
}
}
-#ifdef Q_OS_WINCE
- return 0;
-#else
return q->d_func()->getMessageHook ? CallNextHookEx(0, code, wp, lp) : 0;
-#endif
}
// Provide class name and atom for the message window used by
@@ -535,7 +309,7 @@ QWindowsMessageWindowClassContext::QWindowsMessageWindowClassContext()
wc.lpfnWndProc = qt_internal_proc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
- wc.hInstance = qWinAppInst();
+ wc.hInstance = GetModuleHandle(0);
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = 0;
@@ -552,7 +326,7 @@ QWindowsMessageWindowClassContext::QWindowsMessageWindowClassContext()
QWindowsMessageWindowClassContext::~QWindowsMessageWindowClassContext()
{
if (className) {
- UnregisterClass(className, qWinAppInst());
+ UnregisterClass(className, GetModuleHandle(0));
delete [] className;
}
}
@@ -564,18 +338,13 @@ static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatch
QWindowsMessageWindowClassContext *ctx = qWindowsMessageWindowClassContext();
if (!ctx->atom)
return 0;
-#ifdef Q_OS_WINCE
- HWND parent = 0;
-#else
- HWND parent = HWND_MESSAGE;
-#endif
HWND wnd = CreateWindow(ctx->className, // classname
ctx->className, // window name
0, // style
0, 0, 0, 0, // geometry
- parent, // parent
+ HWND_MESSAGE, // parent
0, // menu handle
- qWinAppInst(), // application
+ GetModuleHandle(0), // application
0); // windows creation data.
if (!wnd) {
@@ -609,24 +378,27 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t)
Q_Q(QEventDispatcherWin32);
- int ok = 0;
+ bool ok = false;
calculateNextTimeout(t, qt_msectime());
uint interval = t->interval;
if (interval == 0u) {
// optimization for single-shot-zero-timer
QCoreApplication::postEvent(q, new QZeroTimerEvent(t->timerId));
- ok = 1;
- } else if ((interval < 20u || t->timerType == Qt::PreciseTimer) && qtimeSetEvent) {
- ok = t->fastTimerId = qtimeSetEvent(interval, 1, qt_fast_timer_proc, (DWORD_PTR)t,
- TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
+ ok = true;
+ } else if (interval < 20u || t->timerType == Qt::PreciseTimer) {
+ // 3/2016: Although MSDN states timeSetEvent() is deprecated, the function
+ // is still deemed to be the most reliable precision timer.
+ t->fastTimerId = timeSetEvent(interval, 1, qt_fast_timer_proc, DWORD_PTR(t),
+ TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
+ ok = t->fastTimerId;
}
- if (ok == 0) {
+ if (!ok) {
// user normal timers for (Very)CoarseTimers, or if no more multimedia timers available
ok = SetTimer(internalHwnd, t->timerId, interval, 0);
}
- if (ok == 0)
+ if (!ok)
qErrnoWarning("QEventDispatcherWin32::registerTimer: Failed to create a timer");
}
@@ -635,7 +407,7 @@ void QEventDispatcherWin32Private::unregisterTimer(WinTimerInfo *t)
if (t->interval == 0) {
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
} else if (t->fastTimerId != 0) {
- qtimeKillEvent(t->fastTimerId);
+ timeKillEvent(t->fastTimerId);
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
} else if (internalHwnd) {
KillTimer(internalHwnd, t->timerId);
@@ -702,7 +474,6 @@ void QEventDispatcherWin32::installMessageHook()
if (d->getMessageHook)
return;
-#ifndef Q_OS_WINCE
// setup GetMessage hook needed to drive our posted events
d->getMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) qt_GetMessageHook, NULL, GetCurrentThreadId());
if (Q_UNLIKELY(!d->getMessageHook)) {
@@ -710,17 +481,14 @@ void QEventDispatcherWin32::installMessageHook()
qFatal("Qt: INTERNAL ERROR: failed to install GetMessage hook: %d, %s",
errorCode, qPrintable(qt_error_string(errorCode)));
}
-#endif
}
void QEventDispatcherWin32::uninstallMessageHook()
{
Q_D(QEventDispatcherWin32);
-#ifndef Q_OS_WINCE
if (d->getMessageHook)
UnhookWindowsHookEx(d->getMessageHook);
-#endif
d->getMessageHook = 0;
}
@@ -1166,11 +934,7 @@ void QEventDispatcherWin32::activateEventNotifiers()
Q_D(QEventDispatcherWin32);
//### this could break if events are removed/added in the activation
for (int i=0; i<d->winEventNotifierList.count(); i++) {
-#if !defined(Q_OS_WINCE)
if (WaitForSingleObjectEx(d->winEventNotifierList.at(i)->handle(), 0, TRUE) == WAIT_OBJECT_0)
-#else
- if (WaitForSingleObject(d->winEventNotifierList.at(i)->handle(), 0) == WAIT_OBJECT_0)
-#endif
d->activateEventNotifier(d->winEventNotifierList.at(i));
}
}
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index a87b56cd38..773315c04f 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -138,7 +138,7 @@ struct WinTimerInfo { // internal timer info
quint64 timeout; // - when to actually fire
QObject *obj; // - object to receive events
bool inTimerEvent;
- int fastTimerId;
+ UINT fastTimerId;
};
class QZeroTimerEvent : public QTimerEvent
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp
index 2ffcf03eb2..3b2321aa49 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt.cpp
+++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp
@@ -95,6 +95,51 @@ private:
std::function<HRESULT()> delegate;
};
+class QWorkHandler : public IWorkItemHandler
+{
+public:
+ QWorkHandler(const std::function<HRESULT()> &delegate)
+ : m_delegate(delegate)
+ {
+ }
+
+ STDMETHODIMP Invoke(ABI::Windows::Foundation::IAsyncAction *operation)
+ {
+ HRESULT res = m_delegate();
+ Q_UNUSED(operation);
+ return res;
+ }
+
+ STDMETHODIMP QueryInterface(REFIID riid, void FAR* FAR* ppvObj)
+ {
+ if (riid == IID_IUnknown || riid == IID_IWorkItemHandler) {
+ *ppvObj = this;
+ AddRef();
+ return NOERROR;
+ }
+ *ppvObj = NULL;
+ return ResultFromScode(E_NOINTERFACE);
+ }
+
+ STDMETHODIMP_(ULONG) AddRef(void)
+ {
+ return ++m_refs;
+ }
+
+ STDMETHODIMP_(ULONG) Release(void)
+ {
+ if (--m_refs == 0) {
+ delete this;
+ return 0;
+ }
+ return m_refs;
+ }
+
+private:
+ std::function<HRESULT()> m_delegate;
+ ULONG m_refs{0};
+};
+
class QEventDispatcherWinRTPrivate : public QAbstractEventDispatcherPrivate
{
Q_DECLARE_PUBLIC(QEventDispatcherWinRT)
@@ -175,48 +220,62 @@ QEventDispatcherWinRT::~QEventDispatcherWinRT()
HRESULT QEventDispatcherWinRT::runOnXamlThread(const std::function<HRESULT ()> &delegate, bool waitForRun)
{
static __declspec(thread) ICoreDispatcher *dispatcher = nullptr;
+ HRESULT hr;
if (!dispatcher) {
- HRESULT hr;
ComPtr<ICoreImmersiveApplication> application;
hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(),
IID_PPV_ARGS(&application));
ComPtr<ICoreApplicationView> view;
hr = application->get_MainView(&view);
- Q_ASSERT_SUCCEEDED(hr);
- ComPtr<ICoreWindow> window;
- hr = view->get_CoreWindow(&window);
- Q_ASSERT_SUCCEEDED(hr);
- if (!window) {
- // In case the application is launched via activation
- // there might not be a main view (eg ShareTarget).
- // Hence iterate through the available views and try to find
- // a dispatcher in there
- ComPtr<IVectorView<CoreApplicationView*>> appViews;
- hr = application->get_Views(&appViews);
+ if (SUCCEEDED(hr) && view) {
+ ComPtr<ICoreWindow> window;
+ hr = view->get_CoreWindow(&window);
Q_ASSERT_SUCCEEDED(hr);
- quint32 count;
- hr = appViews->get_Size(&count);
- Q_ASSERT_SUCCEEDED(hr);
- for (quint32 i = 0; i < count; ++i) {
- hr = appViews->GetAt(i, &view);
+ if (!window) {
+ // In case the application is launched via activation
+ // there might not be a main view (eg ShareTarget).
+ // Hence iterate through the available views and try to find
+ // a dispatcher in there
+ ComPtr<IVectorView<CoreApplicationView*>> appViews;
+ hr = application->get_Views(&appViews);
Q_ASSERT_SUCCEEDED(hr);
- hr = view->get_CoreWindow(&window);
+ quint32 count;
+ hr = appViews->get_Size(&count);
Q_ASSERT_SUCCEEDED(hr);
- if (window) {
- hr = window->get_Dispatcher(&dispatcher);
+ for (quint32 i = 0; i < count; ++i) {
+ hr = appViews->GetAt(i, &view);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = view->get_CoreWindow(&window);
Q_ASSERT_SUCCEEDED(hr);
- if (dispatcher)
- break;
+ if (window) {
+ hr = window->get_Dispatcher(&dispatcher);
+ Q_ASSERT_SUCCEEDED(hr);
+ if (dispatcher)
+ break;
+ }
}
+ } else {
+ hr = window->get_Dispatcher(&dispatcher);
+ Q_ASSERT_SUCCEEDED(hr);
}
- Q_ASSERT(dispatcher);
- } else {
- hr = window->get_Dispatcher(&dispatcher);
- Q_ASSERT_SUCCEEDED(hr);
}
}
- HRESULT hr;
+ if (Q_UNLIKELY(!dispatcher)) {
+ // In case the application is launched in a way that has no UI and
+ // also does not allow to create one, e.g. as a background task.
+ // Features like network operations do still work, others might cause
+ // errors in that case.
+ ComPtr<IThreadPoolStatics> tpStatics;
+ hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPool).Get(),
+ IID_PPV_ARGS(&tpStatics));
+ ComPtr<IAsyncAction> op;
+ hr = tpStatics.Get()->RunAsync(new QWorkHandler(delegate), &op);
+ if (FAILED(hr) || !waitForRun)
+ return hr;
+ return QWinRTFunctions::await(op);
+ }
+
boolean onXamlThread;
hr = dispatcher->get_HasThreadAccess(&onXamlThread);
Q_ASSERT_SUCCEEDED(hr);
diff --git a/src/corelib/kernel/qeventdispatcher_winrt_p.h b/src/corelib/kernel/qeventdispatcher_winrt_p.h
index abcb3bf99c..f69bb9cf3f 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt_p.h
+++ b/src/corelib/kernel/qeventdispatcher_winrt_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qabstracteventdispatcher.h"
#include <qt_windows.h>
diff --git a/src/corelib/kernel/qeventloop_p.h b/src/corelib/kernel/qeventloop_p.h
index 3ce707a6a9..dcbb5c63c6 100644
--- a/src/corelib/kernel/qeventloop_p.h
+++ b/src/corelib/kernel/qeventloop_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include "qcoreapplication.h"
#include "qobject_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qfunctions_fake_env_p.h b/src/corelib/kernel/qfunctions_fake_env_p.h
index 31d8bd2f26..16d18c4d88 100644
--- a/src/corelib/kernel/qfunctions_fake_env_p.h
+++ b/src/corelib/kernel/qfunctions_fake_env_p.h
@@ -44,9 +44,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// 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.
//
diff --git a/src/corelib/kernel/qfunctions_p.h b/src/corelib/kernel/qfunctions_p.h
index 06f5ea09da..715c553dc5 100644
--- a/src/corelib/kernel/qfunctions_p.h
+++ b/src/corelib/kernel/qfunctions_p.h
@@ -51,11 +51,9 @@
#ifndef QFUNCTIONS_P_H
#define QFUNCTIONS_P_H
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
-#if defined(Q_OS_WINCE)
-# include "QtCore/qfunctions_wince.h"
-#elif defined(Q_OS_VXWORKS)
+#if defined(Q_OS_VXWORKS)
# include "QtCore/qfunctions_vxworks.h"
#elif defined(Q_OS_NACL)
# include "QtCore/qfunctions_nacl.h"
diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp
deleted file mode 100644
index 104c6fb27c..0000000000
--- a/src/corelib/kernel/qfunctions_wince.cpp
+++ /dev/null
@@ -1,407 +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$
-**
-****************************************************************************/
-#ifdef _WIN32_WCE //Q_OS_WINCE
-
-#include <windows.h>
-#include <winbase.h>
-#include <kfuncs.h>
-#include <stdio.h>
-#if _WIN32_WCE < 0x800
-# include <altcecrt.h>
-#else
-# include <fcntl.h>
-#endif
-
-#include "qplatformdefs.h"
-#include "qfunctions_wince.h"
-#include "qfunctions_fake_env_p.h"
-#include "qstring.h"
-
-QT_USE_NAMESPACE
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-wchar_t* CEPrivConvCharToWide(const char* string)
-{
- size_t length = strlen(string);
- wchar_t* wString = new wchar_t[length +1];
- for (unsigned int i = 0; i < (length +1); i++)
- wString[i] = string[i];
- return wString;
-}
-
-// Time -------------------------------------------------------------
-time_t qt_wince_ftToTime_t( const FILETIME ft )
-{
- ULARGE_INTEGER li;
- li.LowPart = ft.dwLowDateTime;
- li.HighPart = ft.dwHighDateTime;
-
- // 100-nanosec to seconds
- li.QuadPart /= 10000000;
-
- // FILETIME is from 1601-01-01 T 00:00:00
- // time_t is from 1970-01-01 T 00:00:00
- // 1970 - 1601 = 369 year (89 leap years)
- //
- // ((369y*365d) + 89d) *24h *60min *60sec
- // = 11644473600 seconds
- li.QuadPart -= 11644473600;
- return li.LowPart;
-}
-
-FILETIME qt_wince_time_tToFt( time_t tt )
-{
- ULARGE_INTEGER li;
- li.QuadPart = tt;
- li.QuadPart += 11644473600;
- li.QuadPart *= 10000000;
-
- FILETIME ft;
- ft.dwLowDateTime = li.LowPart;
- ft.dwHighDateTime = li.HighPart;
- return ft;
-}
-
-// File I/O ---------------------------------------------------------
-#if _WIN32_WCE < 0x800
-int errno = 0;
-#endif
-
-int qt_wince__getdrive( void )
-{
- return 1;
-}
-
-int qt_wince__waccess( const wchar_t *path, int pmode )
-{
- DWORD res = GetFileAttributes( path );
- if ( 0xFFFFFFFF == res )
- return -1;
-
- if ( (pmode & W_OK) && (res & FILE_ATTRIBUTE_READONLY) )
- return -1;
-
- if ( (pmode & X_OK) && !(res & FILE_ATTRIBUTE_DIRECTORY) ) {
- QString file = QString::fromWCharArray(path);
- if ( !(file.endsWith(QString::fromLatin1(".exe")) ||
- file.endsWith(QString::fromLatin1(".com"))) )
- return -1;
- }
-
- return 0;
-}
-
-int qt_wince_open( const char *filename, int oflag, int pmode )
-{
- QString fn( QString::fromLatin1(filename) );
- return _wopen( (wchar_t*)fn.utf16(), oflag, pmode );
-}
-
-int qt_wince__wopen( const wchar_t *filename, int oflag, int /*pmode*/ )
-{
- wchar_t *flag;
-
- if ( oflag & _O_APPEND ) {
- if ( oflag & _O_WRONLY ) {
- flag = L"a";
- } else if ( oflag & _O_RDWR ) {
- flag = L"a+";
- }
- } else if (oflag & _O_BINARY) {
- if ( oflag & _O_WRONLY ) {
- flag = L"wb";
- } else if ( oflag & _O_RDWR ) {
- flag = L"w+b"; // slightly different from "r+" where the file must exist
- } else if ( oflag & _O_RDONLY ) {
- flag = L"rb";
- } else {
- flag = L"b";
- }
- } else {
- if ( oflag & _O_WRONLY ) {
- flag = L"wt";
- } else if ( oflag & _O_RDWR ) {
- flag = L"w+t"; // slightly different from "r+" where the file must exist
- } else if ( oflag & _O_RDONLY ) {
- flag = L"rt";
- } else {
- flag = L"t";
- }
- }
-
- int retval = (int)_wfopen( filename, flag );
- return (retval == NULL) ? -1 : retval;
-}
-
-long qt_wince__lseek( int handle, long offset, int origin )
-{
- return fseek( (FILE*)handle, offset, origin );
-}
-
-int qt_wince__read( int handle, void *buffer, unsigned int count )
-{
- return fread( buffer, 1, count, (FILE*)handle );
-}
-
-int qt_wince__write( int handle, const void *buffer, unsigned int count )
-{
- return fwrite( buffer, 1, count, (FILE*)handle );
-}
-
-int qt_wince__close( int handle )
-{
- if (!handle)
- return 0;
- return fclose( (FILE*)handle );
-}
-
-FILE *qt_wince__fdopen(int handle, const char* /*mode*/)
-{
- return (FILE*)handle;
-}
-
-FILE *qt_wince_fdopen( int handle, const char* /*mode*/ )
-{
- return (FILE*)handle;
-}
-
-void qt_wince_rewind( FILE *stream )
-{
- fseek( stream, 0L, SEEK_SET );
-}
-
-int qt_wince___fileno(FILE *f)
-{
- return (int) _fileno(f);
-}
-
-FILE *qt_wince_tmpfile( void )
-{
- static long i = 0;
- char name[16];
- sprintf( name, "tmp%i", i++ );
- return fopen( name, "r+" );
-}
-
-int qt_wince__mkdir(const char *dirname)
-{
- return CreateDirectory(reinterpret_cast<const wchar_t *> (QString(QString::fromLatin1(dirname)).utf16()), 0) ? 0 : -1;
-}
-
-int qt_wince__rmdir(const char *dirname)
-{
- return RemoveDirectory(reinterpret_cast<const wchar_t *> (QString::fromLatin1(dirname).utf16())) ? 0 : -1;
-}
-
-int qt_wince__access( const char *path, int pmode )
-{
- return _waccess(reinterpret_cast<const wchar_t *> (QString::fromLatin1(path).utf16()),pmode);
-}
-
-int qt_wince__rename( const char *oldname, const char *newname )
-{
- return !MoveFile(reinterpret_cast<const wchar_t *> (QString::fromLatin1(oldname).utf16()), reinterpret_cast<const wchar_t *> (QString::fromLatin1(newname).utf16()));
-}
-
-int qt_wince__remove( const char *name )
-{
- return !DeleteFile(reinterpret_cast<const wchar_t *> (QString::fromLatin1(name).utf16()));
-}
-
-int qt_wince_stat( const char *path, struct stat *buffer )
-{
- WIN32_FIND_DATA finfo;
- HANDLE ff = FindFirstFile( reinterpret_cast<const wchar_t *> (QString::fromLatin1(path).utf16()), &finfo );
-
- if ( ff == INVALID_HANDLE_VALUE )
- return -1;
-
- buffer->st_ctime = qt_wince_ftToTime_t( finfo.ftCreationTime );
- buffer->st_atime = qt_wince_ftToTime_t( finfo.ftLastAccessTime );
- buffer->st_mtime = qt_wince_ftToTime_t( finfo.ftLastWriteTime );
- buffer->st_nlink = 0;
- buffer->st_size = finfo.nFileSizeLow; // ### missing high!
- buffer->st_mode = (finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR : _S_IFREG;
- buffer->st_mode |= (finfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _O_RDONLY : _O_RDWR;
- return (FindClose(ff) == 0);
-}
-
-int qt_wince__fstat( int handle, struct stat *buffer)
-{
- BY_HANDLE_FILE_INFORMATION fInfo;
- BOOL res = GetFileInformationByHandle((HANDLE)handle, &fInfo);
-
- buffer->st_ctime = qt_wince_ftToTime_t( fInfo.ftCreationTime );
- buffer->st_atime = qt_wince_ftToTime_t( fInfo.ftLastAccessTime );
- buffer->st_mtime = qt_wince_ftToTime_t( fInfo.ftLastWriteTime );
- buffer->st_nlink = 0;
- buffer->st_size = fInfo.nFileSizeLow; // ### missing high!
- buffer->st_mode = (fInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR : _S_IFREG;
- buffer->st_mode |= (fInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _O_RDONLY : _O_RDWR;
- return (res == 0);
-}
-
-int qt_wince_SetErrorMode(int newValue)
-{
- static int oldValue;
- int result = oldValue;
- oldValue = newValue;
- return result;
-}
-
-bool qt_wince__chmod(const char *file, int mode)
-{
- return _wchmod( reinterpret_cast<const wchar_t *> (QString::fromLatin1(file).utf16()), mode);
-}
-
-bool qt_wince__wchmod(const wchar_t *file, int mode)
-{
- BOOL success = FALSE;
- // ### Does not work properly, what about just adding one property?
- if(mode&_S_IWRITE) {
- success = SetFileAttributes(file, FILE_ATTRIBUTE_NORMAL);
- } else if((mode&_S_IREAD) && !(mode&_S_IWRITE)) {
- success = SetFileAttributes(file, FILE_ATTRIBUTE_READONLY);
- }
- return success ? 0 : -1;
-}
-
-HANDLE qt_wince_CreateFileA(LPCSTR filename, DWORD access, DWORD share, LPSECURITY_ATTRIBUTES attr, DWORD dispo, DWORD flags, HANDLE tempFile)
-{
- return CreateFileW( reinterpret_cast<const wchar_t *>(QString::fromLatin1(filename).utf16()), access, share, attr, dispo, flags, tempFile);
-}
-
-// Graphics ---------------------------------------------------------
-BOOL qt_wince_SetWindowOrgEx( HDC /*hdc*/, int /*X*/, int /*Y*/, LPPOINT /*lpPoint*/) {
- return TRUE;
-}
-
-// Threading --------------------------------------------------------
-HANDLE qt_wince__beginthread(void( *start_address )( void * ), unsigned stack_size, void *arglist)
-{
- unsigned initflag = 0;
- if (stack_size > 0)
- initflag |= STACK_SIZE_PARAM_IS_A_RESERVATION;
- return CreateThread(NULL, stack_size, (LPTHREAD_START_ROUTINE)start_address, arglist, initflag, NULL);
-}
-
-unsigned long qt_wince__beginthreadex( void *security,
- unsigned stack_size,
- unsigned (__stdcall *start_address)(void *),
- void *arglist,
- unsigned initflag,
- unsigned *thrdaddr)
-{
- if (stack_size > 0)
- initflag |= STACK_SIZE_PARAM_IS_A_RESERVATION;
- return (unsigned long)
- CreateThread( (LPSECURITY_ATTRIBUTES)security,
- (DWORD)stack_size,
- (LPTHREAD_START_ROUTINE)start_address,
- (LPVOID)arglist,
- (DWORD)initflag | CREATE_SUSPENDED,
- (LPDWORD)thrdaddr);
-}
-
-void qt_wince__endthreadex(unsigned nExitCode) {
- ExitThread((DWORD)nExitCode);
-}
-
-void *qt_wince_bsearch(const void *key,
- const void *base,
- size_t num,
- size_t size,
- int (__cdecl *compare)(const void *, const void *))
-{
- size_t low = 0;
- size_t high = num - 1;
- while (low <= high) {
- size_t mid = (low + high) >> 1;
- int c = compare(key, (char*)base + mid * size);
- if (c < 0) {
- if (!mid)
- break;
- high = mid - 1;
- } else if (c > 0)
- low = mid + 1;
- else
- return (char*) base + mid * size;
- }
- return 0;
-}
-
-void *lfind(const void* key, const void* base, size_t* elements, size_t size,
- int (__cdecl *compare)(const void*, const void*))
-{
- const char* current = (char*) base;
- const char* const end = (char*) (current + (*elements) * size);
- while (current != end) {
- if (compare(current, key) == 0)
- return (void*)current;
- current += size;
- }
- return 0;
-}
-
-DWORD qt_wince_GetThreadLocale(void)
-{
- return GetUserDefaultLCID();
-}
-
-void *qt_wince_calloc( size_t num, size_t size )
-{
- void *ptr = malloc( num * size );
- if( ptr )
- memset( ptr, 0, num * size );
- return ptr;
-}
-
-// _getpid is currently only used for creating a temporary filename
-int qt_wince__getpid()
-{
- return qAbs((int)GetCurrentProcessId());
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-#endif // Q_OS_WINCE
diff --git a/src/corelib/kernel/qfunctions_wince.h b/src/corelib/kernel/qfunctions_wince.h
deleted file mode 100644
index 030950e1bd..0000000000
--- a/src/corelib/kernel/qfunctions_wince.h
+++ /dev/null
@@ -1,473 +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$
-**
-****************************************************************************/
-
-#ifndef QFUNCTIONS_WINCE_H
-#define QFUNCTIONS_WINCE_H
-
-#include <QtCore/qglobal.h>
-
-#ifdef Q_OS_WINCE
-# ifndef NOMINMAX
-# define NOMINMAX
-# endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-#include <winuser.h>
-#include <winbase.h>
-#include <objbase.h>
-#include <kfuncs.h>
-#include <ctype.h>
-#include <time.h>
-#include <crtdefs.h>
-#if _WIN32_WCE < 0x800
-# include <altcecrt.h>
-#else
-# include <fcntl.h>
-# include <stat.h>
-#endif
-#include <winsock.h>
-#include <ceconfig.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_BUILD_CORE_LIB
-#endif
-
-QT_END_NAMESPACE
-
-// The standard SDK misses this define...
-#define _control87 _controlfp
-
-#if !defined __cplusplus
-#define bool int
-#define true 1
-#define false 0
-#endif
-
-// Environment ------------------------------------------------------
-errno_t qt_fake_getenv_s(size_t*, char*, size_t, const char*);
-errno_t qt_fake__putenv_s(const char*, const char*);
-
-#ifdef __cplusplus // have this as tiff plugin is written in C
-extern "C" {
-#endif
-
-#if !defined(NO_ERRNO_H)
-#define NO_ERRNO_H
-#endif
-
-// Environment ------------------------------------------------------
-int qt_wince__getpid(void);
-
-
-// Time -------------------------------------------------------------
-#ifndef _TM_DEFINED
-#define _TM_DEFINED
-struct tm {
- int tm_sec; /* seconds after the minute - [0,59] */
- int tm_min; /* minutes after the hour - [0,59] */
- int tm_hour; /* hours since midnight - [0,23] */
- int tm_mday; /* day of the month - [1,31] */
- int tm_mon; /* months since January - [0,11] */
- int tm_year; /* years since 1900 */
- int tm_wday; /* days since Sunday - [0,6] */
- int tm_yday; /* days since January 1 - [0,365] */
- int tm_isdst; /* daylight-saving time flag */
-};
-#endif // _TM_DEFINED
-
-FILETIME qt_wince_time_tToFt( time_t tt );
-time_t qt_wince_ftToTime_t( const FILETIME ft );
-
-#if _WIN32_WCE < 0x800
-
-// File I/O ---------------------------------------------------------
-#define _O_RDONLY 0x0001
-#define _O_RDWR 0x0002
-#define _O_WRONLY 0x0004
-#define _O_CREAT 0x0008
-#define _O_TRUNC 0x0010
-#define _O_APPEND 0x0020
-#define _O_EXCL 0x0040
-
-#define O_RDONLY _O_RDONLY
-#define O_RDWR _O_RDWR
-#define O_WRONLY _O_WRONLY
-#define O_CREAT _O_CREAT
-#define O_TRUNC _O_TRUNC
-#define O_APPEND _O_APPEND
-#define O_EXCL _O_EXCL
-
-#define _S_IFMT 0x0600
-#define _S_IFDIR 0x0200
-#define _S_IFCHR 0x0100
-#define _S_IFREG 0x0400
-#define _S_IREAD 0x0010
-#define _S_IWRITE 0x0008
-
-#define S_IFMT _S_IFMT
-#define S_IFDIR _S_IFDIR
-#define S_IFCHR _S_IFCHR
-#define S_IFREG _S_IFREG
-#define S_IREAD _S_IREAD
-#define S_IWRITE _S_IWRITE
-
-#ifndef _IOFBF
-#define _IOFBF 0x0000
-#endif
-
-#ifndef _IOLBF
-#define _IOLBF 0x0040
-#endif
-
-#ifndef _IONBF
-#define _IONBF 0x0004
-#endif
-
-// Regular Berkeley error constants
-#ifndef _STAT_DEFINED
-#define _STAT_DEFINED
-struct stat
-{
- int st_mode;
- int st_size;
- int st_nlink;
- time_t st_mtime;
- time_t st_atime;
- time_t st_ctime;
-};
-#endif
-
-typedef int mode_t;
-extern int errno;
-#endif // _WIN32_WCE < 0x800
-
-int qt_wince__getdrive( void );
-int qt_wince__waccess( const wchar_t *path, int pmode );
-int qt_wince__wopen( const wchar_t *filename, int oflag, int pmode );
-long qt_wince__lseek( int handle, long offset, int origin );
-int qt_wince__read( int handle, void *buffer, unsigned int count );
-int qt_wince__write( int handle, const void *buffer, unsigned int count );
-int qt_wince__close( int handle );
-FILE *qt_wince__fdopen(int handle, const char *mode);
-FILE *qt_wince_fdopen(int handle, const char *mode);
-void qt_wince_rewind( FILE *stream );
-int qt_wince___fileno(FILE *);
-FILE *qt_wince_tmpfile( void );
-
-//For zlib we need these helper functions, but they break the build when
-//set globally, so just set them for zlib use
-#ifdef ZLIB_H
-#define open qt_wince_open
-#define close qt_wince__close
-#define lseek qt_wince__lseek
-#define read qt_wince__read
-#define write qt_wince__write
-#endif
-
-int qt_wince__mkdir(const char *dirname);
-int qt_wince__rmdir(const char *dirname);
-int qt_wince__access( const char *path, int pmode );
-int qt_wince__rename( const char *oldname, const char *newname );
-int qt_wince__remove( const char *name );
-#ifdef __cplusplus
-int qt_wince_open( const char *filename, int oflag, int pmode = 0 );
-#else
-int qt_wince_open( const char *filename, int oflag, int pmode );
-#endif
-int qt_wince_stat( const char *path, struct stat *buffer );
-int qt_wince__fstat( int handle, struct stat *buffer);
-
-#define SEM_FAILCRITICALERRORS 0x0001
-#define SEM_NOOPENFILEERRORBOX 0x0002
-int qt_wince_SetErrorMode(int);
-#ifndef CoInitialize
-#define CoInitialize(x) CoInitializeEx(x, COINIT_MULTITHREADED)
-#endif
-
-bool qt_wince__chmod(const char *file, int mode);
-bool qt_wince__wchmod(const wchar_t *file, int mode);
-
-QT_WARNING_DISABLE_MSVC(4273)
-HANDLE qt_wince_CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
-
-// Printer ----------------------------------------------------------
-#define ETO_GLYPH_INDEX 0x0010
-
-// Graphics ---------------------------------------------------------
-#ifndef SM_CXCURSOR
-# define SM_CXCURSOR 13
-#endif
-#ifndef SM_CYCURSOR
-# define SM_CYCURSOR 14
-#endif
-BOOL qt_wince_SetWindowOrgEx( HDC hdc, int X, int Y, LPPOINT lpPoint );
-
-// Other stuff ------------------------------------------------------
-#define MWMO_ALERTABLE 0x0002
-// ### not the real values
-#define CREATE_NO_WINDOW 2
-#define CF_HDROP 15
-
-void *qt_wince_calloc(size_t num, size_t size);
-#if !defined(TLS_OUT_OF_INDEXES)
-# define TLS_OUT_OF_INDEXES 0xffffffff
-#endif
-DWORD qt_wince_GetThreadLocale(void);
-
-HANDLE qt_wince__beginthread(void( *start_address )( void * ), unsigned stack_size, void *arglist);
-
-unsigned long qt_wince__beginthreadex( void *security,
- unsigned stack_size,
- unsigned (__stdcall *start_address)(void *),
- void *arglist,
- unsigned initflag,
- unsigned *thrdaddr );
-void qt_wince__endthreadex(unsigned nExitCode);
-
-
-// bsearch is needed for building the tiff plugin
-// otherwise it could go into qguifunctions_wce
-void *qt_wince_bsearch(const void *key,
- const void *base,
- size_t num,
- size_t size,
- int (__cdecl *compare)(const void *, const void *));
-
-// Missing typedefs
-#ifndef _TIME_T_DEFINED
-typedef unsigned long time_t;
-#define _TIME_T_DEFINED
-#endif
-typedef HANDLE HDROP;
-
-#ifndef WS_THICKFRAME
-#define WS_THICKFRAME WS_DLGFRAME
-#endif
-
-typedef UINT UWORD;
-
-// Missing definitions: not necessary equal to their Win32 values
-// (the goal is to just have a clean compilation of MFC)
-#define WS_MAXIMIZE 0
-#define WS_MINIMIZE 0
-#ifndef WS_EX_TOOLWINDOW
-#define WS_EX_TOOLWINDOW 0
-#endif
-#define WS_EX_NOPARENTNOTIFY 0
-#define WM_ENTERIDLE 0x0121
-#define WM_PRINT WM_PAINT
-#define WM_NCCREATE (0x0081)
-#define WM_PARENTNOTIFY 0
-#define WM_NCDESTROY (WM_APP-1)
-#ifndef SW_RESTORE
-#define SW_RESTORE (SW_SHOWNORMAL)
-#endif
-#define SW_NORMAL (SW_SHOWNORMAL)
-#define WAIT_OBJECT_0 0x00000000L
-#define DEFAULT_GUI_FONT SYSTEM_FONT
-#ifndef SWP_NOREDRAW
-#define SWP_NOREDRAW 0
-#endif
-#define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
-#define HWND_TOPMOST ((HWND)-1)
-#define HWND_NOTOPMOST ((HWND)-2)
-#define PS_DOT 2
-#define PD_ALLPAGES 0
-#define PD_USEDEVMODECOPIES 0
-#define PD_NOSELECTION 0
-#define PD_HIDEPRINTTOFILE 0
-#define PD_NOPAGENUMS 0
-#define CF_METAFILEPICT 3
-#define MM_ANISOTROPIC 8
-#define KF_ALTDOWN 0x2000
-#define SPI_GETWORKAREA 48
-
-#ifndef WM_SETCURSOR
- #define WM_SETCURSOR 0x0020
- #define IDC_ARROW MAKEINTRESOURCE(32512)
- #define IDC_IBEAM MAKEINTRESOURCE(32513)
- #define IDC_WAIT MAKEINTRESOURCE(32514)
- #define IDC_CROSS MAKEINTRESOURCE(32515)
- #define IDC_UPARROW MAKEINTRESOURCE(32516)
- #define IDC_SIZE MAKEINTRESOURCE(32646)
- #define IDC_ICON MAKEINTRESOURCE(32512)
- #define IDC_SIZENWSE MAKEINTRESOURCE(32642)
- #define IDC_SIZENESW MAKEINTRESOURCE(32643)
- #define IDC_SIZEWE MAKEINTRESOURCE(32644)
- #define IDC_SIZENS MAKEINTRESOURCE(32645)
- #define IDC_SIZEALL MAKEINTRESOURCE(32646)
- #define IDC_NO MAKEINTRESOURCE(32648)
- #define IDC_APPSTARTING MAKEINTRESOURCE(32650)
- #define IDC_HELP MAKEINTRESOURCE(32651)
- #define IDC_HAND MAKEINTRESOURCE(32649)
-#endif
-
-#define GMEM_MOVEABLE LMEM_MOVEABLE
-#define GPTR LPTR
-
-// WinCE: CESYSGEN prunes the following FRP defines,
-// and INTERNET_TRANSFER_TYPE_ASCII breaks in wininet.h
-#undef FTP_TRANSFER_TYPE_ASCII
-#define FTP_TRANSFER_TYPE_ASCII 0x00000001
-#undef FTP_TRANSFER_TYPE_BINARY
-#define FTP_TRANSFER_TYPE_BINARY 0x00000002
-
-typedef DWORD OLE_COLOR;
-
-// Define the Windows Styles which are not defined by MS
-#ifndef WS_POPUPWINDOW
-#define WS_POPUPWINDOW WS_POPUP|WS_BORDER|WS_SYSMENU|WS_CAPTION
-#endif
-
-#ifndef WS_OVERLAPPEDWINDOW
-#define WS_OVERLAPPEDWINDOW WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX
-#endif
-
-#ifndef WS_TILED
-#define WS_TILED WS_OVERLAPPED
-#endif
-
-#ifndef WS_TILEDWINDOW
-#define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW
-#endif
-
-#ifndef WS_EX_CAPTIONOKBTN
-#define WS_EX_CAPTIONOKBTN 0x80000000L
-#endif
-
-#ifndef WS_EX_NODRAG
-#define WS_EX_NODRAG 0x40000000L
-#endif
-
-#ifdef __cplusplus
-} // Extern C.
-#endif
-
-#ifdef __cplusplus
-
-
-// As Windows CE lacks some standard functions used in Qt, these got
-// reimplemented. Other projects do this as well. Inline functions are used
-// that there is a central place to disable functions for newer versions if
-// they get available. There are no defines used anymore, because this
-// will break member functions of classes which are called like these
-// functions. Also inline functions are only supported by C++, so just define
-// them for C++, as only 3rd party dependencies are C, this is no issue.
-// The other declarations available in this file are being used per
-// define inside qplatformdefs.h of the corresponding WinCE mkspec.
-
-#define generate_inline_return_func0(funcname, returntype) \
- inline returntype funcname() \
- { \
- return qt_wince_##funcname(); \
- }
-#define generate_inline_return_func1(funcname, returntype, param1) \
- inline returntype funcname(param1 p1) \
- { \
- return qt_wince_##funcname(p1); \
- }
-#define generate_inline_return_func2(funcname, returntype, prependnamespace, param1, param2) \
- inline returntype funcname(param1 p1, param2 p2) \
- { \
- return prependnamespace##funcname(p1, p2); \
- }
-#define generate_inline_return_func3(funcname, returntype, param1, param2, param3) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3) \
- { \
- return qt_wince_##funcname(p1, p2, p3); \
- }
-#define generate_inline_return_func4(funcname, returntype, prependnamespace, param1, param2, param3, param4) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4) \
- { \
- return prependnamespace##funcname(p1, p2, p3, p4); \
- }
-#define generate_inline_return_func5(funcname, returntype, param1, param2, param3, param4, param5) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
- { \
- return qt_wince_##funcname(p1, p2, p3, p4, p5); \
- }
-#define generate_inline_return_func6(funcname, returntype, param1, param2, param3, param4, param5, param6) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
- { \
- return qt_wince_##funcname(p1, p2, p3, p4, p5, p6); \
- }
-#define generate_inline_return_func7(funcname, returntype, param1, param2, param3, param4, param5, param6, param7) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, param7 p7) \
- { \
- return qt_wince_##funcname(p1, p2, p3, p4, p5, p6, p7); \
- }
-
-typedef unsigned (__stdcall *StartAdressExFunc)(void *);
-typedef void(*StartAdressFunc)(void *);
-typedef int ( __cdecl *CompareFunc ) (const void *, const void *) ;
-
-generate_inline_return_func4(getenv_s, errno_t, qt_fake_, size_t *, char *, size_t, const char *)
-generate_inline_return_func2(_putenv_s, errno_t, qt_fake_, const char *, const char *)
-generate_inline_return_func0(_getpid, int)
-generate_inline_return_func1(time_tToFt, FILETIME, time_t)
-generate_inline_return_func1(ftToTime_t, time_t, FILETIME)
-generate_inline_return_func0(_getdrive, int)
-generate_inline_return_func2(_waccess, int, qt_wince_, const wchar_t *, int)
-generate_inline_return_func3(_wopen, int, const wchar_t *, int, int)
-generate_inline_return_func2(_fdopen, FILE *, qt_wince_, int, const char *)
-generate_inline_return_func2(fdopen, FILE *, qt_wince_, int, const char *)
-generate_inline_return_func1(rewind, void, FILE *)
-generate_inline_return_func0(tmpfile, FILE *)
-generate_inline_return_func2(_rename, int, qt_wince_, const char *, const char *)
-generate_inline_return_func1(_remove, int, const char *)
-generate_inline_return_func1(SetErrorMode, int, int)
-#if _WIN32_WCE < 0x800
-generate_inline_return_func2(_chmod, bool, qt_wince_, const char *, int)
-generate_inline_return_func2(_wchmod, bool, qt_wince_, const wchar_t *, int)
-#endif
-generate_inline_return_func7(CreateFileA, HANDLE, LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE)
-generate_inline_return_func4(SetWindowOrgEx, BOOL, qt_wince_, HDC, int, int, LPPOINT)
-generate_inline_return_func2(calloc, void *, qt_wince_, size_t, size_t)
-generate_inline_return_func0(GetThreadLocale, DWORD)
-generate_inline_return_func3(_beginthread, HANDLE, StartAdressFunc, unsigned, void *)
-generate_inline_return_func6(_beginthreadex, unsigned long, void *, unsigned, StartAdressExFunc, void *, unsigned, unsigned *)
-generate_inline_return_func1(_endthreadex, void, unsigned)
-generate_inline_return_func5(bsearch, void *, const void *, const void *, size_t, size_t, CompareFunc)
-
-#endif //__cplusplus
-
-#endif // Q_OS_WINCE
-#endif // QFUNCTIONS_WINCE_H
diff --git a/src/corelib/kernel/qjni_p.h b/src/corelib/kernel/qjni_p.h
index 79cbe1de72..52abd51dc1 100644
--- a/src/corelib/kernel/qjni_p.h
+++ b/src/corelib/kernel/qjni_p.h
@@ -52,7 +52,7 @@
#define QJNI_P_H
#include <jni.h>
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qsharedpointer.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index 76f530ab9c..6a46f7dd11 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -38,14 +38,17 @@
****************************************************************************/
#include "qjnihelpers_p.h"
+#include "qjni_p.h"
#include "qmutex.h"
#include "qlist.h"
#include "qsemaphore.h"
#include "qsharedpointer.h"
#include "qvector.h"
+#include "qthread.h"
#include <QtCore/qrunnable.h>
#include <deque>
+#include <memory>
QT_BEGIN_NAMESPACE
@@ -60,6 +63,22 @@ static jmethodID g_hideSplashScreenMethodID = Q_NULLPTR;
Q_GLOBAL_STATIC(std::deque<QtAndroidPrivate::Runnable>, g_pendingRunnables);
Q_GLOBAL_STATIC(QMutex, g_pendingRunnablesMutex);
+class PermissionsResultClass : public QObject
+{
+ Q_OBJECT
+public:
+ PermissionsResultClass(const QtAndroidPrivate::PermissionsResultFunc &func) : m_func(func) {}
+ Q_INVOKABLE void sendResult(const QtAndroidPrivate::PermissionsHash &result) { m_func(result); }
+
+private:
+ QtAndroidPrivate::PermissionsResultFunc m_func;
+};
+
+typedef QHash<int, QSharedPointer<PermissionsResultClass>> PendingPermissionRequestsHash;
+Q_GLOBAL_STATIC(PendingPermissionRequestsHash, g_pendingPermissionRequests);
+Q_GLOBAL_STATIC(QMutex, g_pendingPermissionRequestsMutex);
+Q_GLOBAL_STATIC(QAtomicInt, g_requestPermissionsRequestCode);
+
// function called from Java from Android UI thread
static void runPendingCppRunnables(JNIEnv */*env*/, jobject /*obj*/)
{
@@ -81,9 +100,43 @@ namespace {
QMutex mutex;
QVector<QtAndroidPrivate::GenericMotionEventListener *> listeners;
};
+
+ enum {
+ PERMISSION_GRANTED = 0
+ };
}
Q_GLOBAL_STATIC(GenericMotionEventListeners, g_genericMotionEventListeners)
+static void sendRequestPermissionsResult(JNIEnv *env, jobject /*obj*/, jint requestCode,
+ jobjectArray permissions, jintArray grantResults)
+{
+ g_pendingPermissionRequestsMutex->lock();
+ auto it = g_pendingPermissionRequests->find(requestCode);
+ if (it == g_pendingPermissionRequests->end()) {
+ g_pendingPermissionRequestsMutex->unlock();
+ // show an error or something ?
+ return;
+ }
+ g_pendingPermissionRequestsMutex->unlock();
+
+ Qt::ConnectionType connection = QThread::currentThread() == it.value()->thread() ? Qt::DirectConnection : Qt::BlockingQueuedConnection;
+ QtAndroidPrivate::PermissionsHash hash;
+ const int size = env->GetArrayLength(permissions);
+ std::unique_ptr<jint[]> results(new jint[size]);
+ env->GetIntArrayRegion(grantResults, 0, size, results.get());
+ for (int i = 0 ; i < size; ++i) {
+ const auto &permission = QJNIObjectPrivate(env->GetObjectArrayElement(permissions, i)).toString();
+ auto value = results[i] == PERMISSION_GRANTED ?
+ QtAndroidPrivate::PermissionsResult::Granted :
+ QtAndroidPrivate::PermissionsResult::Denied;
+ hash[permission] = value;
+ }
+ QMetaObject::invokeMethod(it.value().data(), "sendResult", connection, Q_ARG(QtAndroidPrivate::PermissionsHash, hash));
+ g_pendingPermissionRequestsMutex->lock();
+ g_pendingPermissionRequests->erase(it);
+ g_pendingPermissionRequestsMutex->unlock();
+}
+
static jboolean dispatchGenericMotionEvent(JNIEnv *, jclass, jobject event)
{
jboolean ret = JNI_FALSE;
@@ -328,7 +381,8 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
{"dispatchGenericMotionEvent", "(Landroid/view/MotionEvent;)Z", reinterpret_cast<void *>(dispatchGenericMotionEvent)},
{"dispatchKeyEvent", "(Landroid/view/KeyEvent;)Z", reinterpret_cast<void *>(dispatchKeyEvent)},
{"setNativeActivity", "(Landroid/app/Activity;)V", reinterpret_cast<void *>(setNativeActivity)},
- {"setNativeService", "(Landroid/app/Service;)V", reinterpret_cast<void *>(setNativeService)}
+ {"setNativeService", "(Landroid/app/Service;)V", reinterpret_cast<void *>(setNativeService)},
+ {"sendRequestPermissionsResult", "(I[Ljava/lang/String;[I)V", reinterpret_cast<void *>(sendRequestPermissionsResult)},
};
const bool regOk = (env->RegisterNatives(jQtNative, methods, sizeof(methods) / sizeof(methods[0])) == JNI_OK);
@@ -357,6 +411,16 @@ jobject QtAndroidPrivate::service()
return g_jService;
}
+jobject QtAndroidPrivate::context()
+{
+ if (g_jActivity)
+ return g_jActivity;
+ if (g_jService)
+ return g_jService;
+
+ return 0;
+}
+
JavaVM *QtAndroidPrivate::javaVM()
{
return g_javaVM;
@@ -401,6 +465,70 @@ void QtAndroidPrivate::runOnAndroidThreadSync(const QtAndroidPrivate::Runnable &
sem->tryAcquire(1, timeoutMs);
}
+void QtAndroidPrivate::requestPermissions(JNIEnv *env, const QStringList &permissions, const QtAndroidPrivate::PermissionsResultFunc &callbackFunc, bool directCall)
+{
+ if (androidSdkVersion() < 23 || !activity()) {
+ QHash<QString, QtAndroidPrivate::PermissionsResult> res;
+ for (const auto &perm : permissions)
+ res[perm] = checkPermission(perm);
+ callbackFunc(res);
+ return;
+ }
+ // Check API 23+ permissions
+ const int requestCode = (*g_requestPermissionsRequestCode)++;
+ if (!directCall) {
+ g_pendingPermissionRequestsMutex->lock();
+ (*g_pendingPermissionRequests)[requestCode] = QSharedPointer<PermissionsResultClass>::create(callbackFunc);
+ g_pendingPermissionRequestsMutex->unlock();
+ }
+
+ runOnAndroidThread([permissions, callbackFunc, requestCode, directCall] {
+ if (directCall) {
+ g_pendingPermissionRequestsMutex->lock();
+ (*g_pendingPermissionRequests)[requestCode] = QSharedPointer<PermissionsResultClass>::create(callbackFunc);
+ g_pendingPermissionRequestsMutex->unlock();
+ }
+
+ QJNIEnvironmentPrivate env;
+ auto array = env->NewObjectArray(permissions.size(), env->FindClass("java/lang/String"), nullptr);
+ int index = 0;
+ for (const auto &perm : permissions)
+ env->SetObjectArrayElement(array, index++, QJNIObjectPrivate::fromString(perm).object());
+ QJNIObjectPrivate(activity()).callMethod<void>("requestPermissions", "([Ljava/lang/String;I)V", array, requestCode);
+ env->DeleteLocalRef(array);
+ }, env);
+}
+
+QHash<QString, QtAndroidPrivate::PermissionsResult> QtAndroidPrivate::requestPermissionsSync(JNIEnv *env, const QStringList &permissions, int timeoutMs)
+{
+ QSharedPointer<QHash<QString, QtAndroidPrivate::PermissionsResult>> res(new QHash<QString, QtAndroidPrivate::PermissionsResult>());
+ QSharedPointer<QSemaphore> sem(new QSemaphore);
+ requestPermissions(env, permissions, [sem, res](const QHash<QString, PermissionsResult> &result){
+ *res = result;
+ sem->release();
+ }, true);
+ sem->tryAcquire(1, timeoutMs);
+ return *res;
+}
+
+QtAndroidPrivate::PermissionsResult QtAndroidPrivate::checkPermission(const QString &permission)
+{
+ const auto res = QJNIObjectPrivate::callStaticMethod<jint>("org/qtproject/qt5/android/QtNative",
+ "checkSelfPermission",
+ "(Ljava/lang/String;)I",
+ QJNIObjectPrivate::fromString(permission).object());
+ return res == PERMISSION_GRANTED ? PermissionsResult::Granted : PermissionsResult::Denied;
+}
+
+bool QtAndroidPrivate::shouldShowRequestPermissionRationale(const QString &permission)
+{
+ if (androidSdkVersion() < 23 || !activity())
+ return false;
+
+ return QJNIObjectPrivate(activity()).callMethod<jboolean>("shouldShowRequestPermissionRationale", "(Ljava/lang/String;)Z",
+ QJNIObjectPrivate::fromString(permission).object());
+}
+
void QtAndroidPrivate::registerGenericMotionEventListener(QtAndroidPrivate::GenericMotionEventListener *listener)
{
QMutexLocker locker(&g_genericMotionEventListeners()->mutex);
@@ -431,3 +559,5 @@ void QtAndroidPrivate::hideSplashScreen(JNIEnv *env)
}
QT_END_NAMESPACE
+
+#include "qjnihelpers.moc"
diff --git a/src/corelib/kernel/qjnihelpers_p.h b/src/corelib/kernel/qjnihelpers_p.h
index 78ad08a09e..478f62a5c7 100644
--- a/src/corelib/kernel/qjnihelpers_p.h
+++ b/src/corelib/kernel/qjnihelpers_p.h
@@ -52,12 +52,13 @@
//
#include <jni.h>
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#include <functional>
QT_BEGIN_NAMESPACE
class QRunnable;
+class QStringList;
namespace QtAndroidPrivate
{
@@ -97,10 +98,17 @@ namespace QtAndroidPrivate
virtual bool handleKeyEvent(jobject event) = 0;
};
+ enum class PermissionsResult {
+ Granted,
+ Denied
+ };
+ typedef QHash<QString, QtAndroidPrivate::PermissionsResult> PermissionsHash;
typedef std::function<void()> Runnable;
+ typedef std::function<void(const PermissionsHash &)> PermissionsResultFunc;
Q_CORE_EXPORT jobject activity();
Q_CORE_EXPORT jobject service();
+ Q_CORE_EXPORT jobject context();
Q_CORE_EXPORT JavaVM *javaVM();
Q_CORE_EXPORT jint initJNI(JavaVM *vm, JNIEnv *env);
jobject classLoader();
@@ -108,6 +116,10 @@ namespace QtAndroidPrivate
Q_CORE_EXPORT void runOnAndroidThread(const Runnable &runnable, JNIEnv *env);
Q_CORE_EXPORT void runOnAndroidThreadSync(const Runnable &runnable, JNIEnv *env, int timeoutMs = INT_MAX);
Q_CORE_EXPORT void runOnUiThread(QRunnable *runnable, JNIEnv *env);
+ Q_CORE_EXPORT void requestPermissions(JNIEnv *env, const QStringList &permissions, const PermissionsResultFunc &callbackFunc, bool directCall = false);
+ Q_CORE_EXPORT QHash<QString, PermissionsResult> requestPermissionsSync(JNIEnv *env, const QStringList &permissions, int timeoutMs = INT_MAX);
+ Q_CORE_EXPORT PermissionsResult checkPermission(const QString &permission);
+ Q_CORE_EXPORT bool shouldShowRequestPermissionRationale(const QString &permission);
Q_CORE_EXPORT void handleActivityResult(jint requestCode, jint resultCode, jobject data);
Q_CORE_EXPORT void registerActivityResultListener(ActivityResultListener *listener);
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index c24fc3a0ce..773884047a 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -45,6 +45,7 @@
#endif
#include <QtCore/qglobal.h>
+#include <QtCore/qalgorithms.h>
#ifndef _USE_MATH_DEFINES
# define _USE_MATH_DEFINES
@@ -241,20 +242,12 @@ Q_DECL_CONSTEXPR inline double qRadiansToDegrees(double radians)
}
-#if defined(Q_CC_GNU)
-// clz instructions exist in at least MIPS, ARM, PowerPC and X86, so we can assume this builtin always maps to an efficient instruction.
+#if defined(QT_HAS_BUILTIN_CLZ)
inline quint32 qNextPowerOfTwo(quint32 v)
{
if (v == 0)
return 1;
- return 2U << (31 ^ __builtin_clz(v));
-}
-
-inline quint64 qNextPowerOfTwo(quint64 v)
-{
- if (v == 0)
- return 1;
- return Q_UINT64_C(2) << (63 ^ __builtin_clzll(v));
+ return 2U << (31 ^ QAlgorithmsPrivate::qt_builtin_clz(v));
}
#else
inline quint32 qNextPowerOfTwo(quint32 v)
@@ -267,7 +260,16 @@ inline quint32 qNextPowerOfTwo(quint32 v)
++v;
return v;
}
+#endif
+#if defined(QT_HAS_BUILTIN_CLZLL)
+inline quint64 qNextPowerOfTwo(quint64 v)
+{
+ if (v == 0)
+ return 1;
+ return Q_UINT64_C(2) << (63 ^ QAlgorithmsPrivate::qt_builtin_clzll(v));
+}
+#else
inline quint64 qNextPowerOfTwo(quint64 v)
{
v |= v >> 1;
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index f4f75e39e6..2e0dd8e5d2 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -2557,9 +2557,19 @@ int QMetaEnum::value(int index) const
*/
bool QMetaEnum::isFlag() const
{
- return mobj && mobj->d.data[handle + 1];
+ return mobj && mobj->d.data[handle + 1] & EnumIsFlag;
}
+/*!
+ \since 5.8
+
+ Returns \c true if this enumerator is declared as a C++11 enum class;
+ otherwise returns false.
+*/
+bool QMetaEnum::isScoped() const
+{
+ return mobj && mobj->d.data[handle + 1] & EnumIsScoped;
+}
/*!
Returns the scope this enumerator was declared in.
@@ -2652,15 +2662,16 @@ int QMetaEnum::keysToValue(const char *keys, bool *ok) const
return -1;
if (ok != 0)
*ok = true;
- QStringList l = QString::fromLatin1(keys).split(QLatin1Char('|'));
- if (l.isEmpty())
+ const QString keysString = QString::fromLatin1(keys);
+ const QVector<QStringRef> splitKeys = keysString.splitRef(QLatin1Char('|'));
+ if (splitKeys.isEmpty())
return 0;
- //#### TODO write proper code, do not use QStringList
+ // ### TODO write proper code: do not allocate memory, so we can go nothrow
int value = 0;
int count = mobj->d.data[handle + 2];
int data = mobj->d.data[handle + 3];
- for (int li = 0; li < l.size(); ++li) {
- QString trimmed = l.at(li).trimmed();
+ for (const QStringRef &untrimmed : splitKeys) {
+ const QStringRef trimmed = untrimmed.trimmed();
QByteArray qualified_key = trimmed.toLatin1();
const char *key = qualified_key.constData();
uint scope = 0;
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 85ac7e77e4..40b2aa6402 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -168,19 +168,15 @@ public:
inline bool isValid() const { return mobj != Q_NULLPTR; }
-#ifdef Q_QDOC
- static QMetaMethod fromSignal(PointerToMemberFunction signal);
-#else
- template <typename Func>
- static inline QMetaMethod fromSignal(Func signal)
+ template <typename PointerToMemberFunction>
+ static inline QMetaMethod fromSignal(PointerToMemberFunction signal)
{
- typedef QtPrivate::FunctionPointer<Func> SignalType;
+ typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SignalType;
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
"No Q_OBJECT in the class with the signal");
return fromSignalImpl(&SignalType::Object::staticMetaObject,
reinterpret_cast<void **>(&signal));
}
-#endif
private:
#if QT_DEPRECATED_SINCE(5,0)
@@ -214,6 +210,7 @@ public:
const char *name() const;
bool isFlag() const;
+ bool isScoped() const;
int keyCount() const;
const char *key(int index) const;
diff --git a/src/corelib/kernel/qmetaobject_moc_p.h b/src/corelib/kernel/qmetaobject_moc_p.h
index 1b24837ec0..ad258acfcd 100644
--- a/src/corelib/kernel/qmetaobject_moc_p.h
+++ b/src/corelib/kernel/qmetaobject_moc_p.h
@@ -52,6 +52,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
QT_BEGIN_NAMESPACE
// This function is shared with moc.cpp. This file should be included where needed.
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 0790af2bb5..1c540f64c7 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -114,6 +114,11 @@ enum MetaDataFlags {
TypeNameIndexMask = 0x7FFFFFFF
};
+enum EnumFlags {
+ EnumIsFlag = 0x1,
+ EnumIsScoped = 0x2
+};
+
extern int qMetaTypeTypeInternal(const char *);
class QArgumentType
@@ -168,6 +173,7 @@ class QMutex;
struct QMetaObjectPrivate
{
+ // revision 7 is Qt 5.0 everything lower is not supported
enum { OutputRevision = 7 }; // Used by moc, qmetaobjectbuilder and qdbus
int revision;
@@ -176,12 +182,9 @@ struct QMetaObjectPrivate
int methodCount, methodData;
int propertyCount, propertyData;
int enumeratorCount, enumeratorData;
- int constructorCount, constructorData; //since revision 2
- int flags; //since revision 3
- int signalCount; //since revision 4
- // revision 5 introduces changes in normalized signatures, no new members
- // revision 6 added qt_static_metacall as a member of each Q_OBJECT and inside QMetaObject itself
- // revision 7 is Qt 5
+ int constructorCount, constructorData;
+ int flags;
+ int signalCount;
static inline const QMetaObjectPrivate *get(const QMetaObject *metaobject)
{ return reinterpret_cast<const QMetaObjectPrivate*>(metaobject->d.data); }
diff --git a/src/corelib/kernel/qmetaobjectbuilder_p.h b/src/corelib/kernel/qmetaobjectbuilder_p.h
index 0934873ad0..144595330d 100644
--- a/src/corelib/kernel/qmetaobjectbuilder_p.h
+++ b/src/corelib/kernel/qmetaobjectbuilder_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qobject.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qdatastream.h>
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 3ac1f28638..f27fde6b8d 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -870,8 +870,7 @@ const char *QMetaType::typeName(int typeId)
return result;
}
-/*!
- \internal
+/*
Similar to QMetaType::type(), but only looks in the static set of types.
*/
static inline int qMetaTypeStaticType(const char *typeName, int length)
@@ -884,8 +883,7 @@ static inline int qMetaTypeStaticType(const char *typeName, int length)
return types[i].type;
}
-/*!
- \internal
+/*
Similar to QMetaType::type(), but only looks in the custom set of
types, and doesn't lock the mutex.
The extra \a firstInvalidIndex parameter is an easy way to avoid
@@ -1270,6 +1268,7 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
case QMetaType::UnknownType:
case QMetaType::Void:
case QMetaType::VoidStar:
+ case QMetaType::Nullptr:
case QMetaType::QObjectStar:
case QMetaType::QModelIndex:
case QMetaType::QPersistentModelIndex:
@@ -1491,6 +1490,7 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
case QMetaType::UnknownType:
case QMetaType::Void:
case QMetaType::VoidStar:
+ case QMetaType::Nullptr:
case QMetaType::QObjectStar:
case QMetaType::QModelIndex:
case QMetaType::QPersistentModelIndex:
@@ -1840,6 +1840,8 @@ public:
template<typename T>
void delegate(const T *where) { DestructorImpl<T>::Destruct(m_type, const_cast<T*>(where)); }
+ // MSVC2013 and earlier can not const_cast a std::nullptr_t pointer.
+ void delegate(const std::nullptr_t *) {}
void delegate(const void *) {}
void delegate(const QMetaTypeSwitcher::UnknownType*) {}
void delegate(const QMetaTypeSwitcher::NotBuiltinType *where)
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index b68dbacbd3..9e2a5bf75d 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -86,6 +86,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
F(UChar, 37, uchar) \
F(Float, 38, float) \
F(SChar, 40, signed char) \
+ F(Nullptr, 51, std::nullptr_t) \
#define QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)\
F(VoidStar, 31, void*) \
@@ -414,7 +415,7 @@ public:
QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID)
FirstCoreType = Bool,
- LastCoreType = QPersistentModelIndex,
+ LastCoreType = Nullptr,
FirstGuiType = QFont,
LastGuiType = QPolygonF,
FirstWidgetsType = QSizePolicy,
@@ -506,11 +507,8 @@ public:
static int registerTypedef(const char *typeName, int aliasId);
static int registerNormalizedTypedef(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName, int aliasId);
static int type(const char *typeName);
-#ifndef Q_QDOC
+
static int type(const QT_PREPEND_NAMESPACE(QByteArray) &typeName);
-#else
- static int type(const QByteArray &typeName);
-#endif
static const char *typeName(int type);
static int sizeOf(int type);
static TypeFlags typeFlags(int type);
@@ -600,8 +598,11 @@ public:
}
#ifdef Q_QDOC
+ template<typename MemberFunction, int>
static bool registerConverter(MemberFunction function);
+ template<typename MemberFunctionOk, char>
static bool registerConverter(MemberFunctionOk function);
+ template<typename UnaryFunction>
static bool registerConverter(UnaryFunction function);
#else
// member function as in "QString QFont::toString() const"
@@ -1621,16 +1622,9 @@ namespace QtPrivate {
{ return -1; }
};
-#ifndef Q_COMPILER_VARIADIC_TEMPLATES
// Function pointers don't derive from QObject
- template <class Result> struct IsPointerToTypeDerivedFromQObject<Result(*)()> { enum { Value = false }; };
- template <class Result, class Arg0> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0)> { enum { Value = false }; };
- template <class Result, class Arg0, class Arg1> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0, Arg1)> { enum { Value = false }; };
- template <class Result, class Arg0, class Arg1, class Arg2> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0, Arg1, Arg2)> { enum { Value = false }; };
-#else
template <typename Result, typename... Args>
struct IsPointerToTypeDerivedFromQObject<Result(*)(Args...)> { enum { Value = false }; };
-#endif
template<typename T>
struct QMetaTypeTypeFlags
@@ -1857,6 +1851,7 @@ inline int qRegisterMetaTypeStreamOperators()
} QT_END_NAMESPACE \
/**/
+#ifndef Q_MOC_RUN
#define Q_DECLARE_METATYPE(TYPE) Q_DECLARE_METATYPE_IMPL(TYPE)
#define Q_DECLARE_METATYPE_IMPL(TYPE) \
QT_BEGIN_NAMESPACE \
@@ -1876,7 +1871,7 @@ inline int qRegisterMetaTypeStreamOperators()
} \
}; \
QT_END_NAMESPACE
-
+#endif // Q_MOC_RUN
#define Q_DECLARE_BUILTIN_METATYPE(TYPE, METATYPEID, NAME) \
QT_BEGIN_NAMESPACE \
@@ -1899,7 +1894,9 @@ QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_FORWARD_DECLARE_STATIC_TYPES_ITER)
typedef QList<QVariant> QVariantList;
typedef QMap<QString, QVariant> QVariantMap;
typedef QHash<QString, QVariant> QVariantHash;
+#ifndef Q_QDOC
typedef QList<QByteArray> QByteArrayList;
+#endif
#define Q_DECLARE_METATYPE_TEMPLATE_1ARG(SINGLE_ARG_TEMPLATE) \
QT_BEGIN_NAMESPACE \
diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h
index 445e912cf7..dd0bce2645 100644
--- a/src/corelib/kernel/qmetatype_p.h
+++ b/src/corelib/kernel/qmetatype_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qmetatype.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp
index 84e680dbd9..a550ca6ca1 100644
--- a/src/corelib/kernel/qmimedata.cpp
+++ b/src/corelib/kernel/qmimedata.cpp
@@ -122,7 +122,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
const QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) {
if (list.at(i).type() == QVariant::Url) {
- text.append(list.at(i).toUrl().toDisplayString() + QLatin1Char('\n'));
+ text += list.at(i).toUrl().toDisplayString() + QLatin1Char('\n');
++numUrls;
}
}
@@ -167,7 +167,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
case QVariant::List: {
if (format != QLatin1String("text/uri-list"))
break;
- // fall through
+ Q_FALLTHROUGH();
}
case QVariant::Url: {
QByteArray ba = data.toByteArray();
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index c235260f1b..e901d8cefa 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4248,7 +4248,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
This macro registers an enum type with the meta-object system.
It must be placed after the enum declaration in a class that has the Q_OBJECT or the
- Q_GADGET macro.
+ Q_GADGET macro. For namespaces use \l Q_ENUM_NS instead.
For example:
@@ -4275,7 +4275,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
This macro registers a single \l{QFlags}{flags type} with the
meta-object system. It is typically used in a class definition to declare
that values of a given enum can be used as flags and combined using the
- bitwise OR operator.
+ bitwise OR operator. For namespaces use \l Q_FLAG_NS instead.
The macro must be placed after the enum declaration.
@@ -4294,6 +4294,48 @@ QDebug operator<<(QDebug dbg, const QObject *o)
\sa {Qt's Property System}
*/
+/*!
+ \macro Q_ENUM_NS(...)
+ \since 5.8
+
+ This macro registers an enum type with the meta-object system.
+ It must be placed after the enum declaration in a namespace that
+ has the Q_NAMESPACE macro. It is the same as \l Q_ENUM but in a
+ namespace.
+
+ Enumerations that are declared with Q_ENUM_NS have their QMetaEnum
+ registered in the enclosing QMetaObject. You can also use
+ QMetaEnum::fromType() to get the QMetaEnum.
+
+ Registered enumerations are automatically registered also to the Qt meta
+ type system, making them known to QMetaType without the need to use
+ Q_DECLARE_METATYPE(). This will enable useful features; for example, if
+ used in a QVariant, you can convert them to strings. Likewise, passing them
+ to QDebug will print out their names.
+
+ \sa {Qt's Property System}
+*/
+
+
+/*!
+ \macro Q_FLAG_NS(...)
+ \since 5.8
+
+ This macro registers a single \l{QFlags}{flags type} with the
+ meta-object system. It is used in a namespace that has the
+ Q_NAMESPACE macro, to declare that values of a given enum can be
+ used as flags and combined using the bitwise OR operator.
+ It is the same as \l Q_FLAG but in a namespace.
+
+ The macro must be placed after the enum declaration.
+
+ \note The Q_FLAG_NS macro takes care of registering individual flag
+ values with the meta-object system, so it is unnecessary to use
+ Q_ENUM_NS() in addition to this macro.
+
+ \sa {Qt's Property System}
+*/
+
/*!
\macro Q_OBJECT
@@ -4335,6 +4377,21 @@ QDebug operator<<(QDebug dbg, const QObject *o)
*/
/*!
+ \macro Q_NAMESPACE
+ \since 5.8
+
+ The Q_NAMESPACE macro can be used to add QMetaObject capabilities
+ to a namespace.
+
+ Q_NAMESPACEs can have Q_CLASSINFO, Q_ENUM_NS, Q_FLAG_NS, but they
+ cannot have Q_ENUM, Q_FLAG, Q_PROPERTY, Q_INVOKABLE, signals nor slots.
+
+ Q_NAMESPACE makes an external variable, \c{staticMetaObject}, available.
+ \c{staticMetaObject} is of type QMetaObject and provides access to the
+ enums declared with Q_ENUM_NS/Q_FLAG_NS.
+*/
+
+/*!
\macro Q_SIGNALS
\relates QObject
@@ -4471,6 +4528,19 @@ QDebug operator<<(QDebug dbg, const QObject *o)
*/
/*!
+ \macro QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
+ \relates QObject
+ \since 5.8
+
+ Defining this macro will disable narrowing and floating-point-to-integral
+ conversions between the arguments carried by a signal and the arguments
+ accepted by a slot, when the signal and the slot are connected using the
+ PMF-based syntax.
+
+ \sa QObject::connect
+*/
+
+/*!
\typedef QObjectList
\relates QObject
@@ -4776,11 +4846,12 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
c->isSlotObject = false;
}
+ c->sender->disconnectNotify(QMetaObjectPrivate::signal(c->sender->metaObject(),
+ c->signal_index));
+
const_cast<QMetaObject::Connection &>(connection).d_ptr = 0;
c->deref(); // has been removed from the QMetaObject::Connection object
- // disconnectNotify() not called (the signal index is unknown).
-
return true;
}
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index c06f702b30..3cec9802dc 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -210,8 +210,11 @@ public:
const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection);
+ template<typename PointerToMemberFunction, typename Functor>
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor);
+ template<typename PointerToMemberFunction, typename Functor>
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type = Qt::AutoConnection);
#else
//Connect a signal to a pointer to qobject member function
@@ -337,6 +340,7 @@ public:
static bool disconnect(const QMetaObject::Connection &);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
static bool disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method);
#else
template <typename Func1, typename Func2>
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index aa68c9c1ad..d7ae63a98c 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -97,7 +97,7 @@ namespace QtPrivate {
inline void destroyIfLastRef() Q_DECL_NOTHROW
{ if (!m_ref.deref()) m_impl(Destroy, this, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR); }
- inline bool compare(void **a) { bool ret; m_impl(Compare, this, Q_NULLPTR, a, &ret); return ret; }
+ inline bool compare(void **a) { bool ret = false; m_impl(Compare, this, Q_NULLPTR, a, &ret); return ret; }
inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, Q_NULLPTR); }
protected:
~QSlotObjectBase() {}
@@ -143,10 +143,9 @@ namespace QtPrivate {
case Call:
FuncType::template call<Args, R>(static_cast<QStaticSlotObject*>(this_)->function, r, a);
break;
- case Compare:
- *ret = false; // not implemented
- break;
- case NumOperations: ;
+ case Compare: // not implemented
+ case NumOperations:
+ Q_UNUSED(ret);
}
}
public:
@@ -168,10 +167,9 @@ namespace QtPrivate {
case Call:
FuncType::template call<Args, R>(static_cast<QFunctorSlotObject*>(this_)->function, r, a);
break;
- case Compare:
- *ret = false; // not implemented
- break;
- case NumOperations: ;
+ case Compare: // not implemented
+ case NumOperations:
+ Q_UNUSED(ret);
}
}
public:
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 4383ece245..a7d7ef0889 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qobject.h"
#include "QtCore/qpointer.h"
#include "QtCore/qsharedpointer.h"
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index a40614bd31..5cdbef443b 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -124,6 +124,11 @@ class QString;
friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #ENUM; }
#define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x)
#define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x)
+#define Q_ENUM_NS_IMPL(ENUM) \
+ inline Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) Q_DECL_NOEXCEPT { return &staticMetaObject; } \
+ inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #ENUM; }
+#define Q_ENUM_NS(x) Q_ENUMS(x) Q_ENUM_NS_IMPL(x)
+#define Q_FLAG_NS(x) Q_FLAGS(x) Q_ENUM_NS_IMPL(x)
#define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable)
#define Q_INVOKABLE QT_ANNOTATE_FUNCTION(qt_invokable)
#define Q_SIGNAL QT_ANNOTATE_FUNCTION(qt_signal)
@@ -227,6 +232,12 @@ private: \
QT_WARNING_POP \
QT_ANNOTATE_CLASS(qt_qgadget, "") \
/*end*/
+
+#define Q_NAMESPACE \
+ extern const QMetaObject staticMetaObject; \
+ QT_ANNOTATE_CLASS(qt_qnamespace, "") \
+ /*end*/
+
#endif // QT_NO_META_MACROS
#else // Q_MOC_RUN
diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h
index 5eae70ecc5..e94e713e1f 100644
--- a/src/corelib/kernel/qobjectdefs_impl.h
+++ b/src/corelib/kernel/qobjectdefs_impl.h
@@ -50,6 +50,8 @@
#pragma qt_sync_stop_processing
#endif
+#include <type_traits>
+
QT_BEGIN_NAMESPACE
@@ -194,6 +196,46 @@ namespace QtPrivate {
};
/*
+ Logic that checks if the underlying type of an enum is signed or not.
+ Needs an external, explicit check that E is indeed an enum. Works
+ around the fact that it's undefined behavior to instantiate
+ std::underlying_type on non-enums (cf. §20.13.7.6 [meta.trans.other]).
+ */
+ template<typename E, typename Enable = void>
+ struct IsEnumUnderlyingTypeSigned : std::false_type
+ {
+ };
+
+ template<typename E>
+ struct IsEnumUnderlyingTypeSigned<E, typename std::enable_if<std::is_enum<E>::value>::type>
+ : std::integral_constant<bool, std::is_signed<typename std::underlying_type<E>::type>::value>
+ {
+ };
+
+ /*
+ Logic that checks if the argument of the slot does not narrow the
+ argument of the signal when used in list initialization. Cf. §8.5.4.7
+ [dcl.init.list] for the definition of narrowing.
+ For incomplete From/To types, there's no narrowing.
+ */
+ template<typename From, typename To, typename Enable = void>
+ struct AreArgumentsNarrowedBase : std::false_type
+ {
+ };
+
+ template<typename From, typename To>
+ struct AreArgumentsNarrowedBase<From, To, typename std::enable_if<sizeof(From) && sizeof(To)>::type>
+ : std::integral_constant<bool,
+ (std::is_floating_point<From>::value && std::is_integral<To>::value) ||
+ (std::is_floating_point<From>::value && std::is_floating_point<To>::value && sizeof(From) > sizeof(To)) ||
+ ((std::is_integral<From>::value || std::is_enum<From>::value) && std::is_floating_point<To>::value) ||
+ (std::is_integral<From>::value && std::is_integral<To>::value && (sizeof(From) > sizeof(To) || std::is_signed<From>::value != std::is_signed<To>::value)) ||
+ (std::is_enum<From>::value && std::is_integral<To>::value && (sizeof(From) > sizeof(To) || IsEnumUnderlyingTypeSigned<From>::value != std::is_signed<To>::value))
+ >
+ {
+ };
+
+ /*
Logic that check if the arguments of the slot matches the argument of the signal.
To be used like this:
Q_STATIC_ASSERT(CheckCompatibleArguments<FunctionPointer<Signal>::Arguments, FunctionPointer<Slot>::Arguments>::value)
@@ -203,6 +245,10 @@ namespace QtPrivate {
static char test(...);
static const typename RemoveRef<A1>::Type &dummy();
enum { value = sizeof(test(dummy())) == sizeof(int) };
+#ifdef QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
+ struct AreArgumentsNarrowed : AreArgumentsNarrowedBase<typename RemoveRef<A1>::Type, typename RemoveRef<A2>::Type> {};
+ Q_STATIC_ASSERT_X(!AreArgumentsNarrowed::value, "Signal and slot arguments are not compatible (narrowing)");
+#endif
};
template<typename A1, typename A2> struct AreArgumentsCompatible<A1, A2&> { enum { value = false }; };
template<typename A> struct AreArgumentsCompatible<A&, A&> { enum { value = true }; };
diff --git a/src/corelib/kernel/qppsattribute_p.h b/src/corelib/kernel/qppsattribute_p.h
index 1d9cc4484c..035756e002 100644
--- a/src/corelib/kernel/qppsattribute_p.h
+++ b/src/corelib/kernel/qppsattribute_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QList>
#include <QMap>
#include <QSharedDataPointer>
diff --git a/src/corelib/kernel/qppsobject.cpp b/src/corelib/kernel/qppsobject.cpp
index 30498a380d..dd01d48cc0 100644
--- a/src/corelib/kernel/qppsobject.cpp
+++ b/src/corelib/kernel/qppsobject.cpp
@@ -397,12 +397,12 @@ QByteArray QPpsObjectPrivate::encode(const QVariantMap &ppsData, bool *ok)
void QPpsObjectPrivate::encodeData(pps_encoder_t *encoder, const char *name, const QVariant &data,
bool *ok)
{
- QString errorFunction;
+ const char *errorFunction;
pps_encoder_error_t error = PPS_ENCODER_OK;
switch (data.type()) {
case QVariant::Bool:
error = pps_encoder_add_bool(encoder, name, data.toBool());
- errorFunction = QStringLiteral("pps_encoder_add_bool");
+ errorFunction = "pps_encoder_add_bool";
break;
// We want to support encoding uint even though libpps doesn't support it directly.
// We can't encode uint as an int since that will lose precision (e.g. 2^31+1 can't be
@@ -411,41 +411,41 @@ void QPpsObjectPrivate::encodeData(pps_encoder_t *encoder, const char *name, con
case QVariant::UInt:
case QVariant::Double:
error = pps_encoder_add_double(encoder, name, data.toDouble());
- errorFunction = QStringLiteral("pps_encoder_add_double");
+ errorFunction = "pps_encoder_add_double";
break;
case QVariant::Int:
error = pps_encoder_add_int(encoder, name, data.toInt());
- errorFunction = QStringLiteral("pps_encoder_add_int");
+ errorFunction = "pps_encoder_add_int";
break;
case QVariant::LongLong:
error = pps_encoder_add_int64(encoder, name, data.toLongLong());
- errorFunction = QStringLiteral("pps_encoder_add_int64");
+ errorFunction = "pps_encoder_add_int64";
break;
case QVariant::String:
error = pps_encoder_add_string(encoder, name, data.toString().toUtf8().constData());
- errorFunction = QStringLiteral("pps_encoder_add_string");
+ errorFunction = "pps_encoder_add_string";
break;
case QVariant::List:
error = pps_encoder_start_array(encoder, name);
- errorFunction = QStringLiteral("pps_encoder_start_array");
+ errorFunction = "pps_encoder_start_array";
if (error == PPS_ENCODER_OK) {
encodeArray(encoder, data.toList(), ok);
error = pps_encoder_end_array(encoder);
- errorFunction = QStringLiteral("pps_encoder_end_array");
+ errorFunction = "pps_encoder_end_array";
}
break;
case QVariant::Map:
error = pps_encoder_start_object(encoder, name);
- errorFunction = QStringLiteral("pps_encoder_start_object");
+ errorFunction = "pps_encoder_start_object";
if (error == PPS_ENCODER_OK) {
encodeObject(encoder, data.toMap(), ok);
error = pps_encoder_end_object(encoder);
- errorFunction = QStringLiteral("pps_encoder_end_object");
+ errorFunction = "pps_encoder_end_object";
}
break;
case QVariant::Invalid:
error = pps_encoder_add_null(encoder, name);
- errorFunction = QStringLiteral("pps_encoder_add_null");
+ errorFunction = "pps_encoder_add_null";
break;
default:
qWarning("QPpsObjectPrivate::encodeData: the type of the parameter data is invalid");
@@ -454,7 +454,7 @@ void QPpsObjectPrivate::encodeData(pps_encoder_t *encoder, const char *name, con
}
if (error != PPS_ENCODER_OK) {
- qWarning() << "QPpsObjectPrivate::encodeData: " << errorFunction << " failed";
+ qWarning("QPpsObjectPrivate::encodeData: %s failed", errorFunction);
*ok = false;
} else {
*ok = true;
diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp
index e998b938c7..07d4930332 100644
--- a/src/corelib/kernel/qsharedmemory_win.cpp
+++ b/src/corelib/kernel/qsharedmemory_win.cpp
@@ -64,8 +64,8 @@ void QSharedMemoryPrivate::setErrorString(QLatin1String function)
errorString = QSharedMemory::tr("%1: already exists").arg(function);
break;
case ERROR_FILE_NOT_FOUND:
-#if defined(Q_OS_WINCE) || (defined(Q_OS_WINRT) && _MSC_VER < 1900)
- // This happens on CE only if no file is present as CreateFileMappingW
+#if defined(Q_OS_WINRT) && _MSC_VER < 1900
+ // This happens on WinRT only if no file is present as CreateFileMappingW
// bails out with this error code
case ERROR_INVALID_PARAMETER:
#endif
@@ -112,10 +112,6 @@ HANDLE QSharedMemoryPrivate::handle()
#else
hand = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, (PCWSTR)nativeKey.utf16());
#endif
-#elif defined(Q_OS_WINCE)
- // This works for opening a mapping too, but always opens it with read/write access in
- // attach as it seems.
- hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)nativeKey.utf16());
#else
hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)nativeKey.utf16());
#endif
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 12fd5404da..3899f24d3b 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -39,15 +39,9 @@
#include <qglobal.h>
#include "qsystemerror_p.h"
-#if !defined(Q_OS_WINCE)
-# include <errno.h>
-# if defined(Q_CC_MSVC)
-# include <crtdbg.h>
-# endif
-#else
-# if (_WIN32_WCE >= 0x700)
-# include <errno.h>
-# endif
+#include <errno.h>
+#if defined(Q_CC_MSVC)
+# include <crtdbg.h>
#endif
#ifdef Q_OS_WIN
# include <qt_windows.h>
@@ -131,16 +125,12 @@ static QString standardLibraryErrorString(int errorCode)
s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
break;
default: {
- #ifdef Q_OS_WINCE
- ret = windowsErrorString(errorCode);
- #else
- #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
+ #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
QByteArray buf(1024, '\0');
ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
- #else
+ #else
ret = QString::fromLocal8Bit(strerror(errorCode));
- #endif
- #endif
+ #endif
break; }
}
if (s) {
@@ -159,12 +149,13 @@ QString QSystemError::toString() const
return windowsErrorString(errorCode);
#else
//unix: fall through as native and standard library are the same
+ Q_FALLTHROUGH();
#endif
case StandardLibraryError:
return standardLibraryErrorString(errorCode);
default:
qWarning("invalid error scope");
- //fall through
+ Q_FALLTHROUGH();
case NoError:
return QLatin1String("No error");
}
diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h
index c3d8118711..440b763149 100644
--- a/src/corelib/kernel/qsystemerror_p.h
+++ b/src/corelib/kernel/qsystemerror_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qstring.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qsystemsemaphore_p.h b/src/corelib/kernel/qsystemsemaphore_p.h
index 26647db2e1..3b55d80276 100644
--- a/src/corelib/kernel/qsystemsemaphore_p.h
+++ b/src/corelib/kernel/qsystemsemaphore_p.h
@@ -56,9 +56,7 @@
#ifndef QT_NO_SYSTEMSEMAPHORE
#include "qsharedmemory_p.h"
-#ifndef Q_OS_WINCE
-# include <sys/types.h>
-#endif
+#include <sys/types.h>
#ifdef QT_POSIX_IPC
# include <semaphore.h>
#endif
diff --git a/src/corelib/kernel/qsystemsemaphore_posix.cpp b/src/corelib/kernel/qsystemsemaphore_posix.cpp
index 6137239467..9fbf5779b8 100644
--- a/src/corelib/kernel/qsystemsemaphore_posix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_posix.cpp
@@ -147,7 +147,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
if (::sem_post(semaphore) == -1) {
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore (sem_post)"));
#if defined QSYSTEMSEMAPHORE_DEBUG
- qDebug() << QLatin1String("QSystemSemaphore::modify sem_post failed") << count << errno;
+ qDebug("QSystemSemaphore::modify sem_post failed %d %d", count, errno);
#endif
// rollback changes to preserve the SysV semaphore behavior
for ( ; cnt < count; ++cnt) {
@@ -169,7 +169,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
}
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore (sem_wait)"));
#if defined QSYSTEMSEMAPHORE_DEBUG
- qDebug() << QLatin1String("QSystemSemaphore::modify sem_wait failed") << count << errno;
+ qDebug("QSystemSemaphore::modify sem_wait failed %d %d", count, errno);
#endif
return false;
}
diff --git a/src/corelib/kernel/qsystemsemaphore_systemv.cpp b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
index f4fdfa5f58..1967899a58 100644
--- a/src/corelib/kernel/qsystemsemaphore_systemv.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
@@ -187,7 +187,8 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
}
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore"));
#if defined QSYSTEMSEMAPHORE_DEBUG
- qDebug() << QLatin1String("QSystemSemaphore::modify failed") << count << semctl(semaphore, 0, GETVAL) << errno << EIDRM << EINVAL;
+ qDebug("QSystemSemaphore::modify failed %d %d %d %d %d",
+ count, int(semctl(semaphore, 0, GETVAL)), int(errno), int(EIDRM), int(EINVAL);
#endif
return false;
}
diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp
index 236e346afe..3395f5641e 100644
--- a/src/corelib/kernel/qsystemsemaphore_win.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_win.cpp
@@ -121,11 +121,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
return false;
}
} else {
-#if !defined(Q_OS_WINCE)
if (WAIT_OBJECT_0 != WaitForSingleObjectEx(semaphore, INFINITE, FALSE)) {
-#else
- if (WAIT_OBJECT_0 != WaitForSingleObject(semaphore, INFINITE)) {
-#endif
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore"));
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug("QSystemSemaphore::modifySemaphore WaitForSingleObject failed");
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index 80accc0cb8..8ba494ec3d 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -533,6 +533,78 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
*/
/*!
+ \fn void QTimer::singleShot(std::chrono::duration<Rep, Period> value, const QObject *receiver, const char *member)
+ \since 5.8
+ \overload
+ \reentrant
+
+ This static function calls a slot after a given time interval.
+
+ It is very convenient to use this function because you do not need
+ to bother with a \l{QObject::timerEvent()}{timerEvent} or
+ create a local QTimer object.
+
+ The \a receiver is the receiving object and the \a member is the slot. The
+ time interval is given in the duration object \a value.
+
+ \sa start()
+*/
+
+/*!
+ \fn void QTimer::singleShot(std::chrono::duration<Rep, Period> value, Qt::TimerType timerType, const QObject *receiver, const char *member)
+ \since 5.8
+ \overload
+ \reentrant
+
+ This static function calls a slot after a given time interval.
+
+ It is very convenient to use this function because you do not need
+ to bother with a \l{QObject::timerEvent()}{timerEvent} or
+ create a local QTimer object.
+
+ The \a receiver is the receiving object and the \a member is the slot. The
+ time interval is given in the duration object \a value. The \a timerType affects the
+ accuracy of the timer.
+
+ \sa start()
+*/
+
+/*!
+ \fn void QTimer::start(std::chrono::duration<Rep, Period> value)
+ \since 5.8
+ \overload
+
+ Starts or restarts the timer with a timeout of duration \a value.
+
+ If the timer is already running, it will be
+ \l{QTimer::stop()}{stopped} and restarted.
+
+ If \l singleShot is true, the timer will be activated only once.
+*/
+
+/*!
+ \fn std::chrono::milliseconds QTimer::intervalAsDuration() const
+ \since 5.8
+
+ Returns the interval of this timer as a \c std::chrono::milliseconds object.
+
+ \sa interval
+*/
+
+/*!
+ \fn std::chrono::milliseconds QTimer::remainingTimeAsDuration() const
+ \since 5.8
+
+ Returns the time remaining in this timer object as a \c
+ std::chrono::milliseconds object. If this timer is due or overdue, the
+ returned value is \c std::chrono::milliseconds::zero(). If the remaining
+ time could not be found or the timer is not active, this function returns a
+ negative duration.
+
+ \sa remainingTime()
+*/
+
+/*!
\property QTimer::singleShot
\brief whether the timer is a single-shot timer
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index dd52d52a1c..1567fe760c 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -47,6 +47,10 @@
#include <QtCore/qbasictimer.h> // conceptual inheritance
#include <QtCore/qobject.h>
+#if QT_HAS_INCLUDE(<chrono>)
+# include <chrono>
+#endif
+
QT_BEGIN_NAMESPACE
@@ -80,21 +84,27 @@ public:
static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
static void singleShot(int msec, const QObject *receiver, PointerToMemberFunction method);
+ template<typename PointerToMemberFunction>
static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, PointerToMemberFunction method);
+ template<typename Functor>
static void singleShot(int msec, Functor functor);
+ template<typename Functor>
static void singleShot(int msec, Qt::TimerType timerType, Functor functor);
+ template<typename Functor, int>
static void singleShot(int msec, const QObject *context, Functor functor);
+ template<typename Functor, int>
static void singleShot(int msec, Qt::TimerType timerType, const QObject *context, Functor functor);
#else
// singleShot to a QObject slot
- template <typename Func1>
- static inline void singleShot(int msec, const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot)
+ template <typename Duration, typename Func1>
+ static inline void singleShot(Duration interval, const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot)
{
- singleShot(msec, msec >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer, receiver, slot);
+ singleShot(interval, defaultTypeFor(interval), receiver, slot);
}
- template <typename Func1>
- static inline void singleShot(int msec, Qt::TimerType timerType, const typename QtPrivate::FunctionPointer<Func1>::Object *receiver,
+ template <typename Duration, typename Func1>
+ static inline void singleShot(Duration interval, Qt::TimerType timerType, const typename QtPrivate::FunctionPointer<Func1>::Object *receiver,
Func1 slot)
{
typedef QtPrivate::FunctionPointer<Func1> SlotType;
@@ -103,42 +113,42 @@ public:
Q_STATIC_ASSERT_X(int(SlotType::ArgumentCount) == 0,
"The slot must not have any arguments.");
- singleShotImpl(msec, timerType, receiver,
+ singleShotImpl(interval, timerType, receiver,
new QtPrivate::QSlotObject<Func1, typename SlotType::Arguments, void>(slot));
}
// singleShot to a functor or function pointer (without context)
- template <typename Func1>
+ template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!QtPrivate::is_same<const char*, Func1>::value, void>::Type
- singleShot(int msec, Func1 slot)
+ singleShot(Duration interval, Func1 slot)
{
- singleShot(msec, msec >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer, Q_NULLPTR, slot);
+ singleShot(interval, defaultTypeFor(interval), nullptr, slot);
}
- template <typename Func1>
+ template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!QtPrivate::is_same<const char*, Func1>::value, void>::Type
- singleShot(int msec, Qt::TimerType timerType, Func1 slot)
+ singleShot(Duration interval, Qt::TimerType timerType, Func1 slot)
{
- singleShot(msec, timerType, Q_NULLPTR, slot);
+ singleShot(interval, timerType, nullptr, slot);
}
// singleShot to a functor or function pointer (with context)
- template <typename Func1>
+ template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!QtPrivate::is_same<const char*, Func1>::value, void>::Type
- singleShot(int msec, QObject *context, Func1 slot)
+ singleShot(Duration interval, QObject *context, Func1 slot)
{
- singleShot(msec, msec >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer, context, slot);
+ singleShot(interval, defaultTypeFor(interval), context, slot);
}
- template <typename Func1>
+ template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!QtPrivate::is_same<const char*, Func1>::value, void>::Type
- singleShot(int msec, Qt::TimerType timerType, QObject *context, Func1 slot)
+ singleShot(Duration interval, Qt::TimerType timerType, QObject *context, Func1 slot)
{
//compilation error if the slot has arguments.
typedef QtPrivate::FunctionPointer<Func1> SlotType;
Q_STATIC_ASSERT_X(int(SlotType::ArgumentCount) <= 0, "The slot must not have any arguments.");
- singleShotImpl(msec, timerType, context,
+ singleShotImpl(interval, timerType, context,
new QtPrivate::QFunctorSlotObject<Func1, 0,
typename QtPrivate::List_Left<void, 0>::Value, void>(slot));
}
@@ -153,6 +163,43 @@ public Q_SLOTS:
Q_SIGNALS:
void timeout(QPrivateSignal);
+public:
+#if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC)
+ template <class Rep, class Period>
+ void setInterval(std::chrono::duration<Rep, Period> value)
+ {
+ setInterval(std::chrono::duration_cast<std::chrono::milliseconds>(value).count());
+ }
+
+ std::chrono::milliseconds intervalAsDuration() const
+ {
+ return std::chrono::milliseconds(interval());
+ }
+
+ std::chrono::milliseconds remainingTimeAsDuration() const
+ {
+ return std::chrono::milliseconds(remainingTime());
+ }
+
+ template <class Rep, class Period>
+ static void singleShot(std::chrono::duration<Rep, Period> value, const QObject *receiver, const char *member)
+ {
+ singleShot(int(std::chrono::duration_cast<std::chrono::milliseconds>(value).count()), receiver, member);
+ }
+
+ template <class Rep, class Period>
+ static void singleShot(std::chrono::duration<Rep, Period> value, Qt::TimerType timerType, const QObject *receiver, const char *member)
+ {
+ singleShot(int(std::chrono::duration_cast<std::chrono::milliseconds>(value).count()), timerType, receiver, member);
+ }
+
+ template <class Rep, class Period>
+ void start(std::chrono::duration<Rep, Period> value)
+ {
+ start(int(std::chrono::duration_cast<std::chrono::milliseconds>(value).count()));
+ }
+#endif
+
protected:
void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
@@ -162,9 +209,25 @@ private:
inline int startTimer(int){ return -1;}
inline void killTimer(int){}
+ static Q_DECL_CONSTEXPR Qt::TimerType defaultTypeFor(int msecs) Q_DECL_NOTHROW
+ { return msecs >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer; }
static void singleShotImpl(int msec, Qt::TimerType timerType,
const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj);
+#if QT_HAS_INCLUDE(<chrono>)
+ template <class Rep, class Period>
+ static Qt::TimerType defaultTypeFor(std::chrono::duration<Rep, Period> interval)
+ { return defaultTypeFor(int(std::chrono::duration_cast<std::chrono::milliseconds>(interval).count())); }
+
+ template <class Rep, class Period>
+ static void singleShotImpl(std::chrono::duration<Rep, Period> interval, Qt::TimerType timerType,
+ const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj)
+ {
+ singleShotImpl(int(std::chrono::duration_cast<std::chrono::milliseconds>(interval).count()),
+ timerType, receiver, slotObj);
+ }
+#endif
+
int id, inter, del;
uint single : 1;
uint nulltimer : 1;
diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp
index 56337bdb45..c3b8c86063 100644
--- a/src/corelib/kernel/qtimerinfo_unix.cpp
+++ b/src/corelib/kernel/qtimerinfo_unix.cpp
@@ -468,7 +468,6 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time
// above 20 s, 5% inaccuracy is above 1 s, so we convert to VeryCoarseTimer
if (interval >= 20000) {
t->timerType = Qt::VeryCoarseTimer;
- // fall through
} else {
t->timeout = expected;
if (interval <= 20) {
@@ -479,7 +478,7 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time
}
break;
}
- // fall through
+ Q_FALLTHROUGH();
case Qt::VeryCoarseTimer:
// the very coarse timer is based on full second precision,
// so we keep the interval in seconds (round to closest second)
diff --git a/src/corelib/kernel/qtimerinfo_unix_p.h b/src/corelib/kernel/qtimerinfo_unix_p.h
index 2de8a4681f..7bd6f16ea1 100644
--- a/src/corelib/kernel/qtimerinfo_unix_p.h
+++ b/src/corelib/kernel/qtimerinfo_unix_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
// #define QTIMERINFO_DEBUG
#include "qabstracteventdispatcher.h"
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 2c813b5156..04a5e7ed7a 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -487,10 +487,9 @@ bool QTranslator::load(const QString & filename, const QString & directory,
}
const QString suffixOrDotQM = suffix.isNull() ? dotQmLiteral() : suffix;
- QString fname = filename;
+ QStringRef fname(&filename);
QString realname;
- QString delims;
- delims = search_delimiters.isNull() ? QStringLiteral("_.") : search_delimiters;
+ const QString delims = search_delimiters.isNull() ? QStringLiteral("_.") : search_delimiters;
for (;;) {
QFileInfo fi;
diff --git a/src/corelib/kernel/qtranslator_p.h b/src/corelib/kernel/qtranslator_p.h
index 21de8e2a8c..e148637ac6 100644
--- a/src/corelib/kernel/qtranslator_p.h
+++ b/src/corelib/kernel/qtranslator_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
enum {
Q_EQ = 0x01,
Q_LT = 0x02,
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index a8cc1095fe..72ae3b063f 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -203,7 +203,7 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok)
case QMetaType::QJsonValue:
if (!v_cast<QJsonValue>(d)->isDouble())
break;
- // no break
+ Q_FALLTHROUGH();
#endif
case QVariant::Double:
case QVariant::Int:
@@ -278,7 +278,7 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok)
case QMetaType::QJsonValue:
if (!v_cast<QJsonValue>(d)->isDouble())
break;
- // no break
+ Q_FALLTHROUGH();
#endif
case QVariant::Double:
case QVariant::Int:
@@ -3119,7 +3119,7 @@ bool QVariant::canConvert(int targetTypeId) const
case QVariant::Int:
if (currentType == QVariant::KeySequence)
return true;
- // fall through
+ Q_FALLTHROUGH();
case QVariant::UInt:
case QVariant::LongLong:
case QVariant::ULongLong:
diff --git a/src/corelib/mimetypes/mimetypes.pri b/src/corelib/mimetypes/mimetypes.pri
index 1ab773fc10..870b6c65a5 100644
--- a/src/corelib/mimetypes/mimetypes.pri
+++ b/src/corelib/mimetypes/mimetypes.pri
@@ -1,6 +1,7 @@
# Qt core mimetype module
-HEADERS += \
+qtConfig(mimetype) {
+ HEADERS += \
mimetypes/qmimedatabase.h \
mimetypes/qmimetype.h \
mimetypes/qmimemagicrulematcher_p.h \
@@ -11,7 +12,7 @@ HEADERS += \
mimetypes/qmimeglobpattern_p.h \
mimetypes/qmimeprovider_p.h
-SOURCES += \
+ SOURCES += \
mimetypes/qmimedatabase.cpp \
mimetypes/qmimetype.cpp \
mimetypes/qmimemagicrulematcher.cpp \
@@ -20,6 +21,5 @@ SOURCES += \
mimetypes/qmimeglobpattern.cpp \
mimetypes/qmimeprovider.cpp
-!contains(DEFINES, QT_NO_MIMETYPE) {
RESOURCES += mimetypes/mimetypes.qrc
}
diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp
index 94be5385f3..568f9bf4de 100644
--- a/src/corelib/mimetypes/qmimeglobpattern.cpp
+++ b/src/corelib/mimetypes/qmimeglobpattern.cpp
@@ -124,7 +124,7 @@ bool QMimeGlobPattern::matchFileName(const QString &inputFilename) const
if (starCount == 1 && m_pattern.at(pattern_len - 1) == QLatin1Char('*')) {
if (len + 1 < pattern_len) return false;
if (m_pattern.at(0) == QLatin1Char('*'))
- return filename.indexOf(m_pattern.mid(1, pattern_len - 2)) != -1;
+ return filename.indexOf(m_pattern.midRef(1, pattern_len - 2)) != -1;
const QChar *c1 = m_pattern.unicode();
const QChar *c2 = filename.unicode();
diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h
index e4c74ff7fa..3e4fdb50f6 100644
--- a/src/corelib/mimetypes/qmimeglobpattern_p.h
+++ b/src/corelib/mimetypes/qmimeglobpattern_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#ifndef QT_NO_MIMETYPE
diff --git a/src/corelib/mimetypes/qmimemagicrule_p.h b/src/corelib/mimetypes/qmimemagicrule_p.h
index 26f93d96cc..0c6c1dbcd7 100644
--- a/src/corelib/mimetypes/qmimemagicrule_p.h
+++ b/src/corelib/mimetypes/qmimemagicrule_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#ifndef QT_NO_MIMETYPE
diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp
index dc6eb05d9a..a798d9eff6 100644
--- a/src/corelib/mimetypes/qmimeprovider.cpp
+++ b/src/corelib/mimetypes/qmimeprovider.cpp
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
static QString fallbackParent(const QString &mimeTypeName)
{
- const QString myGroup = mimeTypeName.left(mimeTypeName.indexOf(QLatin1Char('/')));
+ const QStringRef myGroup = mimeTypeName.leftRef(mimeTypeName.indexOf(QLatin1Char('/')));
// All text/* types are subclasses of text/plain.
if (myGroup == QLatin1String("text") && mimeTypeName != QLatin1String("text/plain"))
return QLatin1String("text/plain");
@@ -217,22 +217,24 @@ bool QMimeBinaryProvider::isValid()
bool QMimeBinaryProvider::CacheFileList::checkCacheChanged()
{
bool somethingChanged = false;
- QMutableListIterator<CacheFile *> it(*this);
- while (it.hasNext()) {
- CacheFile *cacheFile = it.next();
+ for (CacheFile *cacheFile : qAsConst(*this)) {
QFileInfo fileInfo(cacheFile->file);
- if (!fileInfo.exists()) { // This can't happen by just running update-mime-database. But the user could use rm -rf :-)
- delete cacheFile;
- it.remove();
- somethingChanged = true;
- } else if (fileInfo.lastModified() > cacheFile->m_mtime) {
- if (!cacheFile->reload()) {
- delete cacheFile;
- it.remove();
- }
+ if (!fileInfo.exists() || fileInfo.lastModified() > cacheFile->m_mtime) {
+ // Deletion can't happen by just running update-mime-database.
+ // But the user could use rm -rf :-)
+ cacheFile->reload(); // will mark itself as invalid on failure
somethingChanged = true;
}
}
+ if (somethingChanged) {
+ auto deleteIfNoLongerValid = [](CacheFile *cacheFile) -> bool {
+ const bool invalid = !cacheFile->isValid();
+ if (invalid)
+ delete cacheFile;
+ return invalid;
+ };
+ erase(std::remove_if(begin(), end(), deleteIfNoLongerValid), end());
+ }
return somethingChanged;
}
@@ -363,7 +365,8 @@ bool QMimeBinaryProvider::matchSuffixTree(QMimeGlobMatchResult &result, QMimeBin
const int weight = flagsAndWeight & 0xff;
const bool caseSensitive = flagsAndWeight & 0x100;
if (caseSensitiveCheck || !caseSensitive) {
- result.addMatch(QLatin1String(mimeType), weight, QLatin1Char('*') + fileName.mid(charPos+1));
+ result.addMatch(QLatin1String(mimeType), weight,
+ QLatin1Char('*') + fileName.midRef(charPos + 1));
success = true;
}
}
@@ -569,10 +572,9 @@ void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
const QString file = data.name + QLatin1String(".xml");
// shared-mime-info since 1.3 lowercases the xml files
- QStringList mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file.toLower());
- if (mimeFiles.isEmpty()) {
- mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file); // pre-1.3
- }
+ QStringList mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/") + file.toLower());
+ if (mimeFiles.isEmpty())
+ mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/") + file); // pre-1.3
if (mimeFiles.isEmpty()) {
qWarning() << "No file found for" << file << ", even though update-mime-info said it would exist.\n"
"Either it was just removed, or the directory doesn't have executable permission..."
@@ -804,7 +806,7 @@ bool QMimeXMLProvider::load(const QString &fileName, QString *errorMessage)
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
if (errorMessage)
- *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(fileName, file.errorString());
+ *errorMessage = QLatin1String("Cannot open ") + fileName + QLatin1String(": ") + file.errorString();
return false;
}
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp
index b259b42ac8..98a0e8eb1b 100644
--- a/src/corelib/mimetypes/qmimetype.cpp
+++ b/src/corelib/mimetypes/qmimetype.cpp
@@ -286,11 +286,12 @@ QString QMimeType::genericIconName() const
// then the mimetype is used to generate the generic icon by using the top-level
// media type (e.g. "video" in "video/ogg") and appending "-x-generic"
// (i.e. "video-x-generic" in the previous example).
- QString group = name();
- const int slashindex = group.indexOf(QLatin1Char('/'));
+ const QString group = name();
+ QStringRef groupRef(&group);
+ const int slashindex = groupRef.indexOf(QLatin1Char('/'));
if (slashindex != -1)
- group = group.left(slashindex);
- return group + QLatin1String("-x-generic");
+ groupRef = groupRef.left(slashindex);
+ return groupRef + QLatin1String("-x-generic");
}
return d->genericIconName;
}
diff --git a/src/corelib/mimetypes/qmimetype_p.h b/src/corelib/mimetypes/qmimetype_p.h
index c89ffbefa3..b0bfad2f65 100644
--- a/src/corelib/mimetypes/qmimetype_p.h
+++ b/src/corelib/mimetypes/qmimetype_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qmimetype.h"
#ifndef QT_NO_MIMETYPE
diff --git a/src/corelib/mimetypes/qmimetypeparser.cpp b/src/corelib/mimetypes/qmimetypeparser.cpp
index 535fa51c92..7693055cc1 100644
--- a/src/corelib/mimetypes/qmimetypeparser.cpp
+++ b/src/corelib/mimetypes/qmimetypeparser.cpp
@@ -85,7 +85,7 @@ static const char matchMaskAttributeC[] = "mask";
\class QMimeTypeParser
\inmodule QtCore
\internal
- \brief The QMimeTypeParser class parses MIME types, and builds a MIME database hierarchy by adding to QMimeDatabasePrivate.
+ \brief The QMimeTypeParser class parses MIME types, and builds a MIME database hierarchy by adding to QMimeDatabase.
Populates QMimeDataBase
diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri
index 544dd41742..473480eb55 100644
--- a/src/corelib/plugin/plugin.pri
+++ b/src/corelib/plugin/plugin.pri
@@ -35,8 +35,4 @@ integrity {
SOURCES += plugin/qlibrary_unix.cpp
}
-darwin {
- OBJECTIVE_SOURCES += plugin/quuid_darwin.mm
-}
-
!no-libdl: LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD
diff --git a/src/corelib/plugin/qelfparser_p.h b/src/corelib/plugin/qelfparser_p.h
index 145f00df43..bcda19e8b5 100644
--- a/src/corelib/plugin/qelfparser_p.h
+++ b/src/corelib/plugin/qelfparser_p.h
@@ -52,7 +52,7 @@
//
#include <qendian.h>
-#include <qglobal.h>
+#include <private/qglobal_p.h>
#ifndef QT_NO_LIBRARY
#if defined (Q_OF_ELF) && defined(Q_CC_GNU)
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index 6cd02e3a3f..c09dc6c22b 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -108,7 +108,11 @@ void QFactoryLoader::update()
if (!QDir(path).exists(QLatin1String(".")))
continue;
- QStringList plugins = QDir(path).entryList(QDir::Files);
+ QStringList plugins = QDir(path).entryList(
+#ifdef Q_OS_WIN
+ QStringList(QStringLiteral("*.dll")),
+#endif
+ QDir::Files);
QLibraryPrivate *library = 0;
#ifdef Q_OS_MAC
@@ -187,10 +191,12 @@ void QFactoryLoader::update()
++keyUsageCount;
}
}
- if (keyUsageCount || keys.isEmpty())
+ if (keyUsageCount || keys.isEmpty()) {
+ library->setLoadHints(QLibrary::PreventUnloadHint); // once loaded, don't unload
d->libraryList += library;
- else
+ } else {
library->release();
+ }
}
}
#else
diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h
index 6f62da484b..0876d141c4 100644
--- a/src/corelib/plugin/qfactoryloader_p.h
+++ b/src/corelib/plugin/qfactoryloader_p.h
@@ -91,8 +91,6 @@ public:
QObject *instance(int index) const;
};
-#ifdef Q_COMPILER_VARIADIC_TEMPLATES
-
template <class PluginInterface, class FactoryInterface, typename ...Args>
PluginInterface *qLoadPlugin(const QFactoryLoader *loader, const QString &key, Args &&...args)
{
@@ -106,68 +104,6 @@ PluginInterface *qLoadPlugin(const QFactoryLoader *loader, const QString &key, A
return nullptr;
}
-#else
-
-template <class PluginInterface, class FactoryInterface>
- PluginInterface *qLoadPlugin(const QFactoryLoader *loader, const QString &key)
-{
- const int index = loader->indexOf(key);
- if (index != -1) {
- QObject *factoryObject = loader->instance(index);
- if (FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
- if (PluginInterface *result = factory->create(key))
- return result;
- }
- return 0;
-}
-
-template <class PluginInterface, class FactoryInterface, class P1>
-PluginInterface *qLoadPlugin(const QFactoryLoader *loader,
- const QString &key,
- P1 &&p1)
-{
- const int index = loader->indexOf(key);
- if (index != -1) {
- QObject *factoryObject = loader->instance(index);
- if (FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
- if (PluginInterface *result = factory->create(key, std::forward<P1>(p1)))
- return result;
- }
- return 0;
-}
-
-template <class PluginInterface, class FactoryInterface, class P1, class P2>
-PluginInterface *qLoadPlugin(const QFactoryLoader *loader,
- const QString &key,
- P1 &&p1, P2 &&p2)
-{
- const int index = loader->indexOf(key);
- if (index != -1) {
- QObject *factoryObject = loader->instance(index);
- if (FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
- if (PluginInterface *result = factory->create(key, std::forward<P1>(p1), std::forward<P2>(p2)))
- return result;
- }
- return 0;
-}
-
-template <class PluginInterface, class FactoryInterface, class P1, class P2, class P3>
-PluginInterface *qLoadPlugin(const QFactoryLoader *loader,
- const QString &key,
- P1 &&p1, P2 &&p2, P3 &&p3)
-{
- const int index = loader->indexOf(key);
- if (index != -1) {
- QObject *factoryObject = loader->instance(index);
- if (FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
- if (PluginInterface *result = factory->create(key, std::forward<P1>(p1), std::forward<P2>(p2), std::forward<P3>(p3)))
- return result;
- }
- return 0;
-}
-
-#endif
-
template <class PluginInterface, class FactoryInterface, typename Arg>
Q_DECL_DEPRECATED PluginInterface *qLoadPlugin1(const QFactoryLoader *loader, const QString &key, Arg &&arg)
{ return qLoadPlugin<PluginInterface, FactoryInterface>(loader, key, std::forward<Arg>(arg)); }
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 18ce085856..aff2991ed1 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -621,12 +621,12 @@ bool QLibrary::isLibrary(const QString &fileName)
QString completeSuffix = QFileInfo(fileName).completeSuffix();
if (completeSuffix.isEmpty())
return false;
- QStringList suffixes = completeSuffix.split(QLatin1Char('.'));
+ const QVector<QStringRef> suffixes = completeSuffix.splitRef(QLatin1Char('.'));
# if defined(Q_OS_DARWIN)
// On Mac, libs look like libmylib.1.0.0.dylib
- const QString lastSuffix = suffixes.at(suffixes.count() - 1);
- const QString firstSuffix = suffixes.at(0);
+ const QStringRef &lastSuffix = suffixes.at(suffixes.count() - 1);
+ const QStringRef &firstSuffix = suffixes.at(0);
bool valid = (lastSuffix == QLatin1String("dylib")
|| firstSuffix == QLatin1String("so")
@@ -662,7 +662,7 @@ bool QLibrary::isLibrary(const QString &fileName)
int suffix;
int suffixPos = -1;
for (suffix = 0; suffix < validSuffixList.count() && suffixPos == -1; ++suffix)
- suffixPos = suffixes.indexOf(validSuffixList.at(suffix));
+ suffixPos = suffixes.indexOf(QStringRef(&validSuffixList.at(suffix)));
bool valid = suffixPos != -1;
for (int i = suffixPos + 1; i < suffixes.count() && valid; ++i)
diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h
index c3bdc5a832..f883e74843 100644
--- a/src/corelib/plugin/qlibrary_p.h
+++ b/src/corelib/plugin/qlibrary_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qlibrary.h"
#include "QtCore/qpointer.h"
#include "QtCore/qstringlist.h"
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index f6a947b61a..9db0b7ff39 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -50,10 +50,6 @@
# include <private/qcore_mac_p.h>
#endif
-#if defined(QT_AOUT_UNDERSCORE)
-#include <string.h>
-#endif
-
#if (defined(Q_OS_VXWORKS) && !defined(VXWORKS_RTP)) || defined (Q_OS_NACL)
#define QT_NO_DYNAMIC_LIBRARY
#endif
@@ -171,9 +167,6 @@ bool QLibraryPrivate::load_sys()
}
#if !defined(Q_OS_CYGWIN)
else {
-#if defined(Q_OS_MAC)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4)
-#endif
dlFlags |= RTLD_LOCAL;
}
#endif
@@ -308,14 +301,7 @@ Q_CORE_EXPORT QFunctionPointer qt_mac_resolve_sys(void *handle, const char *symb
QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
{
-#if defined(QT_AOUT_UNDERSCORE)
- // older a.out systems add an underscore in front of symbols
- char* undrscr_symbol = new char[strlen(symbol)+2];
- undrscr_symbol[0] = '_';
- strcpy(undrscr_symbol+1, symbol);
- QFunctionPointer address = QFunctionPointer(dlsym(pHnd, undrscr_symbol));
- delete [] undrscr_symbol;
-#elif defined(QT_HPUX_LD)
+#if defined(QT_HPUX_LD)
QFunctionPointer address = 0;
if (shl_findsym((shl_t*)&pHnd, symbol, TYPE_UNDEFINED, &address) < 0)
address = 0;
diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp
index 46fbba151c..48aa0cdbb6 100644
--- a/src/corelib/plugin/qlibrary_win.cpp
+++ b/src/corelib/plugin/qlibrary_win.cpp
@@ -71,15 +71,6 @@ bool QLibraryPrivate::load_sys()
#endif
// We make the following attempts at locating the library:
//
- // WinCE
- // if (absolute)
- // fileName
- // fileName + ".dll"
- // else
- // fileName + ".dll"
- // fileName
- // QFileInfo(fileName).absoluteFilePath()
- //
// Windows
// if (absolute)
// fileName
@@ -97,14 +88,10 @@ bool QLibraryPrivate::load_sys()
// If the fileName is an absolute path we try that first, otherwise we
// use the system-specific suffix first
QFileSystemEntry fsEntry(fileName);
- if (fsEntry.isAbsolute()) {
+ if (fsEntry.isAbsolute())
attempts.prepend(fileName);
- } else {
+ else
attempts.append(fileName);
-#if defined(Q_OS_WINCE)
- attempts.append(QFileInfo(fileName).absoluteFilePath());
-#endif
- }
#ifdef Q_OS_WINRT
if (fileName.startsWith(QLatin1Char('/')))
attempts.prepend(QDir::rootPath() + fileName);
@@ -176,11 +163,7 @@ bool QLibraryPrivate::unload_sys()
QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
{
-#ifdef Q_OS_WINCE
- FARPROC address = GetProcAddress(pHnd, (const wchar_t*)QString::fromLatin1(symbol).utf16());
-#else
FARPROC address = GetProcAddress(pHnd, symbol);
-#endif
if (!address) {
errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg(
QString::fromLatin1(symbol)).arg(
diff --git a/src/corelib/plugin/qmachparser.cpp b/src/corelib/plugin/qmachparser.cpp
index c136ef3797..a599fbcb23 100644
--- a/src/corelib/plugin/qmachparser.cpp
+++ b/src/corelib/plugin/qmachparser.cpp
@@ -59,6 +59,9 @@ static const cpu_type_t my_cputype = CPU_TYPE_X86;
static const cpu_type_t my_cputype = CPU_TYPE_POWERPC64;
#elif defined(Q_PROCESSOR_POWER_32)
static const cpu_type_t my_cputype = CPU_TYPE_POWERPC;
+#elif defined(Q_PROCESSOR_ARM_64)
+# define MACHO64
+static const cpu_type_t my_cputype = CPU_TYPE_ARM64;
#elif defined(Q_PROCESSOR_ARM)
static const cpu_type_t my_cputype = CPU_TYPE_ARM;
#else
diff --git a/src/corelib/plugin/qmachparser_p.h b/src/corelib/plugin/qmachparser_p.h
index 0df7a98f96..ff7eaadb70 100644
--- a/src/corelib/plugin/qmachparser_p.h
+++ b/src/corelib/plugin/qmachparser_p.h
@@ -52,7 +52,7 @@
//
#include <qendian.h>
-#include <qglobal.h>
+#include <private/qglobal_p.h>
#ifndef QT_NO_LIBRARY
#if defined(Q_OF_MACH_O)
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index 094280e3b4..4ec4e43952 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -154,6 +154,7 @@ QPluginLoader::QPluginLoader(const QString &fileName, QObject *parent)
: QObject(parent), d(0), did_load(false)
{
setFileName(fileName);
+ setLoadHints(QLibrary::PreventUnloadHint);
}
/*!
@@ -348,7 +349,7 @@ static QString locatePlugin(const QString& fileName)
void QPluginLoader::setFileName(const QString &fileName)
{
#if defined(QT_SHARED)
- QLibrary::LoadHints lh;
+ QLibrary::LoadHints lh = QLibrary::PreventUnloadHint;
if (d) {
lh = d->loadHints();
d->release();
@@ -394,7 +395,7 @@ QString QPluginLoader::errorString() const
\brief Give the load() function some hints on how it should behave.
You can give hints on how the symbols in the plugin are
- resolved. By default, none of the hints are set.
+ resolved. By default since Qt 5.7, QLibrary::PreventUnloadHint is set.
See the documentation of QLibrary::loadHints for a complete
description of how this property works.
diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp
index 178a33f987..7c80fbbd42 100644
--- a/src/corelib/plugin/qsystemlibrary.cpp
+++ b/src/corelib/plugin/qsystemlibrary.cpp
@@ -68,23 +68,11 @@
DLL Safe search mode is documented in the "Dynamic-Link Library Search
Order" document on MSDN.
-
- Since library loading code is sometimes shared between Windows and WinCE,
- this class can also be used on WinCE. However, its implementation just
- calls the LoadLibrary() function. This is ok since it is documented as not
- loading from the current directory on WinCE. This behaviour is documented
- in the documentation for LoadLibrary for Windows CE at MSDN.
- (http://msdn.microsoft.com/en-us/library/ms886736.aspx)
*/
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_WINCE)
-HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirectory /* = true */)
-{
- return ::LoadLibrary(libraryName);
-}
-#elif defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirectory /* = true */)
{
Q_UNUSED(onlySystemDirectory);
@@ -141,6 +129,6 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect
}
-#endif //Q_OS_WINCE
+#endif // Q_OS_WINRT
QT_END_NAMESPACE
diff --git a/src/corelib/plugin/qsystemlibrary_p.h b/src/corelib/plugin/qsystemlibrary_p.h
index 469376d81b..4e093c0b7c 100644
--- a/src/corelib/plugin/qsystemlibrary_p.h
+++ b/src/corelib/plugin/qsystemlibrary_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#ifdef Q_OS_WIN
# include <QtCore/qstring.h>
# include <qt_windows.h>
@@ -93,11 +93,7 @@ public:
load();
if (!m_handle)
return 0;
-#ifdef Q_OS_WINCE
- return QFunctionPointer(GetProcAddress(m_handle, (const wchar_t*)QString::fromLatin1(symbol).utf16()));
-#else
return QFunctionPointer(GetProcAddress(m_handle, symbol));
-#endif
}
static QFunctionPointer resolve(const QString &libraryName, const char *symbol)
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index 5876bb84c3..f11ac6548b 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -809,39 +809,6 @@ QUuid::Version QUuid::version() const Q_DECL_NOTHROW
return ver;
}
-/*! \fn QUuid QUuid::fromCFUUID(CFUUIDRef uuid)
- \since 5.7
-
- Constructs a new QUuid containing a copy of the \a uuid CFUUID.
-
- \note this function is only available on Apple platforms.
-*/
-
-/*! \fn CFUUIDRef QUuid::toCFUUID() const
- \since 5.7
-
- Creates a CFUUID from a QUuid. The caller owns the CFUUID and is
- responsible for releasing it.
-
- \note this function is only available on Apple platforms.
-*/
-
-/*! \fn QUuid QUuid::fromNSUUID(const NSUUID *uuid)
- \since 5.7
-
- Constructs a new QUuid containing a copy of the \a uuid NSUUID.
-
- \note this function is only available on Apple platforms.
-*/
-
-/*! \fn NSUUID QUuid::toNSUUID() const
- \since 5.7
-
- Creates a NSUUID from a QUuid. The NSUUID is autoreleased.
-
- \note this function is only available on Apple platforms.
-*/
-
/*!
\fn bool QUuid::operator<(const QUuid &other) const
@@ -1002,7 +969,7 @@ QUuid QUuid::createUuid()
{
int *pseed = new int;
static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2);
- qsrand(*pseed = QDateTime::currentDateTimeUtc().toTime_t()
+ qsrand(*pseed = QDateTime::currentSecsSinceEpoch()
+ quintptr(&pseed)
+ serial.fetchAndAddRelaxed(1));
uuidseed.setLocalData(pseed);
@@ -1010,7 +977,7 @@ QUuid QUuid::createUuid()
#else
static bool seeded = false;
if (!seeded)
- qsrand(QDateTime::currentDateTimeUtc().toTime_t()
+ qsrand(QDateTime::currentSecsSinceEpoch()
+ quintptr(&seeded));
#endif
diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h
index a1d16b449e..264f572993 100644
--- a/src/corelib/plugin/quuid.h
+++ b/src/corelib/plugin/quuid.h
@@ -55,11 +55,9 @@ typedef struct _GUID
#endif
#endif
-#ifdef Q_OS_DARWIN
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFUUID);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSUUID);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -210,10 +208,8 @@ public:
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QUuid fromCFUUID(CFUUIDRef uuid);
CFUUIDRef toCFUUID() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QUuid fromNSUUID(const NSUUID *uuid);
NSUUID *toNSUUID() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
uint data1;
diff --git a/src/corelib/plugin/quuid_darwin.mm b/src/corelib/plugin/quuid_darwin.mm
deleted file mode 100644
index c2a7240f3b..0000000000
--- a/src/corelib/plugin/quuid_darwin.mm
+++ /dev/null
@@ -1,75 +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 "quuid.h"
-
-#import <Foundation/Foundation.h>
-
-QT_BEGIN_NAMESPACE
-
-QUuid QUuid::fromCFUUID(CFUUIDRef uuid)
-{
- if (!uuid)
- return QUuid();
- const CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid);
- return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(&bytes), sizeof(bytes)));
-}
-
-CFUUIDRef QUuid::toCFUUID() const
-{
- const QByteArray bytes = toRfc4122();
- return CFUUIDCreateFromUUIDBytes(0, *reinterpret_cast<const CFUUIDBytes *>(bytes.constData()));
-}
-
-QUuid QUuid::fromNSUUID(const NSUUID *uuid)
-{
- if (!uuid)
- return QUuid();
- uuid_t bytes;
- [uuid getUUIDBytes:bytes];
- return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(bytes), sizeof(bytes)));
-}
-
-NSUUID *QUuid::toNSUUID() const
-{
- const QByteArray bytes = toRfc4122();
- return [[[NSUUID alloc] initWithUUIDBytes:*reinterpret_cast<const uuid_t *>(bytes.constData())] autorelease];
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qabstractstate_p.h b/src/corelib/statemachine/qabstractstate_p.h
index b5e1b19862..552125f95a 100644
--- a/src/corelib/statemachine/qabstractstate_p.h
+++ b/src/corelib/statemachine/qabstractstate_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <QtCore/qglobal.h>
+
+#ifndef QT_NO_STATEMACHINE
+
#include <private/qobject_p.h>
#include <QtCore/qabstractstate.h>
@@ -94,4 +98,6 @@ public:
QT_END_NAMESPACE
-#endif
+#endif // QT_NO_STATEMACHINE
+
+#endif // QABSTRACTSTATE_P_H
diff --git a/src/corelib/statemachine/qhistorystate_p.h b/src/corelib/statemachine/qhistorystate_p.h
index 2e93c31982..ae9ed431cb 100644
--- a/src/corelib/statemachine/qhistorystate_p.h
+++ b/src/corelib/statemachine/qhistorystate_p.h
@@ -53,6 +53,8 @@
#include "private/qabstractstate_p.h"
+#ifndef QT_NO_STATEMACHINE
+
#include <QtCore/qabstracttransition.h>
#include <QtCore/qhistorystate.h>
#include <QtCore/qlist.h>
@@ -93,4 +95,6 @@ protected:
QT_END_NAMESPACE
-#endif
+#endif // QT_NO_STATEMACHINE
+
+#endif // QHISTORYSTATE_P_H
diff --git a/src/corelib/statemachine/qsignaleventgenerator_p.h b/src/corelib/statemachine/qsignaleventgenerator_p.h
index c0bb52c480..92b1ee3b70 100644
--- a/src/corelib/statemachine/qsignaleventgenerator_p.h
+++ b/src/corelib/statemachine/qsignaleventgenerator_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h
index e8d413cd8a..d7cf8584da 100644
--- a/src/corelib/statemachine/qsignaltransition.h
+++ b/src/corelib/statemachine/qsignaltransition.h
@@ -60,6 +60,7 @@ public:
QSignalTransition(const QObject *sender, const char *signal,
QState *sourceState = Q_NULLPTR);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
QSignalTransition(const QObject *object, PointerToMemberFunction signal,
QState *sourceState = Q_NULLPTR);
#elif defined(Q_COMPILER_DELEGATING_CONSTRUCTORS)
diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h
index ee1ff3fea3..7a9dc9c132 100644
--- a/src/corelib/statemachine/qstate.h
+++ b/src/corelib/statemachine/qstate.h
@@ -82,6 +82,7 @@ public:
void addTransition(QAbstractTransition *transition);
QSignalTransition *addTransition(const QObject *sender, const char *signal, QAbstractState *target);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
QSignalTransition *addTransition(const QObject *sender, PointerToMemberFunction signal,
QAbstractState *target);
#else
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index e3cfd7b988..db395b24dd 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -57,7 +57,7 @@
#include "private/qobject_p.h"
#include "private/qthread_p.h"
-#ifndef QT_NO_STATEMACHINE_EVENTFILTER
+#if QT_CONFIG(qeventtransition)
#include "qeventtransition.h"
#include "qeventtransition_p.h"
#endif
@@ -2196,7 +2196,7 @@ void QStateMachinePrivate::maybeRegisterTransition(QAbstractTransition *transiti
if (QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)) {
maybeRegisterSignalTransition(st);
}
-#ifndef QT_NO_STATEMACHINE_EVENTFILTER
+#if QT_CONFIG(qeventtransition)
else if (QEventTransition *et = qobject_cast<QEventTransition*>(transition)) {
maybeRegisterEventTransition(et);
}
@@ -2208,7 +2208,7 @@ void QStateMachinePrivate::registerTransition(QAbstractTransition *transition)
if (QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)) {
registerSignalTransition(st);
}
-#ifndef QT_NO_STATEMACHINE_EVENTFILTER
+#if QT_CONFIG(qeventtransition)
else if (QEventTransition *oet = qobject_cast<QEventTransition*>(transition)) {
registerEventTransition(oet);
}
@@ -2220,7 +2220,7 @@ void QStateMachinePrivate::unregisterTransition(QAbstractTransition *transition)
if (QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)) {
unregisterSignalTransition(st);
}
-#ifndef QT_NO_STATEMACHINE_EVENTFILTER
+#if QT_CONFIG(qeventtransition)
else if (QEventTransition *oet = qobject_cast<QEventTransition*>(transition)) {
unregisterEventTransition(oet);
}
@@ -2342,7 +2342,7 @@ void QStateMachinePrivate::unregisterAllTransitions()
}
}
-#ifndef QT_NO_STATEMACHINE_EVENTFILTER
+#if QT_CONFIG(qeventtransition)
void QStateMachinePrivate::maybeRegisterEventTransition(QEventTransition *transition)
{
if ((state == Running) && configuration.contains(transition->sourceState()))
@@ -2872,7 +2872,7 @@ bool QStateMachine::event(QEvent *e)
return QState::event(e);
}
-#ifndef QT_NO_STATEMACHINE_EVENTFILTER
+#if QT_CONFIG(qeventtransition)
/*!
\reimp
*/
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index 843844e172..031d9ceee2 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -141,7 +141,7 @@ public:
QSet<QAbstractState*> configuration() const;
-#ifndef QT_NO_STATEMACHINE_EVENTFILTER
+#if QT_CONFIG(qeventtransition)
bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
#endif
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index 1305558ef8..45634e27fb 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -66,7 +66,7 @@
QT_BEGIN_NAMESPACE
class QEvent;
-#ifndef QT_NO_STATEMACHINE_EVENTFILTER
+#if QT_CONFIG(qeventtransition)
class QEventTransition;
#endif
class QSignalEventGenerator;
@@ -186,7 +186,7 @@ public:
void registerSignalTransition(QSignalTransition *transition);
void unregisterSignalTransition(QSignalTransition *transition);
void registerMultiThreadedSignalTransitions();
-#ifndef QT_NO_STATEMACHINE_EVENTFILTER
+#if QT_CONFIG(qeventtransition)
void maybeRegisterEventTransition(QEventTransition *transition);
void registerEventTransition(QEventTransition *transition);
void unregisterEventTransition(QEventTransition *transition);
@@ -301,7 +301,7 @@ public:
QHash<const QObject*, QVector<int> > connections;
QMutex connectionsMutex;
-#ifndef QT_NO_STATEMACHINE_EVENTFILTER
+#if QT_CONFIG(qeventtransition)
QHash<QObject*, QHash<QEvent::Type, int> > qobjectEvents;
#endif
QFreeList<void> delayedEventIdFreeList;
diff --git a/src/corelib/statemachine/statemachine.pri b/src/corelib/statemachine/statemachine.pri
index c5396a2ef8..52df10a3bc 100644
--- a/src/corelib/statemachine/statemachine.pri
+++ b/src/corelib/statemachine/statemachine.pri
@@ -22,8 +22,10 @@ SOURCES += $$PWD/qstatemachine.cpp \
$$PWD/qabstracttransition.cpp \
$$PWD/qsignaltransition.cpp
-!contains(DEFINES, QT_NO_STATEMACHINE_EVENTFILTER) {
-HEADERS += $$PWD/qeventtransition.h \
- $$PWD/qeventtransition_p.h
-SOURCES += $$PWD/qeventtransition.cpp
+qtConfig(qeventtransition) {
+ HEADERS += \
+ $$PWD/qeventtransition.h \
+ $$PWD/qeventtransition_p.h
+ SOURCES += \
+ $$PWD/qeventtransition.cpp
}
diff --git a/src/corelib/thread/qfuture.h b/src/corelib/thread/qfuture.h
index 7ae5c68bb9..1f0c747f40 100644
--- a/src/corelib/thread/qfuture.h
+++ b/src/corelib/thread/qfuture.h
@@ -65,13 +65,7 @@ public:
explicit QFuture(QFutureInterface<T> *p) // internal
: d(*p)
{ }
- QFuture(const QFuture &other)
- : d(other.d)
- { }
- ~QFuture()
- { }
- inline QFuture &operator=(const QFuture &other);
bool operator==(const QFuture &other) const { return (d == other.d); }
bool operator!=(const QFuture &other) const { return (d != other.d); }
@@ -157,13 +151,6 @@ public: // Warning: the d pointer is not documented and is considered private.
};
template <typename T>
-inline QFuture<T> &QFuture<T>::operator=(const QFuture<T> &other)
-{
- d = other.d;
- return *this;
-}
-
-template <typename T>
inline T QFuture<T>::result() const
{
d.waitForResult(0);
@@ -195,13 +182,7 @@ public:
explicit QFuture(QFutureInterfaceBase *p) // internal
: d(*p)
{ }
- QFuture(const QFuture &other)
- : d(other.d)
- { }
- ~QFuture()
- { }
- QFuture &operator=(const QFuture &other);
bool operator==(const QFuture &other) const { return (d == other.d); }
bool operator!=(const QFuture &other) const { return (d != other.d); }
@@ -248,12 +229,6 @@ public:
mutable QFutureInterfaceBase d;
};
-inline QFuture<void> &QFuture<void>::operator=(const QFuture<void> &other)
-{
- d = other.d;
- return *this;
-}
-
inline QFuture<void> QFutureInterface<void>::future()
{
return QFuture<void>(this);
diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h
index 1787ff3b93..559d26e231 100644
--- a/src/corelib/thread/qfutureinterface.h
+++ b/src/corelib/thread/qfutureinterface.h
@@ -285,21 +285,13 @@ template <>
class QFutureInterface<void> : public QFutureInterfaceBase
{
public:
- QFutureInterface<void>(State initialState = NoState)
+ explicit QFutureInterface<void>(State initialState = NoState)
: QFutureInterfaceBase(initialState)
{ }
- QFutureInterface<void>(const QFutureInterface<void> &other)
- : QFutureInterfaceBase(other)
- { }
static QFutureInterface<void> canceledResult()
{ return QFutureInterface(State(Started | Finished | Canceled)); }
- QFutureInterface<void> &operator=(const QFutureInterface<void> &other)
- {
- QFutureInterfaceBase::operator=(other);
- return *this;
- }
inline QFuture<void> future(); // implemented in qfuture.h
diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h
index f5f0e7047f..ee8dfe1354 100644
--- a/src/corelib/thread/qfutureinterface_p.h
+++ b/src/corelib/thread/qfutureinterface_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qlist.h>
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index 878a920ffc..366413e82e 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -264,6 +264,61 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT
return lockInternal(timeout);
}
+/*! \fn bool QMutex::try_lock()
+ \since 5.8
+
+ This function is provided for compatibility with the Standard Library
+ concept \c Lockable. It is equivalent to tryLock().
+*/
+
+/*! \fn bool QMutex::try_lock_for(std::chrono::duration<Rep, Period> duration)
+ \since 5.8
+
+ Attempts to lock the mutex. This function returns \c true if the lock
+ was obtained; otherwise it returns \c false. If another thread has
+ locked the mutex, this function will wait for at most \a duration
+ for the mutex to become available.
+
+ Note: Passing a negative duration as the \a duration is equivalent to
+ calling try_lock(). This behavior is different from tryLock.
+
+ If the lock was obtained, the mutex must be unlocked with unlock()
+ before another thread can successfully lock it.
+
+ Calling this function multiple times on the same mutex from the
+ same thread is allowed if this mutex is a
+ \l{QMutex::Recursive}{recursive mutex}. If this mutex is a
+ \l{QMutex::NonRecursive}{non-recursive mutex}, this function will
+ \e always return false when attempting to lock the mutex
+ recursively.
+
+ \sa lock(), unlock()
+*/
+
+/*! \fn bool QMutex::try_lock_until(std::chrono::time_point<Clock, Duration> timePoint)
+ \since 5.8
+
+ Attempts to lock the mutex. This function returns \c true if the lock
+ was obtained; otherwise it returns \c false. If another thread has
+ locked the mutex, this function will wait at most until \a timePoint
+ for the mutex to become available.
+
+ Note: Passing a \a timePoint which has already passed is equivalent
+ to calling try_lock. This behavior is different from tryLock.
+
+ If the lock was obtained, the mutex must be unlocked with unlock()
+ before another thread can successfully lock it.
+
+ Calling this function multiple times on the same mutex from the
+ same thread is allowed if this mutex is a
+ \l{QMutex::Recursive}{recursive mutex}. If this mutex is a
+ \l{QMutex::NonRecursive}{non-recursive mutex}, this function will
+ \e always return false when attempting to lock the mutex
+ recursively.
+
+ \sa lock(), unlock()
+*/
+
/*! \fn void QMutex::unlock()
Unlocks the mutex. Attempting to unlock a mutex in a different
thread to the one that locked it results in an error. Unlocking a
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index a06bcd99ac..3a0e22e3bd 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -44,6 +44,10 @@
#include <QtCore/qatomic.h>
#include <new>
+#if QT_HAS_INCLUDE(<chrono>)
+# include <chrono>
+#endif
+
QT_BEGIN_NAMESPACE
@@ -60,11 +64,13 @@ class QMutexData;
class Q_CORE_EXPORT QBasicMutex
{
public:
+ // BasicLockable concept
inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
if (!fastTryLock())
lockInternal();
}
+ // BasicLockable concept
inline void unlock() Q_DECL_NOTHROW {
Q_ASSERT(d_ptr.load()); //mutex must be locked
if (!fastTryUnlock())
@@ -75,6 +81,9 @@ public:
return fastTryLock();
}
+ // Lockable concept
+ bool try_lock() Q_DECL_NOTHROW { return tryLock(); }
+
bool isRecursive() Q_DECL_NOTHROW; //### Qt6: remove me
bool isRecursive() const Q_DECL_NOTHROW;
@@ -112,10 +121,41 @@ public:
explicit QMutex(RecursionMode mode = NonRecursive);
~QMutex();
+ // BasicLockable concept
void lock() QT_MUTEX_LOCK_NOEXCEPT;
bool tryLock(int timeout = 0) QT_MUTEX_LOCK_NOEXCEPT;
+ // BasicLockable concept
void unlock() Q_DECL_NOTHROW;
+ // Lockable concept
+ bool try_lock() QT_MUTEX_LOCK_NOEXCEPT { return tryLock(); }
+
+#if QT_HAS_INCLUDE(<chrono>)
+ // TimedLockable concept
+ template <class Rep, class Period>
+ bool try_lock_for(std::chrono::duration<Rep, Period> duration)
+ {
+ // N4606 § 30.4.1.3 [thread.timedmutex.requirements]/5 specifies that
+ // a duration less than or equal to duration.zero() shall result in a
+ // try_lock, unlike QMutex's tryLock with a negative duration which
+ // results in a lock.
+
+ if (duration <= duration.zero())
+ return tryLock(0);
+ return tryLock(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count());
+ }
+
+ // TimedLockable concept
+ template<class Clock, class Duration>
+ bool try_lock_until(std::chrono::time_point<Clock, Duration> timePoint)
+ {
+ // Implemented in terms of try_lock_for to honor the similar
+ // requirement in N4606 § 30.4.1.3 [thread.timedmutex.requirements]/12.
+
+ return try_lock_for(timePoint - Clock::now());
+ }
+#endif
+
bool isRecursive() const Q_DECL_NOTHROW
{ return QBasicMutex::isRecursive(); }
@@ -189,9 +229,26 @@ public:
inline void lock() Q_DECL_NOTHROW {}
inline bool tryLock(int timeout = 0) Q_DECL_NOTHROW { Q_UNUSED(timeout); return true; }
+ inline bool try_lock() Q_DECL_NOTHROW { return true; }
inline void unlock() Q_DECL_NOTHROW {}
inline bool isRecursive() const Q_DECL_NOTHROW { return true; }
+#if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC)
+ template <class Rep, class Period>
+ inline bool try_lock_for(std::chrono::duration<Rep, Period> duration) Q_DECL_NOTHROW
+ {
+ Q_UNUSED(duration);
+ return true;
+ }
+
+ template<class Clock, class Duration>
+ inline bool try_lock_until(std::chrono::time_point<Clock, Duration> timePoint) Q_DECL_NOTHROW
+ {
+ Q_UNUSED(timePoint);
+ return true;
+ }
+#endif
+
private:
Q_DISABLE_COPY(QMutex)
};
diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h
index 20cc5f1f5e..4e6f522a37 100644
--- a/src/corelib/thread/qmutex_p.h
+++ b/src/corelib/thread/qmutex_p.h
@@ -54,7 +54,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qmutex.h>
#include <QtCore/qatomic.h>
diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp
index acb0f9dc61..3c314a4c0c 100644
--- a/src/corelib/thread/qmutex_win.cpp
+++ b/src/corelib/thread/qmutex_win.cpp
@@ -61,11 +61,7 @@ QMutexPrivate::~QMutexPrivate()
bool QMutexPrivate::wait(int timeout)
{
-#ifndef Q_OS_WINCE
return (WaitForSingleObjectEx(event, timeout < 0 ? INFINITE : timeout, FALSE) == WAIT_OBJECT_0);
-#else
- return (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0);
-#endif
}
void QMutexPrivate::wakeUp() Q_DECL_NOTHROW
diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h
index 796e65d960..58d853b0e3 100644
--- a/src/corelib/thread/qmutexpool_p.h
+++ b/src/corelib/thread/qmutexpool_p.h
@@ -44,13 +44,14 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of QSettings. This header file may change from version to
+// 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/private/qglobal_p.h>
#include "QtCore/qatomic.h"
#include "QtCore/qmutex.h"
#include "QtCore/qvarlengtharray.h"
diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h
index f54f7c705d..81c7c5268c 100644
--- a/src/corelib/thread/qorderedmutexlocker_p.h
+++ b/src/corelib/thread/qorderedmutexlocker_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qmutex.h>
#include <functional>
diff --git a/src/corelib/thread/qreadwritelock_p.h b/src/corelib/thread/qreadwritelock_p.h
index 24d25eb2be..bb58dfab56 100644
--- a/src/corelib/thread/qreadwritelock_p.h
+++ b/src/corelib/thread/qreadwritelock_p.h
@@ -52,7 +52,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qhash.h>
#include <QtCore/QWaitCondition>
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 4aac24f454..7118ad5c9b 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -403,7 +403,7 @@ QThread::QThread(QThreadPrivate &dd, QObject *parent)
Note that deleting a QThread object will not stop the execution
of the thread it manages. Deleting a running QThread (i.e.
- isFinished() returns \c false) will probably result in a program
+ isFinished() returns \c false) will result in a program
crash. Wait for the finished() signal before deleting the
QThread.
*/
@@ -418,7 +418,7 @@ QThread::~QThread()
locker.relock();
}
if (d->running && !d->finished && !d->data->isAdopted)
- qWarning("QThread: Destroyed while thread is still running");
+ qFatal("QThread: Destroyed while thread is still running");
d->data->thread = 0;
}
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index deedd61c17..ba5f2dca95 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -45,7 +45,7 @@
#include <private/qcoreapplication_p.h>
#include <private/qcore_unix_p.h>
-#if defined(Q_OS_OSX)
+#if defined(Q_OS_DARWIN)
# include <private/qeventdispatcher_cf_p.h>
#else
# if !defined(QT_NO_GLIB)
@@ -279,7 +279,7 @@ typedef void*(*QtThreadCallback)(void*);
void QThreadPrivate::createEventDispatcher(QThreadData *data)
{
-#if defined(Q_OS_OSX)
+#if defined(Q_OS_DARWIN)
bool ok = false;
int value = qEnvironmentVariableIntValue("QT_EVENT_DISPATCHER_CORE_FOUNDATION", &ok);
if (ok && value > 0)
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index ef1799a021..a14c193bad 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -55,15 +55,10 @@
#include <qt_windows.h>
#ifndef Q_OS_WINRT
-#ifndef Q_OS_WINCE
-#ifndef _MT
-#define _MT
-#endif // _MT
-#include <process.h>
-#else // !Q_OS_WINCE
-#include "qfunctions_wince.h"
-#endif // Q_OS_WINCE
-#else // !Q_OS_WINRT
+# ifndef _MT
+# define _MT
+# endif // _MT
+# include <process.h>
#endif // Q_OS_WINRT
#ifndef QT_NO_THREAD
@@ -150,7 +145,6 @@ QThreadData *QThreadData::current(bool createIfNecessary)
// WinRT API?
} else {
HANDLE realHandle = INVALID_HANDLE_VALUE;
-#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
DuplicateHandle(GetCurrentProcess(),
GetCurrentThread(),
GetCurrentProcess(),
@@ -158,9 +152,6 @@ QThreadData *QThreadData::current(bool createIfNecessary)
0,
FALSE,
DUPLICATE_SAME_ACCESS);
-#else
- realHandle = reinterpret_cast<HANDLE>(GetCurrentThreadId());
-#endif
qt_watch_adopted_thread(realHandle, threadData->thread);
}
}
@@ -190,9 +181,7 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)
QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
if (GetCurrentThreadId() == qt_adopted_thread_watcher_id) {
-#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
CloseHandle(adoptedThreadHandle);
-#endif
return;
}
@@ -291,9 +280,7 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
data->deref();
QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
-#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
CloseHandle(qt_adopted_thread_handles.at(handleIndex));
-#endif
qt_adopted_thread_handles.remove(handleIndex);
qt_adopted_qthreads.remove(qthreadIndex);
}
@@ -306,7 +293,7 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
return 0;
}
-#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
#ifndef Q_OS_WIN64
# define ULONG_PTR DWORD
@@ -336,7 +323,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName)
{
}
}
-#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINCE && !Q_OS_WINRT
+#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINRT
/**************************************************************************
** QThreadPrivate
@@ -378,7 +365,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
else
createEventDispatcher(data);
-#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
// sets the name of the current thread.
QByteArray objectName = thr->objectName().toLocal8Bit();
qt_set_thread_name((HANDLE)-1,
@@ -453,7 +440,7 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW
void QThread::yieldCurrentThread()
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
SwitchToThread();
#else
::Sleep(0);
@@ -495,7 +482,6 @@ void QThread::start(Priority priority)
d->returnCode = 0;
d->interruptionRequested = false;
-#ifndef Q_OS_WINRT
/*
NOTE: we create the thread in the suspended state, set the
priority and then resume the thread.
@@ -506,9 +492,21 @@ void QThread::start(Priority priority)
less than NormalPriority), but the newly created thread preempts
its 'parent' and runs at normal priority.
*/
+#if defined(Q_CC_MSVC) && !defined(_DLL) // && !defined(Q_OS_WINRT)
+# ifdef Q_OS_WINRT
+ // If you wish to accept the memory leaks, uncomment the part above.
+ // See:
+ // https://support.microsoft.com/en-us/kb/104641
+ // https://msdn.microsoft.com/en-us/library/kdzttdcb.aspx
+# error "Microsoft documentation says this combination leaks memory every time a thread is started. " \
+ "Please change your build back to -MD/-MDd or, if you understand this issue and want to continue, " \
+ "edit this source file."
+# endif
+ // MSVC -MT or -MTd build
d->handle = (Qt::HANDLE) _beginthreadex(NULL, d->stackSize, QThreadPrivate::start,
this, CREATE_SUSPENDED, &(d->id));
-#else // !Q_OS_WINRT
+#else
+ // MSVC -MD or -MDd or MinGW build
d->handle = (Qt::HANDLE) CreateThread(NULL, d->stackSize, (LPTHREAD_START_ROUTINE)QThreadPrivate::start,
this, CREATE_SUSPENDED, reinterpret_cast<LPDWORD>(&d->id));
#endif // Q_OS_WINRT
diff --git a/src/corelib/thread/qwaitcondition.h b/src/corelib/thread/qwaitcondition.h
index d2e018834a..a0c6766833 100644
--- a/src/corelib/thread/qwaitcondition.h
+++ b/src/corelib/thread/qwaitcondition.h
@@ -65,6 +65,9 @@ public:
void wakeOne();
void wakeAll();
+ void notify_one() { wakeOne(); }
+ void notify_all() { wakeAll(); }
+
private:
Q_DISABLE_COPY(QWaitCondition)
diff --git a/src/corelib/thread/qwaitcondition.qdoc b/src/corelib/thread/qwaitcondition.qdoc
index d7de323922..eebc28f059 100644
--- a/src/corelib/thread/qwaitcondition.qdoc
+++ b/src/corelib/thread/qwaitcondition.qdoc
@@ -172,3 +172,18 @@
\sa wakeOne(), wakeAll()
*/
+
+
+/*! \fn void QWaitCondition::notify_one()
+ \since 5.8
+
+ This function is provided for STL compatibility. It is equivalent
+ to wakeOne().
+*/
+
+/*! \fn void QWaitCondition::notify_all()
+ \since 5.8
+
+ This function is provided for STL compatibility. It is equivalent
+ to wakeAll().
+*/
diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp
index a95ca0b8fd..e6610f18c8 100644
--- a/src/corelib/thread/qwaitcondition_win.cpp
+++ b/src/corelib/thread/qwaitcondition_win.cpp
@@ -115,12 +115,7 @@ bool QWaitConditionPrivate::wait(QWaitConditionEvent *wce, unsigned long time)
{
// wait for the event
bool ret = false;
-#ifndef Q_OS_WINCE
switch (WaitForSingleObjectEx(wce->event, time, FALSE)) {
-#else
- switch (WaitForSingleObject(wce->event, time)) {
-#endif
-
default: break;
case WAIT_OBJECT_0:
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index 4f704d6764..6e472e8b22 100644
--- a/src/corelib/tools/qalgorithms.h
+++ b/src/corelib/tools/qalgorithms.h
@@ -142,15 +142,9 @@ QT_DEPRECATED_X("Use std::count") inline void qCount(const Container &container,
}
#ifdef Q_QDOC
-template <typename T>
-LessThan qLess()
-{
-}
-
-template <typename T>
-LessThan qGreater()
-{
-}
+typedef void* LessThan;
+template <typename T> LessThan qLess();
+template <typename T> LessThan qGreater();
#else
template <typename T>
class QT_DEPRECATED_X("Use std::less") qLess
@@ -522,20 +516,153 @@ QT_DEPRECATED_X("Use std::binary_search") Q_OUTOFLINE_TEMPLATE RandomAccessItera
#endif // QT_DEPRECATED_SINCE(5, 2)
-} //namespace QAlgorithmsPrivate
-
+#ifdef Q_CC_CLANG
+// Clang had a bug where __builtin_ctz/clz/popcount were not marked as constexpr.
+# if (defined __apple_build_version__ && __clang_major__ >= 7) || (Q_CC_CLANG >= 307)
+# define QT_HAS_CONSTEXPR_BUILTINS
+# endif
+#elif defined(Q_CC_MSVC) && !defined(Q_CC_INTEL) && !defined(Q_OS_WINCE) && !defined(Q_PROCESSOR_ARM)
+# define QT_HAS_CONSTEXPR_BUILTINS
+#elif defined(Q_CC_GNU)
+# define QT_HAS_CONSTEXPR_BUILTINS
+#endif
-// Use __builtin_popcount on gcc. Clang claims to be gcc
-// but has a bug where __builtin_popcount is not marked as
-// constexpr.
-#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG)
+#if defined QT_HAS_CONSTEXPR_BUILTINS
+#if defined(Q_CC_GNU) || defined(Q_CC_CLANG)
+# define QT_HAS_BUILTIN_CTZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW
+{
+# if QT_HAS_BUILTIN(__builtin_ctzs) || defined(__BMI__)
+ return __builtin_ctzs(v);
+# else
+ return __builtin_ctz(v);
+# endif
+}
+#define QT_HAS_BUILTIN_CLZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW
+{
+# if QT_HAS_BUILTIN(__builtin_clzs) || defined(__BMI__)
+ return __builtin_clzs(v);
+# else
+ return __builtin_clz(v) - 16U;
+# endif
+}
+#define QT_HAS_BUILTIN_CTZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctz(quint32 v) Q_DECL_NOTHROW
+{
+ return __builtin_ctz(v);
+}
+#define QT_HAS_BUILTIN_CLZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clz(quint32 v) Q_DECL_NOTHROW
+{
+ return __builtin_clz(v);
+}
+#define QT_HAS_BUILTIN_CTZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzll(quint64 v) Q_DECL_NOTHROW
+{
+ return __builtin_ctzll(v);
+}
+#define QT_HAS_BUILTIN_CLZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzll(quint64 v) Q_DECL_NOTHROW
+{
+ return __builtin_clzll(v);
+}
#define QALGORITHMS_USE_BUILTIN_POPCOUNT
-#endif
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcount(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcount(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcount(v);
+}
+#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcountll(v);
+}
+#elif defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_PROCESSOR_ARM)
+#define QT_HAS_BUILTIN_CTZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_ctz(quint32 val)
+{
+ unsigned long result;
+ _BitScanForward(&result, val);
+ return result;
+}
+#define QT_HAS_BUILTIN_CLZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_clz(quint32 val)
+{
+ unsigned long result;
+ _BitScanReverse(&result, val);
+ // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31
+ // and the lsb index is 0. The result for the index when counting up: msb index is 0 (because it
+ // starts there), and the lsb index is 31.
+ result ^= sizeof(quint32) * 8 - 1;
+ return result;
+}
+#if Q_PROCESSOR_WORDSIZE == 8
+// These are only defined for 64bit builds.
+#define QT_HAS_BUILTIN_CTZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_ctzll(quint64 val)
+{
+ unsigned long result;
+ _BitScanForward64(&result, val);
+ return result;
+}
+// MSVC calls it _BitScanReverse and returns the carry flag, which we don't need
+#define QT_HAS_BUILTIN_CLZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_clzll(quint64 val)
+{
+ unsigned long result;
+ _BitScanReverse64(&result, val);
+ // see qt_builtin_clz
+ result ^= sizeof(quint64) * 8 - 1;
+ return result;
+}
+#endif // MSVC 64bit
+# define QT_HAS_BUILTIN_CTZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW
+{
+ return qt_builtin_ctz(v);
+}
+#define QT_HAS_BUILTIN_CLZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW
+{
+ return qt_builtin_clz(v) - 16U;
+}
+#define QALGORITHMS_USE_BUILTIN_POPCOUNT
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW
+{
+ return __popcnt(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW
+{
+ return __popcnt16(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW
+{
+ return __popcnt16(v);
+}
+#if Q_PROCESSOR_WORDSIZE == 8
+#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW
+{
+ return __popcnt64(v);
+}
+#endif // MSVC 64bit
+#endif // MSVC
+#endif // QT_HAS_CONSTEXPR_BUILTINS
+
+} //namespace QAlgorithmsPrivate
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint32 v) Q_DECL_NOTHROW
{
#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcount(v);
+ return QAlgorithmsPrivate::qt_builtin_popcount(v);
#else
// See http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
return
@@ -548,7 +675,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint32 v) Q
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint8 v) Q_DECL_NOTHROW
{
#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcount(v);
+ return QAlgorithmsPrivate::qt_builtin_popcount(v);
#else
return
(((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
@@ -558,7 +685,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint8 v) Q_
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint16 v) Q_DECL_NOTHROW
{
#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcount(v);
+ return QAlgorithmsPrivate::qt_builtin_popcount(v);
#else
return
(((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
@@ -568,8 +695,8 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint16 v) Q
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint64 v) Q_DECL_NOTHROW
{
-#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcountll(v);
+#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNTLL
+ return QAlgorithmsPrivate::qt_builtin_popcountll(v);
#else
return
(((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
@@ -592,8 +719,8 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(long unsigne
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_ctz(v) : 32U;
+#if defined(QT_HAS_BUILTIN_CTZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctz(v) : 32U;
#else
// see http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightParallel
unsigned int c = 32; // c will be the number of zero bits on the right
@@ -610,8 +737,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NO
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_ctz(v) : 8U;
+#if defined(QT_HAS_BUILTIN_CTZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctz(v) : 8U;
#else
unsigned int c = 8; // c will be the number of zero bits on the right
v &= -signed(v);
@@ -625,12 +752,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOT
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
-# if QT_HAS_BUILTIN(__builtin_ctzs) || (defined(__LZCNT__) && defined(__BMI__))
- return v ? __builtin_ctzs(v) : 16U;
-# else
- return v ? __builtin_ctz(v) : 16U;
-# endif
+#if defined(QT_HAS_BUILTIN_CTZS)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctzs(v) : 16U;
#else
unsigned int c = 16; // c will be the number of zero bits on the right
v &= -signed(v);
@@ -645,8 +768,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NO
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint64 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_ctzll(v) : 64;
+#if defined(QT_HAS_BUILTIN_CTZLL)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctzll(v) : 64;
#else
quint32 x = static_cast<quint32>(v);
return x ? qCountTrailingZeroBits(x)
@@ -661,8 +784,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(unsigned long v) Q_D
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_clz(v) : 32U;
+#if defined(QT_HAS_BUILTIN_CLZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_clz(v) : 32U;
#else
// Hacker's Delight, 2nd ed. Fig 5-16, p. 102
v = v | (v >> 1);
@@ -676,8 +799,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) Q_DECL_NOT
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_clz(v)-24U : 8U;
+#if defined(QT_HAS_BUILTIN_CLZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_clz(v)-24U : 8U;
#else
v = v | (v >> 1);
v = v | (v >> 2);
@@ -688,12 +811,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL_NOTH
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
-# if QT_HAS_BUILTIN(__builtin_clzs) || (defined(__LZCNT__) && defined(__BMI__))
- return v ? __builtin_clzs(v) : 16U;
-# else
- return v ? __builtin_clz(v)-16U : 16U;
-# endif
+#if defined(QT_HAS_BUILTIN_CLZS)
+ return v ? QAlgorithmsPrivate::qt_builtin_clzs(v) : 16U;
#else
v = v | (v >> 1);
v = v | (v >> 2);
@@ -705,8 +824,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DECL_NOT
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint64 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_clzll(v) : 64U;
+#if defined(QT_HAS_BUILTIN_CLZLL)
+ return v ? QAlgorithmsPrivate::qt_builtin_clzll(v) : 64U;
#else
v = v | (v >> 1);
v = v | (v >> 2);
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 08a70a06c7..9298472305 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -4468,91 +4468,6 @@ QByteArray QByteArray::fromPercentEncoding(const QByteArray &input, char percent
\sa fromStdString(), QString::toStdString()
*/
-/*! \fn QByteArray QByteArray::fromCFData(CFDataRef data)
- \since 5.3
-
- Constructs a new QByteArray containing a copy of the CFData \a data.
-
- \sa fromRawCFData(), fromRawData(), toRawCFData(), toCFData()
-*/
-
-/*! \fn QByteArray QByteArray::fromRawCFData(CFDataRef data)
- \since 5.3
-
- Constructs a QByteArray that uses the bytes of the CFData \a data.
-
- The \a data's bytes are not copied.
-
- The caller guarantees that the CFData will not be deleted
- or modified as long as this QByteArray object exists.
-
- \sa fromCFData(), fromRawData(), toRawCFData(), toCFData()
-*/
-
-/*! \fn CFDataRef QByteArray::toCFData() const
- \since 5.3
-
- Creates a CFData from a QByteArray. The caller owns the CFData object
- and is responsible for releasing it.
-
- \sa toRawCFData(), fromCFData(), fromRawCFData(), fromRawData()
-*/
-
-/*! \fn CFDataRef QByteArray::toRawCFData() const
- \since 5.3
-
- Constructs a CFData that uses the bytes of the QByteArray.
-
- The QByteArray's bytes are not copied.
-
- The caller guarantees that the QByteArray will not be deleted
- or modified as long as this CFData object exists.
-
- \sa toCFData(), fromRawCFData(), fromCFData(), fromRawData()
-*/
-
-/*! \fn QByteArray QByteArray::fromNSData(const NSData *data)
- \since 5.3
-
- Constructs a new QByteArray containing a copy of the NSData \a data.
-
- \sa fromRawNSData(), fromRawData(), toNSData(), toRawNSData()
-*/
-
-/*! \fn QByteArray QByteArray::fromRawNSData(const NSData *data)
- \since 5.3
-
- Constructs a QByteArray that uses the bytes of the NSData \a data.
-
- The \a data's bytes are not copied.
-
- The caller guarantees that the NSData will not be deleted
- or modified as long as this QByteArray object exists.
-
- \sa fromNSData(), fromRawData(), toRawNSData(), toNSData()
-*/
-
-/*! \fn NSData QByteArray::toNSData() const
- \since 5.3
-
- Creates a NSData from a QByteArray. The NSData object is autoreleased.
-
- \sa fromNSData(), fromRawNSData(), fromRawData(), toRawNSData()
-*/
-
-/*! \fn NSData QByteArray::toRawNSData() const
- \since 5.3
-
- Constructs a NSData that uses the bytes of the QByteArray.
-
- The QByteArray's bytes are not copied.
-
- The caller guarantees that the QByteArray will not be deleted
- or modified as long as this NSData object exists.
-
- \sa fromRawNSData(), fromNSData(), fromRawData(), toNSData()
-*/
-
static inline bool q_strchr(const char str[], char chr)
{
if (!str) return false;
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index d334bb43c5..477402d6de 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -56,11 +56,9 @@
#error qbytearray.h must be included before any header file that defines truncate
#endif
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFData);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSData);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -384,17 +382,15 @@ public:
static QByteArray fromHex(const QByteArray &hexEncoded) Q_REQUIRED_RESULT;
static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%') Q_REQUIRED_RESULT;
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QByteArray fromCFData(CFDataRef data);
static QByteArray fromRawCFData(CFDataRef data);
CFDataRef toCFData() const Q_DECL_CF_RETURNS_RETAINED;
CFDataRef toRawCFData() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QByteArray fromNSData(const NSData *data);
static QByteArray fromRawNSData(const NSData *data);
NSData *toNSData() const Q_DECL_NS_RETURNS_AUTORELEASED;
NSData *toRawNSData() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
typedef char *iterator;
diff --git a/src/corelib/tools/qbytearray_mac.mm b/src/corelib/tools/qbytearray_mac.mm
deleted file mode 100644
index 9386a966f0..0000000000
--- a/src/corelib/tools/qbytearray_mac.mm
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Samuel Gaist <samuel.gaist@edeltech.ch>
-** 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 "qbytearray.h"
-
-#import <Foundation/Foundation.h>
-
-QT_BEGIN_NAMESPACE
-
-QByteArray QByteArray::fromCFData(CFDataRef data)
-{
- if (!data)
- return QByteArray();
-
- return QByteArray(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
-}
-
-QByteArray QByteArray::fromRawCFData(CFDataRef data)
-{
- if (!data)
- return QByteArray();
-
- return QByteArray::fromRawData(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
-}
-
-CFDataRef QByteArray::toCFData() const
-{
- return CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()), length());
-}
-
-CFDataRef QByteArray::toRawCFData() const
-{
- return CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()),
- length(), kCFAllocatorNull);
-}
-
-QByteArray QByteArray::fromNSData(const NSData *data)
-{
- if (!data)
- return QByteArray();
- return QByteArray(reinterpret_cast<const char *>([data bytes]), [data length]);
-}
-
-QByteArray QByteArray::fromRawNSData(const NSData *data)
-{
- if (!data)
- return QByteArray();
- return QByteArray::fromRawData(reinterpret_cast<const char *>([data bytes]), [data length]);
-}
-
-NSData *QByteArray::toNSData() const
-{
- return [NSData dataWithBytes:constData() length:size()];
-}
-
-NSData *QByteArray::toRawNSData() const
-{
- // const_cast is fine here because NSData is immutable thus will never modify bytes we're giving it
- return [NSData dataWithBytesNoCopy:const_cast<char *>(constData()) length:size() freeWhenDone:NO];
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/tools/qbytearraylist.h
index bc8b08b380..501bb2e0d5 100644
--- a/src/corelib/tools/qbytearraylist.h
+++ b/src/corelib/tools/qbytearraylist.h
@@ -50,11 +50,13 @@ QT_BEGIN_NAMESPACE
typedef QListIterator<QByteArray> QByteArrayListIterator;
typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator;
+#ifndef Q_QDOC
typedef QList<QByteArray> QByteArrayList;
namespace QtPrivate {
QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength);
}
+#endif
#ifdef Q_QDOC
class QByteArrayList : public QList<QByteArray>
diff --git a/src/corelib/tools/qbytedata_p.h b/src/corelib/tools/qbytedata_p.h
index b275158597..8331be112d 100644
--- a/src/corelib/tools/qbytedata_p.h
+++ b/src/corelib/tools/qbytedata_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qbytearray.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index f01fbc109c..a83e5e6f98 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -578,6 +578,18 @@ Q_DECL_CONSTEXPR inline bool operator>=(QChar c1, QChar c2) Q_DECL_NOTHROW { ret
Q_DECL_CONSTEXPR inline bool operator> (QChar c1, QChar c2) Q_DECL_NOTHROW { return operator< (c2, c1); }
Q_DECL_CONSTEXPR inline bool operator<=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator< (c2, c1); }
+// disambiguate QChar == int (but only that, so constrain template to exactly 'int'):
+template <typename T>
+Q_DECL_DEPRECATED_X("don't compare ints to QChars, compare them to QChar::unicode() instead")
+Q_DECL_CONSTEXPR inline
+typename std::enable_if<std::is_same<typename std::remove_cv<T>::type, int>::value, bool>::type
+operator==(QChar lhs, T rhs) Q_DECL_NOEXCEPT { return lhs == QChar(rhs); }
+template <typename T>
+Q_DECL_DEPRECATED_X("don't compare ints to QChars, compare them to QChar::unicode() instead")
+Q_DECL_CONSTEXPR inline
+typename std::enable_if<std::is_same<typename std::remove_cv<T>::type, int>::value, bool>::type
+operator!=(QChar lhs, T rhs) Q_DECL_NOEXCEPT { return lhs != QChar(rhs); }
+
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QChar);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QChar &);
diff --git a/src/corelib/tools/qcollator_p.h b/src/corelib/tools/qcollator_p.h
index a056fcc4af..fbbce00676 100644
--- a/src/corelib/tools/qcollator_p.h
+++ b/src/corelib/tools/qcollator_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qcollator.h"
#include <QVector>
#ifdef QT_USE_ICU
diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp
index 751e18c44e..c2b86014ba 100644
--- a/src/corelib/tools/qcommandlineoption.cpp
+++ b/src/corelib/tools/qcommandlineoption.cpp
@@ -49,14 +49,12 @@ class QCommandLineOptionPrivate : public QSharedData
public:
Q_NEVER_INLINE
explicit QCommandLineOptionPrivate(const QString &name)
- : names(removeInvalidNames(QStringList(name))),
- hidden(false)
+ : names(removeInvalidNames(QStringList(name)))
{ }
Q_NEVER_INLINE
explicit QCommandLineOptionPrivate(const QStringList &names)
- : names(removeInvalidNames(names)),
- hidden(false)
+ : names(removeInvalidNames(names))
{ }
static QStringList removeInvalidNames(QStringList nameList);
@@ -74,8 +72,7 @@ public:
//! The list of default values used for this option.
QStringList defaultValues;
- //! Show or hide in --help
- bool hidden;
+ QCommandLineOption::Flags flags;
};
/*!
@@ -394,6 +391,7 @@ QStringList QCommandLineOption::defaultValues() const
return d->defaultValues;
}
+#if QT_DEPRECATED_SINCE(5, 8)
/*!
Sets whether to hide this option in the user-visible help output.
@@ -401,11 +399,12 @@ QStringList QCommandLineOption::defaultValues() const
a particular option makes it internal, i.e. not listed in the help output.
\since 5.6
+ \obsolete Use setFlags(QCommandLineOption::HiddenFromHelp), QCommandLineOption::HiddenFromHelp
\sa isHidden
*/
void QCommandLineOption::setHidden(bool hide)
{
- d->hidden = hide;
+ d->flags.setFlag(HiddenFromHelp, hide);
}
/*!
@@ -413,11 +412,52 @@ void QCommandLineOption::setHidden(bool hide)
false if the option is listed.
\since 5.6
- \sa setHidden()
+ \obsolete Use flags() & QCommandLineOption::HiddenFromHelp
+ \sa setHidden(), QCommandLineOption::HiddenFromHelp
*/
bool QCommandLineOption::isHidden() const
{
- return d->hidden;
+ return d->flags & HiddenFromHelp;
}
+#endif
+
+/*!
+ Returns a set of flags that affect this command-line option.
+
+ \since 5.8
+ \sa setFlags(), QCommandLineOption::Flags
+ */
+QCommandLineOption::Flags QCommandLineOption::flags() const
+{
+ return d->flags;
+}
+
+/*!
+ Set the set of flags that affect this command-line option to \a flags.
+
+ \since 5.8
+ \sa flags(), QCommandLineOption::Flags
+ */
+void QCommandLineOption::setFlags(Flags flags)
+{
+ d->flags = flags;
+}
+
+/*!
+ \enum QCommandLineOption::Flag
+
+ \value HiddenFromHelp Hide this option in the user-visible help output. All
+ options are visible by default. Setting this flag for a particular
+ option makes it internal, i.e. not listed in the help output.
+
+ \value ShortOptionStyle The option will always be understood as a short
+ option, regardless of what was set by
+ QCommandLineParser::setSingleDashWordOptionMode.
+ This allows flags such as \c{-DDEFINE=VALUE} or \c{-I/include/path} to be
+ interpreted as short flags even when the parser is in
+ QCommandLineParser::ParseAsLongOptions mode.
+
+ \sa QCommandLineOption::setFlags(), QCommandLineOption::flags()
+*/
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qcommandlineoption.h b/src/corelib/tools/qcommandlineoption.h
index a7747f9fb2..6ebaab3d48 100644
--- a/src/corelib/tools/qcommandlineoption.h
+++ b/src/corelib/tools/qcommandlineoption.h
@@ -50,6 +50,12 @@ class QCommandLineOptionPrivate;
class Q_CORE_EXPORT QCommandLineOption
{
public:
+ enum Flag {
+ HiddenFromHelp = 0x1,
+ ShortOptionStyle = 0x2
+ };
+ Q_DECLARE_FLAGS(Flags, Flag)
+
explicit QCommandLineOption(const QString &name);
explicit QCommandLineOption(const QStringList &names);
/*implicit*/ QCommandLineOption(const QString &name, const QString &description,
@@ -82,14 +88,24 @@ public:
void setDefaultValues(const QStringList &defaultValues);
QStringList defaultValues() const;
+ Flags flags() const;
+ void setFlags(Flags aflags);
+
+#if QT_DEPRECATED_SINCE(5, 8)
+ QT_DEPRECATED_X("Use setFlags() with HiddenFromHelp)")
void setHidden(bool hidden);
+ QT_DEPRECATED_X("Use flags() and HiddenFromHelp")
bool isHidden() const;
+#endif
+
private:
QSharedDataPointer<QCommandLineOptionPrivate> d;
};
Q_DECLARE_SHARED(QCommandLineOption)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QCommandLineOption::Flags)
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index 7db0920a29..4c55880915 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -44,7 +44,7 @@
#include <qhash.h>
#include <qvector.h>
#include <qdebug.h>
-#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINRT)
# include <qt_windows.h>
#endif
#include <stdio.h>
@@ -297,7 +297,9 @@ QCommandLineParser::~QCommandLineParser()
i.e. as the long option named \c{abc}. This is how Qt's own tools
(uic, rcc...) have always been parsing arguments. This mode should be
used for preserving compatibility in applications that were parsing
- arguments in such a way.
+ arguments in such a way. There is an exception if the \c{a} option has the
+ QCommandLineOption::ShortOptionStyle flag set, in which case it is still
+ interpreted as \c{-a bc}.
\sa setSingleDashWordOptionMode()
*/
@@ -532,7 +534,7 @@ QString QCommandLineParser::errorText() const
enum MessageType { UsageMessage, ErrorMessage };
-#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINRT)
// Return whether to use a message box. Use handles if a console can be obtained
// or we are run with redirected handles (for example, by QProcess).
static inline bool displayMessageBox()
@@ -554,7 +556,7 @@ static void showParserMessage(const QString &message, MessageType type)
else
qCritical(qPrintable(message));
return;
-#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINCE)
+#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED)
if (displayMessageBox()) {
const UINT flags = MB_OK | MB_TOPMOST | MB_SETFOREGROUND
| (type == UsageMessage ? MB_ICONINFORMATION : MB_ICONERROR);
@@ -567,7 +569,7 @@ static void showParserMessage(const QString &message, MessageType type)
reinterpret_cast<const wchar_t *>(title.utf16()), flags);
return;
}
-#endif // Q_OS_WIN && !QT_BOOTSTRAPPED && !Q_OS_WINCE
+#endif // Q_OS_WIN && !QT_BOOTSTRAPPED
fputs(qPrintable(message), type == UsageMessage ? stdout : stderr);
}
@@ -765,6 +767,18 @@ bool QCommandLineParserPrivate::parse(const QStringList &args)
}
case QCommandLineParser::ParseAsLongOptions:
{
+ if (argument.size() > 2) {
+ const QString possibleShortOptionStyleName = argument.mid(1, 1);
+ const auto shortOptionIt = nameHash.constFind(possibleShortOptionStyleName);
+ if (shortOptionIt != nameHash.constEnd()) {
+ const auto &arg = commandLineOptionList.at(*shortOptionIt);
+ if (arg.flags() & QCommandLineOption::ShortOptionStyle) {
+ registerFoundOption(possibleShortOptionStyleName);
+ optionValuesHash[*shortOptionIt].append(argument.mid(2));
+ break;
+ }
+ }
+ }
const QString optionName = argument.mid(1).section(assignChar, 0, 0);
if (registerFoundOption(optionName)) {
if (!parseOptionValue(optionName, argument, &argumentIterator, args.end()))
@@ -1103,7 +1117,7 @@ QString QCommandLineParserPrivate::helpText() const
optionNameList.reserve(commandLineOptionList.size());
int longestOptionNameString = 0;
for (const QCommandLineOption &option : commandLineOptionList) {
- if (option.isHidden())
+ if (option.flags() & QCommandLineOption::HiddenFromHelp)
continue;
const QStringList optionNames = option.names();
QString optionNamesString;
@@ -1122,7 +1136,7 @@ QString QCommandLineParserPrivate::helpText() const
++longestOptionNameString;
auto optionNameIterator = optionNameList.cbegin();
for (const QCommandLineOption &option : commandLineOptionList) {
- if (option.isHidden())
+ if (option.flags() & QCommandLineOption::HiddenFromHelp)
continue;
text += wrapText(*optionNameIterator, longestOptionNameString, option.description());
++optionNameIterator;
diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h
index a19c734768..0f17baa036 100644
--- a/src/corelib/tools/qcryptographichash.h
+++ b/src/corelib/tools/qcryptographichash.h
@@ -42,6 +42,7 @@
#define QCRYPTOGRAPHICHASH_H
#include <QtCore/qbytearray.h>
+#include <QtCore/qobjectdefs.h>
QT_BEGIN_NAMESPACE
@@ -51,6 +52,7 @@ class QIODevice;
class Q_CORE_EXPORT QCryptographicHash
{
+ Q_GADGET
public:
enum Algorithm {
#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
@@ -69,6 +71,7 @@ public:
Sha3_512
#endif
};
+ Q_ENUM(Algorithm)
explicit QCryptographicHash(Algorithm method);
~QCryptographicHash();
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index bfc7e1ca0e..f8611b3e68 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -57,9 +57,6 @@
#include <time.h>
#ifdef Q_OS_WIN
# include <qt_windows.h>
-# ifdef Q_OS_WINCE
-# include "qfunctions_wince.h"
-# endif
# ifdef Q_OS_WINRT
# include "qfunctions_winrt.h"
# endif
@@ -71,8 +68,6 @@
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QDateTimePrivate>, defaultDateTimePrivate, (new QDateTimePrivate()))
-
/*****************************************************************************
Date/Time Constants
*****************************************************************************/
@@ -1687,9 +1682,6 @@ QString QTime::toString(const QString& format) const
bool QTime::setHMS(int h, int m, int s, int ms)
{
-#if defined(Q_OS_WINCE)
- startTick = NullTime;
-#endif
if (!isValid(h,m,s,ms)) {
mds = NullTime; // make this invalid
return false;
@@ -1769,10 +1761,6 @@ QTime QTime::addMSecs(int ms) const
t.mds = (ds() + ms) % MSECS_PER_DAY;
}
}
-#if defined(Q_OS_WINCE)
- if (startTick > NullTime)
- t.startTick = (startTick + ms) % MSECS_PER_DAY;
-#endif
return t;
}
@@ -1794,13 +1782,7 @@ int QTime::msecsTo(const QTime &t) const
{
if (!isValid() || !t.isValid())
return 0;
-#if defined(Q_OS_WINCE)
- // GetLocalTime() for Windows CE has no milliseconds resolution
- if (t.startTick > NullTime && startTick > NullTime)
- return t.startTick - startTick;
- else
-#endif
- return t.ds() - ds();
+ return t.ds() - ds();
}
@@ -2141,13 +2123,14 @@ int QTime::elapsed() const
QDateTime static helper functions
*****************************************************************************/
+// get the types from QDateTime (through QDateTimePrivate)
+typedef QDateTimePrivate::QDateTimeShortData ShortData;
+typedef QDateTimePrivate::QDateTimeData QDateTimeData;
+
// Calls the platform variant of tzset
static void qt_tzset()
{
-#if defined(Q_OS_WINCE)
- // WinCE doesn't use tzset
- return;
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
_tzset();
#else
tzset();
@@ -2161,12 +2144,7 @@ static void qt_tzset()
// Relies on tzset, mktime, or localtime having been called to populate timezone
static int qt_timezone()
{
-#if defined(Q_OS_WINCE)
- TIME_ZONE_INFORMATION tzi;
- GetTimeZoneInformation(&tzi);
- // Expressed in minutes, convert to seconds
- return (tzi.Bias + tzi.StandardBias) * 60;
-#elif defined(_MSC_VER) && _MSC_VER >= 1400
+#if defined(_MSC_VER)
long offset;
_get_timezone(&offset);
return offset;
@@ -2195,16 +2173,6 @@ static int qt_timezone()
// Returns the tzname, assume tzset has been called already
static QString qt_tzname(QDateTimePrivate::DaylightStatus daylightStatus)
{
-#if defined(Q_OS_WINCE)
- TIME_ZONE_INFORMATION tzi;
- DWORD res = GetTimeZoneInformation(&tzi);
- if (res == TIME_ZONE_ID_UNKNOWN)
- return QString();
- else if (daylightStatus == QDateTimePrivate::DaylightTime)
- return QString::fromWCharArray(tzi.DaylightName);
- else
- return QString::fromWCharArray(tzi.StandardName);
-#else
int isDst = (daylightStatus == QDateTimePrivate::DaylightTime) ? 1 : 0;
#if defined(_MSC_VER) && _MSC_VER >= 1400
size_t s = 0;
@@ -2215,7 +2183,6 @@ static QString qt_tzname(QDateTimePrivate::DaylightStatus daylightStatus)
#else
return QString::fromLocal8Bit(tzname[isDst]);
#endif // Q_OS_WIN
-#endif // Q_OS_WINCE
}
// Calls the platform variant of mktime for the given date, time and daylightStatus,
@@ -2230,48 +2197,6 @@ static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStat
int yy, mm, dd;
date->getDate(&yy, &mm, &dd);
-#if defined(Q_OS_WINCE)
- // WinCE doesn't provide standard C library time functions
- SYSTEMTIME st;
- memset(&st, 0, sizeof(SYSTEMTIME));
- st.wSecond = time->second();
- st.wMinute = time->minute();
- st.wHour = time->hour();
- st.wDay = dd;
- st.wMonth = mm;
- st.wYear = yy;
- FILETIME lft;
- bool valid = SystemTimeToFileTime(&st, &lft);
- FILETIME ft;
- if (valid)
- valid = LocalFileTimeToFileTime(&lft, &ft);
- const time_t secsSinceEpoch = ftToTime_t(ft);
- const time_t localSecs = ftToTime_t(lft);
- TIME_ZONE_INFORMATION tzi;
- GetTimeZoneInformation(&tzi);
- bool isDaylight = false;
- // Check for overflow
- qint64 localDiff = qAbs(localSecs - secsSinceEpoch);
- int daylightOffset = qAbs(tzi.Bias + tzi.DaylightBias) * 60;
- if (localDiff > daylightOffset)
- valid = false;
- else
- isDaylight = (localDiff == daylightOffset);
- if (daylightStatus) {
- if (isDaylight)
- *daylightStatus = QDateTimePrivate::DaylightTime;
- else
- *daylightStatus = QDateTimePrivate::StandardTime;
- }
- if (abbreviation) {
- if (isDaylight)
- *abbreviation = QString::fromWCharArray(tzi.DaylightName);
- else
- *abbreviation = QString::fromWCharArray(tzi.StandardName);
- }
- if (ok)
- *ok = valid;
-#else
// All other platforms provide standard C library time functions
tm local;
memset(&local, 0, sizeof(local)); // tm_[wy]day plus any non-standard fields
@@ -2333,7 +2258,6 @@ static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStat
if (ok)
*ok = false;
}
-#endif // Q_OS_WINCE
return ((qint64)secsSinceEpoch * 1000) + msec;
}
@@ -2349,23 +2273,7 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT
tm local;
bool valid = false;
-#if defined(Q_OS_WINCE)
- FILETIME utcTime = time_tToFt(secsSinceEpoch);
- FILETIME resultTime;
- valid = FileTimeToLocalFileTime(&utcTime , &resultTime);
- SYSTEMTIME sysTime;
- if (valid)
- valid = FileTimeToSystemTime(&resultTime , &sysTime);
-
- if (valid) {
- local.tm_sec = sysTime.wSecond;
- local.tm_min = sysTime.wMinute;
- local.tm_hour = sysTime.wHour;
- local.tm_mday = sysTime.wDay;
- local.tm_mon = sysTime.wMonth - 1;
- local.tm_year = sysTime.wYear - 1900;
- }
-#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
// localtime() is required to work as if tzset() was called before it.
// localtime_r() does not have this requirement, so make an explicit call.
qt_tzset();
@@ -2578,240 +2486,423 @@ static qint64 localMSecsToEpochMSecs(qint64 localMsecs,
}
}
-/*****************************************************************************
- QDateTimePrivate member functions
- *****************************************************************************/
+static inline bool specCanBeSmall(Qt::TimeSpec spec)
+{
+ return spec == Qt::LocalTime || spec == Qt::UTC;
+}
-QDateTimePrivate::QDateTimePrivate(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
- int offsetSeconds)
- : m_msecs(0),
- m_spec(Qt::LocalTime),
- m_offsetFromUtc(0),
- m_status(0)
+static inline bool msecsCanBeSmall(qint64 msecs)
{
- setTimeSpec(toSpec, offsetSeconds);
- setDateTime(toDate, toTime);
+ if (!QDateTimeData::CanBeSmall)
+ return false;
+
+ ShortData sd;
+ sd.msecs = qintptr(msecs);
+ return sd.msecs == msecs;
}
-#ifndef QT_BOOTSTRAPPED
-QDateTimePrivate::QDateTimePrivate(const QDate &toDate, const QTime &toTime,
- const QTimeZone &toTimeZone)
- : m_spec(Qt::TimeZone),
- m_offsetFromUtc(0),
- m_timeZone(toTimeZone),
- m_status(0)
+static Q_DECL_CONSTEXPR inline
+QDateTimePrivate::StatusFlags mergeSpec(QDateTimePrivate::StatusFlags status, Qt::TimeSpec spec)
{
- setDateTime(toDate, toTime);
+ return QDateTimePrivate::StatusFlags((status & ~QDateTimePrivate::TimeSpecMask) |
+ (int(spec) << QDateTimePrivate::TimeSpecShift));
+}
+
+static Q_DECL_CONSTEXPR inline Qt::TimeSpec extractSpec(QDateTimePrivate::StatusFlags status)
+{
+ return Qt::TimeSpec((status & QDateTimePrivate::TimeSpecMask) >> QDateTimePrivate::TimeSpecShift);
+}
+
+// Set the Daylight Status if LocalTime set via msecs
+static Q_DECL_RELAXED_CONSTEXPR inline QDateTimePrivate::StatusFlags
+mergeDaylightStatus(QDateTimePrivate::StatusFlags sf, QDateTimePrivate::DaylightStatus status)
+{
+ sf &= ~QDateTimePrivate::DaylightMask;
+ if (status == QDateTimePrivate::DaylightTime) {
+ sf |= QDateTimePrivate::SetToDaylightTime;
+ } else if (status == QDateTimePrivate::StandardTime) {
+ sf |= QDateTimePrivate::SetToStandardTime;
+ }
+ return sf;
+}
+
+// Get the DST Status if LocalTime set via msecs
+static Q_DECL_RELAXED_CONSTEXPR inline
+QDateTimePrivate::DaylightStatus extractDaylightStatus(QDateTimePrivate::StatusFlags status)
+{
+ if (status & QDateTimePrivate::SetToDaylightTime)
+ return QDateTimePrivate::DaylightTime;
+ if (status & QDateTimePrivate::SetToStandardTime)
+ return QDateTimePrivate::StandardTime;
+ return QDateTimePrivate::UnknownDaylightTime;
}
-#endif // QT_BOOTSTRAPPED
-void QDateTimePrivate::setTimeSpec(Qt::TimeSpec spec, int offsetSeconds)
+static inline qint64 getMSecs(const QDateTimeData &d)
{
- clearValidDateTime();
- clearSetToDaylightStatus();
+ if (d.isShort()) {
+ // same as, but producing better code
+ //return d.data.msecs;
+ return qintptr(d.d) >> 8;
+ }
+ return d->m_msecs;
+}
+
+static inline QDateTimePrivate::StatusFlags getStatus(const QDateTimeData &d)
+{
+ if (d.isShort()) {
+ // same as, but producing better code
+ //return StatusFlag(d.data.status);
+ return QDateTimePrivate::StatusFlag(qintptr(d.d) & 0xFF);
+ }
+ return d->m_status;
+}
+
+static inline Qt::TimeSpec getSpec(const QDateTimeData &d)
+{
+ return extractSpec(getStatus(d));
+}
+
+// Refresh the LocalTime validity and offset
+static void refreshDateTime(QDateTimeData &d)
+{
+ auto status = getStatus(d);
+ const auto spec = extractSpec(status);
+ const qint64 msecs = getMSecs(d);
+ qint64 epochMSecs = 0;
+ int offsetFromUtc = 0;
+ QDate testDate;
+ QTime testTime;
+ Q_ASSERT(spec == Qt::TimeZone || spec == Qt::LocalTime);
#ifndef QT_BOOTSTRAPPED
- m_timeZone = QTimeZone();
+ // If not valid time zone then is invalid
+ if (spec == Qt::TimeZone) {
+ if (!d->m_timeZone.isValid())
+ status &= ~QDateTimePrivate::ValidDateTime;
+ else
+ epochMSecs = QDateTimePrivate::zoneMSecsToEpochMSecs(msecs, d->m_timeZone, &testDate, &testTime);
+ }
#endif // QT_BOOTSTRAPPED
- switch (spec) {
- case Qt::OffsetFromUTC:
- if (offsetSeconds == 0) {
- m_spec = Qt::UTC;
- m_offsetFromUtc = 0;
+ // If not valid date and time then is invalid
+ if (!(status & QDateTimePrivate::ValidDate) || !(status & QDateTimePrivate::ValidTime)) {
+ status &= ~QDateTimePrivate::ValidDateTime;
+ if (status & QDateTimePrivate::ShortData) {
+ d.data.status = status;
} else {
- m_spec = Qt::OffsetFromUTC;
- m_offsetFromUtc = offsetSeconds;
+ d->m_status = status;
+ d->m_offsetFromUtc = 0;
}
+ return;
+ }
+
+ // We have a valid date and time and a Qt::LocalTime or Qt::TimeZone that needs calculating
+ // LocalTime and TimeZone might fall into a "missing" DST transition hour
+ // Calling toEpochMSecs will adjust the returned date/time if it does
+ if (spec == Qt::LocalTime) {
+ auto dstStatus = extractDaylightStatus(status);
+ epochMSecs = localMSecsToEpochMSecs(msecs, &dstStatus, &testDate, &testTime);
+ }
+ if (timeToMSecs(testDate, testTime) == msecs) {
+ status |= QDateTimePrivate::ValidDateTime;
+ // Cache the offset to use in offsetFromUtc()
+ offsetFromUtc = (msecs - epochMSecs) / 1000;
+ } else {
+ status &= ~QDateTimePrivate::ValidDateTime;
+ }
+
+ if (status & QDateTimePrivate::ShortData) {
+ d.data.status = status;
+ } else {
+ d->m_status = status;
+ d->m_offsetFromUtc = offsetFromUtc;
+ }
+}
+
+// Check the UTC / offsetFromUTC validity
+static void checkValidDateTime(QDateTimeData &d)
+{
+ auto status = getStatus(d);
+ auto spec = extractSpec(status);
+ switch (spec) {
+ case Qt::OffsetFromUTC:
+ case Qt::UTC:
+ // for these, a valid date and a valid time imply a valid QDateTime
+ if ((status & QDateTimePrivate::ValidDate) && (status & QDateTimePrivate::ValidTime))
+ status |= QDateTimePrivate::ValidDateTime;
+ else
+ status &= ~QDateTimePrivate::ValidDateTime;
+ if (status & QDateTimePrivate::ShortData)
+ d.data.status = status;
+ else
+ d->m_status = status;
break;
case Qt::TimeZone:
- // Use system time zone instead
- m_spec = Qt::LocalTime;
- m_offsetFromUtc = 0;
+ case Qt::LocalTime:
+ // for these, we need to check whether the timezone is valid and whether
+ // the time is valid in that timezone. Expensive, but no other option.
+ refreshDateTime(d);
+ break;
+ }
+}
+
+static void setTimeSpec(QDateTimeData &d, Qt::TimeSpec spec, int offsetSeconds)
+{
+ auto status = getStatus(d);
+ status &= ~(QDateTimePrivate::ValidDateTime | QDateTimePrivate::DaylightMask |
+ QDateTimePrivate::TimeSpecMask);
+
+ switch (spec) {
+ case Qt::OffsetFromUTC:
+ if (offsetSeconds == 0)
+ spec = Qt::UTC;
break;
+ case Qt::TimeZone:
+ // Use system time zone instead
+ spec = Qt::LocalTime;
+ Q_FALLTHROUGH();
case Qt::UTC:
case Qt::LocalTime:
- m_spec = spec;
- m_offsetFromUtc = 0;
+ offsetSeconds = 0;
break;
}
+
+ status = mergeSpec(status, spec);
+ if (d.isShort() && offsetSeconds == 0) {
+ d.data.status = status;
+ } else {
+ d.detach();
+ d->m_status = status & ~QDateTimePrivate::ShortData;
+ d->m_offsetFromUtc = offsetSeconds;
+#ifndef QT_BOOTSTRAPPED
+ d->m_timeZone = QTimeZone();
+#endif // QT_BOOTSTRAPPED
+ }
}
-void QDateTimePrivate::setDateTime(const QDate &date, const QTime &time)
+static void setDateTime(QDateTimeData &d, const QDate &date, const QTime &time)
{
// If the date is valid and the time is not we set time to 00:00:00
QTime useTime = time;
if (!useTime.isValid() && date.isValid())
useTime = QTime::fromMSecsSinceStartOfDay(0);
- StatusFlags newStatus;
+ QDateTimePrivate::StatusFlags newStatus = 0;
// Set date value and status
qint64 days = 0;
if (date.isValid()) {
days = date.toJulianDay() - JULIAN_DAY_FOR_EPOCH;
- newStatus = ValidDate;
- } else if (date.isNull()) {
- newStatus = NullDate;
+ newStatus = QDateTimePrivate::ValidDate;
}
// Set time value and status
int ds = 0;
if (useTime.isValid()) {
ds = useTime.msecsSinceStartOfDay();
- newStatus |= ValidTime;
- } else if (time.isNull()) {
- newStatus |= NullTime;
+ newStatus |= QDateTimePrivate::ValidTime;
}
// Set msecs serial value
- m_msecs = (days * MSECS_PER_DAY) + ds;
- m_status = newStatus;
+ qint64 msecs = (days * MSECS_PER_DAY) + ds;
+ if (d.isShort()) {
+ // let's see if we can keep this short
+ if (msecsCanBeSmall(msecs)) {
+ // yes, we can
+ d.data.msecs = qintptr(msecs);
+ d.data.status &= ~(QDateTimePrivate::ValidityMask | QDateTimePrivate::DaylightMask);
+ d.data.status |= newStatus;
+ } else {
+ // nope...
+ d.detach();
+ }
+ }
+ if (!d.isShort()) {
+ d.detach();
+ d->m_msecs = msecs;
+ d->m_status &= ~(QDateTimePrivate::ValidityMask | QDateTimePrivate::DaylightMask);
+ d->m_status |= newStatus;
+ }
// Set if date and time are valid
- checkValidDateTime();
+ checkValidDateTime(d);
}
-QPair<QDate, QTime> QDateTimePrivate::getDateTime() const
+static QPair<QDate, QTime> getDateTime(const QDateTimeData &d)
{
QPair<QDate, QTime> result;
- msecsToTime(m_msecs, &result.first, &result.second);
+ qint64 msecs = getMSecs(d);
+ auto status = getStatus(d);
+ msecsToTime(msecs, &result.first, &result.second);
- if (isNullDate())
+ if (!status.testFlag(QDateTimePrivate::ValidDate))
result.first = QDate();
- if (isNullTime())
+ if (!status.testFlag(QDateTimePrivate::ValidTime))
result.second = QTime();
return result;
}
-// Set the Daylight Status if LocalTime set via msecs
-void QDateTimePrivate::setDaylightStatus(QDateTimePrivate::DaylightStatus status)
-{
- if (status == DaylightTime) {
- m_status = m_status & ~SetToStandardTime;
- m_status = m_status | SetToDaylightTime;
- } else if (status == StandardTime) {
- m_status = m_status & ~SetToDaylightTime;
- m_status = m_status | SetToStandardTime;
+/*****************************************************************************
+ QDateTime::Data member functions
+ *****************************************************************************/
+
+inline QDateTime::Data::Data()
+{
+ // default-constructed data has a special exception:
+ // it can be small even if CanBeSmall == false
+ // (optimization so we don't allocate memory in the default constructor)
+ quintptr value = quintptr(mergeSpec(QDateTimePrivate::ShortData, Qt::LocalTime));
+ d = reinterpret_cast<QDateTimePrivate *>(value);
+}
+
+inline QDateTime::Data::Data(Qt::TimeSpec spec)
+{
+ if (CanBeSmall && Q_LIKELY(specCanBeSmall(spec))) {
+ d = reinterpret_cast<QDateTimePrivate *>(quintptr(mergeSpec(QDateTimePrivate::ShortData, spec)));
} else {
- clearSetToDaylightStatus();
+ // the structure is too small, we need to detach
+ d = new QDateTimePrivate;
+ d->ref.ref();
+ d->m_status = mergeSpec(0, spec);
}
}
-// Get the DST Status if LocalTime set via msecs
-QDateTimePrivate::DaylightStatus QDateTimePrivate::daylightStatus() const
+inline QDateTime::Data::Data(const Data &other)
+ : d(other.d)
{
- if ((m_status & SetToDaylightTime) == SetToDaylightTime)
- return DaylightTime;
- if ((m_status & SetToStandardTime) == SetToStandardTime)
- return StandardTime;
- return UnknownDaylightTime;
+ if (!isShort()) {
+ // check if we could shrink
+ if (specCanBeSmall(extractSpec(d->m_status)) && msecsCanBeSmall(d->m_msecs)) {
+ ShortData sd;
+ sd.msecs = qintptr(d->m_msecs);
+ sd.status = d->m_status | QDateTimePrivate::ShortData;
+ data = sd;
+ } else {
+ // no, have to keep it big
+ d->ref.ref();
+ }
+ }
}
-qint64 QDateTimePrivate::toMSecsSinceEpoch() const
+inline QDateTime::Data::Data(Data &&other)
+ : d(other.d)
{
- switch (m_spec) {
- case Qt::OffsetFromUTC:
- case Qt::UTC:
- return (m_msecs - (m_offsetFromUtc * 1000));
+ // reset the other to a short state
+ Data dummy;
+ Q_ASSERT(dummy.isShort());
+ other.d = dummy.d;
+}
- case Qt::LocalTime: {
- // recalculate the local timezone
- DaylightStatus status = daylightStatus();
- return localMSecsToEpochMSecs(m_msecs, &status);
- }
+inline QDateTime::Data &QDateTime::Data::operator=(const Data &other)
+{
+ if (d == other.d)
+ return *this;
- case Qt::TimeZone:
-#ifdef QT_BOOTSTRAPPED
- return 0;
-#else
- return zoneMSecsToEpochMSecs(m_msecs, m_timeZone);
-#endif
+ auto x = d;
+ d = other.d;
+ if (!other.isShort()) {
+ // check if we could shrink
+ if (specCanBeSmall(extractSpec(other.d->m_status)) && msecsCanBeSmall(other.d->m_msecs)) {
+ ShortData sd;
+ sd.msecs = qintptr(other.d->m_msecs);
+ sd.status = other.d->m_status | QDateTimePrivate::ShortData;
+ data = sd;
+ } else {
+ // no, have to keep it big
+ other.d->ref.ref();
+ }
}
- Q_UNREACHABLE();
- return 0;
+
+ if (!(quintptr(x) & QDateTimePrivate::ShortData) && !x->ref.deref())
+ delete x;
+ return *this;
}
-// Check the UTC / offsetFromUTC validity
-void QDateTimePrivate::checkValidDateTime()
+inline QDateTime::Data::~Data()
{
- switch (m_spec) {
- case Qt::OffsetFromUTC:
- case Qt::UTC:
- // for these, a valid date and a valid time imply a valid QDateTime
- if (isValidDate() && isValidTime())
- setValidDateTime();
- else
- clearValidDateTime();
- break;
- case Qt::TimeZone:
- case Qt::LocalTime:
- // for these, we need to check whether the timezone is valid and whether
- // the time is valid in that timezone. Expensive, but no other option.
- refreshDateTime();
- break;
- }
+ if (!isShort() && !d->ref.deref())
+ delete d;
}
-// Refresh the LocalTime validity and offset
-void QDateTimePrivate::refreshDateTime()
+inline bool QDateTime::Data::isShort() const
{
- switch (m_spec) {
- case Qt::OffsetFromUTC:
- case Qt::UTC:
- // Always set by setDateTime so just return
- return;
- case Qt::TimeZone:
- case Qt::LocalTime:
- break;
- }
-
- // If not valid date and time then is invalid
- if (!isValidDate() || !isValidTime()) {
- clearValidDateTime();
- m_offsetFromUtc = 0;
- return;
- }
+ bool b = quintptr(d) & QDateTimePrivate::ShortData;
-#ifndef QT_BOOTSTRAPPED
- // If not valid time zone then is invalid
- if (m_spec == Qt::TimeZone && !m_timeZone.isValid()) {
- clearValidDateTime();
- m_offsetFromUtc = 0;
- return;
- }
-#endif // QT_BOOTSTRAPPED
+ // even if CanBeSmall = false, we have short data for a default-constructed
+ // QDateTime object. But it's unlikely.
+ if (CanBeSmall)
+ return Q_LIKELY(b);
+ return Q_UNLIKELY(b);
+}
- // We have a valid date and time and a Qt::LocalTime or Qt::TimeZone that needs calculating
- // LocalTime and TimeZone might fall into a "missing" DST transition hour
- // Calling toEpochMSecs will adjust the returned date/time if it does
- QDate testDate;
- QTime testTime;
- qint64 epochMSecs = 0;
- if (m_spec == Qt::LocalTime) {
- DaylightStatus status = daylightStatus();
- epochMSecs = localMSecsToEpochMSecs(m_msecs, &status, &testDate, &testTime);
-#ifndef QT_BOOTSTRAPPED
- } else {
- epochMSecs = zoneMSecsToEpochMSecs(m_msecs, m_timeZone, &testDate, &testTime);
-#endif // QT_BOOTSTRAPPED
- }
- if (timeToMSecs(testDate, testTime) == m_msecs) {
- setValidDateTime();
- // Cache the offset to use in toMSecsSinceEpoch()
- m_offsetFromUtc = (m_msecs - epochMSecs) / 1000;
+inline void QDateTime::Data::detach()
+{
+ QDateTimePrivate *x;
+ bool wasShort = isShort();
+ if (wasShort) {
+ // force enlarging
+ x = new QDateTimePrivate;
+ x->m_status = QDateTimePrivate::StatusFlag(data.status & ~QDateTimePrivate::ShortData);
+ x->m_msecs = data.msecs;
} else {
- clearValidDateTime();
- m_offsetFromUtc = 0;
+ if (d->ref.load() == 1)
+ return;
+
+ x = new QDateTimePrivate(*d);
}
+
+ x->ref.store(1);
+ if (!wasShort && !d->ref.deref())
+ delete d;
+ d = x;
+}
+
+inline const QDateTimePrivate *QDateTime::Data::operator->() const
+{
+ Q_ASSERT(!isShort());
+ return d;
+}
+
+inline QDateTimePrivate *QDateTime::Data::operator->()
+{
+ // should we attempt to detach here?
+ Q_ASSERT(!isShort());
+ Q_ASSERT(d->ref.load() == 1);
+ return d;
+}
+
+/*****************************************************************************
+ QDateTimePrivate member functions
+ *****************************************************************************/
+
+Q_NEVER_INLINE
+QDateTime::Data QDateTimePrivate::create(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
+ int offsetSeconds)
+{
+ QDateTime::Data result(toSpec);
+ setTimeSpec(result, toSpec, offsetSeconds);
+ setDateTime(result, toDate, toTime);
+ return result;
}
#ifndef QT_BOOTSTRAPPED
+inline QDateTime::Data QDateTimePrivate::create(const QDate &toDate, const QTime &toTime,
+ const QTimeZone &toTimeZone)
+{
+ QDateTime::Data result(Qt::TimeZone);
+ Q_ASSERT(!result.isShort());
+
+ result.d->m_status = mergeSpec(result.d->m_status, Qt::TimeZone);
+ result.d->m_timeZone = toTimeZone;
+ setDateTime(result, toDate, toTime);
+ return result;
+}
+
// Convert a TimeZone time expressed in zone msecs encoding into a UTC epoch msecs
-qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone &zone,
- QDate *localDate, QTime *localTime)
+inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone &zone,
+ QDate *localDate, QTime *localTime)
{
// Get the effective data from QTimeZone
QTimeZonePrivate::Data data = zone.d->dataForLocalTime(zoneMSecs);
@@ -2961,8 +3052,7 @@ qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone
\sa isValid()
*/
-QDateTime::QDateTime()
- : d(*defaultDateTimePrivate())
+QDateTime::QDateTime() Q_DECL_NOEXCEPT_EXPR(Data::CanBeSmall)
{
}
@@ -2973,7 +3063,7 @@ QDateTime::QDateTime()
*/
QDateTime::QDateTime(const QDate &date)
- : d(new QDateTimePrivate(date, QTime(0, 0, 0), Qt::LocalTime, 0))
+ : d(QDateTimePrivate::create(date, QTime(0, 0, 0), Qt::LocalTime, 0))
{
}
@@ -2993,7 +3083,7 @@ QDateTime::QDateTime(const QDate &date)
*/
QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec)
- : d(new QDateTimePrivate(date, time, spec, 0))
+ : d(QDateTimePrivate::create(date, time, spec, 0))
{
}
@@ -3016,7 +3106,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec)
*/
QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, int offsetSeconds)
- : d(new QDateTimePrivate(date, time, spec, offsetSeconds))
+ : d(QDateTimePrivate::create(date, time, spec, offsetSeconds))
{
}
@@ -3033,7 +3123,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, in
*/
QDateTime::QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone)
- : d(new QDateTimePrivate(date, time, timeZone))
+ : d(QDateTimePrivate::create(date, time, timeZone))
{
}
#endif // QT_BOOTSTRAPPED
@@ -3041,13 +3131,22 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, const QTimeZone &time
/*!
Constructs a copy of the \a other datetime.
*/
-
-QDateTime::QDateTime(const QDateTime &other)
+QDateTime::QDateTime(const QDateTime &other) Q_DECL_NOTHROW
: d(other.d)
{
}
/*!
+ \since 5.8
+ Moves the content of the temporary \a other datetime to this object and
+ leaves \a other in an unspecified (but proper) state.
+*/
+QDateTime::QDateTime(QDateTime &&other) Q_DECL_NOTHROW
+ : d(std::move(other.d))
+{
+}
+
+/*!
Destroys the datetime.
*/
QDateTime::~QDateTime()
@@ -3059,7 +3158,7 @@ QDateTime::~QDateTime()
copy.
*/
-QDateTime &QDateTime::operator=(const QDateTime &other)
+QDateTime &QDateTime::operator=(const QDateTime &other) Q_DECL_NOTHROW
{
d = other.d;
return *this;
@@ -3081,7 +3180,9 @@ QDateTime &QDateTime::operator=(const QDateTime &other)
bool QDateTime::isNull() const
{
- return d->isNullDate() && d->isNullTime();
+ auto status = getStatus(d);
+ return !status.testFlag(QDateTimePrivate::ValidDate) &&
+ !status.testFlag(QDateTimePrivate::ValidTime);
}
/*!
@@ -3098,7 +3199,8 @@ bool QDateTime::isNull() const
bool QDateTime::isValid() const
{
- return (d->isValidDateTime());
+ auto status = getStatus(d);
+ return status & QDateTimePrivate::ValidDateTime;
}
/*!
@@ -3109,10 +3211,11 @@ bool QDateTime::isValid() const
QDate QDateTime::date() const
{
- if (d->isNullDate())
+ auto status = getStatus(d);
+ if (!status.testFlag(QDateTimePrivate::ValidDate))
return QDate();
QDate dt;
- msecsToTime(d->m_msecs, &dt, 0);
+ msecsToTime(getMSecs(d), &dt, 0);
return dt;
}
@@ -3124,10 +3227,11 @@ QDate QDateTime::date() const
QTime QDateTime::time() const
{
- if (d->isNullTime())
+ auto status = getStatus(d);
+ if (!status.testFlag(QDateTimePrivate::ValidTime))
return QTime();
QTime tm;
- msecsToTime(d->m_msecs, 0, &tm);
+ msecsToTime(getMSecs(d), 0, &tm);
return tm;
}
@@ -3139,7 +3243,7 @@ QTime QDateTime::time() const
Qt::TimeSpec QDateTime::timeSpec() const
{
- return d->m_spec;
+ return getSpec(d);
}
#ifndef QT_BOOTSTRAPPED
@@ -3157,7 +3261,7 @@ Qt::TimeSpec QDateTime::timeSpec() const
QTimeZone QDateTime::timeZone() const
{
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
return QTimeZone::utc();
case Qt::OffsetFromUTC:
@@ -3192,7 +3296,20 @@ QTimeZone QDateTime::timeZone() const
int QDateTime::offsetFromUtc() const
{
- return d->m_offsetFromUtc;
+ if (!d.isShort())
+ return d->m_offsetFromUtc;
+ if (!isValid())
+ return 0;
+
+ auto spec = getSpec(d);
+ if (spec == Qt::LocalTime) {
+ // we didn't cache the value, so we need to calculate it now...
+ qint64 msecs = getMSecs(d);
+ return (msecs - toMSecsSinceEpoch()) / 1000;
+ }
+
+ Q_ASSERT(spec == Qt::UTC);
+ return 0;
}
/*!
@@ -3218,7 +3335,7 @@ int QDateTime::offsetFromUtc() const
QString QDateTime::timeZoneAbbreviation() const
{
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
return QTimeZonePrivate::utcQString();
case Qt::OffsetFromUTC:
@@ -3227,12 +3344,12 @@ QString QDateTime::timeZoneAbbreviation() const
#ifdef QT_BOOTSTRAPPED
break;
#else
- return d->m_timeZone.d->abbreviation(d->toMSecsSinceEpoch());
+ return d->m_timeZone.d->abbreviation(toMSecsSinceEpoch());
#endif // QT_BOOTSTRAPPED
case Qt::LocalTime: {
QString abbrev;
- QDateTimePrivate::DaylightStatus status = d->daylightStatus();
- localMSecsToEpochMSecs(d->m_msecs, &status, 0, 0, &abbrev);
+ auto status = extractDaylightStatus(getStatus(d));
+ localMSecsToEpochMSecs(getMSecs(d), &status, 0, 0, &abbrev);
return abbrev;
}
}
@@ -3252,7 +3369,7 @@ QString QDateTime::timeZoneAbbreviation() const
bool QDateTime::isDaylightTime() const
{
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
case Qt::OffsetFromUTC:
return false;
@@ -3263,9 +3380,9 @@ bool QDateTime::isDaylightTime() const
return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch());
#endif // QT_BOOTSTRAPPED
case Qt::LocalTime: {
- QDateTimePrivate::DaylightStatus status = d->daylightStatus();
+ auto status = extractDaylightStatus(getStatus(d));
if (status == QDateTimePrivate::UnknownDaylightTime)
- localMSecsToEpochMSecs(d->m_msecs, &status);
+ localMSecsToEpochMSecs(getMSecs(d), &status);
return (status == QDateTimePrivate::DaylightTime);
}
}
@@ -3281,7 +3398,7 @@ bool QDateTime::isDaylightTime() const
void QDateTime::setDate(const QDate &date)
{
- d->setDateTime(date, time());
+ setDateTime(d, date, time());
}
/*!
@@ -3299,7 +3416,7 @@ void QDateTime::setDate(const QDate &date)
void QDateTime::setTime(const QTime &time)
{
- d->setDateTime(date(), time);
+ setDateTime(d, date(), time);
}
/*!
@@ -3320,9 +3437,8 @@ void QDateTime::setTime(const QTime &time)
void QDateTime::setTimeSpec(Qt::TimeSpec spec)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
- d->setTimeSpec(spec, 0);
- d->checkValidDateTime();
+ QT_PREPEND_NAMESPACE(setTimeSpec(d, spec, 0));
+ checkValidDateTime(d);
}
/*!
@@ -3342,9 +3458,8 @@ void QDateTime::setTimeSpec(Qt::TimeSpec spec)
void QDateTime::setOffsetFromUtc(int offsetSeconds)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
- d->setTimeSpec(Qt::OffsetFromUTC, offsetSeconds);
- d->checkValidDateTime();
+ QT_PREPEND_NAMESPACE(setTimeSpec(d, Qt::OffsetFromUTC, offsetSeconds));
+ checkValidDateTime(d);
}
#ifndef QT_BOOTSTRAPPED
@@ -3361,11 +3476,11 @@ void QDateTime::setOffsetFromUtc(int offsetSeconds)
void QDateTime::setTimeZone(const QTimeZone &toZone)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
- d->m_spec = Qt::TimeZone;
+ d.detach(); // always detach
+ d->m_status = mergeSpec(d->m_status, Qt::TimeZone);
d->m_offsetFromUtc = 0;
d->m_timeZone = toZone;
- d->refreshDateTime();
+ refreshDateTime(d);
}
#endif // QT_BOOTSTRAPPED
@@ -3382,44 +3497,85 @@ void QDateTime::setTimeZone(const QTimeZone &toZone)
this object is not valid. However, for all valid dates, this function
returns a unique value.
- \sa toTime_t(), setMSecsSinceEpoch()
+ \sa toSecsSinceEpoch(), setMSecsSinceEpoch()
*/
qint64 QDateTime::toMSecsSinceEpoch() const
{
- return d->toMSecsSinceEpoch();
+ switch (getSpec(d)) {
+ case Qt::UTC:
+ return getMSecs(d);
+
+ case Qt::OffsetFromUTC:
+ return d->m_msecs - (d->m_offsetFromUtc * 1000);
+
+ case Qt::LocalTime: {
+ // recalculate the local timezone
+ auto status = extractDaylightStatus(getStatus(d));
+ return localMSecsToEpochMSecs(getMSecs(d), &status);
+ }
+
+ case Qt::TimeZone:
+#ifdef QT_BOOTSTRAPPED
+ return 0;
+#else
+ return QDateTimePrivate::zoneMSecsToEpochMSecs(d->m_msecs, d->m_timeZone);
+#endif
+ }
+ Q_UNREACHABLE();
+ return 0;
+}
+
+/*!
+ \since 5.8
+
+ Returns the datetime as the number of seconds that have passed since
+ 1970-01-01T00:00:00.000, Coordinated Universal Time (Qt::UTC).
+
+ On systems that do not support time zones, this function will
+ behave as if local time were Qt::UTC.
+
+ The behavior for this function is undefined if the datetime stored in
+ this object is not valid. However, for all valid dates, this function
+ returns a unique value.
+
+ \sa toMSecsSinceEpoch(), setSecsSinceEpoch()
+*/
+qint64 QDateTime::toSecsSinceEpoch() const
+{
+ return toMSecsSinceEpoch() / 1000;
}
+#if QT_DEPRECATED_SINCE(5, 8)
/*!
+ \deprecated
+
Returns the datetime as the number of seconds that have passed
since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC).
On systems that do not support time zones, this function will
behave as if local time were Qt::UTC.
- \note This function returns a 32-bit unsigned integer, so it does not
- support dates before 1970, but it does support dates after
- 2038-01-19T03:14:06, which may not be valid time_t values. Be careful
- when passing those time_t values to system functions, which could
- interpret them as negative dates.
+ \note This function returns a 32-bit unsigned integer and is deprecated.
If the date is outside the range 1970-01-01T00:00:00 to
2106-02-07T06:28:14, this function returns -1 cast to an unsigned integer
(i.e., 0xFFFFFFFF).
- To get an extended range, use toMSecsSinceEpoch().
+ To get an extended range, use toMSecsSinceEpoch() or toSecsSinceEpoch().
- \sa toMSecsSinceEpoch(), setTime_t()
+ \sa toSecsSinceEpoch(), toMSecsSinceEpoch(), setTime_t()
*/
uint QDateTime::toTime_t() const
{
if (!isValid())
return uint(-1);
- qint64 retval = d->toMSecsSinceEpoch() / 1000;
+ qint64 retval = toMSecsSinceEpoch() / 1000;
if (quint64(retval) >= Q_UINT64_C(0xFFFFFFFF))
return uint(-1);
return uint(retval);
}
+#endif
/*!
\since 4.7
@@ -3433,65 +3589,98 @@ uint QDateTime::toTime_t() const
(\c{std::numeric_limits<qint64>::min()}) to \a msecs will result in
undefined behavior.
- \sa toMSecsSinceEpoch(), setTime_t()
+ \sa toMSecsSinceEpoch(), setSecsSinceEpoch()
*/
void QDateTime::setMSecsSinceEpoch(qint64 msecs)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
+ const auto spec = getSpec(d);
+ auto status = getStatus(d);
- d->m_status = 0;
- switch (d->m_spec) {
+ status &= ~QDateTimePrivate::ValidityMask;
+ switch (spec) {
case Qt::UTC:
- d->m_msecs = msecs;
- d->m_status = d->m_status
+ status = status
| QDateTimePrivate::ValidDate
| QDateTimePrivate::ValidTime
| QDateTimePrivate::ValidDateTime;
break;
case Qt::OffsetFromUTC:
- d->m_msecs = msecs + (d->m_offsetFromUtc * 1000);
- d->m_status = d->m_status
+ msecs = msecs + (d->m_offsetFromUtc * 1000);
+ status = status
| QDateTimePrivate::ValidDate
| QDateTimePrivate::ValidTime
| QDateTimePrivate::ValidDateTime;
break;
case Qt::TimeZone:
+ Q_ASSERT(!d.isShort());
#ifndef QT_BOOTSTRAPPED
// Docs state any LocalTime before 1970-01-01 will *not* have any DST applied
// but all affected times afterwards will have DST applied.
+ d.detach();
if (msecs >= 0)
d->m_offsetFromUtc = d->m_timeZone.d->offsetFromUtc(msecs);
else
d->m_offsetFromUtc = d->m_timeZone.d->standardTimeOffset(msecs);
- d->m_msecs = msecs + (d->m_offsetFromUtc * 1000);
- d->m_status = d->m_status
+ msecs = msecs + (d->m_offsetFromUtc * 1000);
+ status = status
| QDateTimePrivate::ValidDate
| QDateTimePrivate::ValidTime
| QDateTimePrivate::ValidDateTime;
- d->refreshDateTime();
#endif // QT_BOOTSTRAPPED
break;
case Qt::LocalTime: {
QDate dt;
QTime tm;
- QDateTimePrivate::DaylightStatus status;
- epochMSecsToLocalTime(msecs, &dt, &tm, &status);
- d->setDateTime(dt, tm);
- d->setDaylightStatus(status);
- d->refreshDateTime();
+ QDateTimePrivate::DaylightStatus dstStatus;
+ epochMSecsToLocalTime(msecs, &dt, &tm, &dstStatus);
+ setDateTime(d, dt, tm);
+ msecs = getMSecs(d);
+ status = mergeDaylightStatus(getStatus(d), dstStatus);
break;
}
}
+
+ if (msecsCanBeSmall(msecs) && d.isShort()) {
+ // we can keep short
+ d.data.msecs = qintptr(msecs);
+ d.data.status = status;
+ } else {
+ d.detach();
+ d->m_status = status;
+ d->m_msecs = msecs;
+ }
+
+ if (spec == Qt::LocalTime || spec == Qt::TimeZone)
+ refreshDateTime(d);
}
/*!
+ \since 5.8
+
+ Sets the date and time given the number of seconds \a secs that have
+ passed since 1970-01-01T00:00:00.000, Coordinated Universal Time
+ (Qt::UTC). On systems that do not support time zones this function
+ will behave as if local time were Qt::UTC.
+
+ \sa toSecsSinceEpoch(), setMSecsSinceEpoch()
+*/
+void QDateTime::setSecsSinceEpoch(qint64 secs)
+{
+ setMSecsSinceEpoch(secs * 1000);
+}
+
+#if QT_DEPRECATED_SINCE(5, 8)
+/*!
\fn void QDateTime::setTime_t(uint seconds)
+ \deprecated
Sets the date and time given the number of \a seconds that have
passed since 1970-01-01T00:00:00, Coordinated Universal Time
(Qt::UTC). On systems that do not support time zones this function
will behave as if local time were Qt::UTC.
+ \note This function is deprecated. For new code, use setSecsSinceEpoch().
+
\sa toTime_t()
*/
@@ -3499,6 +3688,7 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
{
setMSecsSinceEpoch((qint64)secsSince1Jan1970UTC * 1000);
}
+#endif
#ifndef QT_NO_DATESTRING
/*!
@@ -3569,13 +3759,13 @@ QString QDateTime::toString(Qt::DateFormat format) const
return QLocale().toString(*this, QLocale::LongFormat);
case Qt::RFC2822Date: {
buf = QLocale::c().toString(*this, QStringLiteral("dd MMM yyyy hh:mm:ss "));
- buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc);
+ buf += toOffsetString(Qt::TextDate, offsetFromUtc());
return buf;
}
default:
#ifndef QT_NO_TEXTDATE
case Qt::TextDate: {
- const QPair<QDate, QTime> p = d->getDateTime();
+ const QPair<QDate, QTime> p = getDateTime(d);
const QDate &dt = p.first;
const QTime &tm = p.second;
//We cant use date.toString(Qt::TextDate) as we need to insert the time before the year
@@ -3586,14 +3776,14 @@ QString QDateTime::toString(Qt::DateFormat format) const
.arg(dt.year());
if (timeSpec() != Qt::LocalTime) {
buf += QLatin1String(" GMT");
- if (d->m_spec == Qt::OffsetFromUTC)
- buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc);
+ if (getSpec(d) == Qt::OffsetFromUTC)
+ buf += toOffsetString(Qt::TextDate, offsetFromUtc());
}
return buf;
}
#endif
case Qt::ISODate: {
- const QPair<QDate, QTime> p = d->getDateTime();
+ const QPair<QDate, QTime> p = getDateTime(d);
const QDate &dt = p.first;
const QTime &tm = p.second;
buf = dt.toString(Qt::ISODate);
@@ -3601,12 +3791,12 @@ QString QDateTime::toString(Qt::DateFormat format) const
return QString(); // failed to convert
buf += QLatin1Char('T');
buf += tm.toString(Qt::ISODate);
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
buf += QLatin1Char('Z');
break;
case Qt::OffsetFromUTC:
- buf += toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
+ buf += toOffsetString(Qt::ISODate, offsetFromUtc());
break;
default:
break;
@@ -3695,12 +3885,7 @@ QString QDateTime::toString(const QString& format) const
}
#endif //QT_NO_DATESTRING
-static void massageAdjustedDateTime(Qt::TimeSpec spec,
-#ifndef QT_BOOTSTRAPPED
- const QTimeZone &zone,
-#endif // QT_BOOTSTRAPPED
- QDate *date,
- QTime *time)
+static inline void massageAdjustedDateTime(const QDateTimeData &d, QDate *date, QTime *time)
{
/*
If we have just adjusted to a day with a DST transition, our given time
@@ -3710,24 +3895,20 @@ static void massageAdjustedDateTime(Qt::TimeSpec spec,
to its DST-ness); but for a time in spring's missing hour it'll adjust the
time while picking a DST-ness. (Handling of autumn is trickier, as either
DST-ness is valid, without adjusting the time. We might want to propagate
- d->daylightStatus() in that case, but it's hard to do so without breaking
+ the daylight status in that case, but it's hard to do so without breaking
(far more common) other cases; and it makes little difference, as the two
answers do then differ only in DST-ness.)
*/
+ auto spec = getSpec(d);
if (spec == Qt::LocalTime) {
QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime;
localMSecsToEpochMSecs(timeToMSecs(*date, *time), &status, date, time);
#ifndef QT_BOOTSTRAPPED
} else if (spec == Qt::TimeZone) {
- QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), zone, date, time);
+ QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), d->m_timeZone, date, time);
#endif // QT_BOOTSTRAPPED
}
}
-#ifdef QT_BOOTSTRAPPED // Avoid duplicate #if-ery in uses.
-#define MASSAGEADJUSTEDDATETIME(s, z, d, t) massageAdjustedDateTime(s, d, t)
-#else
-#define MASSAGEADJUSTEDDATETIME(s, z, d, t) massageAdjustedDateTime(s, z, d, t)
-#endif // QT_BOOTSTRAPPED
/*!
Returns a QDateTime object containing a datetime \a ndays days
@@ -3746,12 +3927,12 @@ static void massageAdjustedDateTime(Qt::TimeSpec spec,
QDateTime QDateTime::addDays(qint64 ndays) const
{
QDateTime dt(*this);
- QPair<QDate, QTime> p = d->getDateTime();
+ QPair<QDate, QTime> p = getDateTime(d);
QDate &date = p.first;
QTime &time = p.second;
date = date.addDays(ndays);
- MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);
- dt.d->setDateTime(date, time);
+ massageAdjustedDateTime(dt.d, &date, &time);
+ setDateTime(dt.d, date, time);
return dt;
}
@@ -3772,12 +3953,12 @@ QDateTime QDateTime::addDays(qint64 ndays) const
QDateTime QDateTime::addMonths(int nmonths) const
{
QDateTime dt(*this);
- QPair<QDate, QTime> p = d->getDateTime();
+ QPair<QDate, QTime> p = getDateTime(d);
QDate &date = p.first;
QTime &time = p.second;
date = date.addMonths(nmonths);
- MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);
- dt.d->setDateTime(date, time);
+ massageAdjustedDateTime(dt.d, &date, &time);
+ setDateTime(dt.d, date, time);
return dt;
}
@@ -3798,15 +3979,14 @@ QDateTime QDateTime::addMonths(int nmonths) const
QDateTime QDateTime::addYears(int nyears) const
{
QDateTime dt(*this);
- QPair<QDate, QTime> p = d->getDateTime();
+ QPair<QDate, QTime> p = getDateTime(d);
QDate &date = p.first;
QTime &time = p.second;
date = date.addYears(nyears);
- MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);
- dt.d->setDateTime(date, time);
+ massageAdjustedDateTime(dt.d, &date, &time);
+ setDateTime(dt.d, date, time);
return dt;
}
-#undef MASSAGEADJUSTEDDATETIME
/*!
Returns a QDateTime object containing a datetime \a s seconds
@@ -3838,12 +4018,26 @@ QDateTime QDateTime::addMSecs(qint64 msecs) const
return QDateTime();
QDateTime dt(*this);
- if (d->m_spec == Qt::LocalTime || d->m_spec == Qt::TimeZone)
+ auto spec = getSpec(d);
+ if (spec == Qt::LocalTime || spec == Qt::TimeZone) {
// Convert to real UTC first in case crosses DST transition
- dt.setMSecsSinceEpoch(d->toMSecsSinceEpoch() + msecs);
- else
+ dt.setMSecsSinceEpoch(toMSecsSinceEpoch() + msecs);
+ } else {
// No need to convert, just add on
- dt.d->m_msecs = dt.d->m_msecs + msecs;
+ if (d.isShort()) {
+ // need to check if we need to enlarge first
+ msecs += dt.d.data.msecs;
+ if (msecsCanBeSmall(msecs)) {
+ dt.d.data.msecs = qintptr(msecs);
+ } else {
+ dt.d.detach();
+ dt.d->m_msecs = msecs;
+ }
+ } else {
+ dt.d.detach();
+ dt.d->m_msecs += msecs;
+ }
+ }
return dt;
}
@@ -3909,7 +4103,7 @@ qint64 QDateTime::msecsTo(const QDateTime &other) const
if (!isValid() || !other.isValid())
return 0;
- return other.d->toMSecsSinceEpoch() - d->toMSecsSinceEpoch();
+ return other.toMSecsSinceEpoch() - toMSecsSinceEpoch();
}
/*!
@@ -3932,7 +4126,7 @@ qint64 QDateTime::msecsTo(const QDateTime &other) const
QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const
{
- if (d->m_spec == spec && (spec == Qt::UTC || spec == Qt::LocalTime))
+ if (getSpec(d) == spec && (spec == Qt::UTC || spec == Qt::LocalTime))
return *this;
if (!isValid()) {
@@ -3941,7 +4135,7 @@ QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const
return ret;
}
- return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), spec, 0);
+ return fromMSecsSinceEpoch(toMSecsSinceEpoch(), spec, 0);
}
/*!
@@ -3959,7 +4153,8 @@ QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const
QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const
{
- if (d->m_spec == Qt::OffsetFromUTC && d->m_offsetFromUtc == offsetSeconds)
+ if (getSpec(d) == Qt::OffsetFromUTC
+ && d->m_offsetFromUtc == offsetSeconds)
return *this;
if (!isValid()) {
@@ -3968,7 +4163,7 @@ QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const
return ret;
}
- return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), Qt::OffsetFromUTC, offsetSeconds);
+ return fromMSecsSinceEpoch(toMSecsSinceEpoch(), Qt::OffsetFromUTC, offsetSeconds);
}
#ifndef QT_BOOTSTRAPPED
@@ -3982,7 +4177,7 @@ QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const
QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const
{
- if (d->m_spec == Qt::TimeZone && d->m_timeZone == timeZone)
+ if (getSpec(d) == Qt::TimeZone && d->m_timeZone == timeZone)
return *this;
if (!isValid()) {
@@ -3991,7 +4186,7 @@ QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const
return ret;
}
- return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), timeZone);
+ return fromMSecsSinceEpoch(toMSecsSinceEpoch(), timeZone);
}
#endif // QT_BOOTSTRAPPED
@@ -4004,10 +4199,9 @@ QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const
bool QDateTime::operator==(const QDateTime &other) const
{
- if (d->m_spec == Qt::LocalTime
- && other.d->m_spec == Qt::LocalTime
- && d->m_status == other.d->m_status) {
- return (d->m_msecs == other.d->m_msecs);
+ if (getSpec(d) == Qt::LocalTime
+ && getStatus(d) == getStatus(other.d)) {
+ return getMSecs(d) == getMSecs(other.d);
}
// Convert to UTC and compare
return (toMSecsSinceEpoch() == other.toMSecsSinceEpoch());
@@ -4032,10 +4226,9 @@ bool QDateTime::operator==(const QDateTime &other) const
bool QDateTime::operator<(const QDateTime &other) const
{
- if (d->m_spec == Qt::LocalTime
- && other.d->m_spec == Qt::LocalTime
- && d->m_status == other.d->m_status) {
- return (d->m_msecs < other.d->m_msecs);
+ if (getSpec(d) == Qt::LocalTime
+ && getStatus(d) == getStatus(other.d)) {
+ return getMSecs(d) < getMSecs(other.d);
}
// Convert to UTC and compare
return (toMSecsSinceEpoch() < other.toMSecsSinceEpoch());
@@ -4090,6 +4283,16 @@ bool QDateTime::operator<(const QDateTime &other) const
\sa currentDateTime(), currentDateTimeUtc(), toTime_t(), toTimeSpec()
*/
+/*!
+ \fn qint64 QDateTime::currentSecsSinceEpoch()
+ \since 5.8
+
+ Returns the number of seconds since 1970-01-01T00:00:00 Universal
+ Coordinated Time.
+
+ \sa currentMSecsSinceEpoch()
+*/
+
#if defined(Q_OS_WIN)
static inline uint msecsFromDecomposed(int hour, int minute, int sec, int msec = 0)
{
@@ -4113,9 +4316,6 @@ QTime QTime::currentTime()
memset(&st, 0, sizeof(SYSTEMTIME));
GetLocalTime(&st);
ct.setHMS(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
-#if defined(Q_OS_WINCE)
- ct.startTick = GetTickCount() % MSECS_PER_DAY;
-#endif
return ct;
}
@@ -4154,6 +4354,17 @@ qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW
- julianDayFromDate(1970, 1, 1)) * Q_INT64_C(86400000);
}
+qint64 QDateTime::currentSecsSinceEpoch() Q_DECL_NOTHROW
+{
+ SYSTEMTIME st;
+ memset(&st, 0, sizeof(SYSTEMTIME));
+ GetSystemTime(&st);
+
+ return st.wHour * SECS_PER_HOUR + st.wMinute * SECS_PER_MIN + st.wSecond +
+ qint64(julianDayFromDate(st.wYear, st.wMonth, st.wDay)
+ - julianDayFromDate(1970, 1, 1)) * Q_INT64_C(86400);
+}
+
#elif defined(Q_OS_UNIX)
QDate QDate::currentDate()
{
@@ -4184,51 +4395,29 @@ qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW
return qint64(tv.tv_sec) * Q_INT64_C(1000) + tv.tv_usec / 1000;
}
+qint64 QDateTime::currentSecsSinceEpoch() Q_DECL_NOTHROW
+{
+ struct timeval tv;
+ gettimeofday(&tv, 0);
+ return qint64(tv.tv_sec);
+}
#else
#error "What system is this?"
#endif
-/*! \fn QDateTime QDateTime::fromCFDate(CFDateRef date)
- \since 5.5
-
- Constructs a new QDateTime containing a copy of the CFDate \a date.
-
- \sa toCFDate()
-*/
-
-/*! \fn CFDateRef QDateTime::toCFDate() const
- \since 5.5
-
- Creates a CFDate from a QDateTime. The caller owns the CFDate object
- and is responsible for releasing it.
-
- \sa fromCFDate()
-*/
-
-/*! \fn QDateTime QDateTime::fromNSDate(const NSDate *date)
- \since 5.5
-
- Constructs a new QDateTime containing a copy of the NSDate \a date.
-
- \sa toNSDate()
-*/
-
-/*! \fn NSDate QDateTime::toNSDate() const
- \since 5.5
-
- Creates an NSDate from a QDateTime. The NSDate object is autoreleased.
-
- \sa fromNSDate()
-*/
-
+#if QT_DEPRECATED_SINCE(5, 8)
/*!
\since 4.2
+ \deprecated
Returns a datetime whose date and time are the number of \a seconds
that have passed since 1970-01-01T00:00:00, Coordinated Universal
Time (Qt::UTC) and converted to Qt::LocalTime. On systems that do not
support time zones, the time will be set as if local time were Qt::UTC.
+ \note This function is deprecated. Please use fromSecsSinceEpoch() in new
+ code.
+
\sa toTime_t(), setTime_t()
*/
QDateTime QDateTime::fromTime_t(uint seconds)
@@ -4238,6 +4427,7 @@ QDateTime QDateTime::fromTime_t(uint seconds)
/*!
\since 5.2
+ \deprecated
Returns a datetime whose date and time are the number of \a seconds
that have passed since 1970-01-01T00:00:00, Coordinated Universal
@@ -4247,6 +4437,9 @@ QDateTime QDateTime::fromTime_t(uint seconds)
ignored. If the \a spec is Qt::OffsetFromUTC and the \a offsetSeconds is 0
then the spec will be set to Qt::UTC, i.e. an offset of 0 seconds.
+ \note This function is deprecated. Please use fromSecsSinceEpoch() in new
+ code.
+
\sa toTime_t(), setTime_t()
*/
QDateTime QDateTime::fromTime_t(uint seconds, Qt::TimeSpec spec, int offsetSeconds)
@@ -4257,11 +4450,15 @@ QDateTime QDateTime::fromTime_t(uint seconds, Qt::TimeSpec spec, int offsetSecon
#ifndef QT_BOOTSTRAPPED
/*!
\since 5.2
+ \deprecated
Returns a datetime whose date and time are the number of \a seconds
that have passed since 1970-01-01T00:00:00, Coordinated Universal
Time (Qt::UTC) and with the given \a timeZone.
+ \note This function is deprecated. Please use fromSecsSinceEpoch() in new
+ code.
+
\sa toTime_t(), setTime_t()
*/
QDateTime QDateTime::fromTime_t(uint seconds, const QTimeZone &timeZone)
@@ -4269,6 +4466,7 @@ QDateTime QDateTime::fromTime_t(uint seconds, const QTimeZone &timeZone)
return fromMSecsSinceEpoch((qint64)seconds * 1000, timeZone);
}
#endif
+#endif // QT_DEPRECATED_SINCE(5, 8)
/*!
\since 4.7
@@ -4282,7 +4480,7 @@ QDateTime QDateTime::fromTime_t(uint seconds, const QTimeZone &timeZone)
range of QDateTime, both negative and positive. The behavior of this
function is undefined for those values.
- \sa toTime_t(), setTime_t()
+ \sa toMSecsSinceEpoch(), setMSecsSinceEpoch()
*/
QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs)
{
@@ -4307,16 +4505,41 @@ QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs)
If \a spec is Qt::TimeZone then the spec will be set to Qt::LocalTime,
i.e. the current system time zone.
- \sa fromTime_t()
+ \sa toMSecsSinceEpoch(), setMSecsSinceEpoch()
*/
QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetSeconds)
{
QDateTime dt;
- dt.d->setTimeSpec(spec, offsetSeconds);
+ QT_PREPEND_NAMESPACE(setTimeSpec(dt.d, spec, offsetSeconds));
dt.setMSecsSinceEpoch(msecs);
return dt;
}
+/*!
+ \since 5.8
+
+ Returns a datetime whose date and time are the number of seconds \a secs
+ that have passed since 1970-01-01T00:00:00.000, Coordinated Universal
+ Time (Qt::UTC) and converted to the given \a spec.
+
+ Note that there are possible values for \a secs that lie outside the valid
+ range of QDateTime, both negative and positive. The behavior of this
+ function is undefined for those values.
+
+ If the \a spec is not Qt::OffsetFromUTC then the \a offsetSeconds will be
+ ignored. If the \a spec is Qt::OffsetFromUTC and the \a offsetSeconds is 0
+ then the spec will be set to Qt::UTC, i.e. an offset of 0 seconds.
+
+ If \a spec is Qt::TimeZone then the spec will be set to Qt::LocalTime,
+ i.e. the current system time zone.
+
+ \sa toSecsSinceEpoch(), setSecsSinceEpoch()
+*/
+QDateTime QDateTime::fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spec, int offsetSeconds)
+{
+ return fromMSecsSinceEpoch(secs * 1000, spec, offsetSeconds);
+}
+
#ifndef QT_BOOTSTRAPPED
/*!
\since 5.2
@@ -4325,7 +4548,7 @@ QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int of
that have passed since 1970-01-01T00:00:00.000, Coordinated Universal
Time (Qt::UTC) and with the given \a timeZone.
- \sa fromTime_t()
+ \sa fromSecsSinceEpoch()
*/
QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone)
{
@@ -4334,6 +4557,20 @@ QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone
dt.setMSecsSinceEpoch(msecs);
return dt;
}
+
+/*!
+ \since 5.8
+
+ Returns a datetime whose date and time are the number of seconds \a secs
+ that have passed since 1970-01-01T00:00:00.000, Coordinated Universal
+ Time (Qt::UTC) and with the given \a timeZone.
+
+ \sa fromMSecsSinceEpoch()
+*/
+QDateTime QDateTime::fromSecsSinceEpoch(qint64 secs, const QTimeZone &timeZone)
+{
+ return fromMSecsSinceEpoch(secs * 1000, timeZone);
+}
#endif
#if QT_DEPRECATED_SINCE(5, 2)
@@ -4831,7 +5068,7 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
if (out.version() >= QDataStream::Qt_5_2) {
// In 5.2 we switched to using Qt::TimeSpec and added offset support
- dateAndTime = dateTime.d->getDateTime();
+ dateAndTime = getDateTime(dateTime.d);
out << dateAndTime << qint8(dateTime.timeSpec());
if (dateTime.timeSpec() == Qt::OffsetFromUTC)
out << qint32(dateTime.offsetFromUtc());
@@ -4846,13 +5083,13 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
// This approach is wrong and should not be used again; it breaks
// the guarantee that a deserialised local datetime is the same time
// of day, regardless of which timezone it was serialised in.
- dateAndTime = (dateTime.isValid() ? dateTime.toUTC() : dateTime).d->getDateTime();
+ dateAndTime = getDateTime((dateTime.isValid() ? dateTime.toUTC() : dateTime).d);
out << dateAndTime << qint8(dateTime.timeSpec());
} else if (out.version() >= QDataStream::Qt_4_0) {
// From 4.0 to 5.1 (except 5.0) we used QDateTimePrivate::Spec
- dateAndTime = dateTime.d->getDateTime();
+ dateAndTime = getDateTime(dateTime.d);
out << dateAndTime;
switch (dateTime.timeSpec()) {
case Qt::UTC:
@@ -4872,7 +5109,7 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
} else { // version < QDataStream::Qt_4_0
// Before 4.0 there was no TimeSpec, only Qt::LocalTime was supported
- dateAndTime = dateTime.d->getDateTime();
+ dateAndTime = getDateTime(dateTime.d);
out << dateAndTime;
}
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index f292a97db1..ebf9b45570 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -46,11 +47,9 @@
#include <limits>
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFDate);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSDate);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -148,15 +147,9 @@ Q_DECLARE_TYPEINFO(QDate, Q_MOVABLE_TYPE);
class Q_CORE_EXPORT QTime
{
explicit Q_DECL_CONSTEXPR QTime(int ms) : mds(ms)
-#if defined(Q_OS_WINCE)
- , startTick(NullTime)
-#endif
{}
public:
Q_DECL_CONSTEXPR QTime(): mds(NullTime)
-#if defined(Q_OS_WINCE)
- , startTick(NullTime)
-#endif
{}
QTime(int h, int m, int s = 0, int ms = 0);
@@ -202,9 +195,6 @@ private:
enum TimeFlag { NullTime = -1 };
Q_DECL_CONSTEXPR inline int ds() const { return mds == -1 ? 0 : mds; }
int mds;
-#if defined(Q_OS_WINCE)
- int startTick;
-#endif
friend class QDateTime;
friend class QDateTimePrivate;
@@ -219,8 +209,46 @@ class QDateTimePrivate;
class Q_CORE_EXPORT QDateTime
{
+ // ### Qt 6: revisit the optimization
+ struct ShortData {
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ quintptr status : 8;
+#endif
+ // note: this is only 24 bits on 32-bit systems...
+ qintptr msecs : sizeof(void *) * 8 - 8;
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ quintptr status : 8;
+#endif
+ };
+
+ union Data {
+ enum {
+ // To be of any use, we need at least 60 years around 1970, which
+ // is 1,893,456,000,000 ms. That requires 41 bits to store, plus
+ // the sign bit. With the status byte, the minimum size is 50 bits.
+ CanBeSmall = sizeof(ShortData) * 8 > 50
+ };
+
+ Data();
+ Data(Qt::TimeSpec);
+ Data(const Data &other);
+ Data(Data &&other);
+ Data &operator=(const Data &other);
+ ~Data();
+
+ bool isShort() const;
+ void detach();
+
+ const QDateTimePrivate *operator->() const;
+ QDateTimePrivate *operator->();
+
+ QDateTimePrivate *d;
+ ShortData data;
+ };
+
public:
- QDateTime();
+ QDateTime() Q_DECL_NOEXCEPT_EXPR(Data::CanBeSmall);
explicit QDateTime(const QDate &);
QDateTime(const QDate &, const QTime &, Qt::TimeSpec spec = Qt::LocalTime);
// ### Qt 6: Merge with above with default offsetSeconds = 0
@@ -228,15 +256,16 @@ public:
#ifndef QT_BOOTSTRAPPED
QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone);
#endif // QT_BOOTSTRAPPED
- QDateTime(const QDateTime &other);
+ QDateTime(const QDateTime &other) Q_DECL_NOTHROW;
+ QDateTime(QDateTime &&other) Q_DECL_NOTHROW;
~QDateTime();
#ifdef Q_COMPILER_RVALUE_REFS
QDateTime &operator=(QDateTime &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- QDateTime &operator=(const QDateTime &other);
+ QDateTime &operator=(const QDateTime &other) Q_DECL_NOTHROW;
- void swap(QDateTime &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
+ void swap(QDateTime &other) Q_DECL_NOTHROW { qSwap(d.d, other.d.d); }
bool isNull() const;
bool isValid() const;
@@ -252,8 +281,7 @@ public:
bool isDaylightTime() const;
qint64 toMSecsSinceEpoch() const;
- // ### Qt 6: use quint64 instead of uint
- uint toTime_t() const;
+ qint64 toSecsSinceEpoch() const;
void setDate(const QDate &date);
void setTime(const QTime &time);
@@ -263,8 +291,7 @@ public:
void setTimeZone(const QTimeZone &toZone);
#endif // QT_BOOTSTRAPPED
void setMSecsSinceEpoch(qint64 msecs);
- // ### Qt 6: use quint64 instead of uint
- void setTime_t(uint secsSince1Jan1970UTC);
+ void setSecsSinceEpoch(qint64 secs);
#ifndef QT_NO_DATESTRING
QString toString(Qt::DateFormat f = Qt::TextDate) const;
@@ -306,38 +333,40 @@ public:
static QDateTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate);
static QDateTime fromString(const QString &s, const QString &format);
#endif
- // ### Qt 6: use quint64 instead of uint
+
+#if QT_DEPRECATED_SINCE(5, 8)
+ uint toTime_t() const;
+ void setTime_t(uint secsSince1Jan1970UTC);
static QDateTime fromTime_t(uint secsSince1Jan1970UTC);
- // ### Qt 6: Merge with above with default spec = Qt::LocalTime
static QDateTime fromTime_t(uint secsSince1Jan1970UTC, Qt::TimeSpec spec,
int offsetFromUtc = 0);
-#ifndef QT_BOOTSTRAPPED
static QDateTime fromTime_t(uint secsSince1Jan1970UTC, const QTimeZone &timeZone);
#endif
+
static QDateTime fromMSecsSinceEpoch(qint64 msecs);
// ### Qt 6: Merge with above with default spec = Qt::LocalTime
static QDateTime fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetFromUtc = 0);
+ static QDateTime fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spe = Qt::LocalTime, int offsetFromUtc = 0);
+
#ifndef QT_BOOTSTRAPPED
static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone);
+ static QDateTime fromSecsSinceEpoch(qint64 secs, const QTimeZone &timeZone);
#endif
+
static qint64 currentMSecsSinceEpoch() Q_DECL_NOTHROW;
+ static qint64 currentSecsSinceEpoch() Q_DECL_NOTHROW;
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QDateTime fromCFDate(CFDateRef date);
CFDateRef toCFDate() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QDateTime fromNSDate(const NSDate *date);
NSDate *toNSDate() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
private:
friend class QDateTimePrivate;
- // ### Qt6: Using a private here has high impact on runtime
- // on users such as QFileInfo. In Qt 6, the data members
- // should be inlined.
- QSharedDataPointer<QDateTimePrivate> d;
+ Data d;
#ifndef QT_NO_DATASTREAM
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);
diff --git a/src/corelib/tools/qdatetime_mac.mm b/src/corelib/tools/qdatetime_mac.mm
deleted file mode 100644
index d61ea28636..0000000000
--- a/src/corelib/tools/qdatetime_mac.mm
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2014 Petroules Corporation.
-** 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 "qdatetime.h"
-
-#import <Foundation/Foundation.h>
-
-QT_BEGIN_NAMESPACE
-
-QDateTime QDateTime::fromCFDate(CFDateRef date)
-{
- if (!date)
- return QDateTime();
- return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>((CFDateGetAbsoluteTime(date)
- + kCFAbsoluteTimeIntervalSince1970) * 1000));
-}
-
-CFDateRef QDateTime::toCFDate() const
-{
- return CFDateCreate(kCFAllocatorDefault, (static_cast<CFAbsoluteTime>(toMSecsSinceEpoch())
- / 1000) - kCFAbsoluteTimeIntervalSince1970);
-}
-
-QDateTime QDateTime::fromNSDate(const NSDate *date)
-{
- if (!date)
- return QDateTime();
- return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>([date timeIntervalSince1970] * 1000));
-}
-
-NSDate *QDateTime::toNSDate() const
-{
- return [NSDate
- dateWithTimeIntervalSince1970:static_cast<NSTimeInterval>(toMSecsSinceEpoch()) / 1000];
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h
index 104cbccbd4..38a084b257 100644
--- a/src/corelib/tools/qdatetime_p.h
+++ b/src/corelib/tools/qdatetime_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -51,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qplatformdefs.h"
#include "QtCore/qatomic.h"
#include "QtCore/qdatetime.h"
@@ -60,9 +62,13 @@
QT_BEGIN_NAMESPACE
-class QDateTimePrivate : public QSharedData
+class QDateTimePrivate
{
public:
+ // forward the declarations from QDateTime (this makes them public)
+ typedef QDateTime::ShortData QDateTimeShortData;
+ typedef QDateTime::Data QDateTimeData;
+
// Never change or delete this enum, it is required for backwards compatible
// serialization of QDateTime before 5.2, so is essentially public API
enum Spec {
@@ -76,7 +82,6 @@ public:
// Daylight Time Status
enum DaylightStatus {
- NoDaylightTime = -2,
UnknownDaylightTime = -1,
StandardTime = 0,
DaylightTime = 1
@@ -84,62 +89,46 @@ public:
// Status of date/time
enum StatusFlag {
- NullDate = 0x01,
- NullTime = 0x02,
- ValidDate = 0x04, // just the date field
- ValidTime = 0x08, // just the time field
- ValidDateTime = 0x10, // the whole object (including timezone)
+ ShortData = 0x01,
+
+ ValidDate = 0x02,
+ ValidTime = 0x04,
+ ValidDateTime = 0x08,
+
+ TimeSpecMask = 0x30,
+
SetToStandardTime = 0x40,
SetToDaylightTime = 0x80
};
Q_DECLARE_FLAGS(StatusFlags, StatusFlag)
+ enum {
+ TimeSpecShift = 4,
+ ValidityMask = ValidDate | ValidTime | ValidDateTime,
+ DaylightMask = SetToStandardTime | SetToDaylightTime
+ };
+
QDateTimePrivate() : m_msecs(0),
- m_spec(Qt::LocalTime),
+ m_status(StatusFlag(Qt::LocalTime << TimeSpecShift)),
m_offsetFromUtc(0),
- m_status(NullDate | NullTime)
- {}
+ ref(0)
+ {
+ }
- QDateTimePrivate(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
- int offsetSeconds);
+ static QDateTime::Data create(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
+ int offsetSeconds);
#ifndef QT_BOOTSTRAPPED
- QDateTimePrivate(const QDate &toDate, const QTime &toTime, const QTimeZone & timeZone);
+ static QDateTime::Data create(const QDate &toDate, const QTime &toTime, const QTimeZone & timeZone);
#endif // QT_BOOTSTRAPPED
- // ### XXX: when the tooling situation improves, look at fixing the padding.
- // 4 bytes padding
-
qint64 m_msecs;
- Qt::TimeSpec m_spec;
+ StatusFlags m_status;
int m_offsetFromUtc;
+ mutable QAtomicInt ref;
#ifndef QT_BOOTSTRAPPED
QTimeZone m_timeZone;
#endif // QT_BOOTSTRAPPED
- StatusFlags m_status;
-
- void setTimeSpec(Qt::TimeSpec spec, int offsetSeconds);
- void setDateTime(const QDate &date, const QTime &time);
- QPair<QDate, QTime> getDateTime() const;
-
- void setDaylightStatus(DaylightStatus status);
- DaylightStatus daylightStatus() const;
-
- // Returns msecs since epoch, assumes offset value is current
- inline qint64 toMSecsSinceEpoch() const;
-
- void checkValidDateTime();
- void refreshDateTime();
-
- // Get/set date and time status
- inline bool isNullDate() const { return m_status & NullDate; }
- inline bool isNullTime() const { return m_status & NullTime; }
- inline bool isValidDate() const { return m_status & ValidDate; }
- inline bool isValidTime() const { return m_status & ValidTime; }
- inline bool isValidDateTime() const { return m_status & ValidDateTime; }
- inline void setValidDateTime() { m_status |= ValidDateTime; }
- inline void clearValidDateTime() { m_status &= ~ValidDateTime; }
- inline void clearSetToDaylightStatus() { m_status &= ~(SetToStandardTime | SetToDaylightTime); }
#ifndef QT_BOOTSTRAPPED
static qint64 zoneMSecsToEpochMSecs(qint64 msecs, const QTimeZone &zone,
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp
index 36ab93df1e..3271e2a8c4 100644
--- a/src/corelib/tools/qdatetimeparser.cpp
+++ b/src/corelib/tools/qdatetimeparser.cpp
@@ -602,7 +602,7 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const
return 2;
#else
mcount = 7;
- // fall through
+ Q_FALLTHROUGH();
#endif
case MonthSection:
#ifdef QT_NO_TEXTDATE
@@ -770,7 +770,8 @@ int QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionInde
state = Intermediate;
}
break;
- } // else: fall through
+ }
+ Q_FALLTHROUGH();
case DaySection:
case YearSection:
case YearSection2Digits:
@@ -1155,7 +1156,7 @@ end:
done = true;
break;
}
- // fallthrough
+ Q_FALLTHROUGH();
default: {
int toMin;
int toMax;
@@ -1489,7 +1490,7 @@ QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const
switch (sn.type) {
case MSecSection:
ret |= Fraction;
- // fallthrough
+ Q_FALLTHROUGH();
case SecondSection:
case MinuteSection:
case Hour24Section:
@@ -1509,7 +1510,7 @@ QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const
switch (sn.count) {
case 2:
ret |= FixedWidth;
- // fallthrough
+ Q_FALLTHROUGH();
case 1:
ret |= (Numeric|AllowPartial);
break;
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h
index 01a2f20802..6f381965a9 100644
--- a/src/corelib/tools/qdatetimeparser_p.h
+++ b/src/corelib/tools/qdatetimeparser_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qplatformdefs.h"
#include "QtCore/qatomic.h"
#include "QtCore/qdatetime.h"
diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h
index ebe34bc135..c3efc41d62 100644
--- a/src/corelib/tools/qfreelist_p.h
+++ b/src/corelib/tools/qfreelist_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qatomic.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qharfbuzz_p.h b/src/corelib/tools/qharfbuzz_p.h
index cc4d9bbd85..2a0307d35f 100644
--- a/src/corelib/tools/qharfbuzz_p.h
+++ b/src/corelib/tools/qharfbuzz_p.h
@@ -48,6 +48,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
#ifndef QHARFBUZZ_P_H
#define QHARFBUZZ_P_H
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 593a87e65d..abec9ebb79 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -2644,4 +2644,24 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa QHash::constFind()
*/
+/*!
+ \fn uint qHash(const QHash<Key, T> &key, uint seed = 0)
+ \since 5.8
+ \relates QHash
+
+ Returns the hash value for the \a key, using \a seed to seed the calculation.
+
+ Type \c T must be supported by qHash().
+*/
+
+/*!
+ \fn uint qHash(const QMultiHash<Key, T> &key, uint seed = 0)
+ \since 5.8
+ \relates QMultiHash
+
+ Returns the hash value for the \a key, using \a seed to seed the calculation.
+
+ Type \c T must be supported by qHash().
+*/
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 7abbeabeae..6a2d7bdd11 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -1095,6 +1095,27 @@ Q_INLINE_TEMPLATE int QMultiHash<Key, T>::count(const Key &key, const T &value)
Q_DECLARE_ASSOCIATIVE_ITERATOR(Hash)
Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR(Hash)
+template <class Key, class T>
+uint qHash(const QHash<Key, T> &key, uint seed = 0)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(std::declval<Key&>())) && noexcept(qHash(std::declval<T&>())))
+{
+ QtPrivate::QHashCombineCommutative hash;
+ for (auto it = key.begin(), end = key.end(); it != end; ++it) {
+ const Key &k = it.key();
+ const T &v = it.value();
+ seed = hash(seed, std::pair<const Key&, const T&>(k, v));
+ }
+ return seed;
+}
+
+template <class Key, class T>
+inline uint qHash(const QMultiHash<Key, T> &key, uint seed = 0)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(std::declval<Key&>())) && noexcept(qHash(std::declval<T&>())))
+{
+ const QHash<Key, T> &key2 = key;
+ return qHash(key2, seed);
+}
+
QT_END_NAMESPACE
#if defined(Q_CC_MSVC)
diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp
index b004f74be9..8942292a3d 100644
--- a/src/corelib/tools/qline.cpp
+++ b/src/corelib/tools/qline.cpp
@@ -214,6 +214,14 @@ QT_BEGIN_NAMESPACE
Returns this line translated the distance specified by \a dx and \a dy.
*/
+/*!
+ \fn QPoint QLine::center() const
+
+ \since 5.8
+
+ Returns the center point of this line. This is equivalent to
+ (p1() + p2()) / 2, except it will never overflow.
+*/
/*!
\fn void QLine::setP1(const QPoint &p1)
@@ -351,6 +359,12 @@ QDataStream &operator>>(QDataStream &stream, QLine &line)
translate() function, and can be traversed using the pointAt()
function.
+ \section1 Constraints
+
+ QLine is limited to the minimum and maximum values for the
+ \c int type. Operations on a QLine that could potentially result
+ in values outside this range will result in undefined behavior.
+
\sa QLine, QPolygonF, QRectF
*/
@@ -711,6 +725,15 @@ QLineF::IntersectType QLineF::intersect(const QLineF &l, QPointF *intersectionPo
*/
/*!
+ \fn QPointF QLineF::center() const
+
+ \since 5.8
+
+ Returns the center point of this line. This is equivalent to
+ 0.5 * p1() + 0.5 * p2().
+*/
+
+/*!
\fn void QLineF::setP1(const QPointF &p1)
\since 4.4
diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h
index 819dd3fd3b..5b5ca3b4c8 100644
--- a/src/corelib/tools/qline.h
+++ b/src/corelib/tools/qline.h
@@ -76,6 +76,8 @@ public:
Q_DECL_CONSTEXPR inline QLine translated(const QPoint &p) const Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR inline QLine translated(int dx, int dy) const Q_REQUIRED_RESULT;
+ Q_DECL_CONSTEXPR inline QPoint center() const Q_REQUIRED_RESULT;
+
inline void setP1(const QPoint &p1);
inline void setP2(const QPoint &p2);
inline void setPoints(const QPoint &p1, const QPoint &p2);
@@ -165,6 +167,11 @@ Q_DECL_CONSTEXPR inline QLine QLine::translated(int adx, int ady) const
return translated(QPoint(adx, ady));
}
+Q_DECL_CONSTEXPR inline QPoint QLine::center() const
+{
+ return QPoint(int((qint64(pt1.x()) + pt2.x()) / 2), int((qint64(pt1.y()) + pt2.y()) / 2));
+}
+
inline void QLine::setP1(const QPoint &aP1)
{
pt1 = aP1;
@@ -253,6 +260,8 @@ public:
Q_DECL_CONSTEXPR inline QLineF translated(const QPointF &p) const Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR inline QLineF translated(qreal dx, qreal dy) const Q_REQUIRED_RESULT;
+ Q_DECL_CONSTEXPR inline QPointF center() const Q_REQUIRED_RESULT;
+
inline void setP1(const QPointF &p1);
inline void setP2(const QPointF &p2);
inline void setPoints(const QPointF &p1, const QPointF &p2);
@@ -357,6 +366,11 @@ Q_DECL_CONSTEXPR inline QLineF QLineF::translated(qreal adx, qreal ady) const
return translated(QPointF(adx, ady));
}
+Q_DECL_CONSTEXPR inline QPointF QLineF::center() const
+{
+ return QPointF(0.5 * pt1.x() + 0.5 * pt2.x(), 0.5 * pt1.y() + 0.5 * pt2.y());
+}
+
inline void QLineF::setLength(qreal len)
{
if (isNull())
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index 838965c4e7..249f76dafd 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -136,8 +136,12 @@ public:
Node *i;
inline iterator() : i(Q_NULLPTR) {}
inline iterator(Node *n) : i(n) {}
- inline iterator(const iterator &o) : i(o.i) {}
- inline iterator &operator=(const iterator &o) { i = o.i; return *this; }
+#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
+ iterator(const iterator &other) Q_DECL_NOTHROW : i(other.i) {}
+ iterator &operator=(const iterator &other) Q_DECL_NOTHROW { i = other.i; return *this; }
+ iterator(iterator &&other) Q_DECL_NOTHROW : i(other.i) {}
+ iterator &operator=(iterator &&other) Q_DECL_NOTHROW { return *this = other; }
+#endif
inline T &operator*() const { return i->t; }
inline T *operator->() const { return &i->t; }
inline bool operator==(const iterator &o) const { return i == o.i; }
@@ -169,9 +173,13 @@ public:
Node *i;
inline const_iterator() : i(Q_NULLPTR) {}
inline const_iterator(Node *n) : i(n) {}
- inline const_iterator(const const_iterator &o) : i(o.i){}
inline const_iterator(iterator ci) : i(ci.i){}
- inline const_iterator &operator=(const const_iterator &o) { i = o.i; return *this; }
+#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
+ const_iterator(const const_iterator &other) Q_DECL_NOTHROW : i(other.i) {}
+ const_iterator &operator=(const const_iterator &other) Q_DECL_NOTHROW { i = other.i; return *this; }
+ const_iterator(const_iterator &&other) Q_DECL_NOTHROW : i(other.i) {}
+ const_iterator &operator=(const_iterator &&other) Q_DECL_NOTHROW { return *this = other; }
+#endif
inline const T &operator*() const { return i->t; }
inline const T *operator->() const { return &i->t; }
inline bool operator==(const const_iterator &o) const { return i == o.i; }
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 90ed5072e7..c7f27abdd6 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -118,7 +118,10 @@ struct Q_CORE_EXPORT QListData {
};
template <typename T>
-class QList : public QListSpecialMethods<T>
+class QList
+#ifndef Q_QDOC
+ : public QListSpecialMethods<T>
+#endif
{
public:
struct MemoryLayout
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index ea5d74d9bb..7809c513d6 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -61,7 +61,6 @@
#include "qvariant.h"
#include "qstringbuilder.h"
#include "private/qnumeric_p.h"
-#include "private/qsystemlibrary_p.h"
#ifdef Q_OS_WIN
# include <qt_windows.h>
# include <time.h>
diff --git a/src/corelib/tools/qlocale_data_p.h b/src/corelib/tools/qlocale_data_p.h
index 262cecb564..869153942e 100644
--- a/src/corelib/tools/qlocale_data_p.h
+++ b/src/corelib/tools/qlocale_data_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
QT_BEGIN_NAMESPACE
/* This part of the file isn't generated, but written by hand since
diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm
index 4b1d190705..4f6efc8832 100644
--- a/src/corelib/tools/qlocale_mac.mm
+++ b/src/corelib/tools/qlocale_mac.mm
@@ -390,9 +390,6 @@ static QString macFormatCurrency(const QSystemLocale::CurrencyToStringArgument &
static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef &str)
{
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_6)
- return QVariant();
-
QString begin, end;
QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
switch (type) {
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index f95edf4d14..c83c9d3333 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qstring.h"
#include "QtCore/qvarlengtharray.h"
#include "QtCore/qvariant.h"
diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp
index 9d2db61a11..b5f97b5fe8 100644
--- a/src/corelib/tools/qlocale_win.cpp
+++ b/src/corelib/tools/qlocale_win.cpp
@@ -44,9 +44,6 @@
#include "qstringlist.h"
#include "qvariant.h"
#include "qdatetime.h"
-
-#include "private/qsystemlibrary_p.h"
-
#include "qdebug.h"
#ifdef Q_OS_WIN
@@ -60,20 +57,20 @@
#include <wrl.h>
#include <windows.foundation.h>
#include <windows.foundation.collections.h>
-#include <windows.globalization.h>
+#include <windows.system.userprofile.h>
#endif // Q_OS_WINRT
QT_BEGIN_NAMESPACE
#ifndef Q_OS_WINRT
static QByteArray getWinLocaleName(LCID id = LOCALE_USER_DEFAULT);
-static const char *winLangCodeToIsoName(int code);
static QString winIso639LangName(LCID id = LOCALE_USER_DEFAULT);
static QString winIso3116CtryName(LCID id = LOCALE_USER_DEFAULT);
#else // !Q_OS_WINRT
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Foundation;
+using namespace ABI::Windows::System::UserProfile;
static QByteArray getWinLocaleName(LPWSTR id = LOCALE_NAME_USER_DEFAULT);
static const char *winLangCodeToIsoName(int code);
@@ -600,62 +597,45 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS
QVariant QSystemLocalePrivate::uiLanguages()
{
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) {
- typedef BOOL (WINAPI *GetUserPreferredUILanguagesFunc) (
- DWORD dwFlags,
- PULONG pulNumLanguages,
- PWSTR pwszLanguagesBuffer,
- PULONG pcchLanguagesBuffer);
- static GetUserPreferredUILanguagesFunc GetUserPreferredUILanguages_ptr = 0;
#ifndef Q_OS_WINRT
- if (!GetUserPreferredUILanguages_ptr) {
- QSystemLibrary lib(QLatin1String("kernel32"));
- if (lib.load())
- GetUserPreferredUILanguages_ptr = (GetUserPreferredUILanguagesFunc)lib.resolve("GetUserPreferredUILanguages");
- }
-#endif // !Q_OS_WINRT
- if (GetUserPreferredUILanguages_ptr) {
- unsigned long cnt = 0;
- QVarLengthArray<wchar_t, 64> buf(64);
- unsigned long size = buf.size();
- if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
- size = 0;
- if (GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
- GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, NULL, &size)) {
- buf.resize(size);
- if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size))
- return QStringList();
- }
- }
- QStringList result;
- result.reserve(cnt);
- const wchar_t *str = buf.constData();
- for (; cnt > 0; --cnt) {
- QString s = QString::fromWCharArray(str);
- if (s.isEmpty())
- break; // something is wrong
- result.append(s);
- str += s.size()+1;
- }
- return result;
+ unsigned long cnt = 0;
+ QVarLengthArray<wchar_t, 64> buf(64);
+# if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE) // Not present in MinGW 4.9/bootstrap builds.
+ unsigned long size = buf.size();
+ if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
+ size = 0;
+ if (GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
+ GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, NULL, &size)) {
+ buf.resize(size);
+ if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size))
+ return QStringList();
}
}
-
-#ifndef Q_OS_WINRT
- // old Windows before Vista
- return QStringList(QString::fromLatin1(winLangCodeToIsoName(GetUserDefaultUILanguage())));
+# endif // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
+ QStringList result;
+ result.reserve(cnt);
+ const wchar_t *str = buf.constData();
+ for (; cnt > 0; --cnt) {
+ QString s = QString::fromWCharArray(str);
+ if (s.isEmpty())
+ break; // something is wrong
+ result.append(s);
+ str += s.size() + 1;
+ }
+ return result;
#else // !Q_OS_WINRT
QStringList result;
- ComPtr<ABI::Windows::Globalization::IApplicationLanguagesStatics> appLanguagesStatics;
- if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Globalization_ApplicationLanguages).Get(), &appLanguagesStatics))) {
+
+ ComPtr<IGlobalizationPreferencesStatics> preferences;
+ HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_UserProfile_GlobalizationPreferences).Get(), &preferences);
+ if (FAILED(hr)) {
qWarning("Could not obtain ApplicationLanguagesStatic");
return QStringList();
}
ComPtr<ABI::Windows::Foundation::Collections::IVectorView<HSTRING> > languageList;
- // Languages is a ranked list of "long names" (e.g. en-US) of preferred languages, which matches
- // languages from the manifest with languages from the user's system.
- HRESULT hr = appLanguagesStatics->get_Languages(&languageList);
+ // Languages is a ranked list of "long names" (e.g. en-US) of preferred languages
+ hr = preferences->get_Languages(&languageList);
Q_ASSERT_SUCCEEDED(hr);
unsigned int size;
hr = languageList->get_Size(&size);
@@ -670,36 +650,6 @@ QVariant QSystemLocalePrivate::uiLanguages()
result << QString::fromWCharArray(rawString, length);
}
- // ManifestLanguages covers all languages given in the manifest and uses short names (like "en").
- hr = appLanguagesStatics->get_ManifestLanguages(&languageList);
- Q_ASSERT_SUCCEEDED(hr);
- hr = languageList->get_Size(&size);
- Q_ASSERT_SUCCEEDED(hr);
- for (unsigned int i = 0; i < size; ++i) {
- HString language;
- hr = languageList->GetAt(i, language.GetAddressOf());
- Q_ASSERT_SUCCEEDED(hr);
- UINT32 length;
- PCWSTR rawString = language.GetRawBuffer(&length);
- const QString qLanguage = QString::fromWCharArray(rawString, length);
- bool found = false;
- // Since ApplicationLanguages:::Languages uses long names, we compare the "pre-dash" part of
- // the language and filter it out, if it is already covered by a more specialized form.
- for (const QString &lang : qAsConst(result)) {
- int dashIndex = lang.indexOf('-');
- // There will not be any long name after the first short name was found, so we can stop.
- if (dashIndex == -1)
- break;
-
- if (lang.leftRef(dashIndex) == qLanguage) {
- found = true;
- break;
- }
- }
- if (!found)
- result << qLanguage;
- }
-
return result;
#endif // Q_OS_WINRT
}
@@ -1160,19 +1110,16 @@ static QByteArray getWinLocaleName(LPWSTR id)
}
}
-#if defined(Q_OS_WINCE)
- result = winLangCodeToIsoName(id != LOCALE_USER_DEFAULT ? id : GetUserDefaultLCID());
-#else // !Q_OS_WINCE
-# ifndef Q_OS_WINRT
+#ifndef Q_OS_WINRT
if (id == LOCALE_USER_DEFAULT)
id = GetUserDefaultLCID();
-# else // !Q_OS_WINRT
+#else // !Q_OS_WINRT
WCHAR lcName[LOCALE_NAME_MAX_LENGTH];
if (QString::fromWCharArray(id) == QString::fromWCharArray(LOCALE_NAME_USER_DEFAULT)) {
GetUserDefaultLocaleName(lcName, LOCALE_NAME_MAX_LENGTH);
id = lcName;
}
-# endif // Q_OS_WINRT
+#endif // Q_OS_WINRT
QString resultuage = winIso639LangName(id);
QString country = winIso3116CtryName(id);
result = resultuage.toLatin1();
@@ -1180,7 +1127,6 @@ static QByteArray getWinLocaleName(LPWSTR id)
result += '_';
result += country.toLatin1();
}
-#endif // !Q_OS_WINCE
return result;
}
diff --git a/src/corelib/tools/qpodlist_p.h b/src/corelib/tools/qpodlist_p.h
index 810df02000..95990e0bb6 100644
--- a/src/corelib/tools/qpodlist_p.h
+++ b/src/corelib/tools/qpodlist_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qvarlengtharray.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index 4e2e6b91a6..7b1004897a 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -42,6 +42,10 @@
#include <QtCore/qnamespace.h>
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+struct CGPoint;
+#endif
+
QT_BEGIN_NAMESPACE
@@ -89,6 +93,10 @@ public:
friend Q_DECL_CONSTEXPR inline const QPoint operator-(const QPoint &);
friend Q_DECL_CONSTEXPR inline const QPoint operator/(const QPoint &, qreal);
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ CGPoint toCGPoint() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
friend class QTransform;
int xp;
@@ -247,6 +255,11 @@ public:
Q_DECL_CONSTEXPR QPoint toPoint() const;
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ static QPointF fromCGPoint(CGPoint point) Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ CGPoint toCGPoint() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
friend class QMatrix;
friend class QTransform;
diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h
index b376b6b999..f973cf3494 100644
--- a/src/corelib/tools/qrect.h
+++ b/src/corelib/tools/qrect.h
@@ -48,6 +48,10 @@
#error qrect.h must be included before any header file that defines topLeft
#endif
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+struct CGRect;
+#endif
+
QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QRect
@@ -149,6 +153,10 @@ public:
friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) Q_DECL_NOTHROW;
friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) Q_DECL_NOTHROW;
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
int x1;
int y1;
@@ -604,6 +612,11 @@ public:
Q_DECL_CONSTEXPR inline QRect toRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
QRect toAlignedRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ static QRectF fromCGRect(CGRect rect) Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
qreal xp;
qreal yp;
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index f8f3347786..96ddca56af 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -3011,7 +3011,7 @@ int QRegExpEngine::getEscape()
case 'I':
if (xmlSchemaExtensions) {
yyCharClass->setNegative(!yyCharClass->negative());
- // fall through
+ Q_FALLTHROUGH();
} else {
break;
}
@@ -3051,7 +3051,7 @@ int QRegExpEngine::getEscape()
case 'C':
if (xmlSchemaExtensions) {
yyCharClass->setNegative(!yyCharClass->negative());
- // fall through
+ Q_FALLTHROUGH();
} else {
break;
}
@@ -3097,7 +3097,7 @@ int QRegExpEngine::getEscape()
case 'P':
if (xmlSchemaExtensions) {
yyCharClass->setNegative(!yyCharClass->negative());
- // fall through
+ Q_FALLTHROUGH();
} else {
break;
}
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
index 4a2dfdec2b..cb11e72435 100644
--- a/src/corelib/tools/qringbuffer.cpp
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -108,24 +108,25 @@ char *QRingBuffer::reserve(qint64 bytes)
if (bytes <= 0 || bytes >= MaxByteArraySize)
return 0;
- if (buffers.isEmpty()) {
- buffers.append(QByteArray());
- buffers.first().resize(qMax(basicBlockSize, int(bytes)));
+ if (bufferSize == 0) {
+ if (buffers.isEmpty())
+ buffers.append(QByteArray(qMax(basicBlockSize, int(bytes)), Qt::Uninitialized));
+ else
+ buffers.first().resize(qMax(basicBlockSize, int(bytes)));
} else {
const qint64 newSize = bytes + tail;
- // if need buffer reallocation
- if (newSize > buffers.constLast().size()) {
- if (newSize > buffers.constLast().capacity() && (tail >= basicBlockSize
- || newSize >= MaxByteArraySize)) {
- // shrink this buffer to its current size
- buffers.last().resize(tail);
-
- // create a new QByteArray
- buffers.append(QByteArray());
- ++tailBuffer;
- tail = 0;
- }
- buffers.last().resize(qMax(basicBlockSize, tail + int(bytes)));
+ // if need a new buffer
+ if (basicBlockSize == 0 || (newSize > buffers.constLast().capacity()
+ && (tail >= basicBlockSize || newSize >= MaxByteArraySize))) {
+ // shrink this buffer to its current size
+ buffers.last().resize(tail);
+
+ // create a new QByteArray
+ buffers.append(QByteArray(qMax(basicBlockSize, int(bytes)), Qt::Uninitialized));
+ ++tailBuffer;
+ tail = 0;
+ } else if (newSize > buffers.constLast().size()) {
+ buffers.last().resize(qMax(basicBlockSize, int(newSize)));
}
}
@@ -146,10 +147,8 @@ char *QRingBuffer::reserveFront(qint64 bytes)
if (bytes <= 0 || bytes >= MaxByteArraySize)
return 0;
- if (head < bytes) {
- if (buffers.isEmpty()) {
- buffers.append(QByteArray());
- } else {
+ if (head < bytes || basicBlockSize == 0) {
+ if (head > 0) {
buffers.first().remove(0, head);
if (tailBuffer == 0)
tail -= head;
@@ -157,12 +156,15 @@ char *QRingBuffer::reserveFront(qint64 bytes)
head = qMax(basicBlockSize, int(bytes));
if (bufferSize == 0) {
+ if (buffers.isEmpty())
+ buffers.prepend(QByteArray(head, Qt::Uninitialized));
+ else
+ buffers.first().resize(head);
tail = head;
} else {
- buffers.prepend(QByteArray());
+ buffers.prepend(QByteArray(head, Qt::Uninitialized));
++tailBuffer;
}
- buffers.first().resize(head);
}
head -= int(bytes);
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index 9ff1ec49cf..325b71f267 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qlist.h>
@@ -66,6 +67,14 @@ public:
explicit inline QRingBuffer(int growth = QRINGBUFFER_CHUNKSIZE) :
head(0), tail(0), tailBuffer(0), basicBlockSize(growth), bufferSize(0) { }
+ inline void setChunkSize(int size) {
+ basicBlockSize = size;
+ }
+
+ inline int chunkSize() const {
+ return basicBlockSize;
+ }
+
inline qint64 nextDataBlockSize() const {
return (tailBuffer == 0 ? tail : buffers.first().size()) - head;
}
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 1a37e0bc9c..67d11660e1 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -193,6 +193,48 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a lhs is a null pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a rhs is a null pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a lhs is a valid (i.e. a non-null)
+ pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a rhs is a valid (i.e. a non-null)
+ pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
\fn bool QScopedPointer::isNull() const
Returns \c true if this object is holding a pointer that is \c null.
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 3e6af97a33..92d7df6e5d 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -97,7 +97,7 @@ class QScopedPointer
{
typedef T *QScopedPointer:: *RestrictedBool;
public:
- explicit inline QScopedPointer(T *p = Q_NULLPTR) : d(p)
+ explicit QScopedPointer(T *p = Q_NULLPTR) Q_DECL_NOTHROW : d(p)
{
}
@@ -113,13 +113,12 @@ public:
return *d;
}
- inline T *operator->() const
+ T *operator->() const Q_DECL_NOTHROW
{
- Q_ASSERT(d);
return d;
}
- inline bool operator!() const
+ bool operator!() const Q_DECL_NOTHROW
{
return !d;
}
@@ -130,23 +129,23 @@ public:
return isNull() ? Q_NULLPTR : &QScopedPointer::d;
}
#else
- inline operator RestrictedBool() const
+ operator RestrictedBool() const Q_DECL_NOTHROW
{
return isNull() ? Q_NULLPTR : &QScopedPointer::d;
}
#endif
- inline T *data() const
+ T *data() const Q_DECL_NOTHROW
{
return d;
}
- inline bool isNull() const
+ bool isNull() const Q_DECL_NOTHROW
{
return !d;
}
- inline void reset(T *other = Q_NULLPTR)
+ void reset(T *other = Q_NULLPTR) Q_DECL_NOEXCEPT_EXPR(noexcept(Cleanup::cleanup(std::declval<T *>())))
{
if (d == other)
return;
@@ -155,7 +154,7 @@ public:
Cleanup::cleanup(oldD);
}
- inline T *take()
+ T *take() Q_DECL_NOTHROW
{
T *oldD = d;
d = Q_NULLPTR;
@@ -177,18 +176,42 @@ private:
};
template <class T, class Cleanup>
-inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
{
return lhs.data() == rhs.data();
}
template <class T, class Cleanup>
-inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
{
return lhs.data() != rhs.data();
}
template <class T, class Cleanup>
+inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
+template <class T, class Cleanup>
inline void swap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2) Q_DECL_NOTHROW
{ p1.swap(p2); }
diff --git a/src/corelib/tools/qscopedpointer_p.h b/src/corelib/tools/qscopedpointer_p.h
index f74a3a7945..c1c44e7695 100644
--- a/src/corelib/tools/qscopedpointer_p.h
+++ b/src/corelib/tools/qscopedpointer_p.h
@@ -48,6 +48,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
#ifndef QSCOPEDPOINTER_P_H
#define QSCOPEDPOINTER_P_H
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index 84afb0c5db..af09ef6f40 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -442,15 +442,20 @@
*/
/*!
- \fn QSharedPointer::QSharedPointer(T *ptr)
+ \fn QSharedPointer::QSharedPointer(X *ptr)
Creates a QSharedPointer that points to \a ptr. The pointer \a ptr
becomes managed by this QSharedPointer and must not be passed to
another QSharedPointer object or deleted outside this object.
+
+ Since Qt 5.8, when the last reference to this QSharedPointer gets
+ destroyed, \a ptr will be deleted by calling \c X's destructor (even if \c
+ X is not the same as QSharedPointer's template parameter \c T). Previously,
+ the destructor for \c T was called.
*/
/*!
- \fn QSharedPointer::QSharedPointer(T *ptr, Deleter deleter)
+ \fn QSharedPointer::QSharedPointer(X *ptr, Deleter deleter)
Creates a QSharedPointer that points to \a ptr. The pointer \a ptr
becomes managed by this QSharedPointer and must not be passed to
@@ -477,6 +482,9 @@
}
\endcode
+ Note that the custom deleter function will be called with a pointer to type
+ \c X, even if the QSharedPointer template parameter \c T is not the same.
+
It is also possible to specify a member function directly, as in:
\code
QSharedPointer<MyObject> obj =
@@ -487,6 +495,22 @@
*/
/*!
+ \fn QSharedPointer::QSharedPointer(std::nullptr_t)
+ \since 5.8
+
+ Creates a QSharedPointer that is null. This is equivalent to the
+ QSharedPointer default constructor.
+*/
+
+/*!
+ \fn QSharedPointer::QSharedPointer(std::nullptr_t, Deleter)
+ \since 5.8
+
+ Creates a QSharedPointer that is null. This is equivalent to the
+ QSharedPointer default constructor.
+*/
+
+/*!
\fn QSharedPointer::QSharedPointer(const QSharedPointer<T> &other)
Creates a QSharedPointer object that shares \a other's pointer.
@@ -1124,6 +1148,90 @@
*/
/*!
+ \fn bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a null pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a null pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a null pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a null pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
\fn bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QWeakPointer
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index 72976637d5..3b86eb238b 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -67,8 +67,10 @@ public:
// constructors
QSharedPointer();
- explicit QSharedPointer(T *ptr);
- QSharedPointer(T *ptr, Deleter d);
+ template <typename X> explicit QSharedPointer(X *ptr);
+ template <typename X, typename Deleter> QSharedPointer(X *ptr, Deleter d);
+ QSharedPointer(std::nullptr_t);
+ template <typename Deleter> QSharedPointer(std::nullptr_t, Deleter d);
QSharedPointer(const QSharedPointer<T> &other);
QSharedPointer(const QWeakPointer<T> &other);
@@ -147,6 +149,14 @@ template<class T, class X> bool operator==(const QWeakPointer<T> &ptr1, const QS
template<class T, class X> bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2);
template<class T, class X> bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2);
template<class T, class X> bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2);
+template<class T> bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs);
+template<class T> bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs);
+template<class T> bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs);
+template<class T> bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs);
template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QSharedPointer<T> &other);
template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QWeakPointer<T> &other);
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index fc23c29148..a0c22c9179 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -67,10 +67,6 @@ QT_END_NAMESPACE
#endif
#include <QtCore/qhashfunctions.h>
-#if defined(Q_COMPILER_RVALUE_REFS) && defined(Q_COMPILER_VARIADIC_TEMPLATES)
-# include <utility> // for std::forward
-#endif
-
QT_BEGIN_NAMESPACE
@@ -305,23 +301,29 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
- inline T *data() const { return value; }
- inline bool isNull() const { return !data(); }
- inline operator RestrictedBool() const { return isNull() ? Q_NULLPTR : &QSharedPointer::value; }
- inline bool operator !() const { return isNull(); }
- inline T &operator*() const { return *data(); }
- inline T *operator->() const { return data(); }
+ T *data() const Q_DECL_NOTHROW { return value; }
+ bool isNull() const Q_DECL_NOTHROW { return !data(); }
+ operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? Q_NULLPTR : &QSharedPointer::value; }
+ bool operator !() const Q_DECL_NOTHROW { return isNull(); }
+ T &operator*() const { return *data(); }
+ T *operator->() const Q_DECL_NOTHROW { return data(); }
- QSharedPointer() Q_DECL_NOTHROW : value(Q_NULLPTR), d(Q_NULLPTR) {}
+ Q_DECL_CONSTEXPR QSharedPointer() Q_DECL_NOTHROW : value(nullptr), d(nullptr) { }
~QSharedPointer() { deref(); }
- inline explicit QSharedPointer(T *ptr) : value(ptr) // noexcept
+ Q_DECL_CONSTEXPR QSharedPointer(std::nullptr_t) Q_DECL_NOTHROW : value(nullptr), d(nullptr) { }
+
+ template <class X>
+ inline explicit QSharedPointer(X *ptr) : value(ptr) // noexcept
{ internalConstruct(ptr, QtSharedPointer::NormalDeleter()); }
- template <typename Deleter>
- inline QSharedPointer(T *ptr, Deleter deleter) : value(ptr) // throws
+ template <class X, typename Deleter>
+ inline QSharedPointer(X *ptr, Deleter deleter) : value(ptr) // throws
{ internalConstruct(ptr, deleter); }
+ template <typename Deleter>
+ QSharedPointer(std::nullptr_t, Deleter) : value(nullptr), d(nullptr) { }
+
QSharedPointer(const QSharedPointer &other) Q_DECL_NOTHROW : value(other.value), d(other.d)
{ if (d) ref(); }
QSharedPointer &operator=(const QSharedPointer &other) Q_DECL_NOTHROW
@@ -363,7 +365,7 @@ public:
#endif
template <class X>
- inline QSharedPointer(const QSharedPointer<X> &other) : value(other.value), d(other.d)
+ QSharedPointer(const QSharedPointer<X> &other) Q_DECL_NOTHROW : value(other.value), d(other.d)
{ if (d) ref(); }
template <class X>
@@ -422,7 +424,6 @@ public:
QWeakPointer<T> toWeakRef() const;
-#if defined(Q_COMPILER_RVALUE_REFS) && defined(Q_COMPILER_VARIADIC_TEMPLATES)
template <typename... Args>
static QSharedPointer create(Args && ...arguments)
{
@@ -444,49 +445,6 @@ public:
result.enableSharedFromThis(result.data());
return result;
}
-#else
- static inline QSharedPointer create()
- {
- typedef QtSharedPointer::ExternalRefCountWithContiguousData<T> Private;
-# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
- typename Private::DestroyerFn destroy = &Private::safetyCheckDeleter;
-# else
- typename Private::DestroyerFn destroy = &Private::deleter;
-# endif
- QSharedPointer result(Qt::Uninitialized);
- result.d = Private::create(&result.value, destroy);
-
- // now initialize the data
- new (result.data()) T();
-# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
- internalSafetyCheckAdd(result.d, result.value);
-# endif
- result.d->setQObjectShared(result.value, true);
- result.enableSharedFromThis(result.data());
- return result;
- }
-
- template <typename Arg>
- static inline QSharedPointer create(const Arg &arg)
- {
- typedef QtSharedPointer::ExternalRefCountWithContiguousData<T> Private;
-# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
- typename Private::DestroyerFn destroy = &Private::safetyCheckDeleter;
-# else
- typename Private::DestroyerFn destroy = &Private::deleter;
-# endif
- QSharedPointer result(Qt::Uninitialized);
- result.d = Private::create(&result.value, destroy);
-
- // now initialize the data
- new (result.data()) T(arg);
-# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
- internalSafetyCheckAdd(result.d, result.value);
-# endif
- result.d->setQObjectShared(result.value, true);
- return result;
- }
-#endif
private:
explicit QSharedPointer(Qt::Initialization) {}
@@ -511,15 +469,15 @@ private:
inline void enableSharedFromThis(...) {}
- template <typename Deleter>
- inline void internalConstruct(T *ptr, Deleter deleter)
+ template <typename X, typename Deleter>
+ inline void internalConstruct(X *ptr, Deleter deleter)
{
if (!ptr) {
d = Q_NULLPTR;
return;
}
- typedef QtSharedPointer::ExternalRefCountWithCustomDeleter<T, Deleter> Private;
+ typedef QtSharedPointer::ExternalRefCountWithCustomDeleter<X, Deleter> Private;
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
typename Private::DestroyerFn actualDeleter = &Private::safetyCheckDeleter;
# else
@@ -598,10 +556,10 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
- inline bool isNull() const { return d == Q_NULLPTR || d->strongref.load() == 0 || value == Q_NULLPTR; }
- inline operator RestrictedBool() const { return isNull() ? Q_NULLPTR : &QWeakPointer::value; }
- inline bool operator !() const { return isNull(); }
- inline T *data() const { return d == Q_NULLPTR || d->strongref.load() == 0 ? Q_NULLPTR : value; }
+ bool isNull() const Q_DECL_NOTHROW { return d == Q_NULLPTR || d->strongref.load() == 0 || value == Q_NULLPTR; }
+ operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? Q_NULLPTR : &QWeakPointer::value; }
+ bool operator !() const Q_DECL_NOTHROW { return isNull(); }
+ T *data() const Q_DECL_NOTHROW { return d == Q_NULLPTR || d->strongref.load() == 0 ? Q_NULLPTR : value; }
inline QWeakPointer() Q_DECL_NOTHROW : d(Q_NULLPTR), value(Q_NULLPTR) { }
inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; }
@@ -668,11 +626,11 @@ public:
}
template <class X>
- inline bool operator==(const QWeakPointer<X> &o) const
+ bool operator==(const QWeakPointer<X> &o) const Q_DECL_NOTHROW
{ return d == o.d && value == static_cast<const T *>(o.value); }
template <class X>
- inline bool operator!=(const QWeakPointer<X> &o) const
+ bool operator!=(const QWeakPointer<X> &o) const Q_DECL_NOTHROW
{ return !(*this == o); }
template <class X>
@@ -688,11 +646,11 @@ public:
}
template <class X>
- inline bool operator==(const QSharedPointer<X> &o) const
+ bool operator==(const QSharedPointer<X> &o) const Q_DECL_NOTHROW
{ return d == o.d; }
template <class X>
- inline bool operator!=(const QSharedPointer<X> &o) const
+ bool operator!=(const QSharedPointer<X> &o) const Q_DECL_NOTHROW
{ return !(*this == o); }
inline void clear() { *this = QWeakPointer(); }
@@ -774,48 +732,96 @@ public:
// operator== and operator!=
//
template <class T, class X>
-bool operator==(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
+bool operator==(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr1.data() == ptr2.data();
}
template <class T, class X>
-bool operator!=(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
+bool operator!=(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr1.data() != ptr2.data();
}
template <class T, class X>
-bool operator==(const QSharedPointer<T> &ptr1, const X *ptr2)
+bool operator==(const QSharedPointer<T> &ptr1, const X *ptr2) Q_DECL_NOTHROW
{
return ptr1.data() == ptr2;
}
template <class T, class X>
-bool operator==(const T *ptr1, const QSharedPointer<X> &ptr2)
+bool operator==(const T *ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr1 == ptr2.data();
}
template <class T, class X>
-bool operator!=(const QSharedPointer<T> &ptr1, const X *ptr2)
+bool operator!=(const QSharedPointer<T> &ptr1, const X *ptr2) Q_DECL_NOTHROW
{
return !(ptr1 == ptr2);
}
template <class T, class X>
-bool operator!=(const T *ptr1, const QSharedPointer<X> &ptr2)
+bool operator!=(const T *ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return !(ptr2 == ptr1);
}
template <class T, class X>
-bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
+bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr2 == ptr1;
}
template <class T, class X>
-bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
+bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr2 != ptr1;
}
+template<class T>
+inline bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template<class T>
+inline bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
+template<class T>
+inline bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template<class T>
+inline bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
//
// operator-
//
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index c869c4e089..d4edf459de 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -48,16 +48,8 @@
#endif
#if defined(Q_OS_WIN)
-# if defined(Q_OS_WINCE)
-# include <qt_windows.h>
-# if _WIN32_WCE < 0x800
-# include <cmnintrin.h>
-# endif
-# endif
# if !defined(Q_CC_GNU)
-# ifndef Q_OS_WINCE
-# include <intrin.h>
-# endif
+# include <intrin.h>
# endif
#elif defined(Q_OS_LINUX) && (defined(Q_PROCESSOR_ARM) || defined(Q_PROCESSOR_MIPS_32))
#include "private/qcore_unix_p.h"
@@ -93,25 +85,6 @@ static inline uint detectProcessorFeatures()
{
return 0;
}
-#elif defined (Q_OS_WINCE)
-static inline quint64 detectProcessorFeatures()
-{
- quint64 features = 0;
-
-#if defined (ARM)
-# ifdef PF_ARM_NEON
- if (IsProcessorFeaturePresent(PF_ARM_NEON))
- features |= Q_UINT64_C(1) << CpuFeatureNEON;
-# endif
-#elif defined(_X86_)
- if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
- features |= Q_UINT64_C(1) << CpuFeatureSSE2;
- if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
- features |= Q_UINT64_C(1) << CpuFeatureSSE3;
-#endif
- return features;
-}
-
#elif defined(Q_PROCESSOR_ARM)
static inline quint64 detectProcessorFeatures()
{
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 7002d34654..2fd4be00a5 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -52,7 +52,7 @@
// We mean it.
//
-#include <qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#include <qatomic.h>
/*
@@ -139,7 +139,7 @@
* }
*/
-#if defined(__MINGW64_VERSION_MAJOR) || (defined(Q_CC_MSVC) && !defined(Q_OS_WINCE))
+#if defined(__MINGW64_VERSION_MAJOR) || defined(Q_CC_MSVC)
#include <intrin.h>
#endif
@@ -465,68 +465,12 @@ static inline quint64 qCpuFeatures()
#define qCpuHasFeature(feature) ((qCompilerCpuFeatures & (Q_UINT64_C(1) << CpuFeature ## feature)) \
|| (qCpuFeatures() & (Q_UINT64_C(1) << CpuFeature ## feature)))
-#if QT_HAS_BUILTIN(__builtin_clz) && QT_HAS_BUILTIN(__builtin_ctz) && defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
-static Q_ALWAYS_INLINE unsigned _bit_scan_reverse(unsigned val)
-{
- Q_ASSERT(val != 0); // if val==0, the result is undefined.
- unsigned result = static_cast<unsigned>(__builtin_clz(val)); // Count Leading Zeros
- // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31
- // and the lsb inde is 0. The result for _bit_scan_reverse is expected to be the index when
- // counting up: msb index is 0 (because it starts there), and the lsb index is 31.
- result ^= sizeof(unsigned) * 8 - 1;
- return result;
-}
-static Q_ALWAYS_INLINE unsigned _bit_scan_forward(unsigned val)
-{
- Q_ASSERT(val != 0); // if val==0, the result is undefined.
- return static_cast<unsigned>(__builtin_ctz(val)); // Count Trailing Zeros
-}
-#elif defined(Q_PROCESSOR_X86)
-// Bit scan functions for x86
-# if defined(Q_CC_MSVC)
-# if defined _WIN32_WCE && _WIN32_WCE < 0x800
-extern "C" unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask);
-extern "C" unsigned char _BitScanReverse(unsigned long* Index, unsigned long Mask);
-# pragma intrinsic(_BitScanForward)
-# pragma intrinsic(_BitScanReverse)
-# endif
-// MSVC calls it _BitScanReverse and returns the carry flag, which we don't need
-static __forceinline unsigned long _bit_scan_reverse(uint val)
-{
- unsigned long result;
- _BitScanReverse(&result, val);
- return result;
-}
-static __forceinline unsigned long _bit_scan_forward(uint val)
-{
- unsigned long result;
- _BitScanForward(&result, val);
- return result;
-}
-# elif (defined(Q_CC_CLANG) || (defined(Q_CC_GNU) && Q_CC_GNU < 405)) \
- && !defined(Q_CC_INTEL)
-// Clang is missing the intrinsic for _bit_scan_reverse
-// GCC only added it in version 4.5
-static inline __attribute__((always_inline))
-unsigned _bit_scan_reverse(unsigned val)
-{
- unsigned result;
- asm("bsr %1, %0" : "=r" (result) : "r" (val));
- return result;
-}
-static inline __attribute__((always_inline))
-unsigned _bit_scan_forward(unsigned val)
-{
- unsigned result;
- asm("bsf %1, %0" : "=r" (result) : "r" (val));
- return result;
-}
-# endif
-#endif // Q_PROCESSOR_X86
-
#define ALIGNMENT_PROLOGUE_16BYTES(ptr, i, length) \
for (; i < static_cast<int>(qMin(static_cast<quintptr>(length), ((4 - ((reinterpret_cast<quintptr>(ptr) >> 2) & 0x3)) & 0x3))); ++i)
+#define ALIGNMENT_PROLOGUE_32BYTES(ptr, i, length) \
+ for (; i < static_cast<int>(qMin(static_cast<quintptr>(length), ((8 - ((reinterpret_cast<quintptr>(ptr) >> 2) & 0x7)) & 0x7))); ++i)
+
QT_END_NAMESPACE
#endif // QSIMD_P_H
diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h
index 5d40c4079a..cd5f8adbf5 100644
--- a/src/corelib/tools/qsize.h
+++ b/src/corelib/tools/qsize.h
@@ -42,6 +42,10 @@
#include <QtCore/qnamespace.h>
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+struct CGSize;
+#endif
+
QT_BEGIN_NAMESPACE
@@ -86,6 +90,10 @@ public:
friend inline Q_DECL_CONSTEXPR const QSize operator*(qreal, const QSize &) Q_DECL_NOTHROW;
friend inline const QSize operator/(const QSize &, qreal);
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ CGSize toCGSize() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
int wd;
int ht;
@@ -248,6 +256,11 @@ public:
Q_DECL_CONSTEXPR inline QSize toSize() const Q_DECL_NOTHROW;
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ static QSizeF fromCGSize(CGSize size) Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ CGSize toCGSize() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
qreal wd;
qreal ht;
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 69fd4f1e52..bf1bc3e650 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -81,9 +81,6 @@
#ifdef Q_OS_WIN
# include <qt_windows.h>
-# ifdef Q_OS_WINCE
-# include <winnls.h>
-# endif
#endif
#ifdef truncate
@@ -471,7 +468,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
uint mask = ~_mm_movemask_epi8(result);
if (ushort(mask)) {
// found a different byte
- uint idx = uint(_bit_scan_forward(mask));
+ uint idx = qCountTrailingZeroBits(mask);
return reinterpret_cast<const QChar *>(ptr + idx)->unicode()
- reinterpret_cast<const QChar *>(ptr + distance + idx)->unicode();
}
@@ -574,7 +571,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
# endif
if (mask) {
// found a different character
- uint idx = uint(_bit_scan_forward(mask));
+ uint idx = qCountTrailingZeroBits(mask);
return uc[offset + idx / 2] - c[offset + idx / 2];
}
}
@@ -592,7 +589,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
uint mask = ~_mm_movemask_epi8(result);
if (ushort(mask)) {
// found a different character
- uint idx = uint(_bit_scan_forward(mask));
+ uint idx = qCountTrailingZeroBits(mask);
return uc[offset + idx / 2] - c[offset + idx / 2];
}
@@ -687,7 +684,7 @@ static int findChar(const QChar *str, int len, QChar ch, int from,
// found a match
// same as: return n - s + _bit_scan_forward(mask) / 2
return (reinterpret_cast<const char *>(n) - reinterpret_cast<const char *>(s)
- + _bit_scan_forward(mask)) >> 1;
+ + qCountTrailingZeroBits(mask)) >> 1;
}
}
@@ -1152,7 +1149,7 @@ const QString::Null QString::null = { };
has a ref count of 1, whereas QString::append() needs an extra
test).
- There are three ways you can access this improved method of string
+ There are two ways you can access this improved method of string
construction. The straightforward way is to include
\c{QStringBuilder} wherever you want to use it, and use the
\c{'%'} operator instead of \c{'+'} when concatenating strings:
@@ -3266,22 +3263,7 @@ static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *nee
*/
int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const
{
- const int sl = str.d->size;
- if (sl == 1)
- return lastIndexOf(QChar(str.d->data()[0]), from, cs);
-
- const int l = d->size;
- if (from < 0)
- from += l;
- int delta = l-sl;
- if (from == l && sl == 0)
- return from;
- if (uint(from) >= uint(l) || delta < 0)
- return -1;
- if (from > delta)
- from = delta;
-
- return lastIndexOfHelper(d->data(), from, str.d->data(), str.d->size, cs);
+ return QStringRef(this).lastIndexOf(QStringRef(&str), from, cs);
}
/*!
@@ -3305,25 +3287,7 @@ int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) c
*/
int QString::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const
{
- const int sl = str.size();
- if (sl == 1)
- return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs);
-
- const int l = d->size;
- if (from < 0)
- from += l;
- int delta = l-sl;
- if (from == l && sl == 0)
- return from;
- if (uint(from) >= uint(l) || delta < 0)
- return -1;
- if (from > delta)
- from = delta;
-
- QVarLengthArray<ushort> s(sl);
- qt_from_latin1(s.data(), str.latin1(), sl);
-
- return lastIndexOfHelper(d->data(), from, s.data(), sl, cs);
+ return QStringRef(this).lastIndexOf(str, from, cs);
}
/*!
@@ -3354,23 +3318,7 @@ int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
*/
int QString::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const
{
- const int sl = str.size();
- if (sl == 1)
- return lastIndexOf(str.at(0), from, cs);
-
- const int l = d->size;
- if (from < 0)
- from += l;
- int delta = l - sl;
- if (from == l && sl == 0)
- return from;
- if (uint(from) >= uint(l) || delta < 0)
- return -1;
- if (from > delta)
- from = delta;
-
- return lastIndexOfHelper(d->data(), from, reinterpret_cast<const ushort*>(str.unicode()),
- str.size(), cs);
+ return QStringRef(this).lastIndexOf(str, from, cs);
}
@@ -5045,7 +4993,7 @@ void QString::truncate(int pos)
If you want to remove characters from the \e beginning of the
string, use remove() instead.
- \sa truncate(), resize(), remove()
+ \sa truncate(), resize(), remove(), QStringRef::chop()
*/
void QString::chop(int n)
{
@@ -5453,9 +5401,15 @@ int QString::compare(QLatin1String other, Qt::CaseSensitivity cs) const Q_DECL_N
int QString::compare_helper(const QChar *data1, int length1, const char *data2, int length2,
Qt::CaseSensitivity cs)
{
- // ### optimize me
- const QString s2 = QString::fromUtf8(data2, length2 == -1 ? (data2 ? int(strlen(data2)) : -1) : length2);
- return compare_helper(data1, length1, s2.constData(), s2.size(), cs);
+ if (!data2)
+ return length1;
+ if (Q_UNLIKELY(length2 < 0))
+ length2 = int(strlen(data2));
+ // ### make me nothrow in all cases
+ QVarLengthArray<ushort> s2(length2);
+ const auto beg = reinterpret_cast<QChar *>(s2.data());
+ const auto end = QUtf8::convertToUnicode(beg, data2, length2);
+ return compare_helper(data1, length1, beg, end - beg, cs);
}
/*!
@@ -5556,7 +5510,7 @@ int QString::localeAwareCompare(const QString &other) const
return localeAwareCompare_helper(constData(), length(), other.constData(), other.length());
}
-#if defined(QT_USE_ICU) && !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE) && !defined (Q_OS_MAC)
+#if defined(QT_USE_ICU) && !defined(Q_OS_WIN32) && !defined(Q_OS_DARWIN)
Q_GLOBAL_STATIC(QThreadStorage<QCollator>, defaultCollator)
#endif
@@ -5571,12 +5525,12 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1,
if (length1 == 0 || length2 == 0)
return ucstrcmp(data1, length1, data2, length2);
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
-#ifndef Q_OS_WINRT
+#if defined(Q_OS_WIN)
+# ifndef Q_OS_WINRT
int res = CompareString(GetUserDefaultLCID(), 0, (wchar_t*)data1, length1, (wchar_t*)data2, length2);
-#else
+# else
int res = CompareStringEx(LOCALE_NAME_USER_DEFAULT, 0, (LPCWSTR)data1, length1, (LPCWSTR)data2, length2, NULL, NULL, 0);
-#endif
+# endif
switch (res) {
case CSTR_LESS_THAN:
@@ -7983,40 +7937,6 @@ QString QString::multiArg(int numArgs, const QString **args) const
return result;
}
-
-/*! \fn QString QString::fromCFString(CFStringRef string)
- \since 5.2
-
- Constructs a new QString containing a copy of the \a string CFString.
-
- \note this function is only available on \macos and iOS.
-*/
-
-/*! \fn CFStringRef QString::toCFString() const
- \since 5.2
-
- Creates a CFString from a QString. The caller owns the CFString and is
- responsible for releasing it.
-
- \note this function is only available on \macos and iOS.
-*/
-
-/*! \fn QString QString::fromNSString(const NSString *string)
- \since 5.2
-
- Constructs a new QString containing a copy of the \a string NSString.
-
- \note this function is only available on \macos and iOS.
-*/
-
-/*! \fn NSString QString::toNSString() const
- \since 5.2
-
- Creates a NSString from a QString. The NSString is autoreleased.
-
- \note this function is only available on \macos and iOS.
-*/
-
/*! \fn bool QString::isSimpleText() const
\internal
@@ -8366,6 +8286,78 @@ QString &QString::setRawData(const QChar *unicode, int size)
Returns the size of the Latin-1 string stored in this object.
*/
+/*! \fn QLatin1Char QLatin1String::at(int pos) const
+ \since 5.8
+
+ Returns the character at position \a pos in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a pos < 0 or \a pos ≥ size().
+
+ \sa operator[]()
+*/
+
+/*! \fn QLatin1Char QLatin1String::operator[](int pos) const
+ \since 5.8
+
+ Returns the character at position \a pos in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a pos < 0 or \a pos ≥ size().
+
+ \sa at()
+*/
+
+/*! \fn QLatin1String QLatin1String::mid(int start) const
+ \since 5.8
+
+ Returns the substring starting at position \a start in this object,
+ and extending to the end of the string.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a start < 0 or \a start > size().
+
+ \sa left(), right()
+*/
+
+/*! \fn QLatin1String QLatin1String::mid(int start, int length) const
+ \since 5.8
+ \overload
+
+ Returns the substring of length \a length starting at position
+ \a start in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a start < 0, \a length < 0,
+ or \a start + \a length > size().
+
+ \sa left(), right()
+*/
+
+/*! \fn QLatin1String QLatin1String::left(int length) const
+ \since 5.8
+
+ Returns the substring of length \a length starting at position
+ 0 in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a length < 0 or \a length > size().
+
+ \sa mid(), right()
+*/
+
+/*! \fn QLatin1String QLatin1String::right(int length) const
+ \since 5.8
+
+ Returns the substring of length \a length starting at position
+ size() - \a length in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a length < 0 or \a length > size().
+
+ \sa mid(), left()
+*/
+
/*! \fn bool QLatin1String::operator==(const QString &other) const
Returns \c true if this string is equal to string \a other;
@@ -9398,6 +9390,24 @@ QStringRef QStringRef::appendTo(QString *string) const
*/
/*!
+ \overload
+ \fn int QStringRef::compare(const QByteArray &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \since 5.8
+
+ Compares this string with \a other and returns an
+ integer less than, equal to, or greater than zero if this string
+ is less than, equal to, or greater than the \a other byte array,
+ interpreted as a UTF-8 sequence.
+
+ If \a cs is Qt::CaseSensitive, the comparison is case sensitive;
+ otherwise the comparison is case insensitive.
+
+ Equivalent to \c {compare(*this, other, cs)}.
+
+ \sa QString::compare()
+*/
+
+/*!
\fn int QStringRef::localeAwareCompare(const QStringRef &s1, const QString & s2)
\since 4.5
@@ -9640,6 +9650,18 @@ QStringRef QString::midRef(int position, int n) const
*/
/*!
+ \fn void QStringRef::chop(int n)
+ \since 5.8
+
+ Removes \a n characters from the end of the string.
+
+ If \a n is greater than or equal to size(), the result is an
+ empty string; if \a n is negative, it is equivalent to passing zero.
+
+ \sa QString::chop(), truncate()
+*/
+
+/*!
\since 4.8
Returns the index position of the first occurrence of the string \a
@@ -9729,23 +9751,7 @@ int QStringRef::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs)
*/
int QStringRef::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const
{
- const int sl = str.size();
- if (sl == 1)
- return lastIndexOf(str.at(0), from, cs);
-
- const int l = size();;
- if (from < 0)
- from += l;
- int delta = l - sl;
- if (from == l && sl == 0)
- return from;
- if (uint(from) >= uint(l) || delta < 0)
- return -1;
- if (from > delta)
- from = delta;
-
- return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from,
- reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs);
+ return lastIndexOf(QStringRef(&str), from, cs);
}
/*!
@@ -9781,7 +9787,7 @@ int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs)
{
const int sl = str.size();
if (sl == 1)
- return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs);
+ return lastIndexOf(str.at(0), from, cs);
const int l = size();
if (from < 0)
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index ce09582ef9..b50b2ee4e5 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -68,11 +68,9 @@ namespace std
#error qstring.h must be included before any header file that defines truncate
#endif
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFString);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSString);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -99,6 +97,18 @@ public:
Q_DECL_CONSTEXPR int size() const Q_DECL_NOTHROW { return m_size; }
Q_DECL_CONSTEXPR const char *data() const Q_DECL_NOTHROW { return m_data; }
+ Q_DECL_CONSTEXPR QLatin1Char at(int i) const { return QLatin1Char(m_data[i]); }
+ Q_DECL_CONSTEXPR QLatin1Char operator[](int i) const { return at(i); }
+
+ Q_DECL_CONSTEXPR QLatin1String mid(int pos) const
+ { return QLatin1String(m_data + pos, m_size - pos); }
+ Q_DECL_CONSTEXPR QLatin1String mid(int pos, int n) const
+ { return QLatin1String(m_data + pos, n); }
+ Q_DECL_CONSTEXPR QLatin1String left(int n) const
+ { return QLatin1String(m_data, n); }
+ Q_DECL_CONSTEXPR QLatin1String right(int n) const
+ { return QLatin1String(m_data + m_size - n, n); }
+
inline bool operator==(const QString &s) const Q_DECL_NOTHROW;
inline bool operator!=(const QString &s) const Q_DECL_NOTHROW;
inline bool operator>(const QString &s) const Q_DECL_NOTHROW;
@@ -593,7 +603,7 @@ public:
Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW
{ return -s2.compare(s1, cs); }
- int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
+ inline int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
static int compare(const QString &s1, const QStringRef &s2,
Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW;
@@ -768,13 +778,11 @@ public:
inline std::u32string toStdU32String() const;
#endif
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QString fromCFString(CFStringRef string);
CFStringRef toCFString() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QString fromNSString(const NSString *string);
NSString *toNSString() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
// compatibility
struct Null { };
@@ -802,6 +810,16 @@ private:
Data *d;
+ friend inline bool operator==(QChar, const QString &) Q_DECL_NOTHROW;
+ friend inline bool operator< (QChar, const QString &) Q_DECL_NOTHROW;
+ friend inline bool operator> (QChar, const QString &) Q_DECL_NOTHROW;
+ friend inline bool operator==(QChar, const QStringRef &) Q_DECL_NOTHROW;
+ friend inline bool operator< (QChar, const QStringRef &) Q_DECL_NOTHROW;
+ friend inline bool operator> (QChar, const QStringRef &) Q_DECL_NOTHROW;
+ friend inline bool operator==(QChar, QLatin1String) Q_DECL_NOTHROW;
+ friend inline bool operator< (QChar, QLatin1String) Q_DECL_NOTHROW;
+ friend inline bool operator> (QChar, QLatin1String) Q_DECL_NOTHROW;
+
void reallocData(uint alloc, bool grow = false);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void expand(int i);
@@ -1423,6 +1441,13 @@ public:
QStringRef mid(int pos, int n = -1) const Q_REQUIRED_RESULT;
void truncate(int pos) Q_DECL_NOTHROW { m_size = qBound(0, pos, m_size); }
+ void chop(int n) Q_DECL_NOTHROW
+ {
+ if (n >= m_size)
+ m_size = 0;
+ else if (n > 0)
+ m_size -= n;
+ }
bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@@ -1486,6 +1511,10 @@ public:
int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
+#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
+ int compare(const QByteArray &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ { return QString::compare_helper(unicode(), size(), s.data(), qstrnlen(s.data(), s.size()), cs); }
+#endif
static int compare(const QStringRef &s1, const QString &s2,
Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW;
static int compare(const QStringRef &s1, const QStringRef &s2,
@@ -1521,24 +1550,10 @@ inline QStringRef::QStringRef(const QString *aString, int aPosition, int aSize)
inline QStringRef::QStringRef(const QString *aString)
:m_string(aString), m_position(0), m_size(aString?aString->size() : 0){}
+// QStringRef <> QStringRef
Q_CORE_EXPORT bool operator==(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW;
inline bool operator!=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW
{ return !(s1 == s2); }
-Q_CORE_EXPORT bool operator==(const QString &s1, const QStringRef &s2) Q_DECL_NOTHROW;
-inline bool operator!=(const QString &s1, const QStringRef &s2) Q_DECL_NOTHROW
-{ return !(s1 == s2); }
-inline bool operator==(const QStringRef &s1, const QString &s2) Q_DECL_NOTHROW
-{ return s2 == s1; }
-inline bool operator!=(const QStringRef &s1, const QString &s2) Q_DECL_NOTHROW
-{ return s2 != s1; }
-Q_CORE_EXPORT bool operator==(QLatin1String s1, const QStringRef &s2) Q_DECL_NOTHROW;
-inline bool operator!=(QLatin1String s1, const QStringRef &s2) Q_DECL_NOTHROW
-{ return !(s1 == s2); }
-inline bool operator==(const QStringRef &s1, QLatin1String s2) Q_DECL_NOTHROW
-{ return s2 == s1; }
-inline bool operator!=(const QStringRef &s1, QLatin1String s2) Q_DECL_NOTHROW
-{ return s2 != s1; }
-
Q_CORE_EXPORT bool operator<(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW;
inline bool operator>(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW
{ return s2 < s1; }
@@ -1547,7 +1562,127 @@ inline bool operator<=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHRO
inline bool operator>=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW
{ return !(s1 < s2); }
+// QString <> QStringRef
+Q_CORE_EXPORT bool operator==(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW;
+inline bool operator!=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) != 0; }
+inline bool operator< (const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) < 0; }
+inline bool operator> (const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) > 0; }
+inline bool operator<=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) <= 0; }
+inline bool operator>=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) >= 0; }
+
+inline bool operator==(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs != lhs; }
+inline bool operator< (const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs >= lhs; }
+inline bool operator>=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs <= lhs; }
+
+inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
+inline int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
+inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
+inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
+inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s, cs); }
+inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
+inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
+inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2, cs); }
+
+// QLatin1String <> QStringRef
+Q_CORE_EXPORT bool operator==(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW;
+inline bool operator!=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) != 0; }
+inline bool operator< (QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) > 0; }
+inline bool operator> (QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) < 0; }
+inline bool operator<=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) >= 0; }
+inline bool operator>=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) <= 0; }
+
+inline bool operator==(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs != lhs; }
+inline bool operator< (const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs >= lhs; }
+inline bool operator>=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs <= lhs; }
+
+// QChar <> QString
+inline bool operator==(QChar lhs, const QString &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) == 0; }
+inline bool operator< (QChar lhs, const QString &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) < 0; }
+inline bool operator> (QChar lhs, const QString &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) > 0; }
+
+inline bool operator!=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); }
+inline bool operator<=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs > rhs); }
+inline bool operator>=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs < rhs); }
+
+inline bool operator==(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); }
+inline bool operator< (const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); }
+inline bool operator>=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); }
+
+// QChar <> QStringRef
+inline bool operator==(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) == 0; }
+inline bool operator< (QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) < 0; }
+inline bool operator> (QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) > 0; }
+
+inline bool operator!=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); }
+inline bool operator<=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs > rhs); }
+inline bool operator>=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs < rhs); }
+
+inline bool operator==(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); }
+inline bool operator< (const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); }
+inline bool operator>=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); }
+
+// QChar <> QLatin1String
+inline bool operator==(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs) == 0; }
+inline bool operator< (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs) < 0; }
+inline bool operator> (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs) > 0; }
+
+inline bool operator!=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs == rhs); }
+inline bool operator<=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs > rhs); }
+inline bool operator>=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs < rhs); }
+
+inline bool operator==(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); }
+inline bool operator< (QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); }
+inline bool operator>=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); }
+
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
+// QStringRef <> QByteArray
+inline QT_ASCII_CAST_WARN bool operator==(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) == 0; }
+inline QT_ASCII_CAST_WARN bool operator!=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) != 0; }
+inline QT_ASCII_CAST_WARN bool operator< (const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) < 0; }
+inline QT_ASCII_CAST_WARN bool operator> (const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) > 0; }
+inline QT_ASCII_CAST_WARN bool operator<=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) <= 0; }
+inline QT_ASCII_CAST_WARN bool operator>=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) >= 0; }
+
+inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) == 0; }
+inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) != 0; }
+inline QT_ASCII_CAST_WARN bool operator< (const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) > 0; }
+inline QT_ASCII_CAST_WARN bool operator> (const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) < 0; }
+inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) >= 0; }
+inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) <= 0; }
+
+// QStringRef <> const char *
inline QT_ASCII_CAST_WARN bool QStringRef::operator==(const char *s) const
{ return QString::compare_helper(constData(), size(), s, -1) == 0; }
inline QT_ASCII_CAST_WARN bool QStringRef::operator!=(const char *s) const
@@ -1575,23 +1710,6 @@ inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QStringRef &s2)
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; }
#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
-inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
-inline int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
-inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
-inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
-inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s, cs); }
-inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
-inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
-inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2, cs); }
-
inline int QString::localeAwareCompare(const QStringRef &s) const
{ return localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); }
inline int QString::localeAwareCompare(const QString& s1, const QStringRef& s2)
@@ -1617,6 +1735,23 @@ inline bool QStringRef::contains(const QStringRef &s, Qt::CaseSensitivity cs) co
inline QString &QString::insert(int i, const QStringRef &s)
{ return insert(i, s.constData(), s.length()); }
+#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER)
+inline QString operator+(const QString &s1, const QStringRef &s2)
+{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
+inline QString operator+(const QStringRef &s1, const QString &s2)
+{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
+inline QString operator+(const QStringRef &s1, QLatin1String s2)
+{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
+inline QString operator+(QLatin1String s1, const QStringRef &s2)
+{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
+inline QString operator+(const QStringRef &s1, const QStringRef &s2)
+{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
+inline QString operator+(const QStringRef &s1, QChar s2)
+{ QString t; t.reserve(s1.size() + 1); t += s1; t += s2; return t; }
+inline QString operator+(QChar s1, const QStringRef &s2)
+{ QString t; t.reserve(1 + s2.size()); t += s1; t += s2; return t; }
+#endif // !(QT_USE_FAST_OPERATOR_PLUS || QT_USE_QSTRINGBUILDER)
+
namespace Qt {
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED inline QString escape(const QString &plain) {
diff --git a/src/corelib/tools/qstring_mac.mm b/src/corelib/tools/qstring_mac.mm
deleted file mode 100644
index 7b3d6b53c0..0000000000
--- a/src/corelib/tools/qstring_mac.mm
+++ /dev/null
@@ -1,83 +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 "qstring.h"
-
-#import <Foundation/Foundation.h>
-
-QT_BEGIN_NAMESPACE
-
-QString QString::fromCFString(CFStringRef string)
-{
- if (!string)
- return QString();
- CFIndex length = CFStringGetLength(string);
-
- // Fast path: CFStringGetCharactersPtr does not copy but may
- // return null for any and no reason.
- const UniChar *chars = CFStringGetCharactersPtr(string);
- if (chars)
- return QString(reinterpret_cast<const QChar *>(chars), length);
-
- QString ret(length, Qt::Uninitialized);
- CFStringGetCharacters(string, CFRangeMake(0, length), reinterpret_cast<UniChar *>(ret.data()));
- return ret;
-}
-
-CFStringRef QString::toCFString() const
-{
- return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(unicode()), length());
-}
-
-QString QString::fromNSString(const NSString *string)
-{
- if (!string)
- return QString();
- QString qstring;
- qstring.resize([string length]);
- [string getCharacters: reinterpret_cast<unichar*>(qstring.data()) range: NSMakeRange(0, [string length])];
- return qstring;
-}
-
-NSString *QString::toNSString() const
-{
- return [NSString stringWithCharacters: reinterpret_cast<const UniChar*>(unicode()) length: length()];
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/tools/qstringiterator_p.h b/src/corelib/tools/qstringiterator_p.h
index 2e24031ce4..7cf59ae42f 100644
--- a/src/corelib/tools/qstringiterator_p.h
+++ b/src/corelib/tools/qstringiterator_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qstring.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp
index eae9e0e5d9..a0b65ea554 100644
--- a/src/corelib/tools/qstringlist.cpp
+++ b/src/corelib/tools/qstringlist.cpp
@@ -447,6 +447,17 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegularEx
#endif // QT_NO_REGULAREXPRESSION
#endif // QT_BOOTSTRAPPED
+static int accumulatedSize(const QStringList &list, int seplen)
+{
+ int result = 0;
+ if (!list.isEmpty()) {
+ for (const auto &e : list)
+ result += e.size() + seplen;
+ result -= seplen;
+ }
+ return result;
+}
+
/*!
\fn QString QStringList::join(const QString &separator) const
@@ -464,15 +475,9 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegularEx
*/
QString QtPrivate::QStringList_join(const QStringList *that, const QChar *sep, int seplen)
{
- int totalLength = 0;
+ const int totalLength = accumulatedSize(*that, seplen);
const int size = that->size();
- for (int i = 0; i < size; ++i)
- totalLength += that->at(i).size();
-
- if(size > 0)
- totalLength += seplen * (size - 1);
-
QString res;
if (totalLength == 0)
return res;
@@ -486,6 +491,27 @@ QString QtPrivate::QStringList_join(const QStringList *that, const QChar *sep, i
}
/*!
+ \fn QString QStringList::join(QLatin1String separator) const
+ \since 5.8
+ \overload join()
+*/
+QString QtPrivate::QStringList_join(const QStringList &list, QLatin1String sep)
+{
+ QString result;
+ if (!list.isEmpty()) {
+ result.reserve(accumulatedSize(list, sep.size()));
+ const auto end = list.end();
+ auto it = list.begin();
+ result += *it;
+ while (++it != end) {
+ result += sep;
+ result += *it;
+ }
+ }
+ return result;
+}
+
+/*!
\fn QStringList QStringList::operator+(const QStringList &other) const
Returns a string list that is the concatenation of this string
diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h
index e01f9e16e8..720d7d7419 100644
--- a/src/corelib/tools/qstringlist.h
+++ b/src/corelib/tools/qstringlist.h
@@ -73,6 +73,7 @@ public:
inline int removeDuplicates();
inline QString join(const QString &sep) const;
+ inline QString join(QLatin1String sep) const;
inline QString join(QChar sep) const;
inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@@ -149,6 +150,7 @@ public:
Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE);
+#ifndef Q_QDOC
inline QStringList *QListSpecialMethods<QString>::self()
{ return static_cast<QStringList *>(this); }
inline const QStringList *QListSpecialMethods<QString>::self() const
@@ -158,6 +160,7 @@ namespace QtPrivate {
void Q_CORE_EXPORT QStringList_sort(QStringList *that, Qt::CaseSensitivity cs);
int Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that);
QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QChar *sep, int seplen);
+ Q_CORE_EXPORT QString QStringList_join(const QStringList &list, QLatin1String sep);
QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QString &str,
Qt::CaseSensitivity cs);
@@ -199,6 +202,11 @@ inline QString QListSpecialMethods<QString>::join(const QString &sep) const
return QtPrivate::QStringList_join(self(), sep.constData(), sep.length());
}
+QString QListSpecialMethods<QString>::join(QLatin1String sep) const
+{
+ return QtPrivate::QStringList_join(*self(), sep);
+}
+
inline QString QListSpecialMethods<QString>::join(QChar sep) const
{
return QtPrivate::QStringList_join(self(), &sep, 1);
@@ -284,6 +292,7 @@ inline int QStringList::lastIndexOf(const QRegularExpression &rx, int from) cons
}
#endif // QT_NO_REGULAREXPRESSION
#endif // QT_BOOTSTRAPPED
+#endif // Q_QDOC
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qtimezoneprivate_data_p.h b/src/corelib/tools/qtimezoneprivate_data_p.h
index b4e52af33a..6bbcb0e2cd 100644
--- a/src/corelib/tools/qtimezoneprivate_data_p.h
+++ b/src/corelib/tools/qtimezoneprivate_data_p.h
@@ -52,6 +52,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
QT_BEGIN_NAMESPACE
/*
diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp
index 8e32db48de..4febeda537 100644
--- a/src/corelib/tools/qtimezoneprivate_win.cpp
+++ b/src/corelib/tools/qtimezoneprivate_win.cpp
@@ -383,17 +383,11 @@ static void calculateTransitionsForYear(const QWinTimeZonePrivate::QWinTransitio
static QLocale::Country userCountry()
{
-#if defined(Q_OS_WINCE)
- // Guess that the syslem locale country is the right one to use
- // TODO Find if WinCE has equivalent api
- return QLocale::system().country();
-#else
const GEOID id = GetUserGeoID(GEOCLASS_NATION);
wchar_t code[3];
const int size = GetGeoInfo(id, GEO_ISO2, code, 3, 0);
return (size == 3) ? QLocalePrivate::codeToCountry(reinterpret_cast<const QChar*>(code), size)
: QLocale::AnyCountry;
-#endif // Q_OS_WINCE
}
// Create the system default time zone
diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h
index 09adee5586..17d2ab852a 100644
--- a/src/corelib/tools/qtools_p.h
+++ b/src/corelib/tools/qtools_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include "QtCore/private/qglobal_p.h"
#include <limits.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h
index cec84a2490..5a422ea4eb 100644
--- a/src/corelib/tools/qunicodetables_p.h
+++ b/src/corelib/tools/qunicodetables_p.h
@@ -50,6 +50,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
#ifndef QUNICODETABLES_P_H
#define QUNICODETABLES_P_H
diff --git a/src/corelib/tools/qunicodetools.cpp b/src/corelib/tools/qunicodetools.cpp
index fad4267edc..be1d88e260 100644
--- a/src/corelib/tools/qunicodetools.cpp
+++ b/src/corelib/tools/qunicodetools.cpp
@@ -522,13 +522,13 @@ static void getLineBreaks(const ushort *string, quint32 len, QCharAttributes *at
// do not change breaks before and after the expression
for (quint32 j = nestart + 1; j < pos; ++j)
attributes[j].lineBreak = false;
- // fall through
+ Q_FALLTHROUGH();
case LB::NS::None:
nelast = LB::NS::XX; // reset state
break;
case LB::NS::Start:
nestart = i;
- // fall through
+ Q_FALLTHROUGH();
default:
nelast = necur;
break;
diff --git a/src/corelib/tools/qunicodetools_p.h b/src/corelib/tools/qunicodetools_p.h
index 5cde188656..5e2d56a226 100644
--- a/src/corelib/tools/qunicodetools_p.h
+++ b/src/corelib/tools/qunicodetools_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qchar.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index b64ec756ba..e3d89651e4 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -71,7 +71,6 @@ HEADERS += \
tools/qtimezoneprivate_p.h \
tools/qtimezoneprivate_data_p.h \
tools/qtools_p.h \
- tools/qelapsedtimer.h \
tools/qunicodetables_p.h \
tools/qunicodetools_p.h \
tools/qvarlengtharray.h \
@@ -92,7 +91,6 @@ SOURCES += \
tools/qdatetime.cpp \
tools/qdatetimeparser.cpp \
tools/qeasingcurve.cpp \
- tools/qelapsedtimer.cpp \
tools/qfreelist.cpp \
tools/qhash.cpp \
tools/qline.cpp \
@@ -130,36 +128,32 @@ msvc: NO_PCH_SOURCES += tools/qvector_msvc.cpp
false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator
!nacl:mac: {
- SOURCES += tools/qelapsedtimer_mac.cpp
OBJECTIVE_SOURCES += tools/qlocale_mac.mm \
tools/qtimezoneprivate_mac.mm \
- tools/qstring_mac.mm \
- tools/qbytearray_mac.mm \
- tools/qdatetime_mac.mm
}
else:android {
- SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_unix.cpp tools/qtimezoneprivate_android.cpp
+ SOURCES += tools/qlocale_unix.cpp tools/qtimezoneprivate_android.cpp
}
else:unix {
- SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_unix.cpp tools/qtimezoneprivate_tz.cpp
+ SOURCES += tools/qlocale_unix.cpp tools/qtimezoneprivate_tz.cpp
}
else:win32 {
- SOURCES += tools/qelapsedtimer_win.cpp \
- tools/qlocale_win.cpp \
+ SOURCES += tools/qlocale_win.cpp \
tools/qtimezoneprivate_win.cpp
winphone: LIBS_PRIVATE += -lWindowsPhoneGlobalizationUtil
winrt-*-msvc2013: LIBS += advapi32.lib
-} else:integrity:SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_unix.cpp
-else:SOURCES += tools/qelapsedtimer_generic.cpp
+} else:integrity {
+ SOURCES += tools/qlocale_unix.cpp
+}
-contains(QT_CONFIG, zlib) {
- include($$PWD/../../3rdparty/zlib.pri)
+qtConfig(system-zlib) {
+ include($$PWD/../../3rdparty/zlib_dependency.pri)
} else {
CONFIG += no_core_dep
- include($$PWD/../../3rdparty/zlib_dependency.pri)
+ include($$PWD/../../3rdparty/zlib.pri)
}
-contains(QT_CONFIG,icu) {
+qtConfig(icu) {
include($$PWD/../../3rdparty/icu_dependency.pri)
SOURCES += tools/qlocale_icu.cpp \
@@ -174,7 +168,7 @@ contains(QT_CONFIG,icu) {
SOURCES += tools/qcollator_posix.cpp
}
-!contains(QT_DISABLED_FEATURES, regularexpression) {
+qtConfig(regularexpression) {
include($$PWD/../../3rdparty/pcre_dependency.pri)
HEADERS += tools/qregularexpression.h
@@ -198,12 +192,10 @@ INCLUDEPATH += ../3rdparty/md5 \
../3rdparty/md4 \
../3rdparty/sha3
-contains(QT_CONFIG, doubleconversion) {
+qtConfig(system-doubleconversion) {
+ QMAKE_USE_PRIVATE += doubleconversion
+} else: qtConfig(doubleconversion) {
include($$PWD/../../3rdparty/double-conversion/double-conversion.pri)
-} else:contains(QT_CONFIG, system-doubleconversion) {
- LIBS_PRIVATE += -ldouble-conversion
-} else {
- DEFINES += QT_NO_DOUBLECONVERSION
}
# Note: libm should be present by default becaue this is C++
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index 83b26d50ab..1ffaeca852 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -976,11 +976,11 @@ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
case '\r':
if ((c = filterCarriageReturn()) == 0)
break;
- // fall through
+ Q_FALLTHROUGH();
case '\n':
++lineNumber;
lastLineStart = characterOffset + readBufferPos;
- // fall through
+ Q_FALLTHROUGH();
case '\t':
textBuffer += QChar(c);
continue;
@@ -1158,11 +1158,11 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent()
case '\r':
if (filterCarriageReturn() == 0)
return n;
- // fall through
+ Q_FALLTHROUGH();
case '\n':
++lineNumber;
lastLineStart = characterOffset + readBufferPos;
- // fall through
+ Q_FALLTHROUGH();
case ' ':
case '\t':
if (normalizeLiterals)
@@ -1179,7 +1179,7 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent()
putChar(c);
return n;
}
- // fall through
+ Q_FALLTHROUGH();
default:
if (c < 0x20) {
putChar(c);
@@ -1201,11 +1201,11 @@ inline int QXmlStreamReaderPrivate::fastScanSpace()
case '\r':
if ((c = filterCarriageReturn()) == 0)
return n;
- // fall through
+ Q_FALLTHROUGH();
case '\n':
++lineNumber;
lastLineStart = characterOffset + readBufferPos;
- // fall through
+ Q_FALLTHROUGH();
case ' ':
case '\t':
textBuffer += QChar(c);
@@ -1259,11 +1259,11 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList()
case '\r':
if ((c = filterCarriageReturn()) == 0)
return n;
- // fall through
+ Q_FALLTHROUGH();
case '\n':
++lineNumber;
lastLineStart = characterOffset + readBufferPos;
- // fall through
+ Q_FALLTHROUGH();
case ' ':
case '\t':
textBuffer += QChar(ushort(c));
@@ -1275,7 +1275,7 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList()
putChar(c);
return n;
}
- // fall through
+ Q_FALLTHROUGH();
default:
if (c < 0x20) {
putChar(c);
@@ -1339,7 +1339,7 @@ inline int QXmlStreamReaderPrivate::fastScanName(int *prefix)
putChar(c);
return n;
}
- // fall through
+ Q_FALLTHROUGH();
default:
textBuffer += QChar(c);
++n;
@@ -2123,7 +2123,7 @@ QString QXmlStreamReader::readElementText(ReadElementTextBehaviour behaviour)
result += readElementText(behaviour);
break;
}
- // Fall through (for ErrorOnUnexpectedElement)
+ Q_FALLTHROUGH();
default:
if (d->error || behaviour == ErrorOnUnexpectedElement) {
if (!d->error)
diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h
index ab0bbba413..b62cc9ac39 100644
--- a/src/corelib/xml/qxmlstream_p.h
+++ b/src/corelib/xml/qxmlstream_p.h
@@ -48,6 +48,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
// This file was generated by qlalr - DO NOT EDIT!
#ifndef QXMLSTREAM_P_H
#define QXMLSTREAM_P_H
@@ -1046,7 +1048,7 @@ bool QXmlStreamReaderPrivate::parse()
dtdName.clear();
dtdPublicId.clear();
dtdSystemId.clear();
- // fall through
+ Q_FALLTHROUGH();
case QXmlStreamReader::Comment:
case QXmlStreamReader::Characters:
isCDATA = false;
@@ -1078,7 +1080,7 @@ bool QXmlStreamReaderPrivate::parse()
return false;
}
#endif
- // fall through
+ Q_FALLTHROUGH();
default:
clearTextBuffer();
;
@@ -1122,7 +1124,7 @@ bool QXmlStreamReaderPrivate::parse()
} else {
break;
}
- // fall through
+ Q_FALLTHROUGH();
case ~0U: {
token = EOF_SYMBOL;
if (!tagsDone && !inParseEntity) {
@@ -1336,7 +1338,7 @@ bool QXmlStreamReaderPrivate::parse()
case 17:
case 18:
dtdName = symString(3);
- // fall through
+ Q_FALLTHROUGH();
case 19:
case 20:
@@ -1478,7 +1480,7 @@ bool QXmlStreamReaderPrivate::parse()
if (entityDeclaration.parameter)
raiseWellFormedError(QXmlStream::tr("NDATA in parameter entity declaration."));
}
- //fall through
+ Q_FALLTHROUGH();
case 94:
case 95: {
@@ -1586,7 +1588,7 @@ bool QXmlStreamReaderPrivate::parse()
case 129:
isWhitespace = false;
- // fall through
+ Q_FALLTHROUGH();
case 130:
sym(1).len += fastScanContentCharList();
@@ -1758,7 +1760,7 @@ bool QXmlStreamReaderPrivate::parse()
case 236:
isEmptyElement = true;
- // fall through
+ Q_FALLTHROUGH();
case 237:
setType(QXmlStreamReader::StartElement);
diff --git a/src/corelib/xml/qxmlutils_p.h b/src/corelib/xml/qxmlutils_p.h
index d45ecb50b3..d8d25e0efe 100644
--- a/src/corelib/xml/qxmlutils_p.h
+++ b/src/corelib/xml/qxmlutils_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qstring.h>
QT_BEGIN_NAMESPACE