JNI: Extract size check from fromContainer
Addresses header review comment. Change-Id: I302ae22da197fa8c317f0a4749d15b07fb5d0078 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit b5538a5a0ebf9bd9a155b857c385c764c30eabae) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
779e5faf1d
commit
abf6c88a86
@ -480,8 +480,7 @@ public:
|
|||||||
template <typename Container, if_compatible_source_container<Container> = true>
|
template <typename Container, if_compatible_source_container<Container> = true>
|
||||||
static auto fromContainer(Container &&container)
|
static auto fromContainer(Container &&container)
|
||||||
{
|
{
|
||||||
if (!q20::in_range<size_type>(std::size(container)))
|
verifySize(std::size(container));
|
||||||
qWarning("QJniArray::fromContainer: Container is too large for Java and will be truncated!");
|
|
||||||
using ElementType = typename std::remove_reference_t<Container>::value_type;
|
using ElementType = typename std::remove_reference_t<Container>::value_type;
|
||||||
if constexpr (std::is_base_of_v<std::remove_pointer_t<jobject>,
|
if constexpr (std::is_base_of_v<std::remove_pointer_t<jobject>,
|
||||||
std::remove_pointer_t<ElementType>>) {
|
std::remove_pointer_t<ElementType>>) {
|
||||||
@ -605,6 +604,13 @@ protected:
|
|||||||
void swap(QJniArrayBase &other) noexcept { m_object.swap(other.m_object); }
|
void swap(QJniArrayBase &other) noexcept { m_object.swap(other.m_object); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
template <typename container_size_type>
|
||||||
|
static void verifySize(container_size_type size)
|
||||||
|
{
|
||||||
|
if (!q20::in_range<size_type>(size))
|
||||||
|
qWarning("QJniArray::fromContainer: Container is too large for Java and will be truncated!");
|
||||||
|
}
|
||||||
|
|
||||||
QJniObject m_object;
|
QJniObject m_object;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user