summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakumi ASAKI <takumi.asaki@nokia.com>2011-11-30 20:29:29 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-13 19:38:35 +0100
commitb5c9a10959e6e665601565ed960910d1c105ec94 (patch)
tree11ba2bc5e63044dccb756a2efbab3bdb0eef8630
parent1d1fbec4a2fcfde4e3e5c20c4ff6b679385773fd (diff)
downloadqttools-b5c9a10959e6e665601565ed960910d1c105ec94.tar.gz
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> (cherry picked from commit 27c322e0f88fa0cccba8cf914655cacb5dae51de) Change-Id: I27c322e0f88fa0cccba8cf914655cacb5dae51de Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
-rw-r--r--src/linguist/linguist/messageeditor.cpp12
-rw-r--r--src/linguist/linguist/messageeditor.h2
-rw-r--r--src/linguist/linguist/messageeditorwidgets.cpp9
-rw-r--r--src/linguist/linguist/messageeditorwidgets.h5
4 files changed, 19 insertions, 9 deletions
diff --git a/src/linguist/linguist/messageeditor.cpp b/src/linguist/linguist/messageeditor.cpp
index 87c2f4a45..28882905c 100644
--- a/src/linguist/linguist/messageeditor.cpp
+++ b/src/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/src/linguist/linguist/messageeditor.h b/src/linguist/linguist/messageeditor.h
index 7b45ed806..ef44e1afb 100644
--- a/src/linguist/linguist/messageeditor.h
+++ b/src/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/src/linguist/linguist/messageeditorwidgets.cpp b/src/linguist/linguist/messageeditorwidgets.cpp
index 29df673c7..042ef3da2 100644
--- a/src/linguist/linguist/messageeditorwidgets.cpp
+++ b/src/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/src/linguist/linguist/messageeditorwidgets.h b/src/linguist/linguist/messageeditorwidgets.h
index 1f6f1f580..c6d92015b 100644
--- a/src/linguist/linguist/messageeditorwidgets.h
+++ b/src/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();