sugarlabs / sugar-toolkit-gtk3

Sugar Learning Environment, Activity Toolkit, GTK 3.
GNU Lesser General Public License v2.1
21 stars 80 forks source link

Set value of "ph" to 0 if division by zero takes place #280

Closed erilyth closed 8 years ago

erilyth commented 8 years ago

The log is always filled with many of these errors where division by zero takes place especially when I drag objects from the clipboard to other places.

This is happening since the palette_dim.width is becoming 0 at times, so its rising the division by zero error.

tchx84 commented 8 years ago

Thanks for looking into this, can you provide a test case for reproducing this? I haven't being able to.

erilyth commented 8 years ago

To reproduce the error, 1)Copy something to the clipboard 2)Drag from the clipboard to any place and release

Try this a few times and you will get the division by zero error in the log.

samdroid-apps commented 8 years ago

Ah yes, can reproduce. I also get at the same time:

Traceback (most recent call last):
  File "/home/saam/sugar-build/build/out/install/lib/python2.7/site-packages/sugar3/graphics/animator.py", line 147, in _next_frame_cb
    animation.do_frame(current_time, self._duration, self._easing)
  File "/home/saam/sugar-build/build/out/install/lib/python2.7/site-packages/sugar3/graphics/animator.py", line 209, in do_frame
    self.next_frame(frame)
  File "/home/saam/sugar-build/build/out/install/lib/python2.7/site-packages/sugar3/graphics/palette.py", line 509, in next_frame
    self._palette.set_palette_state(Palette.SECONDARY)
  File "/home/saam/sugar-build/build/out/install/lib/python2.7/site-packages/sugar3/graphics/palettewindow.py", line 765, in set_palette_state
    self._set_palette_state(state)
  File "/home/saam/sugar-build/build/out/install/lib/python2.7/site-packages/sugar3/graphics/palette.py", line 450, in _set_palette_state
    self.update_position()
  File "/home/saam/sugar-build/build/out/install/lib/python2.7/site-packages/sugar3/graphics/palettewindow.py", line 640, in update_position
    position = invoker.get_position(req)
  File "/home/saam/sugar-build/build/out/install/lib/python2.7/site-packages/sugar3/graphics/palettewindow.py", line 915, in get_position
    alignment = self.get_alignment(palette_dim)
  File "/home/saam/sugar-build/build/out/install/lib/python2.7/site-packages/sugar3/graphics/palettewindow.py", line 943, in get_alignment
    ph = best_alignment[0]
TypeError: 'NoneType' object has no attribute '__getitem__'

But why even is the palette being shown when you release the drag? That shouldn't happen. Maybe that is the real bug?

quozl commented 8 years ago

Reviewed.