summaryrefslogtreecommitdiff
path: root/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@digia.com>2014-01-09 18:04:45 +0100
committerEike Ziller <eike.ziller@digia.com>2014-01-10 14:38:36 +0100
commit2251958375321463995990fc59a88cbc2235c532 (patch)
tree7643ae380141c57f7f6d46825a3b7507a5163e79 /src/plugins/cmakeprojectmanager/cmakeeditor.cpp
parent9ce8bcd114df439f5757595f17ff094d8d3c5b7e (diff)
downloadqt-creator-2251958375321463995990fc59a88cbc2235c532.tar.gz
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 <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmakeeditor.cpp')
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditor.cpp17
1 files changed, 13 insertions, 4 deletions
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<CMakeEditorWidget*>(widget());
- CMakeEditorWidget *ret = new CMakeEditorWidget();
- ret->duplicateFrom(w);
+ CMakeEditorWidget *ret = new CMakeEditorWidget(
+ qobject_cast<CMakeEditorWidget *>(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('#');
}