Decouple attachment download from the lifetime of the enclosing GUI widget

Review Request #110681 - Created May 27, 2013 and submitted

Information
Jan Kundrát
trojita
Reviewers
trojita
Decouple attachment download from the lifetime of the enclosing GUI widget
    
Previously, the downlaod would get interrupted when the user switched to another message -- and that would be rather counterintuitive.

https://github.com/jktjkt/trojita/commit/d9103c5b880dd977578493cc392e77050702d1ac
https://github.com/jktjkt/trojita/commit/54c28e1226a5eccd939144146472f1339ea930b1
Verified that downloading and direct-opening works. Checked that the file is downloaded even when switching to another message. Verifeid the order of destructors through this patch:

diff --git a/src/Gui/AttachmentView.cpp b/src/Gui/AttachmentView.cpp
index 7e1dff0..17ee829 100644
--- a/src/Gui/AttachmentView.cpp
+++ b/src/Gui/AttachmentView.cpp
@@ -49,6 +49,11 @@
 namespace Gui
 {
 
+AttachmentView::~AttachmentView()
+{
+    qDebug() << Q_FUNC_INFO << this;
+}
+
 AttachmentView::AttachmentView(QWidget *parent, Imap::Network::MsgPartNetAccessManager *manager, const QModelIndex &partIndex):
     QWidget(parent), m_partIndex(partIndex), m_downloadButton(0), m_downloadAttachment(0),
     m_openAttachment(0), m_netAccess(manager), m_openingManager(0), m_tmpFile(0)
@@ -116,6 +121,7 @@ AttachmentView::AttachmentView(QWidget *parent, Imap::Network::MsgPartNetAccessM
 void AttachmentView::slotDownloadAttachment()
 {
     Imap::Network::FileDownloadManager *manager = new Imap::Network::FileDownloadManager(0, m_netAccess, m_partIndex);
+    qDebug() << "downlaoding via" << manager;
     connect(manager, SIGNAL(fileNameRequested(QString *)), this, SLOT(slotFileNameRequested(QString *)));
     connect(manager, SIGNAL(succeeded()), manager, SLOT(deleteLater()));
     connect(manager, SIGNAL(transferError(QString)), manager, SLOT(deleteLater()));
diff --git a/src/Gui/AttachmentView.h b/src/Gui/AttachmentView.h
index 7dd2755..d97ab94 100644
--- a/src/Gui/AttachmentView.h
+++ b/src/Gui/AttachmentView.h
@@ -55,6 +55,7 @@ class AttachmentView : public QWidget
     Q_OBJECT
 public:
     AttachmentView(QWidget *parent, Imap::Network::MsgPartNetAccessManager *manager, const QModelIndex &m_partIndex);
+    ~AttachmentView();
 protected:
     virtual void mousePressEvent(QMouseEvent *event);
 private slots:
diff --git a/src/Imap/Network/FileDownloadManager.cpp b/src/Imap/Network/FileDownloadManager.cpp
index aaa1abd..66aff21 100644
--- a/src/Imap/Network/FileDownloadManager.cpp
+++ b/src/Imap/Network/FileDownloadManager.cpp
@@ -37,6 +37,11 @@ namespace Imap
 namespace Network
 {
 
+FileDownloadManager::~FileDownloadManager()
+{
+    qDebug() << Q_FUNC_INFO << this;
+}
+
 FileDownloadManager::FileDownloadManager(QObject *parent, Imap::Network::MsgPartNetAccessManager *manager, const QModelIndex &partIndex):
     QObject(parent), manager(manager), partIndex(partIndex), reply(0), saved(false)
 {
diff --git a/src/Imap/Network/FileDownloadManager.h b/src/Imap/Network/FileDownloadManager.h
index 9786901..a655516 100644
--- a/src/Imap/Network/FileDownloadManager.h
+++ b/src/Imap/Network/FileDownloadManager.h
@@ -44,6 +44,7 @@ class FileDownloadManager : public QObject
     Q_OBJECT
 public:
     FileDownloadManager(QObject *parent, Imap::Network::MsgPartNetAccessManager *manager, const QModelIndex &partIndex);
+    ~FileDownloadManager();
     static QString toRealFileName(const QModelIndex &index);
     QVariant data(int role) const;
 private slots:
Thomas Lübking
Caspar Schutijser
Commit Hook
Jan Kundrát
Review request changed

Status: Closed (submitted)

Loading...