From 2251958375321463995990fc59a88cbc2235c532 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 9 Jan 2014 18:04:45 +0100 Subject: TextEditors: Avoid changing document after construction. Also when duplicating editors, we don't want to change the document after construction. Actually at some places (e.g. CppEditorSupport creation) we don't handle document changes correctly, and we are only lucky that things still (more or less?) work. Get rid of BaseTextEditorWidget::duplicateFrom and use copy-constructor style instead. Change-Id: I7f688b7fcc51d1bb5e222bb333f0d28479b597a6 Reviewed-by: Nikolai Kosjar --- src/plugins/cmakeprojectmanager/cmakeeditor.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/plugins/cmakeprojectmanager/cmakeeditor.cpp') diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp index 805b865adb..760c4d32a0 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp @@ -66,9 +66,8 @@ CMakeEditor::CMakeEditor(CMakeEditorWidget *editor) Core::IEditor *CMakeEditor::duplicate() { - CMakeEditorWidget *w = qobject_cast(widget()); - CMakeEditorWidget *ret = new CMakeEditorWidget(); - ret->duplicateFrom(w); + CMakeEditorWidget *ret = new CMakeEditorWidget( + qobject_cast(editorWidget())); TextEditor::TextEditorSettings::initializeEditor(ret); return ret->editor(); } @@ -118,8 +117,18 @@ void CMakeEditor::build() CMakeEditorWidget::CMakeEditorWidget(QWidget *parent) : BaseTextEditorWidget(new CMakeDocument(), parent) { - baseTextDocument()->setSyntaxHighlighter(new CMakeHighlighter); + ctor(); +} +CMakeEditorWidget::CMakeEditorWidget(CMakeEditorWidget *other) + : BaseTextEditorWidget(other) +{ + ctor(); +} + +void CMakeEditorWidget::ctor() +{ + baseTextDocument()->setSyntaxHighlighter(new CMakeHighlighter); m_commentDefinition.clearCommentStyles(); m_commentDefinition.singleLine = QLatin1Char('#'); } -- cgit v1.2.1