[qt5] don't crash if window->screen() is null

This commit is contained in:
Weng Xuetian 2016-10-12 16:26:34 -07:00
parent 927c3e2041
commit 6cc5e86b1c
1 changed files with 6 additions and 2 deletions

View File

@ -712,8 +712,12 @@ void QFcitxPlatformInputContext::processKeyEventFinished(QDBusPendingCallWatcher
if (!filtered) {
// copied from QXcbKeyboard::handleKeyEvent()
if (type == QEvent::KeyPress && qtcode == Qt::Key_Menu) {
const QPoint globalPos = window->screen()->handle()->cursor()->pos();
const QPoint pos = window->mapFromGlobal(globalPos); QWindowSystemInterface::handleContextMenuEvent(window, false, pos, globalPos, modifiers);
QPoint globalPos, pos;
if (window->screen()) {
globalPos = window->screen()->handle()->cursor()->pos();
pos = window->mapFromGlobal(globalPos);
}
QWindowSystemInterface::handleContextMenuEvent(window, false, pos, globalPos, modifiers);
}
QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers,
code, sym, state, string, isAutoRepeat);