Decrease bandwidth from menu

Bug #483548 reported by Liszy Szilveszter on 2009-11-16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Guiodic (Guido Iodice)

Bug Description

When I select the Decrease bandwidth from the menu, it will decrease the speed with 11KB/s instead of 10KB/s.

description: updated

I tried and tried againg. And again. And again.. :)

But I was not able to reproduce the issue.

BaShare 0.5.0
Gambas 2.13
Os: Ubuntu Karmic

:S weird
it appeared between 1960-2000

BaShare 0.5.0
Gambas 2.13.1
Os: Ubuntu 9.10

ok, the bug is confirmed.

Changed in bashare:
status: New → Confirmed
importance: Undecided → Low
assignee: nobody → Guiodic (Guido Iodice) (guido-iodice)
Changed in bashare:
milestone: none → 0.5.1
Emilien Klein (emilien-klein) wrote :

From my quick analysis, the problem is a conversion problem:
In FMain.PiuBanda_Click(), you are getting "Vbanda" from "pausa" (1/pausa), then you change Vbanda (+10), then you convert that back to pausa (1/Vbanda) before finally displaying that, again converting it from pausa (1/pausa).

This makes that if there is an approximation due to the numbers after the comma, your integer is not 10, but 9.

I have noted this bug passing from 200 till 209...

Guido, you know best about how pausa and Vbanda are related, so I suppose you are the one that can fix this. In my opinion, you should keep those 2 separated, Vbanda to display, and pausa to do whatever you need to do with it. But right now you are making way too much conversions, so that's where this bug appears ;)

tags: added: band ui
tags: added: interface

@Emilien: yes, the problem is that.
I'll try to "play" with data types to increase precision.

well, it's not a solution :)

bug was fixed in 107 revision

Changed in bashare:
status: Confirmed → Fix Committed
Emilien Klein (emilien-klein) wrote :

Data types are not a solution, because your problem is conversion...
let's say you have band=200, and you increase by 10... This is what you do ()
(you keep "pausa" stored...)

1) What is the current band? 1/pausa = 1/0.005 = 200
2) Let's add 10: band = 200+10 = 210
3) What's pausa? 1/band = 1/210 = 0.0047619047619047619047619047619048 (I don't know Gambas' precision, but let's say that it uses something like 0.004775)
4) Let's display band! What's band? (you recalculate it from pausa, this is an error) 1/pausa = 1/0.004775 = 209.424XXXX
In the end, 209 will come out of it.

The numbers in this example are not 100% what BaShare uses, but is can be a good explanation of why we see this strange behavior.
I don't understand why you perform another calculation in step 4? You already now the new band at that stage, because it is either the original Vbanda+10, or MaxBanda. If you didn't recalculate this, but just reuse the value, we wouldn't have this bug...

And even better, instead of getting the current band from "pausa", you could store it in a global (I don't like it) or read it from what you have displayed in the interface. That way, you will always calculate pausa from the REAL band that is displayed...

I haven't tested the fix you put in rev 107, but I am almost sure that this will not remove this bug. We just cannot confirm that it will not happen with bigger numbers... The solution is to change the way pausa and banda get stored/calculated/displayed.

I used round(). So 1979.9 is converted in 1980 instead 1979.
This is better than have more variables.

Emilien Klein (emilien-klein) wrote :

I'm not proposing you add variables, I'm proposing you don't recalculate a value that you already have.

Why don't you do something like
    ME.labBand.text = Vbanda & " KB/s"
instead of
    ME.labBand.text = (Impostazioni.Calc_banda(pausa)) & " KB/s"

You already have the value of the band (either Vbanda +10, or MaxBanda), so just reuse it to display.

Emilien Klein (emilien-klein) wrote :

So I've had the time to test your fix, and it effectively appears to be fixed!
That's good news, but it also means that we will need to test it when fixing bug #480230 (Increase the maximum band) to see if it doesn't show up again, because in my opinion the root cause of the problem has not been fixed. But at least for now it works.

@emilien: I tried to do maxbanda=5000. BaShare increase and decrease the band correctly.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers