GNOME Bugzilla – Bug 391646
cc_circle_set_radius calls cc_item_dirty with NULL view
Last modified: 2007-05-04 16:55:59 UTC
Steps to reproduce: 1. Appenda a CcCircle* c to a CcItem* i 2. Change the radius of c with cc_circle_set_radius(c, whatever) 3. The aplication segfaults Stack trace:
+ Trace 98532
Other information: Using git repository as of Mon Jan 1 10:02:44 CST 2007.
Created attachment 79153 [details] Example; triggers the bug This little example triggers the bug.
Created attachment 79155 [details] [review] Proposed patch The segfaults occur because cc_item_dirty is called with a NULL view. The analogous function cc_circle_set_anchor doesn't call cc_item_dirty, so I propose to remove the call and leave it to the user to call cc_item_dirty (as cc_circle_set_anchor does).
We shouldn't leave that to the application developer. The point is that a canvas should be easily usable and I just forgot to implement the dirty stuff in the circle for these properties. The reason is that the canvas item implementation has got a far better knowledge of the region that has to be repainted than the application developer can imagine. There are 2 ways of getting this right (and I prefer the first one): 1. Fix cc_item_dirty() to accept NULL views (and add g_return_if_fail(!view || CC_IS_VIEW(view))) and in case of a NULL view, call emit dirty on all the views. 2. Fix cc_circle_set_*() to not segfault by calling the iteraton in the item implementation.
Created attachment 79350 [details] [review] cc_item_dirty takes a NULL view I agree; the canvas should be easy to use. I modified cc_item_dirty so it can take a NULL view; in that case it emits the dirty signal to all the views of the item. I also modified the cc_circle_set_anchor function to call cc_item_dirty; I probed in the program I'm developing and so far it works.
I actually don't agree to the patch in cc-circle.c update-bounds is supposed to make sure the bounding box gets updated. So I proposed this way of getting it fixed: 1. Change cc_item_dirty() to also accept NULL (which the meaning of "the bounding box") 2. Change set_anchor() to call cc_item_dirty() (which NULL views and and NULL bbox) - this API will have to change when I rewrite the stuff to update BBoxes, Dirty regions etc. to be run async. 3. After cc_item_dirty() update the anchor point 4. Then update the bounding box 5. Then emit a new dirty event on the new bbox Also, some tests for this behavior would be very nice in the test suite.
Canek, may I put the example that triggers the bug under the same license as the rest of the testing system? http://beast.gtk.org/LICENSE-AS-ISh
*** Bug 432606 has been marked as a duplicate of this bug. ***
This bug is fixed in revision 4da4b3b9dc82d2360906cb8faf98c7da2ea7a07e on my master branch. Closing this bug once the licensing for the test case is clear.
Of course you can relicense the example; and all the code written by me related with CCC.
Great. Thanks a lot.