[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: What is OpProgress::Done's intended meaning? (documentation bug)



On Wed, Jun 22, 2005 at 09:52:49PM -0400, Daniel Burrows wrote:
> Package: libapt-pkg-dev
> Version: 0.6.36
> Severity: wishlist

Thanks for your mail.
 
>   I've been trying to work out some odd bugs involving the aptitude
> status bar being MIA, and I think that I finally found the right
> debugging angle to identify the problem.  When I wrote the internal
> progress bar, I assumed that OpProgress::Done indicated that the
> entire operation was done.  Thus, the progress bar is hidden as soon
> as Done() is called.  However, it appears that pkgDepCache::Init
> pkgDepCache::Init triggers a call to Done, followed by /more/ calls
> to Update() -- I haven't tracked down exactly why, but it seems
> likely that it's calling Done() when each *sub*operation completes.

If that is a regression to apt-0.5 that would be strange. Virtually
nothing changed in depcache.cc between 0.5->0.6.36 in debian. I
changed the behaviour my arch tree (apt--mvo--0), but that is not
released.

Here is a little test script (using python-apt--mvo--0):
-------------------------8<---------------------------
import apt
import apt_pkg

class TextProgress(apt.OpProgress):
        def Update(self,percent):
                if self.MajorChange:
                        print "%s (%s): %.2i" % (self.Op,self.SubOp,percent)
        def Done(self):
                print "Done"

apt_pkg.init()
p = TextProgress()
print "GetCache"
c = apt_pkg.GetCache(p)
d = apt_pkg.GetDepCache(c)
print "Init"
d.Init(p)
-------------------------8<---------------------------

and here is the output:
-------------------------8<-------------------------
GetCache
Reading package lists (): 00
Reading package lists (): 100
Done
Building dependency tree (Candidate versions): 00
Done
Init
Building dependency tree (): 00
Building dependency tree (Candidate versions): 00
-------------------------8<-------------------------

So it looks like "Done" is not called at all when depcache.Init() is
run on it's own (I changed that in apt--mvo--0). I also tested without
the "if self.MajorChange" and it does not change the behaviour (but
gives more output of course). Done is called twice when the cache is
opened (once for the pkgCache and once for the pkgDepCache). Could
that be the problem you are hunting for?

>   Is this how Done is intended to be used?  If so, I think it should be 
> clearly documented somewhere, as the name of the method alone is not very 
> illuminating.
 
I don't think so. I use it in synaptic in the same way as you (hide it
when Done() is called). But looking at the source again I make it
visible again if Update() is called and it's currently invisible.

Cheers,
 Michael

-- 
Linux is not The Answer. Yes is the answer. Linux is The Question. - Neo



Reply to: