diff options
author | Mikko Knuutila <Mikko.Knuutila@Digia.com> | 2011-10-04 13:00:27 (GMT) |
---|---|---|
committer | Jan-Arve Saether <jan-arve.saether@nokia.com> | 2011-10-04 13:00:27 (GMT) |
commit | aefda8ce30695c5383860eab709acca345d290dc (patch) | |
tree | c986d7c200fc8718cfd8faf344cfa69b4249a23d /src/gui | |
parent | eeeebedcf063511fd042b34f419ffa06c985d4a2 (diff) | |
download | Qt-aefda8ce30695c5383860eab709acca345d290dc.zip Qt-aefda8ce30695c5383860eab709acca345d290dc.tar.gz Qt-aefda8ce30695c5383860eab709acca345d290dc.tar.bz2 |
QTBUG-21058: Fix for possible crashes in QTextControl::setCursorWidth()
Cursor's width is now queried from the style only when the user calls
cursorWidth(). Earlier it was queried already in the ctor, which
caused crashes if the application was guiless.
Merge-request: 2697
Reviewed-by: Jan-Arve Saether <jan-arve.saether@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qtextcontrol.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index aeeef85..5babbc2 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -408,7 +408,6 @@ void QTextControlPrivate::init(Qt::TextFormat format, const QString &text, QText setContent(format, text, document); doc->setUndoRedoEnabled(interactionFlags & Qt::TextEditable); - q->setCursorWidth(-1); } void QTextControlPrivate::setContent(Qt::TextFormat format, const QString &text, QTextDocument *document) @@ -2236,7 +2235,10 @@ int QTextControl::cursorWidth() const { #ifndef QT_NO_PROPERTIES Q_D(const QTextControl); - return d->doc->documentLayout()->property("cursorWidth").toInt(); + int width = d->doc->documentLayout()->property("cursorWidth").toInt(); + if (width == -1) + width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth); + return width; #else return 1; #endif @@ -2248,8 +2250,6 @@ void QTextControl::setCursorWidth(int width) #ifdef QT_NO_PROPERTIES Q_UNUSED(width); #else - if (width == -1) - width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth); d->doc->documentLayout()->setProperty("cursorWidth", width); #endif d->repaintCursor(); |