aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmljseditor
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/qmljseditor
parent9ce8bcd114df439f5757595f17ff094d8d3c5b7e (diff)
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/qmljseditor')
-rw-r--r--src/plugins/qmljseditor/qmljseditor.cpp31
-rw-r--r--src/plugins/qmljseditor/qmljseditor.h3
2 files changed, 24 insertions, 10 deletions
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index 061bf76054d..1ed5aa94681 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -450,15 +450,26 @@ protected:
QmlJSTextEditorWidget::QmlJSTextEditorWidget(QWidget *parent) :
- TextEditor::BaseTextEditorWidget(parent),
- m_outlineCombo(0),
- m_outlineModel(new QmlOutlineModel(this)),
- m_modelManager(0),
- m_futureSemanticInfoRevision(0),
- m_contextPane(0),
- m_findReferences(new FindReferences(this)),
- m_semanticHighlighter(new SemanticHighlighter(this))
+ TextEditor::BaseTextEditorWidget(parent)
{
+ ctor();
+}
+
+QmlJSTextEditorWidget::QmlJSTextEditorWidget(QmlJSTextEditorWidget *other)
+ : TextEditor::BaseTextEditorWidget(other)
+{
+ ctor();
+}
+
+void QmlJSTextEditorWidget::ctor()
+{
+ m_outlineCombo = 0;
+ m_outlineModel = new QmlOutlineModel(this);
+ m_futureSemanticInfoRevision = 0;
+ m_contextPane = 0;
+ m_findReferences = new FindReferences(this);
+ m_semanticHighlighter = new SemanticHighlighter(this);
+
m_semanticInfoUpdater = new SemanticInfoUpdater(this);
m_semanticInfoUpdater->start();
@@ -583,8 +594,8 @@ QModelIndex QmlJSTextEditorWidget::outlineModelIndex()
IEditor *QmlJSEditor::duplicate()
{
- QmlJSTextEditorWidget *newEditor = new QmlJSTextEditorWidget();
- newEditor->duplicateFrom(editorWidget());
+ QmlJSTextEditorWidget *newEditor = new QmlJSTextEditorWidget(
+ qobject_cast<QmlJSTextEditorWidget *>(editorWidget()));
TextEditor::TextEditorSettings::initializeEditor(newEditor);
return newEditor->editor();
}
diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h
index 6b9981ded71..4880ab0988b 100644
--- a/src/plugins/qmljseditor/qmljseditor.h
+++ b/src/plugins/qmljseditor/qmljseditor.h
@@ -100,6 +100,7 @@ class QMLJSEDITOR_EXPORT QmlJSTextEditorWidget : public TextEditor::BaseTextEdit
public:
QmlJSTextEditorWidget(QWidget *parent = 0);
+ QmlJSTextEditorWidget(QmlJSTextEditorWidget *other);
~QmlJSTextEditorWidget();
virtual void unCommentSelection();
@@ -166,6 +167,8 @@ protected:
QString foldReplacementText(const QTextBlock &block) const;
private:
+ QmlJSTextEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
+ void ctor();
bool isClosingBrace(const QList<QmlJS::Token> &tokens) const;
void setSelectedElements();