Hi,

either of the following commits should fix this. The first one fixes the code
that produced this NaN, the second one makes sure that we (hopefully) handle
NaNs correctly:

http://git.naquadah.org/?p=awesome.git;a=commitdiff;h=0ac80ddf30cf5fdee294df18e69fb632befc47d5

http://git.naquadah.org/?p=awesome.git;a=commitdiff;h=db0014540691a11f98d7794ff4c22acc31e06d70


On 19.03.2014 07:10, John Kha wrote:
> Further investigation shows that when base.fit_widget is called on
> line 69, it is returning a NaN to w.

Yeah, and arithmetic involving a NaN always results in a NaN again, so...

> On Wed, Mar 19, 2014 at 12:51 AM, John Kha <sir...@gmail.com> wrote:
[...]
>>         local w, h = base.fit_widget(v, width, height)

...w and h are NaN here which means that...

>>         local in_dir, max
>>         if self.dir == "y" then
>>             max, in_dir = w, h
>>             height = height - in_dir
>>         else
>>             in_dir, max = w, h
>>             width = width - in_dir

...width becomes a NaN, too and thus...

>>         end
>>         if max > used_max then
>>             used_max = max
>>         end
>>         used_in_dir = used_in_dir + in_dir
>>         io.stderr:write("Break?\n")
>>         if width <= 0 or height <= 0 then

...this is false, because comparisons involving NaN are always(*) false.

>>             if self.dir == "y" then
>>                 used_in_dir = orig_height
>>             else
>>                 used_in_dir = orig_width
>>             end
>>             io. stderr:write" Break.\n"
>>             break
>>         end
>>     end
>>
>>     if self.dir == "y" then
>>         return used_max, used_in_dir
>>     end
>>     return used_in_dir, used_max
>> end
[...]
>> As you can see, the condition should be true as inner width is 0, but
>> you never get the "Break."
>> --
>> John C. Kha

Thanks a lot in looking into this and helping me figure it out!

Cheers,
Uli


(*):
$ lua -e 'a = 0/0 print(a, a == a)'
-nan    false
-- 
Bruce Schneier can read and understand Perl programs.

-- 
To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.

Reply via email to