]> git.sur5r.net Git - minitube/commitdiff
Fixed small leak
authorFlavio <flavio@odisseo.local>
Wed, 26 Jan 2011 00:47:20 +0000 (01:47 +0100)
committerFlavio <flavio@odisseo.local>
Wed, 26 Jan 2011 00:47:20 +0000 (01:47 +0100)
src/downloaditem.cpp
src/downloaditem.h

index c5192e7ecb3fddc2c8f8508d4e1602fd7245b65f..4c26c87a3af808c6138d17315e964e4215b22795 100644 (file)
@@ -20,6 +20,11 @@ DownloadItem::DownloadItem(Video *video, QUrl url, QString filename, QObject *pa
     , m_status(Idle)
 { }
 
+DownloadItem::~DownloadItem() {
+    if (m_reply) delete m_reply;
+    if (video) delete video;
+}
+
 void DownloadItem::start() {
     m_reply = The::http()->simpleGet(m_url);
     init();
@@ -159,12 +164,12 @@ void DownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
         percent = bytesReceived * 100 / bytesTotal;
     }
 
-    // qDebug() << bytesReceived << bytesTotal;
+    // qDebug() << bytesReceived << bytesTotal << bytesTotal * .005 << m_downloadTime.msecsTo(now) << percent;
 
     if (m_status != Downloading
-        && bytesReceived > 1024 * 1024
+        && bytesReceived > 1024 * 512
         && bytesReceived > bytesTotal * .01
-        && m_downloadTime.msecsTo(now) > 2000 ) {
+        && m_downloadTime.msecsTo(now) > 1500 ) {
         m_status = Downloading;
         emit statusChanged();
     }
@@ -206,6 +211,7 @@ void DownloadItem::requestFinished() {
     m_reply = 0;
     m_finishedDownloading = true;
     if (!m_startedSaving) {
+        qDebug() << "Request finished but never started saving";
         return;
     }
     m_file.close();
index 7ccf4db87937c09818fbb37de77dba82603e8ef9..b4f59f50ca3e0eda45fdc510c33c3afa413dbd0f 100644 (file)
@@ -25,6 +25,7 @@ signals:
 
 public:
     DownloadItem(Video *video, QUrl url, QString filename, QObject *parent = 0);
+    ~DownloadItem();
     qint64 bytesTotal() const;
     qint64 bytesReceived() const;
     double remainingTime() const;