[Pkg-owncloud-commits] [owncloud-client] 06/27: Propagator: Fix crash when logging out during upload

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Jul 29 16:23:58 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 0202351a2783f63b85207753437149744d6c3d83
Author: Markus Goetz <markus at woboq.com>
Date:   Mon Jul 14 19:53:42 2014 +0200

    Propagator: Fix crash when logging out during upload
    
    Fixes #1957
---
 src/mirall/propagator_qnam.cpp | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index ea7b443..a4acd5d 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -119,14 +119,15 @@ void PropagateUploadFileQNAM::start()
 
 struct ChunkDevice : QIODevice {
 public:
-    QIODevice *_file;
+    QPointer<QIODevice> _file;
     qint64 _read;
     qint64 _size;
     qint64 _start;
 
     ChunkDevice(QIODevice *file,  qint64 start, qint64 size)
             : QIODevice(file), _file(file), _read(0), _size(size), _start(start) {
-        _file->seek(start);
+        _file = QPointer<QIODevice>(file);
+        _file.data()->seek(start);
     }
 
     virtual qint64 writeData(const char* , qint64 ) {
@@ -135,10 +136,15 @@ public:
     }
 
     virtual qint64 readData(char* data, qint64 maxlen) {
+        if (_file.isNull()) {
+            qDebug() << Q_FUNC_INFO << "Upload file object deleted during upload";
+            close();
+            return -1;
+        }
         maxlen = qMin(maxlen, chunkSize() - _read);
         if (maxlen == 0)
             return 0;
-        qint64 ret = _file->read(data, maxlen);
+        qint64 ret = _file.data()->read(data, maxlen);
         if (ret < 0)
             return -1;
         _read += ret;
@@ -146,7 +152,11 @@ public:
     }
 
     virtual bool atEnd() const {
-        return  _read >= chunkSize() || _file->atEnd();
+        if (_file.isNull()) {
+            qDebug() << Q_FUNC_INFO << "Upload file object deleted during upload";
+            return true;
+        }
+        return  _read >= chunkSize() || _file.data()->atEnd();
     }
 
     virtual qint64 size() const{
@@ -164,8 +174,13 @@ public:
     }
 
     virtual bool seek ( qint64 pos ) {
+        if (_file.isNull()) {
+            qDebug() << Q_FUNC_INFO << "Upload file object deleted during upload";
+            close();
+            return false;
+        }
         _read = pos;
-        return _file->seek(pos + _start);
+        return _file.data()->seek(pos + _start);
     }
 };
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list