diff --git a/src/corelib/kernel/qjniarray.h b/src/corelib/kernel/qjniarray.h index 3e6976296b9..fdbe05c534c 100644 --- a/src/corelib/kernel/qjniarray.h +++ b/src/corelib/kernel/qjniarray.h @@ -480,8 +480,7 @@ public: template = true> static auto fromContainer(Container &&container) { - if (!q20::in_range(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::value_type; if constexpr (std::is_base_of_v, std::remove_pointer_t>) { @@ -605,6 +604,13 @@ protected: void swap(QJniArrayBase &other) noexcept { m_object.swap(other.m_object); } private: + template + static void verifySize(container_size_type size) + { + if (!q20::in_range(size)) + qWarning("QJniArray::fromContainer: Container is too large for Java and will be truncated!"); + } + QJniObject m_object; };