Fixes InputMethodTest::testEnableDisableV3 on my system when running on Valgrind, should hopefully also fix on CI. (cherry picked from commit f4715b9a)