On Mon, Jun 09, 2008 at 02:42:53PM +0400, [EMAIL PROTECTED] was heard to say:
> Package: aptitude
> Version: 0.4.4-4
>
> Hello, i have this error when starting aptitude without any parameters:
> Необработанное исключение: vs_progress.cc:38: virtual void
> vs_progress::paint(const style&): Assertion "Percent>=0 && Percent<=100"
> failed.
>
> Необработанное исключение - in Russian is "unhandled exception"
I'm not sure why this started tripping, but it should be fixed by
changeset 1bbaf4b2801e (attached). If you're OK with building aptitude
on your computer, that ought to fix your problems. Otherwise, I'm not
sure there's a way to fix this other than waiting for someone to
backport aptitude for you or waiting for the lenny release.
Daniel
changeset: 655:1bbaf4b2801e
user: Daniel Burrows <[EMAIL PROTECTED]>
date: Sun May 20 20:10:33 2007 +0000
summary: [aptitude @ Don't assert that percentages are sane; instead, be robust by clamping them to [0, 100]. (Closes: #425145)]
diff -r 57818f62a48c -r 1bbaf4b2801e src/vs_progress.cc
--- a/src/vs_progress.cc Fri May 18 01:10:29 2007 +0000
+++ b/src/vs_progress.cc Sun May 20 20:10:33 2007 +0000
@@ -1,6 +1,6 @@
// vs_progress.cc
//
-// Copyright 2000, 2004-2006 Daniel Burrows
+// Copyright 2000, 2004-2007 Daniel Burrows
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -29,16 +29,33 @@
{
}
+namespace
+{
+ // Converts a percentage between 0 and 100 to an integer for
+ // display purposes. Out-of-range values are clamped, to avoid
+ // nasty boundary problems.
+ int convertPercent(double Percent)
+ {
+ int rval = (int)Percent;
+ if(rval < 0)
+ rval = 0;
+ if(rval > 100)
+ rval = 100;
+
+ return rval;
+ }
+}
+
void vs_progress::paint(const style &st)
{
int width=getmaxx();
if(!Op.empty())
{
- eassert(Percent>=0 && Percent<=100);
+ int truncPercent = convertPercent(Percent);
std::ostringstream percentstream;
- percentstream << " " << ((int) Percent) << "%";
+ percentstream << " " << truncPercent << "%";
std::string percentstr = percentstream.str();
mvaddstr(0, 0, transcode(Op));
@@ -55,7 +72,7 @@
point vs_progress::get_cursorloc()
{
- return point(int(Percent*getmaxx()/100.0), 0);
+ return point(int(convertPercent(Percent) * getmaxx() / 100.0), 0);
}
void vs_progress::Update()