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