From b68b59f252930538cc124b31decc990ab57bea20 Mon Sep 17 00:00:00 2001 From: Takumi ASAKI Date: Thu, 17 Nov 2011 16:26:05 +0100 Subject: Qt Linguist: Fix crash after select 2nd translation in lengthvariant * MessageEditor keeps deleted editor as m_selectionHolder. QOjbect::destroyed() SIGNAL doesn't fit to fix this problem due to destruction order problem. Merge-request: 1466 Reviewed-by: Oswald Buddenhagen --- tools/linguist/linguist/messageeditor.cpp | 7 +++++++ tools/linguist/linguist/messageeditor.h | 1 + tools/linguist/linguist/messageeditorwidgets.cpp | 4 +++- tools/linguist/linguist/messageeditorwidgets.h | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/linguist/linguist/messageeditor.cpp b/tools/linguist/linguist/messageeditor.cpp index 6cafe8e..87c2f4a 100644 --- a/tools/linguist/linguist/messageeditor.cpp +++ b/tools/linguist/linguist/messageeditor.cpp @@ -262,6 +262,7 @@ 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()) @@ -298,6 +299,12 @@ void MessageEditor::editorCreated(QTextEdit *te) } } +void MessageEditor::editorDeleted(QTextEdit *te) +{ + if (m_selectionHolder == te) + resetSelection(); +} + void MessageEditor::fixTabOrder() { m_tabOrderTimer.start(0); diff --git a/tools/linguist/linguist/messageeditor.h b/tools/linguist/linguist/messageeditor.h index 4686d3d..21b3405 100644 --- a/tools/linguist/linguist/messageeditor.h +++ b/tools/linguist/linguist/messageeditor.h @@ -114,6 +114,7 @@ public slots: private slots: void editorCreated(QTextEdit *); + void editorDeleted(QTextEdit *); void selectionChanged(QTextEdit *); void resetHoverSelection(); void emitTranslationChanged(QTextEdit *); diff --git a/tools/linguist/linguist/messageeditorwidgets.cpp b/tools/linguist/linguist/messageeditorwidgets.cpp index 6422b47..29df673 100644 --- a/tools/linguist/linguist/messageeditorwidgets.cpp +++ b/tools/linguist/linguist/messageeditorwidgets.cpp @@ -362,9 +362,11 @@ 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 m_editors.takeLast(); + delete editor; } 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 cb24377..1f6f1f5 100644 --- a/tools/linguist/linguist/messageeditorwidgets.h +++ b/tools/linguist/linguist/messageeditorwidgets.h @@ -150,6 +150,7 @@ public: signals: void editorCreated(QTextEdit *); + void editorDeleted(QTextEdit *); void textChanged(QTextEdit *); void selectionChanged(QTextEdit *); void cursorPositionChanged(); -- cgit v0.12 From a9c3f7169faf4621d39714f753d6e8b376c5d6e5 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Fri, 18 Nov 2011 18:07:21 +0100 Subject: Fix sporadic hang in QLocalServer::close() in OS X 10.7 There is a bug in CFSocket/CFRunLoopSource in OS X 10.7 which can lead to a deadlock in CFRunLoopRemoveSource or CFRunLoopSourceInvalidate if the CFSocket manager thread is concurrently calling CFSocketInvalidate as a result of the socket's file descriptor having been closed. QLocalServer::close() triggers this race by closing the socket fd before unregistering the QSocketNotifier, which internally uses CFSocket. This commit fixes the problem by changing the ordering in close() so that the socket notifier is disabled before closing the file descriptor. This change also makes QLocalServer::close() perform operations in reverse order to QLocalServer::listen(), as would be expected. Task-number: QTBUG-22789 Merge-request: 1470 Reviewed-by: Oswald Buddenhagen --- src/network/socket/qlocalserver_unix.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp index 851e898..390712c 100644 --- a/src/network/socket/qlocalserver_unix.cpp +++ b/src/network/socket/qlocalserver_unix.cpp @@ -167,16 +167,16 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName) */ void QLocalServerPrivate::closeServer() { - if (-1 != listenSocket) - QT_CLOSE(listenSocket); - listenSocket = -1; - if (socketNotifier) { socketNotifier->setEnabled(false); // Otherwise, closed socket is checked before deleter runs socketNotifier->deleteLater(); socketNotifier = 0; } + if (-1 != listenSocket) + QT_CLOSE(listenSocket); + listenSocket = -1; + if (!fullServerName.isEmpty()) QFile::remove(fullServerName); } -- cgit v0.12