path: root/src
diff options
authorFrederik Gladhorn <>2014-04-29 16:45:33 +0200
committerThe Qt Project <>2014-05-09 17:25:19 +0200
commit667f2449a300950e735250c62686c150dab0080d (patch)
tree6fe78f5b4934a43db4122dbf30895202e42ed36c /src
parent775f1f777b6e517a903cb3e7ad39eaa29e1b427a (diff)
Fix crash on startup when running screenreader
For exaple Qt Creator would crash when started and a screen reader (eg NVDA) is running. This is due to updateAccessibility being called during the ctor of the TextEdit and on Windows the AT can access properties in the same call resulting in accessing the text control before it's fully constructed. Also make sure to not send accessibility updates for non-widget type edits since we don't support any accessibility in Qt Quick 1. Backported from Qt 5.3.1 since it also crashes Qt Creator on startup on Mac (as soon as accessibility is enabled which may be for various reasons, and basically any app that uses a QTextEdit). Task-number: QTBUG-38659 Task-number: QTBUG-38738 Change-Id: I6e5c0dc47bd75e63fe013a9edadbabccd52c20ee Reviewed-by: Jan Arve Sæther <>
Diffstat (limited to 'src')
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 9cc62fd10a..54b20e36f5 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -438,7 +438,6 @@ void QWidgetTextControlPrivate::setContent(Qt::TextFormat format, const QString
QObject::connect(doc, SIGNAL(contentsChanged()), q, SLOT(_q_updateCurrentCharFormatAndSelection()));
QObject::connect(doc, SIGNAL(cursorPositionChanged(QTextCursor)), q, SLOT(_q_emitCursorPosChanged(QTextCursor)));
- QObject::connect(doc, SIGNAL(contentsChange(int,int,int)), q, SLOT(_q_contentsChanged(int,int,int)));
QObject::connect(doc, SIGNAL(documentLayoutChanged()), q, SLOT(_q_documentLayoutChanged()));
// convenience signal forwards
@@ -501,6 +500,8 @@ void QWidgetTextControlPrivate::setContent(Qt::TextFormat format, const QString
emit q->cursorPositionChanged();
+ QObject::connect(doc, SIGNAL(contentsChange(int,int,int)), q, SLOT(_q_contentsChanged(int,int,int)), Qt::UniqueConnection);
void QWidgetTextControlPrivate::startDrag()
@@ -646,7 +647,8 @@ void QWidgetTextControlPrivate::_q_contentsChanged(int from, int charsRemoved, i
- if (QAccessible::isActive()) {
+ if (QAccessible::isActive() && q->parent() && q->parent()->isWidgetType()) {
QTextCursor tmp(doc);
tmp.setPosition(from + charsAdded, QTextCursor::KeepAnchor);