[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/sysadmin/libqapt/src
From:       Jonathan Michael Thomas <echidnaman () kubuntu ! org>
Date:       2010-12-17 14:44:43
Message-ID: 20101217144443.54AF3AC8AB () svn ! kde ! org
[Download RAW message or body]

SVN commit 1207318 by jmthomas:

Fix a small memory leak in PackagePrivate. We had a pointer that we new to in the \
Package constructor which we weren't deleting in the PackagePrivate destructor


 M  +1 -1      backend.cpp  
 M  +3 -4      package.cpp  


--- trunk/extragear/sysadmin/libqapt/src/backend.cpp #1207317:1207318
@@ -185,7 +185,7 @@
 
     pkgCache::PkgIterator iter;
     for (iter = depCache->PkgBegin(); !iter.end(); ++iter) {
-        if (iter->VersionList == 0) {
+        if (!iter->VersionList) {
             continue; // Exclude virtual packages.
         }
 
--- trunk/extragear/sysadmin/libqapt/src/package.cpp #1207317:1207318
@@ -50,6 +50,7 @@
 class PackagePrivate
 {
     public:
+        ~PackagePrivate() { delete packageIter; };
         QApt::Backend *backend;
         pkgDepCache *depCache;
         pkgRecords *records;
@@ -123,10 +124,8 @@
                  pkgRecords *records, pkgCache::PkgIterator &packageIter)
         : d(new PackagePrivate())
 {
-    // Passing the pkgIter by pointer from Backend results in a crash
-    // the first time you try to call a method needing it :(
-    // Probably because the pointer is created inside an iterator and
-    // is very temporary.
+    // We have to make our own pkgIterator, since the one passed here will
+    // keep on iterating while all the packages are being built
     d->packageIter = new pkgCache::PkgIterator(packageIter);
     d->backend = backend;
     d->records= records;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic