Exceptions using InputPanel
-
Hi, I'm using Qt 5.13.2. If I add InputPanel in qml code, I receive some exceptions
Exception at 0x752c35d2, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) in dwrite!GdiFontFileLoader::CreateFontFace
Exception at 0x752c35d2, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) in dwrite!MapExceptionToHresult
this is the QML code:
import QtQuick 2.13
import QtQuick.Window 2.13
import QtQuick.VirtualKeyboard 2.2Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")InputPanel{ }
}
I think it is an internal problem of qt code, can fix this problem or hide this output?
Regards
-
The same problem still exists in Qt 5.15.1.
Even if I run the example project I have an exception.Debugger encountered an exception: Exception at 0x7ff999113e49, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance)
If I use the debugger and debug into the exception I see the applicatoin tries to load a font from WindowsFontDataBase. The font has the family name Sans.
1 RaiseException KERNELBASE 0x7ff999113e49 2 CxxThrowException msvcrt 0x7ff99ac4af2d 3 DWriteCreateFactory dwrite 0x7ff98cc609f1 4 dwrite 0x7ff98cbc7dca 5 QWindowsFontDatabase::createEngine qwindowsfontdatabase.cpp 1968 0x7ff94cfff92a 6 QWindowsFontDatabase::fontEngine qwindowsfontdatabase.cpp 1277 0x7ff94cffd506 7 loadSingleEngine qfontdatabase.cpp 971 0x7ff944b71a3c 8 loadEngine qfontdatabase.cpp 1001 0x7ff944b71cb8 9 QFontDatabase::findFont qfontdatabase.cpp 2737 0x7ff944b6cfc3 10 QFontDatabase::load qfontdatabase.cpp 2823 0x7ff944b6d610 11 QFontPrivate::engineForScript qfont.cpp 228 0x7ff944b2e31a 12 QScriptLine::setDefaultHeight qtextengine.cpp 2821 0x7ff944b7fd7d 13 QTextLine::layout_helper qtextlayout.cpp 1815 0x7ff944bb2458 14 QTextLine::setLineWidth qtextlayout.cpp 1606 0x7ff944baf203 15 QQuickTextPrivate::setLineGeometry qquicktext.cpp 1203 0x7ff94404bce5 16 QQuickTextPrivate::setupTextLayout qquicktext.cpp 824 0x7ff94404e844 17 QQuickTextPrivate::updateSize qquicktext.cpp 413 0x7ff94404a4a2 18 QQuickTextPrivate::updateLayout qquicktext.cpp 295 0x7ff94404b8cf 19 QQuickText::componentComplete qquicktext.cpp 2767 0x7ff944045efa 20 QQmlObjectCreator::finalize qqmlobjectcreator.cpp 1417 0x7ff945e94133 21 QQmlIncubatorPrivate::incubate qqmlincubator.cpp 364 0x7ff945dcf4fc 22 QQmlEnginePrivate::incubate qqmlincubator.cpp 91 0x7ff945dce4de 23 QQmlComponent::create qqmlcomponent.cpp 1179 0x7ff945dc386f 24 QQuickLoaderPrivate::_q_sourceLoaded qquickloader.cpp 744 0x7ff9440f1767 25 QQuickLoaderPrivate::load qquickloader.cpp 617 0x7ff9440f0522 26 QQuickLoader::componentComplete qquickloader.cpp 807 0x7ff9440ef734 27 QQmlObjectCreator::finalize qqmlobjectcreator.cpp 1417 0x7ff945e94133 28 QQmlComponentPrivate::complete qqmlcomponent.cpp 989 0x7ff945dc6660 29 QQmlComponentPrivate::completeCreate qqmlcomponent.cpp 1080 0x7ff945dc5539 30 QQmlComponent::completeCreate qqmlcomponent.cpp 1067 0x7ff945dc3572 31 QQmlComponent::create qqmlcomponent.cpp 821 0x7ff945dc32fe 32 QQuickView::continueExecute qquickview.cpp 487 0x7ff9440f82c6 33 QQuickViewPrivate::execute qquickview.cpp 103 0x7ff9440f8b6e 34 QQuickView::setSource qquickview.cpp 237 0x7ff9440f7c60 35 QtVirtualKeyboard::DesktopInputPanel::createView desktopinputpanel.cpp 157 0x7ff968b5f5e6 36 QtVirtualKeyboard::PlatformInputContext::update platforminputcontext.cpp 104 0x7ff968b1931d 37 QtVirtualKeyboard::PlatformInputContext::setFocusObject platforminputcontext.cpp 212 0x7ff968b19f65 38 QGuiApplicationPrivate::_q_updateFocusObject qguiapplication.cpp 4302 0x7ff9449bfd8e 39 QGuiApplication::qt_static_metacall moc_qguiapplication.cpp 189 0x7ff9449b4391 40 doActivate<0> qobject.cpp 3901 0x7ff9435df73f 41 QMetaObject::activate qobject.cpp 3947 0x7ff9435cbf57 42 QWindow::focusObjectChanged moc_qwindow.cpp 841 0x7ff9449e16a3 43 QQuickWindowPrivate::setFocusInScope qquickwindow.cpp 1180 0x7ff94401c23a 44 QQuickItem::setFocus qquickitem.cpp 7200 0x7ff943fc0da5 45 QQuickItem::forceActiveFocus qquickitem.cpp 4752 0x7ff943fc45ae 46 QQuickTextEdit::mousePressEvent qquicktextedit.cpp 1874 0x7ff9440a9a2f 47 QQuickTextArea::mouseReleaseEvent qquicktextarea.cpp 1170 0x7ff9418ef56c 48 QQuickItem::event qquickitem.cpp 8166 0x7ff943fc5a63 49 QQuickTextEdit::event qquicktextedit.cpp 1662 0x7ff9440a9592 50 QCoreApplicationPrivate::notify_helper qcoreapplication.cpp 1224 0x7ff94356e0b1 51 doNotify qcoreapplication.cpp 1153 0x7ff94356fb4f 52 QCoreApplication::notify qcoreapplication.cpp 1140 0x7ff94356b4b1 53 QGuiApplication::notify qguiapplication.cpp 1936 0x7ff9449b644e 54 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1063 0x7ff94356cc1f 55 QCoreApplication::sendEvent qcoreapplication.cpp 1459 0x7ff94356ad02 56 QQuickWindowPrivate::deliverMouseEvent qquickwindow.cpp 1997 0x7ff9440129a7 57 QQuickWindowPrivate::deliverPointerEvent qquickwindow.cpp 2590 0x7ff944016897 58 QQuickWindowPrivate::handleMouseEvent qquickwindow.cpp 2404 0x7ff94401523c 59 QQuickWindow::mouseReleaseEvent qquickwindow.cpp 2384 0x7ff94400dfdc 60 QQuickView::mouseReleaseEvent qquickview.cpp 645 0x7ff9440f86fd 61 QWindow::event qwindow.cpp 2342 0x7ff9449e1987 62 QQuickWindow::event qquickwindow.cpp 1879 0x7ff94400dd25 63 QCoreApplicationPrivate::notify_helper qcoreapplication.cpp 1224 0x7ff94356e0b1 64 doNotify qcoreapplication.cpp 1153 0x7ff94356fb4f 65 QCoreApplication::notify qcoreapplication.cpp 1140 0x7ff94356b4b1 66 QGuiApplication::notify qguiapplication.cpp 1936 0x7ff9449b644e 67 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1063 0x7ff94356cc1f 68 QCoreApplication::sendSpontaneousEvent qcoreapplication.cpp 1471 0x7ff94356cabb 69 QGuiApplicationPrivate::processMouseEvent qguiapplication.cpp 2278 0x7ff9449ba7bb 70 QGuiApplicationPrivate::processWindowSystemEvent qguiapplication.cpp 2003 0x7ff9449bdcd6 71 QWindowSystemInterface::sendWindowSystemEvents qwindowsysteminterface.cpp 1181 0x7ff944987de2 72 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 82 0x7ff94cffc792 73 QEventDispatcherWin32::processEvents qeventdispatcher_win.cpp 530 0x7ff943640632 74 QWindowsGuiEventDispatcher::processEvents qwindowsguieventdispatcher.cpp 73 0x7ff94cffc744 75 QEventLoop::processEvents qeventloop.cpp 140 0x7ff94356750b 76 QEventLoop::exec qeventloop.cpp 232 0x7ff943567774 77 QCoreApplication::exec qcoreapplication.cpp 1371 0x7ff94356aa89 78 QGuiApplication::exec qguiapplication.cpp 1868 0x7ff9449b63d8 79 main main.cpp 48 0x7ff6aacb275d 80 WinMain qtmain_win.cpp 97 0x7ff6aacb4cd5 81 invoke_main exe_common.inl 107 0x7ff6aacb3522 82 __scrt_common_main_seh exe_common.inl 288 0x7ff6aacb340e 83 __scrt_common_main exe_common.inl 331 0x7ff6aacb32ce 84 WinMainCRTStartup exe_winmain.cpp 17 0x7ff6aacb35b9 85 BaseThreadInitThunk KERNEL32 0x7ff99b347034 86 RtlUserThreadStart ntdll 0x7ff99b47cec1
Why was this code working with Qt 5.12.3? Does anyone know if there was a major change in the implementation on Qt side?
-
A deeper dive and some debugging bought me closer to the problem. I used my application which is developed with VS 2019 and made some more debugging.
Here's a code snipped where the font engine is created. Looking closer to the content of variable lf showed me the font Sans with height of -11 trying to create an engine.
QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const QString &faceName, int dpi, const QSharedPointer<QWindowsFontEngineData> &data) { QFontEngine *fe = 0; LOGFONT lf = fontDefToLOGFONT(request, faceName); const bool preferClearTypeAA = lf.lfQuality == CLEARTYPE_QUALITY; if (request.stretch != 100) { HFONT hfont = CreateFontIndirect(&lf); if (!hfont) { qErrnoWarning("%s: CreateFontIndirect failed", __FUNCTION__); hfont = QWindowsFontDatabase::systemFont(); } HGDIOBJ oldObj = SelectObject(data->hdc, hfont); TEXTMETRIC tm; if (!GetTextMetrics(data->hdc, &tm)) qErrnoWarning("%s: GetTextMetrics failed", __FUNCTION__); else lf.lfWidth = tm.tmAveCharWidth * request.stretch / 100; SelectObject(data->hdc, oldObj); DeleteObject(hfont); }
However this font doesn't exist on my system and therefore I got the exception. In the source file "C:\Qt\onlineinstaller\5.15.1\Src\qtvirtualkeyboard\src\virtualkeyboard\content\styles\default\style.qml" on line 37 is the following member declaration which confirmed my assumption.
readonly property string fontFamily: "Sans"
Now as a workarround I tried to map the Sans font to a font which was available in the requested size. I chose Tahoma. Under "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes" I made a new registry entry.
Starting the application and debugging into the same function showed me that the substitute font was loaded - no exceptions anymore.To round up my problem I made a custom style for the virutal keyboard and specified the fontFamily to Tahoma and things are working fine now.
As I searched to find a solution for my problem there were many comments that people weren't able to reproduce the problem. I think one major issue here is that some fonts are available on some systems and some not depending on the language and settings of the OS.