diff options
author | Takumi ASAKI <takumi.asaki@nokia.com> | 2011-11-30 19:29:29 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-11-30 19:29:29 (GMT) |
commit | 27c322e0f88fa0cccba8cf914655cacb5dae51de (patch) | |
tree | cbeec4550fa1459238d69a3a144310831e661b9a /tools/linguist | |
parent | 70c1e9589bf390bc3010663f133d87a789f17c3e (diff) | |
download | Qt-27c322e0f88fa0cccba8cf914655cacb5dae51de.zip Qt-27c322e0f88fa0cccba8cf914655cacb5dae51de.tar.gz Qt-27c322e0f88fa0cccba8cf914655cacb5dae51de.tar.bz2 |
Qt Linguist: Fix crashes
Fix crash when select translation after close and open file.
This patches includes refactoring of b68b59f252930538cc124b31decc990ab57bea20
Merge-request: 1480
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'tools/linguist')
-rw-r--r-- | tools/linguist/linguist/messageeditor.cpp | 12 | ||||
-rw-r--r-- | tools/linguist/linguist/messageeditor.h | 2 | ||||
-rw-r--r-- | tools/linguist/linguist/messageeditorwidgets.cpp | 9 | ||||
-rw-r--r-- | tools/linguist/linguist/messageeditorwidgets.h | 5 |
4 files changed, 19 insertions, 9 deletions
diff --git a/tools/linguist/linguist/messageeditor.cpp b/tools/linguist/linguist/messageeditor.cpp index 87c2f4a..2888290 100644 --- a/tools/linguist/linguist/messageeditor.cpp +++ b/tools/linguist/linguist/messageeditor.cpp @@ -262,7 +262,6 @@ void MessageEditor::addPluralForm(int model, const QString &label, bool writable { FormMultiWidget *transEditor = new FormMultiWidget(label); connect(transEditor, SIGNAL(editorCreated(QTextEdit*)), SLOT(editorCreated(QTextEdit*))); - connect(transEditor, SIGNAL(editorDeleted(QTextEdit*)), SLOT(editorDeleted(QTextEdit*))); transEditor->setEditingEnabled(writable); transEditor->setHideWhenEmpty(!writable); if (!m_editors[model].transTexts.isEmpty()) @@ -299,9 +298,9 @@ void MessageEditor::editorCreated(QTextEdit *te) } } -void MessageEditor::editorDeleted(QTextEdit *te) +void MessageEditor::editorDestroyed() { - if (m_selectionHolder == te) + if (m_selectionHolder == sender()) resetSelection(); } @@ -352,9 +351,13 @@ static void clearSelection(QTextEdit *t) void MessageEditor::selectionChanged(QTextEdit *te) { if (te != m_selectionHolder) { - if (m_selectionHolder) + if (m_selectionHolder) { clearSelection(m_selectionHolder); + disconnect(this, SLOT(editorDestroyed())); + } m_selectionHolder = (te->textCursor().hasSelection() ? te : 0); + if (FormatTextEdit *fte = qobject_cast<FormatTextEdit*>(m_selectionHolder)) + connect(fte, SIGNAL(editorDestroyed()), SLOT(editorDestroyed())); updateCanCutCopy(); } } @@ -371,6 +374,7 @@ void MessageEditor::resetSelection() { if (m_selectionHolder) { clearSelection(m_selectionHolder); + disconnect(this, SLOT(editorDestroyed())); m_selectionHolder = 0; updateCanCutCopy(); } diff --git a/tools/linguist/linguist/messageeditor.h b/tools/linguist/linguist/messageeditor.h index 21b3405..0fbf658 100644 --- a/tools/linguist/linguist/messageeditor.h +++ b/tools/linguist/linguist/messageeditor.h @@ -114,7 +114,7 @@ public slots: private slots: void editorCreated(QTextEdit *); - void editorDeleted(QTextEdit *); + void editorDestroyed(); void selectionChanged(QTextEdit *); void resetHoverSelection(); void emitTranslationChanged(QTextEdit *); diff --git a/tools/linguist/linguist/messageeditorwidgets.cpp b/tools/linguist/linguist/messageeditorwidgets.cpp index 29df673..042ef3d 100644 --- a/tools/linguist/linguist/messageeditorwidgets.cpp +++ b/tools/linguist/linguist/messageeditorwidgets.cpp @@ -130,6 +130,11 @@ FormatTextEdit::FormatTextEdit(QWidget *parent) m_highlighter = new MessageHighlighter(this); } +FormatTextEdit::~FormatTextEdit() +{ + emit editorDestroyed(); +} + void FormatTextEdit::setEditable(bool editable) { // save default frame style @@ -362,11 +367,9 @@ void FormMultiWidget::setTranslation(const QString &text, bool userAction) QStringList texts = text.split(QChar(Translator::BinaryVariantSeparator), QString::KeepEmptyParts); while (m_editors.count() > texts.count()) { - FormatTextEdit *editor = m_editors.takeLast(); - emit editorDeleted(editor); delete m_minusButtons.takeLast(); delete m_plusButtons.takeLast(); - delete editor; + delete m_editors.takeLast(); } while (m_editors.count() < texts.count()) addEditor(m_editors.count()); diff --git a/tools/linguist/linguist/messageeditorwidgets.h b/tools/linguist/linguist/messageeditorwidgets.h index 1f6f1f5..c6d9201 100644 --- a/tools/linguist/linguist/messageeditorwidgets.h +++ b/tools/linguist/linguist/messageeditorwidgets.h @@ -91,8 +91,12 @@ class FormatTextEdit : public ExpandingTextEdit Q_OBJECT public: FormatTextEdit(QWidget *parent = 0); + ~FormatTextEdit(); void setEditable(bool editable); +signals: + void editorDestroyed(); + public slots: void setPlainText(const QString & text, bool userAction); @@ -150,7 +154,6 @@ public: signals: void editorCreated(QTextEdit *); - void editorDeleted(QTextEdit *); void textChanged(QTextEdit *); void selectionChanged(QTextEdit *); void cursorPositionChanged(); |