iOS: fix crash in auto correction when using unknown font family

If QFont reports a family name that cannot be used to instanciate
a UIFont, we end up trying to insert a nil object to an
NSDictionary. This will raise an exception.

This patch will check that we have a valid UIFont before using it.

Task-number: QTBUG-38018
Change-Id: Id8a2e4afea8c915ff43a7e4680304ba19328f9c2
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
Richard Moe Gustavsen 2014-04-09 15:46:26 +02:00 committed by The Qt Project
parent 3f9ad1efd6
commit 839c54e070

View File

@ -473,6 +473,8 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
QCoreApplication::sendEvent(focusObject, &e);
QFont qfont = qvariant_cast<QFont>(e.value(Qt::ImFont));
UIFont *uifont = [UIFont fontWithName:qfont.family().toNSString() size:qfont.pointSize()];
if (!uifont)
return [NSDictionary dictionary];
return [NSDictionary dictionaryWithObject:uifont forKey:UITextInputTextFontKey];
}