summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-10-29 13:39:32 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-11-11 21:24:30 +0100
commit30adaaedf77d567f7c9c835756b560065c446e9e (patch)
tree59a34e76b85aaa572c00dc653a9dd9c3f773dcee /src/gui
parent30276cec3d47f4f4fa847fea90214ec5c28d54ed (diff)
QInputMethod: check if focusobject supports the "new" IM function before calling it
We use QMetaObject to invoke the "queryFocusObject" function. But if the current focus object doesn't implement this function, we get a "QMetaObject::invokeMethod: No such method" warning. This patch will add a check if the focus object supports IM queries before trying to call "queryFocusObject", to avoid the warning. Task-number: QTBUG-91545 Change-Id: I3aa8bd2d4bf57bd42c2d77ed71174ec4f9951f81 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qinputmethod.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/gui/kernel/qinputmethod.cpp b/src/gui/kernel/qinputmethod.cpp
index f5de06aea1..f358cc87fd 100644
--- a/src/gui/kernel/qinputmethod.cpp
+++ b/src/gui/kernel/qinputmethod.cpp
@@ -426,13 +426,17 @@ QVariant QInputMethod::queryFocusObject(Qt::InputMethodQuery query, const QVaria
if (!focusObject)
return retval;
- bool newMethodWorks = QMetaObject::invokeMethod(focusObject, "inputMethodQuery",
- Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, retval),
- Q_ARG(Qt::InputMethodQuery, query),
- Q_ARG(QVariant, argument));
- if (newMethodWorks)
+ static const char *signature = "inputMethodQuery(Qt::InputMethodQuery,QVariant)";
+ const bool newMethodSupported = focusObject->metaObject()->indexOfMethod(signature) != -1;
+ if (newMethodSupported) {
+ const bool ok = QMetaObject::invokeMethod(focusObject, "inputMethodQuery",
+ Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, retval),
+ Q_ARG(Qt::InputMethodQuery, query),
+ Q_ARG(QVariant, argument));
+ Q_ASSERT(ok);
return retval;
+ }
QInputMethodQueryEvent queryEvent(query);
QCoreApplication::sendEvent(focusObject, &queryEvent);