[kde-doc-english] [trojita] src/Cryptography: GUI: handle malformed crypto messages properly

Jan Kundrát jkt at kde.org
Wed May 4 08:16:25 UTC 2016


Git commit 2b46a258b3bd5891b71e0ebfa3067aaaf3372a86 by Jan Kundrát.
Committed on 30/04/2016 at 13:32.
Pushed by gerrit into branch 'master'.

GUI: handle malformed crypto messages properly

This is deliberately done as a separate commit because my original
approach didn't work. The reason for this is that the
Gui::AsynchronousPartWidget::handleError disconnects the handler of
rowsInserted(), and therefore the source parts were still not being
shown.

Change-Id: I47740747ae6b75da2b47abd7f20b7ca5bf0b03db

M  +7    -6    src/Cryptography/GpgMe++.cpp

http://commits.kde.org/trojita/2b46a258b3bd5891b71e0ebfa3067aaaf3372a86

diff --git a/src/Cryptography/GpgMe++.cpp b/src/Cryptography/GpgMe++.cpp
index e54e5ae..414dcb6 100644
--- a/src/Cryptography/GpgMe++.cpp
+++ b/src/Cryptography/GpgMe++.cpp
@@ -240,19 +240,20 @@ void GpgMePart::forwardFailure(const QString &statusTLDR, const QString &statusL
     m_statusLong = statusLong;
     m_statusIcon = statusIcon;
 
-    // This forward is needed because we migth be emitting this indirectly, from the item's constructor.
-    // At the time the ctor runs, the multipart/encrypted has not been inserted into the proxy model yet,
-    // so we cannot obtain its index.
-    emit m_model->error(m_proxyParentIndex.child(m_row, 0), m_statusTLDR, m_statusLong);
-    emitDataChanged();
-
     if (m_sourceIndex.isValid()) {
         std::vector<MessagePart::Ptr> children;
         for (int i = 0; i < m_sourceIndex.model()->rowCount(m_sourceIndex); ++i) {
             children.emplace_back(MessagePart::Ptr(new ProxyMessagePart(nullptr, 0, m_sourceIndex.child(i, 0), m_model)));
         }
+        // This has to happen prior to emitting error()
         m_model->insertSubtree(m_proxyParentIndex.child(m_row, 0), std::move(children));
     }
+
+    // This forward is needed because we migth be emitting this indirectly, from the item's constructor.
+    // At the time the ctor runs, the multipart/encrypted has not been inserted into the proxy model yet,
+    // so we cannot obtain its index.
+    emit m_model->error(m_proxyParentIndex.child(m_row, 0), m_statusTLDR, m_statusLong);
+    emitDataChanged();
 }
 
 void GpgMePart::emitDataChanged()



More information about the kde-doc-english mailing list