summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/Qt6AndroidMacros.cmake21
-rw-r--r--src/corelib/configure.cmake9
-rw-r--r--src/corelib/doc/qtcore.qdocconf7
-rw-r--r--src/corelib/doc/src/cmake/qt_add_android_dynamic_feature_java_source_dirs.qdoc30
-rw-r--r--src/corelib/doc/src/cmake/qt_add_android_permission.qdoc4
-rw-r--r--src/corelib/doc/src/qtcore.qdoc9
-rw-r--r--src/corelib/global/qcompilerdetection.h2
-rw-r--r--src/corelib/itemmodels/qrangemodel_impl.h96
-rw-r--r--src/corelib/kernel/qjniarray.h4
-rw-r--r--src/corelib/kernel/qjnienvironment.cpp8
-rw-r--r--src/corelib/kernel/qjnienvironment.h1
-rw-r--r--src/corelib/kernel/qjniobject.cpp135
-rw-r--r--src/corelib/kernel/qjniobject.h523
-rw-r--r--src/corelib/kernel/qmetacontainer.cpp8
-rw-r--r--src/corelib/kernel/qobject.cpp35
-rw-r--r--src/corelib/kernel/qpermissions.cpp6
-rw-r--r--src/corelib/platform/wasm/qstdweb.cpp113
-rw-r--r--src/corelib/platform/wasm/qstdweb_p.h81
-rw-r--r--src/corelib/time/qdatetime.cpp12
-rw-r--r--src/corelib/tools/qflatmap_p.h54
-rw-r--r--src/dbus/qt_attribution.json8
-rw-r--r--src/gui/accessible/linux/qspimatchrulematcher.cpp9
-rw-r--r--src/gui/configure.cmake40
-rw-r--r--src/gui/image/qppmhandler.cpp69
-rw-r--r--src/gui/painting/qcolorspace.cpp2
-rw-r--r--src/gui/text/qfont.cpp4
-rw-r--r--src/gui/text/qrawfont.cpp9
-rw-r--r--src/gui/text/qrawfont.h13
-rw-r--r--src/network/access/http2/http2frames.cpp3
-rw-r--r--src/network/access/http2/http2protocol.cpp3
-rw-r--r--src/network/access/qhttp2connection.cpp118
-rw-r--r--src/network/access/qhttp2connection_p.h6
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp4
-rw-r--r--src/network/access/qhttpnetworkheader.cpp2
-rw-r--r--src/network/access/qnetworkaccesscachebackend_p.h2
-rw-r--r--src/network/access/qnetworkreply.cpp4
-rw-r--r--src/network/access/qnetworkrequest.cpp1
-rw-r--r--src/network/configure.cmake6
-rw-r--r--src/network/socket/qlocalsocket_unix.cpp4
-rw-r--r--src/network/ssl/qsslsocket.cpp4
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemtrayicon.h2
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/dmabuf-server/dmabufserverbufferintegration.h6
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drmeglserverbufferintegration.h6
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/shm-emulation-server/shmserverbufferintegration.h6
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/vulkan-server/vulkanserverbufferintegration.h6
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h16
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglinclude_p.h17
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglwindow_p.h16
-rw-r--r--src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h16
-rw-r--r--src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h5
-rw-r--r--src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h5
-rw-r--r--src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h4
-rw-r--r--src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h20
-rw-r--r--src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h20
-rw-r--r--src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h5
-rw-r--r--src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h16
-rw-r--r--src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h20
-rw-r--r--src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h16
-rw-r--r--src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1_p.h17
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputcontext.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassdescription.cpp124
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassdescription.h17
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassregistry.cpp54
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassregistry.h6
-rw-r--r--src/plugins/sqldrivers/configure.cmake17
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style.cpp38
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style_p.h2
-rw-r--r--src/widgets/accessible/qaccessiblemenu.cpp5
-rw-r--r--src/widgets/accessible/qaccessiblewidget.cpp5
-rw-r--r--src/widgets/accessible/rangecontrols.cpp12
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp6
-rw-r--r--src/widgets/dialogs/qsidebar.cpp5
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp6
-rw-r--r--src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicssceneindex.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp6
-rw-r--r--src/widgets/itemviews/qcolumnviewgrip.cpp15
-rw-r--r--src/widgets/itemviews/qlistview.cpp6
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp6
-rw-r--r--src/widgets/itemviews/qtreeview.cpp6
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp6
-rw-r--r--src/widgets/kernel/qapplication.cpp6
-rw-r--r--src/widgets/kernel/qlayout.cpp6
-rw-r--r--src/widgets/kernel/qwidgetrepaintmanager.cpp12
-rw-r--r--src/widgets/util/qflickgesture.cpp6
-rw-r--r--src/widgets/widgets/qcombobox.cpp6
-rw-r--r--src/widgets/widgets/qlabel.cpp6
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp6
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp6
89 files changed, 1367 insertions, 735 deletions
diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake
index 6a83e947146..be362ba1925 100644
--- a/src/corelib/Qt6AndroidMacros.cmake
+++ b/src/corelib/Qt6AndroidMacros.cmake
@@ -106,6 +106,27 @@ function(qt6_add_android_dynamic_features target)
endif()
endfunction()
+
+function(qt_add_android_dynamic_feature_java_source_dirs)
+ qt6_add_android_dynamic_feature_java_source_dirs(${ARGV})
+endfunction()
+
+# Add java source directories for dynamic feature. Intermediate solution until java library
+# support exists.
+function(qt6_add_android_dynamic_feature_java_source_dirs target)
+
+ set(opt_args "")
+ set(single_args "")
+ set(multi_args
+ SOURCE_DIRS
+ )
+ cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
+ if(arg_SOURCE_DIRS)
+ set_property(TARGET ${target} APPEND PROPERTY
+ _qt_android_gradle_java_source_dirs ${arg_SOURCE_DIRS})
+ endif()
+endfunction()
+
# Generate the deployment settings json file for a cmake target.
function(qt6_android_generate_deployment_settings target)
# Information extracted from mkspecs/features/android/android_deployment_settings.prf
diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake
index edcfba0f6ce..08908082991 100644
--- a/src/corelib/configure.cmake
+++ b/src/corelib/configure.cmake
@@ -31,7 +31,10 @@ qt_find_package_extend_sbom(TARGETS GLIB2::GLIB2
LICENSE_EXPRESSION "LGPL-2.1-or-later"
)
qt_find_package(ICU 50.1 COMPONENTS i18n uc data PROVIDED_TARGETS ICU::i18n ICU::uc ICU::data
- MODULE_NAME core QMAKE_LIB icu)
+ MODULE_NAME core QMAKE_LIB icu
+ VCPKG_PORT icu
+ VCPKG_PLATFORM !windows
+)
if(QT_FEATURE_dlopen)
qt_add_qmake_lib_dependency(icu libdl)
@@ -49,7 +52,9 @@ qt_find_package_extend_sbom(TARGETS Libb2::Libb2
qt_find_package(WrapRt MODULE
PROVIDED_TARGETS WrapRt::WrapRt MODULE_NAME core QMAKE_LIB librt)
qt_find_package(WrapSystemPCRE2 10.20 MODULE
- PROVIDED_TARGETS WrapSystemPCRE2::WrapSystemPCRE2 MODULE_NAME core QMAKE_LIB pcre2)
+ PROVIDED_TARGETS WrapSystemPCRE2::WrapSystemPCRE2 MODULE_NAME core QMAKE_LIB pcre2
+ VCPKG_PORT pcre2
+)
set_package_properties(WrapPCRE2 PROPERTIES TYPE REQUIRED)
if((QNX) OR QT_FIND_ALL_PACKAGES_ALWAYS)
qt_find_package(PPS MODULE PROVIDED_TARGETS PPS::PPS MODULE_NAME core QMAKE_LIB pps)
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index d2b386373a0..b3e4e9d30a9 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -21,7 +21,7 @@ qhp.QtCore.virtualFolder = qtcore
qhp.QtCore.indexTitle = Qt Core
qhp.QtCore.indexRoot =
-qhp.QtCore.subprojects = manual classes
+qhp.QtCore.subprojects = manual examples classes
qhp.QtCore.subprojects.manual.title = Qt Core
qhp.QtCore.subprojects.manual.indexTitle = Qt Core module topics
qhp.QtCore.subprojects.manual.type = manual
@@ -31,6 +31,11 @@ qhp.QtCore.subprojects.classes.indexTitle = Qt Core C++ Classes
qhp.QtCore.subprojects.classes.selectors = class fake:headerfile
qhp.QtCore.subprojects.classes.sortPages = true
+qhp.QtCore.subprojects.examples.title = Examples
+qhp.QtCore.subprojects.examples.indexTitle = Qt Core Examples
+qhp.QtCore.subprojects.examples.selectors = example
+qhp.QtCore.subprojects.examples.sortPages = true
+
tagfile = ../../../doc/qtcore/qtcore.tags
# Make QtCore depend on all doc modules; this ensures complete inheritance
diff --git a/src/corelib/doc/src/cmake/qt_add_android_dynamic_feature_java_source_dirs.qdoc b/src/corelib/doc/src/cmake/qt_add_android_dynamic_feature_java_source_dirs.qdoc
new file mode 100644
index 00000000000..cf670110cab
--- /dev/null
+++ b/src/corelib/doc/src/cmake/qt_add_android_dynamic_feature_java_source_dirs.qdoc
@@ -0,0 +1,30 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+\page qt_add_android_dynamic_feature_java_source_dirs.html
+\ingroup cmake-commands-qtcore
+
+\title qt_add_android_dynamic_feature_java_source_dirs
+\keyword qt6_add_android_dynamic_feature_java_source_dirs
+
+\summary {Adds Java source directories to a dynamic feature build.}
+
+\include cmake-find-package-core.qdocinc
+
+\cmakecommandsince 6.11
+
+\section1 Synopsis
+
+\badcode
+qt_add_android_dynamic_feature_java_source_dirs(target [SOURCE_DIRS <directory1> <directory2> ...])
+\endcode
+
+\versionlessCMakeCommandsNote qt6_add_android_dynamic_feature_java_source_dirs()
+
+\section1 Description
+
+The command adds extra Java/Kotlin source directories to the \c {target}
+executable when building the executable app with dynamic feature functionality.
+To be used in conjunction with qt6_add_android_dynamic_features().
+*/
diff --git a/src/corelib/doc/src/cmake/qt_add_android_permission.qdoc b/src/corelib/doc/src/cmake/qt_add_android_permission.qdoc
index 68fe6a8e5cc..8fa6c2bb6d7 100644
--- a/src/corelib/doc/src/cmake/qt_add_android_permission.qdoc
+++ b/src/corelib/doc/src/cmake/qt_add_android_permission.qdoc
@@ -14,6 +14,10 @@
\cmakecommandsince 6.9
+\note When using this API, the \c{<!-- %%INSERT_PERMISSIONS -->} tag must be present
+in the AndroidManifest.xml. For further information on the use of this tag,
+see \l {Qt Permissions and Features}
+
\section1 Synopsis
\badcode
diff --git a/src/corelib/doc/src/qtcore.qdoc b/src/corelib/doc/src/qtcore.qdoc
index ec5fa564639..fbcd02aeea5 100644
--- a/src/corelib/doc/src/qtcore.qdoc
+++ b/src/corelib/doc/src/qtcore.qdoc
@@ -31,3 +31,12 @@
target_link_libraries(mytarget PRIVATE Qt6::CorePrivate)
\endcode
*/
+
+/*!
+ \group corelib_examples
+ \title Qt Core Examples
+
+ \brief Examples for the Qt Core.
+
+ To learn how to use features of the Qt Core module, see examples:
+*/
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 7bb2e5b04ef..0b42af7686c 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1446,7 +1446,7 @@ QT_WARNING_DISABLE_MSVC(4355) /* 'this' : used in base member initializer list *
QT_WARNING_DISABLE_MSVC(4710) /* function not inlined */
QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc */
# elif defined(Q_CC_CLANG_ONLY)
-# if Q_CC_CLANG >= 2100
+# if __has_warning("-Wcharacter-conversion")
QT_WARNING_DISABLE_CLANG("-Wcharacter-conversion") /* until https://github.com/llvm/llvm-project/issues/163719 is fixed */
# endif
# elif defined(Q_CC_BOR)
diff --git a/src/corelib/itemmodels/qrangemodel_impl.h b/src/corelib/itemmodels/qrangemodel_impl.h
index 70552cbfe05..5ad7dd08059 100644
--- a/src/corelib/itemmodels/qrangemodel_impl.h
+++ b/src/corelib/itemmodels/qrangemodel_impl.h
@@ -28,7 +28,7 @@
#include <functional>
#include <iterator>
#include <type_traits>
-#include <QtCore/q20type_traits.h>
+#include <QtCore/qxptype_traits.h>
#include <tuple>
#include <QtCore/q23utility.h>
@@ -109,14 +109,17 @@ namespace QRangeModelDetails
using wrapped_t = std::remove_pointer_t<decltype(pointerTo(std::declval<T&>()))>;
template <typename T>
- using is_wrapped = std::negation<std::is_same<wrapped_t<T>, std::remove_reference_t<T>>>;
+ using is_wrapped = std::negation<std::is_same<
+ QRangeModelDetails::wrapped_t<T>, std::remove_reference_t<T>
+ >>;
template <typename T, typename = void>
struct tuple_like : std::false_type {};
template <typename T, std::size_t N>
struct tuple_like<std::array<T, N>> : std::false_type {};
template <typename T>
- struct tuple_like<T, std::void_t<std::tuple_element_t<0, wrapped_t<T>>>> : std::true_type {};
+ struct tuple_like<T, std::void_t<std::tuple_element_t<0, QRangeModelDetails::wrapped_t<T>>>>
+ : std::true_type {};
template <typename T>
[[maybe_unused]] static constexpr bool tuple_like_v = tuple_like<T>::value;
@@ -132,7 +135,7 @@ namespace QRangeModelDetails
template <typename T, typename = void>
struct has_metaobject : std::false_type {};
template <typename T>
- struct has_metaobject<T, std::void_t<decltype(wrapped_t<T>::staticMetaObject)>>
+ struct has_metaobject<T, std::void_t<decltype(QRangeModelDetails::wrapped_t<T>::staticMetaObject)>>
: std::true_type {};
template <typename T>
[[maybe_unused]] static constexpr bool has_metaobject_v = has_metaobject<T>::value;
@@ -235,14 +238,16 @@ namespace QRangeModelDetails
: std::true_type
{};
- // we use std::rotate in moveRows/Columns, which requires std::swap
+ // we use std::rotate in moveRows/Columns, which requires std::swap and the
+ // iterators to be at least a forward iterator
template <typename It, typename = void>
struct test_rotate : std::false_type {};
template <typename It>
struct test_rotate<It, std::void_t<decltype(std::swap(*std::declval<It>(),
*std::declval<It>()))>>
- : std::true_type
+ : std::is_base_of<std::forward_iterator_tag,
+ typename std::iterator_traits<It>::iterator_category>
{};
template <typename C, typename = void>
@@ -492,12 +497,12 @@ namespace QRangeModelDetails
template <typename T>
[[maybe_unused]] static constexpr int static_size_v =
- row_traits<std::remove_cv_t<wrapped_t<T>>>::static_size;
+ row_traits<std::remove_cv_t<QRangeModelDetails::wrapped_t<T>>>::static_size;
template <typename Range>
struct ListProtocol
{
- using row_type = typename range_traits<wrapped_t<Range>>::value_type;
+ using row_type = typename range_traits<QRangeModelDetails::wrapped_t<Range>>::value_type;
template <typename R = row_type>
auto newRow() -> decltype(R{}) { return R{}; }
@@ -506,16 +511,16 @@ namespace QRangeModelDetails
template <typename Range>
struct TableProtocol
{
- using row_type = typename range_traits<wrapped_t<Range>>::value_type;
+ using row_type = typename range_traits<QRangeModelDetails::wrapped_t<Range>>::value_type;
template <typename R = row_type,
std::enable_if_t<std::conjunction_v<std::is_destructible<wrapped_t<R>>,
is_owning_or_raw_pointer<R>>, bool> = true>
- auto newRow() -> decltype(R(new wrapped_t<R>)) {
+ auto newRow() -> decltype(R(new QRangeModelDetails::wrapped_t<R>)) {
if constexpr (is_any_of<R, std::shared_ptr>())
- return std::make_shared<wrapped_t<R>>();
+ return std::make_shared<QRangeModelDetails::wrapped_t<R>>();
else
- return R(new wrapped_t<R>);
+ return R(new QRangeModelDetails::wrapped_t<R>);
}
template <typename R = row_type,
@@ -527,7 +532,8 @@ namespace QRangeModelDetails
auto deleteRow(R&& row) -> decltype(delete row) { delete row; }
};
- template <typename Range, typename R = typename range_traits<wrapped_t<Range>>::value_type>
+ template <typename Range,
+ typename R = typename range_traits<QRangeModelDetails::wrapped_t<Range>>::value_type>
using table_protocol_t = std::conditional_t<static_size_v<R> == 0 && !has_metaobject_v<R>,
ListProtocol<Range>, TableProtocol<Range>>;
@@ -562,35 +568,30 @@ namespace QRangeModelDetails
}
};
- template <typename P, typename R, typename = void>
- struct protocol_parentRow : std::false_type {};
template <typename P, typename R>
- struct protocol_parentRow<P, R,
- std::void_t<decltype(std::declval<P&>().parentRow(std::declval<wrapped_t<R>&>()))>>
- : std::true_type {};
+ using protocol_parentRow_test = decltype(std::declval<P&>()
+ .parentRow(std::declval<QRangeModelDetails::wrapped_t<R>&>()));
+ template <typename P, typename R>
+ using protocol_parentRow = qxp::is_detected<protocol_parentRow_test, P, R>;
- template <typename P, typename R, typename = void>
- struct protocol_childRows : std::false_type {};
template <typename P, typename R>
- struct protocol_childRows<P, R,
- std::void_t<decltype(std::declval<P&>().childRows(std::declval<wrapped_t<R>&>()))>>
- : std::true_type {};
+ using protocol_childRows_test = decltype(std::declval<P&>()
+ .childRows(std::declval<QRangeModelDetails::wrapped_t<R>&>()));
+ template <typename P, typename R>
+ using protocol_childRows = qxp::is_detected<protocol_childRows_test, P, R>;
- template <typename P, typename R, typename = void>
- struct protocol_setParentRow : std::false_type {};
template <typename P, typename R>
- struct protocol_setParentRow<P, R,
- std::void_t<decltype(std::declval<P&>().setParentRow(std::declval<wrapped_t<R>&>(),
- std::declval<wrapped_t<R>*>()))>>
- : std::true_type {};
+ using protocol_setParentRow_test = decltype(std::declval<P&>()
+ .setParentRow(std::declval<QRangeModelDetails::wrapped_t<R>&>(),
+ std::declval<QRangeModelDetails::wrapped_t<R>*>()));
+ template <typename P, typename R>
+ using protocol_setParentRow = qxp::is_detected<protocol_setParentRow_test, P, R>;
- template <typename P, typename R, typename = void>
- struct protocol_mutable_childRows : std::false_type {};
template <typename P, typename R>
- struct protocol_mutable_childRows<P, R,
- std::void_t<decltype(refTo(std::declval<P&>().childRows(std::declval<wrapped_t<R>&>()))
- = {}) >>
- : std::true_type {};
+ using protocol_mutable_childRows_test = decltype(refTo(std::declval<P&>()
+ .childRows(std::declval<wrapped_t<R>&>())) = {});
+ template <typename P, typename R>
+ using protocol_mutable_childRows = qxp::is_detected<protocol_mutable_childRows_test, P, R>;
template <typename P, typename = void>
struct protocol_newRow : std::false_type {};
@@ -618,20 +619,23 @@ namespace QRangeModelDetails
> : std::true_type {};
template <typename Range>
- using if_table_range = std::enable_if_t<std::conjunction_v<is_range<wrapped_t<Range>>,
- std::negation<is_tree_range<wrapped_t<Range>>>>,
- bool>;
+ using if_table_range = std::enable_if_t<std::conjunction_v<
+ is_range<QRangeModelDetails::wrapped_t<Range>>,
+ std::negation<is_tree_range<QRangeModelDetails::wrapped_t<Range>>>
+ >, bool>;
template <typename Range, typename Protocol = DefaultTreeProtocol<Range>>
- using if_tree_range = std::enable_if_t<std::conjunction_v<is_range<wrapped_t<Range>>,
- is_tree_range<wrapped_t<Range>, wrapped_t<Protocol>>>,
- bool>;
+ using if_tree_range = std::enable_if_t<std::conjunction_v<
+ is_range<QRangeModelDetails::wrapped_t<Range>>,
+ is_tree_range<QRangeModelDetails::wrapped_t<Range>,
+ QRangeModelDetails::wrapped_t<Protocol>>
+ >, bool>;
template <typename Range, typename Protocol>
struct protocol_traits
{
- using protocol = wrapped_t<Protocol>;
- using row = typename range_traits<wrapped_t<Range>>::value_type;
+ using protocol = QRangeModelDetails::wrapped_t<Protocol>;
+ using row = typename range_traits<QRangeModelDetails::wrapped_t<Range>>::value_type;
static constexpr bool is_tree = std::conjunction_v<protocol_parentRow<protocol, row>,
protocol_childRows<protocol, row>>;
static constexpr bool is_list = static_size_v<row> == 0
@@ -718,7 +722,7 @@ namespace QRangeModelDetails
PropertyData<has_metaobject_v<ItemType>,
std::is_base_of_v<QObject, std::remove_pointer_t<ItemType>>>
{
- using WrappedStorage = Storage<wrapped_t<ModelStorage>>;
+ using WrappedStorage = Storage<QRangeModelDetails::wrapped_t<ModelStorage>>;
using iterator = typename WrappedStorage::iterator;
using const_iterator = typename WrappedStorage::const_iterator;
@@ -990,8 +994,8 @@ protected:
using std::distance;
#endif
using container_type = std::conditional_t<range_traits<C>::has_cbegin,
- const wrapped_t<C>,
- wrapped_t<C>>;
+ const QRangeModelDetails::wrapped_t<C>,
+ QRangeModelDetails::wrapped_t<C>>;
container_type& container = const_cast<container_type &>(refTo(c));
return int(distance(std::begin(container), std::end(container)));
}
diff --git a/src/corelib/kernel/qjniarray.h b/src/corelib/kernel/qjniarray.h
index 13349688d20..97d0cd37682 100644
--- a/src/corelib/kernel/qjniarray.h
+++ b/src/corelib/kernel/qjniarray.h
@@ -872,7 +872,7 @@ auto QJniArrayBase::makeArray(List &&list, NewFn &&newArray, SetFn &&setRegion)
const size_type length = size_type(std::size(list));
JNIEnv *env = QJniEnvironment::getJniEnv();
auto localArray = (env->*newArray)(length);
- if (QJniEnvironment::checkAndClearExceptions(env)) {
+ if (env->ExceptionCheck()) {
if (localArray)
env->DeleteLocalRef(localArray);
return QJniArray<ElementType>();
@@ -916,7 +916,7 @@ auto QJniArrayBase::makeObjectArray(List &&list)
elementClass = env->GetObjectClass(*std::begin(list));
}
auto localArray = env->NewObjectArray(length, elementClass, nullptr);
- if (QJniEnvironment::checkAndClearExceptions(env)) {
+ if (env->ExceptionCheck()) {
if (localArray)
env->DeleteLocalRef(localArray);
return ResultType();
diff --git a/src/corelib/kernel/qjnienvironment.cpp b/src/corelib/kernel/qjnienvironment.cpp
index b4f8497ddda..1ee658fd18d 100644
--- a/src/corelib/kernel/qjnienvironment.cpp
+++ b/src/corelib/kernel/qjnienvironment.cpp
@@ -559,4 +559,12 @@ bool QJniEnvironment::checkAndClearExceptions(JNIEnv *env, QJniEnvironment::Outp
return false;
}
+/*!
+ Returns the stack trace that resulted in \a exception being thrown.
+*/
+QStringList QJniEnvironment::stackTrace(jthrowable exception)
+{
+ return exceptionMessage(getJniEnv(), exception).split(u'\n');
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qjnienvironment.h b/src/corelib/kernel/qjnienvironment.h
index b473f75bed1..a5f3700b1f0 100644
--- a/src/corelib/kernel/qjnienvironment.h
+++ b/src/corelib/kernel/qjnienvironment.h
@@ -89,6 +89,7 @@ public:
static bool checkAndClearExceptions(JNIEnv *env, OutputMode outputMode = OutputMode::Verbose);
static JNIEnv *getJniEnv();
+ static QStringList stackTrace(jthrowable exception);
private:
Q_DISABLE_COPY_MOVE(QJniEnvironment)
diff --git a/src/corelib/kernel/qjniobject.cpp b/src/corelib/kernel/qjniobject.cpp
index 8f3da9a8595..59117bd01d4 100644
--- a/src/corelib/kernel/qjniobject.cpp
+++ b/src/corelib/kernel/qjniobject.cpp
@@ -348,7 +348,10 @@ static inline QByteArray cacheKey(Args &&...args)
return (QByteArrayView(":") + ... + QByteArrayView(args));
}
-typedef QHash<QByteArray, jclass> JClassHash;
+struct JClassHash : QHash<QByteArray, jclass>
+{
+ jmethodID loadClassMethod = 0;
+};
Q_GLOBAL_STATIC(JClassHash, cachedClasses)
Q_GLOBAL_STATIC(QReadWriteLock, cachedClassesLock)
@@ -391,29 +394,22 @@ bool QJniObjectPrivate::isJString(JNIEnv *env) const
*/
static QJniObject getCleanJniObject(jobject object, JNIEnv *env)
{
- if (QJniEnvironment::checkAndClearExceptions(env) || !object) {
- if (object)
- env->DeleteLocalRef(object);
+ if (!object || env->ExceptionCheck())
return QJniObject();
- }
- QJniObject res(object);
- env->DeleteLocalRef(object);
- return res;
+ return QJniObject::fromLocalRef(object);
}
-/*!
- \internal
- \a className must be slash-encoded
-*/
-jclass QtAndroidPrivate::findClass(const char *className, JNIEnv *env)
+namespace {
+
+jclass loadClassHelper(const QByteArray &className, JNIEnv *env)
{
Q_ASSERT(env);
QByteArray classNameArray(className);
#ifdef QT_DEBUG
if (classNameArray.contains('.')) {
qWarning("QtAndroidPrivate::findClass: className '%s' should use slash separators!",
- className);
+ className.constData());
}
#endif
classNameArray.replace('.', '/');
@@ -442,21 +438,40 @@ jclass QtAndroidPrivate::findClass(const char *className, JNIEnv *env)
if (!clazz) {
// Wrong class loader, try our own
- QJniObject classLoader(QtAndroidPrivate::classLoader());
- if (!classLoader.isValid())
+ jobject classLoader = QtAndroidPrivate::classLoader();
+ if (!classLoader)
return nullptr;
+ if (!cachedClasses->loadClassMethod) {
+ jclass classLoaderClass = env->GetObjectClass(classLoader);
+ if (!classLoaderClass)
+ return nullptr;
+ cachedClasses->loadClassMethod =
+ env->GetMethodID(classLoaderClass,
+ "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
+ env->DeleteLocalRef(classLoaderClass);
+ if (!cachedClasses->loadClassMethod) {
+ qCritical("Couldn't find the 'loadClass' method in the Qt class loader");
+ return nullptr;
+ }
+ }
+
// ClassLoader::loadClass on the other hand wants the binary name of the class,
// e.g. dot-separated. In testing it works also with /, but better to stick to
// the specification.
const QString binaryClassName = QString::fromLatin1(className).replace(u'/', u'.');
- jstring classNameObject = env->NewString(reinterpret_cast<const jchar*>(binaryClassName.constData()),
- binaryClassName.length());
- QJniObject classObject = classLoader.callMethod<jclass>("loadClass", classNameObject);
+ jstring classNameObject = env->NewString(binaryClassName.utf16(), binaryClassName.length());
+ jobject classObject = env->CallObjectMethod(classLoader,
+ cachedClasses->loadClassMethod,
+ classNameObject);
env->DeleteLocalRef(classNameObject);
- if (!QJniEnvironment::checkAndClearExceptions(env) && classObject.isValid())
- clazz = static_cast<jclass>(env->NewGlobalRef(classObject.object()));
+ if (classObject && !env->ExceptionCheck()) {
+ clazz = static_cast<jclass>(env->NewGlobalRef(classObject));
+ env->DeleteLocalRef(classObject);
+ }
+ // Clearing the exception is the caller's responsibility (see
+ // QtAndroidPrivate::findClass()) and QJniObject::loadClass{KeepExceptions}
}
if (clazz)
@@ -465,11 +480,32 @@ jclass QtAndroidPrivate::findClass(const char *className, JNIEnv *env)
return clazz;
}
+} // unnamed namespace
+
+/*!
+ \internal
+ \a className must be slash-encoded
+*/
+jclass QtAndroidPrivate::findClass(const char *className, JNIEnv *env)
+{
+ jclass clazz = loadClassHelper(className, env);
+ if (!clazz)
+ QJniEnvironment::checkAndClearExceptions(env);
+ return clazz;
+}
+
jclass QJniObject::loadClass(const QByteArray &className, JNIEnv *env)
{
return QtAndroidPrivate::findClass(className, env);
}
+jclass QJniObject::loadClassKeepExceptions(const QByteArray &className, JNIEnv *env)
+{
+ return loadClassHelper(className, env);
+}
+
+
+
typedef QHash<QByteArray, jmethodID> JMethodIDHash;
Q_GLOBAL_STATIC(JMethodIDHash, cachedMethodID)
Q_GLOBAL_STATIC(QReadWriteLock, cachedMethodIDLock)
@@ -483,9 +519,6 @@ jmethodID QJniObject::getMethodID(JNIEnv *env,
jmethodID id = isStatic ? env->GetStaticMethodID(clazz, name, signature)
: env->GetMethodID(clazz, name, signature);
- if (QJniEnvironment::checkAndClearExceptions(env))
- return nullptr;
-
return id;
}
@@ -525,7 +558,8 @@ jmethodID QJniObject::getCachedMethodID(JNIEnv *env,
jmethodID id = getMethodID(env, clazz, name, signature, isStatic);
- cachedMethodID->insert(key, id);
+ if (id)
+ cachedMethodID->insert(key, id);
return id;
}
}
@@ -549,9 +583,6 @@ jfieldID QJniObject::getFieldID(JNIEnv *env,
jfieldID id = isStatic ? env->GetStaticFieldID(clazz, name, signature)
: env->GetFieldID(clazz, name, signature);
- if (QJniEnvironment::checkAndClearExceptions(env))
- return nullptr;
-
return id;
}
@@ -583,7 +614,8 @@ jfieldID QJniObject::getCachedFieldID(JNIEnv *env,
jfieldID id = getFieldID(env, clazz, name, signature, isStatic);
- cachedFieldID->insert(key, id);
+ if (id)
+ cachedFieldID->insert(key, id);
return id;
}
}
@@ -1008,15 +1040,15 @@ QJniObject QJniObject::callObjectMethod(const char *methodName, const char *sign
{
JNIEnv *env = jniEnv();
jmethodID id = getCachedMethodID(env, methodName, signature);
- if (id) {
- va_list args;
- va_start(args, signature);
- QJniObject res = getCleanJniObject(env->CallObjectMethodV(d->m_jobject, id, args), env);
- va_end(args);
- return res;
- }
+ va_list args;
+ va_start(args, signature);
+ // can't go back from variadic arguments to variadic templates
+ jobject object = id ? jniEnv()->CallObjectMethodV(javaObject(), id, args) : nullptr;
+ QJniObject res = getCleanJniObject(object, env);
+ va_end(args);
- return QJniObject();
+ QJniEnvironment::checkAndClearExceptions(env);
+ return res;
}
/*!
@@ -1150,7 +1182,7 @@ QJniObject QJniObject::callStaticObjectMethod(jclass clazz, jmethodID methodId,
*/
/*!
- \fn template <typename T> void QJniObject::setStaticField(const char *className, const char *fieldName, const char *signature, T value);
+ \fn template <typename Ret, typename Type> auto QJniObject::setStaticField(const char *className, const char *fieldName, const char *signature, Type value);
Sets the static field \a fieldName on the class \a className to \a value
using the setter with \a signature.
@@ -1158,7 +1190,7 @@ QJniObject QJniObject::callStaticObjectMethod(jclass clazz, jmethodID methodId,
*/
/*!
- \fn template <typename T> void QJniObject::setStaticField(jclass clazz, const char *fieldName, const char *signature, T value);
+ \fn template <typename Ret, typename Type> auto QJniObject::setStaticField(jclass clazz, const char *fieldName, const char *signature, Type value);
Sets the static field \a fieldName on the class \a clazz to \a value using
the setter with \a signature.
@@ -1196,19 +1228,19 @@ QJniObject QJniObject::callStaticObjectMethod(jclass clazz, jmethodID methodId,
*/
/*!
- \fn template <typename T> void QJniObject::setStaticField(const char *className, const char *fieldName, T value)
+ \fn template <typename Ret, typename Type> auto QJniObject::setStaticField(const char *className, const char *fieldName, Type value)
Sets the static field \a fieldName of the class \a className to \a value.
*/
/*!
- \fn template <typename T> void QJniObject::setStaticField(jclass clazz, const char *fieldName, T value)
+ \fn template <typename Ret, typename Type> auto QJniObject::setStaticField(jclass clazz, const char *fieldName, Type value)
Sets the static field \a fieldName of the class \a clazz to \a value.
*/
/*!
- \fn template <typename Klass, typename T> auto QJniObject::setStaticField(const char *fieldName, T value)
+ \fn template <typename Klass, typename Ret, typename Type> auto QJniObject::setStaticField(const char *fieldName, Type value)
Sets the static field \a fieldName of the class \c Klass to \a value.
@@ -1263,11 +1295,16 @@ QJniObject QJniObject::getStaticObjectField(jclass clazz, const char *fieldName,
{
JNIEnv *env = QJniEnvironment::getJniEnv();
jfieldID id = getFieldID(env, clazz, fieldName, signature, true);
- return getCleanJniObject(env->GetStaticObjectField(clazz, id), env);
+
+ const auto clearExceptions = qScopeGuard([env]{
+ QJniEnvironment::checkAndClearExceptions(env);
+ });
+
+ return getCleanJniObject(getStaticObjectFieldImpl(env, clazz, id), env);
}
/*!
- \fn template <typename T> void QJniObject::setField(const char *fieldName, const char *signature, T value)
+ \fn template <typename Ret, typename Type> void QJniObject::setField(const char *fieldName, const char *signature, Type value)
Sets the value of \a fieldName with \a signature to \a value.
@@ -1304,14 +1341,16 @@ QJniObject QJniObject::getObjectField(const char *fieldName, const char *signatu
{
JNIEnv *env = jniEnv();
jfieldID id = getCachedFieldID(env, fieldName, signature);
- if (!id)
- return QJniObject();
- return getCleanJniObject(env->GetObjectField(d->m_jobject, id), env);
+ const auto clearExceptions = qScopeGuard([env]{
+ QJniEnvironment::checkAndClearExceptions(env);
+ });
+
+ return getCleanJniObject(getObjectFieldImpl(env, id), env);
}
/*!
- \fn template <typename T> void QJniObject::setField(const char *fieldName, T value)
+ \fn template <typename Ret, typename Type> void QJniObject::setField(const char *fieldName, Type value)
Sets the value of \a fieldName to \a value.
diff --git a/src/corelib/kernel/qjniobject.h b/src/corelib/kernel/qjniobject.h
index 236a49544be..06dfc328b4b 100644
--- a/src/corelib/kernel/qjniobject.h
+++ b/src/corelib/kernel/qjniobject.h
@@ -27,10 +27,29 @@ struct StoresGlobalRefTest<T, std::void_t<decltype(std::declval<T>().object())>>
: std::is_same<decltype(std::declval<T>().object()), jobject>
{};
-template <typename ...Args>
+// detect if a type is std::expected-like
+template <typename R, typename = void>
+struct CallerHandlesException : std::false_type {
+ using value_type = R;
+};
+template <typename R>
+struct CallerHandlesException<R, std::void_t<typename R::unexpected_type,
+ typename R::value_type,
+ typename R::error_type>> : std::true_type
+{
+ using value_type = typename R::value_type;
+};
+
+template <typename ReturnType>
+static constexpr bool callerHandlesException = CallerHandlesException<ReturnType>::value;
+
+template <typename Ret, typename ...Args>
struct LocalFrame {
+ using ReturnType = Ret;
+
mutable JNIEnv *env;
bool hasFrame = false;
+
explicit LocalFrame(JNIEnv *env = nullptr) noexcept
: env(env)
{
@@ -52,9 +71,12 @@ struct LocalFrame {
env = QJniEnvironment::getJniEnv();
return env;
}
- bool checkAndClearExceptions()
+ bool checkAndClearExceptions() const
{
- return env ? QJniEnvironment::checkAndClearExceptions(env) : false;
+ if constexpr (callerHandlesException<ReturnType>)
+ return false;
+ else
+ return QJniEnvironment::checkAndClearExceptions(jniEnv());
}
template <typename T>
auto convertToJni(T &&value)
@@ -79,13 +101,46 @@ struct LocalFrame {
using Type = q20::remove_cvref_t<T>;
return QtJniTypes::Traits<Type>::convertFromJni(std::move(object));
}
+
+ template <typename T>
+ auto convertFromJni(jobject object);
+
+ auto makeResult()
+ {
+ if constexpr (callerHandlesException<ReturnType>) {
+ JNIEnv *env = jniEnv();
+ if (env->ExceptionCheck()) {
+ jthrowable exception = env->ExceptionOccurred();
+ env->ExceptionClear();
+ return ReturnType(typename ReturnType::unexpected_type(exception));
+ }
+ return ReturnType();
+ } else {
+ checkAndClearExceptions();
+ }
+ }
+
+ template <typename Value>
+ auto makeResult(Value &&value)
+ {
+ if constexpr (callerHandlesException<ReturnType>) {
+ auto maybeValue = makeResult();
+ if (maybeValue)
+ return ReturnType(std::forward<Value>(value));
+ return std::move(maybeValue);
+ } else {
+ checkAndClearExceptions();
+ return std::forward<Value>(value);
+ }
+ }
};
}
}
class Q_CORE_EXPORT QJniObject
{
- template <typename ...Args> using LocalFrame = QtJniTypes::Detail::LocalFrame<Args...>;
+ template <typename Ret, typename ...Args> using LocalFrame
+ = QtJniTypes::Detail::LocalFrame<Ret, Args...>;
public:
QJniObject();
@@ -97,12 +152,12 @@ public:
#endif
>
explicit QJniObject(const char *className, Args &&...args)
- : QJniObject(LocalFrame<Args...>{}, className, std::forward<Args>(args)...)
+ : QJniObject(LocalFrame<QJniObject, Args...>{}, className, std::forward<Args>(args)...)
{
}
private:
template<typename ...Args>
- explicit QJniObject(LocalFrame<Args...> localFrame, const char *className, Args &&...args)
+ explicit QJniObject(LocalFrame<QJniObject, Args...> localFrame, const char *className, Args &&...args)
: QJniObject(className, QtJniTypes::constructorSignature<Args...>().data(),
localFrame.convertToJni(std::forward<Args>(args))...)
{
@@ -130,13 +185,23 @@ public:
void swap(QJniObject &other) noexcept { d.swap(other.d); }
- template<typename Class, typename ...Args>
- static inline QJniObject construct(Args &&...args)
+ template<typename Class, typename ...Args
+#ifndef Q_QDOC
+ , QtJniTypes::IfValidSignatureTypes<Class, Args...> = true
+#endif
+ >
+ static inline auto construct(Args &&...args)
{
- LocalFrame<Args...> frame;
- return QJniObject(QtJniTypes::Traits<Class>::className().data(),
- QtJniTypes::constructorSignature<Args...>().data(),
- frame.convertToJni(std::forward<Args>(args))...);
+ LocalFrame<Class, Args...> frame;
+ jclass clazz = QJniObject::loadClassKeepExceptions(QtJniTypes::Traits<Class>::className().data(),
+ frame.jniEnv());
+ auto res = clazz
+ ? QJniObject(clazz, QtJniTypes::constructorSignature<Args...>().data(),
+ frame.convertToJni(std::forward<Args>(args))...)
+ : QtJniTypes::Detail::callerHandlesException<Class>
+ ? QJniObject(Qt::Initialization::Uninitialized)
+ : QJniObject();
+ return frame.makeResult(std::move(res));
}
jobject object() const;
@@ -149,47 +214,49 @@ public:
jclass objectClass() const;
QByteArray className() const;
- template <typename Ret = void, typename ...Args
+ template <typename ReturnType = void, typename ...Args
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<Ret> = true
+ , QtJniTypes::IfValidFieldType<ReturnType> = true
#endif
>
auto callMethod(const char *methodName, const char *signature, Args &&...args) const
{
- LocalFrame<Args...> frame(jniEnv());
+ using Ret = typename QtJniTypes::Detail::CallerHandlesException<ReturnType>::value_type;
+ LocalFrame<ReturnType, Args...> frame(jniEnv());
+ jmethodID id = getCachedMethodID(frame.jniEnv(), methodName, signature);
+
if constexpr (QtJniTypes::isObjectType<Ret>()) {
- return frame.template convertFromJni<Ret>(callObjectMethod(methodName, signature,
- frame.convertToJni(std::forward<Args>(args))...));
+ return frame.makeResult(frame.template convertFromJni<Ret>(callObjectMethodImpl(
+ id, frame.convertToJni(std::forward<Args>(args))...))
+ );
} else {
- jmethodID id = getCachedMethodID(frame.jniEnv(), methodName, signature);
if (id) {
if constexpr (std::is_same_v<Ret, void>) {
callVoidMethodV(frame.jniEnv(), id,
frame.convertToJni(std::forward<Args>(args))...);
- frame.checkAndClearExceptions();
} else {
Ret res{};
callMethodForType<Ret>(frame.jniEnv(), res, object(), id,
frame.convertToJni(std::forward<Args>(args))...);
- if (frame.checkAndClearExceptions())
- res = {};
- return res;
+ return frame.makeResult(res);
}
}
if constexpr (!std::is_same_v<Ret, void>)
- return Ret{};
+ return frame.makeResult(Ret{});
+ else
+ return frame.makeResult();
}
}
- template <typename Ret = void, typename ...Args
+ template <typename ReturnType = void, typename ...Args
#ifndef Q_QDOC
- , QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
+ , QtJniTypes::IfValidSignatureTypes<ReturnType, Args...> = true
#endif
>
auto callMethod(const char *methodName, Args &&...args) const
{
- constexpr auto signature = QtJniTypes::methodSignature<Ret, Args...>();
- return callMethod<Ret>(methodName, signature.data(), std::forward<Args>(args)...);
+ constexpr auto signature = QtJniTypes::methodSignature<ReturnType, Args...>();
+ return callMethod<ReturnType>(methodName, signature.data(), std::forward<Args>(args)...);
}
template <typename Ret, typename ...Args
@@ -201,9 +268,11 @@ public:
{
QtJniTypes::assertObjectType<Ret>();
constexpr auto signature = QtJniTypes::methodSignature<Ret, Args...>();
- LocalFrame<Args...> frame(jniEnv());
- return frame.template convertFromJni<Ret>(callObjectMethod(methodName, signature,
+ LocalFrame<Ret, Args...> frame(jniEnv());
+ auto object = frame.template convertFromJni<Ret>(callObjectMethod(methodName, signature,
frame.convertToJni(std::forward<Args>(args))...));
+ frame.checkAndClearExceptions();
+ return object;
}
QJniObject callObjectMethod(const char *methodName, const char *signature, ...) const;
@@ -211,90 +280,93 @@ public:
template <typename Ret = void, typename ...Args>
static auto callStaticMethod(const char *className, const char *methodName, const char *signature, Args &&...args)
{
- JNIEnv *env = QJniEnvironment::getJniEnv();
- jclass clazz = QJniObject::loadClass(className, env);
+ LocalFrame<Ret, Args...> frame;
+ jclass clazz = QJniObject::loadClass(className, frame.jniEnv());
return callStaticMethod<Ret>(clazz, methodName, signature, std::forward<Args>(args)...);
}
template <typename Ret = void, typename ...Args>
static auto callStaticMethod(jclass clazz, const char *methodName, const char *signature, Args &&...args)
{
- JNIEnv *env = QJniEnvironment::getJniEnv();
- jmethodID id = clazz ? getMethodID(env, clazz, methodName, signature, true)
+ LocalFrame<Ret, Args...> frame;
+ jmethodID id = clazz ? getMethodID(frame.jniEnv(), clazz, methodName, signature, true)
: 0;
return callStaticMethod<Ret>(clazz, id, std::forward<Args>(args)...);
}
- template <typename Ret = void, typename ...Args
+ template <typename ReturnType = void, typename ...Args
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<Ret> = true
+ , QtJniTypes::IfValidFieldType<ReturnType> = true
#endif
>
static auto callStaticMethod(jclass clazz, jmethodID methodId, Args &&...args)
{
- LocalFrame<Args...> frame;
+ using Ret = typename QtJniTypes::Detail::CallerHandlesException<ReturnType>::value_type;
+ LocalFrame<ReturnType, Args...> frame;
if constexpr (QtJniTypes::isObjectType<Ret>()) {
- return frame.template convertFromJni<Ret>(callStaticObjectMethod(clazz, methodId,
- frame.convertToJni(std::forward<Args>(args))...));
+ return frame.makeResult(frame.template convertFromJni<Ret>(callStaticObjectMethod(
+ clazz, methodId,
+ frame.convertToJni(std::forward<Args>(args))...))
+ );
} else {
if (clazz && methodId) {
if constexpr (std::is_same_v<Ret, void>) {
callStaticMethodForVoid(frame.jniEnv(), clazz, methodId,
frame.convertToJni(std::forward<Args>(args))...);
- frame.checkAndClearExceptions();
} else {
Ret res{};
callStaticMethodForType<Ret>(frame.jniEnv(), res, clazz, methodId,
frame.convertToJni(std::forward<Args>(args))...);
- if (frame.checkAndClearExceptions())
- res = {};
- return res;
+ return frame.makeResult(res);
}
}
if constexpr (!std::is_same_v<Ret, void>)
- return Ret{};
+ return frame.makeResult(Ret{});
+ else
+ return frame.makeResult();
}
}
- template <typename Ret = void, typename ...Args
+ template <typename ReturnType = void, typename ...Args
#ifndef Q_QDOC
- , QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
+ , QtJniTypes::IfValidSignatureTypes<ReturnType, Args...> = true
#endif
>
static auto callStaticMethod(const char *className, const char *methodName, Args &&...args)
{
- JNIEnv *env = QJniEnvironment::getJniEnv();
- jclass clazz = QJniObject::loadClass(className, env);
- const jmethodID id = clazz ? getMethodID(env, clazz, methodName,
+ using Ret = typename QtJniTypes::Detail::CallerHandlesException<ReturnType>::value_type;
+ LocalFrame<Ret, Args...> frame;
+ jclass clazz = QJniObject::loadClass(className, frame.jniEnv());
+ const jmethodID id = clazz ? getMethodID(frame.jniEnv(), clazz, methodName,
QtJniTypes::methodSignature<Ret, Args...>().data(), true)
: 0;
- return callStaticMethod<Ret>(clazz, id, std::forward<Args>(args)...);
+ return callStaticMethod<ReturnType>(clazz, id, std::forward<Args>(args)...);
}
- template <typename Ret = void, typename ...Args
+ template <typename ReturnType = void, typename ...Args
#ifndef Q_QDOC
- , QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
+ , QtJniTypes::IfValidSignatureTypes<ReturnType, Args...> = true
#endif
>
static auto callStaticMethod(jclass clazz, const char *methodName, Args &&...args)
{
- constexpr auto signature = QtJniTypes::methodSignature<Ret, Args...>();
- return callStaticMethod<Ret>(clazz, methodName, signature.data(), std::forward<Args>(args)...);
+ constexpr auto signature = QtJniTypes::methodSignature<ReturnType, Args...>();
+ return callStaticMethod<ReturnType>(clazz, methodName, signature.data(), std::forward<Args>(args)...);
}
- template <typename Klass, typename Ret = void, typename ...Args
+ template <typename Klass, typename ReturnType = void, typename ...Args
#ifndef Q_QDOC
- , QtJniTypes::IfValidSignatureTypes<Ret, Args...> = true
+ , QtJniTypes::IfValidSignatureTypes<ReturnType, Args...> = true
#endif
>
static auto callStaticMethod(const char *methodName, Args &&...args)
{
- JNIEnv *env = QJniEnvironment::getJniEnv();
+ LocalFrame<ReturnType, Args...> frame;
const jclass clazz = QJniObject::loadClass(QtJniTypes::Traits<Klass>::className().data(),
- env);
- const jmethodID id = clazz ? getMethodID(env, clazz, methodName,
- QtJniTypes::methodSignature<Ret, Args...>().data(), true)
+ frame.jniEnv());
+ const jmethodID id = clazz ? getMethodID(frame.jniEnv(), clazz, methodName,
+ QtJniTypes::methodSignature<ReturnType, Args...>().data(), true)
: 0;
- return callStaticMethod<Ret>(clazz, id, std::forward<Args>(args)...);
+ return callStaticMethod<ReturnType>(clazz, id, std::forward<Args>(args)...);
}
static QJniObject callStaticObjectMethod(const char *className, const char *methodName,
@@ -315,7 +387,7 @@ public:
{
QtJniTypes::assertObjectType<Ret>();
constexpr auto signature = QtJniTypes::methodSignature<Ret, Args...>();
- LocalFrame<Args...> frame;
+ LocalFrame<QJniObject, Args...> frame;
return frame.template convertFromJni<Ret>(callStaticObjectMethod(className, methodName, signature.data(),
frame.convertToJni(std::forward<Args>(args))...));
}
@@ -329,98 +401,95 @@ public:
{
QtJniTypes::assertObjectType<Ret>();
constexpr auto signature = QtJniTypes::methodSignature<Ret, Args...>();
- LocalFrame<Args...> frame;
+ LocalFrame<QJniObject, Args...> frame;
return frame.template convertFromJni<Ret>(callStaticObjectMethod(clazz, methodName, signature.data(),
- frame.convertToJni(std::forward<Args>(args))...));
+ frame.convertToJni(std::forward<Args>(args))...));
}
- template <typename T
+ template <typename Type
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<T> = true
+ , QtJniTypes::IfValidFieldType<Type> = true
#endif
>
auto getField(const char *fieldName) const
{
- LocalFrame<T> frame(jniEnv());
+ using T = typename QtJniTypes::Detail::CallerHandlesException<Type>::value_type;
+ LocalFrame<Type, T> frame(jniEnv());
+ constexpr auto signature = QtJniTypes::fieldSignature<T>();
+ jfieldID id = getCachedFieldID(frame.jniEnv(), fieldName, signature);
+
if constexpr (QtJniTypes::isObjectType<T>()) {
- return frame.template convertFromJni<T>(getObjectField<T>(fieldName));
+ return frame.makeResult(frame.template convertFromJni<T>(getObjectFieldImpl(
+ frame.jniEnv(), id))
+ );
} else {
T res{};
- constexpr auto signature = QtJniTypes::fieldSignature<T>();
- jfieldID id = getCachedFieldID(frame.jniEnv(), fieldName, signature);
- if (id) {
+ if (id)
getFieldForType<T>(frame.jniEnv(), res, object(), id);
- if (frame.checkAndClearExceptions())
- res = {};
- }
- return res;
+ return frame.makeResult(res);
}
}
- template <typename T
+ template <typename Klass, typename T
#ifndef Q_QDOC
, QtJniTypes::IfValidFieldType<T> = true
#endif
>
- static auto getStaticField(const char *className, const char *fieldName)
+ static auto getStaticField(const char *fieldName)
{
- LocalFrame<T> frame;
- if constexpr (QtJniTypes::isObjectType<T>()) {
- return frame.template convertFromJni<T>(getStaticObjectField<T>(className, fieldName));
- } else {
- jclass clazz = QJniObject::loadClass(className, frame.jniEnv());
- if (!clazz)
- return T{};
- return getStaticField<T>(clazz, fieldName);
- }
+ return getStaticField<T>(QtJniTypes::Traits<Klass>::className(), fieldName);
}
template <typename T
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<T> = true
+ , std::enable_if_t<QtJniTypes::isObjectType<T>(), bool> = true
#endif
>
- static auto getStaticField(jclass clazz, const char *fieldName)
+ QJniObject getObjectField(const char *fieldName) const
{
- LocalFrame<T> frame;
- if constexpr (QtJniTypes::isObjectType<T>()) {
- return frame.template convertFromJni<T>(getStaticObjectField<T>(clazz, fieldName));
- } else {
- T res{};
- constexpr auto signature = QtJniTypes::fieldSignature<T>();
- jfieldID id = getFieldID(frame.jniEnv(), clazz, fieldName, signature, true);
- if (id) {
- getStaticFieldForType<T>(frame.jniEnv(), res, clazz, id);
- if (frame.checkAndClearExceptions())
- res = {};
- }
- return res;
- }
+ constexpr auto signature = QtJniTypes::fieldSignature<T>();
+ return getObjectField(fieldName, signature);
}
- template <typename Klass, typename T
+ QJniObject getObjectField(const char *fieldName, const char *signature) const;
+
+ template <typename Type
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<T> = true
+ , QtJniTypes::IfValidFieldType<Type> = true
#endif
>
- static auto getStaticField(const char *fieldName)
+ static auto getStaticField(const char *className, const char *fieldName)
{
- return getStaticField<T>(QtJniTypes::Traits<Klass>::className(), fieldName);
+ using T = typename QtJniTypes::Detail::CallerHandlesException<Type>::value_type;
+ LocalFrame<Type, T> frame;
+ jclass clazz = QJniObject::loadClass(className, frame.jniEnv());
+ return getStaticField<Type>(clazz, fieldName);
}
- template <typename T
+ template <typename Type
#ifndef Q_QDOC
- , std::enable_if_t<QtJniTypes::isObjectType<T>(), bool> = true
+ , QtJniTypes::IfValidFieldType<Type> = true
#endif
>
- QJniObject getObjectField(const char *fieldName) const
+ static auto getStaticField(jclass clazz, const char *fieldName)
{
+ using T = typename QtJniTypes::Detail::CallerHandlesException<Type>::value_type;
+ LocalFrame<Type, T> frame;
constexpr auto signature = QtJniTypes::fieldSignature<T>();
- return getObjectField(fieldName, signature);
+ jfieldID id = clazz ? getFieldID(frame.jniEnv(), clazz, fieldName, signature, true)
+ : nullptr;
+ if constexpr (QtJniTypes::isObjectType<T>()) {
+ return frame.makeResult(frame.template convertFromJni<T>(getStaticObjectFieldImpl(
+ frame.jniEnv(), clazz, id))
+ );
+ } else {
+ T res{};
+ if (id)
+ getStaticFieldForType<T>(frame.jniEnv(), res, clazz, id);
+ return frame.makeResult(res);
+ }
}
- QJniObject getObjectField(const char *fieldName, const char *signature) const;
-
template <typename T
#ifndef Q_QDOC
, std::enable_if_t<QtJniTypes::isObjectType<T>(), bool> = true
@@ -450,114 +519,122 @@ public:
static QJniObject getStaticObjectField(jclass clazz, const char *fieldName,
const char *signature);
- template <typename T
+ template <typename Ret = void, typename Type
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<T> = true
+ , QtJniTypes::IfValidFieldType<Type> = true
#endif
>
- void setField(const char *fieldName, T value)
+ auto setField(const char *fieldName, Type value)
{
+ // handle old code explicitly specifying a non-return type for Ret
+ using T = std::conditional_t<!std::is_void_v<Ret> && !QtJniTypes::Detail::callerHandlesException<Ret>,
+ Ret, Type>;
+ LocalFrame<Ret, T> frame(jniEnv());
constexpr auto signature = QtJniTypes::fieldSignature<T>();
jfieldID id = getCachedFieldID(jniEnv(), fieldName, signature);
- if (id) {
+ if (id)
setFieldForType<T>(jniEnv(), object(), id, value);
- QJniEnvironment::checkAndClearExceptions(jniEnv());
- }
+ return frame.makeResult();
}
- template <typename T
+ template <typename Ret = void, typename Type
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<T> = true
+ , QtJniTypes::IfValidFieldType<Type> = true
#endif
>
- void setField(const char *fieldName, const char *signature, T value)
- {
- jfieldID id = getCachedFieldID(jniEnv(), fieldName, signature);
- if (id) {
+ auto setField(const char *fieldName, const char *signature, Type value)
+ {
+ // handle old code explicitly specifying a non-return type for Ret
+ using T = std::conditional_t<!std::is_void_v<Ret> && !QtJniTypes::Detail::callerHandlesException<Ret>,
+ Ret, Type>;
+ LocalFrame<Ret, T> frame(jniEnv());
+ jfieldID id = getCachedFieldID(frame.jniEnv(), fieldName, signature);
+ if (id)
setFieldForType<T>(jniEnv(), object(), id, value);
- QJniEnvironment::checkAndClearExceptions(jniEnv());
- }
+ return frame.makeResult();
}
- template <typename T
+ template <typename Ret = void, typename Type
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<T> = true
+ , QtJniTypes::IfValidFieldType<Type> = true
#endif
>
- static void setStaticField(const char *className, const char *fieldName, T value)
- {
- LocalFrame<T> frame;
- jclass clazz = QJniObject::loadClass(className, frame.jniEnv());
- if (!clazz)
- return;
-
- constexpr auto signature = QtJniTypes::fieldSignature<T>();
- jfieldID id = getCachedFieldID(frame.jniEnv(), clazz, className, fieldName,
- signature, true);
- if (!id)
- return;
-
- setStaticFieldForType<T>(frame.jniEnv(), clazz, id, value);
- frame.checkAndClearExceptions();
+ static auto setStaticField(const char *className, const char *fieldName, Type value)
+ {
+ // handle old code explicitly specifying a non-return type for Ret
+ using T = std::conditional_t<!std::is_void_v<Ret> && !QtJniTypes::Detail::callerHandlesException<Ret>,
+ Ret, Type>;
+ LocalFrame<Ret, T> frame;
+ if (jclass clazz = QJniObject::loadClass(className, frame.jniEnv())) {
+ constexpr auto signature = QtJniTypes::fieldSignature<q20::remove_cvref_t<T>>();
+ jfieldID id = getCachedFieldID(frame.jniEnv(), clazz, className, fieldName,
+ signature, true);
+ if (id)
+ setStaticFieldForType<T>(frame.jniEnv(), clazz, id, value);
+ }
+ return frame.makeResult();
}
- template <typename T
+ template <typename Ret = void, typename Type
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<T> = true
+ , QtJniTypes::IfValidFieldType<Type> = true
#endif
>
- static void setStaticField(const char *className, const char *fieldName,
- const char *signature, T value)
- {
- JNIEnv *env = QJniEnvironment::getJniEnv();
- jclass clazz = QJniObject::loadClass(className, env);
-
- if (!clazz)
- return;
-
- jfieldID id = getCachedFieldID(env, clazz, className, fieldName,
- signature, true);
- if (id) {
- setStaticFieldForType<T>(env, clazz, id, value);
- QJniEnvironment::checkAndClearExceptions(env);
+ static auto setStaticField(const char *className, const char *fieldName,
+ const char *signature, Type value)
+ {
+ // handle old code explicitly specifying a non-return type for Ret
+ using T = std::conditional_t<!std::is_void_v<Ret> && !QtJniTypes::Detail::callerHandlesException<Ret>,
+ Ret, Type>;
+ LocalFrame<Ret, T> frame;
+ if (jclass clazz = QJniObject::loadClass(className, frame.jniEnv())) {
+ jfieldID id = getCachedFieldID(frame.jniEnv(), clazz, className, fieldName,
+ signature, true);
+ if (id)
+ setStaticFieldForType<T>(frame.jniEnv(), clazz, id, value);
}
+ return frame.makeResult();
}
- template <typename T
+ template <typename Ret = void, typename Type
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<T> = true
+ , QtJniTypes::IfValidFieldType<Type> = true
#endif
>
- static void setStaticField(jclass clazz, const char *fieldName,
- const char *signature, T value)
+ static auto setStaticField(jclass clazz, const char *fieldName,
+ const char *signature, Type value)
{
- JNIEnv *env = QJniEnvironment::getJniEnv();
- jfieldID id = getFieldID(env, clazz, fieldName, signature, true);
+ // handle old code explicitly specifying a non-return type for Ret
+ using T = std::conditional_t<!std::is_void_v<Ret> && !QtJniTypes::Detail::callerHandlesException<Ret>,
+ Ret, Type>;
+ LocalFrame<Ret, T> frame;
+ jfieldID id = getFieldID(frame.jniEnv(), clazz, fieldName, signature, true);
- if (id) {
- setStaticFieldForType<T>(env, clazz, id, value);
- QJniEnvironment::checkAndClearExceptions(env);
- }
+ if (id)
+ setStaticFieldForType<T>(frame.jniEnv(), clazz, id, value);
+ return frame.makeResult();
}
- template <typename T
+ template <typename Ret = void, typename Type
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<T> = true
+ , QtJniTypes::IfValidFieldType<Type> = true
#endif
>
- static void setStaticField(jclass clazz, const char *fieldName, T value)
+ static auto setStaticField(jclass clazz, const char *fieldName, Type value)
{
- setStaticField(clazz, fieldName, QtJniTypes::fieldSignature<T>(), value);
+ return setStaticField<Ret, Type>(clazz, fieldName,
+ QtJniTypes::fieldSignature<q20::remove_cvref_t<Type>>(),
+ value);
}
- template <typename Klass, typename T
+ template <typename Klass, typename Ret = void, typename Type
#ifndef Q_QDOC
- , QtJniTypes::IfValidFieldType<T> = true
+ , QtJniTypes::IfValidFieldType<Type> = true
#endif
>
- static void setStaticField(const char *fieldName, T value)
+ static auto setStaticField(const char *fieldName, Type value)
{
- setStaticField(QtJniTypes::Traits<Klass>::className(), fieldName, value);
+ return setStaticField<Ret, Type>(QtJniTypes::Traits<Klass>::className(), fieldName, value);
}
static QJniObject fromString(const QString &string);
@@ -583,6 +660,7 @@ protected:
private:
static jclass loadClass(const QByteArray &className, JNIEnv *env);
+ static jclass loadClassKeepExceptions(const QByteArray &className, JNIEnv *env);
#if QT_CORE_REMOVED_SINCE(6, 7)
// these need to stay in the ABI as they were used in inline methods before 6.7
@@ -620,12 +698,25 @@ private:
template<typename T>
static constexpr void callMethodForType(JNIEnv *env, T &res, jobject obj, jmethodID id, ...)
{
+ if (!id)
+ return;
+
va_list args = {};
va_start(args, id);
QtJniTypes::Caller<T>::callMethodForType(env, res, obj, id, args);
va_end(args);
}
+ jobject callObjectMethodImpl(jmethodID method, ...) const
+ {
+ va_list args;
+ va_start(args, method);
+ jobject res = method ? jniEnv()->CallObjectMethodV(javaObject(), method, args)
+ : nullptr;
+ va_end(args);
+ return res;
+ }
+
template<typename T>
static constexpr void callStaticMethodForType(JNIEnv *env, T &res, jclass clazz,
jmethodID id, ...)
@@ -652,6 +743,9 @@ private:
template<typename T>
static constexpr void getFieldForType(JNIEnv *env, T &res, jobject obj, jfieldID id)
{
+ if (!id)
+ return;
+
QtJniTypes::Caller<T>::getFieldForType(env, res, obj, id);
}
@@ -661,22 +755,42 @@ private:
QtJniTypes::Caller<T>::getStaticFieldForType(env, res, clazz, id);
}
- template<typename T>
- static constexpr void setFieldForType(JNIEnv *env, jobject obj, jfieldID id, T value)
+ template<typename Type>
+ static constexpr void setFieldForType(JNIEnv *env, jobject obj, jfieldID id, Type value)
{
+ if (!id)
+ return;
+
+ using T = q20::remove_cvref_t<Type>;
if constexpr (QtJniTypes::isObjectType<T>()) {
- LocalFrame<T> frame(env);
+ LocalFrame<T, T> frame(env);
env->SetObjectField(obj, id, static_cast<jobject>(frame.convertToJni(value)));
} else {
- QtJniTypes::Caller<T>::setFieldForType(env, obj, id, value);
+ using ValueType = typename QtJniTypes::Detail::CallerHandlesException<T>::value_type;
+ QtJniTypes::Caller<ValueType>::setFieldForType(env, obj, id, value);
}
}
- template<typename T>
- static constexpr void setStaticFieldForType(JNIEnv *env, jclass clazz, jfieldID id, T value)
+ jobject getObjectFieldImpl(JNIEnv *env, jfieldID field) const
+ {
+ return field ? env->GetObjectField(javaObject(), field) : nullptr;
+ }
+
+ static jobject getStaticObjectFieldImpl(JNIEnv *env, jclass clazz, jfieldID field)
+ {
+ return clazz && field ? env->GetStaticObjectField(clazz, field)
+ : nullptr;
+ }
+
+ template<typename Type>
+ static constexpr void setStaticFieldForType(JNIEnv *env, jclass clazz, jfieldID id, Type value)
{
+ if (!clazz || !id)
+ return;
+
+ using T = q20::remove_cvref_t<Type>;
if constexpr (QtJniTypes::isObjectType<T>()) {
- LocalFrame<T> frame(env);
+ LocalFrame<T, T> frame(env);
env->SetStaticObjectField(clazz, id, static_cast<jobject>(frame.convertToJni(value)));
} else {
QtJniTypes::Caller<T>::setStaticFieldForType(env, clazz, id, value);
@@ -797,14 +911,14 @@ public:
{
return QJniObject::getStaticField<Class, T>(field);
}
- template <typename T
+ template <typename Ret = void, typename T
#ifndef Q_QDOC
, QtJniTypes::IfValidFieldType<T> = true
#endif
>
- static void setStaticField(const char *field, T &&value)
+ static auto setStaticField(const char *field, T &&value)
{
- QJniObject::setStaticField<Class, T>(field, std::forward<T>(value));
+ return QJniObject::setStaticField<Class, Ret, T>(field, std::forward<T>(value));
}
// keep only these overloads, the rest is made private
@@ -827,14 +941,14 @@ public:
return m_object.getField<T>(fieldName);
}
- template <typename T
+ template <typename Ret = void, typename T
#ifndef Q_QDOC
, QtJniTypes::IfValidFieldType<T> = true
#endif
>
- void setField(const char *fieldName, T &&value)
+ auto setField(const char *fieldName, T &&value)
{
- m_object.setField(fieldName, std::forward<T>(value));
+ return m_object.setField<Ret>(fieldName, std::forward<T>(value));
}
QByteArray className() const {
@@ -911,6 +1025,37 @@ struct Traits<QString>
}
};
+template <typename T>
+struct Traits<T, std::enable_if_t<QtJniTypes::Detail::callerHandlesException<T>>>
+{
+ static constexpr auto className()
+ {
+ return Traits<typename T::value_type>::className();
+ }
+
+ static constexpr auto signature()
+ {
+ return Traits<typename T::value_type>::signature();
+ }
+};
+
+}
+
+template <typename ReturnType, typename ...Args>
+template <typename T>
+auto QtJniTypes::Detail::LocalFrame<ReturnType, Args...>::convertFromJni(jobject object)
+{
+ // If the caller wants to handle exceptions through a std::expected-like
+ // type, then we cannot turn the jobject into a QJniObject, as a
+ // std::expected<jobject, jthrowable> cannot be constructed from a QJniObject.
+ // The caller will have to take care of this themselves, by asking for a
+ // std::expected<QJniObject, ...>, or (typically) using a declared JNI class
+ // or implicitly supported Qt type (QString or array type).
+ if constexpr (callerHandlesException<ReturnType> &&
+ std::is_base_of_v<std::remove_pointer_t<jobject>, std::remove_pointer_t<T>>)
+ return static_cast<T>(object);
+ else
+ return convertFromJni<T>(object ? QJniObject::fromLocalRef(object) : QJniObject());
}
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qmetacontainer.cpp b/src/corelib/kernel/qmetacontainer.cpp
index 4b4ea06d8b9..6173198a972 100644
--- a/src/corelib/kernel/qmetacontainer.cpp
+++ b/src/corelib/kernel/qmetacontainer.cpp
@@ -210,7 +210,7 @@ void QMetaContainer::destroyIterator(const void *iterator) const
*/
bool QMetaContainer::compareIterator(const void *i, const void *j) const
{
- return hasIterator() ? d_ptr->compareIteratorFn(i, j) : false;
+ return i == j || (hasIterator() && d_ptr->compareIteratorFn(i, j));
}
/*!
@@ -249,7 +249,7 @@ void QMetaContainer::advanceIterator(void *iterator, qsizetype step) const
*/
qsizetype QMetaContainer::diffIterator(const void *i, const void *j) const
{
- return hasIterator() ? d_ptr->diffIteratorFn(i, j) : 0;
+ return (i != j && hasIterator()) ? d_ptr->diffIteratorFn(i, j) : 0;
}
/*!
@@ -327,7 +327,7 @@ void QMetaContainer::destroyConstIterator(const void *iterator) const
*/
bool QMetaContainer::compareConstIterator(const void *i, const void *j) const
{
- return hasConstIterator() ? d_ptr->compareConstIteratorFn(i, j) : false;
+ return i == j || (hasConstIterator() && d_ptr->compareConstIteratorFn(i, j));
}
/*!
@@ -366,7 +366,7 @@ void QMetaContainer::advanceConstIterator(void *iterator, qsizetype step) const
*/
qsizetype QMetaContainer::diffConstIterator(const void *i, const void *j) const
{
- return hasConstIterator() ? d_ptr->diffConstIteratorFn(i, j) : 0;
+ return (i != j && hasConstIterator()) ? d_ptr->diffConstIteratorFn(i, j) : 0;
}
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 02c9f00f301..607dc23f56c 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -2696,23 +2696,38 @@ static void err_method_notfound(const QObject *object,
case QSIGNAL_CODE: type = "signal"; break;
}
const char *loc = extract_location(method);
+ const char *err;
if (strchr(method, ')') == nullptr) // common typing mistake
- qCWarning(lcConnect, "QObject::%s: Parentheses expected, %s %s::%s%s%s", func, type,
- object->metaObject()->className(), method + 1, loc ? " in " : "", loc ? loc : "");
+ err = "Parentheses expected,";
else
- qCWarning(lcConnect, "QObject::%s: No such %s %s::%s%s%s", func, type,
- object->metaObject()->className(), method + 1, loc ? " in " : "", loc ? loc : "");
+ err = "No such";
+ qCWarning(lcConnect, "QObject::%s: %s %s %s::%s%s%s", func, err, type,
+ object->metaObject()->className(), method + 1, loc ? " in " : "", loc ? loc : "");
+}
+
+enum class ConnectionEnd : bool { Sender, Receiver };
+Q_DECL_COLD_FUNCTION
+static void err_info_about_object(const char *func, const QObject *o, ConnectionEnd end)
+{
+ if (!o)
+ return;
+ const QString name = o->objectName();
+ if (name.isEmpty())
+ return;
+ const bool sender = end == ConnectionEnd::Sender;
+ qCWarning(lcConnect, "QObject::%s: (%s name:%*s'%ls')",
+ func,
+ sender ? "sender" : "receiver",
+ sender ? 3 : 1, // ← length of generated whitespace
+ "",
+ qUtf16Printable(name));
}
Q_DECL_COLD_FUNCTION
static void err_info_about_objects(const char *func, const QObject *sender, const QObject *receiver)
{
- QString a = sender ? sender->objectName() : QString();
- QString b = receiver ? receiver->objectName() : QString();
- if (!a.isEmpty())
- qCWarning(lcConnect, "QObject::%s: (sender name: '%s')", func, a.toLocal8Bit().data());
- if (!b.isEmpty())
- qCWarning(lcConnect, "QObject::%s: (receiver name: '%s')", func, b.toLocal8Bit().data());
+ err_info_about_object(func, sender, ConnectionEnd::Sender);
+ err_info_about_object(func, receiver, ConnectionEnd::Receiver);
}
Q_DECL_COLD_FUNCTION
diff --git a/src/corelib/kernel/qpermissions.cpp b/src/corelib/kernel/qpermissions.cpp
index bbcea8338ca..6767917e176 100644
--- a/src/corelib/kernel/qpermissions.cpp
+++ b/src/corelib/kernel/qpermissions.cpp
@@ -124,7 +124,11 @@ Q_LOGGING_CATEGORY(lcPermissions, "qt.permissions", QtWarningMsg);
The relevant permission names are described in the documentation
for each permission type.
- \sa {Qt Creator: Editing Manifest Files}
+ \note When using this API, the \c{<!-- %%INSERT_PERMISSIONS -->} tag must be present in
+ the AndroidManifest.xml. For further information on the use of this tag,
+ see \l {Qt Permissions and Features}
+
+ \sa {Qt Creator: Editing Manifest Files}.
\section1 Available Permissions
diff --git a/src/corelib/platform/wasm/qstdweb.cpp b/src/corelib/platform/wasm/qstdweb.cpp
index 4f3ecc4c6d9..bbaf2c442a0 100644
--- a/src/corelib/platform/wasm/qstdweb.cpp
+++ b/src/corelib/platform/wasm/qstdweb.cpp
@@ -446,6 +446,119 @@ EventCallback::EventCallback(emscripten::val element, const std::string &name,
}
+size_t qstdweb::Promise::State::s_numInstances = 0;
+
+//
+// When a promise settles, all attached handlers will be called in
+// the order they where added.
+//
+// In particular a finally handler will be called according to its
+// position in the call chain. Which is not necessarily at the end,
+//
+// This makes cleanup difficult. If we cleanup to early, we will remove
+// handlers before they have a chance to be called. This would be the
+// case if we add a finally handler in the Promise constructor.
+//
+// For correct cleanup it is necessary that it happens after the
+// last handler has been called.
+//
+// We choose to implement this by making sure the last handler
+// is always a finally handler.
+//
+// In this case we have multiple finally handlers, so any called
+// handler checks if it is the last handler to be called.
+// If it is, the cleanup is performed, otherwise cleanup
+// is delayed to the last handler.
+//
+// We could try to let the handlers cleanup themselves, but this
+// only works for finally handlers. A then or catch handler is not
+// necessarily called, and would not cleanup itself.
+//
+// We could try to let a (then,catch) pair cleanup both handlers,
+// under the assumption that one of them will always be called.
+// This does not work in the case that we do not have both handlers,
+// or if the then handler throws (both should be called in this case).
+//
+Promise& Promise::addThenFunction(std::function<void(emscripten::val)> thenFunc)
+{
+ QWasmSuspendResumeControl *suspendResume = QWasmSuspendResumeControl::get();
+ Q_ASSERT(suspendResume);
+
+ m_state->m_handlers.push_back(suspendResume->registerEventHandler(thenFunc));
+ m_state->m_promise =
+ m_state->m_promise.call<emscripten::val>(
+ "then",
+ suspendResume->jsEventHandlerAt(
+ m_state->m_handlers.back()));
+
+ addFinallyFunction([](){}); // Add a potential cleanup handler
+ return (*this);
+}
+
+Promise& Promise::addCatchFunction(std::function<void(emscripten::val)> catchFunc)
+{
+ QWasmSuspendResumeControl *suspendResume = QWasmSuspendResumeControl::get();
+ Q_ASSERT(suspendResume);
+
+ m_state->m_handlers.push_back(suspendResume->registerEventHandler(catchFunc));
+ m_state->m_promise =
+ m_state->m_promise.call<emscripten::val>(
+ "catch",
+ suspendResume->jsEventHandlerAt(
+ m_state->m_handlers.back()));
+
+ addFinallyFunction([](){}); // Add a potential cleanup handler
+ return (*this);
+}
+
+Promise& Promise::addFinallyFunction(std::function<void()> finallyFunc)
+{
+ QWasmSuspendResumeControl *suspendResume = QWasmSuspendResumeControl::get();
+ Q_ASSERT(suspendResume);
+
+ auto thisHandler = std::make_shared<uint32_t>((uint32_t)(-1));
+ auto state = m_state;
+
+ std::function<void(emscripten::val)> func =
+ [state, thisHandler, finallyFunc](emscripten::val element) {
+ Q_UNUSED(element);
+
+ finallyFunc();
+
+ // See comment at top, we can only do the cleanup
+ // if we are the last handler in the handler chain
+ if (state->m_handlers.back() == *thisHandler) {
+ auto guard = state; // removeEventHandler will remove also this function
+ QWasmSuspendResumeControl *suspendResume = QWasmSuspendResumeControl::get();
+ Q_ASSERT(suspendResume);
+ for (int i = 0; i < guard->m_handlers.size(); ++i) {
+ suspendResume->removeEventHandler(guard->m_handlers[i]);
+ guard->m_handlers[i] = (uint32_t)(-1);
+ }
+ }
+ };
+
+ *thisHandler = suspendResume->registerEventHandler(func);
+ m_state->m_handlers.push_back(*thisHandler);
+ m_state->m_promise =
+ m_state->m_promise.call<emscripten::val>(
+ "finally",
+ suspendResume->jsEventHandlerAt(
+ m_state->m_handlers.back()));
+
+ return (*this);
+}
+
+void Promise::suspendExclusive()
+{
+ Promise::suspendExclusive(m_state->m_handlers);
+}
+
+emscripten::val Promise::getPromise() const
+{
+ return m_state->m_promise;
+}
+
uint32_t Promise::adoptPromise(emscripten::val promise, PromiseCallbacks callbacks, QList<uint32_t> *handlers)
{
Q_ASSERT_X(!!callbacks.catchFunc || !!callbacks.finallyFunc || !!callbacks.thenFunc,
diff --git a/src/corelib/platform/wasm/qstdweb_p.h b/src/corelib/platform/wasm/qstdweb_p.h
index b14d9e4012f..07df021c444 100644
--- a/src/corelib/platform/wasm/qstdweb_p.h
+++ b/src/corelib/platform/wasm/qstdweb_p.h
@@ -237,11 +237,80 @@ namespace qstdweb {
std::function<void()> finallyFunc;
};
- namespace Promise {
- uint32_t Q_CORE_EXPORT adoptPromise(emscripten::val promise, PromiseCallbacks callbacks, QList<uint32_t> *handlers = nullptr);
+ // Note: it is ok for the Promise object to go out of scope,
+ // the resources will be cleaned up in the finally handler.
+ class Q_CORE_EXPORT Promise {
+ public:
+ template<typename... Args>
+ Promise(emscripten::val target, QString methodName, Args... args) {
+ m_state = std::make_shared<State>();
+ m_state->m_promise = target.call<emscripten::val>(
+ methodName.toStdString().c_str(), std::forward<Args>(args)...);
+ if (m_state->m_promise.isUndefined() || m_state->m_promise["constructor"]["name"].as<std::string>() != "Promise") {
+ qFatal("This function did not return a promise");
+ }
+ addFinallyFunction([](){});
+ }
+
+ Promise(emscripten::val promise) {
+ m_state = std::make_shared<State>();
+ m_state->m_promise = promise;
+ if (m_state->m_promise.isUndefined() || m_state->m_promise["constructor"]["name"].as<std::string>() != "Promise") {
+ qFatal("This function did not return a promise");
+ }
+ addFinallyFunction([](){});
+ }
+
+ Promise(const std::vector<Promise> &promises) {
+ std::vector<emscripten::val> all;
+ all.reserve(promises.size());
+ for (const auto &p : promises)
+ all.push_back(p.getPromise());
+
+ auto arr = emscripten::val::array(all);
+ m_state = std::make_shared<State>();
+ m_state->m_promise = emscripten::val::global("Promise").call<emscripten::val>("all", arr);
+ addFinallyFunction([](){});
+ }
+
+ Promise& addThenFunction(std::function<void(emscripten::val)> thenFunc);
+ Promise& addCatchFunction(std::function<void(emscripten::val)> catchFunc);
+ Promise& addFinallyFunction(std::function<void()> finallyFunc);
+
+ void suspendExclusive();
+
+ emscripten::val getPromise() const;
+
+ public:
+ class State {
+ private:
+ friend class Promise;
+
+ State(const State&) = delete;
+ State(State&&) = delete;
+ State& operator=(const State&) = delete;
+ State& operator=(State&&) = delete;
+
+ public:
+ State() { ++s_numInstances; }
+ ~State() { --s_numInstances; }
+ static size_t numInstances() { return s_numInstances; }
+
+ private:
+ emscripten::val m_promise = emscripten::val::undefined();
+ QList<uint32_t> m_handlers;
+ static size_t s_numInstances;
+ };
+
+ private:
+ std::shared_ptr<State> m_state;
+
+ public:
+ // Deprecated: To be backwards compatible
+ static uint32_t Q_CORE_EXPORT adoptPromise(emscripten::val promise, PromiseCallbacks callbacks, QList<uint32_t> *handlers = nullptr);
template<typename... Args>
- uint32_t make(emscripten::val target,
+ static uint32_t make(emscripten::val target,
QString methodName,
PromiseCallbacks callbacks,
Args... args)
@@ -256,7 +325,7 @@ namespace qstdweb {
}
template<typename... Args>
- void make(
+ static void make(
QList<uint32_t> &handlers,
emscripten::val target,
QString methodName,
@@ -272,8 +341,8 @@ namespace qstdweb {
adoptPromise(std::move(promiseObject), std::move(callbacks), &handlers);
}
- void Q_CORE_EXPORT suspendExclusive(QList<uint32_t> handlerIndices);
- void Q_CORE_EXPORT all(std::vector<emscripten::val> promises, PromiseCallbacks callbacks);
+ static void Q_CORE_EXPORT suspendExclusive(QList<uint32_t> handlerIndices);
+ static void Q_CORE_EXPORT all(std::vector<emscripten::val> promises, PromiseCallbacks callbacks);
};
template<class F>
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index deac396061d..34e910fabec 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -3894,10 +3894,12 @@ QDateTime::Data QDateTimePrivate::create(QDate toDate, QTime toTime, const QTime
Selects a time on the standard time side of the transition.
\value PreferDaylightSaving
Selects a time on the daylight-saving-time side of the transition.
- \value LegacyBehavior
- An alias for RelativeToBefore, which is used as default for
- TransitionResolution parameters, as this most closely matches the
- behavior prior to Qt 6.7.
+ \omitvalue LegacyBehavior
+
+ An additional constant, \c LegacyBehavior, is used as a default value for
+ TransitionResolution parameters in some constructors and setter functions.
+ This is an alias for \c RelativeToBefore, which implements behavior that
+ most closely matches the behavior of QDateTime prior to Qt 6.7.
For \l addDays(), \l addMonths() or \l addYears(), the behavior is and
(mostly) was to use \c RelativeToBefore if adding a positive adjustment and \c
@@ -3909,7 +3911,7 @@ QDateTime::Data QDateTimePrivate::create(QDate toDate, QTime toTime, const QTime
where the daylight-saving mechanism is a decrease in offset from UTC in
winter (known as "negative DST"), the reverse applies, provided the
operating system reports - as it does on most platforms - whether a datetime
- is in DST or standard time. For some platforms, where transition times are
+ is in DST or standard time. For some platforms, where transition details are
unavailable even for Qt::TimeZone datetimes, QTimeZone is obliged to presume
that the side with lower offset from UTC is standard time, effectively
assuming positive DST.
diff --git a/src/corelib/tools/qflatmap_p.h b/src/corelib/tools/qflatmap_p.h
index d2c0d45b79d..5a827fb4148 100644
--- a/src/corelib/tools/qflatmap_p.h
+++ b/src/corelib/tools/qflatmap_p.h
@@ -15,7 +15,9 @@
// We mean it.
//
+#include <QtCore/qcontainertools_impl.h>
#include "qlist.h"
+#include <QtCore/qtclasshelpermacros.h>
#include "private/qglobal_p.h"
#include <algorithm>
@@ -42,23 +44,9 @@ QT_BEGIN_NAMESPACE
QFlatMap<float, int, std::less<float>, std::vector<float>, std::vector<int>>
*/
-// Qt 6.4:
-// - removed QFlatMap API which was incompatible with STL semantics
-// - will be released with said API disabled, to catch any out-of-tree users
-// - also allows opting in to the new API using QFLATMAP_ENABLE_STL_COMPATIBLE_INSERT
-// Qt 6.5
-// - will make QFLATMAP_ENABLE_STL_COMPATIBLE_INSERT the default:
-
-#ifndef QFLATMAP_ENABLE_STL_COMPATIBLE_INSERT
-# if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
-# define QFLATMAP_ENABLE_STL_COMPATIBLE_INSERT
-# endif
-#endif
-
namespace Qt {
-struct OrderedUniqueRange_t {};
-constexpr OrderedUniqueRange_t OrderedUniqueRange = {};
+QT_DEFINE_TAG(OrderedUniqueRange);
} // namespace Qt
@@ -83,35 +71,11 @@ public:
}
};
-namespace qflatmap {
-namespace detail {
-template <class T>
-class QFlatMapMockPointer
-{
- T ref;
-public:
- QFlatMapMockPointer(T r)
- : ref(r)
- {
- }
-
- T *operator->()
- {
- return &ref;
- }
-};
-} // namespace detail
-} // namespace qflatmap
-
template<class Key, class T, class Compare = std::less<Key>, class KeyContainer = QList<Key>,
class MappedContainer = QList<T>>
class QFlatMap : private QFlatMapValueCompare<Key, T, Compare>
{
static_assert(std::is_nothrow_destructible_v<T>, "Types with throwing destructors are not supported in Qt containers.");
-
- template<class U>
- using mock_pointer = qflatmap::detail::QFlatMapMockPointer<U>;
-
public:
using key_type = Key;
using mapped_type = T;
@@ -134,7 +98,7 @@ public:
using difference_type = ptrdiff_t;
using value_type = std::pair<const Key, T>;
using reference = std::pair<const Key &, T &>;
- using pointer = mock_pointer<reference>;
+ using pointer = QtPrivate::ArrowProxy<reference>;
using iterator_category = std::random_access_iterator_tag;
iterator() = default;
@@ -266,7 +230,7 @@ public:
using difference_type = ptrdiff_t;
using value_type = std::pair<const Key, const T>;
using reference = std::pair<const Key &, const T &>;
- using pointer = mock_pointer<reference>;
+ using pointer = QtPrivate::ArrowProxy<reference>;
using iterator_category = std::random_access_iterator_tag;
const_iterator() = default;
@@ -415,7 +379,6 @@ private:
public:
QFlatMap() = default;
-#ifdef QFLATMAP_ENABLE_STL_COMPATIBLE_INSERT
explicit QFlatMap(const key_container_type &keys, const mapped_container_type &values)
: c{keys, values}
{
@@ -451,7 +414,6 @@ public:
initWithRange(first, last);
ensureOrderedUnique();
}
-#endif
explicit QFlatMap(Qt::OrderedUniqueRange_t, const key_container_type &keys,
const mapped_container_type &values)
@@ -493,7 +455,6 @@ public:
{
}
-#ifdef QFLATMAP_ENABLE_STL_COMPATIBLE_INSERT
explicit QFlatMap(const key_container_type &keys, const mapped_container_type &values,
const Compare &compare)
: value_compare(compare), c{keys, values}
@@ -534,7 +495,6 @@ public:
initWithRange(first, last);
ensureOrderedUnique();
}
-#endif
explicit QFlatMap(Qt::OrderedUniqueRange_t, const key_container_type &keys,
const mapped_container_type &values, const Compare &compare)
@@ -674,7 +634,6 @@ public:
return value(key);
}
-#ifdef QFLATMAP_ENABLE_STL_COMPATIBLE_INSERT
std::pair<iterator, bool> insert(const Key &key, const T &value)
{
return try_emplace(key, value);
@@ -694,7 +653,6 @@ public:
{
return try_emplace(std::move(key), std::move(value));
}
-#endif
template <typename...Args>
std::pair<iterator, bool> try_emplace(const Key &key, Args&&...args)
@@ -738,7 +696,6 @@ public:
return r;
}
-#ifdef QFLATMAP_ENABLE_STL_COMPATIBLE_INSERT
template <class InputIt, is_compatible_iterator<InputIt> = nullptr>
void insert(InputIt first, InputIt last)
{
@@ -764,7 +721,6 @@ public:
{
insertOrderedUniqueRange(first, last);
}
-#endif
iterator begin() { return { &c, 0 }; }
const_iterator begin() const { return { &c, 0 }; }
diff --git a/src/dbus/qt_attribution.json b/src/dbus/qt_attribution.json
index 067e3013bb1..faffd45685a 100644
--- a/src/dbus/qt_attribution.json
+++ b/src/dbus/qt_attribution.json
@@ -7,14 +7,14 @@
"Description": "D-Bus is a message bus system, a simple way for applications to talk to one another.",
"Homepage": "https://www.freedesktop.org/wiki/Software/dbus/",
"Version": "Minimal supported is 1.2, compatible up to ...",
- "Version": "dbus-1.13.12",
- "PURL": "pkg:github/d-bus/dbus@$<VERSION>",
+ "Version": "1.13.12",
+ "PURL": "pkg:github/d-bus/dbus@dbus-$<VERSION>",
+ "CPE": "cpe:2.3:a:freedesktop:dbus:$<VERSION>:*:*:*:*:*:*:*",
"LicenseId": "AFL-2.1 OR GPL-2.0-or-later",
"License": "Academic Free License v2.1, or GNU General Public License v2.0 or later",
"LicenseFile": "LICENSE.LIBDBUS-1.txt",
"Comment": "Fragments from various upstream files, see comments in ...",
"Files": "dbus_minimal_p.h",
"Copyright": ["Copyright (C) 2002, 2003 CodeFactory AB",
- "Copyright (C) 2004, 2005 Red Hat, Inc."],
- "Comment": "no relevant CPE found"
+ "Copyright (C) 2004, 2005 Red Hat, Inc."]
}
diff --git a/src/gui/accessible/linux/qspimatchrulematcher.cpp b/src/gui/accessible/linux/qspimatchrulematcher.cpp
index d7047ad3e0e..48357f7ae63 100644
--- a/src/gui/accessible/linux/qspimatchrulematcher.cpp
+++ b/src/gui/accessible/linux/qspimatchrulematcher.cpp
@@ -23,11 +23,11 @@ QSpiMatchRuleMatcher::QSpiMatchRuleMatcher(const QSpiMatchRule &matchRule)
m_interfaceMatchType(matchRule.interfaceMatchType)
{
// extract roles encoded in bitset stored in multiple 32 bit integers
- std::unordered_set<AtspiRole> atSpiRoles;
- for (int i = 0; i < matchRule.roles.size(); ++i) {
+ for (qsizetype i = 0; i < matchRule.roles.size(); ++i) {
+ const auto role = matchRule.roles.at(i);
for (int j = 0; j < 32; j++) {
- if (matchRule.roles.at(i) & (1 << j)) {
- const int atspiRole = i * 32 + j;
+ if (role & (1 << j)) {
+ const auto atspiRole = i * 32 + j;
if (atspiRole < ATSPI_ROLE_LAST_DEFINED)
m_roles.insert(AtspiRole(atspiRole));
else
@@ -38,6 +38,7 @@ QSpiMatchRuleMatcher::QSpiMatchRuleMatcher(const QSpiMatchRule &matchRule)
}
// use qualified interface names to match what accessibleInterfaces() returns
+ m_interfaces.reserve(matchRule.interfaces.size());
for (const QString &ifaceName : matchRule.interfaces)
m_interfaces.push_back("org.a11y.atspi."_L1 + ifaceName);
}
diff --git a/src/gui/configure.cmake b/src/gui/configure.cmake
index dac2d072e42..e34f4d8b30a 100644
--- a/src/gui/configure.cmake
+++ b/src/gui/configure.cmake
@@ -28,8 +28,12 @@ set_property(CACHE INPUT_libpng PROPERTY STRINGS undefined no qt system)
#### Libraries
-qt_set01(X11_SUPPORTED LINUX OR HPUX OR FREEBSD OR NETBSD OR OPENBSD OR SOLARIS OR
- HURD)
+if(LINUX OR HPUX OR FREEBSD OR NETBSD OR OPENBSD OR SOLARIS OR HURD)
+ set(X11_SUPPORTED 1)
+else()
+ set(X11_SUPPORTED 0)
+endif()
+qt_feature_vcpkg_scope(gui)
qt_find_package(ATSPI2 MODULE PROVIDED_TARGETS PkgConfig::ATSPI2 MODULE_NAME gui QMAKE_LIB atspi)
qt_find_package(DirectFB PROVIDED_TARGETS PkgConfig::DirectFB MODULE_NAME gui QMAKE_LIB directfb)
qt_find_package(Libdrm MODULE PROVIDED_TARGETS Libdrm::Libdrm MODULE_NAME gui QMAKE_LIB drm)
@@ -39,15 +43,26 @@ qt_find_package(PlatformGraphics
qt_find_package(EGL MODULE PROVIDED_TARGETS EGL::EGL MODULE_NAME gui QMAKE_LIB egl)
qt_find_package(WrapSystemFreetype 2.2.0 MODULE
- PROVIDED_TARGETS WrapSystemFreetype::WrapSystemFreetype MODULE_NAME gui QMAKE_LIB freetype)
+ PROVIDED_TARGETS WrapSystemFreetype::WrapSystemFreetype MODULE_NAME gui QMAKE_LIB freetype
+ VCPKG_PORT freetype
+ VCPKG_ADD_TO_FEATURE freetype
+)
if(QT_FEATURE_system_zlib)
qt_add_qmake_lib_dependency(freetype zlib)
endif()
-qt_find_package(Fontconfig PROVIDED_TARGETS Fontconfig::Fontconfig MODULE_NAME gui QMAKE_LIB fontconfig)
+qt_find_package(Fontconfig PROVIDED_TARGETS Fontconfig::Fontconfig MODULE_NAME gui
+ QMAKE_LIB fontconfig
+ VCPKG_PORT fontconfig
+ VCPKG_ADD_TO_FEATURE fontconfig
+ VCPKG_PLATFORM "linux"
+)
qt_add_qmake_lib_dependency(fontconfig freetype)
qt_find_package(gbm MODULE PROVIDED_TARGETS gbm::gbm MODULE_NAME gui QMAKE_LIB gbm)
qt_find_package(WrapSystemHarfbuzz 2.6.0 MODULE
- PROVIDED_TARGETS WrapSystemHarfbuzz::WrapSystemHarfbuzz MODULE_NAME gui QMAKE_LIB harfbuzz)
+ PROVIDED_TARGETS WrapSystemHarfbuzz::WrapSystemHarfbuzz MODULE_NAME gui QMAKE_LIB harfbuzz
+ VCPKG_PORT harfbuzz
+ VCPKG_ADD_TO_FEATURE harfbuzz
+)
qt_find_package(Libinput MODULE
PROVIDED_TARGETS Libinput::Libinput MODULE_NAME gui QMAKE_LIB libinput)
qt_find_package_extend_sbom(TARGETS Libinput::Libinput
@@ -61,11 +76,20 @@ qt_find_package_extend_sbom(TARGETS Libinput::Libinput
"Copyright © 2013-2015 Red Hat, Inc."
)
qt_find_package(WrapSystemJpeg MODULE
- PROVIDED_TARGETS WrapSystemJpeg::WrapSystemJpeg MODULE_NAME gui QMAKE_LIB libjpeg)
+ PROVIDED_TARGETS WrapSystemJpeg::WrapSystemJpeg MODULE_NAME gui QMAKE_LIB libjpeg
+ VCPKG_PORT libjpeg-turbo
+ VCPKG_ADD_TO_FEATURE jpeg
+)
qt_find_package(WrapSystemMd4c MODULE
- PROVIDED_TARGETS WrapSystemMd4c::WrapSystemMd4c MODULE_NAME gui QMAKE_LIB libmd4c)
+ PROVIDED_TARGETS WrapSystemMd4c::WrapSystemMd4c MODULE_NAME gui QMAKE_LIB libmd4c
+ VCPKG_PORT md4c
+ VCPKG_ADD_TO_FEATURE textmarkdownreader
+)
qt_find_package(WrapSystemPNG MODULE
- PROVIDED_TARGETS WrapSystemPNG::WrapSystemPNG MODULE_NAME gui QMAKE_LIB libpng)
+ PROVIDED_TARGETS WrapSystemPNG::WrapSystemPNG MODULE_NAME gui QMAKE_LIB libpng
+ VCPKG_PORT libpng
+ VCPKG_ADD_TO_FEATURE png
+)
if(QT_FEATURE_system_zlib)
qt_add_qmake_lib_dependency(libpng zlib)
endif()
diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp
index a0a1dcdaca9..8a413ded95e 100644
--- a/src/gui/image/qppmhandler.cpp
+++ b/src/gui/image/qppmhandler.cpp
@@ -123,8 +123,8 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
break;
case '2': // ascii PGM
case '5': // raw PGM
- nbits = 8;
- format = QImage::Format_Grayscale8;
+ nbits = mcc <= std::numeric_limits<uint8_t>::max() ? 8 : 16;
+ format = mcc <= std::numeric_limits<uint8_t>::max() ? QImage::Format_Grayscale8 : QImage::Format_Grayscale16;
break;
case '3': // ascii PPM
case '6': // raw PPM
@@ -175,20 +175,20 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
}
}
delete[] buf24;
- } else if (nbits == 8 && mcc > 255) { // type 5 16bit
- pbm_bpl = 2*w;
+ } else if (nbits == 16) { // type 5 16bit
+ pbm_bpl = sizeof(uint16_t)*w;
uchar *buf16 = new uchar[pbm_bpl];
for (y=0; y<h; y++) {
if (device->read((char *)buf16, pbm_bpl) != pbm_bpl) {
delete[] buf16;
return false;
}
- uchar *p = outImage->scanLine(y);
- uchar *end = p + w;
- uchar *b = buf16;
+ uint16_t *p = reinterpret_cast<uint16_t *>(outImage->scanLine(y));
+ uint16_t *end = p + w;
+ uint16_t *b = reinterpret_cast<uint16_t *>(buf16);
while (p < end) {
- *p++ = (b[0] << 8 | b[1]) * 255 / mcc;
- b += 2;
+ *p++ = qFromBigEndian(*b) * std::numeric_limits<uint16_t>::max() / mcc;
+ b++;
}
}
delete[] buf16;
@@ -225,13 +225,25 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
*p++ = b;
}
} else if (nbits == 8) {
- if (mcc == 255) {
+ if (mcc == std::numeric_limits<uint8_t>::max()) {
while (n-- && ok) {
*p++ = read_pbm_int(device, &ok);
}
} else {
while (n-- && ok) {
- *p++ = (read_pbm_int(device, &ok) & 0xffff) * 255 / mcc;
+ *p++ = (read_pbm_int(device, &ok) & 0xffff) * std::numeric_limits<uint8_t>::max() / mcc;
+ }
+ }
+ } else if (nbits == 16) {
+ uint16_t* data = reinterpret_cast<uint16_t*>(p);
+ qsizetype numPixel = n/2;
+ if (mcc == std::numeric_limits<uint16_t>::max()) {
+ while (numPixel-- && ok) {
+ *data++ = read_pbm_int(device, &ok);
+ }
+ } else {
+ while (numPixel-- && ok) {
+ *data++ = (read_pbm_int(device, &ok) & 0xffff) * std::numeric_limits<uint16_t>::max() / mcc;
}
}
} else { // 32 bits
@@ -280,7 +292,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, QByteArra
if (format == "pbm") {
image = image.convertToFormat(QImage::Format_Mono);
} else if (gray) {
- image = image.convertToFormat(QImage::Format_Grayscale8);
+ image = image.depth() <= 8 ? image.convertToFormat(QImage::Format_Grayscale8) : image.convertToFormat(QImage::Format_Grayscale16);
} else {
switch (image.format()) {
case QImage::Format_Mono:
@@ -388,6 +400,34 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, QByteArra
delete [] buf;
break;
}
+ case 16: {
+ str.insert(1, gray ? '5' : '6');
+ str.append("65535\n");
+ if (out->write(str, str.size()) != str.size())
+ return false;
+ qsizetype bpl = sizeof(uint16_t) * qsizetype(w) * (gray ? 1 : 3);
+ uchar *buf = new uchar[bpl];
+ for (uint y=0; y<h; y++) {
+ const uint16_t *b = reinterpret_cast<const uint16_t *>(image.constScanLine(y));
+ uint16_t *p = reinterpret_cast<uint16_t *>(buf);
+ uint16_t *end = reinterpret_cast<uint16_t *>(buf + bpl);
+ if (gray) {
+ while (p < end)
+ *p++ = qToBigEndian(*b++);
+ } else {
+ while (p < end) {
+ uchar color = qToBigEndian(*b++);
+ *p++ = color;
+ *p++ = color;
+ *p++ = color;
+ }
+ }
+ if (bpl != (qsizetype)out->write((char*)buf, bpl))
+ return false;
+ }
+ delete [] buf;
+ break;
+ }
case 32: {
str.insert(1, '6');
@@ -530,7 +570,10 @@ QVariant QPpmHandler::option(ImageOption option) const
break;
case '2': // ascii PGM
case '5': // raw PGM
- format = QImage::Format_Grayscale8;
+ if (mcc <= std::numeric_limits<uint8_t>::max())
+ format = QImage::Format_Grayscale8;
+ else
+ format = QImage::Format_Grayscale16;
break;
case '3': // ascii PPM
case '6': // raw PPM
diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp
index 9149971b999..680bdef3ac9 100644
--- a/src/gui/painting/qcolorspace.cpp
+++ b/src/gui/painting/qcolorspace.cpp
@@ -1205,9 +1205,9 @@ QByteArray QColorSpace::iccProfile() const
*/
QColorSpace QColorSpace::fromIccProfile(const QByteArray &iccProfile)
{
+ QColorSpace colorSpace;
// Must detach if input is fromRawData(); nullTerminated() is trick to do that and nothing else
QByteArray ownedIccProfile = iccProfile.nullTerminated();
- QColorSpace colorSpace;
if (QIcc::fromIccProfile(ownedIccProfile, &colorSpace))
return colorSpace;
colorSpace.detach();
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 7ffb688c035..2b2f2a27fcd 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1829,6 +1829,8 @@ bool QFont::operator==(const QFont &f) const
*/
bool QFont::operator<(const QFont &f) const
{
+ // NB: This operator actually implements greater-than, because it consistently
+ // swaps LHS (should be *this, but is `f`) and RHS (should be `f`, but is *this)
if (f.d == d) return false;
// the < operator for fontdefs ignores point sizes.
const QFontDef &r1 = f.d->request;
@@ -2199,7 +2201,7 @@ QString QFont::toString() const
fontDescription += comma + QString::number(sortedFeatures.size());
for (const auto &[tag, value] : std::as_const(sortedFeatures).asKeyValueRange())
- fontDescription += comma + tag.toString() + u'=' + QString::number(value);
+ fontDescription += comma + QLatin1StringView{tag.toString()} + u'=' + QString::number(value);
return fontDescription;
}
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 9eb3b62443c..7acc3c5218c 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -554,7 +554,6 @@ bool QRawFont::glyphIndexesForChars(const QChar *chars, int numChars, quint32 *g
}
/*!
- \fn QList<QPointF> QRawFont::advancesForGlyphIndexes(const QList<quint32> &glyphIndexes, LayoutFlags layoutFlags) const
\since 5.1
Returns the QRawFont's advances for each of the \a glyphIndexes in pixel units. The advances
@@ -570,6 +569,14 @@ bool QRawFont::glyphIndexesForChars(const QChar *chars, int numChars, quint32 *g
\sa QTextLine::horizontalAdvance(), QFontMetricsF::horizontalAdvance(), QTextLayout::glyphRuns()
*/
+QList<QPointF> QRawFont::advancesForGlyphIndexes(const QList<quint32> &glyphIndexes, QRawFont::LayoutFlags layoutFlags) const
+{
+ QList<QPointF> advances(glyphIndexes.size());
+ if (advancesForGlyphIndexes(glyphIndexes.constData(), advances.data(), int(glyphIndexes.size()), layoutFlags))
+ return advances;
+ return QList<QPointF>();
+}
+
/*!
\fn QList<QPointF> QRawFont::advancesForGlyphIndexes(const QList<quint32> &glyphIndexes) const
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h
index d0bed84a68a..f13f04ebe37 100644
--- a/src/gui/text/qrawfont.h
+++ b/src/gui/text/qrawfont.h
@@ -65,8 +65,8 @@ public:
QList<quint32> glyphIndexesForString(const QString &text) const;
inline QList<QPointF> advancesForGlyphIndexes(const QList<quint32> &glyphIndexes) const;
- inline QList<QPointF> advancesForGlyphIndexes(const QList<quint32> &glyphIndexes,
- LayoutFlags layoutFlags) const;
+ QList<QPointF> advancesForGlyphIndexes(const QList<quint32> &glyphIndexes,
+ LayoutFlags layoutFlags) const;
bool glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const;
bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const;
bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs, LayoutFlags layoutFlags) const;
@@ -128,14 +128,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QRawFont::LayoutFlags)
Q_GUI_EXPORT size_t qHash(const QRawFont &font, size_t seed = 0) noexcept;
-inline QList<QPointF> QRawFont::advancesForGlyphIndexes(const QList<quint32> &glyphIndexes,
- QRawFont::LayoutFlags layoutFlags) const
-{
- QList<QPointF> advances(glyphIndexes.size());
- if (advancesForGlyphIndexes(glyphIndexes.constData(), advances.data(), int(glyphIndexes.size()), layoutFlags))
- return advances;
- return QList<QPointF>();
-}
+
inline QList<QPointF> QRawFont::advancesForGlyphIndexes(const QList<quint32> &glyphIndexes) const
{
diff --git a/src/network/access/http2/http2frames.cpp b/src/network/access/http2/http2frames.cpp
index 3b52204c7d3..e6a3474d7b0 100644
--- a/src/network/access/http2/http2frames.cpp
+++ b/src/network/access/http2/http2frames.cpp
@@ -34,7 +34,8 @@ FrameType Frame::type() const
quint32 Frame::streamID() const
{
Q_ASSERT(buffer.size() >= frameHeaderSize);
- return qFromBigEndian<quint32>(&buffer[5]);
+ // RFC 9113, 4.1: 31-bit Stream ID; lastValidStreamID(0x7FFFFFFF) masks out the reserved MSB
+ return qFromBigEndian<quint32>(&buffer[5]) & lastValidStreamID;
}
FrameFlags Frame::flags() const
diff --git a/src/network/access/http2/http2protocol.cpp b/src/network/access/http2/http2protocol.cpp
index 050beacb31c..314be07f952 100644
--- a/src/network/access/http2/http2protocol.cpp
+++ b/src/network/access/http2/http2protocol.cpp
@@ -188,8 +188,9 @@ bool is_protocol_upgraded(const QHttpNetworkReply &reply)
if (reply.statusCode() != 101)
return false;
+ const auto values = reply.header().values(QHttpHeaders::WellKnownHeader::Upgrade);
// Do some minimal checks here - we expect 'Upgrade: h2c' to be found.
- for (const auto &v : reply.header().values(QHttpHeaders::WellKnownHeader::Upgrade)) {
+ for (const auto &v : values) {
if (v.compare("h2c", Qt::CaseInsensitive) == 0)
return true;
}
diff --git a/src/network/access/qhttp2connection.cpp b/src/network/access/qhttp2connection.cpp
index 1d5c0d92b63..2895e8335d2 100644
--- a/src/network/access/qhttp2connection.cpp
+++ b/src/network/access/qhttp2connection.cpp
@@ -454,7 +454,7 @@ void QHttp2Stream::internalSendDATA()
"[%p] stream %u, exhausted device %p, sent END_STREAM? %d, %ssending end stream "
"after DATA",
connection, m_streamID, m_uploadByteDevice, sentEND_STREAM,
- m_endStreamAfterDATA ? "" : "not ");
+ !sentEND_STREAM && m_endStreamAfterDATA ? "" : "not ");
if (!sentEND_STREAM && m_endStreamAfterDATA) {
// We need to send an empty DATA frame with END_STREAM since we
// have exhausted the device, but we haven't sent END_STREAM yet.
@@ -690,8 +690,9 @@ void QHttp2Stream::handleDATA(const Frame &inboundFrame)
m_recvWindow -= qint32(inboundFrame.payloadSize());
const bool endStream = inboundFrame.flags().testFlag(FrameFlag::END_STREAM);
+ const bool ignoreData = connection->streamIsIgnored(m_streamID);
// Uncompress data if needed and append it ...
- if (inboundFrame.dataSize() > 0 || endStream) {
+ if ((inboundFrame.dataSize() > 0 || endStream) && !ignoreData) {
QByteArray fragment(reinterpret_cast<const char *>(inboundFrame.dataBegin()),
inboundFrame.dataSize());
if (endStream)
@@ -1245,16 +1246,12 @@ void QHttp2Connection::connectionError(Http2Error errorCode, const char *message
{
Q_ASSERT(message);
// RFC 9113, 6.8: An endpoint MAY send multiple GOAWAY frames if circumstances change.
- // Anyway, we do not send multiple GOAWAY frames.
- if (m_goingAway)
- return;
qCCritical(qHttp2ConnectionLog, "[%p] Connection error: %s (%d)", this, message,
int(errorCode));
// RFC 9113, 6.8: Endpoints SHOULD always send a GOAWAY frame before closing a connection so
// that the remote peer can know whether a stream has been partially processed or not.
- m_goingAway = true;
sendGOAWAY(errorCode);
auto messageView = QLatin1StringView(message);
@@ -1295,6 +1292,20 @@ bool QHttp2Connection::isInvalidStream(quint32 streamID) noexcept
return (!stream || stream->wasResetbyPeer()) && !streamWasResetLocally(streamID);
}
+/*!
+ When we send a GOAWAY we also send the ID of the last stream we know about
+ at the time. Any stream that starts after this one is ignored, but we still
+ have to process HEADERS due to compression state, and DATA due to stream and
+ connection window size changes.
+ Other than that - any \a streamID for which this returns true should be
+ ignored, and deleted at the earliest convenience.
+*/
+bool QHttp2Connection::streamIsIgnored(quint32 streamID) const noexcept
+{
+ const bool streamIsRemote = (streamID & 1) == (m_connectionType == Type::Client ? 0 : 1);
+ return Q_UNLIKELY(streamIsRemote && m_lastStreamToProcess < streamID);
+}
+
bool QHttp2Connection::sendClientPreface()
{
QIODevice *socket = getSocket();
@@ -1359,9 +1370,16 @@ bool QHttp2Connection::sendWINDOW_UPDATE(quint32 streamID, quint32 delta)
bool QHttp2Connection::sendGOAWAY(Http2::Http2Error errorCode)
{
+ m_goingAway = true;
+ // If this is the first time, start the timer:
+ if (m_lastStreamToProcess == Http2::lastValidStreamID)
+ m_goawayGraceTimer.setRemainingTime(GoawayGracePeriod);
+ m_lastStreamToProcess = std::min(m_lastIncomingStreamID, m_lastStreamToProcess);
+ qCDebug(qHttp2ConnectionLog, "[%p] Sending GOAWAY frame, error code %u, last stream %u", this,
+ errorCode, m_lastStreamToProcess);
frameWriter.start(FrameType::GOAWAY, FrameFlag::EMPTY,
Http2PredefinedParameters::connectionStreamID);
- frameWriter.append(quint32(m_lastIncomingStreamID));
+ frameWriter.append(m_lastStreamToProcess);
frameWriter.append(quint32(errorCode));
return frameWriter.write(*getSocket());
}
@@ -1411,8 +1429,20 @@ void QHttp2Connection::handleDATA()
if (stream)
stream->handleDATA(inboundFrame);
- if (inboundFrame.flags().testFlag(FrameFlag::END_STREAM))
- emit receivedEND_STREAM(streamID);
+
+ if (inboundFrame.flags().testFlag(FrameFlag::END_STREAM)) {
+ const bool ignoreData = stream && streamIsIgnored(stream->streamID());
+ if (!ignoreData) {
+ emit receivedEND_STREAM(streamID);
+ } else {
+ // Stream opened after our GOAWAY cut-off. We would just drop the
+ // data, but needed to handle it enough to track sizes of streams and
+ // connection windows. Since we've now taken care of that, we can
+ // at last close and delete it.
+ stream->setState(QHttp2Stream::State::Closed);
+ delete stream;
+ }
+ }
if (sessionReceiveWindowSize < maxSessionReceiveWindowSize / 2) {
// @future[consider]: emit signal instead
@@ -1454,8 +1484,15 @@ void QHttp2Connection::handleHEADERS()
return;
}
- qCDebug(qHttp2ConnectionLog, "[%p] Created new incoming stream %d", this, streamID);
- emit newIncomingStream(newStream);
+ qCDebug(qHttp2ConnectionLog, "[%p] New incoming stream %d", this, streamID);
+ if (!streamIsIgnored(newStream->streamID())) {
+ emit newIncomingStream(newStream);
+ } else if (m_goawayGraceTimer.hasExpired()) {
+ // We gave the peer some time to handle the GOAWAY message, but they have started a new
+ // stream, so we error out.
+ connectionError(Http2Error::PROTOCOL_ERROR, "Peer refused to GOAWAY.");
+ return;
+ }
} else if (streamWasResetLocally(streamID)) {
qCDebug(qHttp2ConnectionLog,
"[%p] Received HEADERS on previously locally reset stream %d (must process but ignore)",
@@ -1500,6 +1537,9 @@ void QHttp2Connection::handlePRIORITY()
|| inboundFrame.type() == FrameType::HEADERS);
const auto streamID = inboundFrame.streamID();
+ if (streamIsIgnored(streamID))
+ return;
+
// RFC 9913, 6.3: If a PRIORITY frame is received with a stream identifier of 0x00, the
// recipient MUST respond with a connection error
if (streamID == connectionStreamID)
@@ -1534,11 +1574,14 @@ void QHttp2Connection::handleRST_STREAM()
{
Q_ASSERT(inboundFrame.type() == FrameType::RST_STREAM);
+ const auto streamID = inboundFrame.streamID();
+ if (streamIsIgnored(streamID))
+ return;
+
// RFC 9113, 6.4: RST_STREAM frames MUST be associated with a stream.
// If a RST_STREAM frame is received with a stream identifier of 0x0,
// the recipient MUST treat this as a connection error (Section 5.4.1)
// of type PROTOCOL_ERROR.
- const auto streamID = inboundFrame.streamID();
if (streamID == connectionStreamID)
return connectionError(PROTOCOL_ERROR, "RST_STREAM on 0x0");
@@ -1764,31 +1807,33 @@ void QHttp2Connection::handleGOAWAY()
Q_ASSERT(inboundFrame.payloadSize() >= 8);
const uchar *const src = inboundFrame.dataBegin();
- quint32 lastStreamID = qFromBigEndian<quint32>(src);
+ // RFC 9113, 4.1: 31-bit Stream ID; lastValidStreamID(0x7FFFFFFF) masks out the reserved MSB
+ const quint32 lastStreamID = qFromBigEndian<quint32>(src) & lastValidStreamID;
const Http2Error errorCode = Http2Error(qFromBigEndian<quint32>(src + 4));
- if (!lastStreamID) {
- // "The last stream identifier can be set to 0 if no
- // streams were processed."
- lastStreamID = 1;
- } else if (!(lastStreamID & 0x1)) {
- // 5.1.1 - we (client) use only odd numbers as stream identifiers.
+ // 6.8 "the GOAWAY contains the stream identifier of the last peer-initiated stream that was
+ // or might be processed on the sending endpoint in this connection."
+ // Alternatively, they can specify 0 as the last stream ID, meaning they are not intending to
+ // process any remaining stream(s).
+ const quint32 LocalMask = m_connectionType == Type::Client ? 1 : 0;
+ // The stream must match the LocalMask, meaning we initiated it, for the last stream ID to make
+ // sense - they are not processing their own streams.
+ if (lastStreamID != 0 && (lastStreamID & 0x1) != LocalMask)
return connectionError(PROTOCOL_ERROR, "GOAWAY with invalid last stream ID");
- } else if (lastStreamID >= m_nextStreamID) {
- // "A server that is attempting to gracefully shut down a connection SHOULD
- // send an initial GOAWAY frame with the last stream identifier set to 2^31-1
- // and a NO_ERROR code."
- if (lastStreamID != lastValidStreamID || errorCode != HTTP2_NO_ERROR)
- return connectionError(PROTOCOL_ERROR, "GOAWAY invalid stream/error code");
- } else {
- lastStreamID += 2;
- }
+ qCDebug(qHttp2ConnectionLog, "[%p] Received GOAWAY frame, error code %u, last stream %u",
+ this, errorCode, lastStreamID);
m_goingAway = true;
emit receivedGOAWAY(errorCode, lastStreamID);
- for (quint32 id = lastStreamID; id < m_nextStreamID; id += 2) {
+ // Since the embedded stream ID is the last one that was or _might be_ processed,
+ // we cancel anything that comes after it. 0 can be used in the special case that
+ // no streams at all were or will be processed.
+ const quint32 firstPossibleStream = m_connectionType == Type::Client ? 1 : 2;
+ const quint32 firstCancelledStream = lastStreamID ? lastStreamID + 2 : firstPossibleStream;
+ Q_ASSERT((firstCancelledStream & 0x1) == LocalMask);
+ for (quint32 id = firstCancelledStream; id < m_nextStreamID; id += 2) {
QHttp2Stream *stream = m_streams.value(id, nullptr);
if (stream && stream->isActive())
stream->finishWithError(errorCode, "Received GOAWAY"_L1);
@@ -1809,7 +1854,8 @@ void QHttp2Connection::handleWINDOW_UPDATE()
// errors on the connection flow-control window MUST be treated as a connection error
const bool valid = delta && delta <= quint32(std::numeric_limits<qint32>::max());
const auto streamID = inboundFrame.streamID();
-
+ if (streamIsIgnored(streamID))
+ return;
// RFC 9113, 6.9: A WINDOW_UPDATE frame with a length other than 4 octets MUST be treated
// as a connection error (Section 5.4.1) of type FRAME_SIZE_ERROR.
@@ -1939,6 +1985,18 @@ void QHttp2Connection::handleContinuedHEADERS()
if (streamWasResetLocally(streamID) || streamIt == m_streams.cend())
return; // No more processing without a stream from here on.
+ if (streamIsIgnored(streamID)) {
+ // Stream was established after GOAWAY cut-off, we ignore it, but we
+ // have to process things that alter state. That already happened, so we
+ // stop here.
+ if (continuedFrames[0].flags().testFlag(Http2::FrameFlag::END_STREAM)) {
+ if (QHttp2Stream *stream = streamIt.value()) {
+ stream->setState(QHttp2Stream::State::Closed);
+ delete stream;
+ }
+ }
+ return;
+ }
switch (firstFrameType) {
case FrameType::HEADERS:
diff --git a/src/network/access/qhttp2connection_p.h b/src/network/access/qhttp2connection_p.h
index dcdc0f91318..f3f14145278 100644
--- a/src/network/access/qhttp2connection_p.h
+++ b/src/network/access/qhttp2connection_p.h
@@ -283,6 +283,8 @@ private:
bool isInvalidStream(quint32 streamID) noexcept;
bool streamWasResetLocally(quint32 streamID) noexcept;
+ Q_ALWAYS_INLINE
+ bool streamIsIgnored(quint32 streamID) const noexcept;
void connectionError(Http2::Http2Error errorCode,
const char *message); // Connection failed to be established?
@@ -400,6 +402,10 @@ private:
bool m_goingAway = false;
bool pushPromiseEnabled = false;
quint32 m_lastIncomingStreamID = Http2::connectionStreamID;
+ // Gets lowered when/if we send GOAWAY:
+ quint32 m_lastStreamToProcess = Http2::lastValidStreamID;
+ static constexpr std::chrono::duration GoawayGracePeriod = std::chrono::seconds(60);
+ QDeadlineTimer m_goawayGraceTimer;
bool m_prefaceSent = false;
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 9f59d11375b..ffd5d8ff333 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -859,6 +859,10 @@ void QHttpNetworkConnectionChannel::_q_disconnected()
state = QHttpNetworkConnectionChannel::ReadingState;
_q_receiveReply();
}
+ } else if (reply && reply->contentLength() == -1 && !reply->d_func()->isChunked()) {
+ // There was no content-length header and it's not chunked encoding,
+ // so this is a valid way to have the connection closed by the server
+ _q_receiveReply();
} else if (state == QHttpNetworkConnectionChannel::IdleState && resendCurrent) {
// re-sending request because the socket was in ClosingState
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
diff --git a/src/network/access/qhttpnetworkheader.cpp b/src/network/access/qhttpnetworkheader.cpp
index acb4fcfa8e1..d09d856e441 100644
--- a/src/network/access/qhttpnetworkheader.cpp
+++ b/src/network/access/qhttpnetworkheader.cpp
@@ -4,8 +4,6 @@
#include "qhttpnetworkheader_p.h"
-#include <algorithm>
-
QT_BEGIN_NAMESPACE
QHttpNetworkHeader::~QHttpNetworkHeader()
diff --git a/src/network/access/qnetworkaccesscachebackend_p.h b/src/network/access/qnetworkaccesscachebackend_p.h
index 0bf0fdceea8..4014bbcf272 100644
--- a/src/network/access/qnetworkaccesscachebackend_p.h
+++ b/src/network/access/qnetworkaccesscachebackend_p.h
@@ -18,8 +18,6 @@
#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkaccessbackend_p.h"
-#include "qnetworkrequest.h"
-#include "qnetworkreply.h"
QT_BEGIN_NAMESPACE
diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp
index 1424aa679ed..20314de5c1e 100644
--- a/src/network/access/qnetworkreply.cpp
+++ b/src/network/access/qnetworkreply.cpp
@@ -474,7 +474,7 @@ void QNetworkReply::close()
}
/*!
- \internal
+ \reimp
*/
bool QNetworkReply::isSequential() const
{
@@ -817,7 +817,7 @@ void QNetworkReply::ignoreSslErrors()
}
/*!
- \internal
+ \reimp
*/
qint64 QNetworkReply::writeData(const char *, qint64)
{
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index 87f113be5dc..5047fc77bd5 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -21,7 +21,6 @@
#include "QtCore/private/qduplicatetracker_p.h"
#include "QtCore/private/qtools_p.h"
-#include <ctype.h>
#if QT_CONFIG(datestring)
# include <stdio.h>
#endif
diff --git a/src/network/configure.cmake b/src/network/configure.cmake
index baadf23dbd7..5dd2af418fa 100644
--- a/src/network/configure.cmake
+++ b/src/network/configure.cmake
@@ -7,8 +7,12 @@
#### Libraries
+qt_feature_vcpkg_scope(network)
qt_find_package(WrapBrotli MODULE
- PROVIDED_TARGETS WrapBrotli::WrapBrotliDec MODULE_NAME network QMAKE_LIB brotli)
+ PROVIDED_TARGETS WrapBrotli::WrapBrotliDec MODULE_NAME network QMAKE_LIB brotli
+ VCPKG_PORT brotli
+ VCPKG_ADD_TO_FEATURE brotli
+)
qt_find_package(Libproxy MODULE
PROVIDED_TARGETS PkgConfig::Libproxy MODULE_NAME network QMAKE_LIB libproxy)
qt_find_package(GSSAPI MODULE PROVIDED_TARGETS GSSAPI::GSSAPI MODULE_NAME network QMAKE_LIB gssapi)
diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp
index 76928bfb2c4..4e2a4e34e0e 100644
--- a/src/network/socket/qlocalsocket_unix.cpp
+++ b/src/network/socket/qlocalsocket_unix.cpp
@@ -68,7 +68,11 @@ void QLocalSocketPrivate::init()
// QIODevice signals
q->connect(&unixSocket, SIGNAL(bytesWritten(qint64)),
q, SIGNAL(bytesWritten(qint64)));
+ q->connect(&unixSocket, SIGNAL(channelBytesWritten(int, qint64)),
+ q, SIGNAL(channelBytesWritten(int, qint64)));
q->connect(&unixSocket, SIGNAL(readyRead()), q, SIGNAL(readyRead()));
+ q->connect(&unixSocket, SIGNAL(channelReadyRead(int)),
+ q, SIGNAL(channelReadyRead(int)));
// QAbstractSocket signals
q->connect(&unixSocket, SIGNAL(connected()), q, SIGNAL(connected()));
q->connect(&unixSocket, SIGNAL(disconnected()), q, SIGNAL(disconnected()));
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 93123b6553b..46859a2ab1f 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -1844,7 +1844,7 @@ void QSslSocket::continueInterruptedHandshake()
}
/*!
- \internal
+ \reimp
*/
void QSslSocket::connectToHost(const QString &hostName, quint16 port, OpenMode openMode, NetworkLayerProtocol protocol)
{
@@ -1875,7 +1875,7 @@ void QSslSocket::connectToHost(const QString &hostName, quint16 port, OpenMode o
}
/*!
- \internal
+ \reimp
*/
void QSslSocket::disconnectFromHost()
{
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
index 9a491d4d058..35fb7f24dd5 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h
@@ -29,7 +29,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSStatusItem);
QT_BEGIN_NAMESPACE
-class Q_GUI_EXPORT QCocoaSystemTrayIcon : public QPlatformSystemTrayIcon
+class QCocoaSystemTrayIcon : public QPlatformSystemTrayIcon
{
public:
QCocoaSystemTrayIcon() {}
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/dmabuf-server/dmabufserverbufferintegration.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/dmabuf-server/dmabufserverbufferintegration.h
index 13dbdfbfbab..41946105f08 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/dmabuf-server/dmabufserverbufferintegration.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/dmabuf-server/dmabufserverbufferintegration.h
@@ -1,15 +1,13 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef DMABUFSERVERBUFFERINTEGRATION_H
-#define DMABUFSERVERBUFFERINTEGRATION_H
+#pragma once
#include <QtCore/QVariant>
#include <QtWaylandClient/private/qwayland-wayland.h>
#include "qwayland-qt-dmabuf-server-buffer.h"
#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h>
-#include "dmabufserverbufferintegration.h"
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtCore/QTextStream>
@@ -107,5 +105,3 @@ void DmaBufServerBufferIntegration::glEGLImageTargetTexture2DOES(GLenum target,
}
QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drmeglserverbufferintegration.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drmeglserverbufferintegration.h
index a06bc96b87d..68db25dbfc5 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drmeglserverbufferintegration.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drmeglserverbufferintegration.h
@@ -1,15 +1,13 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef DRMEGLSERVERBUFFERINTEGRATION_H
-#define DRMEGLSERVERBUFFERINTEGRATION_H
+#pragma once
#include <QtWaylandClient/private/qwayland-wayland.h>
#include <QtCore/QVariant>
#include "qwayland-drm-egl-server-buffer.h"
#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h>
-#include "drmeglserverbufferintegration.h"
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtCore/QTextStream>
@@ -102,5 +100,3 @@ void DrmEglServerBufferIntegration::glEGLImageTargetTexture2DOES (GLenum target,
}
QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/shm-emulation-server/shmserverbufferintegration.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/shm-emulation-server/shmserverbufferintegration.h
index 344046ae182..d112fb32385 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/shm-emulation-server/shmserverbufferintegration.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/shm-emulation-server/shmserverbufferintegration.h
@@ -1,14 +1,12 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef SHMSERVERBUFFERINTEGRATION_H
-#define SHMSERVERBUFFERINTEGRATION_H
+#pragma once
#include <QtWaylandClient/private/qwayland-wayland.h>
#include "qwayland-shm-emulation-server-buffer.h"
#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h>
-#include "shmserverbufferintegration.h"
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtCore/QTextStream>
@@ -51,5 +49,3 @@ private:
}
QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/vulkan-server/vulkanserverbufferintegration.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/vulkan-server/vulkanserverbufferintegration.h
index 2f0867a8197..9d86c61a366 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/vulkan-server/vulkanserverbufferintegration.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/vulkan-server/vulkanserverbufferintegration.h
@@ -1,14 +1,12 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef VULKANSERVERBUFFERINTEGRATION_H
-#define VULKANSERVERBUFFERINTEGRATION_H
+#pragma once
#include <QtWaylandClient/private/qwayland-wayland.h>
#include "qwayland-qt-vulkan-server-buffer-unstable-v1.h"
#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h>
-#include "vulkanserverbufferintegration.h"
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtCore/QTextStream>
@@ -62,5 +60,3 @@ private:
}
QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h
index 9890d14f137..756d139cac1 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h
@@ -1,19 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-//
-// 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.
-//
-
-#ifndef QWAYLANDEGLINTEGRATION_H
-#define QWAYLANDEGLINTEGRATION_H
+#pragma once
#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h>
@@ -59,5 +47,3 @@ private:
QT_END_NAMESPACE
}
-
-#endif // QWAYLANDEGLINTEGRATION_H
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglinclude_p.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglinclude_p.h
index aa45d1b1759..b18c01ac267 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglinclude_p.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglinclude_p.h
@@ -1,20 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-
-//
-// 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.
-//
-
-#ifndef QWAYLANDEGLINCLUDE_H
-#define QWAYLANDEGLINCLUDE_H
+#pragma once
#include <string.h>
#include <wayland-client-core.h>
@@ -23,5 +10,3 @@
#define EGL_EGLEXT_PROTOTYPES
#include <QtGui/private/qt_egl_p.h>
-
-#endif // QWAYLANDEGLINCLUDE_H
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglwindow_p.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglwindow_p.h
index dc2e0319519..863bd7f0e53 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglwindow_p.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglwindow_p.h
@@ -1,19 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-//
-// 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.
-//
-
-#ifndef QWAYLANDEGLWINDOW_H
-#define QWAYLANDEGLWINDOW_H
+#pragma once
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include "qwaylandeglinclude_p.h"
@@ -72,5 +60,3 @@ private:
}
QT_END_NAMESPACE
-
-#endif // QWAYLANDEGLWINDOW_H
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h
index 543c31fd727..7ea7019dfe5 100644
--- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h
+++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h
@@ -1,19 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-//
-// 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.
-//
-
-#ifndef QWAYLANDGLCONTEXT_H
-#define QWAYLANDGLCONTEXT_H
+#pragma once
#include "qwaylandeglinclude_p.h" //must be first
@@ -71,5 +59,3 @@ private:
}
QT_END_NAMESPACE
-
-#endif // QWAYLANDGLCONTEXT_H
diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h b/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h
index 006f648e4d6..693c179fe29 100644
--- a/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h
+++ b/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h
@@ -1,8 +1,7 @@
// Copyright (C) 2018 Pier Luigi Fiorini <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef QWAYLANDFULLSCREENSHELLV1INTEGRATION_H
-#define QWAYLANDFULLSCREENSHELLV1INTEGRATION_H
+#pragma once
#include <wayland-client-core.h>
#include <QtWaylandClient/private/qwayland-wayland.h>
@@ -27,5 +26,3 @@ public:
} // namespace QtWaylandClient
QT_END_NAMESPACE
-
-#endif // QWAYLANDFULLSCREENSHELLV1INTEGRATION_H
diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h b/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h
index 0a82e5eee2a..12f551d1031 100644
--- a/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h
+++ b/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h
@@ -1,8 +1,7 @@
// Copyright (C) 2018 Pier Luigi Fiorini <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef QWAYLANDFULLSCREENSHELLV1SURFACE_H
-#define QWAYLANDFULLSCREENSHELLV1SURFACE_H
+#pragma once
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
@@ -28,5 +27,3 @@ private:
} // namespace QtWaylandClient
QT_END_NAMESPACE
-
-#endif // QWAYLANDFULLSCREENSHELLV1SURFACE_H
diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h
index 780f5f3268e..6d86600bad2 100644
--- a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h
+++ b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h
@@ -82,8 +82,8 @@ private:
friend class QWaylandWindow;
};
-QT_END_NAMESPACE
+} // namespace QtWaylandClient
-}
+QT_END_NAMESPACE
#endif // QWAYLANDSHELLSURFACE_H
diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h
index bddb5c614e0..fd107f825e1 100644
--- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h
+++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h
@@ -1,19 +1,7 @@
// Copyright (C) 2020 Aleix Pol Gonzalez <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef QWAYLANDXDGACTIVATIONV1_P_H
-#define QWAYLANDXDGACTIVATIONV1_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.
-//
+#pragma once
#include <QObject>
#include "qwayland-xdg-activation-v1.h"
@@ -52,8 +40,6 @@ public:
const QString &app_id);
};
-QT_END_NAMESPACE
-
-}
+} // namespace QtWaylandClient
-#endif // QWAYLANDXDGACTIVATIONV1_P_H
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h
index 8a0cc9e79a7..fc2e67b97c4 100644
--- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h
+++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h
@@ -1,19 +1,7 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef QWAYLANDXDGDECORATIONV1_P_H
-#define QWAYLANDXDGDECORATIONV1_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.
-//
+#pragma once
#include "qwayland-xdg-decoration-unstable-v1.h"
@@ -56,8 +44,6 @@ private:
bool m_configured = false;
};
-QT_END_NAMESPACE
-
-}
+} // namespace QtWaylandClient
-#endif // QWAYLANDXDGDECORATIONV1_P_H
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h
index f5465a63e6f..27ebc8d5afa 100644
--- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h
+++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h
@@ -1,8 +1,7 @@
// Copyright (C) 2022 David Reondo <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef QWAYLANDDIALOGV1_P_H
-#define QWAYLANDDIALOGV1_P_H
+#pragma once
#include <qwayland-xdg-dialog-v1.h>
@@ -28,5 +27,3 @@ public:
} // namespace QtWaylandClient
QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h
index c993e390a24..aa48e38c34b 100644
--- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h
+++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h
@@ -1,19 +1,7 @@
// Copyright (C) 2022 David Reondo <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef QWAYLANDXDGEXPORTERV2_H
-#define QWAYLANDXDGEXPORTERV2_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.
-//
+#pragma once
#include <qwayland-xdg-foreign-unstable-v2.h>
@@ -45,5 +33,3 @@ public:
}
QT_END_NAMESPACE
-
-#endif // QWAYLANDXDGEXPORTERV2_H
diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
index a12311eff74..bfecff41758 100644
--- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
@@ -2,19 +2,7 @@
// Copyright (C) 2017 Eurogiciel, author: <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef QWAYLANDXDGSHELL_H
-#define QWAYLANDXDGSHELL_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.
-//
+#pragma once
#include "qwayland-xdg-shell.h"
@@ -201,8 +189,6 @@ private:
friend class QWaylandXdgSurface;
};
-QT_END_NAMESPACE
-
-}
+} // namespace QtWaylandClient
-#endif // QWAYLANDXDGSHELL_H
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
index b7627d80462..82b2e005edd 100644
--- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
@@ -1,19 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef QWAYLANDXDGSHELLINTEGRATION_P_H
-#define QWAYLANDXDGSHELLINTEGRATION_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.
-//
+#pragma once
#include "qwayland-xdg-shell.h"
@@ -47,5 +35,3 @@ private:
}
QT_END_NAMESPACE
-
-#endif // QWAYLANDXDGSHELLINTEGRATION_P_H
diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1_p.h
index 63e379c4daf..25e06183f2f 100644
--- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1_p.h
+++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1_p.h
@@ -2,19 +2,7 @@
// Copyright (C) 2024 David Edmundson <[email protected]>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-#ifndef QWAYLANDTOPLEVELICONV1_P_H
-#define QWAYLANDTOPLEVELICONV1_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.
-//
+#pragma once
#include "wayland-xdg-shell-client-protocol.h"
#include <qwayland-xdg-toplevel-icon-v1.h>
@@ -45,8 +33,7 @@ private:
QList<int> mPreferredSizes;
QWaylandDisplay *mDisplay;
};
+
} // namespace QtWaylandClient
QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/platforms/wayland/qwaylandinputcontext.cpp b/src/plugins/platforms/wayland/qwaylandinputcontext.cpp
index 5ab285ad97d..0ccc4dba57a 100644
--- a/src/plugins/platforms/wayland/qwaylandinputcontext.cpp
+++ b/src/plugins/platforms/wayland/qwaylandinputcontext.cpp
@@ -192,12 +192,10 @@ void QWaylandInputContext::setFocusObject(QObject *object)
if (window && window->handle()) {
if (mCurrentWindow.data() != window) {
if (!inputMethodAccepted()) {
- if (mCurrentWindow) {
- auto *surface = static_cast<QWaylandWindow *>(mCurrentWindow->handle())->wlSurface();
- if (surface)
- inputInterface->disableSurface(surface);
- mCurrentWindow.clear();
- }
+ auto *surface = static_cast<QWaylandWindow *>(window->handle())->wlSurface();
+ if (surface)
+ inputInterface->disableSurface(surface);
+ mCurrentWindow.clear();
} else {
auto *surface = static_cast<QWaylandWindow *>(window->handle())->wlSurface();
if (surface) {
diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
index 63e16260b62..6962d28e7d0 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
+++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
@@ -11,68 +11,112 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
-QWindowsWindowClassDescription QWindowsWindowClassDescription::fromName(QString name, WNDPROC procedure)
+QString QWindowsWindowClassDescription::classNameSuffix(Qt::WindowFlags type, unsigned int style, bool hasIcon)
{
- return { std::move(name), procedure };
+ QString suffix;
+
+ switch (type) {
+ case Qt::Popup:
+ suffix += "Popup"_L1;
+ break;
+ case Qt::Tool:
+ suffix += "Tool"_L1;
+ break;
+ case Qt::ToolTip:
+ suffix += "ToolTip"_L1;
+ break;
+ default:
+ break;
+ }
+
+ if (style & CS_DROPSHADOW)
+ suffix += "DropShadow"_L1;
+ if (style & CS_SAVEBITS)
+ suffix += "SaveBits"_L1;
+ if (style & CS_OWNDC)
+ suffix += "OwnDC"_L1;
+ if (hasIcon)
+ suffix += "Icon"_L1;
+
+ return suffix;
}
-QWindowsWindowClassDescription QWindowsWindowClassDescription::fromWindow(const QWindow *window, WNDPROC procedure)
+bool QWindowsWindowClassDescription::computeHasIcon(Qt::WindowFlags flags, Qt::WindowFlags type)
{
- Q_ASSERT(window);
-
- QWindowsWindowClassDescription description;
- description.procedure = procedure;
+ bool hasIcon = true;
- const Qt::WindowFlags flags = window->flags();
- const Qt::WindowFlags type = flags & Qt::WindowType_Mask;
- // Determine style and icon.
- description.style = CS_DBLCLKS;
- description.hasIcon = true;
- // The following will not set CS_OWNDC for any widget window, even if it contains a
- // QOpenGLWidget or QQuickWidget later on. That cannot be detected at this stage.
- if (window->surfaceType() == QSurface::OpenGLSurface || (flags & Qt::MSWindowsOwnDC))
- description.style |= CS_OWNDC;
- if (!(flags & Qt::NoDropShadowWindowHint)
- && (type == Qt::Popup || window->property("_q_windowsDropShadow").toBool())) {
- description.style |= CS_DROPSHADOW;
- }
switch (type) {
case Qt::Tool:
case Qt::ToolTip:
case Qt::Popup:
- description.style |= CS_SAVEBITS; // Save/restore background
- description.hasIcon = false;
+ hasIcon = false;
break;
case Qt::Dialog:
if (!(flags & Qt::WindowSystemMenuHint))
- description.hasIcon = false; // QTBUG-2027, dialogs without system menu.
+ hasIcon = false; // QTBUG-2027, dialogs without system menu.
break;
}
- // Create a unique name for the flag combination
- description.name = "QWindow"_L1;
+
+ return hasIcon;
+}
+
+unsigned int QWindowsWindowClassDescription::computeWindowStyles(Qt::WindowFlags flags, Qt::WindowFlags type, WindowStyleOptions options)
+{
+ unsigned int style = CS_DBLCLKS;
+
+ // The following will not set CS_OWNDC for any widget window, even if it contains a
+ // QOpenGLWidget or QQuickWidget later on. That cannot be detected at this stage.
+ if (options.testFlag(WindowStyleOption::GLSurface) || (flags & Qt::MSWindowsOwnDC))
+ style |= CS_OWNDC;
+ if (!(flags & Qt::NoDropShadowWindowHint) && (type == Qt::Popup || options.testFlag(WindowStyleOption::DropShadow)))
+ style |= CS_DROPSHADOW;
+
switch (type) {
case Qt::Tool:
- description.name += "Tool"_L1;
- break;
case Qt::ToolTip:
- description.name += "ToolTip"_L1;
- break;
case Qt::Popup:
- description.name += "Popup"_L1;
- break;
- default:
+ style |= CS_SAVEBITS; // Save/restore background
break;
}
- if (description.style & CS_DROPSHADOW)
- description.name += "DropShadow"_L1;
- if (description.style & CS_SAVEBITS)
- description.name += "SaveBits"_L1;
- if (description.style & CS_OWNDC)
- description.name += "OwnDC"_L1;
- if (description.hasIcon)
- description.name += "Icon"_L1;
+
+ return style;
+}
+
+QWindowsWindowClassDescription QWindowsWindowClassDescription::fromName(QString name, WNDPROC procedure)
+{
+ return { std::move(name), procedure };
+}
+
+QWindowsWindowClassDescription QWindowsWindowClassDescription::fromWindow(const QWindow *window, WNDPROC procedure)
+{
+ Q_ASSERT(window);
+
+ const Qt::WindowFlags flags = window->flags();
+ const Qt::WindowFlags type = flags & Qt::WindowType_Mask;
+
+ WindowStyleOptions options = WindowStyleOption::None;
+ if (window->surfaceType() == QSurface::OpenGLSurface)
+ options |= WindowStyleOption::GLSurface;
+ if (window->property("_q_windowsDropShadow").toBool())
+ options |= WindowStyleOption::DropShadow;
+
+ QWindowsWindowClassDescription description;
+ description.procedure = procedure;
+ description.style = computeWindowStyles(flags, type, options);
+ description.hasIcon = computeHasIcon(flags, type);
+ description.name = "QWindow"_L1 + classNameSuffix(type, description.style, description.hasIcon);
return description;
}
+QDebug operator<<(QDebug dbg, const QWindowsWindowClassDescription &description)
+{
+ dbg << description.name
+ << " style=0x" << Qt::hex << description.style << Qt::dec
+ << " brush=" << description.brush
+ << " hasIcon=" << description.hasIcon;
+
+ return dbg;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.h b/src/plugins/platforms/windows/qwindowswindowclassdescription.h
index 9423abf9d2d..f0019f8f3c2 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassdescription.h
+++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.h
@@ -14,6 +14,14 @@ class QWindow;
struct QWindowsWindowClassDescription
{
+ enum class WindowStyleOption
+ {
+ None = 0x00,
+ GLSurface = 0x01,
+ DropShadow = 0x02
+ };
+ Q_DECLARE_FLAGS(WindowStyleOptions, WindowStyleOption)
+
static QWindowsWindowClassDescription fromName(QString name, WNDPROC procedure);
static QWindowsWindowClassDescription fromWindow(const QWindow *window, WNDPROC procedure);
@@ -23,8 +31,17 @@ struct QWindowsWindowClassDescription
HBRUSH brush{ nullptr };
bool hasIcon{ false };
bool shouldAddPrefix{ true };
+
+private:
+ static QString classNameSuffix(Qt::WindowFlags type, unsigned int style, bool hasIcon);
+ static bool computeHasIcon(Qt::WindowFlags flags, Qt::WindowFlags type);
+ static unsigned int computeWindowStyles(Qt::WindowFlags flags, Qt::WindowFlags type, WindowStyleOptions options);
+
+ friend QDebug operator<<(QDebug dbg, const QWindowsWindowClassDescription &description);
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowsWindowClassDescription::WindowStyleOptions)
+
QT_END_NAMESPACE
#endif // QWINDOWSWINDOWCLASSDESCRIPTION_H
diff --git a/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp b/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp
index c330720a09c..8bf2fb887f1 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp
+++ b/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp
@@ -18,8 +18,8 @@ Q_LOGGING_CATEGORY(lcQpaWindowClass, "qt.qpa.windowclass")
QWindowsWindowClassRegistry *QWindowsWindowClassRegistry::m_instance = nullptr;
-QWindowsWindowClassRegistry::QWindowsWindowClassRegistry(WNDPROC proc)
- : m_proc(proc)
+QWindowsWindowClassRegistry::QWindowsWindowClassRegistry(WNDPROC defaultProcedure)
+ : m_defaultProcedure(defaultProcedure)
{
m_instance = this;
}
@@ -69,25 +69,19 @@ QString QWindowsWindowClassRegistry::registerWindowClass(const QWindowsWindowCla
// add a UUID. The check needs to be performed for each name
// in case new message windows are added (QTBUG-81347).
// Note: GetClassInfo() returns != 0 when a class exists.
- const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));
- WNDCLASS wcinfo;
- const bool classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(className.utf16()), &wcinfo) != FALSE
- && wcinfo.lpfnWndProc != description.procedure;
-
- if (classExists)
+ if (shouldDecorateWindowClassName(description))
className += QUuid::createUuid().toString();
if (m_registeredWindowClassNames.contains(className)) // already registered in our list
return className;
- WNDCLASSEX wc;
+ const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));
+
+ WNDCLASSEX wc{};
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = description.style;
wc.lpfnWndProc = description.procedure;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
wc.hInstance = appInstance;
- wc.hCursor = nullptr;
wc.hbrBackground = description.brush;
if (description.hasIcon) {
wc.hIcon = static_cast<HICON>(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE));
@@ -98,31 +92,25 @@ QString QWindowsWindowClassRegistry::registerWindowClass(const QWindowsWindowCla
}
else {
wc.hIcon = static_cast<HICON>(LoadImage(nullptr, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
- wc.hIconSm = nullptr;
}
}
- else {
- wc.hIcon = nullptr;
- wc.hIconSm = nullptr;
- }
- wc.lpszMenuName = nullptr;
wc.lpszClassName = reinterpret_cast<LPCWSTR>(className.utf16());
ATOM atom = RegisterClassEx(&wc);
if (!atom)
- qErrnoWarning("QApplication::regClass: Registering window class '%s' failed.",
- qPrintable(className));
+ qCWarning(lcQpaWindowClass) << "Failed to register window class" << className
+ << "(" << qt_error_string(-1) << ")";
m_registeredWindowClassNames.insert(className);
- qCDebug(lcQpaWindowClass).nospace() << __FUNCTION__ << ' ' << className
- << " style=0x" << Qt::hex << description.style << Qt::dec
- << " brush=" << description.brush << " icon=" << description.hasIcon << " atom=" << atom;
+
+ qCDebug(lcQpaWindowClass).nospace() << __FUNCTION__ << ' ' << className << ' ' << description << " atom=" << atom;
+
return className;
}
QString QWindowsWindowClassRegistry::registerWindowClass(const QWindow *window)
{
- return registerWindowClass(QWindowsWindowClassDescription::fromWindow(window, m_proc));
+ return registerWindowClass(QWindowsWindowClassDescription::fromWindow(window, m_defaultProcedure));
}
QString QWindowsWindowClassRegistry::registerWindowClass(QString name, WNDPROC procedure)
@@ -130,13 +118,29 @@ QString QWindowsWindowClassRegistry::registerWindowClass(QString name, WNDPROC p
return registerWindowClass(QWindowsWindowClassDescription::fromName(name, procedure));
}
+bool QWindowsWindowClassRegistry::shouldDecorateWindowClassName(const QWindowsWindowClassDescription &description) const
+{
+ return shouldDecorateWindowClassName(description.name, description.procedure);
+}
+
+bool QWindowsWindowClassRegistry::shouldDecorateWindowClassName(const QString &name, WNDPROC procedure) const
+{
+ const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));
+
+ WNDCLASS wc{};
+
+ return GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(name.utf16()), &wc) != FALSE
+ && wc.lpfnWndProc != procedure;
+}
+
void QWindowsWindowClassRegistry::unregisterWindowClasses()
{
const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));
for (const QString &name : std::as_const(m_registeredWindowClassNames)) {
if (!UnregisterClass(reinterpret_cast<LPCWSTR>(name.utf16()), appInstance) && QWindowsContext::verbose)
- qErrnoWarning("UnregisterClass failed for '%s'", qPrintable(name));
+ qCWarning(lcQpaWindowClass) << "Failed to unregister window class" << name
+ << "(" << qt_error_string(-1) << ")";
}
m_registeredWindowClassNames.clear();
}
diff --git a/src/plugins/platforms/windows/qwindowswindowclassregistry.h b/src/plugins/platforms/windows/qwindowswindowclassregistry.h
index c19b4f616fb..c4a36b7f3c4 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassregistry.h
+++ b/src/plugins/platforms/windows/qwindowswindowclassregistry.h
@@ -22,7 +22,7 @@ class QWindowsWindowClassRegistry
{
Q_DISABLE_COPY_MOVE(QWindowsWindowClassRegistry)
public:
- QWindowsWindowClassRegistry(WNDPROC proc);
+ QWindowsWindowClassRegistry(WNDPROC defaultProcedure);
~QWindowsWindowClassRegistry();
static QWindowsWindowClassRegistry *instance();
@@ -34,11 +34,13 @@ public:
private:
static QString classNamePrefix();
+ bool shouldDecorateWindowClassName(const QWindowsWindowClassDescription &description) const;
+ bool shouldDecorateWindowClassName(const QString &name, WNDPROC procedure) const;
void unregisterWindowClasses();
static QWindowsWindowClassRegistry *m_instance;
- WNDPROC m_proc;
+ WNDPROC m_defaultProcedure;
QSet<QString> m_registeredWindowClassNames;
};
diff --git a/src/plugins/sqldrivers/configure.cmake b/src/plugins/sqldrivers/configure.cmake
index d96c220d70a..d12917f5631 100644
--- a/src/plugins/sqldrivers/configure.cmake
+++ b/src/plugins/sqldrivers/configure.cmake
@@ -13,12 +13,22 @@ set_property(CACHE INPUT_sqlite PROPERTY STRINGS undefined qt system)
#### Libraries
+qt_feature_vcpkg_scope(sql)
qt_find_package(DB2 MODULE PROVIDED_TARGETS DB2::DB2 MODULE_NAME sqldrivers QMAKE_LIB db2)
-qt_find_package(MySQL MODULE PROVIDED_TARGETS MySQL::MySQL MODULE_NAME sqldrivers QMAKE_LIB mysql)
-qt_find_package(PostgreSQL MODULE PROVIDED_TARGETS PostgreSQL::PostgreSQL MODULE_NAME sqldrivers QMAKE_LIB psql)
+qt_find_package(MySQL MODULE PROVIDED_TARGETS MySQL::MySQL MODULE_NAME sqldrivers QMAKE_LIB mysql
+ VCPKG_PORT libmysql
+ VCPKG_ADD_TO_FEATURE sql-mysql
+)
+qt_find_package(PostgreSQL MODULE PROVIDED_TARGETS PostgreSQL::PostgreSQL MODULE_NAME sqldrivers QMAKE_LIB psql
+ VCPKG_PORT libpq
+ VCPKG_ADD_TO_FEATURE sql-psql
+)
qt_find_package(Oracle MODULE PROVIDED_TARGETS Oracle::OCI MODULE_NAME sqldrivers QMAKE_LIB oci)
qt_find_package(ODBC PROVIDED_TARGETS ODBC::ODBC MODULE_NAME sqldrivers QMAKE_LIB odbc)
-qt_find_package(SQLite3 PROVIDED_TARGETS SQLite::SQLite3 MODULE_NAME sqldrivers QMAKE_LIB sqlite3)
+qt_find_package(SQLite3 PROVIDED_TARGETS SQLite::SQLite3 MODULE_NAME sqldrivers QMAKE_LIB sqlite3
+ VCPKG_PORT sqlite3
+ VCPKG_ADD_TO_FEATURE sql-sqlite
+)
qt_find_package(Interbase MODULE
PROVIDED_TARGETS Interbase::Interbase MODULE_NAME sqldrivers QMAKE_LIB ibase) # special case
qt_find_package(Mimer MODULE PROVIDED_TARGETS MimerSQL::MimerSQL MODULE_NAME sqldrivers QMAKE_LIB mimer)
@@ -60,6 +70,7 @@ qt_feature("sql-psql" PRIVATE
qt_feature("sql-sqlite" PRIVATE
LABEL "SQLite"
CONDITION QT_FEATURE_datestring
+ VCPKG_DEFAULT
)
qt_feature("system-sqlite" PRIVATE SYSTEM_LIBRARY
LABEL " Using system provided SQLite"
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp
index ffba4f775c8..13682256370 100644
--- a/src/plugins/styles/modernwindows/qwindows11style.cpp
+++ b/src/plugins/styles/modernwindows/qwindows11style.cpp
@@ -69,6 +69,10 @@ inline bool isAutoRaise(const QStyleOption *option)
{
return option->state.testFlag(QStyle::State_AutoRaise);
}
+inline bool hasFocus(const QStyleOption *option)
+{
+ return option->state.testFlag(QStyle::State_HasFocus);
+}
enum class ControlState { Normal, Hover, Pressed, Disabled };
inline ControlState calcControlState(const QStyleOption *option)
{
@@ -125,7 +129,7 @@ static constexpr int percentToAlpha(double percent)
return qRound(percent * 255. / 100.);
}
-static constexpr std::array<QColor, 33> WINUI3ColorsLight {
+static constexpr std::array<QColor, 34> WINUI3ColorsLight {
QColor(0x00,0x00,0x00,percentToAlpha(3.73)), // subtleHighlightColor (fillSubtleSecondary)
QColor(0x00,0x00,0x00,percentToAlpha(2.41)), // subtlePressedColor (fillSubtleTertiary)
QColor(0x00,0x00,0x00,0x0F), //frameColorLight
@@ -144,6 +148,7 @@ static constexpr std::array<QColor, 33> WINUI3ColorsLight {
QColor(0xF9,0xF9,0xF9,percentToAlpha(50)), // fillControlSecondary
QColor(0xF9,0xF9,0xF9,percentToAlpha(30)), // fillControlTertiary
QColor(0xF9,0xF9,0xF9,percentToAlpha(30)), // fillControlDisabled
+ QColor(0xFF,0xFF,0xFF,percentToAlpha(100)), // fillControlInputActive
QColor(0x00,0x00,0x00,percentToAlpha(2.41)), // fillControlAltSecondary
QColor(0x00,0x00,0x00,percentToAlpha(5.78)), // fillControlAltTertiary
QColor(0x00,0x00,0x00,percentToAlpha(9.24)), // fillControlAltQuarternary
@@ -161,7 +166,7 @@ static constexpr std::array<QColor, 33> WINUI3ColorsLight {
QColor(0x00,0x00,0x00,percentToAlpha(8.03)), // dividerStrokeDefault
};
-static constexpr std::array<QColor, 33> WINUI3ColorsDark {
+static constexpr std::array<QColor, 34> WINUI3ColorsDark {
QColor(0xFF,0xFF,0xFF,percentToAlpha(6.05)), // subtleHighlightColor (fillSubtleSecondary)
QColor(0xFF,0xFF,0xFF,percentToAlpha(4.19)), // subtlePressedColor (fillSubtleTertiary)
QColor(0xFF,0xFF,0xFF,0x12), //frameColorLight
@@ -180,6 +185,7 @@ static constexpr std::array<QColor, 33> WINUI3ColorsDark {
QColor(0xFF,0xFF,0xFF,percentToAlpha(8.37)), // fillControlSecondary
QColor(0xFF,0xFF,0xFF,percentToAlpha(3.26)), // fillControlTertiary
QColor(0xFF,0xFF,0xFF,percentToAlpha(4.19)), // fillControlDisabled
+ QColor(0x1E,0x1E,0x1E,percentToAlpha(70)), // fillControlInputActive
QColor(0x00,0x00,0x00,percentToAlpha(10.0)), // fillControlAltDefault
QColor(0xFF,0xFF,0xFF,percentToAlpha(4.19)), // fillControlAltSecondary
QColor(0xFF,0xFF,0xFF,percentToAlpha(6.98)), // fillControlAltTertiafillCy
@@ -197,7 +203,7 @@ static constexpr std::array<QColor, 33> WINUI3ColorsDark {
QColor(0xFF,0xFF,0xFF,percentToAlpha(8.37)), // dividerStrokeDefault
};
-static constexpr std::array<std::array<QColor,33>, 2> WINUI3Colors {
+static constexpr std::array<std::array<QColor,34>, 2> WINUI3Colors {
WINUI3ColorsLight,
WINUI3ColorsDark
};
@@ -990,16 +996,9 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
case PE_PanelLineEdit:
if (const auto *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
const auto frameRect = QRectF(option->rect).marginsRemoved(QMarginsF(1.5, 1.5, 1.5, 1.5));
- drawRoundedRect(painter, frameRect, Qt::NoPen, option->palette.brush(QPalette::Base));
-
+ drawRoundedRect(painter, frameRect, Qt::NoPen, inputFillBrush(option, widget));
if (panel->lineWidth > 0)
proxy()->drawPrimitive(PE_FrameLineEdit, panel, painter, widget);
-
- const bool isMouseOver = state & State_MouseOver;
- const bool hasFocus = state & State_HasFocus;
- const bool isEnabled = state & State_Enabled;
- if (isMouseOver && isEnabled && hasFocus && !highContrastTheme)
- drawRoundedRect(painter, frameRect, Qt::NoPen, winUI3Color(subtleHighlightColor));
}
break;
case PE_FrameLineEdit: {
@@ -2674,6 +2673,23 @@ QBrush QWindows11Style::controlFillBrush(const QStyleOption *option, ControlType
return winUI3Color(colorEnums[int(controlType)][int(state)]);
}
+QBrush QWindows11Style::inputFillBrush(const QStyleOption *option, const QWidget *widget) const
+{
+ // slightly different states than in controlFillBrush
+ using namespace StyleOptionHelper;
+ const auto role = widget ? widget->backgroundRole() : QPalette::Window;
+ if (option->palette.isBrushSet(QPalette::Current, role))
+ return option->palette.button();
+
+ if (isDisabled(option))
+ return winUI3Color(fillControlDisabled);
+ if (hasFocus(option))
+ return winUI3Color(fillControlInputActive);
+ if (isHover(option))
+ return winUI3Color(fillControlSecondary);
+ return winUI3Color(fillControlDefault);
+}
+
QColor QWindows11Style::controlTextColor(const QStyleOption *option, QPalette::ColorRole role) const
{
using namespace StyleOptionHelper;
diff --git a/src/plugins/styles/modernwindows/qwindows11style_p.h b/src/plugins/styles/modernwindows/qwindows11style_p.h
index a51a93ddd9b..96c2c4136e0 100644
--- a/src/plugins/styles/modernwindows/qwindows11style_p.h
+++ b/src/plugins/styles/modernwindows/qwindows11style_p.h
@@ -42,6 +42,7 @@ enum WINUI3Color {
fillControlSecondary, // button hover color (alpha)
fillControlTertiary, // button pressed color (alpha)
fillControlDisabled, // button disabled color (alpha)
+ fillControlInputActive, // input active
fillControlAltSecondary, // checkbox/RadioButton default color (alpha)
fillControlAltTertiary, // checkbox/RadioButton hover color (alpha)
fillControlAltQuarternary, // checkbox/RadioButton pressed color (alpha)
@@ -101,6 +102,7 @@ private:
ControlAlt
};
QBrush controlFillBrush(const QStyleOption *option, ControlType controlType) const;
+ QBrush inputFillBrush(const QStyleOption *option, const QWidget *widget) const;
// ControlType::ControlAlt can be mapped to QPalette directly
QColor controlTextColor(const QStyleOption *option,
QPalette::ColorRole role = QPalette::ButtonText) const;
diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp
index fd5f1efc7a0..2416110042a 100644
--- a/src/widgets/accessible/qaccessiblemenu.cpp
+++ b/src/widgets/accessible/qaccessiblemenu.cpp
@@ -146,6 +146,11 @@ int QAccessibleMenuBar::indexOfChild(const QAccessibleInterface *child) const
#endif // QT_CONFIG(menubar)
+/*!
+ \class QAccessibleMenuItem
+ \inmodule QtWidgets
+ \internal
+*/
QAccessibleMenuItem::QAccessibleMenuItem(QWidget *owner, QAction *action)
: m_action(action), m_owner(owner)
{
diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp
index b4adae2e6e6..6fd86004fff 100644
--- a/src/widgets/accessible/qaccessiblewidget.cpp
+++ b/src/widgets/accessible/qaccessiblewidget.cpp
@@ -455,6 +455,11 @@ QAccessibleWidgetV2::QAccessibleWidgetV2(QWidget *object, QAccessible::Role role
{
}
+/*!
+ \class QAccessibleWidgetV2
+ \inmodule QtWidgets
+ \internal
+*/
QAccessibleWidgetV2::QAccessibleWidgetV2(QWidget *object, QAccessible::Role role)
: QAccessibleWidget(object, role)
{
diff --git a/src/widgets/accessible/rangecontrols.cpp b/src/widgets/accessible/rangecontrols.cpp
index 1f7b20833dd..969fb74c2c1 100644
--- a/src/widgets/accessible/rangecontrols.cpp
+++ b/src/widgets/accessible/rangecontrols.cpp
@@ -34,6 +34,12 @@ using namespace Qt::StringLiterals;
#if QT_CONFIG(accessibility)
#if QT_CONFIG(spinbox)
+
+/*!
+ \class QAccessibleAbstractSpinBox
+ \inmodule QtWidgets
+ \internal
+*/
QAccessibleAbstractSpinBox::QAccessibleAbstractSpinBox(QWidget *w)
: QAccessibleWidgetV2(w, QAccessible::SpinBox), lineEdit(nullptr)
{
@@ -242,6 +248,12 @@ QSpinBox *QAccessibleSpinBox::spinBox() const
// ================================== QAccessibleDoubleSpinBox ==================================
+
+/*!
+ \class QAccessibleDoubleSpinBox
+ \inmodule QtWidgets
+ \internal
+*/
QAccessibleDoubleSpinBox::QAccessibleDoubleSpinBox(QWidget *widget)
: QAccessibleAbstractSpinBox(widget)
{
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 03a42e321d2..1f39dbfb516 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -4172,6 +4172,12 @@ QSize QFileDialogTreeView::sizeHint() const
}
/*!
+ \class QFileDialogLineEdit
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
// FIXME: this is a hack to avoid propagating key press events
// to the dialog and from there to the "Ok" button
*/
diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp
index a357d34f327..1ac2271fa8b 100644
--- a/src/widgets/dialogs/qsidebar.cpp
+++ b/src/widgets/dialogs/qsidebar.cpp
@@ -360,6 +360,11 @@ void QUrlModel::changed(const QString &path)
}
}
+/*!
+ \class QSidebar
+ \inmodule QtWidgets
+ \internal
+*/
QSidebar::QSidebar(QWidget *parent) : QListView(parent)
{
}
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 0b7877b96a6..0fe8f5b97fd 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -1087,6 +1087,12 @@ void QGraphicsScenePrivate::enableMouseTrackingOnViews()
}
/*!
+ \class QGraphicsScenePrivate
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
Returns all items for the screen position in \a event.
*/
QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &screenPos,
diff --git a/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp
index 5a8f76fe440..ddf91a99b4f 100644
--- a/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp
+++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp
@@ -58,6 +58,10 @@ static inline int intmaxlog(int n)
}
/*!
+ \class QGraphicsSceneBspTreeIndexPrivate
+ \inmodule QtWidgets
+ \internal
+
Constructs a private scene bsp index.
*/
QGraphicsSceneBspTreeIndexPrivate::QGraphicsSceneBspTreeIndexPrivate(QGraphicsScene *scene)
diff --git a/src/widgets/graphicsview/qgraphicssceneindex.cpp b/src/widgets/graphicsview/qgraphicssceneindex.cpp
index c37f4dfa977..2f9dba99941 100644
--- a/src/widgets/graphicsview/qgraphicssceneindex.cpp
+++ b/src/widgets/graphicsview/qgraphicssceneindex.cpp
@@ -170,6 +170,10 @@ namespace QtPrivate { // just to keep indentation of the following functions at
} // namespace QtPrivate
/*!
+ \class QGraphicsSceneIndexPrivate
+ \inmodule QtWidgets
+ \internal
+
Constructs a private scene index.
*/
QGraphicsSceneIndexPrivate::QGraphicsSceneIndexPrivate(QGraphicsScene *scene) : scene(scene)
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 657fc828074..2246ad6d39e 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -1119,6 +1119,12 @@ void QGraphicsViewPrivate::freeStyleOptionsArray(QStyleOptionGraphicsItem *array
Q_GUI_EXPORT extern QPainterPath qt_regionToPath(const QRegion &region);
/*!
+ \class QGraphicsViewPrivate
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
### Adjustments in findItems: mapToScene(QRect) forces us to adjust the
input rectangle by (0, 0, 1, 1), because it uses QRect::bottomRight()
(etc) when mapping the rectangle to a polygon (which is _wrong_). In
diff --git a/src/widgets/itemviews/qcolumnviewgrip.cpp b/src/widgets/itemviews/qcolumnviewgrip.cpp
index fe82c450c2d..269955a8d63 100644
--- a/src/widgets/itemviews/qcolumnviewgrip.cpp
+++ b/src/widgets/itemviews/qcolumnviewgrip.cpp
@@ -13,19 +13,18 @@ QT_BEGIN_NAMESPACE
/*
\internal
- class QColumnViewGrip
-
- QColumnViewGrip is created to go inside QAbstractScrollArea's corner.
- When the mouse it moved it will resize the scroll area and emit's a signal.
- */
-
-/*
- \internal
\fn void QColumnViewGrip::gripMoved()
Signal that is emitted when the grip moves the parent widget.
*/
/*!
+ \class QColumnViewGrip
+ \inmodule QtWidgets
+ \internal
+
+ QColumnViewGrip is created to go inside QAbstractScrollArea's corner.
+ When the mouse is moved it will resize the scroll area and emit a signal.
+
Creates a new QColumnViewGrip with the given \a parent to view a model.
Use setModel() to set the model.
*/
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index ff1bec803d7..e245f98151b 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -608,6 +608,12 @@ void QListViewPrivate::selectAll(QItemSelectionModel::SelectionFlags command)
}
/*!
+ \class QListViewPrivate
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
\reimp
We have a QListView way of knowing what elements are on the viewport
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index d175bf9c5a1..54279efe2f0 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -256,6 +256,12 @@ bool QListModel::removeRows(int row, int count, const QModelIndex &parent)
}
/*!
+ \class QListModel
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
\since 5.13
\reimp
*/
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 84ff04c9f34..e38d78b72f8 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -1453,6 +1453,12 @@ QRect QTreeViewPrivate::intersectedRect(const QRect rect, const QModelIndex &top
}
/*!
+ \class QTreeViewPrivate
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
\reimp
We have a QTreeView way of knowing what elements are on the viewport
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index 6b03b6f9f1a..f8ffaba3ec2 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -523,6 +523,12 @@ bool QTreeModel::setHeaderData(int section, Qt::Orientation orientation,
}
/*!
+ \class QTreeModel
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
\reimp
Returns the flags for the item referred to the given \a index.
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index fa95a1d2538..d2b0fb724ac 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -503,6 +503,12 @@ void qt_init_tooltip_palette()
extern void qRegisterWidgetsVariant();
/*!
+ \class QApplicationPrivate
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
Initializes the QApplication object, called from the constructors.
*/
void QApplicationPrivate::initialize()
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 5ba92714f6c..45b0c8d2aea 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -771,6 +771,12 @@ void QLayoutPrivate::reparentChildWidgets(QWidget *mw)
}
/*!
+ \class QLayoutPrivate
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
Returns \c true if the \a widget can be added to the \a layout;
otherwise returns \c false.
*/
diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp
index 93464264506..30526e38b3e 100644
--- a/src/widgets/kernel/qwidgetrepaintmanager.cpp
+++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp
@@ -597,6 +597,12 @@ static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget)
// ---------------------------------------------------------------------------
/*!
+ \class QWidgetRepaintManager
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
Synchronizes the \a exposedRegion of the \a exposedWidget with the backing store.
If there are dirty widgets, including but not limited to the \a exposedWidget,
@@ -1202,6 +1208,12 @@ bool QWidgetRepaintManager::isDirty() const
}
/*!
+ \class QWidgetPrivate
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
Invalidates the backing store when the widget is resized.
Static areas are never invalidated unless absolutely needed.
*/
diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp
index a05781cd439..41d02779039 100644
--- a/src/widgets/util/qflickgesture.cpp
+++ b/src/widgets/util/qflickgesture.cpp
@@ -293,6 +293,12 @@ QFlickGestureRecognizer::QFlickGestureRecognizer(Qt::MouseButton button)
this->button = button;
}
+/*!
+ \class QFlickGestureRecognizer
+ \inmodule QtWidgets
+ \internal
+*/
+
/*! \reimp
*/
QGesture *QFlickGestureRecognizer::create(QObject *target)
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 1dcbec27487..0182ab8531f 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -829,6 +829,12 @@ QAbstractItemView *QComboBoxPrivateContainer::itemView() const
}
/*!
+ \class QComboBoxPrivateContainer
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
Sets the item view to be used for the combobox popup.
*/
void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 784ce2c8d19..a2171eb3473 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -518,6 +518,12 @@ void QLabel::setMargin(int margin)
}
/*!
+ \class QLabelPrivate
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
Returns the size that will be used if the width of the label is \a
w. If \a w is -1, the sizeHint() is returned. If \a w is 0 minimumSizeHint() is returned
*/
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index ee80cca649c..0a083beeb25 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -293,6 +293,12 @@ void QLineEditPrivate::resetInputMethod()
}
/*!
+ \class QLineEditPrivate
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
This function is not intended as polymorphic usage. Just a shared code
fragment that calls QInputMethod::invokeAction for this
class.
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 1708a53f163..cec25faef3e 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -1541,6 +1541,12 @@ void QMainWindowLayout::removeToolBar(QToolBar *toolbar)
}
/*!
+ \class QMainWindowLayout
+ \inmodule QtWidgets
+ \internal
+*/
+
+/*!
Adds \a toolbar to \a area, continuing the current line.
*/
void QMainWindowLayout::addToolBar(Qt::ToolBarArea area,