Comment 2 for bug 830786

Revision history for this message
Jonathan Thomas (echidnaman) wrote : [libqapt/1.2] src/worker: Since deb file installation is an asynchronous process compared to installing packages via

Git commit 928a512050f38e186b34e6f06f63a9e5d711575e by Jonathan Thomas.
Committed on 27/08/2011 at 21:31.
Pushed by jmthomas into branch '1.2'.

Since deb file installation is an asynchronous process compared to installing packages via
APT, the QApt Worker's idle timeout was not being blocked during deb file installation.
This caused .deb file installations that went on for 30 seconds or longer to fail due to
the QApt Worker's idle timer timing out and quitting the process.

Fixes issues with the installation of Skype and Opera packages failing by appearing to hang.

BUG: 280890
CCMAIL: <email address hidden>
FIXED-IN:1.2.1, 1.2.65

M +7 -1 src/worker/worker.cpp
M +3 -0 src/worker/worker.h

http://commits.kde.org/libqapt/928a512050f38e186b34e6f06f63a9e5d711575e

diff --git a/src/worker/worker.cpp b/src/worker/worker.cpp
index 782b592..087d6d8 100644
--- a/src/worker/worker.cpp
+++ b/src/worker/worker.cpp
@@ -76,7 +76,10 @@ QAptWorker::QAptWorker(int &argc, char **argv)
         return;
     }

- QTimer::singleShot(30000, this, SLOT(quit()));
+ m_timeout = new QTimer(this);
+ connect(m_timeout, SIGNAL(timeout()), this, SLOT(quit()));
+ m_timeout->setSingleShot(true);
+ m_timeout->start(30000);
 }

 QAptWorker::~QAptWorker()
@@ -542,6 +545,7 @@ void QAptWorker::installDebFile(const QString &fileName)
         emit workerFinished(false);
         return;
     }
+ m_timeout->stop();

     emit workerStarted();

@@ -597,6 +601,8 @@ void QAptWorker::dpkgFinished(int exitCode, QProcess::ExitStatus exitStatus)
         emit workerEvent(QApt::DebInstallFinished);
     }

+ m_timeout->start();
+
     emit workerFinished(!exitStatus);
     delete m_dpkgProcess;
     m_dpkgProcess = 0;
diff --git a/src/worker/worker.h b/src/worker/worker.h
index e4b4bac..a2b1433 100644
--- a/src/worker/worker.h
+++ b/src/worker/worker.h
@@ -30,6 +30,7 @@ class pkgRecords;

 class QEventLoop;
 class QProcess;
+class QTimer;

 namespace QApt {
     class Cache;
@@ -54,12 +55,14 @@ private:
     pkgPolicy *m_policy;
     pkgRecords *m_records;
     bool m_systemLocked;
+ pid_t m_child_id;

     QVariantMap m_questionResponse;
     WorkerAcquire *m_acquireStatus;
     QEventLoop *m_questionBlock;
     QProcess *m_xapianProc;
     QProcess *m_dpkgProcess;
+ QTimer *m_timeout;

 public Q_SLOTS:
     void setLocale(const QString &locale) const;