Android: Warn user if backend register does not have requested interface

Just in case, warn user if they are trying to use callInterface on an
interface that does not exist (probably has not been registered)

Change-Id: I1a4b2226cfecd139e36ab6386ea2fe868bd73f3f
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
(cherry picked from commit 6643e97a89f06f0c32c3dff8b2c343eaa76c0e85)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Petri Virkkunen 2024-07-26 14:50:37 +03:00 committed by Qt Cherry-pick Bot
parent bb3f1cc62a
commit 45f361e97e

View File

@ -43,8 +43,12 @@ public:
ValidInterfaceType<Interface> = true>
auto callInterface(const char *func, Args... args)
{
if (const auto obj = getInterface<Interface>(); obj.isValid())
if (const auto obj = getInterface<Interface>(); obj.isValid()) {
return obj.template callMethod<Ret, Args...>(func, std::forward<Args>(args)...);
} else {
qWarning() << "No interface with className"
<< QtJniTypes::Traits<Interface>::className() << "has been registered.";
}
if constexpr (IsObjectType<Ret>::value)
return Ret(QJniObject());