summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextcontrol.cpp
diff options
context:
space:
mode:
authorMikko Knuutila <Mikko.Knuutila@Digia.com>2011-10-04 15:00:27 +0200
committerJan-Arve Saether <jan-arve.saether@nokia.com>2011-10-04 15:00:27 +0200
commitaefda8ce30695c5383860eab709acca345d290dc (patch)
treec986d7c200fc8718cfd8faf344cfa69b4249a23d /src/gui/text/qtextcontrol.cpp
parenteeeebedcf063511fd042b34f419ffa06c985d4a2 (diff)
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/text/qtextcontrol.cpp')
-rw-r--r--src/gui/text/qtextcontrol.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index aeeef85c9e..5babbc22ef 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();