Ok, confirmed !

When canvas.drawRect( ... ) is given coords that will make it draw
outside of the canvas buffer (bitmap), it will throw a
NullPointerException.

This should NOT happen whatever the draw method is drawRect or other!

Any draw method MUST clip the coords to match the available drawing
area, and this should be stated in the Documentation of Canvas class,
and eventually inside every drawing method documentation.

For now we have to make a wrapper, to avoid this bug, and clip the
coords ourselves.
For rectangles, it's easy, but for other drawing primitives, it may be
problematic, if they also present this bug !


On 12 abr, 16:01, Rui Martins <[EMAIL PROTECTED]> wrote:
> Apparently, on M3, canvas.drawRect(...) will throw a
> NullPointerException, when the rectangle is out of the screen, zero
> area or something similar. Haven't tested on M5 either.
>
> Haven't debugged it further, just asking, maybe someone already knows
> the answer.
> So I can't quite exactly pinpoint the problem exactly.
>
> E/AndroidRuntime(1264): Uncaught handler: thread Main exiting due to
> uncaught exception
> E/AndroidRuntime(1264): java.lang.NullPointerException
> E/AndroidRuntime(1264):     at
> android.graphics.Canvas.drawRect(Canvas.java:661)
> E/AndroidRuntime(1264):     at
> net.ruimartins.app.unwind.GameMenuView.drawDataLines(GameMenuView.java:
> 645)
> E/AndroidRuntime(1264):     at
> net.ruimartins.app.unwind.GameMenuView.onDraw(GameMenuView.java:578)
> E/AndroidRuntime(1264):     at android.view.View.draw(View.java:3538)
> E/AndroidRuntime(1264):     at
> android.view.ViewGroup.drawChild(ViewGroup.java:674)
> E/AndroidRuntime(1264):     at
> android.view.ViewGroup.dispatchDraw(ViewGroup.java:572)
> E/AndroidRuntime(1264):     at android.view.View.draw(View.java:3514)
> E/AndroidRuntime(1264):     at
> android.widget.FrameLayout.draw(FrameLayout.java:197)
> E/AndroidRuntime(1264):     at
> android.view.ViewGroup.drawChild(ViewGroup.java:674)
> E/AndroidRuntime(1264):     at
> android.view.ViewGroup.dispatchDraw(ViewGroup.java:572)
> E/AndroidRuntime(1264):     at android.view.View.draw(View.java:3514)
> E/AndroidRuntime(1264):     at
> android.view.ViewGroup.drawChild(ViewGroup.java:674)
> E/AndroidRuntime(1264):     at
> android.view.ViewGroup.dispatchDraw(ViewGroup.java:572)
> E/AndroidRuntime(1264):     at android.view.View.draw(View.java:3514)
> E/AndroidRuntime(1264):     at
> android.widget.FrameLayout.draw(FrameLayout.java:197)
> E/AndroidRuntime(1264):     at
> android.view.ViewGroup.drawChild(ViewGroup.java:674)
> E/AndroidRuntime(1264):     at
> android.view.ViewGroup.dispatchDraw(ViewGroup.java:572)
> E/AndroidRuntime(1264):     at android.view.View.draw(View.java:3542)
> E/AndroidRuntime(1264):     at
> android.widget.FrameLayout.draw(FrameLayout.java:197)
> E/AndroidRuntime(1264):     at
> android.view.ViewRoot.draw(ViewRoot.java:483)
> E/AndroidRuntime(1264):     at
> android.view.ViewRoot.performTraversals(ViewRoot.java:379)
> E/AndroidRuntime(1264):     at
> android.view.ViewRoot.handleMessage(ViewRoot.java:547)
> E/AndroidRuntime(1264):     at
> android.os.Handler.dispatchMessage(Handler.java:80)
> E/AndroidRuntime(1264):     at android.os.Looper.loop(Looper.java:71)
> E/AndroidRuntime(1264):     at
> android.app.ActivityThread.main(ActivityThread.java:2506)
> E/AndroidRuntime(1264):     at
> java.lang.reflect.Method.invokeNative(Native Method)
> E/AndroidRuntime(1264):     at
> java.lang.reflect.Method.invoke(Method.java:380)
> E/AndroidRuntime(1264):     at android.os.ZygoteInit
> $MethodAndArgsCaller.run(ZygoteInit.java:1170)
> E/AndroidRuntime(1264):     at
> android.os.ZygoteInit.main(ZygoteInit.java:1121)
> E/AndroidRuntime(1264):     at android.dalvik.NativeStart.main(Native
> Method)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to