From 883492c13536694f5565295ce87ce17a5a42444f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 16 Mar 2017 10:50:58 +0100 Subject: [PATCH] TextEditor: Set widthFactor from TextMark ctor The text marks are added to the document from their ctor. The document then uses the widthFactor to calculate the space needed for them. If the widthFactor is only set afterwards, the calculated space is wrong. Change-Id: Ic7d24f99cc78d1bf084b2b1cfdf6b955496072f3 Task-number: QTCREATORBUG-17833 Reviewed-by: hjk --- src/plugins/qmlprofiler/qmlprofilertextmark.cpp | 3 +-- src/plugins/texteditor/textmark.cpp | 4 ++-- src/plugins/texteditor/textmark.h | 2 +- src/plugins/valgrind/callgrindtextmark.cpp | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/plugins/qmlprofiler/qmlprofilertextmark.cpp b/src/plugins/qmlprofiler/qmlprofilertextmark.cpp index 5cdcaeb183b..3060c8f1400 100644 --- a/src/plugins/qmlprofiler/qmlprofilertextmark.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertextmark.cpp @@ -33,10 +33,9 @@ namespace Internal { QmlProfilerTextMark::QmlProfilerTextMark(QmlProfilerTool *tool, int typeId, const QString &fileName, int lineNumber) : - TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY), m_tool(tool), + TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY, 3.5), m_tool(tool), m_typeIds(1, typeId) { - setWidthFactor(3.5); } void QmlProfilerTextMark::addTypeId(int typeId) diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index dea5ca70c01..286cd2af41d 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -41,14 +41,14 @@ using namespace TextEditor::Internal; namespace TextEditor { -TextMark::TextMark(const QString &fileName, int lineNumber, Id category) +TextMark::TextMark(const QString &fileName, int lineNumber, Id category, double widthFactor) : m_baseTextDocument(0), m_fileName(fileName), m_lineNumber(lineNumber), m_priority(NormalPriority), m_visible(true), m_category(category), - m_widthFactor(1.0) + m_widthFactor(widthFactor) { if (!m_fileName.isEmpty()) TextEditorPlugin::baseTextMarkRegistry()->add(this); diff --git a/src/plugins/texteditor/textmark.h b/src/plugins/texteditor/textmark.h index 0aebe697606..1eec26d17ac 100644 --- a/src/plugins/texteditor/textmark.h +++ b/src/plugins/texteditor/textmark.h @@ -50,7 +50,7 @@ namespace Internal { class TextMarkRegistry; } class TEXTEDITOR_EXPORT TextMark { public: - TextMark(const QString &fileName, int lineNumber, Core::Id category); + TextMark(const QString &fileName, int lineNumber, Core::Id category, double widthFactor = 1.0); virtual ~TextMark(); // determine order on markers on the same line. diff --git a/src/plugins/valgrind/callgrindtextmark.cpp b/src/plugins/valgrind/callgrindtextmark.cpp index 5a8ed43ebd3..cfd19c7a0ce 100644 --- a/src/plugins/valgrind/callgrindtextmark.cpp +++ b/src/plugins/valgrind/callgrindtextmark.cpp @@ -42,11 +42,10 @@ namespace Constants { const char CALLGRIND_TEXT_MARK_CATEGORY[] = "Callgrind.Tex CallgrindTextMark::CallgrindTextMark(const QPersistentModelIndex &index, const QString &fileName, int lineNumber) - : TextEditor::TextMark(fileName, lineNumber, Constants::CALLGRIND_TEXT_MARK_CATEGORY) + : TextEditor::TextMark(fileName, lineNumber, Constants::CALLGRIND_TEXT_MARK_CATEGORY, 4.0) , m_modelIndex(index) { setPriority(TextEditor::TextMark::HighPriority); - setWidthFactor(4.0); } void CallgrindTextMark::paint(QPainter *painter, const QRect &paintRect) const